10
10
connect_nodes_bi ,
11
11
)
12
12
import shutil
13
+ import os
13
14
14
15
class WalletHDTest (BitcoinTestFramework ):
15
16
def set_test_params (self ):
@@ -70,9 +71,9 @@ def run_test (self):
70
71
self .stop_node (1 )
71
72
# we need to delete the complete regtest directory
72
73
# otherwise node1 would auto-recover all funds in flag the keypool keys as used
73
- shutil .rmtree (tmpdir + "/ node1/regtest/blocks" )
74
- shutil .rmtree (tmpdir + "/ node1/regtest/chainstate" )
75
- shutil .copyfile (tmpdir + "/ hd.bak", tmpdir + "/ node1/regtest/wallet.dat" )
74
+ shutil .rmtree (os . path . join ( tmpdir , " node1/regtest/blocks") )
75
+ shutil .rmtree (os . path . join ( tmpdir , " node1/regtest/chainstate") )
76
+ shutil .copyfile (os . path . join ( tmpdir , " hd.bak"), os . path . join ( tmpdir , " node1/regtest/wallet.dat") )
76
77
self .start_node (1 )
77
78
78
79
# Assert that derivation is deterministic
@@ -91,6 +92,22 @@ def run_test (self):
91
92
self .start_node (1 , extra_args = self .extra_args [1 ] + ['-rescan' ])
92
93
assert_equal (self .nodes [1 ].getbalance (), num_hd_adds + 1 )
93
94
95
+ # Try a RPC based rescan
96
+ self .stop_node (1 )
97
+ shutil .rmtree (os .path .join (tmpdir , "node1/regtest/blocks" ))
98
+ shutil .rmtree (os .path .join (tmpdir , "node1/regtest/chainstate" ))
99
+ shutil .copyfile (os .path .join (tmpdir , "hd.bak" ), os .path .join (tmpdir , "node1/regtest/wallet.dat" ))
100
+ self .start_node (1 , extra_args = self .extra_args [1 ])
101
+ connect_nodes_bi (self .nodes , 0 , 1 )
102
+ self .sync_all ()
103
+ out = self .nodes [1 ].rescanblockchain (0 , 1 )
104
+ assert_equal (out ['start_height' ], 0 )
105
+ assert_equal (out ['stop_height' ], 1 )
106
+ out = self .nodes [1 ].rescanblockchain ()
107
+ assert_equal (out ['start_height' ], 0 )
108
+ assert_equal (out ['stop_height' ], self .nodes [1 ].getblockcount ())
109
+ assert_equal (self .nodes [1 ].getbalance (), num_hd_adds + 1 )
110
+
94
111
# send a tx and make sure its using the internal chain for the changeoutput
95
112
txid = self .nodes [1 ].sendtoaddress (self .nodes [0 ].getnewaddress (), 1 )
96
113
outs = self .nodes [1 ].decoderawtransaction (self .nodes [1 ].gettransaction (txid )['hex' ])['vout' ]
0 commit comments