Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_hd.py
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
assert_equal(change_addrV["hdkeypath"], "m/0'/1'/1'") | assert_equal(change_addrV["hdkeypath"], "m/0'/1'/1'") | ||||
self.sync_all() | self.sync_all() | ||||
assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1) | assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1) | ||||
self.log.info("Restore backup ...") | self.log.info("Restore backup ...") | ||||
self.stop_node(1) | self.stop_node(1) | ||||
# we need to delete the complete regtest directory | # we need to delete the complete regtest directory | ||||
# otherwise node1 would auto-recover all funds in flag the keypool keys as used | # otherwise node1 would auto-recover all funds in flag the keypool keys | ||||
# as used | |||||
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "blocks")) | shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "blocks")) | ||||
shutil.rmtree(os.path.join( | shutil.rmtree(os.path.join( | ||||
self.nodes[1].datadir, "regtest", "chainstate")) | self.nodes[1].datadir, "regtest", "chainstate")) | ||||
shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join( | shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join( | ||||
self.nodes[1].datadir, "regtest", "wallets", "wallet.dat")) | self.nodes[1].datadir, "regtest", "wallets", "wallet.dat")) | ||||
self.start_node(1) | self.start_node(1) | ||||
# Assert that derivation is deterministic | # Assert that derivation is deterministic | ||||
Show All 34 Lines | def run_test(self): | ||||
out = self.nodes[1].rescanblockchain(3) | out = self.nodes[1].rescanblockchain(3) | ||||
assert_equal(out['start_height'], 3) | assert_equal(out['start_height'], 3) | ||||
assert_equal(out['stop_height'], self.nodes[1].getblockcount()) | assert_equal(out['stop_height'], self.nodes[1].getblockcount()) | ||||
out = self.nodes[1].rescanblockchain() | out = self.nodes[1].rescanblockchain() | ||||
assert_equal(out['start_height'], 0) | assert_equal(out['start_height'], 0) | ||||
assert_equal(out['stop_height'], self.nodes[1].getblockcount()) | assert_equal(out['stop_height'], self.nodes[1].getblockcount()) | ||||
assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1) | assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1) | ||||
# send a tx and make sure its using the internal chain for the changeoutput | # send a tx and make sure its using the internal chain for the | ||||
# changeoutput | |||||
txid = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1) | txid = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1) | ||||
outs = self.nodes[1].decoderawtransaction( | outs = self.nodes[1].decoderawtransaction( | ||||
self.nodes[1].gettransaction(txid)['hex'])['vout'] | self.nodes[1].gettransaction(txid)['hex'])['vout'] | ||||
keypath = "" | keypath = "" | ||||
for out in outs: | for out in outs: | ||||
if out['value'] != 1: | if out['value'] != 1: | ||||
keypath = self.nodes[1].getaddressinfo( | keypath = self.nodes[1].getaddressinfo( | ||||
out['scriptPubKey']['addresses'][0])['hdkeypath'] | out['scriptPubKey']['addresses'][0])['hdkeypath'] | ||||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |