Skip to content

Commit

Permalink
wallet, bugfix: fix bumpfee with explicit fee rate modes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatack committed Oct 24, 2020
1 parent 80c8a02 commit 052427e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3461,7 +3461,6 @@ static RPCHelpMan bumpfee_helper(std::string method_name)
if (options.exists("fee_rate")) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "conf_target can't be set with fee_rate. Please provide either a confirmation target in blocks for automatic fee estimation, or an explicit fee rate.");
}
coin_control.m_confirm_target = ParseConfirmTarget(conf_target, pwallet->chain().estimateMaxBlocks());
} else if (options.exists("fee_rate")) {
CFeeRate fee_rate(AmountFromValue(options["fee_rate"]));
if (fee_rate <= CFeeRate(0)) {
Expand Down
15 changes: 12 additions & 3 deletions test/functional/wallet_bumpfee.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import io

from test_framework.blocktools import add_witness_commitment, create_block, create_coinbase, send_to_witness
from test_framework.messages import BIP125_SEQUENCE_NUMBER, CTransaction
from test_framework.messages import BIP125_SEQUENCE_NUMBER, COIN, CTransaction
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
Expand All @@ -36,6 +36,8 @@
HIGH = 0.00500000
TOO_HIGH = 1.00000000

BTC_MODE = "BTC/kB"
SAT_MODE = "sat/B"

class BumpFeeTest(BitcoinTestFramework):
def set_test_params(self):
Expand Down Expand Up @@ -77,8 +79,8 @@ def run_test(self):
self.log.info("Running tests")
dest_address = peer_node.getnewaddress()
self.test_invalid_parameters(rbf_node, dest_address)
test_simple_bumpfee_succeeds(self, "default", rbf_node, peer_node, dest_address)
test_simple_bumpfee_succeeds(self, "fee_rate", rbf_node, peer_node, dest_address)
for mode in ["default", "fee_rate", BTC_MODE, SAT_MODE]:
test_simple_bumpfee_succeeds(self, mode, rbf_node, peer_node, dest_address)
test_feerate_args(self, rbf_node, peer_node, dest_address)
test_segwit_bumpfee_succeeds(self, rbf_node, dest_address)
test_nonrbf_bumpfee_fails(self, peer_node, dest_address)
Expand Down Expand Up @@ -132,6 +134,13 @@ def test_simple_bumpfee_succeeds(self, mode, rbf_node, peer_node, dest_address):
if mode == "fee_rate":
bumped_psbt = rbf_node.psbtbumpfee(rbfid, {"fee_rate": NORMAL})
bumped_tx = rbf_node.bumpfee(rbfid, {"fee_rate": NORMAL})
elif mode == BTC_MODE:
bumped_psbt = rbf_node.psbtbumpfee(rbfid, {"conf_target": NORMAL, "estimate_mode": BTC_MODE})
bumped_tx = rbf_node.bumpfee(rbfid, {"conf_target": NORMAL, "estimate_mode": BTC_MODE})
elif mode == SAT_MODE:
sat_fee = NORMAL * COIN / 1000 # convert NORMAL from BTC/kB to sat/B
bumped_psbt = rbf_node.psbtbumpfee(rbfid, {"conf_target": sat_fee, "estimate_mode": SAT_MODE})
bumped_tx = rbf_node.bumpfee(rbfid, {"conf_target": sat_fee, "estimate_mode": SAT_MODE})
else:
bumped_psbt = rbf_node.psbtbumpfee(rbfid)
bumped_tx = rbf_node.bumpfee(rbfid)
Expand Down

0 comments on commit 052427e

Please sign in to comment.