Skip to content

Commit b22cce0

Browse files
committed
scripted-diff: validateaddress to getaddressinfo in tests
Change all instances of validateaddress to getaddressinfo since it seems that no test actually uses validateaddress for actually validating addresses. -BEGIN VERIFY SCRIPT- find ./test/functional -path '*py' -not -path ./test/functional/wallet_disable.py -not -path ./test/functional/rpc_deprecated.py -not -path ./test/functional/wallet_address_types.py -exec sed -i'' -e 's/validateaddress/getaddressinfo/g' {} \; -END VERIFY SCRIPT-
1 parent b98bfc5 commit b22cce0

14 files changed

+104
-104
lines changed

test/functional/feature_segwit.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def run_test(self):
9696
wit_ids = [] # wit_ids[NODE][VER] is an array of txids that spend to a witness version VER pkscript to an address for NODE via bare witness
9797
for i in range(3):
9898
newaddress = self.nodes[i].getnewaddress()
99-
self.pubkey.append(self.nodes[i].validateaddress(newaddress)["pubkey"])
99+
self.pubkey.append(self.nodes[i].getaddressinfo(newaddress)["pubkey"])
100100
multiscript = CScript([OP_1, hex_str_to_bytes(self.pubkey[-1]), OP_1, OP_CHECKMULTISIG])
101101
p2sh_addr = self.nodes[i].addwitnessaddress(newaddress)
102102
bip173_addr = self.nodes[i].addwitnessaddress(newaddress, False)
@@ -274,8 +274,8 @@ def run_test(self):
274274
uncompressed_spendable_address = ["mvozP4UwyGD2mGZU4D2eMvMLPB9WkMmMQu"]
275275
self.nodes[0].importprivkey("cNC8eQ5dg3mFAVePDX4ddmPYpPbw41r9bm2jd1nLJT77e6RrzTRR")
276276
compressed_spendable_address = ["mmWQubrDomqpgSYekvsU7HWEVjLFHAakLe"]
277-
assert ((self.nodes[0].validateaddress(uncompressed_spendable_address[0])['iscompressed'] == False))
278-
assert ((self.nodes[0].validateaddress(compressed_spendable_address[0])['iscompressed'] == True))
277+
assert ((self.nodes[0].getaddressinfo(uncompressed_spendable_address[0])['iscompressed'] == False))
278+
assert ((self.nodes[0].getaddressinfo(compressed_spendable_address[0])['iscompressed'] == True))
279279

280280
self.nodes[0].importpubkey(pubkeys[0])
281281
compressed_solvable_address = [key_to_p2pkh(pubkeys[0])]
@@ -308,7 +308,7 @@ def run_test(self):
308308
solvable_after_importaddress.append(CScript([OP_HASH160, hash160(script), OP_EQUAL]))
309309

310310
for i in compressed_spendable_address:
311-
v = self.nodes[0].validateaddress(i)
311+
v = self.nodes[0].getaddressinfo(i)
312312
if (v['isscript']):
313313
[bare, p2sh, p2wsh, p2sh_p2wsh] = self.p2sh_address_to_script(v)
314314
# bare and p2sh multisig with compressed keys should always be spendable
@@ -325,7 +325,7 @@ def run_test(self):
325325
spendable_anytime.extend([p2wpkh, p2sh_p2wpkh])
326326

327327
for i in uncompressed_spendable_address:
328-
v = self.nodes[0].validateaddress(i)
328+
v = self.nodes[0].getaddressinfo(i)
329329
if (v['isscript']):
330330
[bare, p2sh, p2wsh, p2sh_p2wsh] = self.p2sh_address_to_script(v)
331331
# bare and p2sh multisig with uncompressed keys should always be spendable
@@ -342,7 +342,7 @@ def run_test(self):
342342
unseen_anytime.extend([p2wpkh, p2sh_p2wpkh, p2wsh_p2pk, p2wsh_p2pkh, p2sh_p2wsh_p2pk, p2sh_p2wsh_p2pkh])
343343

