Skip to content

Commit

Permalink
Use asset exchange rates when validating feebumper fee rate
Browse files Browse the repository at this point in the history
  • Loading branch information
JBetz committed Apr 23, 2024
1 parent ce0d89d commit 762e39d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/wallet/feebumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ static feebumper::Result CheckFeeRate(const CWallet& wallet, const CWalletTx& wt
FormatMoney(minMempoolFeeRate.GetFeePerK())));
return feebumper::Result::WALLET_ERROR;
}

CAmount new_total_fee = newFeerate.GetFee(maxTxSize);
const CAsset& feeAsset = wtx.tx->GetFeeAsset(::policyAsset);
CAmount new_total_fee = newFeerate.GetFee(maxTxSize, feeAsset);

CFeeRate incrementalRelayFee = std::max(wallet.chain().relayIncrementalFee(), CFeeRate(WALLET_INCREMENTAL_RELAY_FEE));

// Given old total fee and transaction size, calculate the old feeRate
isminefilter filter = wallet.GetLegacyScriptPubKeyMan() && wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) ? ISMINE_WATCH_ONLY : ISMINE_SPENDABLE;
CAmount old_fee = CachedTxGetDebit(wallet, wtx, filter)[::policyAsset] - wtx.tx->GetValueOutMap()[::policyAsset];
CAmount old_fee = CachedTxGetDebit(wallet, wtx, filter)[feeAsset] - wtx.tx->GetValueOutMap()[feeAsset];
if (g_con_elementsmode) {
old_fee = GetFeeMap(*wtx.tx)[::policyAsset];
old_fee = GetFeeMap(*wtx.tx)[feeAsset];
}
const int64_t txSize = GetVirtualTransactionSize(*(wtx.tx));
CFeeRate nOldFeeRate(old_fee, txSize);
// Min total fee is old fee + relay fee
CAmount minTotalFee = nOldFeeRate.GetFee(maxTxSize) + incrementalRelayFee.GetFee(maxTxSize);
CAmount minTotalFee = nOldFeeRate.GetFee(maxTxSize, feeAsset) + incrementalRelayFee.GetFee(maxTxSize, feeAsset);

if (new_total_fee < minTotalFee) {
errors.push_back(strprintf(Untranslated("Insufficient total fee %s, must be at least %s (oldFee %s + incrementalFee %s)"),
Expand Down

0 comments on commit 762e39d

Please sign in to comment.