In the following post Calculating fee based on fee rate for bitcoin transaction the respondent describes how the fees can be calculated.

Since your transaction building starts with a known target feerate, and you know the size of the transaction header data and outputs, you can calculate their fees in advance.

However, AFAKT, the bitcoin core SRD algorithm only accounts for a single output, the change output (change_fee):


In the line about, the target_value is incremented by the CHANGE_LOWER (dust limit) and the cost of producing a change output (change_fee). That way, the change amount is larger than the dust limit and can also pay for the fee of creating the change output. However, this does not account for paying for the remaining output nor the transaction header fields as described in the above link. Why is it not important to add the size of theses respective transaction parts when setting the target_value in SRD?

1 Answer 1


It is important to account for these fees!

Bitcoin Core adds up recipient amounts and fees for header and recipient outputs to create selection_target in CreateTransactionInternal(…). This value is then used a few lines later in SelectCoins(…), from where calls go to AutomaticCoinSelection(…), AttemptSelection(…), and ChooseSelectionResult(…).

ChooseSelectionResult(…) then calls all coin selection algorithms with targets based on the above value, including SelectCoinsSRD(…). So, the SRD algorithm’s target does include the fees for the recipient outputs and header.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.