344344
for i in compressed_solvable_address:
345-
v = self.nodes[0].validateaddress(i)
345+
v = self.nodes[0].getaddressinfo(i)
346346
if (v['isscript']):
347347
# Multisig without private is not seen after addmultisigaddress, but seen after importaddress
348348
[bare, p2sh, p2wsh, p2sh_p2wsh] = self.p2sh_address_to_script(v)
@@ -355,7 +355,7 @@ def run_test(self):
355355
solvable_after_importaddress.extend([p2sh_p2pk, p2sh_p2pkh, p2wsh_p2pk, p2wsh_p2pkh, p2sh_p2wsh_p2pk, p2sh_p2wsh_p2pkh])
356356

357357
for i in uncompressed_solvable_address:
358-
v = self.nodes[0].validateaddress(i)
358+
v = self.nodes[0].getaddressinfo(i)
359359
if (v['isscript']):
360360
[bare, p2sh, p2wsh, p2sh_p2wsh] = self.p2sh_address_to_script(v)
361361
# Base uncompressed multisig without private is not seen after addmultisigaddress, but seen after importaddress
@@ -395,7 +395,7 @@ def run_test(self):
395395

396396
importlist = []
397397
for i in compressed_spendable_address + uncompressed_spendable_address + compressed_solvable_address + uncompressed_solvable_address:
398-
v = self.nodes[0].validateaddress(i)
398+
v = self.nodes[0].getaddressinfo(i)
399399
if (v['isscript']):
400400
bare = hex_str_to_bytes(v['hex'])
401401
importlist.append(bytes_to_hex_str(bare))
@@ -473,7 +473,7 @@ def run_test(self):
473473
premature_witaddress = []
474474

475475
for i in compressed_spendable_address:
476-
v = self.nodes[0].validateaddress(i)
476+
v = self.nodes[0].getaddressinfo(i)
477477
if (v['isscript']):
478478
[bare, p2sh, p2wsh, p2sh_p2wsh] = self.p2sh_address_to_script(v)
479479
# P2WSH and P2SH(P2WSH) multisig with compressed keys are spendable after addwitnessaddress
@@ -485,7 +485,7 @@ def run_test(self):
485485
spendable_anytime.extend([p2wpkh, p2sh_p2wpkh])
486486

487487
for i in uncompressed_spendable_address + uncompressed_solvable_address:
488-
v = self.nodes[0].validateaddress(i)
488+
v = self.nodes[0].getaddressinfo(i)
489489
if (v['isscript']):
490490
[bare, p2sh, p2wsh, p2sh_p2wsh] = self.p2sh_address_to_script(v)
491491
# P2WSH and P2SH(P2WSH) multisig with uncompressed keys are never seen
@@ -496,7 +496,7 @@ def run_test(self):
496496
unseen_anytime.extend([p2wpkh, p2sh_p2wpkh])
497497

498498
for i in compressed_solvable_address:
499-
v = self.nodes[0].validateaddress(i)
499+
v = self.nodes[0].getaddressinfo(i)
500500
if (v['isscript']):
501501
# P2WSH multisig without private key are seen after addwitnessaddress
502502
[bare, p2sh, p2wsh, p2sh_p2wsh] = self.p2sh_address_to_script(v)
@@ -519,7 +519,7 @@ def run_test(self):
519519
assert_raises_rpc_error(-4, "Public key or redeemscript not known to wallet, or the key is uncompressed", self.nodes[0].addwitnessaddress, i)
520520

521521
# after importaddress it should pass addwitnessaddress
522-
v = self.nodes[0].validateaddress(compressed_solvable_address[1])
522+
v = self.nodes[0].getaddressinfo(compressed_solvable_address[1])
523523
self.nodes[0].importaddress(v['hex'],"",False,True)
524524
for i in compressed_spendable_address + compressed_solvable_address + premature_witaddress:
525525
witaddress = self.nodes[0].addwitnessaddress(i)

test/functional/rpc_fundrawtransaction.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def run_test(self):
5353
assert_equal(rawmatch["changepos"], -1)
5454

