Skip to content

Commit 02afb0c

Browse files
committed
Fix origfee return for bumpfee with feerate arg
1 parent 2ecb7e1 commit 02afb0c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/wallet/feebumper.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,11 @@ static feebumper::Result CheckFeeRate(const CWallet& wallet, const CWalletTx& wt
108108
return feebumper::Result::OK;
109109
}
110110

111-
static CFeeRate EstimateFeeRate(const CWallet& wallet, const CWalletTx& wtx, CCoinControl& coin_control, CAmount& old_fee)
111+
static CFeeRate EstimateFeeRate(const CWallet& wallet, const CWalletTx& wtx, const CAmount old_fee, CCoinControl& coin_control)
112112
{
113113
// Get the fee rate of the original transaction. This is calculated from
114114
// the tx fee/vsize, so it may have been rounded down. Add 1 satoshi to the
115115
// result.
116-
old_fee = wtx.GetDebit(ISMINE_SPENDABLE) - wtx.tx->GetValueOut();
117116
int64_t txSize = GetVirtualTransactionSize(*(wtx.tx));
118117
CFeeRate feerate(old_fee, txSize);
119118
feerate += CFeeRate(1);
@@ -309,6 +308,8 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
309308
}
310309
}
311310

311+
old_fee = wtx.GetDebit(ISMINE_SPENDABLE) - wtx.tx->GetValueOut();
312+
312313
if (coin_control.m_feerate) {
313314
// The user provided a feeRate argument.
314315
// We calculate this here to avoid compiler warning on the cs_wallet lock
@@ -319,7 +320,7 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
319320
}
320321
} else {
321322
// The user did not provide a feeRate argument
322-
new_coin_control.m_feerate = EstimateFeeRate(wallet, wtx, new_coin_control, old_fee);
323+
new_coin_control.m_feerate = EstimateFeeRate(wallet, wtx, old_fee, new_coin_control);
323324
}
324325

325326
// Fill in required inputs we are double-spending(all of them)

test/functional/wallet_bumpfee.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def test_simple_bumpfee_succeeds(self, mode, rbf_node, peer_node, dest_address):
101101
else:
102102
bumped_tx = rbf_node.bumpfee(rbfid)
103103
assert_equal(bumped_tx["errors"], [])
104-
assert bumped_tx["fee"] - abs(rbftx["fee"]) > 0
104+
assert bumped_tx["fee"] > -rbftx["fee"]
105+
assert_equal(bumped_tx["origfee"], -rbftx["fee"])
105106
# check that bumped_tx propagates, original tx was evicted and has a wallet conflict
106107
self.sync_mempools((rbf_node, peer_node))
107108
assert bumped_tx["txid"] in rbf_node.getrawmempool()

0 commit comments

Comments
 (0)