Using latest bitoind, any way to calculate max spendable from wallet with some amount of outputs? For example i need to send all wallet amount to 2 outputs and set mining fee enough to get confirmation in first block. How can i calculate max spendable amount?
In Bitcoin Core, there is the option to subtract the fee from the amount. When you create a transaction, you set the amount to be the maximum amounts, and then you enable the subtract fee from amount options which will then reduce the specified outputs by the fee. This way, you can choose to send your entire balance without change and have the fee be subtracted from the output.
In the GUI (bitcoin-qt), there is a checkbox labeled "Subtract fee from amount" which you can set for each recipient. You can use the "Use available balance" button to auto-fill the full wallet balance. It will also automatically check that option for you.
If you are using bitcoind over the RPC interface,
sendtoaddress has a parameter
subtractfeefromamount which you can set to
true in order to deduct the fee from the amount you are sending.
sendmany has a similar option but it is instead an array of addresses so you specify the addresses that will receive less due to the fee being subtracted from their amounts.