Bitcoin
Transaction Fees – How does fee subtraction work in Bitcoin Core?
In the explanation of Bitcoin Core, subtractfeefrom
A parameter that defines which recipient address will be selected to receive a smaller amount and contribute to the fee payment.
Use cases include:
Alex has 1 utxo with 10btc and sent TXN of 1BTC each to Mary BTC and BOB. The fee is 0.5BTC, so the change amount to Alex would be 10-2-0.5 = 7.5BTC.
How to? subtractfeefrom
Would you like to apply it in detail to the above case?
My high level assumption is
- Get the fees you need for txn
- Deduct this amount equally for all optin output destinations except change output (e.g. 0.5BTC/2 destination)
- The first optin output object is also deducted as an indivisible amount. Example: 0.5BTC % 2 target
- Check if the deducted output is dust, otherwise continue.
- Add total deduction for change of address
Additionally, if there is no change output, should I generate output in this case?