bit
bit copied to clipboard
Calculate fee or trx size
https://github.com/ofek/bit/issues/106
I have the same need to calculate the fee amount, or deduct the fee amount from the transfer amount. Otherwise, a bug will appear.
Let's say you have 1 bitcoin on your balance and you need to transfer the entire balance. If you specify 1 bitcoin for the transfer, you will receive an error not enough funds. How to correctly calculate the maximum value for a transfer, taking into account the fee?
Normally, this is how we do it: https://ofek.dev/bit/guide/transactions.html#transfer-funds
looks like kludge
It might appear as such to you, but that is the exact high level representation of how a wallet sweep actually works 😉
It's not about wallet sweep at all. Don't you find the problem is that it is not possible to calculate the exact fee and include it in the transfer amount? After all, it is also necessary to check the balance for availability. Conventionally, if there is 0.1 bitcoin on the wallet and I need to transfer 0.99997, the transaction will not go through with the "insufficient balance" error.
The fee calculation function was fixed in https://github.com/ofek/bit/pull/109/files
Can I get more information about func arguments: in_size, n_in, out_size, n_out ?