lwk_common 0.17.0

Liquid Wallet Kit - Common utilities
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
/// Default fee rate in sats/kvb (0.1 sat/vb = 100 sats/kvb)
pub const DEFAULT_FEE_RATE: f32 = 100.0;

/// Calculate the fee from transaction weight and fee rate.
///
/// # Arguments
/// * `weight` - Transaction weight in weight units
/// * `fee_rate` - Fee rate in sats/kvb
pub fn calculate_fee(weight: usize, fee_rate: f32) -> u64 {
    let vsize = weight.div_ceil(4);
    (vsize as f32 * fee_rate / 1000.0).ceil() as u64
}