tMerge pull request #3514 from SomberNight/2fa_testnet - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 03b40a3c0a7dd84e76bc0d0ea2ad390dafc92250 DIR parent 98cdbe37714b23b2826b18276a789cf98ca98510 HTML Author: ThomasV <thomasv@electrum.org> Date: Tue, 27 Feb 2018 00:50:09 +0100 Merge pull request #3514 from SomberNight/2fa_testnet make 2fa wallets work on testnet Diffstat: M lib/tests/test_wallet_vertical.py | 2 +- M plugins/trustedcoin/trustedcoin.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) --- DIR diff --git a/lib/tests/test_wallet_vertical.py b/lib/tests/test_wallet_vertical.py t@@ -128,7 +128,7 @@ class TestWalletKeystoreAddressIntegrity(unittest.TestCase): long_user_id, short_id = trustedcoin.get_user_id( {'x1/': {'xpub': xpub1}, 'x2/': {'xpub': xpub2}}) - xpub3 = trustedcoin.make_xpub(trustedcoin.signing_xpub, long_user_id) + xpub3 = trustedcoin.make_xpub(trustedcoin.get_signing_xpub(), long_user_id) ks3 = keystore.from_xpub(xpub3) self._check_xpub_keystore_sanity(ks3) self.assertTrue(isinstance(ks3, keystore.BIP32_KeyStore)) DIR diff --git a/plugins/trustedcoin/trustedcoin.py b/plugins/trustedcoin/trustedcoin.py t@@ -43,8 +43,17 @@ from electrum.util import NotEnoughFunds from electrum.storage import STO_EV_USER_PW # signing_xpub is hardcoded so that the wallet can be restored from seed, without TrustedCoin's server -signing_xpub = "xpub661MyMwAqRbcGnMkaTx2594P9EDuiEqMq25PM2aeG6UmwzaohgA6uDmNsvSUV8ubqwA3Wpste1hg69XHgjUuCD5HLcEp2QPzyV1HMrPppsL" -billing_xpub = "xpub6DTBdtBB8qUmH5c77v8qVGVoYk7WjJNpGvutqjLasNG1mbux6KsojaLrYf2sRhXAVU4NaFuHhbD9SvVPRt1MB1MaMooRuhHcAZH1yhQ1qDU" +def get_signing_xpub(): + if NetworkConstants.TESTNET: + return "tpubD6NzVbkrYhZ4XdmyJQcCPjQfg6RXVUzGFhPjZ7uvRC8JLcS7Hw1i7UTpyhp9grHpak4TyK2hzBJrujDVLXQ6qB5tNpVx9rC6ixijUXadnmY" + else: + return "xpub661MyMwAqRbcGnMkaTx2594P9EDuiEqMq25PM2aeG6UmwzaohgA6uDmNsvSUV8ubqwA3Wpste1hg69XHgjUuCD5HLcEp2QPzyV1HMrPppsL" + +def get_billing_xpub(): + if NetworkConstants.TESTNET: + return "tpubD6NzVbkrYhZ4X11EJFTJujsYbUmVASAYY7gXsEt4sL97AMBdypiH1E9ZVTpdXXEy3Kj9Eqd1UkxdGtvDt5z23DKsh6211CfNJo8bLLyem5r" + else: + return "xpub6DTBdtBB8qUmH5c77v8qVGVoYk7WjJNpGvutqjLasNG1mbux6KsojaLrYf2sRhXAVU4NaFuHhbD9SvVPRt1MB1MaMooRuhHcAZH1yhQ1qDU" SEED_PREFIX = version.SEED_PREFIX_2FA t@@ -307,7 +316,7 @@ def make_xpub(xpub, s): def make_billing_address(wallet, num): long_id, short_id = wallet.get_user_id() - xpub = make_xpub(billing_xpub, long_id) + xpub = make_xpub(get_billing_xpub(), long_id) version, _, _, _, c, cK = deserialize_xpub(xpub) cK, c = bitcoin.CKD_pub(cK, c, num) return bitcoin.public_key_to_p2pkh(cK) t@@ -484,7 +493,7 @@ class TrustedCoinPlugin(BasePlugin): storage.put('x1/', k1.dump()) storage.put('x2/', k2.dump()) long_user_id, short_id = get_user_id(storage) - xpub3 = make_xpub(signing_xpub, long_user_id) + xpub3 = make_xpub(get_signing_xpub(), long_user_id) k3 = keystore.from_xpub(xpub3) storage.put('x3/', k3.dump()) t@@ -501,7 +510,7 @@ class TrustedCoinPlugin(BasePlugin): xpub2 = wizard.storage.get('x2/')['xpub'] # Generate third key deterministically. long_user_id, short_id = get_user_id(wizard.storage) - xpub3 = make_xpub(signing_xpub, long_user_id) + xpub3 = make_xpub(get_signing_xpub(), long_user_id) # secret must be sent by the server try: r = server.create(xpub1, xpub2, email)