LtbLightning / bdk-flutter

Bitcoin Development Kit - Flutter Package
MIT License
60 stars 27 forks source link

Sweep Wallet #29

Open BitcoinZavior opened 1 year ago

BitcoinZavior commented 1 year ago

This should not be much, a new fn called sweepFunds can be created for this. This could be a good first issue for me to get the hang of the entire end to end FFI workflow.

If you have any documentation on this process, that would be really helpful or if you could give me a run down either here or if we can schedule a call over discord that would be even better. I will document the process so that new developers will find it easy to contribute.

BitcoinZavior commented 1 year ago

Addresses https://github.com/LtbLightning/bdk-flutter/issues/27

BullishNode commented 1 year ago

Does bdk support substracting fees from amount sent?

MrUnfunny commented 1 year ago

@BullishNode Are you asking if we can include the fee in the total amount? Like if we send 1000 satoshi, then 1000 must include the fee as well?

For this, you can calculate the fee rate beforehand by calculating the transaction size and supplying this fee rate and amount as (total amount - fee). Not sure if this is your exact requirement but it is certainly possible to modify fee with bdk.

BullishNode commented 1 year ago

Was thinking about the subtractfeefromamount argument in the Bitcoin Core RPC which will do that automatically

i5hi commented 1 year ago

Was thinking about the subtractfeefromamount argument in the Bitcoin Core RPC which will do that automatically

bdk does'nt support this with a normal send.

It does this if you sweep/drain. You will not have control over the amount sent. It will first determine how much fees to use and the remaining will be sent as an output with 0 change.

You can set an absolute fee, which although is not exactly the same, can get you a similar effect. Problem with absolute fee is that it doesnt consider the network fee_rate and also doesnt consider the size of your tx, so you won't have the UX of saying i can only send 100k sats, i want to send all that at a fast rate and just take the fees from the amount required. You could however say, send 90ksats and use an absolute fee of 10k sats. But now you don't know how fast this will get confirmed, but you get the UX of i can only spend exactly 100k and that has to include fees.