Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@
- `BalanceDetails::spendable_onchain_balance_sats` no longer includes wallet outputs selected
as inputs of a channel funding transaction or splice that has yet to confirm. They remain
part of `total_onchain_balance_sats` until the transaction is seen by a wallet sync. (#1037)
- Splices on zero-conf channels, e.g., with peers in `Config::trusted_peers_0conf` or LSPs
trusted for zero-conf, are no longer zero-conf themselves. Following LDK, a splice now
requires six confirmations before it locks, independent of the channel's own minimum depth.
This also applies to existing channels.
- An LSPS2 service now enforces the `max_client_to_self_delay` agreed upon in the selected
opening fee parameters when opening a JIT channel. If the client's `to_self_delay` exceeds it,
the channel open fails. LDK clients use a `to_self_delay` of 144 blocks by default, so a
service configured with a lower `LSPS2ServiceConfig::max_client_to_self_delay` will fail to
open JIT channels to them.

## Feature and API updates
- `Node::splice_out_max` withdraws the maximum available channel balance to an on-chain address.
Expand Down
30 changes: 15 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ uniffi-default = [
#lightning-macros = { version = "0.2.0" }
#lightning-dns-resolver = { version = "0.3.0" }

lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "d7a980641c6325ddda5072a0f470ef8392676cf5", features = ["std"] }
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "d7a980641c6325ddda5072a0f470ef8392676cf5" }
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "d7a980641c6325ddda5072a0f470ef8392676cf5", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "d7a980641c6325ddda5072a0f470ef8392676cf5" }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "d7a980641c6325ddda5072a0f470ef8392676cf5", features = ["tokio"], optional = true }
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "d7a980641c6325ddda5072a0f470ef8392676cf5" }
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "d7a980641c6325ddda5072a0f470ef8392676cf5" }
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "d7a980641c6325ddda5072a0f470ef8392676cf5", features = ["rest-client", "rpc-client", "tokio"], optional = true }
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "d7a980641c6325ddda5072a0f470ef8392676cf5", optional = true }
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "d7a980641c6325ddda5072a0f470ef8392676cf5", features = ["std"] }
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "d7a980641c6325ddda5072a0f470ef8392676cf5" }
lightning-dns-resolver = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "d7a980641c6325ddda5072a0f470ef8392676cf5", optional = true }
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3ed13ee320a10ca98f1bba919e1886b1fc959758", features = ["std"] }
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3ed13ee320a10ca98f1bba919e1886b1fc959758" }
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3ed13ee320a10ca98f1bba919e1886b1fc959758", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3ed13ee320a10ca98f1bba919e1886b1fc959758" }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3ed13ee320a10ca98f1bba919e1886b1fc959758", features = ["tokio"], optional = true }
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3ed13ee320a10ca98f1bba919e1886b1fc959758" }
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3ed13ee320a10ca98f1bba919e1886b1fc959758" }
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3ed13ee320a10ca98f1bba919e1886b1fc959758", features = ["rest-client", "rpc-client", "tokio"], optional = true }
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3ed13ee320a10ca98f1bba919e1886b1fc959758", optional = true }
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3ed13ee320a10ca98f1bba919e1886b1fc959758", features = ["std"] }
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3ed13ee320a10ca98f1bba919e1886b1fc959758" }
lightning-dns-resolver = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3ed13ee320a10ca98f1bba919e1886b1fc959758", optional = true }

bdk_chain = { version = "0.23.3", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.22.2", default-features = false, features = ["async-https-rustls", "tokio"], optional = true }
Expand Down Expand Up @@ -133,14 +133,14 @@ postgres-native-tls = { version = "0.5", default-features = false, features = ["
vss-client = { package = "vss-client-ng", version = "0.6", optional = true }
prost = { version = "0.11.6", default-features = false, optional = true}
#bitcoin-payment-instructions = { version = "0.6" }
bitcoin-payment-instructions = { git = "https://github.com/benthecarman/bitcoin-payment-instructions", rev = "3dbe11bdf8916639df42476501fb40f87b253e84", optional = true }
bitcoin-payment-instructions = { git = "https://github.com/benthecarman/bitcoin-payment-instructions", rev = "7b082636f8136fbc298c1c0a567245b0df7821d7", optional = true }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "d7a980641c6325ddda5072a0f470ef8392676cf5", features = ["std", "_test_utils"] }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "d7a980641c6325ddda5072a0f470ef8392676cf5", features = ["tokio"] }
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3ed13ee320a10ca98f1bba919e1886b1fc959758", features = ["std", "_test_utils"] }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3ed13ee320a10ca98f1bba919e1886b1fc959758", features = ["tokio"] }
rand = { version = "0.9.2", default-features = false, features = ["std", "thread_rng", "os_rng"] }
proptest = "1.0.0"
regex = "1.5.6"
Expand Down
32 changes: 24 additions & 8 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use lightning::ln::msgs::SocketAddress;
use lightning::routing::gossip::NodeAlias;
use lightning::routing::router::{RouteParameters, RouteParametersConfig};
use lightning::util::config::{
ChannelConfig as LdkChannelConfig, MaxDustHTLCExposure as LdkMaxDustHTLCExposure, UserConfig,
ChannelConfig as LdkChannelConfig, ChannelConfigUpdate,
MaxDustHTLCExposure as LdkMaxDustHTLCExposure, UserConfig,
};

