Bitcoin

Bitcoin Core – How does Fee Subtraction work?

As you write, sendmany There are optional parameters. subtractfeefrom. I need an array of addresses that should be a subset of the addresses that appear here. amounts object. If an address is provided instead of the default action where the sender pays a transaction fee subtractfeefromTransaction fees are deducted equally from the listed recipients.

Internally, Bitcoin Core uses the real value of the UTXO instead of the effective value to perform coin selection as if the transaction were commission-free. After allocating the remaining amount to the change output, the fee for the entire transaction is calculated and deducted from the listed recipients. subtractfeefrom In equal shares. If the amount is not divided neatly, the remainder will be deducted from the first listed address. That is, if the transaction fee is 800 sats and there are 3 recipients from whom the fee will be deducted, the first person will pay 268 sats and the latter two will pay 268 sats. 266Saturday

Due to a combination of SFFO and attempts to find unchanged transactions, which resulted in several bugs over the past year, Bitcoin Core will always create changed transactions when there are variants of: subtractfeefromoutput (SFFO) is used. For reference, if you want to completely empty your wallet, sendall RPC instead.

Overall, SFFO is a huge pain in the neck because it overturns many common assumptions about coin selection and trade construction. If you’re looking to implement something similar, I recommend not copying Bitcoin Core’s approach.

Related Articles

Back to top button