Skip to content

Commit ec3b93d

Browse files
committed
tests: Test for bumping single output transaction
1 parent 8af5778 commit ec3b93d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/functional/wallet_bumpfee.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from test_framework.test_framework import BitcoinTestFramework
2525
from test_framework.util import (
2626
assert_equal,
27+
assert_fee_amount,
2728
assert_greater_than,
2829
assert_raises_rpc_error,
2930
get_fee,
@@ -111,6 +112,7 @@ def run_test(self):
111112
test_no_more_inputs_fails(self, rbf_node, dest_address)
112113
self.test_bump_back_to_yourself()
113114
self.test_provided_change_pos(rbf_node)
115+
self.test_single_output()
114116

115117
# Context independent tests
116118
test_feerate_checks_replaced_outputs(self, rbf_node, peer_node)
@@ -263,6 +265,43 @@ def test_provided_change_pos(self, rbf_node):
263265
assert_greater_than(change_value, new_change_value)
264266

265267

268+
def test_single_output(self):
269+
self.log.info("Test that single output txs can be bumped")
270+
node = self.nodes[1]
271+
272+
node.createwallet("single_out_rbf")
273+
wallet = node.get_wallet_rpc("single_out_rbf")
274+
275+
addr = wallet.getnewaddress()
276+
amount = Decimal("0.001")
277+
# Make 2 UTXOs
278+
self.nodes[0].sendtoaddress(addr, amount)
279+
self.nodes[0].sendtoaddress(addr, amount)
280+
self.generate(self.nodes[0], 1)
281+
utxos = wallet.listunspent()
282+
283+
tx = wallet.sendall(recipients=[wallet.getnewaddress()], fee_rate=2, options={"inputs": [utxos[0]]})
284+
285+
# Reduce the only output with a crazy high feerate, should fail as the output would be dust
286+
assert_raises_rpc_error(-4, "The transaction amount is too small to pay the fee", wallet.bumpfee, txid=tx["txid"], options={"fee_rate": 1100, "reduce_output": 0})
287+
288+
# Reduce the only output successfully
289+
bumped = wallet.bumpfee(txid=tx["txid"], options={"fee_rate": 10, "reduce_output": 0})
290+
bumped_tx = wallet.gettransaction(txid=bumped["txid"], verbose=True)
291+
assert_equal(len(bumped_tx["decoded"]["vout"]), 1)
292+
assert_equal(len(bumped_tx["decoded"]["vin"]), 1)
293+
assert_equal(bumped_tx["decoded"]["vout"][0]["value"] + bumped["fee"], amount)
294+
assert_fee_amount(bumped["fee"], bumped_tx["decoded"]["vsize"], Decimal(10) / Decimal(1e8) * 1000)
295+
296+
# Bumping without reducing adds a new input and output
297+
bumped = wallet.bumpfee(txid=bumped["txid"], options={"fee_rate": 20})
298+
bumped_tx = wallet.gettransaction(txid=bumped["txid"], verbose=True)
299+
assert_equal(len(bumped_tx["decoded"]["vout"]), 2)
300+
assert_equal(len(bumped_tx["decoded"]["vin"]), 2)
301+
assert_fee_amount(bumped["fee"], bumped_tx["decoded"]["vsize"], Decimal(20) / Decimal(1e8) * 1000)
302+
303+
wallet.unloadwallet()
304+
266305
def test_simple_bumpfee_succeeds(self, mode, rbf_node, peer_node, dest_address):
267306
self.log.info('Test simple bumpfee: {}'.format(mode))
268307
rbfid = spend_one_input(rbf_node, dest_address)

0 commit comments

Comments
 (0)