|
|
@ -17,7 +17,7 @@ from electrum.mnemonic import seed_type |
|
|
|
from electrum.plugins.trustedcoin import trustedcoin |
|
|
|
|
|
|
|
from . import TestCaseForTestnet |
|
|
|
from . import SequentialTestCase |
|
|
|
from . import ElectrumTestCase |
|
|
|
from .test_bitcoin import needs_test_with_all_ecc_implementations |
|
|
|
|
|
|
|
|
|
|
@ -45,25 +45,26 @@ class WalletIntegrityHelper: |
|
|
|
test_obj.assertFalse(ks.has_seed()) |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def create_standard_wallet(cls, ks, gap_limit=None): |
|
|
|
def create_standard_wallet(cls, ks, *, config: SimpleConfig, gap_limit=None): |
|
|
|
store = storage.WalletStorage('if_this_exists_mocking_failed_648151893') |
|
|
|
store.put('keystore', ks.dump()) |
|
|
|
store.put('gap_limit', gap_limit or cls.gap_limit) |
|
|
|
w = Standard_Wallet(store) |
|
|
|
w = Standard_Wallet(store, config=config) |
|
|
|
w.synchronize() |
|
|
|
return w |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def create_imported_wallet(cls, privkeys=False): |
|
|
|
def create_imported_wallet(cls, *, config: SimpleConfig, privkeys: bool): |
|
|
|
store = storage.WalletStorage('if_this_exists_mocking_failed_648151893') |
|
|
|
if privkeys: |
|
|
|
k = keystore.Imported_KeyStore({}) |
|
|
|
store.put('keystore', k.dump()) |
|
|
|
w = Imported_Wallet(store) |
|
|
|
w = Imported_Wallet(store, config=config) |
|
|
|
return w |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def create_multisig_wallet(cls, keystores: Sequence, multisig_type: str, gap_limit=None): |
|
|
|
def create_multisig_wallet(cls, keystores: Sequence, multisig_type: str, *, |
|
|
|
config: SimpleConfig, gap_limit=None): |
|
|
|
"""Creates a multisig wallet.""" |
|
|
|
store = storage.WalletStorage('if_this_exists_mocking_failed_648151893') |
|
|
|
for i, ks in enumerate(keystores): |
|
|
@ -71,12 +72,16 @@ class WalletIntegrityHelper: |
|
|
|
store.put('x%d/' % cosigner_index, ks.dump()) |
|
|
|
store.put('wallet_type', multisig_type) |
|
|
|
store.put('gap_limit', gap_limit or cls.gap_limit) |
|
|
|
w = Multisig_Wallet(store) |
|
|
|
w = Multisig_Wallet(store, config=config) |
|
|
|
w.synchronize() |
|
|
|
return w |
|
|
|
|
|
|
|
|
|
|
|
class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
class TestWalletKeystoreAddressIntegrityForMainnet(ElectrumTestCase): |
|
|
|
|
|
|
|
def setUp(self): |
|
|
|
super().setUp() |
|
|
|
self.config = SimpleConfig({'electrum_path': self.electrum_path}) |
|
|
|
|
|
|
|
@needs_test_with_all_ecc_implementations |
|
|
|
@mock.patch.object(storage.WalletStorage, '_write') |
|
|
@ -92,7 +97,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
self.assertEqual(ks.xprv, 'xprv9s21ZrQH143K32jECVM729vWgGq4mUDJCk1ozqAStTphzQtCTuoFmFafNoG1g55iCnBTXUzz3zWnDb5CVLGiFvmaZjuazHDL8a81cPQ8KL6') |
|
|
|
self.assertEqual(ks.xpub, 'xpub661MyMwAqRbcFWohJWt7PHsFEJfZAvw9ZxwQoDa4SoMgsDDM1T7WK3u9E4edkC4ugRnZ8E4xDZRpk8Rnts3Nbt97dPwT52CwBdDWroaZf8U') |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2pkh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '1NNkttn1YvVGdqBW4PR6zvc3Zx3H5owKRf') |
|
|
@ -112,7 +117,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
self.assertEqual(ks.xprv, 'zprvAZswDvNeJeha8qZ8g7efN3FXYVJLaEUsE9TW6qXDEbVe74AZ75c2sZFZXPNFzxnhChDQ89oC8C5AjWwHmH1HeRKE1c4kKBQAmjUDdKDUZw2') |
|
|
|
self.assertEqual(ks.xpub, 'zpub6nsHdRuY92FsMKdbn9BfjBCG6X8pyhCibNP6uDvpnw2cyrVhecvHRMa3Ne8kdJZxjxgwnpbHLkcR4bfnhHy6auHPJyDTQ3kianeuVLdkCYQ') |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2wpkh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], 'bc1q3g5tmkmlvxryhh843v4dz026avatc0zzr6h3af') |
|
|
@ -132,7 +137,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
self.assertEqual(ks.xprv, 'zprvAZDmEQiCLUcZXPfrBXoksCD2R6RMAzAre7SUyBotibisy9c7vGhLYvHaP3d9rYU12DKAWdZfscPNA7qEPgTkCDqX5sE93ryAJAQvkDbfLxU') |
|
|
|
self.assertEqual(ks.xpub, 'zpub6nD7dvF6ArArjskKHZLmEL9ky8FqaSti1LN5maDWGwFrqwwGTp1b6ic4EHwciFNaYDmCXcQYxXSiF9BjcLCMPcaYkVN2nQD6QjYQ8vpSR3Z') |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2wpkh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], 'bc1qx94dutas7ysn2my645cyttujrms5d9p57f6aam') |
|
|
@ -151,7 +156,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
|
|
|
|
self.assertEqual(ks.mpk, 'e9d4b7866dd1e91c862aebf62a49548c7dbf7bcc6e4b7b8c9da820c7737968df9c09d5a3e271dc814a29981f81b3faaf2737b551ef5dcc6189cf0f8252c442b3') |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2pkh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '1FJEEB8ihPMbzs2SkLmr37dHyRFzakqUmo') |
|
|
@ -186,7 +191,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
WalletIntegrityHelper.check_xpub_keystore_sanity(self, ks3) |
|
|
|
self.assertTrue(isinstance(ks3, keystore.BIP32_KeyStore)) |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2, ks3], '2of3') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2, ks3], '2of3', config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2sh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '35L8XmCDoEBKeaWRjvmZvoZvhp8BXMMMPV') |
|
|
@ -221,7 +226,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
WalletIntegrityHelper.check_xpub_keystore_sanity(self, ks3) |
|
|
|
self.assertTrue(isinstance(ks3, keystore.BIP32_KeyStore)) |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2, ks3], '2of3') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2, ks3], '2of3', config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2wsh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], 'bc1qpmufh0zjp5prfsrk2yskcy82sa26srqkd97j0457andc6m0gh5asw7kqd2') |
|
|
@ -240,7 +245,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
self.assertEqual(ks.xprv, 'xprv9zGLcNEb3cHUKizLVBz6RYeE9bEZAVPjH2pD1DEzCnPcsemWc3d3xTao8sfhfUmDLMq6e3RcEMEvJG1Et8dvfL8DV4h7mwm9J6AJsW9WXQD') |
|
|
|
self.assertEqual(ks.xpub, 'xpub6DFh1smUsyqmYD4obDX6ngaxhd53Zx7aeFjoobebm7vbkT6f9awJWFuGzBT9FQJEWFBL7UyhMXtYzRcwDuVbcxtv9Ce2W9eMm4KXLdvdbjv') |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2pkh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '16j7Dqk3Z9DdTdBtHcCVLaNQy9MTgywUUo') |
|
|
@ -259,7 +264,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
self.assertEqual(ks.xprv, 'xprv9z8izheguGnLopSqkY7GcGFrP2Gu6rzBvvHo6uB9B8DWJhsows6WDZAsbBTaP3ncP2AVbTQphyEQkahrB9s1L7ihZtfz5WGQPMbXwsUtSik') |
|
|
|
self.assertEqual(ks.xpub, 'xpub6D85QDBajeLe2JXJrZeGyQCaw47PWKi3J9DPuHakjTkVBWCxVQQkmMVMSSfnw39tj9FntbozpRtb1AJ8ubjeVSBhyK4M5mzdvsXZzKPwodT') |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2pkh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '1F88g2naBMhDB7pYFttPWGQgryba3hPevM') |
|
|
@ -278,7 +283,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
self.assertEqual(ks.xprv, 'yprvAJEYHeNEPcyBoQYM7sGCxDiNCTX65u4ANgZuSGTrKN5YCC9MP84SBayrgaMyZV7zvkHrr3HVPTK853s2SPk4EttPazBZBmz6QfDkXeE8Zr7') |
|
|
|
self.assertEqual(ks.xpub, 'ypub6XDth9u8DzXV1tcpDtoDKMf6kVMaVMn1juVWEesTshcX4zUVvfNgjPJLXrD9N7AdTLnbHFL64KmBn3SNaTe69iZYbYCqLCCNPZKbLz9niQ4') |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2wpkh-p2sh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '35ohQTdNykjkF1Mn9nAVEFjupyAtsPAK1W') |
|
|
@ -298,7 +303,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
self.assertEqual(ks.xprv, 'zprvAdG4iTXWBoARxkkzNpNh8r6Qag3irQB8PzEMkAFeTRXxHpbF9z4QgEvBRmfvqWvGp42t42nvgGpNgYSJA9iefm1yYNZKEm7z6qUWCroSQnE') |
|
|
|
self.assertEqual(ks.xpub, 'zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs') |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2wpkh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], 'bc1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu') |
|
|
@ -321,7 +326,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
WalletIntegrityHelper.check_xpub_keystore_sanity(self, ks2) |
|
|
|
self.assertTrue(isinstance(ks2, keystore.BIP32_KeyStore)) |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2], '2of2') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2], '2of2', config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2sh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '32ji3QkAgXNz6oFoRfakyD3ys1XXiERQYN') |
|
|
@ -344,7 +349,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
WalletIntegrityHelper.check_xpub_keystore_sanity(self, ks2) |
|
|
|
self.assertTrue(isinstance(ks2, keystore.BIP32_KeyStore)) |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2], '2of2') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2], '2of2', config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2wsh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], 'bc1qvzezdcv6vs5h45ugkavp896e0nde5c5lg5h0fwe2xyfhnpkxq6gq7pnwlc') |
|
|
@ -367,7 +372,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
WalletIntegrityHelper.check_xpub_keystore_sanity(self, ks2) |
|
|
|
self.assertTrue(isinstance(ks2, keystore.BIP32_KeyStore)) |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2], '2of2') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2], '2of2', config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2sh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '3JPTQ2nitVxXBJ1yhMeDwH6q417UifE3bN') |
|
|
@ -389,7 +394,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
WalletIntegrityHelper.check_xpub_keystore_sanity(self, ks2) |
|
|
|
self.assertTrue(isinstance(ks2, keystore.BIP32_KeyStore)) |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2], '2of2') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2], '2of2', config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2wsh-p2sh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '35LeC45QgCVeRor1tJD6LiDgPbybBXisns') |
|
|
@ -414,42 +419,42 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
self.assertEqual('02bf27f41683d84183e4e930e66d64fc8af5508b4b5bf3c473c505e4dbddaeed80', ks.derive_pubkey(1, 0)) |
|
|
|
|
|
|
|
ks = create_keystore_from_bip32seed(xtype='standard') # p2pkh |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, config=self.config) |
|
|
|
self.assertEqual(ks.xprv, 'xprv9s21ZrQH143K3nyWMZVjzGL4KKAE1zahmhTHuV5pdw4eK3o3igC5QywgQG7UTRe6TGBniPDpPFWzXMeMUFbBj8uYsfXGjyMmF54wdNt8QBm') |
|
|
|
self.assertEqual(ks.xpub, 'xpub661MyMwAqRbcGH3yTb2kMQGnsLziRTJZ8vNthsVSCGbdBr8CGDWKxnGAFYgyKTzBtwvPPmfVAWJuFmxRXjSbUTg87wDkWQ5GmzpfUcN9t8Z') |
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '19fWEVaXqgJFFn7JYNr6ouxyjZy3uK7CdK') |
|
|
|
self.assertEqual(w.get_change_addresses()[0], '1EEX7da31qndYyeKdbM665w1ze5gbkkAZZ') |
|
|
|
|
|
|
|
ks = create_keystore_from_bip32seed(xtype='p2wpkh-p2sh') |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, config=self.config) |
|
|
|
self.assertEqual(ks.xprv, 'yprvABrGsX5C9janu6AdBvHNCMRZVHJfxcaCgoyWgsyi1wSXN9cGyLMe33bpRU54TLJ1ruJbTrpNqusYQeFvBx1CXNb9k1DhKtBFWo8b1sLbXhN') |
|
|
|
self.assertEqual(ks.xpub, 'ypub6QqdH2c5z7967aF6HwpNZVNJ3K9AN5J442u7VGPKaGyWEwwRWsftaqvJGkeZKNe7Jb3C9FG3dAfT94ZzFRrcGhMizGvB6Jtm3itJsEFhxMC') |
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '34SAT5gGF5UaBhhSZ8qEuuxYvZ2cm7Zi23') |
|
|
|
self.assertEqual(w.get_change_addresses()[0], '38unULZaetSGSKvDx7Krukh8zm8NQnxGiA') |
|
|
|
|
|
|
|
ks = create_keystore_from_bip32seed(xtype='p2wpkh') |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, config=self.config) |
|
|
|
self.assertEqual(ks.xprv, 'zprvAWgYBBk7JR8GkPMk2H4zQSX4fFT7uEZhbvVjUGsbPwpQRFRWDzXCf7FxSg2eTEwwGYRQDLQwJaE6HvsUueRDKcGkcLv7unzjnXCEQVWhrF9') |
|
|
|
self.assertEqual(ks.xpub, 'zpub6jftahH18ngZxsSD8JbzmaToDHHcJhHYy9RLGfHCxHMPJ3kemXqTCuaSHxc9KHJ2iE9ztirc5q212MBYy8Gd4w3KrccbgDiFKSwxFpYKEH6') |
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], 'bc1qtuynwzd0d6wptvyqmc6ehkm70zcamxpshyzu5e') |
|
|
|
self.assertEqual(w.get_change_addresses()[0], 'bc1qjy5zunxh6hjysele86qqywfa437z4xwmleq8wk') |
|
|
|
|
|
|
|
ks = create_keystore_from_bip32seed(xtype='standard') # p2sh |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks], '1of1') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks], '1of1', config=self.config) |
|
|
|
self.assertEqual(ks.xprv, 'xprv9s21ZrQH143K3nyWMZVjzGL4KKAE1zahmhTHuV5pdw4eK3o3igC5QywgQG7UTRe6TGBniPDpPFWzXMeMUFbBj8uYsfXGjyMmF54wdNt8QBm') |
|
|
|
self.assertEqual(ks.xpub, 'xpub661MyMwAqRbcGH3yTb2kMQGnsLziRTJZ8vNthsVSCGbdBr8CGDWKxnGAFYgyKTzBtwvPPmfVAWJuFmxRXjSbUTg87wDkWQ5GmzpfUcN9t8Z') |
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '3F4nm8Vunb7mxVvqhUP238PYge2hpU5qYv') |
|
|
|
self.assertEqual(w.get_change_addresses()[0], '3N8jvKGmxzVHENn6B4zTdZt3N9bmRKjj96') |
|
|
|
|
|
|
|
ks = create_keystore_from_bip32seed(xtype='p2wsh-p2sh') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks], '1of1') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks], '1of1', config=self.config) |
|
|
|
self.assertEqual(ks.xprv, 'YprvANkMzkodih9AKfL18akM2RmND5LwAyFo15dBc9FFPiGvzLBBjjjv8ATkEB2Y1mWv6NNaLSpVj8G3XosgVBA9frhpaUL6jHeFQXQTbqVPcv2') |
|
|
|
self.assertEqual(ks.xpub, 'Ypub6bjiQGLXZ4hTY9QUEcHMPZi6m7BRaRyeNJYnQXerx3ous8WLHH4AfxnE5Tc2sos1Y47B1qGAWP3xGEBkYf1ZRBUPpk2aViMkwTABT6qoiBb') |
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '3L1BxLLASGKE3DR1ruraWm3hZshGCKqcJx') |
|
|
|
self.assertEqual(w.get_change_addresses()[0], '3NDGcbZVXTpaQWRhiuVPpXsNt4g2JiCX4E') |
|
|
|
|
|
|
|
ks = create_keystore_from_bip32seed(xtype='p2wsh') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks], '1of1') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks], '1of1', config=self.config) |
|
|
|
self.assertEqual(ks.xprv, 'ZprvAhadJRUYsNgeAxX7xwXyEWrsP3VP7bFHvC9QPY98miep3RzQzPuUkE7tFNz81gAqW1VP5vR4BncbR6VFCsaAU6PRSp2XKCTjgFU6zRpk6Xp') |
|
|
|
self.assertEqual(ks.xpub, 'Zpub6vZyhw1ShkEwPSbb4y4ybeobw5KsX3y9HR51BvYkL4BnvEKZXwDjJ2SN6fZcsiWvwhDymJriy3QW9WoKGMRaDR9zh5j15dBFDBDpqjK1ekQ') |
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], 'bc1q84x0yrztvcjg88qef4d6978zccxulcmc9y88xcg4ghjdau999x7q7zv2qe') |
|
|
@ -458,6 +463,10 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): |
|
|
|
|
|
|
|
class TestWalletKeystoreAddressIntegrityForTestnet(TestCaseForTestnet): |
|
|
|
|
|
|
|
def setUp(self): |
|
|
|
super().setUp() |
|
|
|
self.config = SimpleConfig({'electrum_path': self.electrum_path}) |
|
|
|
|
|
|
|
@mock.patch.object(storage.WalletStorage, '_write') |
|
|
|
def test_bip39_multisig_seed_p2sh_segwit_testnet(self, mock_write): |
|
|
|
# bip39 seed: finish seminar arrange erosion sunny coil insane together pretty lunch lunch rose |
|
|
@ -473,7 +482,7 @@ class TestWalletKeystoreAddressIntegrityForTestnet(TestCaseForTestnet): |
|
|
|
WalletIntegrityHelper.check_xpub_keystore_sanity(self, ks2) |
|
|
|
self.assertTrue(isinstance(ks2, keystore.BIP32_KeyStore)) |
|
|
|
|
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2], '2of2') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2], '2of2', config=self.config) |
|
|
|
self.assertEqual(w.txin_type, 'p2wsh-p2sh') |
|
|
|
|
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '2MzsfTfTGomPRne6TkctMmoDj6LwmVkDrMt') |
|
|
@ -498,42 +507,42 @@ class TestWalletKeystoreAddressIntegrityForTestnet(TestCaseForTestnet): |
|
|
|
self.assertEqual('02bf27f41683d84183e4e930e66d64fc8af5508b4b5bf3c473c505e4dbddaeed80', ks.derive_pubkey(1, 0)) |
|
|
|
|
|
|
|
ks = create_keystore_from_bip32seed(xtype='standard') # p2pkh |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, config=self.config) |
|
|
|
self.assertEqual(ks.xprv, 'tprv8ZgxMBicQKsPecD328MF9ux3dSaSFWci7FNQmuWH7uZ86eY8i3XpvjK8KSH8To2QphiZiUqaYc6nzDC6bTw8YCB9QJjaQL5pAApN4z7vh2B') |
|
|
|
self.assertEqual(ks.xpub, 'tpubD6NzVbkrYhZ4Y5Epun1qZKcACU6NQqocgYyC4RYaYBMWw8nuLSMR7DvzVamkqxwRgrTJ1MBMhc8wwxT2vbHqMu8RBXy4BvjWMxR5EdZroxE') |
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], 'mpBTXYfWehjW2tavFwpUdqBJbZZkup13k2') |
|
|
|
self.assertEqual(w.get_change_addresses()[0], 'mtkUQgf1psDtL67wMAKTv19LrdgPWy6GDQ') |
|
|
|
|
|
|
|
ks = create_keystore_from_bip32seed(xtype='p2wpkh-p2sh') |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, config=self.config) |
|
|
|
self.assertEqual(ks.xprv, 'uprv8tXDerPXZ1QsVuQ9rV8sN13YoQitC8cD2MtdZJQAVuw19kMMxhhPYnyGLeEiThgLELqNTxS91GTLsVofKAM9LRrkGeRzzEuJRtt1Tcostr7') |
|
|
|
self.assertEqual(ks.xpub, 'upub57Wa4MvRPNyAiPUcxWfsj8zHMSZNbbL4PapEMgon4FTz2YgWWF1e6bHkBvpDKk2Rg2Zy9LsonXFFbv7jNeCZ5kdKWv8UkfcoxpdjJrZuBX6') |
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '2MuzNWpcHrXyvPVKzEGT7Xrwp8uEnXXjWnK') |
|
|
|
self.assertEqual(w.get_change_addresses()[0], '2MzTzY5VcGLwce7YmdEwjXhgQD7LYEKLJTm') |
|
|
|
|
|
|
|
ks = create_keystore_from_bip32seed(xtype='p2wpkh') |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, config=self.config) |
|
|
|
self.assertEqual(ks.xprv, 'vprv9DMUxX4ShgxMMCbGgqvVa693yNsL8kbhwUQrLhJ3svJtCrAbDMrxArdQMrCJTcLFdyxBDS2hTvotknRE2rmA8fYM8z8Ra9inhcwerEsG6Ev') |
|
|
|
self.assertEqual(ks.xpub, 'vpub5SLqN2bLY4WeZgfjnsTVwE5nXQhpYDKZJhLT95hfSFqs5eVjkuBCiewtD8moKegM5fgmtpUNFBboVCjJ6LcZszJvPFpuLaSJEYhNhUAnrCS') |
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], 'tb1qtuynwzd0d6wptvyqmc6ehkm70zcamxpsaze002') |
|
|
|
self.assertEqual(w.get_change_addresses()[0], 'tb1qjy5zunxh6hjysele86qqywfa437z4xwm4lm549') |
|
|
|
|
|
|
|
ks = create_keystore_from_bip32seed(xtype='standard') # p2sh |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks], '1of1') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks], '1of1', config=self.config) |
|
|
|
self.assertEqual(ks.xprv, 'tprv8ZgxMBicQKsPecD328MF9ux3dSaSFWci7FNQmuWH7uZ86eY8i3XpvjK8KSH8To2QphiZiUqaYc6nzDC6bTw8YCB9QJjaQL5pAApN4z7vh2B') |
|
|
|
self.assertEqual(ks.xpub, 'tpubD6NzVbkrYhZ4Y5Epun1qZKcACU6NQqocgYyC4RYaYBMWw8nuLSMR7DvzVamkqxwRgrTJ1MBMhc8wwxT2vbHqMu8RBXy4BvjWMxR5EdZroxE') |
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '2N6czpsRwQ3d8AHZPNbztf5NotzEsaZmVQ8') |
|
|
|
self.assertEqual(w.get_change_addresses()[0], '2NDgwz4CoaSzdSAQdrCcLFWsJaVowCNgiPA') |
|
|
|
|
|
|
|
ks = create_keystore_from_bip32seed(xtype='p2wsh-p2sh') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks], '1of1') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks], '1of1', config=self.config) |
|
|
|
self.assertEqual(ks.xprv, 'Uprv95RJn67y7xyEvUZXo9brC5PMXCm9QVHoLdYJUZfhsgmQmvvGj75fduqC9MCC28uETouMLYSFtUqqzfRRcPW6UuyR77YQPeNJKd9t3XutF8b') |
|
|
|
self.assertEqual(ks.xpub, 'Upub5JQfBberxLXY8xdzuB8rZDL65Ebdox1ehrTuGx5KS2JPejFRGePvBi9fzdmgtBFKuVdx1vsvfjdkj5jVfsMWEEjzMPEtA55orYubtrCZmRr') |
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], '2NBZQ25GC3ipaF13ZY3UT8i2xnDuS17pJqx') |
|
|
|
self.assertEqual(w.get_change_addresses()[0], '2NDmUgLVX8vKvcJ4FQ37GSUre6QtBzKkb6k') |
|
|
|
|
|
|
|
ks = create_keystore_from_bip32seed(xtype='p2wsh') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks], '1of1') |
|
|
|
w = WalletIntegrityHelper.create_multisig_wallet([ks], '1of1', config=self.config) |
|
|
|
self.assertEqual(ks.xprv, 'Vprv16YtLrHXxePM6noKqtFtMtmUgBE9bEpF3fPLmpvuPksssLostujtdHBwqhEeVuzESz22UY8hyPx9ed684SQpCmUKSVhpxPFbvVNY7qnviNR') |
|
|
|
self.assertEqual(ks.xpub, 'Vpub5dEvVGKn7251zFq7jXvUmJRbFCk5ka19cxz84LyCp2gGhq4eXJZUomop1qjGt5uFK8kkmQUV8PzJcNM4PZmX2URbDiwJjyuJ8GyFHRrEmmG') |
|
|
|
self.assertEqual(w.get_receiving_addresses()[0], 'tb1q84x0yrztvcjg88qef4d6978zccxulcmc9y88xcg4ghjdau999x7qf2696k') |
|
|
@ -542,20 +551,13 @@ class TestWalletKeystoreAddressIntegrityForTestnet(TestCaseForTestnet): |
|
|
|
|
|
|
|
class TestWalletSending(TestCaseForTestnet): |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def setUpClass(cls): |
|
|
|
super().setUpClass() |
|
|
|
cls.electrum_path = tempfile.mkdtemp() |
|
|
|
cls.config = SimpleConfig({'electrum_path': cls.electrum_path}) |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def tearDownClass(cls): |
|
|
|
super().tearDownClass() |
|
|
|
shutil.rmtree(cls.electrum_path) |
|
|
|
def setUp(self): |
|
|
|
super().setUp() |
|
|
|
self.config = SimpleConfig({'electrum_path': self.electrum_path}) |
|
|
|
|
|
|
|
def create_standard_wallet_from_seed(self, seed_words): |
|
|
|
ks = keystore.from_seed(seed_words, '', False) |
|
|
|
return WalletIntegrityHelper.create_standard_wallet(ks, gap_limit=2) |
|
|
|
return WalletIntegrityHelper.create_standard_wallet(ks, gap_limit=2, config=self.config) |
|
|
|
|
|
|
|
@needs_test_with_all_ecc_implementations |
|
|
|
@mock.patch.object(storage.WalletStorage, '_write') |
|
|
@ -623,7 +625,8 @@ class TestWalletSending(TestCaseForTestnet): |
|
|
|
keystore.from_xpub('tpubD6NzVbkrYhZ4YTPEgwk4zzr8wyo7pXGmbbVUnfYNtx6SgAMF5q3LN3Kch58P9hxGNsTmP7Dn49nnrmpE6upoRb1Xojg12FGLuLHkVpVtS44'), |
|
|
|
keystore.from_xpub('tpubD6NzVbkrYhZ4XJzYkhsCbDCcZRmDAKSD7bXi9mdCni7acVt45fxbTVZyU6jRGh29ULKTjoapkfFsSJvQHitcVKbQgzgkkYsAmaovcro7Mhf') |
|
|
|
], |
|
|
|
'2of3', gap_limit=2 |
|
|
|
'2of3', gap_limit=2, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet1b = WalletIntegrityHelper.create_multisig_wallet( |
|
|
|
[ |
|
|
@ -631,7 +634,8 @@ class TestWalletSending(TestCaseForTestnet): |
|
|
|
keystore.from_xpub('tpubD6NzVbkrYhZ4YTPEgwk4zzr8wyo7pXGmbbVUnfYNtx6SgAMF5q3LN3Kch58P9hxGNsTmP7Dn49nnrmpE6upoRb1Xojg12FGLuLHkVpVtS44'), |
|
|
|
keystore.from_xpub('tpubD6NzVbkrYhZ4YARFMEZPckrqJkw59GZD1PXtQnw14ukvWDofR7Z1HMeSCxfYEZVvg4VdZ8zGok5VxHwdrLqew5cMdQntWc5mT7mh1CSgrnX') |
|
|
|
], |
|
|
|
'2of3', gap_limit=2 |
|
|
|
'2of3', gap_limit=2, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
# ^ third seed: ghost into match ivory badge robot record tackle radar elbow traffic loud |
|
|
|
wallet2 = self.create_standard_wallet_from_seed('powerful random nobody notice nothing important anyway look away hidden message over') |
|
|
@ -699,7 +703,8 @@ class TestWalletSending(TestCaseForTestnet): |
|
|
|
keystore.from_xpub('Vpub5fcdcgEwTJmbmqAktuK8Kyq92fMf7sWkcP6oqAii2tG47dNbfkGEGUbfS9NuZaRywLkHE6EmUksrqo32ZL3ouLN1HTar6oRiHpDzKMAF1tf'), |
|
|
|
keystore.from_xpub('Vpub5fjkKyYnvSS4wBuakWTkNvZDaBM2vQ1MeXWq368VJHNr2eT8efqhpmZ6UUkb7s2dwCXv2Vuggjdhk4vZVyiAQTwUftvff73XcUGq2NQmWra') |
|
|
|
], |
|
|
|
'2of3', gap_limit=2 |
|
|
|
'2of3', gap_limit=2, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet1b = WalletIntegrityHelper.create_multisig_wallet( |
|
|
|
[ |
|
|
@ -707,7 +712,8 @@ class TestWalletSending(TestCaseForTestnet): |
|
|
|
keystore.from_xpub('Vpub5fjkKyYnvSS4wBuakWTkNvZDaBM2vQ1MeXWq368VJHNr2eT8efqhpmZ6UUkb7s2dwCXv2Vuggjdhk4vZVyiAQTwUftvff73XcUGq2NQmWra'), |
|
|
|
keystore.from_xpub('Vpub5gSKXzxK7FeKQedu2q1z9oJWxqvX72AArW3HSWpEhc8othDH8xMDu28gr7gf17sp492BuJod8Tn7anjvJrKpETwqnQqX7CS8fcYyUtedEMk') |
|
|
|
], |
|
|
|
'2of3', gap_limit=2 |
|
|
|
'2of3', gap_limit=2, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
# ^ third seed: hedgehog sunset update estate number jungle amount piano friend donate upper wool |
|
|
|
wallet2a = WalletIntegrityHelper.create_multisig_wallet( |
|
|
@ -716,7 +722,8 @@ class TestWalletSending(TestCaseForTestnet): |
|
|
|
keystore.from_xprv('Uprv9CvELvByqm8k2dpecJVjgLMX1z5DufEjY4fBC5YvdGF5WjGCa7GVJJ2fYni1tyuF7Hw83E6W2ZBjAhaFLZv2ri3rEsubkCd5avg4EHKoDBN'), |
|
|
|
keystore.from_xpub('Upub5Qb8ik4Cnu8g97KLXKgVXHqY6tH8emQvqtBncjSKsyfTZuorPtTZgX7ovKKZHuuVGBVd1MTTBkWez1XXt2weN1sWBz6SfgRPQYEkNgz81QF') |
|
|
|
], |
|
|
|
'2of2', gap_limit=2 |
|
|
|
'2of2', gap_limit=2, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet2b = WalletIntegrityHelper.create_multisig_wallet( |
|
|
|
[ |
|
|
@ -724,7 +731,8 @@ class TestWalletSending(TestCaseForTestnet): |
|
|
|
keystore.from_xprv('Uprv9BbnKEXJxXaNvdEsRJ9VA9toYrSeFJh5UfGBpM2iKe8Uh7UhrM9K8ioL53s8gvCoGfirHHaqpABDAE7VUNw8LNU1DMJKVoWyeNKu9XcDC19'), |
|
|
|
keystore.from_xpub('Upub5RuakRisg8h3F7u7iL2k3UJFa1uiK7xauHamzTxYBbn4PXbM7eajr6M9Q2VCr6cVGhfhqWQqxnABvtSATuVM1xzxk4nA189jJwzaMn1QX7V') |
|
|
|
], |
|
|
|
'2of2', gap_limit=2 |
|
|
|
'2of2', gap_limit=2, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
|
|
|
|
# bootstrap wallet1 |
|
|
@ -798,13 +806,15 @@ class TestWalletSending(TestCaseForTestnet): |
|
|
|
keystore.from_seed('phone guilt ancient scan defy gasp off rotate approve ill word exchange', '', True), |
|
|
|
keystore.from_xpub('tpubD6NzVbkrYhZ4YPZ3ntVjqSCxiUUv2jikrUBU73Q3iJ7Y8iR41oYf991L5fanv7ciHjbjokdK2bjYqg1BzEUDxucU9qM5WRdBiY738wmgLP4') |
|
|
|
], |
|
|
|
'1of2', gap_limit=2 |
|
|
|
'1of2', gap_limit=2, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
# ^ second seed: kingdom now gift initial age right velvet exotic harbor enforce kingdom kick |
|
|
|
wallet2 = WalletIntegrityHelper.create_standard_wallet( |
|
|
|
# bip39: uniform tank success logic lesson awesome stove elegant regular desert drip device, der: m/49'/1'/0' |
|
|
|
keystore.from_xprv('uprv91HGbrNZTK4x8u22nbdYGzEuWPxjaHMREUi7CNhY64KsG5ZGnVM99uCa16EMSfrnaPTFxjbRdBZ2WiBkokoM8anzAy3Vpc52o88WPkitnxi'), |
|
|
|
gap_limit=2 |
|
|
|
gap_limit=2, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
|
|
|
|
# bootstrap wallet1 |
|
|
@ -1306,27 +1316,22 @@ class TestWalletSending(TestCaseForTestnet): |
|
|
|
|
|
|
|
class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def setUpClass(cls): |
|
|
|
super().setUpClass() |
|
|
|
cls.electrum_path = tempfile.mkdtemp() |
|
|
|
cls.config = SimpleConfig({'electrum_path': cls.electrum_path}) |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def tearDownClass(cls): |
|
|
|
super().tearDownClass() |
|
|
|
shutil.rmtree(cls.electrum_path) |
|
|
|
def setUp(self): |
|
|
|
super().setUp() |
|
|
|
self.config = SimpleConfig({'electrum_path': self.electrum_path}) |
|
|
|
|
|
|
|
@needs_test_with_all_ecc_implementations |
|
|
|
@mock.patch.object(storage.WalletStorage, '_write') |
|
|
|
def test_sending_offline_old_electrum_seed_online_mpk(self, mock_write): |
|
|
|
wallet_offline = WalletIntegrityHelper.create_standard_wallet( |
|
|
|
keystore.from_seed('alone body father children lead goodbye phone twist exist grass kick join', '', False), |
|
|
|
gap_limit=4 |
|
|
|
gap_limit=4, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet_online = WalletIntegrityHelper.create_standard_wallet( |
|
|
|
keystore.from_master_key('cd805ed20aec61c7a8b409c121c6ba60a9221f46d20edbc2be83ebd91460e97937cd7d782e77c1cb08364c6bc1c98bc040fdad53f22f29f7d3a85c8e51f9c875'), |
|
|
|
gap_limit=4 |
|
|
|
gap_limit=4, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
|
|
|
|
# bootstrap wallet_online |
|
|
@ -1365,11 +1370,13 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
wallet_offline = WalletIntegrityHelper.create_standard_wallet( |
|
|
|
# bip39: "qwe", der: m/44'/1'/0' |
|
|
|
keystore.from_xprv('tprv8gfKwjuAaqtHgqxMh1tosAQ28XvBMkcY5NeFRA3pZMpz6MR4H4YZ3MJM4fvNPnRKeXR1Td2vQGgjorNXfo94WvT5CYDsPAqjHxSn436G1Eu'), |
|
|
|
gap_limit=4 |
|
|
|
gap_limit=4, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet_online = WalletIntegrityHelper.create_standard_wallet( |
|
|
|
keystore.from_xpub('tpubDDMN69wQjDZxaJz9afZQGa48hZS7X5oSegF2hg67yddNvqfpuTN9DqvDEp7YyVf7AzXnqBqHdLhzTAStHvsoMDDb8WoJQzNrcHgDJHVYgQF'), |
|
|
|
gap_limit=4 |
|
|
|
gap_limit=4, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
|
|
|
|
# bootstrap wallet_online |
|
|
@ -1406,11 +1413,13 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
wallet_offline = WalletIntegrityHelper.create_standard_wallet( |
|
|
|
# bip39: "qwe", der: m/49'/1'/0' |
|
|
|
keystore.from_xprv('uprv8zHHrMQMQ26utWwNJ5MK2SXpB9hbmy7pbPaneii69xT8cZTyFpxQFxkknGWKP8dxBTZhzy7yP6cCnLrRCQjzJDk3G61SjZpxhFQuB2NR8a5'), |
|
|
|
gap_limit=4 |
|
|
|
gap_limit=4, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet_online = WalletIntegrityHelper.create_standard_wallet( |
|
|
|
keystore.from_xpub('upub5DGeFrwFEPfD711qQ6tKPaUYjBY6BRqfxcWPT77hiHz7VMo7oNGeom5EdXoKXEazePyoN3ueJMqHBfp3MwmsaD8k9dFHoa8KGeVXev7Pbg2'), |
|
|
|
gap_limit=4 |
|
|
|
gap_limit=4, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
|
|
|
|
# bootstrap wallet_online |
|
|
@ -1448,11 +1457,13 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
wallet_offline = WalletIntegrityHelper.create_standard_wallet( |
|
|
|
# bip39: "qwe", der: m/84'/1'/0' |
|
|
|
keystore.from_xprv('vprv9K9hbuA23Bidgj1KRSHUZMa59jJLeZBpXPVn4RP7sBLArNhZxJjw4AX7aQmVTErDt4YFC11ptMLjbwxgrsH8GLQ1cx77KggWeVPeDBjr9xM'), |
|
|
|
gap_limit=4 |
|
|
|
gap_limit=4, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet_online = WalletIntegrityHelper.create_standard_wallet( |
|
|
|
keystore.from_xpub('vpub5Y941QgusZGvuD5nXTpUvVWohm8q41uftcRNronjRWs9jB2iVr4BbxqbRfAoQjWHgJtDCQEXChgfsPbEuBnidtkFztZSD3zDKTrtwXa2LCa'), |
|
|
|
gap_limit=4 |
|
|
|
gap_limit=4, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
|
|
|
|
# bootstrap wallet_online |
|
|
@ -1487,9 +1498,9 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
@needs_test_with_all_ecc_implementations |
|
|
|
@mock.patch.object(storage.WalletStorage, '_write') |
|
|
|
def test_sending_offline_wif_online_addr_p2pkh(self, mock_write): # compressed pubkey |
|
|
|
wallet_offline = WalletIntegrityHelper.create_imported_wallet(privkeys=True) |
|
|
|
wallet_offline = WalletIntegrityHelper.create_imported_wallet(privkeys=True, config=self.config) |
|
|
|
wallet_offline.import_private_key('p2pkh:cQDxbmQfwRV3vP1mdnVHq37nJekHLsuD3wdSQseBRA2ct4MFk5Pq', password=None) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False, config=self.config) |
|
|
|
wallet_online.import_address('mg2jk6S5WGDhUPA8mLSxDLWpUoQnX1zzoG') |
|
|
|
|
|
|
|
# bootstrap wallet_online |
|
|
@ -1522,9 +1533,9 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
@needs_test_with_all_ecc_implementations |
|
|
|
@mock.patch.object(storage.WalletStorage, '_write') |
|
|
|
def test_sending_offline_wif_online_addr_p2wpkh_p2sh(self, mock_write): |
|
|
|
wallet_offline = WalletIntegrityHelper.create_imported_wallet(privkeys=True) |
|
|
|
wallet_offline = WalletIntegrityHelper.create_imported_wallet(privkeys=True, config=self.config) |
|
|
|
wallet_offline.import_private_key('p2wpkh-p2sh:cU9hVzhpvfn91u2zTVn8uqF2ymS7ucYH8V5TmsTDmuyMHgRk9WsJ', password=None) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False, config=self.config) |
|
|
|
wallet_online.import_address('2NA2JbUVK7HGWUCK5RXSVNHrkgUYF8d9zV8') |
|
|
|
|
|
|
|
# bootstrap wallet_online |
|
|
@ -1557,9 +1568,9 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
@needs_test_with_all_ecc_implementations |
|
|
|
@mock.patch.object(storage.WalletStorage, '_write') |
|
|
|
def test_sending_offline_wif_online_addr_p2wpkh(self, mock_write): |
|
|
|
wallet_offline = WalletIntegrityHelper.create_imported_wallet(privkeys=True) |
|
|
|
wallet_offline = WalletIntegrityHelper.create_imported_wallet(privkeys=True, config=self.config) |
|
|
|
wallet_offline.import_private_key('p2wpkh:cPuQzcNEgbeYZ5at9VdGkCwkPA9r34gvEVJjuoz384rTfYpahfe7', password=None) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False, config=self.config) |
|
|
|
wallet_online.import_address('tb1qm2eh4787lwanrzr6pf0ekf5c7jnmghm2y9k529') |
|
|
|
|
|
|
|
# bootstrap wallet_online |
|
|
@ -1595,9 +1606,10 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
wallet_offline = WalletIntegrityHelper.create_standard_wallet( |
|
|
|
# bip39: "qwe", der: m/44'/1'/0' |
|
|
|
keystore.from_xprv('tprv8gfKwjuAaqtHgqxMh1tosAQ28XvBMkcY5NeFRA3pZMpz6MR4H4YZ3MJM4fvNPnRKeXR1Td2vQGgjorNXfo94WvT5CYDsPAqjHxSn436G1Eu'), |
|
|
|
gap_limit=4 |
|
|
|
gap_limit=4, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False, config=self.config) |
|
|
|
wallet_online.import_address('mg2jk6S5WGDhUPA8mLSxDLWpUoQnX1zzoG') |
|
|
|
|
|
|
|
# bootstrap wallet_online |
|
|
@ -1633,9 +1645,10 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
wallet_offline = WalletIntegrityHelper.create_standard_wallet( |
|
|
|
# bip39: "qwe", der: m/49'/1'/0' |
|
|
|
keystore.from_xprv('uprv8zHHrMQMQ26utWwNJ5MK2SXpB9hbmy7pbPaneii69xT8cZTyFpxQFxkknGWKP8dxBTZhzy7yP6cCnLrRCQjzJDk3G61SjZpxhFQuB2NR8a5'), |
|
|
|
gap_limit=4 |
|
|
|
gap_limit=4, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False, config=self.config) |
|
|
|
wallet_online.import_address('2NA2JbUVK7HGWUCK5RXSVNHrkgUYF8d9zV8') |
|
|
|
|
|
|
|
# bootstrap wallet_online |
|
|
@ -1671,9 +1684,10 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
wallet_offline = WalletIntegrityHelper.create_standard_wallet( |
|
|
|
# bip39: "qwe", der: m/84'/1'/0' |
|
|
|
keystore.from_xprv('vprv9K9hbuA23Bidgj1KRSHUZMa59jJLeZBpXPVn4RP7sBLArNhZxJjw4AX7aQmVTErDt4YFC11ptMLjbwxgrsH8GLQ1cx77KggWeVPeDBjr9xM'), |
|
|
|
gap_limit=4 |
|
|
|
gap_limit=4, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False, config=self.config) |
|
|
|
wallet_online.import_address('tb1qm2eh4787lwanrzr6pf0ekf5c7jnmghm2y9k529') |
|
|
|
|
|
|
|
# bootstrap wallet_online |
|
|
@ -1713,7 +1727,8 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
keystore.from_xpub('tpubD6NzVbkrYhZ4YTPEgwk4zzr8wyo7pXGmbbVUnfYNtx6SgAMF5q3LN3Kch58P9hxGNsTmP7Dn49nnrmpE6upoRb1Xojg12FGLuLHkVpVtS44'), |
|
|
|
keystore.from_xpub('tpubD6NzVbkrYhZ4XJzYkhsCbDCcZRmDAKSD7bXi9mdCni7acVt45fxbTVZyU6jRGh29ULKTjoapkfFsSJvQHitcVKbQgzgkkYsAmaovcro7Mhf') |
|
|
|
], |
|
|
|
'2of3', gap_limit=2 |
|
|
|
'2of3', gap_limit=2, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet_offline2 = WalletIntegrityHelper.create_multisig_wallet( |
|
|
|
[ |
|
|
@ -1721,9 +1736,10 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
keystore.from_xpub('tpubD6NzVbkrYhZ4YTPEgwk4zzr8wyo7pXGmbbVUnfYNtx6SgAMF5q3LN3Kch58P9hxGNsTmP7Dn49nnrmpE6upoRb1Xojg12FGLuLHkVpVtS44'), |
|
|
|
keystore.from_xpub('tpubD6NzVbkrYhZ4YARFMEZPckrqJkw59GZD1PXtQnw14ukvWDofR7Z1HMeSCxfYEZVvg4VdZ8zGok5VxHwdrLqew5cMdQntWc5mT7mh1CSgrnX') |
|
|
|
], |
|
|
|
'2of3', gap_limit=2 |
|
|
|
'2of3', gap_limit=2, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False, config=self.config) |
|
|
|
wallet_online.import_address('2N4z38eTKcWTZnfugCCfRyXtXWMLnn8HDfw') |
|
|
|
|
|
|
|
# bootstrap wallet_online |
|
|
@ -1771,7 +1787,8 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
keystore.from_xprv('Uprv9CvELvByqm8k2dpecJVjgLMX1z5DufEjY4fBC5YvdGF5WjGCa7GVJJ2fYni1tyuF7Hw83E6W2ZBjAhaFLZv2ri3rEsubkCd5avg4EHKoDBN'), |
|
|
|
keystore.from_xpub('Upub5Qb8ik4Cnu8g97KLXKgVXHqY6tH8emQvqtBncjSKsyfTZuorPtTZgX7ovKKZHuuVGBVd1MTTBkWez1XXt2weN1sWBz6SfgRPQYEkNgz81QF') |
|
|
|
], |
|
|
|
'2of2', gap_limit=2 |
|
|
|
'2of2', gap_limit=2, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet_offline2 = WalletIntegrityHelper.create_multisig_wallet( |
|
|
|
[ |
|
|
@ -1779,9 +1796,10 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
keystore.from_xprv('Uprv9BbnKEXJxXaNvdEsRJ9VA9toYrSeFJh5UfGBpM2iKe8Uh7UhrM9K8ioL53s8gvCoGfirHHaqpABDAE7VUNw8LNU1DMJKVoWyeNKu9XcDC19'), |
|
|
|
keystore.from_xpub('Upub5RuakRisg8h3F7u7iL2k3UJFa1uiK7xauHamzTxYBbn4PXbM7eajr6M9Q2VCr6cVGhfhqWQqxnABvtSATuVM1xzxk4nA189jJwzaMn1QX7V') |
|
|
|
], |
|
|
|
'2of2', gap_limit=2 |
|
|
|
'2of2', gap_limit=2, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False, config=self.config) |
|
|
|
wallet_online.import_address('2MsHQRm1pNi6VsmXYRxYMcCTdPu7Xa1RyFe') |
|
|
|
|
|
|
|
# bootstrap wallet_online |
|
|
@ -1830,7 +1848,8 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
keystore.from_xpub('Vpub5fcdcgEwTJmbmqAktuK8Kyq92fMf7sWkcP6oqAii2tG47dNbfkGEGUbfS9NuZaRywLkHE6EmUksrqo32ZL3ouLN1HTar6oRiHpDzKMAF1tf'), |
|
|
|
keystore.from_xpub('Vpub5fjkKyYnvSS4wBuakWTkNvZDaBM2vQ1MeXWq368VJHNr2eT8efqhpmZ6UUkb7s2dwCXv2Vuggjdhk4vZVyiAQTwUftvff73XcUGq2NQmWra') |
|
|
|
], |
|
|
|
'2of3', gap_limit=2 |
|
|
|
'2of3', gap_limit=2, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
wallet_offline2 = WalletIntegrityHelper.create_multisig_wallet( |
|
|
|
[ |
|
|
@ -1838,10 +1857,11 @@ class TestWalletOfflineSigning(TestCaseForTestnet): |
|
|
|
keystore.from_xpub('Vpub5fjkKyYnvSS4wBuakWTkNvZDaBM2vQ1MeXWq368VJHNr2eT8efqhpmZ6UUkb7s2dwCXv2Vuggjdhk4vZVyiAQTwUftvff73XcUGq2NQmWra'), |
|
|
|
keystore.from_xpub('Vpub5gSKXzxK7FeKQedu2q1z9oJWxqvX72AArW3HSWpEhc8othDH8xMDu28gr7gf17sp492BuJod8Tn7anjvJrKpETwqnQqX7CS8fcYyUtedEMk') |
|
|
|
], |
|
|
|
'2of3', gap_limit=2 |
|
|
|
'2of3', gap_limit=2, |
|
|
|
config=self.config |
|
|
|
) |
|
|
|
# ^ third seed: hedgehog sunset update estate number jungle amount piano friend donate upper wool |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False) |
|
|
|
wallet_online = WalletIntegrityHelper.create_imported_wallet(privkeys=False, config=self.config) |
|
|
|
wallet_online.import_address('tb1q83p6eqxkuvq4eumcha46crpzg4nj84s9p0hnynkxg8nhvfzqcc7q4erju6') |
|
|
|
|
|
|
|
# bootstrap wallet_online |
|
|
@ -1905,11 +1925,14 @@ class TestWalletHistory_SimpleRandomOrder(TestCaseForTestnet): |
|
|
|
} |
|
|
|
txid_list = sorted(list(transactions)) |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def create_old_wallet(cls): |
|
|
|
def setUp(self): |
|
|
|
super().setUp() |
|
|
|
self.config = SimpleConfig({'electrum_path': self.electrum_path}) |
|
|
|
|
|
|
|
def create_old_wallet(self): |
|
|
|
ks = keystore.from_old_mpk('e9d4b7866dd1e91c862aebf62a49548c7dbf7bcc6e4b7b8c9da820c7737968df9c09d5a3e271dc814a29981f81b3faaf2737b551ef5dcc6189cf0f8252c442b3') |
|
|
|
# seed words: powerful random nobody notice nothing important anyway look away hidden message over |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, gap_limit=20) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, gap_limit=20, config=self.config) |
|
|
|
# some txns are beyond gap limit: |
|
|
|
w.create_new_address(for_change=True) |
|
|
|
return w |
|
|
@ -1949,28 +1972,17 @@ class TestWalletHistory_EvilGapLimit(TestCaseForTestnet): |
|
|
|
"268fce617aaaa4847835c2212b984d7b7741fdab65de22813288341819bc5656": "010000000001014f1bdc64da8056d08f79db7f5348d1de55946e57aa7c8279499c703889b6e0fd0100000000fdffffff0260e316000000000016001445e9879cf7cd5b4a15df7ddcaf5c6dca0e1508bacc242600000000001600141bc12094a4475dcfbf24f9920dafddf9104ca95b02483045022100ae3618912f341fefee11b67e0047c47c88c4fa031561c3fafe993259dd14d846022056fa0a5b5d8a65942fa68bcc2f848fd71fa455ba42bc2d421b67eb49ba62aa4e01210394d8f4f06c2ea9c569eb050c897737a7315e7f2104d9b536b49968cc89a1f11033181400", |
|
|
|
} |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def setUpClass(cls): |
|
|
|
super().setUpClass() |
|
|
|
cls.electrum_path = tempfile.mkdtemp() |
|
|
|
cls.config = SimpleConfig({ |
|
|
|
'electrum_path': cls.electrum_path, |
|
|
|
def setUp(self): |
|
|
|
super().setUp() |
|
|
|
self.config = SimpleConfig({ |
|
|
|
'electrum_path': self.electrum_path, |
|
|
|
'skipmerklecheck': True, # needed for Synchronizer to generate new addresses without SPV |
|
|
|
}) |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def tearDownClass(cls): |
|
|
|
super().tearDownClass() |
|
|
|
shutil.rmtree(cls.electrum_path) |
|
|
|
# horrible hack. create a new config to ensure custom settings |
|
|
|
# don't get persisted in the "singleton" config: |
|
|
|
SimpleConfig({'electrum_path': cls.electrum_path}) |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def create_wallet(cls): |
|
|
|
def create_wallet(self): |
|
|
|
ks = keystore.from_xpub('vpub5Vhmk4dEJKanDTTw6immKXa3thw45u3gbd1rPYjREB6viP13sVTWcH6kvbR2YeLtGjradr6SFLVt9PxWDBSrvw1Dc1nmd3oko3m24CQbfaJ') |
|
|
|
# seed words: nephew work weather maze pyramid employ check permit garment scene kiwi smooth |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, gap_limit=20) |
|
|
|
w = WalletIntegrityHelper.create_standard_wallet(ks, gap_limit=20, config=self.config) |
|
|
|
return w |
|
|
|
|
|
|
|
@mock.patch.object(storage.WalletStorage, '_write') |
|
|
@ -2017,11 +2029,16 @@ class TestWalletHistory_DoubleSpend(TestCaseForTestnet): |
|
|
|
"2c9aa33d9c8ec649f9bfb84af027a5414b760be5231fe9eca4a95b9eb3f8a017": "020000000001012516fade5b5938336a11815d02787ba1580b3189432aa11b150527f8409084a30100000000fdffffff01d2410f00000000001600147880a7c79744b908a5f6d6235f2eb46c174c84f002483045022100974d27c872f09115e57c6acb674cd4da6d0b26656ad967ddb2678ff409714b9502206d91b49cf778ced6ca9e40b4094fb57b86c86fac09ce46ce53aea4afa68ff311012102254b5b20ed21c3bba75ec2a9ff230257d13a2493f6b7da066d8195dcdd484310788d1700", |
|
|
|
} |
|
|
|
|
|
|
|
def setUp(self): |
|
|
|
super().setUp() |
|
|
|
self.config = SimpleConfig({'electrum_path': self.electrum_path}) |
|
|
|
|
|
|
|
@mock.patch.object(storage.WalletStorage, '_write') |
|
|
|
def test_restoring_wallet_without_manual_delete(self, mock_write): |
|
|
|
w = restore_wallet_from_text("small rapid pattern language comic denial donate extend tide fever burden barrel", |
|
|
|
path='if_this_exists_mocking_failed_648151893', |
|
|
|
gap_limit=5)['wallet'] |
|
|
|
gap_limit=5, |
|
|
|
config=self.config)['wallet'] |
|
|
|
for txid in self.transactions: |
|
|
|
tx = Transaction(self.transactions[txid]) |
|
|
|
w.add_transaction(tx.txid(), tx) |
|
|
@ -2034,7 +2051,8 @@ class TestWalletHistory_DoubleSpend(TestCaseForTestnet): |
|
|
|
def test_restoring_wallet_with_manual_delete(self, mock_write): |
|
|
|
w = restore_wallet_from_text("small rapid pattern language comic denial donate extend tide fever burden barrel", |
|
|
|
path='if_this_exists_mocking_failed_648151893', |
|
|
|
gap_limit=5)['wallet'] |
|
|
|
gap_limit=5, |
|
|
|
config=self.config)['wallet'] |
|
|
|
# txn A is an external incoming txn funding the wallet |
|
|
|
txA = Transaction(self.transactions["a3849040f82705151ba12a4389310b58a17b78025d81116a3338595bdefa1625"]) |
|
|
|
w.add_transaction(txA.txid(), txA) |
|
|
|