]> Untitled Git - bdk/commit
Fix vbytes and fee rate code
authorTobin Harding <me@tobin.cc>
Fri, 16 Jul 2021 05:14:20 +0000 (15:14 +1000)
committerTobin Harding <me@tobin.cc>
Thu, 22 Jul 2021 23:43:12 +0000 (09:43 +1000)
commit2986fce7c61474a90cf2d4a7103a6611a2412e9d
tree400bf1c74c694175e0be6e378e1fcfe1acebc673
parent474620e6a574f7133a3339acfa7d0b1c62d5bb48
Fix vbytes and fee rate code

It was just pointed out that we are calculating the virtual bytes
incorrectly by forgetting to take the ceiling after division by 4 [1]

Add helper functions to encapsulate all weight unit -> virtual byte
calculations including fee to and from fee rate. This makes the code
easier to read, easier to write, and gives us a better chance that bugs
like this will be easier to see.

As an added bonus we can also stop using f32 values for fee amount,
which is by definition an amount in sats so should be a u64. This
removes a bunch of casts and the need for epsilon comparisons and just
deep down feels nice :)

[1] https://github.com/bitcoindevkit/bdk/pull/386#discussion_r670882678
src/types.rs
src/wallet/coin_selection.rs
src/wallet/mod.rs