@@ -71,28 +71,29 @@ def run_test(self):
71
71
test_simple_bumpfee_succeeds (self , "default" , rbf_node , peer_node , dest_address )
72
72
test_simple_bumpfee_succeeds (self , "fee_rate" , rbf_node , peer_node , dest_address )
73
73
test_feerate_args (self , rbf_node , peer_node , dest_address )
74
- test_segwit_bumpfee_succeeds (rbf_node , dest_address )
75
- test_nonrbf_bumpfee_fails (peer_node , dest_address )
76
- test_notmine_bumpfee_fails (rbf_node , peer_node , dest_address )
77
- test_bumpfee_with_descendant_fails (rbf_node , rbf_node_address , dest_address )
78
- test_small_output_fails (rbf_node , dest_address )
79
- test_dust_to_fee (rbf_node , dest_address )
80
- test_settxfee (rbf_node , dest_address )
74
+ test_segwit_bumpfee_succeeds (self , rbf_node , dest_address )
75
+ test_nonrbf_bumpfee_fails (self , peer_node , dest_address )
76
+ test_notmine_bumpfee_fails (self , rbf_node , peer_node , dest_address )
77
+ test_bumpfee_with_descendant_fails (self , rbf_node , rbf_node_address , dest_address )
78
+ test_small_output_fails (self , rbf_node , dest_address )
79
+ test_dust_to_fee (self , rbf_node , dest_address )
80
+ test_settxfee (self , rbf_node , dest_address )
81
81
test_watchonly_psbt (self , peer_node , rbf_node , dest_address )
82
- test_rebumping (rbf_node , dest_address )
83
- test_rebumping_not_replaceable (rbf_node , dest_address )
84
- test_unconfirmed_not_spendable (rbf_node , rbf_node_address )
85
- test_bumpfee_metadata (rbf_node , dest_address )
86
- test_locked_wallet_fails (rbf_node , dest_address )
87
- test_change_script_match (rbf_node , dest_address )
82
+ test_rebumping (self , rbf_node , dest_address )
83
+ test_rebumping_not_replaceable (self , rbf_node , dest_address )
84
+ test_unconfirmed_not_spendable (self , rbf_node , rbf_node_address )
85
+ test_bumpfee_metadata (self , rbf_node , dest_address )
86
+ test_locked_wallet_fails (self , rbf_node , dest_address )
87
+ test_change_script_match (self , rbf_node , dest_address )
88
88
test_maxtxfee_fails (self , rbf_node , dest_address )
89
89
# These tests wipe out a number of utxos that are expected in other tests
90
- test_small_output_with_feerate_succeeds (rbf_node , dest_address )
91
- test_no_more_inputs_fails (rbf_node , dest_address )
90
+ test_small_output_with_feerate_succeeds (self , rbf_node , dest_address )
91
+ test_no_more_inputs_fails (self , rbf_node , dest_address )
92
92
self .log .info ("Success" )
93
93
94
94
95
95
def test_simple_bumpfee_succeeds (self , mode , rbf_node , peer_node , dest_address ):
96
+ self .log .info ('Test simple bumpfee' )
96
97
rbfid = spend_one_input (rbf_node , dest_address )
97
98
rbftx = rbf_node .gettransaction (rbfid )
98
99
self .sync_mempools ((rbf_node , peer_node ))
@@ -119,6 +120,7 @@ def test_simple_bumpfee_succeeds(self, mode, rbf_node, peer_node, dest_address):
119
120
assert_equal (bumpedwtx ["replaces_txid" ], rbfid )
120
121
121
122
def test_feerate_args (self , rbf_node , peer_node , dest_address ):
123
+ self .log .info ('Test feerate args' )
122
124
rbfid = spend_one_input (rbf_node , dest_address )
123
125
self .sync_mempools ((rbf_node , peer_node ))
124
126
assert rbfid in rbf_node .getrawmempool () and rbfid in peer_node .getrawmempool ()
@@ -135,7 +137,8 @@ def test_feerate_args(self, rbf_node, peer_node, dest_address):
135
137
assert_raises_rpc_error (- 4 , "is too high (cannot be higher than" , rbf_node .bumpfee , rbfid , {"fee_rate" :1 })
136
138
137
139
138
- def test_segwit_bumpfee_succeeds (rbf_node , dest_address ):
140
+ def test_segwit_bumpfee_succeeds (self , rbf_node , dest_address ):
141
+ self .log .info ('Test that segwit-sourcing bumpfee works' )
139
142
# Create a transaction with segwit output, then create an RBF transaction
140
143
# which spends it, and make sure bumpfee can be called on it.
141
144
@@ -165,14 +168,14 @@ def test_segwit_bumpfee_succeeds(rbf_node, dest_address):
165
168
assert rbfid not in rbf_node .getrawmempool ()
166
169
167
170
168
- def test_nonrbf_bumpfee_fails (peer_node , dest_address ):
169
- # cannot replace a non RBF transaction (from node which did not enable RBF )
171
+ def test_nonrbf_bumpfee_fails (self , peer_node , dest_address ):
172
+ self . log . info ( 'Test that we cannot replace a non RBF transaction' )
170
173
not_rbfid = peer_node .sendtoaddress (dest_address , Decimal ("0.00090000" ))
171
174
assert_raises_rpc_error (- 4 , "not BIP 125 replaceable" , peer_node .bumpfee , not_rbfid )
172
175
173
176
174
- def test_notmine_bumpfee_fails (rbf_node , peer_node , dest_address ):
175
- # cannot bump fee unless the tx has only inputs that we own.
177
+ def test_notmine_bumpfee_fails (self , rbf_node , peer_node , dest_address ):
178
+ self . log . info ( 'Test that it cannot bump fee if non-owned inputs are included' )
176
179
# here, the rbftx has a peer_node coin and then adds a rbf_node input
177
180
# Note that this test depends upon the RPC code checking input ownership prior to change outputs
178
181
# (since it can't use fundrawtransaction, it lacks a proper change output)
@@ -192,34 +195,36 @@ def test_notmine_bumpfee_fails(rbf_node, peer_node, dest_address):
192
195
rbf_node .bumpfee , rbfid )
193
196
194
197
195
- def test_bumpfee_with_descendant_fails (rbf_node , rbf_node_address , dest_address ):
196
- # cannot bump fee if the transaction has a descendant
198
+ def test_bumpfee_with_descendant_fails (self , rbf_node , rbf_node_address , dest_address ):
199
+ self . log . info ( 'Test that fee cannot be bumped when it has descendant' )
197
200
# parent is send-to-self, so we don't have to check which output is change when creating the child tx
198
201
parent_id = spend_one_input (rbf_node , rbf_node_address )
199
202
tx = rbf_node .createrawtransaction ([{"txid" : parent_id , "vout" : 0 }], {dest_address : 0.00020000 })
200
203
tx = rbf_node .signrawtransactionwithwallet (tx )
201
204
rbf_node .sendrawtransaction (tx ["hex" ])
202
205
assert_raises_rpc_error (- 8 , "Transaction has descendants in the wallet" , rbf_node .bumpfee , parent_id )
203
206
204
- def test_small_output_fails (rbf_node , dest_address ):
207
+ def test_small_output_fails (self , rbf_node , dest_address ):
208
+ self .log .info ('Test totalFee bump with small output fails' )
205
209
# cannot bump fee with a too-small output
206
210
rbfid = spend_one_input (rbf_node , dest_address )
207
211
rbf_node .bumpfee (rbfid , {"totalFee" : 50000 })
208
212
209
213
rbfid = spend_one_input (rbf_node , dest_address )
210
214
assert_raises_rpc_error (- 4 , "Change output is too small" , rbf_node .bumpfee , rbfid , {"totalFee" : 50001 })
211
215
212
- def test_small_output_with_feerate_succeeds (rbf_node , dest_address ):
216
+ def test_small_output_with_feerate_succeeds (self , rbf_node , dest_address ):
217
+ self .log .info ('Testing small output with feerate bump succeeds' )
213
218
214
219
# Make sure additional inputs exist
215
220
rbf_node .generatetoaddress (101 , rbf_node .getnewaddress ())
216
221
rbfid = spend_one_input (rbf_node , dest_address )
217
222
input_list = rbf_node .getrawtransaction (rbfid , 1 )["vin" ]
218
223
assert_equal (len (input_list ), 1 )
219
224
original_txin = input_list [0 ]
220
- # Keep bumping until we out-spend change output
225
+ self . log . info ( ' Keep bumping until transaction fee out-spends non-destination value' )
221
226
tx_fee = 0
222
- while tx_fee < Decimal ( "0.0005" ) :
227
+ while True :
223
228
input_list = rbf_node .getrawtransaction (rbfid , 1 )["vin" ]
224
229
new_item = list (input_list )[0 ]
225
230
assert_equal (len (input_list ), 1 )
@@ -231,7 +236,11 @@ def test_small_output_with_feerate_succeeds(rbf_node, dest_address):
231
236
assert rbfid not in raw_pool
232
237
assert rbfid_new in raw_pool
233
238
rbfid = rbfid_new
234
- tx_fee = rbfid_new_details ["origfee" ]
239
+ tx_fee = rbfid_new_details ["fee" ]
240
+
241
+ # Total value from input not going to destination
242
+ if tx_fee > Decimal ('0.00050000' ):
243
+ break
235
244
236
245
# input(s) have been added
237
246
final_input_list = rbf_node .getrawtransaction (rbfid , 1 )["vin" ]
@@ -244,8 +253,8 @@ def test_small_output_with_feerate_succeeds(rbf_node, dest_address):
244
253
rbf_node .generatetoaddress (1 , rbf_node .getnewaddress ())
245
254
assert_equal (rbf_node .gettransaction (rbfid )["confirmations" ], 1 )
246
255
247
- def test_dust_to_fee (rbf_node , dest_address ):
248
- # check that if output is reduced to dust, it will be converted to fee
256
+ def test_dust_to_fee (self , rbf_node , dest_address ):
257
+ self . log . info ( 'Test that bumped output that is dust is dropped to fee' )
249
258
# the bumped tx sets fee=49,900, but it converts to 50,000
250
259
rbfid = spend_one_input (rbf_node , dest_address )
251
260
fulltx = rbf_node .getrawtransaction (rbfid , 1 )
@@ -257,7 +266,8 @@ def test_dust_to_fee(rbf_node, dest_address):
257
266
assert_equal (len (full_bumped_tx ["vout" ]), 1 ) # change output is eliminated
258
267
259
268
260
- def test_settxfee (rbf_node , dest_address ):
269
+ def test_settxfee (self , rbf_node , dest_address ):
270
+ self .log .info ('Test settxfee' )
261
271
assert_raises_rpc_error (- 8 , "txfee cannot be less than min relay tx fee" , rbf_node .settxfee , Decimal ('0.000005' ))
262
272
assert_raises_rpc_error (- 8 , "txfee cannot be less than wallet min fee" , rbf_node .settxfee , Decimal ('0.000015' ))
263
273
# check that bumpfee reacts correctly to the use of settxfee (paytxfee)
@@ -272,17 +282,19 @@ def test_settxfee(rbf_node, dest_address):
272
282
rbf_node .settxfee (Decimal ("0.00000000" )) # unset paytxfee
273
283
274
284
275
- def test_maxtxfee_fails (test , rbf_node , dest_address ):
285
+ def test_maxtxfee_fails (self , rbf_node , dest_address ):
286
+ self .log .info ('Test that bumpfee fails when it hits -matxfee' )
276
287
# size of bumped transaction (p2wpkh, 1 input, 2 outputs): 141 vbytes
277
288
# expected bumping feerate of 20 sats/vbyte => 141*20 sats = 0.00002820 btc
278
- test .restart_node (1 , ['-maxtxfee=0.000025' ] + test .extra_args [1 ])
289
+ self .restart_node (1 , ['-maxtxfee=0.000025' ] + self .extra_args [1 ])
279
290
rbf_node .walletpassphrase (WALLET_PASSPHRASE , WALLET_PASSPHRASE_TIMEOUT )
280
291
rbfid = spend_one_input (rbf_node , dest_address )
281
292
assert_raises_rpc_error (- 4 , "Unable to create transaction: Fee exceeds maximum configured by -maxtxfee" , rbf_node .bumpfee , rbfid )
282
- test .restart_node (1 , test .extra_args [1 ])
293
+ self .restart_node (1 , self .extra_args [1 ])
283
294
rbf_node .walletpassphrase (WALLET_PASSPHRASE , WALLET_PASSPHRASE_TIMEOUT )
284
295
285
- def test_watchonly_psbt (test , peer_node , rbf_node , dest_address ):
296
+ def test_watchonly_psbt (self , peer_node , rbf_node , dest_address ):
297
+ self .log .info ('Test that PSBT is returned for bumpfee in watchonly wallets' )
286
298
priv_rec_desc = "wpkh([00000001/84'/1'/0']tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/0/*)#rweraev0"
287
299
pub_rec_desc = rbf_node .getdescriptorinfo (priv_rec_desc )["descriptor" ]
288
300
priv_change_desc = "wpkh([00000001/84'/1'/0']tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/*)#j6uzqvuh"
@@ -334,7 +346,7 @@ def test_watchonly_psbt(test, peer_node, rbf_node, dest_address):
334
346
funding_address2 = watcher .getnewaddress (address_type = 'bech32' )
335
347
peer_node .sendmany ("" , {funding_address1 : 0.001 , funding_address2 : 0.001 })
336
348
peer_node .generate (1 )
337
- test .sync_all ()
349
+ self .sync_all ()
338
350
339
351
# Create single-input PSBT for transaction to be bumped
340
352
psbt = watcher .walletcreatefundedpsbt ([], {dest_address :0.0005 }, 0 , {"feeRate" : 0.00001 }, True )['psbt' ]
@@ -363,24 +375,24 @@ def test_watchonly_psbt(test, peer_node, rbf_node, dest_address):
363
375
rbf_node .unloadwallet ("watcher" )
364
376
rbf_node .unloadwallet ("signer" )
365
377
366
- def test_rebumping (rbf_node , dest_address ):
367
- # check that re-bumping the original tx fails, but bumping the bumper succeeds
378
+ def test_rebumping (self , rbf_node , dest_address ):
379
+ self . log . info ( 'Test that re-bumping the original tx fails, but bumping successor works' )
368
380
rbfid = spend_one_input (rbf_node , dest_address )
369
381
bumped = rbf_node .bumpfee (rbfid , {"totalFee" : 2000 })
370
382
assert_raises_rpc_error (- 4 , "already bumped" , rbf_node .bumpfee , rbfid , {"totalFee" : 3000 })
371
383
rbf_node .bumpfee (bumped ["txid" ], {"totalFee" : 3000 })
372
384
373
385
374
- def test_rebumping_not_replaceable (rbf_node , dest_address ):
375
- # check that re-bumping a non-replaceable bump tx fails
386
+ def test_rebumping_not_replaceable (self , rbf_node , dest_address ):
387
+ self . log . info ( 'Test that re-bumping non-replaceable fails' )
376
388
rbfid = spend_one_input (rbf_node , dest_address )
377
389
bumped = rbf_node .bumpfee (rbfid , {"totalFee" : 10000 , "replaceable" : False })
378
390
assert_raises_rpc_error (- 4 , "Transaction is not BIP 125 replaceable" , rbf_node .bumpfee , bumped ["txid" ],
379
391
{"totalFee" : 20000 })
380
392
381
393
382
- def test_unconfirmed_not_spendable (rbf_node , rbf_node_address ):
383
- # check that unconfirmed outputs from bumped transactions are not spendable
394
+ def test_unconfirmed_not_spendable (self , rbf_node , rbf_node_address ):
395
+ self . log . info ( 'Test that unconfirmed outputs from bumped txns are not spendable' )
384
396
rbfid = spend_one_input (rbf_node , rbf_node_address )
385
397
rbftx = rbf_node .gettransaction (rbfid )["hex" ]
386
398
assert rbfid in rbf_node .getrawmempool ()
@@ -418,7 +430,8 @@ def test_unconfirmed_not_spendable(rbf_node, rbf_node_address):
418
430
if t ["txid" ] == rbfid and t ["address" ] == rbf_node_address and t ["spendable" ]), 1 )
419
431
420
432
421
- def test_bumpfee_metadata (rbf_node , dest_address ):
433
+ def test_bumpfee_metadata (self , rbf_node , dest_address ):
434
+ self .log .info ('Test that bumped txn metadata persists to new txn record' )
422
435
assert (rbf_node .getbalance () < 49 )
423
436
rbf_node .generatetoaddress (101 , rbf_node .getnewaddress ())
424
437
rbfid = rbf_node .sendtoaddress (dest_address , 49 , "comment value" , "to value" )
@@ -428,15 +441,17 @@ def test_bumpfee_metadata(rbf_node, dest_address):
428
441
assert_equal (bumped_wtx ["to" ], "to value" )
429
442
430
443
431
- def test_locked_wallet_fails (rbf_node , dest_address ):
444
+ def test_locked_wallet_fails (self , rbf_node , dest_address ):
445
+ self .log .info ('Test that locked wallet cannot bump txn' )
432
446
rbfid = spend_one_input (rbf_node , dest_address )
433
447
rbf_node .walletlock ()
434
448
assert_raises_rpc_error (- 13 , "Please enter the wallet passphrase with walletpassphrase first." ,
435
449
rbf_node .bumpfee , rbfid )
436
450
rbf_node .walletpassphrase (WALLET_PASSPHRASE , WALLET_PASSPHRASE_TIMEOUT )
437
451
438
- def test_change_script_match (rbf_node , dest_address ):
439
- """Test that the same change addresses is used for the replacement transaction when possible."""
452
+ def test_change_script_match (self , rbf_node , dest_address ):
453
+ self .log .info ('Test that the same change addresses is used for the replacement transaction when possible.' )
454
+
440
455
def get_change_address (tx ):
441
456
tx_details = rbf_node .getrawtransaction (tx , 1 )
442
457
txout_addresses = [txout ['scriptPubKey' ]['addresses' ][0 ] for txout in tx_details ["vout" ]]
@@ -480,7 +495,8 @@ def submit_block_with_tx(node, tx):
480
495
node .submitblock (block .serialize ().hex ())
481
496
return block
482
497
483
- def test_no_more_inputs_fails (rbf_node , dest_address ):
498
+ def test_no_more_inputs_fails (self , rbf_node , dest_address ):
499
+ self .log .info ('Test that bumpfee fails when there are no available confirmed outputs' )
484
500
# feerate rbf requires confirmed outputs when change output doesn't exist or is insufficient
485
501
rbf_node .generatetoaddress (1 , dest_address )
486
502
# spend all funds, no change output
0 commit comments