Skip to content

Commit 07e3f58

Browse files
committed
[test] Remove deprecated addwitnessaddress from feature_segwit.py
1 parent 82f2fa0 commit 07e3f58

File tree

1 file changed

+1
-49
lines changed

1 file changed

+1
-49
lines changed

test/functional/feature_segwit.py

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
from test_framework.address import (
1111
key_to_p2pkh,
12-
key_to_p2sh_p2wpkh,
13-
key_to_p2wpkh,
1412
program_to_witness,
1513
script_to_p2sh,
1614
script_to_p2sh_p2wsh,
@@ -50,20 +48,17 @@ def set_test_params(self):
5048
"-rpcserialversion=0",
5149
"-vbparams=segwit:0:999999999999",
5250
"-addresstype=legacy",
53-
"-deprecatedrpc=addwitnessaddress",
5451
],
5552
[
5653
"-blockversion=4",
5754
"-rpcserialversion=1",
5855
"-vbparams=segwit:0:999999999999",
5956
"-addresstype=legacy",
60-
"-deprecatedrpc=addwitnessaddress",
6157
],
6258
[
6359
"-blockversion=536870915",
6460
"-vbparams=segwit:0:999999999999",
6561
"-addresstype=legacy",
66-
"-deprecatedrpc=addwitnessaddress",
6762
],
6863
]
6964

@@ -117,12 +112,8 @@ def run_test(self):
117112
newaddress = self.nodes[i].getnewaddress()
118113
self.pubkey.append(self.nodes[i].getaddressinfo(newaddress)["pubkey"])
119114
multiscript = CScript([OP_1, hex_str_to_bytes(self.pubkey[-1]), OP_1, OP_CHECKMULTISIG])
120-
p2sh_addr = self.nodes[i].addwitnessaddress(newaddress)
121-
bip173_addr = self.nodes[i].addwitnessaddress(newaddress, False)
122115
p2sh_ms_addr = self.nodes[i].addmultisigaddress(1, [self.pubkey[-1]], '', 'p2sh-segwit')['address']
123116
bip173_ms_addr = self.nodes[i].addmultisigaddress(1, [self.pubkey[-1]], '', 'bech32')['address']
124-
assert_equal(p2sh_addr, key_to_p2sh_p2wpkh(self.pubkey[-1]))
125-
assert_equal(bip173_addr, key_to_p2wpkh(self.pubkey[-1]))
126117
assert_equal(p2sh_ms_addr, script_to_p2sh_p2wsh(multiscript))
127118
assert_equal(bip173_ms_addr, script_to_p2wsh(multiscript))
128119
p2sh_ids.append([])
@@ -262,7 +253,7 @@ def run_test(self):
262253
# Mine a block to clear the gbt cache again.
263254
self.nodes[0].generate(1)
264255

265-
self.log.info("Verify behaviour of importaddress, addwitnessaddress and listunspent")
256+
self.log.info("Verify behaviour of importaddress and listunspent")
266257

