Skip to content

Commit

Permalink
Bugfix: get fee asset from transaction rather than non-existent mem p…
Browse files Browse the repository at this point in the history
…ool entry
  • Loading branch information
JBetz committed Apr 23, 2024
1 parent 8e6666b commit a6b3d08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/node/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
return HandleATMPError(result.m_state, err_string);
} else if (g_con_any_asset_fees) {
CAmount mBaseFeesValue = node.mempool->mapTx.find(txid)->GetFeeValue();
CAmount mBaseFeesValue = ExchangeRateMap::GetInstance().CalculateExchangeValue(result.m_base_fees.value(), tx->GetFeeAsset(::policyAsset));
if (mBaseFeesValue > max_tx_fee) {
return TransactionError::MAX_FEE_EXCEEDED;
}
Expand Down
11 changes: 11 additions & 0 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,17 @@ class CTransaction
{
return !witness.IsNull();
}

const CAsset& GetFeeAsset(CAsset& default_asset) const
{
CAsset& feeAsset = default_asset;
for (size_t i = 0; i < vout.size(); i++) {
if (vout[i].IsFee()) {
feeAsset = vout[i].nAsset.GetAsset();
}
}
return feeAsset;
}
};

/** A mutable version of CTransaction. */
Expand Down

0 comments on commit a6b3d08

Please sign in to comment.