LtbLightning / bdk-flutter

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

How to get a transaction fees? #58

Closed awaik closed 1 year ago

awaik commented 1 year ago

As we can see in the example with the package

final PartiallySignedTransaction psbt = await txBuilder.addRecipient(script, 700).feeRate(1.1).finish(wallet);

it was used as a predefined transaction fee.

Also, on the BDK website, there is an article https://bitcoindevkit.org/blog/2021/01/fee-estimation-for-light-clients-part-1/ about this issue.

So the question is - what is the recommended way to get fees for building a UX like in the attached image?

photo_2023-02-13 12 07 35

BitcoinZavior commented 1 year ago

Hi @awaik enhanced fee estimation will be added to bdk-flutter in the next release. It will have flutter api for this functionality https://github.com/bitcoindevkit/bdk-ffi/pull/289

In the meantime electrs provides fee estimation: link to fee estimate reference from electrs: https://github.com/blockstream/esplora/blob/master/API.md#get-fee-estimates This is an example call to the blockstream public server for current fee rates: https://blockstream.info/api/fee-estimates

BitcoinZavior commented 1 year ago

@awaik this is available in v0.27.1

awaik commented 1 year ago

@awaik this is available in v0.27.1

Thank you! There is an issue - I've tried to use it and always have a result 1.0 sat/vB. Code final FeeRate rate = await blockchain!.estimateFee(13);