Skip to content

Commit 6531599

Browse files
committed
test: Add check that newkeypool flushes change addresses too
1 parent 84fa19c commit 6531599

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

test/functional/wallet_keypool.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,16 @@ def run_test(self):
141141
if not self.options.descriptors:
142142
# Check that newkeypool entirely flushes the keypool
143143
start_keypath = nodes[0].getaddressinfo(nodes[0].getnewaddress())['hdkeypath']
144+
start_change_keypath = nodes[0].getaddressinfo(nodes[0].getrawchangeaddress())['hdkeypath']
145+
# flush keypool and get new addresses
144146
nodes[0].newkeypool()
145147
end_keypath = nodes[0].getaddressinfo(nodes[0].getnewaddress())['hdkeypath']
148+
end_change_keypath = nodes[0].getaddressinfo(nodes[0].getrawchangeaddress())['hdkeypath']
146149
# The new keypath index should be 100 more than the old one
147-
keypath_prefix = start_keypath.rsplit('/', 1)[0]
148150
new_index = int(start_keypath.rsplit('/', 1)[1][:-1]) + 100
149-
assert_equal(end_keypath, keypath_prefix + '/' + str(new_index) + '\'')
151+
new_change_index = int(start_change_keypath.rsplit('/', 1)[1][:-1]) + 100
152+
assert_equal(end_keypath, "m/0'/0'/" + str(new_index) + "'")
153+
assert_equal(end_change_keypath, "m/0'/1'/" + str(new_change_index) + "'")
150154

151155
# create a blank wallet
152156
nodes[0].createwallet(wallet_name='w2', blank=True, disable_private_keys=True)

test/functional/wallet_upgradewallet.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,13 @@ def copy_split_hd():
234234
assert_equal(1, hd_chain_version)
235235
seed_id = bytearray(seed_id)
236236
seed_id.reverse()
237-
old_kvs = new_kvs
238-
# New keys should be HD (the two old keys have been flushed)
237+
238+
# New keys (including change) should be HD (the two old keys have been flushed)
239239
info = wallet.getaddressinfo(wallet.getnewaddress())
240240
assert_equal(seed_id.hex(), info['hdseedid'])
241241
assert_equal('m/0\'/0\'/0\'', info['hdkeypath'])
242242
prev_seed_id = info['hdseedid']
243-
# Change key should be the same keypool
243+
# Change key should be HD and from the same keypool
244244
info = wallet.getaddressinfo(wallet.getrawchangeaddress())
245245
assert_equal(prev_seed_id, info['hdseedid'])
246246
assert_equal('m/0\'/0\'/1\'', info['hdkeypath'])

0 commit comments

Comments
 (0)