X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Fchain%2Fchaininterface.rs;h=687262be8a16c16be001fbaf1b813233cb382888;hb=82601052fe2cac04a6249f5930495e987923303b;hp=40406be1b9e1e892bd00d09593522c7a80e3be91;hpb=45ad3320df3768514d968c70fc4b6a9d50028050;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/lightning/chain/chaininterface.rs b/lightning-c-bindings/src/lightning/chain/chaininterface.rs index 40406be..687262b 100644 --- a/lightning-c-bindings/src/lightning/chain/chaininterface.rs +++ b/lightning-c-bindings/src/lightning/chain/chaininterface.rs @@ -135,6 +135,15 @@ pub extern "C" fn ConfirmationTarget_normal() -> ConfirmationTarget { /// Utility method to constructs a new HighPriority-variant ConfirmationTarget pub extern "C" fn ConfirmationTarget_high_priority() -> ConfirmationTarget { ConfirmationTarget::HighPriority} +/// Generates a non-cryptographic 64-bit hash of the ConfirmationTarget. +#[no_mangle] +pub extern "C" fn ConfirmationTarget_hash(o: &ConfirmationTarget) -> u64 { + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(&o.to_native(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} /// Checks if two ConfirmationTargets contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] @@ -153,12 +162,12 @@ pub struct FeeEstimator { pub this_arg: *mut c_void, /// Gets estimated satoshis of fee required per 1000 Weight-Units. /// - /// Must return a value no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later - /// round-downs don't put us below 1 satoshi-per-byte). + /// LDK will wrap this method and ensure that the value returned is no smaller than 253 + /// (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte). /// - /// This method can be implemented with the following unit conversions: - /// * max(satoshis-per-byte * 250, 253) - /// * max(satoshis-per-kbyte / 4, 253) + /// The following unit conversions can be used to convert to sats/KW: + /// * satoshis-per-byte * 250 + /// * satoshis-per-kbyte / 4 #[must_use] pub get_est_sat_per_1000_weight: extern "C" fn (this_arg: *const c_void, confirmation_target: crate::lightning::chain::chaininterface::ConfirmationTarget) -> u32, /// Frees any resources associated with this object given its this_arg pointer. @@ -206,3 +215,9 @@ impl Drop for FeeEstimator { #[no_mangle] pub static MIN_RELAY_FEE_SAT_PER_1000_WEIGHT: u64 = lightning::chain::chaininterface::MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; +/// Minimum feerate that takes a sane approach to bitcoind weight-to-vbytes rounding. +/// See the following Core Lightning commit for an explanation: +/// + +#[no_mangle] +pub static FEERATE_FLOOR_SATS_PER_KW: u32 = lightning::chain::chaininterface::FEERATE_FLOOR_SATS_PER_KW;