|
|
@ -10,6 +10,7 @@ from test_framework.util import ( |
|
|
|
connect_nodes_bi, |
|
|
|
connect_nodes_bi, |
|
|
|
) |
|
|
|
) |
|
|
|
import shutil |
|
|
|
import shutil |
|
|
|
|
|
|
|
import os |
|
|
|
|
|
|
|
|
|
|
|
class WalletHDTest(BitcoinTestFramework): |
|
|
|
class WalletHDTest(BitcoinTestFramework): |
|
|
|
def set_test_params(self): |
|
|
|
def set_test_params(self): |
|
|
@ -70,9 +71,9 @@ class WalletHDTest(BitcoinTestFramework): |
|
|
|
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(tmpdir + "/node1/regtest/blocks") |
|
|
|
shutil.rmtree(os.path.join(tmpdir, "node1/regtest/blocks")) |
|
|
|
shutil.rmtree(tmpdir + "/node1/regtest/chainstate") |
|
|
|
shutil.rmtree(os.path.join(tmpdir, "node1/regtest/chainstate")) |
|
|
|
shutil.copyfile(tmpdir + "/hd.bak", tmpdir + "/node1/regtest/wallet.dat") |
|
|
|
shutil.copyfile(os.path.join(tmpdir, "hd.bak"), os.path.join(tmpdir, "node1/regtest/wallet.dat")) |
|
|
|
self.start_node(1) |
|
|
|
self.start_node(1) |
|
|
|
|
|
|
|
|
|
|
|
# Assert that derivation is deterministic |
|
|
|
# Assert that derivation is deterministic |
|
|
@ -91,6 +92,22 @@ class WalletHDTest(BitcoinTestFramework): |
|
|
|
self.start_node(1, extra_args=self.extra_args[1] + ['-rescan']) |
|
|
|
self.start_node(1, extra_args=self.extra_args[1] + ['-rescan']) |
|
|
|
assert_equal(self.nodes[1].getbalance(), num_hd_adds + 1) |
|
|
|
assert_equal(self.nodes[1].getbalance(), num_hd_adds + 1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Try a RPC based rescan |
|
|
|
|
|
|
|
self.stop_node(1) |
|
|
|
|
|
|
|
shutil.rmtree(os.path.join(tmpdir, "node1/regtest/blocks")) |
|
|
|
|
|
|
|
shutil.rmtree(os.path.join(tmpdir, "node1/regtest/chainstate")) |
|
|
|
|
|
|
|
shutil.copyfile(os.path.join(tmpdir, "hd.bak"), os.path.join(tmpdir, "node1/regtest/wallet.dat")) |
|
|
|
|
|
|
|
self.start_node(1, extra_args=self.extra_args[1]) |
|
|
|
|
|
|
|
connect_nodes_bi(self.nodes, 0, 1) |
|
|
|
|
|
|
|
self.sync_all() |
|
|
|
|
|
|
|
out = self.nodes[1].rescanblockchain(0, 1) |
|
|
|
|
|
|
|
assert_equal(out['start_height'], 0) |
|
|
|
|
|
|
|
assert_equal(out['stop_height'], 1) |
|
|
|
|
|
|
|
out = self.nodes[1].rescanblockchain() |
|
|
|
|
|
|
|
assert_equal(out['start_height'], 0) |
|
|
|
|
|
|
|
assert_equal(out['stop_height'], self.nodes[1].getblockcount()) |
|
|
|
|
|
|
|
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(self.nodes[1].gettransaction(txid)['hex'])['vout'] |
|
|
|
outs = self.nodes[1].decoderawtransaction(self.nodes[1].gettransaction(txid)['hex'])['vout'] |
|
|
|