7
7
Test rescan behavior of importaddress, importpubkey, importprivkey, and
8
8
importmulti RPCs with different types of keys and rescan options.
9
9
10
- In the first part of the test, node 0 creates an address for each type of
11
- import RPC call and sends BTC to it. Then other nodes import the addresses,
12
- and the test makes listtransactions and getbalance calls to confirm that the
13
- importing node either did or did not execute rescans picking up the send
14
- transactions.
10
+ In the first part of the test, node 1 creates an address for each type of
11
+ import RPC call and node 0 sends BTC to it. Then other nodes import the
12
+ addresses, and the test makes listtransactions and getbalance calls to confirm
13
+ that the importing node either did or did not execute rescans picking up the
14
+ send transactions.
15
15
16
16
In the second part of the test, node 0 sends more BTC to each address, and the
17
17
test makes more listtransactions and getbalance calls to confirm that the
@@ -83,6 +83,12 @@ def check(self, txid=None, amount=None, confirmations=None):
83
83
assert_equal (tx ["txid" ], txid )
84
84
assert_equal (tx ["confirmations" ], confirmations )
85
85
assert_equal ("trusted" not in tx , True )
86
+ # Verify the transaction is correctly marked watchonly depending on
87
+ # whether the transaction pays to an imported public key or
88
+ # imported private key. The test setup ensures that transaction
89
+ # inputs will not be from watchonly keys (important because
90
+ # involvesWatchonly will be true if either the transaction output
91
+ # or inputs are watchonly).
86
92
if self .data != Data .priv :
87
93
assert_equal (tx ["involvesWatchonly" ], True )
88
94
else :
@@ -108,11 +114,11 @@ def check(self, txid=None, amount=None, confirmations=None):
108
114
class ImportRescanTest (BitcoinTestFramework ):
109
115
def __init__ (self ):
110
116
super ().__init__ ()
111
- self .num_nodes = 1 + len (IMPORT_NODES )
117
+ self .num_nodes = 2 + len (IMPORT_NODES )
112
118
113
119
def setup_network (self ):
114
120
extra_args = [["-debug=1" ] for _ in range (self .num_nodes )]
115
- for i , import_node in enumerate (IMPORT_NODES , 1 ):
121
+ for i , import_node in enumerate (IMPORT_NODES , 2 ):
116
122
if import_node .prune :
117
123
extra_args [i ] += ["-prune=1" ]
118
124
@@ -125,9 +131,9 @@ def run_test(self):
125
131
# each possible type of wallet import RPC.
126
132
for i , variant in enumerate (IMPORT_VARIANTS ):
127
133
variant .label = "label {} {}" .format (i , variant )
128
- variant .address = self .nodes [0 ].validateaddress (self .nodes [0 ].getnewaddress (variant .label ))
129
- variant .key = self .nodes [0 ].dumpprivkey (variant .address ["address" ])
130
- variant .initial_amount = 25 - (i + 1 ) / 4.0
134
+ variant .address = self .nodes [1 ].validateaddress (self .nodes [1 ].getnewaddress (variant .label ))
135
+ variant .key = self .nodes [1 ].dumpprivkey (variant .address ["address" ])
136
+ variant .initial_amount = 10 - (i + 1 ) / 4.0
131
137
variant .initial_txid = self .nodes [0 ].sendtoaddress (variant .address ["address" ], variant .initial_amount )
132
138
133
139
# Generate a block containing the initial transactions, then another
@@ -144,7 +150,7 @@ def run_test(self):
144
150
for variant in IMPORT_VARIANTS :
145
151
variant .expect_disabled = variant .rescan == Rescan .yes and variant .prune and variant .call == Call .single
146
152
expect_rescan = variant .rescan == Rescan .yes and not variant .expect_disabled
147
- variant .node = self .nodes [1 + IMPORT_NODES .index (ImportNode (variant .prune , expect_rescan ))]
153
+ variant .node = self .nodes [2 + IMPORT_NODES .index (ImportNode (variant .prune , expect_rescan ))]
148
154
variant .do_import (timestamp )
149
155
if expect_rescan :
150
156
variant .expected_balance = variant .initial_amount
@@ -158,7 +164,7 @@ def run_test(self):
158
164
# Create new transactions sending to each address.
159
165
fee = self .nodes [0 ].getnetworkinfo ()["relayfee" ]
160
166
for i , variant in enumerate (IMPORT_VARIANTS ):
161
- variant .sent_amount = 25 - (2 * i + 1 ) / 8.0
167
+ variant .sent_amount = 10 - (2 * i + 1 ) / 8.0
162
168
variant .sent_txid = self .nodes [0 ].sendtoaddress (variant .address ["address" ], variant .sent_amount )
163
169
164
170
# Generate a block containing the new transactions.
0 commit comments