9
9
10
10
from test_framework .address import (
11
11
key_to_p2pkh ,
12
- key_to_p2sh_p2wpkh ,
13
- key_to_p2wpkh ,
14
12
program_to_witness ,
15
13
script_to_p2sh ,
16
14
script_to_p2sh_p2wsh ,
@@ -50,20 +48,17 @@ def set_test_params(self):
50
48
"-rpcserialversion=0" ,
51
49
"-vbparams=segwit:0:999999999999" ,
52
50
"-addresstype=legacy" ,
53
- "-deprecatedrpc=addwitnessaddress" ,
54
51
],
55
52
[
56
53
"-blockversion=4" ,
57
54
"-rpcserialversion=1" ,
58
55
"-vbparams=segwit:0:999999999999" ,
59
56
"-addresstype=legacy" ,
60
- "-deprecatedrpc=addwitnessaddress" ,
61
57
],
62
58
[
63
59
"-blockversion=536870915" ,
64
60
"-vbparams=segwit:0:999999999999" ,
65
61
"-addresstype=legacy" ,
66
- "-deprecatedrpc=addwitnessaddress" ,
67
62
],
68
63
]
69
64
@@ -117,12 +112,8 @@ def run_test(self):
117
112
newaddress = self .nodes [i ].getnewaddress ()
118
113
self .pubkey .append (self .nodes [i ].getaddressinfo (newaddress )["pubkey" ])
119
114
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 )
122
115
p2sh_ms_addr = self .nodes [i ].addmultisigaddress (1 , [self .pubkey [- 1 ]], '' , 'p2sh-segwit' )['address' ]
123
116
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 ]))
126
117
assert_equal (p2sh_ms_addr , script_to_p2sh_p2wsh (multiscript ))
127
118
assert_equal (bip173_ms_addr , script_to_p2wsh (multiscript ))
128
119
p2sh_ids .append ([])
@@ -262,7 +253,7 @@ def run_test(self):
262
253
# Mine a block to clear the gbt cache again.
263
254
self .nodes [0 ].generate (1 )
264
255
265
- self .log .info ("Verify behaviour of importaddress, addwitnessaddress and listunspent" )
256
+ self .log .info ("Verify behaviour of importaddress and listunspent" )
266
257
267
258
# Some public keys to be used later
268
259
pubkeys = [
@@ -303,7 +294,6 @@ def run_test(self):
303
294
uncompressed_solvable_address .append (self .nodes [0 ].addmultisigaddress (2 , [compressed_spendable_address [0 ], uncompressed_solvable_address [0 ]])['address' ])
304
295
compressed_solvable_address .append (self .nodes [0 ].addmultisigaddress (2 , [compressed_spendable_address [0 ], compressed_solvable_address [0 ]])['address' ])
305
296
compressed_solvable_address .append (self .nodes [0 ].addmultisigaddress (2 , [compressed_solvable_address [0 ], compressed_solvable_address [1 ]])['address' ])
306
- unknown_address = ["mtKKyoHabkk6e4ppT7NaM7THqPUt7AzPrT" , "2NDP3jLWAFT8NDAiUa9qiE6oBt2awmMq7Dx" ]
307
297
308
298
# Test multisig_without_privkey
309
299
# We have 2 public keys without private keys, use addmultisigaddress to add to wallet.
@@ -384,7 +374,6 @@ def run_test(self):
384
374
op1 = CScript ([OP_1 ])
385
375
op0 = CScript ([OP_0 ])
386
376
# 2N7MGY19ti4KDMSzRfPAssP6Pxyuxoi6jLe is the P2SH(P2PKH) version of mjoE3sSrb8ByYEvgnC3Aox86u1CHnfJA4V
387
- unsolvable_address = ["mjoE3sSrb8ByYEvgnC3Aox86u1CHnfJA4V" , "2N7MGY19ti4KDMSzRfPAssP6Pxyuxoi6jLe" , script_to_p2sh (op1 ), script_to_p2sh (op0 )]
388
377
unsolvable_address_key = hex_str_to_bytes ("02341AEC7587A51CDE5279E0630A531AEA2615A9F80B17E8D9376327BAEAA59E3D" )
389
378
unsolvablep2pkh = CScript ([OP_DUP , OP_HASH160 , hash160 (unsolvable_address_key ), OP_EQUALVERIFY , OP_CHECKSIG ])
390
379
unsolvablep2wshp2pkh = CScript ([OP_0 , sha256 (unsolvablep2pkh )])
@@ -438,19 +427,6 @@ def run_test(self):
438
427
self .mine_and_test_listunspent (unsolvable_after_importaddress , 1 )
439
428
self .mine_and_test_listunspent (unseen_anytime , 0 )
440
429
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
-
454
430
spendable_txid .append (self .mine_and_test_listunspent (spendable_anytime + spendable_after_importaddress , 2 ))
455
431
solvable_txid .append (self .mine_and_test_listunspent (solvable_anytime + solvable_after_importaddress , 1 ))
456
432
self .mine_and_test_listunspent (unsolvable_after_importaddress , 1 )
@@ -468,8 +444,6 @@ def run_test(self):
468
444
self .nodes [0 ].importpubkey (pubkeys [6 ])
469
445
uncompressed_solvable_address = [key_to_p2pkh (pubkeys [6 ])]
470
446
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
473
447
unseen_anytime = [] # These outputs should never be seen
474
448
solvable_anytime = [] # These outputs should be solvable after importpubkey
475
449
unseen_anytime = [] # These outputs should never be seen
@@ -486,8 +460,6 @@ def run_test(self):
486
460
v = self .nodes [0 ].getaddressinfo (i )
487
461
if (v ['isscript' ]):
488
462
[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 ])
491
463
premature_witaddress .append (script_to_p2sh (p2wsh ))
492
464
else :
493
465
[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):
508
480
for i in compressed_solvable_address :
509
481
v = self .nodes [0 ].getaddressinfo (i )
510
482
if (v ['isscript' ]):
511
- # P2WSH multisig without private key are seen after addwitnessaddress
512
483
[bare , p2sh , p2wsh , p2sh_p2wsh ] = self .p2sh_address_to_script (v )
513
- solvable_after_addwitnessaddress .extend ([p2wsh , p2sh_p2wsh ])
514
484
premature_witaddress .append (script_to_p2sh (p2wsh ))
515
485
else :
516
486
[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):
519
489
520
490
self .mine_and_test_listunspent (spendable_anytime , 2 )
521
491
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 ))
540
492
self .mine_and_test_listunspent (unseen_anytime , 0 )
541
493
542
494
# Check that createrawtransaction/decoderawtransaction with non-v0 Bech32 works
0 commit comments