From 8050269803d4b7bd9079e1887000b9807d14bcf1 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 20 Mar 2021 17:32:50 -0400 Subject: [PATCH] Update auto-generated bindings --- lightning-c-bindings/include/lightning.h | 80 ++++++++++++++++--- lightning-c-bindings/src/ln/channelmanager.rs | 9 +++ lightning-c-bindings/src/util/config.rs | 80 ++++++++++++++++--- 3 files changed, 143 insertions(+), 26 deletions(-) diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index c85ac58..fddd4de 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -4959,6 +4959,8 @@ extern const uint64_t CLOSED_CHANNEL_UPDATE_ID; extern const uint16_t BREAKDOWN_TIMEOUT; +extern const uint16_t MIN_CLTV_EXPIRY_DELTA; + extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; void Transaction_free(struct LDKTransaction _res); @@ -5787,34 +5789,40 @@ uint32_t ChannelHandshakeConfig_get_minimum_depth(const struct LDKChannelHandsha void ChannelHandshakeConfig_set_minimum_depth(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val); /** - * Set to the amount of time we require our counterparty to wait to claim their money. + * Set to the number of blocks we require our counterparty to wait to claim their money (ie + * the number of blocks we have to punish our counterparty if they broadcast a revoked + * transaction). * - * It's one of the main parameter of our security model. We (or one of our watchtowers) MUST - * be online to check for peer having broadcast a revoked transaction to steal our funds - * at least once every our_to_self_delay blocks. + * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST + * be online to check for revoked transactions on-chain at least once every our_to_self_delay + * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, + * possibly with time in between to RBF the spending transaction). * * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in * case of an honest unilateral channel close, which implicitly decrease the economic value of * our channel. * - * Default value: [`BREAKDOWN_TIMEOUT`] (currently 144), we enforce it as a minimum at channel - * opening so you can tweak config to ask for more security, not less. + * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you + * can tweak config to ask for more security, not less. */ uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Set to the amount of time we require our counterparty to wait to claim their money. + * Set to the number of blocks we require our counterparty to wait to claim their money (ie + * the number of blocks we have to punish our counterparty if they broadcast a revoked + * transaction). * - * It's one of the main parameter of our security model. We (or one of our watchtowers) MUST - * be online to check for peer having broadcast a revoked transaction to steal our funds - * at least once every our_to_self_delay blocks. + * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST + * be online to check for revoked transactions on-chain at least once every our_to_self_delay + * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, + * possibly with time in between to RBF the spending transaction). * * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in * case of an honest unilateral channel close, which implicitly decrease the economic value of * our channel. * - * Default value: [`BREAKDOWN_TIMEOUT`] (currently 144), we enforce it as a minimum at channel - * opening so you can tweak config to ask for more security, not less. + * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you + * can tweak config to ask for more security, not less. */ void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val); @@ -6084,6 +6092,52 @@ uint32_t ChannelConfig_get_fee_proportional_millionths(const struct LDKChannelCo */ void ChannelConfig_set_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); +/** + * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over + * the channel this config applies to. + * + * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight + * HTLC balance when a channel appears on-chain whereas + * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining + * (non-HTLC-encumbered) balance. + * + * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, + * we (or one of our watchtowers) MUST be online to check for broadcast of the current + * commitment transaction at least once per this many blocks (minus some margin to allow us + * enough time to broadcast and confirm a transaction, possibly with time in between to RBF + * the spending transaction). + * + * Default value: 72 (12 hours at an average of 6 blocks/hour). + * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as + * [`MIN_CLTV_EXPIRY_DELTA`] instead. + * + * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA + */ +uint16_t ChannelConfig_get_cltv_expiry_delta(const struct LDKChannelConfig *NONNULL_PTR this_ptr); + +/** + * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over + * the channel this config applies to. + * + * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight + * HTLC balance when a channel appears on-chain whereas + * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining + * (non-HTLC-encumbered) balance. + * + * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, + * we (or one of our watchtowers) MUST be online to check for broadcast of the current + * commitment transaction at least once per this many blocks (minus some margin to allow us + * enough time to broadcast and confirm a transaction, possibly with time in between to RBF + * the spending transaction). + * + * Default value: 72 (12 hours at an average of 6 blocks/hour). + * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as + * [`MIN_CLTV_EXPIRY_DELTA`] instead. + * + * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA + */ +void ChannelConfig_set_cltv_expiry_delta(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint16_t val); + /** * Set to announce the channel publicly and notify all nodes that they can route via this * channel. @@ -6147,7 +6201,7 @@ void ChannelConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannelConfig *N /** * Constructs a new ChannelConfig given each field */ -MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t fee_proportional_millionths_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg); +MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg); /** * Creates a copy of the ChannelConfig diff --git a/lightning-c-bindings/src/ln/channelmanager.rs b/lightning-c-bindings/src/ln/channelmanager.rs index a5551a6..2ab0c9f 100644 --- a/lightning-c-bindings/src/ln/channelmanager.rs +++ b/lightning-c-bindings/src/ln/channelmanager.rs @@ -206,6 +206,15 @@ pub extern "C" fn ChainParameters_new(mut network_arg: crate::bitcoin::network:: #[no_mangle] pub static BREAKDOWN_TIMEOUT: u16 = lightning::ln::channelmanager::BREAKDOWN_TIMEOUT; +/// The minimum number of blocks between an inbound HTLC's CLTV and the corresponding outbound +/// HTLC's CLTV. The current default represents roughly six hours of blocks at six blocks/hour. +/// +/// This can be increased (but not decreased) through [`ChannelConfig::cltv_expiry_delta`] +/// +/// [`ChannelConfig::cltv_expiry_delta`]: crate::util::config::ChannelConfig::cltv_expiry_delta + +#[no_mangle] +pub static MIN_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA; use lightning::ln::channelmanager::ChannelDetails as nativeChannelDetailsImport; type nativeChannelDetails = nativeChannelDetailsImport; diff --git a/lightning-c-bindings/src/util/config.rs b/lightning-c-bindings/src/util/config.rs index d1d3f1b..1d1cb15 100644 --- a/lightning-c-bindings/src/util/config.rs +++ b/lightning-c-bindings/src/util/config.rs @@ -79,35 +79,41 @@ pub extern "C" fn ChannelHandshakeConfig_get_minimum_depth(this_ptr: &ChannelHan pub extern "C" fn ChannelHandshakeConfig_set_minimum_depth(this_ptr: &mut ChannelHandshakeConfig, mut val: u32) { unsafe { &mut *this_ptr.inner }.minimum_depth = val; } -/// Set to the amount of time we require our counterparty to wait to claim their money. +/// Set to the number of blocks we require our counterparty to wait to claim their money (ie +/// the number of blocks we have to punish our counterparty if they broadcast a revoked +/// transaction). /// -/// It's one of the main parameter of our security model. We (or one of our watchtowers) MUST -/// be online to check for peer having broadcast a revoked transaction to steal our funds -/// at least once every our_to_self_delay blocks. +/// This is one of the main parameters of our security model. We (or one of our watchtowers) MUST +/// be online to check for revoked transactions on-chain at least once every our_to_self_delay +/// blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, +/// possibly with time in between to RBF the spending transaction). /// /// Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in /// case of an honest unilateral channel close, which implicitly decrease the economic value of /// our channel. /// -/// Default value: [`BREAKDOWN_TIMEOUT`] (currently 144), we enforce it as a minimum at channel -/// opening so you can tweak config to ask for more security, not less. +/// Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you +/// can tweak config to ask for more security, not less. #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_our_to_self_delay(this_ptr: &ChannelHandshakeConfig) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.our_to_self_delay; (*inner_val) } -/// Set to the amount of time we require our counterparty to wait to claim their money. +/// Set to the number of blocks we require our counterparty to wait to claim their money (ie +/// the number of blocks we have to punish our counterparty if they broadcast a revoked +/// transaction). /// -/// It's one of the main parameter of our security model. We (or one of our watchtowers) MUST -/// be online to check for peer having broadcast a revoked transaction to steal our funds -/// at least once every our_to_self_delay blocks. +/// This is one of the main parameters of our security model. We (or one of our watchtowers) MUST +/// be online to check for revoked transactions on-chain at least once every our_to_self_delay +/// blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, +/// possibly with time in between to RBF the spending transaction). /// /// Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in /// case of an honest unilateral channel close, which implicitly decrease the economic value of /// our channel. /// -/// Default value: [`BREAKDOWN_TIMEOUT`] (currently 144), we enforce it as a minimum at channel -/// opening so you can tweak config to ask for more security, not less. +/// Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you +/// can tweak config to ask for more security, not less. #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_set_our_to_self_delay(this_ptr: &mut ChannelHandshakeConfig, mut val: u16) { unsafe { &mut *this_ptr.inner }.our_to_self_delay = val; @@ -528,6 +534,53 @@ pub extern "C" fn ChannelConfig_get_fee_proportional_millionths(this_ptr: &Chann pub extern "C" fn ChannelConfig_set_fee_proportional_millionths(this_ptr: &mut ChannelConfig, mut val: u32) { unsafe { &mut *this_ptr.inner }.fee_proportional_millionths = val; } +/// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over +/// the channel this config applies to. +/// +/// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight +/// HTLC balance when a channel appears on-chain whereas +/// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining +/// (non-HTLC-encumbered) balance. +/// +/// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, +/// we (or one of our watchtowers) MUST be online to check for broadcast of the current +/// commitment transaction at least once per this many blocks (minus some margin to allow us +/// enough time to broadcast and confirm a transaction, possibly with time in between to RBF +/// the spending transaction). +/// +/// Default value: 72 (12 hours at an average of 6 blocks/hour). +/// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as +/// [`MIN_CLTV_EXPIRY_DELTA`] instead. +/// +/// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA +#[no_mangle] +pub extern "C" fn ChannelConfig_get_cltv_expiry_delta(this_ptr: &ChannelConfig) -> u16 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta; + (*inner_val) +} +/// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over +/// the channel this config applies to. +/// +/// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight +/// HTLC balance when a channel appears on-chain whereas +/// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining +/// (non-HTLC-encumbered) balance. +/// +/// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, +/// we (or one of our watchtowers) MUST be online to check for broadcast of the current +/// commitment transaction at least once per this many blocks (minus some margin to allow us +/// enough time to broadcast and confirm a transaction, possibly with time in between to RBF +/// the spending transaction). +/// +/// Default value: 72 (12 hours at an average of 6 blocks/hour). +/// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as +/// [`MIN_CLTV_EXPIRY_DELTA`] instead. +/// +/// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA +#[no_mangle] +pub extern "C" fn ChannelConfig_set_cltv_expiry_delta(this_ptr: &mut ChannelConfig, mut val: u16) { + unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val; +} /// Set to announce the channel publicly and notify all nodes that they can route via this /// channel. /// @@ -593,9 +646,10 @@ pub extern "C" fn ChannelConfig_set_commit_upfront_shutdown_pubkey(this_ptr: &mu /// Constructs a new ChannelConfig given each field #[must_use] #[no_mangle] -pub extern "C" fn ChannelConfig_new(mut fee_proportional_millionths_arg: u32, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool) -> ChannelConfig { +pub extern "C" fn ChannelConfig_new(mut fee_proportional_millionths_arg: u32, mut cltv_expiry_delta_arg: u16, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool) -> ChannelConfig { ChannelConfig { inner: Box::into_raw(Box::new(nativeChannelConfig { fee_proportional_millionths: fee_proportional_millionths_arg, + cltv_expiry_delta: cltv_expiry_delta_arg, announced_channel: announced_channel_arg, commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg, })), is_owned: true } -- 2.30.2