23
23
assert_equal ,
24
24
assert_greater_than ,
25
25
assert_raises_rpc_error ,
26
- connect_nodes ,
27
26
hex_str_to_bytes ,
28
27
)
29
28
37
36
HIGH = 0.00500000
38
37
TOO_HIGH = 1.00000000
39
38
39
+
40
40
class BumpFeeTest (BitcoinTestFramework ):
41
41
def set_test_params (self ):
42
42
self .num_nodes = 2
@@ -55,9 +55,6 @@ def run_test(self):
55
55
self .nodes [1 ].encryptwallet (WALLET_PASSPHRASE )
56
56
self .nodes [1 ].walletpassphrase (WALLET_PASSPHRASE , WALLET_PASSPHRASE_TIMEOUT )
57
57
58
- connect_nodes (self .nodes [0 ], 1 )
59
- self .sync_all ()
60
-
61
58
peer_node , rbf_node = self .nodes
62
59
rbf_node_address = rbf_node .getnewaddress ()
63
60
@@ -94,7 +91,6 @@ def run_test(self):
94
91
# These tests wipe out a number of utxos that are expected in other tests
95
92
test_small_output_with_feerate_succeeds (self , rbf_node , dest_address )
96
93
test_no_more_inputs_fails (self , rbf_node , dest_address )
97
- self .log .info ("Success" )
98
94
99
95
100
96
def test_simple_bumpfee_succeeds (self , mode , rbf_node , peer_node , dest_address ):
@@ -124,6 +120,7 @@ def test_simple_bumpfee_succeeds(self, mode, rbf_node, peer_node, dest_address):
124
120
assert_equal (oldwtx ["replaced_by_txid" ], bumped_tx ["txid" ])
125
121
assert_equal (bumpedwtx ["replaces_txid" ], rbfid )
126
122
123
+
127
124
def test_feerate_args (self , rbf_node , peer_node , dest_address ):
128
125
self .log .info ('Test fee_rate args' )
129
126
rbfid = spend_one_input (rbf_node , dest_address )
@@ -137,7 +134,7 @@ def test_feerate_args(self, rbf_node, peer_node, dest_address):
137
134
# Bumping to just above minrelay should fail to increase total fee enough, at least
138
135
assert_raises_rpc_error (- 8 , "Insufficient total fee" , rbf_node .bumpfee , rbfid , {"fee_rate" : INSUFFICIENT })
139
136
140
- assert_raises_rpc_error (- 3 , "Amount out of range" , rbf_node .bumpfee , rbfid , {"fee_rate" :- 1 })
137
+ assert_raises_rpc_error (- 3 , "Amount out of range" , rbf_node .bumpfee , rbfid , {"fee_rate" : - 1 })
141
138
142
139
assert_raises_rpc_error (- 4 , "is too high (cannot be higher than" , rbf_node .bumpfee , rbfid , {"fee_rate" : TOO_HIGH })
143
140
@@ -209,6 +206,7 @@ def test_bumpfee_with_descendant_fails(self, rbf_node, rbf_node_address, dest_ad
209
206
rbf_node .sendrawtransaction (tx ["hex" ])
210
207
assert_raises_rpc_error (- 8 , "Transaction has descendants in the wallet" , rbf_node .bumpfee , parent_id )
211
208
209
+
212
210
def test_small_output_with_feerate_succeeds (self , rbf_node , dest_address ):
213
211
self .log .info ('Testing small output with feerate bump succeeds' )
214
212
@@ -249,6 +247,7 @@ def test_small_output_with_feerate_succeeds(self, rbf_node, dest_address):
249
247
rbf_node .generatetoaddress (1 , rbf_node .getnewaddress ())
250
248
assert_equal (rbf_node .gettransaction (rbfid )["confirmations" ], 1 )
251
249
250
+
252
251
def test_dust_to_fee (self , rbf_node , dest_address ):
253
252
self .log .info ('Test that bumped output that is dust is dropped to fee' )
254
253
rbfid = spend_one_input (rbf_node , dest_address )
@@ -305,6 +304,7 @@ def test_maxtxfee_fails(self, rbf_node, dest_address):
305
304
self .restart_node (1 , self .extra_args [1 ])
306
305
rbf_node .walletpassphrase (WALLET_PASSPHRASE , WALLET_PASSPHRASE_TIMEOUT )
307
306
307
+
308
308
def test_watchonly_psbt (self , peer_node , rbf_node , dest_address ):
309
309
self .log .info ('Test that PSBT is returned for bumpfee in watchonly wallets' )
310
310
priv_rec_desc = "wpkh([00000001/84'/1'/0']tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/0/*)#rweraev0"
@@ -339,12 +339,11 @@ def test_watchonly_psbt(self, peer_node, rbf_node, dest_address):
339
339
result = watcher .importmulti ([{
340
340
"desc" : pub_rec_desc ,
341
341
"timestamp" : 0 ,
342
- "range" : [0 ,10 ],
342
+ "range" : [0 , 10 ],
343
343
"internal" : False ,
344
344
"keypool" : True ,
345
345
"watchonly" : True
346
- },
347
- {
346
+ }, {
348
347
"desc" : pub_change_desc ,
349
348
"timestamp" : 0 ,
350
349
"range" : [0 , 10 ],
@@ -361,7 +360,7 @@ def test_watchonly_psbt(self, peer_node, rbf_node, dest_address):
361
360
self .sync_all ()
362
361
363
362
# Create single-input PSBT for transaction to be bumped
364
- psbt = watcher .walletcreatefundedpsbt ([], {dest_address :0.0005 }, 0 , {"feeRate" : 0.00001 }, True )['psbt' ]
363
+ psbt = watcher .walletcreatefundedpsbt ([], {dest_address : 0.0005 }, 0 , {"feeRate" : 0.00001 }, True )['psbt' ]
365
364
psbt_signed = signer .walletprocesspsbt (psbt = psbt , sign = True , sighashtype = "ALL" , bip32derivs = True )
366
365
psbt_final = watcher .finalizepsbt (psbt_signed ["psbt" ])
367
366
original_txid = watcher .sendrawtransaction (psbt_final ["hex" ])
@@ -387,6 +386,7 @@ def test_watchonly_psbt(self, peer_node, rbf_node, dest_address):
387
386
rbf_node .unloadwallet ("watcher" )
388
387
rbf_node .unloadwallet ("signer" )
389
388
389
+
390
390
def test_rebumping (self , rbf_node , dest_address ):
391
391
self .log .info ('Test that re-bumping the original tx fails, but bumping successor works' )
392
392
rbfid = spend_one_input (rbf_node , dest_address )
@@ -461,6 +461,7 @@ def test_locked_wallet_fails(self, rbf_node, dest_address):
461
461
rbf_node .bumpfee , rbfid )
462
462
rbf_node .walletpassphrase (WALLET_PASSPHRASE , WALLET_PASSPHRASE_TIMEOUT )
463
463
464
+
464
465
def test_change_script_match (self , rbf_node , dest_address ):
465
466
self .log .info ('Test that the same change addresses is used for the replacement transaction when possible' )
466
467
@@ -480,6 +481,7 @@ def get_change_address(tx):
480
481
bumped_rate_tx = rbf_node .bumpfee (bumped_total_tx ["txid" ])
481
482
assert_equal (change_addresses , get_change_address (bumped_rate_tx ['txid' ]))
482
483
484
+
483
485
def spend_one_input (node , dest_address , change_size = Decimal ("0.00049000" )):
484
486
tx_input = dict (
485
487
sequence = BIP125_SEQUENCE_NUMBER , ** next (u for u in node .listunspent () if u ["amount" ] == Decimal ("0.00100000" )))
@@ -491,6 +493,7 @@ def spend_one_input(node, dest_address, change_size=Decimal("0.00049000")):
491
493
txid = node .sendrawtransaction (signedtx ["hex" ])
492
494
return txid
493
495
496
+
494
497
def submit_block_with_tx (node , tx ):
495
498
ctx = CTransaction ()
496
499
ctx .deserialize (io .BytesIO (hex_str_to_bytes (tx )))
@@ -507,6 +510,7 @@ def submit_block_with_tx(node, tx):
507
510
node .submitblock (block .serialize ().hex ())
508
511
return block
509
512
513
+
510
514
def test_no_more_inputs_fails (self , rbf_node , dest_address ):
511
515
self .log .info ('Test that bumpfee fails when there are no available confirmed outputs' )
512
516
# feerate rbf requires confirmed outputs when change output doesn't exist or is insufficient
0 commit comments