def test_bip39_seeds(monkeypatch, setup_wallet, entropy, mnemonic, key, xpriv): jm_single().config.set('BLOCKCHAIN', 'network', 'mainnet') created_entropy = SegwitLegacyWallet.entropy_from_mnemonic(mnemonic) assert entropy == hexlify(created_entropy).decode('ascii') storage = VolatileStorage() SegwitLegacyWallet.initialize( storage, get_network(), entropy=created_entropy, entropy_extension='TREZOR', max_mixdepth=4) wallet = SegwitLegacyWallet(storage) assert (mnemonic, b'TREZOR') == wallet.get_mnemonic_words() assert key == hexlify(wallet._create_master_key()).decode('ascii') # need to monkeypatch this, else we'll default to the BIP-49 path monkeypatch.setattr(SegwitLegacyWallet, '_get_bip32_base_path', BIP32Wallet._get_bip32_base_path) assert xpriv == wallet.get_bip32_priv_export()
def test_bip49_seed(monkeypatch, setup_wallet): jm_single().config.set('BLOCKCHAIN', 'network', 'testnet') mnemonic = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about' master_xpriv = 'tprv8ZgxMBicQKsPe5YMU9gHen4Ez3ApihUfykaqUorj9t6FDqy3nP6eoXiAo2ssvpAjoLroQxHqr3R5nE3a5dU3DHTjTgJDd7zrbniJr6nrCzd' account0_xpriv = 'tprv8gRrNu65W2Msef2BdBSUgFdRTGzC8EwVXnV7UGS3faeXtuMVtGfEdidVeGbThs4ELEoayCAzZQ4uUji9DUiAs7erdVskqju7hrBcDvDsdbY' addr0_script_hash = '336caa13e08b96080a32b5d818d59b4ab3b36742' entropy = SegwitLegacyWallet.entropy_from_mnemonic(mnemonic) storage = VolatileStorage() SegwitLegacyWallet.initialize( storage, get_network(), entropy=entropy, max_mixdepth=0) wallet = SegwitLegacyWallet(storage) assert (mnemonic, None) == wallet.get_mnemonic_words() assert account0_xpriv == wallet.get_bip32_priv_export(0) assert addr0_script_hash == hexlify(wallet.get_external_script(0)[2:-1]).decode('ascii') # FIXME: is this desired behaviour? BIP49 wallet will not return xpriv for # the root key but only for key after base path monkeypatch.setattr(SegwitLegacyWallet, '_get_bip32_base_path', BIP32Wallet._get_bip32_base_path) assert master_xpriv == wallet.get_bip32_priv_export()