mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
Merge #17643: wallet: Fix origfee return for bumpfee with feerate arg
02afb0c550
Fix origfee return for bumpfee with feerate arg (Gregory Sanders) Pull request description: fixes https://github.com/bitcoin/bitcoin/issues/17642 and adds a simple test that would have caught it ACKs for top commit: achow101: ACK02afb0c550
Tree-SHA512: 303e392e05407f204dffe360689b5bb5dc77fd462dd0e489bc0b6c8f94f89ab7fe2bd8cb47e4dc6dc5c23a619826d15f3bf6b02b2c8e96402fbb51953c462e2d
This commit is contained in:
commit
2b6575d989
@ -108,12 +108,11 @@ static feebumper::Result CheckFeeRate(const CWallet& wallet, const CWalletTx& wt
|
||||
return feebumper::Result::OK;
|
||||
}
|
||||
|
||||
static CFeeRate EstimateFeeRate(const CWallet& wallet, const CWalletTx& wtx, CCoinControl& coin_control, CAmount& old_fee)
|
||||
static CFeeRate EstimateFeeRate(const CWallet& wallet, const CWalletTx& wtx, const CAmount old_fee, CCoinControl& coin_control)
|
||||
{
|
||||
// Get the fee rate of the original transaction. This is calculated from
|
||||
// the tx fee/vsize, so it may have been rounded down. Add 1 satoshi to the
|
||||
// result.
|
||||
old_fee = wtx.GetDebit(ISMINE_SPENDABLE) - wtx.tx->GetValueOut();
|
||||
int64_t txSize = GetVirtualTransactionSize(*(wtx.tx));
|
||||
CFeeRate feerate(old_fee, txSize);
|
||||
feerate += CFeeRate(1);
|
||||
@ -309,6 +308,8 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
|
||||
}
|
||||
}
|
||||
|
||||
old_fee = wtx.GetDebit(ISMINE_SPENDABLE) - wtx.tx->GetValueOut();
|
||||
|
||||
if (coin_control.m_feerate) {
|
||||
// The user provided a feeRate argument.
|
||||
// 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
|
||||
}
|
||||
} else {
|
||||
// The user did not provide a feeRate argument
|
||||
new_coin_control.m_feerate = EstimateFeeRate(wallet, wtx, new_coin_control, old_fee);
|
||||
new_coin_control.m_feerate = EstimateFeeRate(wallet, wtx, old_fee, new_coin_control);
|
||||
}
|
||||
|
||||
// Fill in required inputs we are double-spending(all of them)
|
||||
|
@ -101,7 +101,8 @@ def test_simple_bumpfee_succeeds(self, mode, rbf_node, peer_node, dest_address):
|
||||
else:
|
||||
bumped_tx = rbf_node.bumpfee(rbfid)
|
||||
assert_equal(bumped_tx["errors"], [])
|
||||
assert bumped_tx["fee"] - abs(rbftx["fee"]) > 0
|
||||
assert bumped_tx["fee"] > -rbftx["fee"]
|
||||
assert_equal(bumped_tx["origfee"], -rbftx["fee"])
|
||||
# check that bumped_tx propagates, original tx was evicted and has a wallet conflict
|
||||
self.sync_mempools((rbf_node, peer_node))
|
||||
assert bumped_tx["txid"] in rbf_node.getrawmempool()
|
||||
|
Loading…
Reference in New Issue
Block a user