Wednesday, July 3, 2024

bitcoin core – How does subtractfeefrom work?

As you write, the sendmany has the optionally available parameter subtractfeefrom. It takes an array of addresses which should be a subset of the addresses showing within the quantities object. As a substitute of the default conduct of the sender paying for the transaction charges, when any addresses are offered in subtractfeefrom, the transaction charges are deducted in equal shares from the listed recipients.

Beneath the hood, Bitcoin Core performs coin choice as if the transaction didn’t value charges utilizing the precise values of UTXOs as a substitute of their efficient values. After assigning the leftover quantity to a change output, the charges for the complete transaction are calculated and deducted from the recipients listed in subtractfeefrom in equal shares. If the quantity doesn’t divide cleanly, any the rest is deducted from the primary listed deal with, i.e. if the transaction price amounted to 800 sats and there have been three recipients to deduct the charges from, the primary would pay 268 sats and the latter two would pay 266 sats.

As the mix of SFFO and looking for changeless transactions has triggered a number of bugs within the final 12 months, Bitcoin Core will all the time create a transaction with change when any variant of subtractfeefromoutput (SFFO) is used. By the way, if you wish to empty a pockets fully, maybe think about using the sendall RPC as a substitute.

General, SFFO is a large ache within the neck because it turns a variety of the final assumptions about coin choice and transaction constructing on its head. In case you are seeking to implement one thing prefer it, I’d counsel that you don’t try to repeat Bitcoin Core’s strategy.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles