e8c31f135c tests: Test for bumping single output transaction (Andrew Chow)
4f4d4407e3 test: Test bumpfee reduce_output (Andrew Chow)
7d83502d3d bumpfee: Allow original change position to be specified (Andrew Chow)
Pull request description:
When bumping the transaction fee, we will try to find the change output of the transaction in order to have an output whose value we can modify so that we can meet the target feerate. However we do not always find the change output which can cause us to unnecessarily add an additional output to the transaction. We can avoid this issue by outsourcing the determination of change to the user if they so desire.
This PR adds a `orig_change_pos` option to bumpfee which the user can use to specify the index of the change output.
Fixes#11233Fixes#20795
ACKs for top commit:
ismaelsadeeq:
re ACK e8c31f135c
pinheadmz:
re-ACK e8c31f135c
furszy:
Code review ACK e8c31f13
Tree-SHA512: 3a230655934af17f7c1a5953fafb5ef0d687c21355cf284d5e98fece411f589cd69ea505f06d6bdcf82836b08d268c366ad2dd30ae3d71541c9cdf94d1f698ee
{"outputs",RPCArg::Type::ARR,RPCArg::Default{UniValue::VARR},"New outputs (key-value pairs) which will replace\n"
"the original ones, if provided. Each address can only appear once and there can\n"
"only be one \"data\" object.\n",
"only be one \"data\" object.\n"
"Cannot be provided if 'reduce_output' is specified.",
OutputsDoc(),
RPCArgOptions{.skip_type_check=true}},
{"reduce_output",RPCArg::Type::NUM,RPCArg::DefaultHint{"not set, detect change automatically"},"The 0-based index of the output from which the additional fees will be deducted. In general, this should be the position of change output. Cannot be provided if 'outputs' is specified."},
assert_raises_rpc_error(-1,"JSON integer out of range",rbf_node.bumpfee,rbfid,{"reduce_output":-1})
assert_raises_rpc_error(-8,"Change position is out of range",rbf_node.bumpfee,rbfid,{"reduce_output":2})
self.log.info("Test outputs and reduce_output cannot both be provided")
assert_raises_rpc_error(-8,"Cannot specify both new outputs to use and an output index to reduce",rbf_node.bumpfee,rbfid,{"reduce_output":2,"outputs":[{dest_address:0.1}]})
self.clear_mempool()
deftest_bump_back_to_yourself(self):
@ -225,6 +236,72 @@ class BumpFeeTest(BitcoinTestFramework):
# Reduce the only output with a crazy high feerate, should fail as the output would be dust
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})