Skip to content

Commit 9bd842a

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#26127: test: check that bumping tx with already spent coin fails
74eb194 test: check that bumping tx with already spent coin fails (Sebastian Falbesoner) Pull request description: This PR adds missing coverage for the `bumpfee` RPC, for the case that a wallet transaction is passed with an input that is already spent: https://github.com/bitcoin/bitcoin/blob/0b02ce914e8594e8938e527c91c07f57def4e943/src/wallet/feebumper.cpp#L182-L186 This is achieved by simply creating a transaction with a wallet and then mining it (I'm not aware of any other scenario how this could be achieved). Additionally, two RPC throw checks are changed in the test to be more specific: https://github.com/bitcoin/bitcoin/blob/0b02ce914e8594e8938e527c91c07f57def4e943/src/wallet/feebumper.cpp#L42-L45 https://github.com/bitcoin/bitcoin/blob/0b02ce914e8594e8938e527c91c07f57def4e943/src/wallet/feebumper.cpp#L47-L50 ACKs for top commit: glozow: ACK 74eb194 Tree-SHA512: 487d0e30a7cc5e2a5f63424ab6aed2963e05e47e2649fb1ad2289c4b48ad488f2dae5c27bf50e532e7eb2f2f5bf0340ed7dda985d14473f31dec0d757bb56324
2 parents fc40175 + 74eb194 commit 9bd842a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/functional/wallet_bumpfee.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def run_test(self):
9393
test_watchonly_psbt(self, peer_node, rbf_node, dest_address)
9494
test_rebumping(self, rbf_node, dest_address)
9595
test_rebumping_not_replaceable(self, rbf_node, dest_address)
96+
test_bumpfee_already_spent(self, rbf_node, dest_address)
9697
test_unconfirmed_not_spendable(self, rbf_node, rbf_node_address)
9798
test_bumpfee_metadata(self, rbf_node, dest_address)
9899
test_locked_wallet_fails(self, rbf_node, dest_address)
@@ -229,7 +230,7 @@ def test_segwit_bumpfee_succeeds(self, rbf_node, dest_address):
229230
def test_nonrbf_bumpfee_fails(self, peer_node, dest_address):
230231
self.log.info('Test that we cannot replace a non RBF transaction')
231232
not_rbfid = peer_node.sendtoaddress(dest_address, Decimal("0.00090000"))
232-
assert_raises_rpc_error(-4, "not BIP 125 replaceable", peer_node.bumpfee, not_rbfid)
233+
assert_raises_rpc_error(-4, "Transaction is not BIP 125 replaceable", peer_node.bumpfee, not_rbfid)
233234
self.clear_mempool()
234235

235236

@@ -499,7 +500,8 @@ def test_rebumping(self, rbf_node, dest_address):
499500
self.log.info('Test that re-bumping the original tx fails, but bumping successor works')
500501
rbfid = spend_one_input(rbf_node, dest_address)
501502
bumped = rbf_node.bumpfee(rbfid, {"fee_rate": ECONOMICAL})
502-
assert_raises_rpc_error(-4, "already bumped", rbf_node.bumpfee, rbfid, {"fee_rate": NORMAL})
503+
assert_raises_rpc_error(-4, f"Cannot bump transaction {rbfid} which was already bumped by transaction {bumped['txid']}",
504+
rbf_node.bumpfee, rbfid, {"fee_rate": NORMAL})
503505
rbf_node.bumpfee(bumped["txid"], {"fee_rate": NORMAL})
504506
self.clear_mempool()
505507

@@ -513,6 +515,15 @@ def test_rebumping_not_replaceable(self, rbf_node, dest_address):
513515
self.clear_mempool()
514516

515517

518+
def test_bumpfee_already_spent(self, rbf_node, dest_address):
519+
self.log.info('Test that bumping tx with already spent coin fails')
520+
txid = spend_one_input(rbf_node, dest_address)
521+
self.generate(rbf_node, 1) # spend coin simply by mining block with tx
522+
spent_input = rbf_node.gettransaction(txid=txid, verbose=True)['decoded']['vin'][0]
523+
assert_raises_rpc_error(-1, f"{spent_input['txid']}:{spent_input['vout']} is already spent",
524+
rbf_node.bumpfee, txid, {"fee_rate": NORMAL})
525+
526+
516527
def test_unconfirmed_not_spendable(self, rbf_node, rbf_node_address):
517528
self.log.info('Test that unconfirmed outputs from bumped txns are not spendable')
518529
rbfid = spend_one_input(rbf_node, rbf_node_address)

0 commit comments

Comments
 (0)