This solves the issue #19507.
Note: testmempoolaccept
only returns 'fee'
when 'allowed'
is true
. The reason being, fee
calculation can return garbage or worse can fail if malformed transactions are fed into the RPC call. One disadvantage is, this will not return fee
for a correct transaction but not accepted into mempool for other reasons (ex: tx already exists in a block).
Open for suggestions for other ways of handling the above issue. But my guess is it should be that much of a problem.
On Approach: This approach calculates the transaction fee explicitly in the rpc callback. Which requires mempool lock and some cache memory allocation. So the processing for the same is getting doubled. The other way was to return the calculated fee from deep within the validation process which required touching consensus critical codes. So I stuck with the first one.
Update: After the initial review approach is changed to extract the fee from validation calculation.