#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn ChannelHandshakeConfig_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelHandshakeConfig); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelHandshakeConfig) };
}
#[allow(unused)]
impl ChannelHandshakeConfig {
/// any attacker who is able to take control of a channel can just as easily send the funds via
/// lightning payments, so we never require that our counterparties support this option.
///
-/// The upfront key committed is provided from [`KeysInterface::get_shutdown_scriptpubkey`].
+/// The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`].
///
/// Default value: true.
///
-/// [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey
+/// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey
#[no_mangle]
pub extern "C" fn ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(this_ptr: &ChannelHandshakeConfig) -> bool {
let mut inner_val = &mut this_ptr.get_native_mut_ref().commit_upfront_shutdown_pubkey;
/// any attacker who is able to take control of a channel can just as easily send the funds via
/// lightning payments, so we never require that our counterparties support this option.
///
-/// The upfront key committed is provided from [`KeysInterface::get_shutdown_scriptpubkey`].
+/// The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`].
///
/// Default value: true.
///
-/// [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey
+/// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey
#[no_mangle]
pub extern "C" fn ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) {
unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commit_upfront_shutdown_pubkey = val;
}
+/// The Proportion of the channel value to configure as counterparty's channel reserve,
+/// i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels.
+///
+/// `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain
+/// on their side, at all times.
+/// This ensures that if our counterparty broadcasts a revoked state, we can punish them by
+/// claiming at least this value on chain.
+///
+/// Channel reserve values greater than 30% could be considered highly unreasonable, since that
+/// amount can never be used for payments.
+/// Also, if our selected channel reserve for counterparty and counterparty's selected
+/// channel reserve for us sum up to equal or greater than channel value, channel negotiations
+/// will fail.
+///
+/// Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve
+/// other than the default value.
+///
+/// Default value: 1% of channel value, i.e., configured as 10,000 millionths.
+/// Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated
+/// as 1000 sats instead, which is a safe implementation-specific lower bound.
+/// Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%)
+/// instead, although channel negotiations will fail in that case.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(this_ptr: &ChannelHandshakeConfig) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().their_channel_reserve_proportional_millionths;
+ *inner_val
+}
+/// The Proportion of the channel value to configure as counterparty's channel reserve,
+/// i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels.
+///
+/// `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain
+/// on their side, at all times.
+/// This ensures that if our counterparty broadcasts a revoked state, we can punish them by
+/// claiming at least this value on chain.
+///
+/// Channel reserve values greater than 30% could be considered highly unreasonable, since that
+/// amount can never be used for payments.
+/// Also, if our selected channel reserve for counterparty and counterparty's selected
+/// channel reserve for us sum up to equal or greater than channel value, channel negotiations
+/// will fail.
+///
+/// Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve
+/// other than the default value.
+///
+/// Default value: 1% of channel value, i.e., configured as 10,000 millionths.
+/// Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated
+/// as 1000 sats instead, which is a safe implementation-specific lower bound.
+/// Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%)
+/// instead, although channel negotiations will fail in that case.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(this_ptr: &mut ChannelHandshakeConfig, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.their_channel_reserve_proportional_millionths = val;
+}
/// Constructs a new ChannelHandshakeConfig given each field
#[must_use]
#[no_mangle]
-pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our_to_self_delay_arg: u16, mut our_htlc_minimum_msat_arg: u64, mut max_inbound_htlc_value_in_flight_percent_of_channel_arg: u8, mut negotiate_scid_privacy_arg: bool, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool) -> ChannelHandshakeConfig {
+pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our_to_self_delay_arg: u16, mut our_htlc_minimum_msat_arg: u64, mut max_inbound_htlc_value_in_flight_percent_of_channel_arg: u8, mut negotiate_scid_privacy_arg: bool, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool, mut their_channel_reserve_proportional_millionths_arg: u32) -> ChannelHandshakeConfig {
ChannelHandshakeConfig { inner: ObjOps::heap_alloc(nativeChannelHandshakeConfig {
minimum_depth: minimum_depth_arg,
our_to_self_delay: our_to_self_delay_arg,
negotiate_scid_privacy: negotiate_scid_privacy_arg,
announced_channel: announced_channel_arg,
commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg,
+ their_channel_reserve_proportional_millionths: their_channel_reserve_proportional_millionths_arg,
}), is_owned: true }
}
impl Clone for ChannelHandshakeConfig {
///
/// These limits are only applied to our counterparty's limits, not our own.
///
-/// Use 0/<type>::max_value() as appropriate to skip checking.
+/// Use 0/`<type>::max_value()` as appropriate to skip checking.
///
/// Provides sane defaults for most configurations.
///
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn ChannelHandshakeLimits_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelHandshakeLimits); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelHandshakeLimits) };
}
#[allow(unused)]
impl ChannelHandshakeLimits {
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn ChannelConfig_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelConfig); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelConfig) };
}
#[allow(unused)]
impl ChannelConfig {
/// to such payments may be sustantial if there are many dust HTLCs present when the
/// channel is force-closed.
///
+/// The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a
+/// channel negotiated throughout the channel open process, along with the fees required to have
+/// a broadcastable HTLC spending transaction. When a channel supports anchor outputs
+/// (specifically the zero fee HTLC transaction variant), this threshold no longer takes into
+/// account the HTLC transaction fee as it is zero.
+///
/// This limit is applied for sent, forwarded, and received HTLCs and limits the total
/// exposure across all three types per-channel. Setting this too low may prevent the
/// sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
/// to such payments may be sustantial if there are many dust HTLCs present when the
/// channel is force-closed.
///
+/// The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a
+/// channel negotiated throughout the channel open process, along with the fees required to have
+/// a broadcastable HTLC spending transaction. When a channel supports anchor outputs
+/// (specifically the zero fee HTLC transaction variant), this threshold no longer takes into
+/// account the HTLC transaction fee as it is zero.
+///
/// This limit is applied for sent, forwarded, and received HTLCs and limits the total
/// exposure across all three types per-channel. Setting this too low may prevent the
/// sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
pub extern "C" fn ChannelConfig_clone(orig: &ChannelConfig) -> ChannelConfig {
orig.clone()
}
+/// Checks if two ChannelConfigs contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+/// Two objects with NULL inner values will be considered "equal" here.
+#[no_mangle]
+pub extern "C" fn ChannelConfig_eq(a: &ChannelConfig, b: &ChannelConfig) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if a.get_native_ref() == b.get_native_ref() { true } else { false }
+}
/// Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
#[must_use]
#[no_mangle]
/// Read a ChannelConfig from a byte array, created by ChannelConfig_write
pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelConfigDecodeErrorZ {
let res: Result<lightning::util::config::ChannelConfig, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
- let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::config::ChannelConfig { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::config::ChannelConfig { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
local_res
}
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn UserConfig_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUserConfig); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUserConfig) };
}
#[allow(unused)]
impl UserConfig {
pub extern "C" fn UserConfig_set_manually_accept_inbound_channels(this_ptr: &mut UserConfig, mut val: bool) {
unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.manually_accept_inbound_channels = val;
}
+/// If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over
+/// fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC
+/// intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user.
+///
+/// Setting this to true may break backwards compatibility with LDK versions < 0.0.113.
+///
+/// Default value: false.
+///
+/// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
+/// [`Event::HTLCIntercepted`]: crate::util::events::Event::HTLCIntercepted
+#[no_mangle]
+pub extern "C" fn UserConfig_get_accept_intercept_htlcs(this_ptr: &UserConfig) -> bool {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_intercept_htlcs;
+ *inner_val
+}
+/// If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over
+/// fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC
+/// intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user.
+///
+/// Setting this to true may break backwards compatibility with LDK versions < 0.0.113.
+///
+/// Default value: false.
+///
+/// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
+/// [`Event::HTLCIntercepted`]: crate::util::events::Event::HTLCIntercepted
+#[no_mangle]
+pub extern "C" fn UserConfig_set_accept_intercept_htlcs(this_ptr: &mut UserConfig, mut val: bool) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_intercept_htlcs = val;
+}
/// Constructs a new UserConfig given each field
#[must_use]
#[no_mangle]
-pub extern "C" fn UserConfig_new(mut channel_handshake_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut channel_handshake_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_config_arg: crate::lightning::util::config::ChannelConfig, mut accept_forwards_to_priv_channels_arg: bool, mut accept_inbound_channels_arg: bool, mut manually_accept_inbound_channels_arg: bool) -> UserConfig {
+pub extern "C" fn UserConfig_new(mut channel_handshake_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut channel_handshake_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_config_arg: crate::lightning::util::config::ChannelConfig, mut accept_forwards_to_priv_channels_arg: bool, mut accept_inbound_channels_arg: bool, mut manually_accept_inbound_channels_arg: bool, mut accept_intercept_htlcs_arg: bool) -> UserConfig {
UserConfig { inner: ObjOps::heap_alloc(nativeUserConfig {
channel_handshake_config: *unsafe { Box::from_raw(channel_handshake_config_arg.take_inner()) },
channel_handshake_limits: *unsafe { Box::from_raw(channel_handshake_limits_arg.take_inner()) },
accept_forwards_to_priv_channels: accept_forwards_to_priv_channels_arg,
accept_inbound_channels: accept_inbound_channels_arg,
manually_accept_inbound_channels: manually_accept_inbound_channels_arg,
+ accept_intercept_htlcs: accept_intercept_htlcs_arg,
}), is_owned: true }
}
impl Clone for UserConfig {