5555
watchonly_address = self.nodes[0].getnewaddress()
56-
watchonly_pubkey = self.nodes[0].validateaddress(watchonly_address)["pubkey"]
56+
watchonly_pubkey = self.nodes[0].getaddressinfo(watchonly_address)["pubkey"]
5757
watchonly_amount = Decimal(200)
5858
self.nodes[3].importpubkey(watchonly_pubkey, "", True)
5959
watchonly_txid = self.nodes[0].sendtoaddress(watchonly_address, watchonly_amount)
@@ -371,8 +371,8 @@ def run_test(self):
371371
addr1 = self.nodes[1].getnewaddress()
372372
addr2 = self.nodes[1].getnewaddress()
373373

374-
addr1Obj = self.nodes[1].validateaddress(addr1)
375-
addr2Obj = self.nodes[1].validateaddress(addr2)
374+
addr1Obj = self.nodes[1].getaddressinfo(addr1)
375+
addr2Obj = self.nodes[1].getaddressinfo(addr2)
376376

377377
mSigObj = self.nodes[1].addmultisigaddress(2, [addr1Obj['pubkey'], addr2Obj['pubkey']])['address']
378378

@@ -401,11 +401,11 @@ def run_test(self):
401401
addr4 = self.nodes[1].getnewaddress()
402402
addr5 = self.nodes[1].getnewaddress()
403403

404-
addr1Obj = self.nodes[1].validateaddress(addr1)
405-
addr2Obj = self.nodes[1].validateaddress(addr2)
406-
addr3Obj = self.nodes[1].validateaddress(addr3)
407-
addr4Obj = self.nodes[1].validateaddress(addr4)
408-
addr5Obj = self.nodes[1].validateaddress(addr5)
404+
addr1Obj = self.nodes[1].getaddressinfo(addr1)
405+
addr2Obj = self.nodes[1].getaddressinfo(addr2)
406+
addr3Obj = self.nodes[1].getaddressinfo(addr3)
407+
addr4Obj = self.nodes[1].getaddressinfo(addr4)
408+
addr5Obj = self.nodes[1].getaddressinfo(addr5)
409409

410410
mSigObj = self.nodes[1].addmultisigaddress(4, [addr1Obj['pubkey'], addr2Obj['pubkey'], addr3Obj['pubkey'], addr4Obj['pubkey'], addr5Obj['pubkey']])['address']
411411

@@ -431,8 +431,8 @@ def run_test(self):
431431
addr1 = self.nodes[2].getnewaddress()
432432
addr2 = self.nodes[2].getnewaddress()
433433

434-
addr1Obj = self.nodes[2].validateaddress(addr1)
435-
addr2Obj = self.nodes[2].validateaddress(addr2)
434+
addr1Obj = self.nodes[2].getaddressinfo(addr1)
435+
addr2Obj = self.nodes[2].getaddressinfo(addr2)
436436

437437
mSigObj = self.nodes[2].addmultisigaddress(2, [addr1Obj['pubkey'], addr2Obj['pubkey']])['address']
438438

test/functional/rpc_listtransactions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def run_test(self):
8181
{"category":"receive","amount":Decimal("0.44")},
8282
{"txid":txid, "account" : "toself"} )
8383

84-
pubkey = self.nodes[1].validateaddress(self.nodes[1].getnewaddress())['pubkey']
84+
pubkey = self.nodes[1].getaddressinfo(self.nodes[1].getnewaddress())['pubkey']
8585
multisig = self.nodes[1].createmultisig(1, [pubkey])
8686
self.nodes[0].importaddress(multisig["redeemScript"], "watchonly", False, True)
8787
txid = self.nodes[1].sendtoaddress(multisig["address"], 0.1)

test/functional/rpc_rawtransaction.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def run_test(self):
146146
addr1 = self.nodes[2].getnewaddress()
147147
addr2 = self.nodes[2].getnewaddress()
148148

149-
addr1Obj = self.nodes[2].validateaddress(addr1)
150-
addr2Obj = self.nodes[2].validateaddress(addr2)
149+
addr1Obj = self.nodes[2].getaddressinfo(addr1)
150+
addr2Obj = self.nodes[2].getaddressinfo(addr2)
151151

152152
# Tests for createmultisig and addmultisigaddress
153153
assert_raises_rpc_error(-5, "Invalid public key", self.nodes[0].createmultisig, 1, ["01020304"])
@@ -173,9 +173,9 @@ def run_test(self):
173173
addr2 = self.nodes[2].getnewaddress()
174174
addr3 = self.nodes[2].getnewaddress()
175175

