Adds the automatically-subtract-the-fee-from-the-amount-and-send-whats-left feature to the GUI and rpc (sendtoaddres,sendfrom,sendmany).
The checkbox is only shown for the first recipient. This is to avoid confusion and to make the implementation as simple as possible: We deduct the fee from the first recipient, if its not enough -> fail If whats left to send is dust -> fail
There is an edge case to consider: Instead of moving dust change to fees, we raise the change until no dust and deduct from the recipient. Example: Amount: 10000 satoshis Fee: 300 satoshis Selected unspent output: 10001 satoshis
Now normally: Recipient receives: 9700 Fee: 300 Change: 1 To pay: 10000
But 1 satoshi is dust, so instead we do: Recipient receives: 9155 (9700 - 545) Fee: 300 Change: 546 (1 + 545) To pay: 9455
So you end up paying less than 10000 in this edge case. But if we would move dust-change to fees (or recipient) you would pay 10001 which would be totally unexpected if you enter 10000 and say “please just deduct the fee from the 10000 and send whats left”.
Without checkbox
With checkbox
Dust edge case
rpc