mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
make 2fa wallets work on testnet
This commit is contained in:
parent
3838fdbdcc
commit
a32d27b9d7
2 changed files with 15 additions and 6 deletions
|
@ -128,7 +128,7 @@ class TestWalletKeystoreAddressIntegrity(unittest.TestCase):
|
||||||
long_user_id, short_id = trustedcoin.get_user_id(
|
long_user_id, short_id = trustedcoin.get_user_id(
|
||||||
{'x1/': {'xpub': xpub1},
|
{'x1/': {'xpub': xpub1},
|
||||||
'x2/': {'xpub': xpub2}})
|
'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)
|
ks3 = keystore.from_xpub(xpub3)
|
||||||
self._check_xpub_keystore_sanity(ks3)
|
self._check_xpub_keystore_sanity(ks3)
|
||||||
self.assertTrue(isinstance(ks3, keystore.BIP32_KeyStore))
|
self.assertTrue(isinstance(ks3, keystore.BIP32_KeyStore))
|
||||||
|
|
|
@ -43,8 +43,17 @@ from electrum.util import NotEnoughFunds
|
||||||
from electrum.storage import STO_EV_USER_PW
|
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 is hardcoded so that the wallet can be restored from seed, without TrustedCoin's server
|
||||||
signing_xpub = "xpub661MyMwAqRbcGnMkaTx2594P9EDuiEqMq25PM2aeG6UmwzaohgA6uDmNsvSUV8ubqwA3Wpste1hg69XHgjUuCD5HLcEp2QPzyV1HMrPppsL"
|
def get_signing_xpub():
|
||||||
billing_xpub = "xpub6DTBdtBB8qUmH5c77v8qVGVoYk7WjJNpGvutqjLasNG1mbux6KsojaLrYf2sRhXAVU4NaFuHhbD9SvVPRt1MB1MaMooRuhHcAZH1yhQ1qDU"
|
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
|
SEED_PREFIX = version.SEED_PREFIX_2FA
|
||||||
|
|
||||||
|
@ -307,7 +316,7 @@ def make_xpub(xpub, s):
|
||||||
|
|
||||||
def make_billing_address(wallet, num):
|
def make_billing_address(wallet, num):
|
||||||
long_id, short_id = wallet.get_user_id()
|
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)
|
version, _, _, _, c, cK = deserialize_xpub(xpub)
|
||||||
cK, c = bitcoin.CKD_pub(cK, c, num)
|
cK, c = bitcoin.CKD_pub(cK, c, num)
|
||||||
return bitcoin.public_key_to_p2pkh(cK)
|
return bitcoin.public_key_to_p2pkh(cK)
|
||||||
|
@ -484,7 +493,7 @@ class TrustedCoinPlugin(BasePlugin):
|
||||||
storage.put('x1/', k1.dump())
|
storage.put('x1/', k1.dump())
|
||||||
storage.put('x2/', k2.dump())
|
storage.put('x2/', k2.dump())
|
||||||
long_user_id, short_id = get_user_id(storage)
|
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)
|
k3 = keystore.from_xpub(xpub3)
|
||||||
storage.put('x3/', k3.dump())
|
storage.put('x3/', k3.dump())
|
||||||
|
|
||||||
|
@ -501,7 +510,7 @@ class TrustedCoinPlugin(BasePlugin):
|
||||||
xpub2 = wizard.storage.get('x2/')['xpub']
|
xpub2 = wizard.storage.get('x2/')['xpub']
|
||||||
# Generate third key deterministically.
|
# Generate third key deterministically.
|
||||||
long_user_id, short_id = get_user_id(wizard.storage)
|
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
|
# secret must be sent by the server
|
||||||
try:
|
try:
|
||||||
r = server.create(xpub1, xpub2, email)
|
r = server.create(xpub1, xpub2, email)
|
||||||
|
|
Loading…
Add table
Reference in a new issue