176-
addr1Obj = self.nodes[1].validateaddress(addr1)
177-
addr2Obj = self.nodes[2].validateaddress(addr2)
178-
addr3Obj = self.nodes[2].validateaddress(addr3)
176+
addr1Obj = self.nodes[1].getaddressinfo(addr1)
177+
addr2Obj = self.nodes[2].getaddressinfo(addr2)
178+
addr3Obj = self.nodes[2].getaddressinfo(addr3)
179179

180180
mSigObj = self.nodes[2].addmultisigaddress(2, [addr1Obj['pubkey'], addr2Obj['pubkey'], addr3Obj['pubkey']])['address']
181181

@@ -219,12 +219,12 @@ def run_test(self):
219219
addr1 = self.nodes[1].getnewaddress()
220220
addr2 = self.nodes[2].getnewaddress()
221221

222-
addr1Obj = self.nodes[1].validateaddress(addr1)
223-
addr2Obj = self.nodes[2].validateaddress(addr2)
222+
addr1Obj = self.nodes[1].getaddressinfo(addr1)
223+
addr2Obj = self.nodes[2].getaddressinfo(addr2)
224224

225225
self.nodes[1].addmultisigaddress(2, [addr1Obj['pubkey'], addr2Obj['pubkey']])['address']
226226
mSigObj = self.nodes[2].addmultisigaddress(2, [addr1Obj['pubkey'], addr2Obj['pubkey']])['address']
227-
mSigObjValid = self.nodes[2].validateaddress(mSigObj)
227+
mSigObjValid = self.nodes[2].getaddressinfo(mSigObj)
228228

229229
txId = self.nodes[0].sendtoaddress(mSigObj, 2.2)
230230
decTx = self.nodes[0].gettransaction(txId)

test/functional/test_framework/blocktools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def create_witness_tx(node, use_p2wsh, utxo, pubkey, encode_p2sh, amount):
149149
else:
150150
addr = key_to_p2sh_p2wpkh(pubkey) if encode_p2sh else key_to_p2wpkh(pubkey)
151151
if not encode_p2sh:
152-
assert_equal(node.validateaddress(addr)['scriptPubKey'], witness_script(use_p2wsh, pubkey))
152+
assert_equal(node.getaddressinfo(addr)['scriptPubKey'], witness_script(use_p2wsh, pubkey))
153153
return node.createrawtransaction([utxo], {addr: amount})
154154

155155
# Create a transaction spending a given utxo to a segwit output corresponding

test/functional/wallet_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def run_test(self):
317317
self.nodes[1].importaddress(address_to_import)
318318

319319
# 3. Validate that the imported address is watch-only on node1
320-
assert(self.nodes[1].validateaddress(address_to_import)["iswatchonly"])
320+
assert(self.nodes[1].getaddressinfo(address_to_import)["iswatchonly"])
321321

