This is a followup to #19339, refining upon the 2xATMP approach. It adds a GetTransactionFee
utility function which uses CheckTxInputs
to get a transaction fee.
It also updates the Absurd Fee checking (see BroadcastTransaction
in src/node/transaction.cpp):
- Use
GetTransactionFee
to get the fee.- If it fails, dry-run ATMP to return a proper validation result. (
GetTransactionFee
does not take responsibility for filling inTxValidationState
although it may be modified). - If it succeeds, check against
max_tx_fee
. If fee is too high, just returnMAX_FEE_EXCEEDED
.
- If it fails, dry-run ATMP to return a proper validation result. (
- If fee is ok, call ATMP to submit to mempool. Broadcast.
ATMP is called at most 1 time. I think it’s best to dry-run ATMP in the failure case because ATMP should be the authority on validation, i.e. be responsible for filling in TxValidationResult
here. If the results don’t match; i.e. GetTransactionFee
fails but ATMP somehow succeeds (which should never happen), we don’t risk accidentally allowing an absurd fee through.