diff options
author | Samuel Dobson <dobsonsa68@gmail.com> | 2021-10-14 16:52:59 +1300 |
---|---|---|
committer | Samuel Dobson <dobsonsa68@gmail.com> | 2021-10-14 16:52:59 +1300 |
commit | 6531599f422524fbbcc43816121e7536cf79d66c (patch) | |
tree | 178cbef277746f579c1b901ff232d36b54d73861 | |
parent | 84fa19c77a2c8d0d01add2daf18b42af07c17710 (diff) | |
download | bitcoin-6531599f422524fbbcc43816121e7536cf79d66c.tar.xz |
test: Add check that newkeypool flushes change addresses too
-rwxr-xr-x | test/functional/wallet_keypool.py | 8 | ||||
-rwxr-xr-x | test/functional/wallet_upgradewallet.py | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/test/functional/wallet_keypool.py b/test/functional/wallet_keypool.py index 627a750850..79235646b0 100755 --- a/test/functional/wallet_keypool.py +++ b/test/functional/wallet_keypool.py @@ -141,12 +141,16 @@ class KeyPoolTest(BitcoinTestFramework): if not self.options.descriptors: # Check that newkeypool entirely flushes the keypool start_keypath = nodes[0].getaddressinfo(nodes[0].getnewaddress())['hdkeypath'] + start_change_keypath = nodes[0].getaddressinfo(nodes[0].getrawchangeaddress())['hdkeypath'] + # flush keypool and get new addresses nodes[0].newkeypool() end_keypath = nodes[0].getaddressinfo(nodes[0].getnewaddress())['hdkeypath'] + end_change_keypath = nodes[0].getaddressinfo(nodes[0].getrawchangeaddress())['hdkeypath'] # The new keypath index should be 100 more than the old one - keypath_prefix = start_keypath.rsplit('/', 1)[0] new_index = int(start_keypath.rsplit('/', 1)[1][:-1]) + 100 - assert_equal(end_keypath, keypath_prefix + '/' + str(new_index) + '\'') + new_change_index = int(start_change_keypath.rsplit('/', 1)[1][:-1]) + 100 + assert_equal(end_keypath, "m/0'/0'/" + str(new_index) + "'") + assert_equal(end_change_keypath, "m/0'/1'/" + str(new_change_index) + "'") # create a blank wallet nodes[0].createwallet(wallet_name='w2', blank=True, disable_private_keys=True) diff --git a/test/functional/wallet_upgradewallet.py b/test/functional/wallet_upgradewallet.py index 917293ea8c..5800880830 100755 --- a/test/functional/wallet_upgradewallet.py +++ b/test/functional/wallet_upgradewallet.py @@ -234,13 +234,13 @@ class UpgradeWalletTest(BitcoinTestFramework): assert_equal(1, hd_chain_version) seed_id = bytearray(seed_id) seed_id.reverse() - old_kvs = new_kvs - # New keys should be HD (the two old keys have been flushed) + + # New keys (including change) should be HD (the two old keys have been flushed) info = wallet.getaddressinfo(wallet.getnewaddress()) assert_equal(seed_id.hex(), info['hdseedid']) assert_equal('m/0\'/0\'/0\'', info['hdkeypath']) prev_seed_id = info['hdseedid'] - # Change key should be the same keypool + # Change key should be HD and from the same keypool info = wallet.getaddressinfo(wallet.getrawchangeaddress()) assert_equal(prev_seed_id, info['hdseedid']) assert_equal('m/0\'/0\'/1\'', info['hdkeypath']) |