322322
# 4. Check that the unspents after import are not spendable
323323
assert_array_result(self.nodes[1].listunspent(),

test/functional/wallet_bumpfee.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test_segwit_bumpfee_succeeds(rbf_node, dest_address):
104104
# which spends it, and make sure bumpfee can be called on it.
105105

106106
segwit_in = next(u for u in rbf_node.listunspent() if u["amount"] == Decimal("0.001"))
107-
segwit_out = rbf_node.validateaddress(rbf_node.getnewaddress())
107+
segwit_out = rbf_node.getaddressinfo(rbf_node.getnewaddress())
108108
rbf_node.addwitnessaddress(segwit_out["address"])
109109
segwitid = send_to_witness(
110110
use_p2wsh=False,

test/functional/wallet_dump.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def run_test (self):
9797
addrs = []
9898
for i in range(0,test_addr_count):
9999
addr = self.nodes[0].getnewaddress()
100-
vaddr= self.nodes[0].validateaddress(addr) #required to get hd keypath
100+
vaddr= self.nodes[0].getaddressinfo(addr) #required to get hd keypath
101101
addrs.append(vaddr)
102102
# Should be a no-op:
103103
self.nodes[0].keypoolrefill()
@@ -143,13 +143,13 @@ def run_test (self):
143143
self.start_node(0, ['-wallet=w2'])
144144

145145
# Make sure the address is not IsMine before import
146-
result = self.nodes[0].validateaddress(multisig_addr)
146+
result = self.nodes[0].getaddressinfo(multisig_addr)
147147
assert(result['ismine'] == False)
148148

149149
self.nodes[0].importwallet(os.path.abspath(tmpdir + "/node0/wallet.unencrypted.dump"))
150150

151151
# Now check IsMine is true
152-
result = self.nodes[0].validateaddress(multisig_addr)
152+
result = self.nodes[0].getaddressinfo(multisig_addr)
153153
assert(result['ismine'] == True)
154154

155155
if __name__ == '__main__':

test/functional/wallet_hd.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def run_test (self):
3333

3434
# create an internal key
3535
change_addr = self.nodes[1].getrawchangeaddress()
36-
change_addrV= self.nodes[1].validateaddress(change_addr)
36+
change_addrV= self.nodes[1].getaddressinfo(change_addr)
3737
assert_equal(change_addrV["hdkeypath"], "m/0'/1'/0'") #first internal child key
3838

3939
# Import a non-HD private key in the HD wallet
@@ -51,7 +51,7 @@ def run_test (self):
5151
num_hd_adds = 300
5252
for i in range(num_hd_adds):
5353
hd_add = self.nodes[1].getnewaddress()
54-
hd_info = self.nodes[1].validateaddress(hd_add)
54+
hd_info = self.nodes[1].getaddressinfo(hd_add)
5555
assert_equal(hd_info["hdkeypath"], "m/0'/0'/"+str(i)+"'")
5656
assert_equal(hd_info["hdmasterkeyid"], masterkeyid)
5757
self.nodes[0].sendtoaddress(hd_add, 1)
@@ -61,7 +61,7 @@ def run_test (self):
6161

6262
# create an internal key (again)
6363
change_addr = self.nodes[1].getrawchangeaddress()
64-
change_addrV= self.nodes[1].validateaddress(change_addr)
64+
change_addrV= self.nodes[1].getaddressinfo(change_addr)
6565
assert_equal(change_addrV["hdkeypath"], "m/0'/1'/1'") #second internal child key
6666

6767
self.sync_all()
@@ -80,7 +80,7 @@ def run_test (self):
8080
hd_add_2 = None
8181
for _ in range(num_hd_adds):
8282
hd_add_2 = self.nodes[1].getnewaddress()
83-
hd_info_2 = self.nodes[1].validateaddress(hd_add_2)
83+
hd_info_2 = self.nodes[1].getaddressinfo(hd_add_2)
8484
assert_equal(hd_info_2["hdkeypath"], "m/0'/0'/"+str(_)+"'")
8585
assert_equal(hd_info_2["hdmasterkeyid"], masterkeyid)
8686
assert_equal(hd_add, hd_add_2)
@@ -114,7 +114,7 @@ def run_test (self):
114114
keypath = ""
115115
for out in outs:
116116
if out['value'] != 1:
117-
keypath = self.nodes[1].validateaddress(out['scriptPubKey']['addresses'][0])['hdkeypath']
117+
keypath = self.nodes[1].getaddressinfo(out['scriptPubKey']['addresses'][0])['hdkeypath']
118118

119119
assert_equal(keypath[0:7], "m/0'/1'")
120120

test/functional/wallet_import_rescan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def run_test(self):
134134
# each possible type of wallet import RPC.
135135
for i, variant in enumerate(IMPORT_VARIANTS):
136136
variant.label = "label {} {}".format(i, variant)
137-
variant.address = self.nodes[1].validateaddress(self.nodes[1].getnewaddress(variant.label))
137+
variant.address = self.nodes[1].getaddressinfo(self.nodes[1].getnewaddress(variant.label))
138138
variant.key = self.nodes[1].dumpprivkey(variant.address["address"])
139139
variant.initial_amount = 10 - (i + 1) / 4.0
140140
variant.initial_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.initial_amount)

0 commit comments

Comments
 (0)