use crate::logger::LogLevel;
Expand Down Expand Up @@ -862,19 +863,34 @@ impl From<LdkChannelConfig> for ChannelConfig {
}
}

impl From<ChannelConfig> for LdkChannelConfig {
/// Only sets the fields we expose, leaving any other settings of a channel's [`LdkChannelConfig`],
/// such as its splice minimum depths, untouched when applied.
impl From<ChannelConfig> for ChannelConfigUpdate {
fn from(value: ChannelConfig) -> Self {
Self {
forwarding_fee_proportional_millionths: value.forwarding_fee_proportional_millionths,
forwarding_fee_base_msat: value.forwarding_fee_base_msat,
cltv_expiry_delta: value.cltv_expiry_delta,
max_dust_htlc_exposure: value.max_dust_htlc_exposure.into(),
force_close_avoidance_max_fee_satoshis: value.force_close_avoidance_max_fee_satoshis,
accept_underpaying_htlcs: value.accept_underpaying_htlcs,
forwarding_fee_proportional_millionths: Some(
value.forwarding_fee_proportional_millionths,
),
forwarding_fee_base_msat: Some(value.forwarding_fee_base_msat),
cltv_expiry_delta: Some(value.cltv_expiry_delta),
max_dust_htlc_exposure_msat: Some(value.max_dust_htlc_exposure.into()),
force_close_avoidance_max_fee_satoshis: Some(
value.force_close_avoidance_max_fee_satoshis,
),
accept_underpaying_htlcs: Some(value.accept_underpaying_htlcs),
..Default::default()
}
}
}

impl From<ChannelConfig> for LdkChannelConfig {
fn from(value: ChannelConfig) -> Self {
let mut config = LdkChannelConfig::default();
config.apply(&value.into());
config
}
}

impl Default for ChannelConfig {
fn default() -> Self {
LdkChannelConfig::default().into()
Expand Down
15 changes: 7 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@ impl Node {

let mut user_config = default_user_config(&self.config);
user_config.channel_handshake_config.announce_for_forwarding = announce_for_forwarding;
user_config.channel_config = (channel_config.unwrap_or_default()).clone().into();
user_config.channel_config.apply(&channel_config.unwrap_or_default().into());

// Unannounced channels rely on LDK's default of 100% inbound HTLC value-in-flight
// to support large initial payments via LSPS2.
Expand Down Expand Up @@ -2397,9 +2397,8 @@ impl Node {
/// with [`Node::splice_out_max`]; the output is not reduced to cover the higher fee.
///
/// A splice of all on-chain funds (see [`Node::splice_in_with_all`]) has no amount to preserve:
/// the bump is paid by adding less to the channel, or, if the pending splice's maximum feerate
/// does not allow that or less than dust would be left to add, the splice is rebuilt from all
/// confirmed funds, including any confirmed since.
/// the bump is paid by adding less to the channel, or, if that would leave less than dust to
/// add, the splice is rebuilt from all confirmed funds, including any confirmed since.
///
/// If `min_fee_rate` is set, it will be used as the minimum feerate for the replacement instead
/// of a feerate estimate retrieved from the configured chain source. As with the estimate, we
Expand Down Expand Up @@ -2466,8 +2465,8 @@ impl Node {
None
},
Ok(contribution) => Some(contribution),
// LDK adjusts a contribution of manually selected inputs only up to its maximum
// feerate and never supplements it by coin selection.
// LDK adjusts a contribution of manually selected inputs only as far as its inputs
// can pay and never supplements it by coin selection.
Err(FundingContributionError::ManuallySelectedInputsInsufficient) => None,
Err(e) => {
log_error!(self.logger, "Failed to RBF channel: {}", e);
Expand Down Expand Up @@ -2667,10 +2666,10 @@ impl Node {
open_channels.iter().find(|c| c.user_channel_id == user_channel_id.0)
{
self.channel_manager
.update_channel_config(
.update_partial_channel_config(
&counterparty_node_id,
&[channel_details.channel_id],
&(channel_config).clone().into(),
&channel_config.into(),
)
.map_err(|_| Error::ChannelConfigUpdateFailed)
} else {
Expand Down
10 changes: 10 additions & 0 deletions src/liquidity/service/lsps2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ where
opening_fee_msat: _,
user_channel_id,
intercept_scid: _,
max_client_to_self_delay,
} => {
if self.liquidity_manager.lsps2_service_handler().is_none() {
log_error!(self.logger, "Failed to handle LSPS2ServiceEvent as LSPS2 liquidity service was not configured.",);
Expand Down Expand Up @@ -524,6 +525,15 @@ where
config.channel_config.forwarding_fee_base_msat = 0;
config.channel_config.forwarding_fee_proportional_millionths = 0;

// Ensure the client's `to_self_delay` doesn't exceed the limit agreed upon in the
// selected opening fee parameters. Events persisted before the limit was carried
// in the event fall back to our currently configured limit.
let max_client_to_self_delay =
max_client_to_self_delay.unwrap_or(service_config.max_client_to_self_delay);
let their_to_self_delay = &mut config.channel_handshake_limits.their_to_self_delay;
*their_to_self_delay =
(*their_to_self_delay as u32).min(max_client_to_self_delay) as u16;

let result = if service_config.disable_client_reserve {
self.channel_manager.create_channel_to_trusted_peer_0reserve(
their_network_key,
Expand Down
Loading
Loading