async def all_done(new_words): # So we have another part, might be done or not. global import_xor_parts assert len(new_words) == 24 import_xor_parts.append(new_words) XORWordNestMenu.pop_all() num_parts = len(import_xor_parts) seed = xor32(*(bip39.a2b_words(w) for w in import_xor_parts)) msg = "You've entered %d parts so far.\n\n" % num_parts if num_parts >= 2: chk_word = bip39.b2a_words(seed).split(' ')[-1] msg += "If you stop now, the 24th word of the XOR-combined seed phrase\nwill be:\n\n" msg += "24: %s\n\n" % chk_word if all((not x) for x in seed): # zero seeds are never right. msg += "ZERO WARNING\nProvided seed works out to all zeros "\ "right now. You may have doubled a part or made some other mistake.\n\n" msg += "Press (1) to enter next list of words, or (2) if done with all words." ch = await ux_show_story(msg, strict_escape=True, escape='12x', sensitive=True) if ch == 'x': # give up import_xor_parts.clear() # concern: we are contaminated w/ secrets return None elif ch == '1': # do another list of words nxt = XORWordNestMenu(num_words=24) the_ux.push(nxt) elif ch == '2': # done; import on temp basis, or be the main secret from pincodes import pa enc = stash.SecretStash.encode(seed_phrase=seed) if pa.is_secret_blank(): # save it since they have no other secret set_seed_value(encoded=enc) # update menu contents now that wallet defined goto_top_menu() else: pa.tmp_secret(enc) await ux_show_story( "New master key in effect until next power down.") return None
xfp = sys.argv[sys.argv.index('--xfp') + 1] sim_defaults['xfp'] = unpack("<I", a2b_hex(xfp))[0] print("Override XFP: " + xfp2str(sim_defaults['xfp'])) if '--seed' in sys.argv: # --xfp aabbccdd => pretend we know that key (won't be able to sign) from ustruct import unpack from utils import xfp2str from seed import set_seed_value from main import pa, settings words = sys.argv[sys.argv.index('--seed') + 1].split(' ') assert len(words) == 24, "Expected 24 space-separated words: add some quotes" pa.pin = b'12-12' set_seed_value(words) settings.set('terms_ok', 1) settings.set('_skip_pin', '12-12') settings.set('chain', 'XTN') print("Seed phrase set, resulting XFP: " + xfp2str(settings.get('xfp'))) if '-g' in sys.argv: # do login sim_defaults.pop('_skip_pin', 0) if '--nick' in sys.argv: nick = sys.argv[sys.argv.index('--nick') + 1] sim_defaults['nick'] = nick sim_defaults['terms_ok'] = 1 sim_defaults.pop('_skip_pin', 0)
# load up the simulator w/ indicated list of seed words import tcc, main from sim_settings import sim_defaults import stash, chains from h import b2a_hex from main import settings, pa from stash import SecretStash, SensitiveValues from seed import set_seed_value tn = chains.BitcoinTestnet if 1: settings.current = sim_defaults settings.set('chain', 'XTN') set_seed_value(main.WORDS) print("New key in effect: %s" % settings.get('xpub', 'MISSING')) print("Fingerprint: 0x%08x" % settings.get('xfp', 0)) #assert settings.get('xfp', 0) == node.my_fingerprint()