@@ -73,6 +73,9 @@ def run_test(self):
73
73
test_unconfirmed_not_spendable (rbf_node , rbf_node_address )
74
74
test_bumpfee_metadata (rbf_node , dest_address )
75
75
test_locked_wallet_fails (rbf_node , dest_address )
76
+ # These tests wipe out a number of utxos that are expected in other tests
77
+ test_small_output_with_feerate_succeeds (rbf_node , dest_address )
78
+ test_no_more_inputs_fails (rbf_node , dest_address )
76
79
self .log .info ("Success" )
77
80
78
81
@@ -173,6 +176,40 @@ def test_small_output_fails(rbf_node, dest_address):
173
176
rbfid = spend_one_input (rbf_node , dest_address )
174
177
assert_raises_rpc_error (- 4 , "Change output is too small" , rbf_node .bumpfee , rbfid , {"totalFee" : 50001 })
175
178
179
+ def test_small_output_with_feerate_succeeds (rbf_node , dest_address ):
180
+
181
+ # Make sure additional inputs exist
182
+ rbf_node .generatetoaddress (101 , rbf_node .getnewaddress ())
183
+ rbfid = spend_one_input (rbf_node , dest_address )
184
+ original_input_list = rbf_node .getrawtransaction (rbfid , 1 )["vin" ]
185
+ assert_equal (len (original_input_list ), 1 )
186
+ original_txin = original_input_list [0 ]
187
+ # Keep bumping until we out-spend change output
188
+ tx_fee = 0
189
+ while tx_fee < Decimal ("0.0005" ):
190
+ new_input_list = rbf_node .getrawtransaction (rbfid , 1 )["vin" ]
191
+ new_item = list (new_input_list )[0 ]
192
+ assert_equal (len (original_input_list ), 1 )
193
+ assert_equal (original_txin ["txid" ], new_item ["txid" ])
194
+ assert_equal (original_txin ["vout" ], new_item ["vout" ])
195
+ rbfid_new_details = rbf_node .bumpfee (rbfid )
196
+ rbfid_new = rbfid_new_details ["txid" ]
197
+ raw_pool = rbf_node .getrawmempool ()
198
+ assert rbfid not in raw_pool
199
+ assert rbfid_new in raw_pool
200
+ rbfid = rbfid_new
201
+ tx_fee = rbfid_new_details ["origfee" ]
202
+
203
+ # input(s) have been added
204
+ final_input_list = rbf_node .getrawtransaction (rbfid , 1 )["vin" ]
205
+ assert_greater_than (len (final_input_list ), 1 )
206
+ # Original input is in final set
207
+ assert [txin for txin in final_input_list
208
+ if txin ["txid" ] == original_txin ["txid" ]
209
+ and txin ["vout" ] == original_txin ["vout" ]]
210
+
211
+ rbf_node .generatetoaddress (1 , rbf_node .getnewaddress ())
212
+ assert_equal (rbf_node .gettransaction (rbfid )["confirmations" ], 1 )
176
213
177
214
def test_dust_to_fee (rbf_node , dest_address ):
178
215
# check that if output is reduced to dust, it will be converted to fee
@@ -272,19 +309,20 @@ def test_locked_wallet_fails(rbf_node, dest_address):
272
309
rbf_node .walletlock ()
273
310
assert_raises_rpc_error (- 13 , "Please enter the wallet passphrase with walletpassphrase first." ,
274
311
rbf_node .bumpfee , rbfid )
312
+ rbf_node .walletpassphrase (WALLET_PASSPHRASE , WALLET_PASSPHRASE_TIMEOUT )
275
313
276
314
277
- def spend_one_input (node , dest_address ):
315
+ def spend_one_input (node , dest_address , change_size = Decimal ( "0.00049000" ) ):
278
316
tx_input = dict (
279
317
sequence = BIP125_SEQUENCE_NUMBER , ** next (u for u in node .listunspent () if u ["amount" ] == Decimal ("0.00100000" )))
280
- rawtx = node .createrawtransaction (
281
- [tx_input ], {dest_address : Decimal ("0.00050000" ),
282
- node .getrawchangeaddress (): Decimal ("0.00049000" )})
318
+ destinations = {dest_address : Decimal ("0.00050000" )}
319
+ if change_size > 0 :
320
+ destinations [node .getrawchangeaddress ()] = change_size
321
+ rawtx = node .createrawtransaction ([tx_input ], destinations )
283
322
signedtx = node .signrawtransactionwithwallet (rawtx )
284
323
txid = node .sendrawtransaction (signedtx ["hex" ])
285
324
return txid
286
325
287
-
288
326
def submit_block_with_tx (node , tx ):
289
327
ctx = CTransaction ()
290
328
ctx .deserialize (io .BytesIO (hex_str_to_bytes (tx )))
@@ -301,6 +339,12 @@ def submit_block_with_tx(node, tx):
301
339
node .submitblock (block .serialize (True ).hex ())
302
340
return block
303
341
342
+ def test_no_more_inputs_fails (rbf_node , dest_address ):
343
+ # feerate rbf requires confirmed outputs when change output doesn't exist or is insufficient
344
+ rbf_node .generatetoaddress (1 , dest_address )
345
+ # spend all funds, no change output
346
+ rbfid = rbf_node .sendtoaddress (rbf_node .getnewaddress (), rbf_node .getbalance (), "" , "" , True )
347
+ assert_raises_rpc_error (- 4 , "Unable to create transaction: Insufficient funds" , rbf_node .bumpfee , rbfid )
304
348
305
349
if __name__ == "__main__" :
306
350
BumpFeeTest ().main ()
0 commit comments