267258
# Some public keys to be used later
268259
pubkeys = [
@@ -303,7 +294,6 @@ def run_test(self):
303294
uncompressed_solvable_address.append(self.nodes[0].addmultisigaddress(2, [compressed_spendable_address[0], uncompressed_solvable_address[0]])['address'])
304295
compressed_solvable_address.append(self.nodes[0].addmultisigaddress(2, [compressed_spendable_address[0], compressed_solvable_address[0]])['address'])
305296
compressed_solvable_address.append(self.nodes[0].addmultisigaddress(2, [compressed_solvable_address[0], compressed_solvable_address[1]])['address'])
306-
unknown_address = ["mtKKyoHabkk6e4ppT7NaM7THqPUt7AzPrT", "2NDP3jLWAFT8NDAiUa9qiE6oBt2awmMq7Dx"]
307297

308298
# Test multisig_without_privkey
309299
# We have 2 public keys without private keys, use addmultisigaddress to add to wallet.
@@ -384,7 +374,6 @@ def run_test(self):
384374
op1 = CScript([OP_1])
385375
op0 = CScript([OP_0])
386376
# 2N7MGY19ti4KDMSzRfPAssP6Pxyuxoi6jLe is the P2SH(P2PKH) version of mjoE3sSrb8ByYEvgnC3Aox86u1CHnfJA4V
387-
unsolvable_address = ["mjoE3sSrb8ByYEvgnC3Aox86u1CHnfJA4V", "2N7MGY19ti4KDMSzRfPAssP6Pxyuxoi6jLe", script_to_p2sh(op1), script_to_p2sh(op0)]
388377
unsolvable_address_key = hex_str_to_bytes("02341AEC7587A51CDE5279E0630A531AEA2615A9F80B17E8D9376327BAEAA59E3D")
389378
unsolvablep2pkh = CScript([OP_DUP, OP_HASH160, hash160(unsolvable_address_key), OP_EQUALVERIFY, OP_CHECKSIG])
390379
unsolvablep2wshp2pkh = CScript([OP_0, sha256(unsolvablep2pkh)])
@@ -438,19 +427,6 @@ def run_test(self):
438427
self.mine_and_test_listunspent(unsolvable_after_importaddress, 1)
439428
self.mine_and_test_listunspent(unseen_anytime, 0)
440429

441-
# addwitnessaddress should refuse to return a witness address if an uncompressed key is used
442-
# note that no witness address should be returned by unsolvable addresses
443-
for i in uncompressed_spendable_address + uncompressed_solvable_address + unknown_address + unsolvable_address:
444-
assert_raises_rpc_error(-4, "Public key or redeemscript not known to wallet, or the key is uncompressed", self.nodes[0].addwitnessaddress, i)
445-
446-
# addwitnessaddress should return a witness addresses even if keys are not in the wallet
447-
self.nodes[0].addwitnessaddress(multisig_without_privkey_address)
448-
449-
for i in compressed_spendable_address + compressed_solvable_address:
450-
witaddress = self.nodes[0].addwitnessaddress(i)
451-
# addwitnessaddress should return the same address if it is a known P2SH-witness address
452-
assert_equal(witaddress, self.nodes[0].addwitnessaddress(witaddress))
453-
454430
spendable_txid.append(self.mine_and_test_listunspent(spendable_anytime + spendable_after_importaddress, 2))
455431
solvable_txid.append(self.mine_and_test_listunspent(solvable_anytime + solvable_after_importaddress, 1))
456432
self.mine_and_test_listunspent(unsolvable_after_importaddress, 1)
@@ -468,8 +444,6 @@ def run_test(self):
468444
self.nodes[0].importpubkey(pubkeys[6])
469445
uncompressed_solvable_address = [key_to_p2pkh(pubkeys[6])]
470446

471-
spendable_after_addwitnessaddress = [] # These outputs should be seen after importaddress
472-
solvable_after_addwitnessaddress = [] # These outputs should be seen after importaddress but not spendable
473447
unseen_anytime = [] # These outputs should never be seen
474448
solvable_anytime = [] # These outputs should be solvable after importpubkey
475449
unseen_anytime = [] # These outputs should never be seen
@@ -486,8 +460,6 @@ def run_test(self):
486460
v = self.nodes[0].getaddressinfo(i)
487461
if (v['isscript']):
488462
[bare, p2sh, p2wsh, p2sh_p2wsh] = self.p2sh_address_to_script(v)
489-
# P2WSH and P2SH(P2WSH) multisig with compressed keys are spendable after addwitnessaddress
490-
spendable_after_addwitnessaddress.extend([p2wsh, p2sh_p2wsh])
491463
premature_witaddress.append(script_to_p2sh(p2wsh))
492464
else:
493465
[p2wpkh, p2sh_p2wpkh, p2pk, p2pkh, p2sh_p2pk, p2sh_p2pkh, p2wsh_p2pk, p2wsh_p2pkh, p2sh_p2wsh_p2pk, p2sh_p2wsh_p2pkh] = self.p2pkh_address_to_script(v)
@@ -508,9 +480,7 @@ def run_test(self):
508480
for i in compressed_solvable_address:
509481
v = self.nodes[0].getaddressinfo(i)
510482
if (v['isscript']):
511-
# P2WSH multisig without private key are seen after addwitnessaddress
512483
[bare, p2sh, p2wsh, p2sh_p2wsh] = self.p2sh_address_to_script(v)
513-
solvable_after_addwitnessaddress.extend([p2wsh, p2sh_p2wsh])
514484
premature_witaddress.append(script_to_p2sh(p2wsh))
515485
else:
516486
[p2wpkh, p2sh_p2wpkh, p2pk, p2pkh, p2sh_p2pk, p2sh_p2pkh, p2wsh_p2pk, p2wsh_p2pkh, p2sh_p2wsh_p2pk, p2sh_p2wsh_p2pkh] = self.p2pkh_address_to_script(v)
@@ -519,24 +489,6 @@ def run_test(self):
519489

520490
self.mine_and_test_listunspent(spendable_anytime, 2)
521491
self.mine_and_test_listunspent(solvable_anytime, 1)
522-
self.mine_and_test_listunspent(spendable_after_addwitnessaddress + solvable_after_addwitnessaddress + unseen_anytime, 0)
523-
524-
# addwitnessaddress should refuse to return a witness address if an uncompressed key is used
525-
# note that a multisig address returned by addmultisigaddress is not solvable until it is added with importaddress
526-
# premature_witaddress are not accepted until the script is added with addwitnessaddress first
527-
for i in uncompressed_spendable_address + uncompressed_solvable_address + premature_witaddress:
528-
# This will raise an exception
529-
assert_raises_rpc_error(-4, "Public key or redeemscript not known to wallet, or the key is uncompressed", self.nodes[0].addwitnessaddress, i)
530-
531-
# after importaddress it should pass addwitnessaddress
532-
v = self.nodes[0].getaddressinfo(compressed_solvable_address[1])
533-
self.nodes[0].importaddress(v['hex'], "", False, True)
534-
for i in compressed_spendable_address + compressed_solvable_address + premature_witaddress:
535-
witaddress = self.nodes[0].addwitnessaddress(i)
536-
assert_equal(witaddress, self.nodes[0].addwitnessaddress(witaddress))
537-
538-
spendable_txid.append(self.mine_and_test_listunspent(spendable_after_addwitnessaddress + spendable_anytime, 2))
539-
solvable_txid.append(self.mine_and_test_listunspent(solvable_after_addwitnessaddress + solvable_anytime, 1))
540492
self.mine_and_test_listunspent(unseen_anytime, 0)
541493

542494
# Check that createrawtransaction/decoderawtransaction with non-v0 Bech32 works

0 commit comments

Comments
 (0)