From 507f968916a19ff861eaaca8090fb09b057d0525 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Wed, 11 Nov 2026 13:38:24 -0600 Subject: [PATCH 1/2] Bump LDK to v0.3.0-rc4 Pin every LDK crate to commit faf1e513 on the 0.3 branch, i.e., the v0.3-rc4 tag plus the backports since, including the fix for the Esplora build of lightning-transaction-sync. LDK now only provides its Electrum sync client when built with the buggy_electrum_sync cfg flag, as the transaction-based Electrum protocol doesn't give the guarantees Lightning needs. We gate our Electrum chain source behind the same flag and drop chain-electrum from the default and uniffi-default features. CI keeps building and testing it by passing the flag. LSPS2 OpenChannel events now carry the client to_self_delay limit agreed upon in the selected opening fee parameters, which the service must enforce itself. We now cap the channel's their_to_self_delay handshake limit accordingly, falling back to our configured limit for events persisted before the field existed. LSPS2 payment_forwarded also takes the forward's inbound HTLCs so replayed events aren't counted twice towards the opening fee. LDK's ChannelConfig gained inbound and outbound splice minimum-depth knobs, which default to six confirmations and no longer follow the channel's own minimum depth. We adopt that default, so splices on zero-conf channels are no longer zero-conf. The test for superseded zero-conf splice rounds, which can no longer occur, is replaced by one covering the new behavior, and the test for a second splice on a zero-conf channel now waits for each splice to confirm. As we don't expose the knobs, our ChannelConfig is applied as a partial update so that it doesn't reset them. LDK now bounds the RBF adjustment of a prior splice contribution by the bump's own maximum feerate rather than the prior round's, so a bump above the prior maximum is paid from the existing inputs where they suffice. The tests relying on such a bump to pull in a new coin now size the first round so its inputs cannot pay the bump. Accepting an inbound channel now requires passing back the OpenChannelRequest's inbound_channel_request_counter. LDK refuses to sign messages that serialize as signed gossip, so Node::sign_message now returns a Result, failing with MessageSigningFailed. Paying a BOLT11 invoice for another network now fails with InvalidNetwork. bitcoin-payment-instructions is moved to a fork commit pinned to the same LDK revision so both resolve to a single copy of LDK. Developed with assistance from Claude Code. --- .github/workflows/postgres-integration.yml | 4 +- .github/workflows/rust.yml | 4 +- CHANGELOG.md | 20 +- Cargo.toml | 35 +- README.md | 2 +- bindings/ldk_node.udl | 2 + src/builder.rs | 17 +- src/chain/mod.rs | 39 ++- src/config.rs | 32 +- src/error.rs | 5 +- src/event.rs | 4 + src/lib.rs | 24 +- src/liquidity/service/lsps2.rs | 18 +- src/payment/bolt11.rs | 7 + src/runtime.rs | 1 + src/tx_broadcaster.rs | 1 + src/wallet/mod.rs | 20 +- tests/common/mod.rs | 10 +- tests/integration_tests_rust.rs | 386 ++++++++++++++------- 19 files changed, 421 insertions(+), 210 deletions(-) diff --git a/.github/workflows/postgres-integration.yml b/.github/workflows/postgres-integration.yml index a3c8e053af..ae8c4823e7 100644 --- a/.github/workflows/postgres-integration.yml +++ b/.github/workflows/postgres-integration.yml @@ -37,8 +37,8 @@ jobs: - name: Check sparse feature sets run: | cargo check --no-default-features --features uniffi,chain-bitcoind,storage-postgres --verbose --color always - cargo test --lib --no-run --no-default-features --features chain-electrum,storage-postgres --verbose --color always - cargo check --test integration_tests_postgres --no-default-features --features chain-electrum,storage-postgres --verbose --color always + RUSTFLAGS="--cfg buggy_electrum_sync" cargo test --lib --no-run --no-default-features --features chain-electrum,storage-postgres --verbose --color always + RUSTFLAGS="--cfg buggy_electrum_sync" cargo check --test integration_tests_postgres --no-default-features --features chain-electrum,storage-postgres --verbose --color always - name: Enable caching for bitcoind id: cache-bitcoind uses: actions/cache@v4 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 750d637f32..7637d9eb68 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -107,11 +107,11 @@ jobs: - name: Test on Rust ${{ matrix.toolchain }} if: "matrix.platform != 'windows-latest'" run: | - RUSTFLAGS="--cfg cycle_tests --cfg tokio_unstable" cargo test + RUSTFLAGS="--cfg cycle_tests --cfg tokio_unstable --cfg buggy_electrum_sync" cargo test --features chain-electrum - name: Test with UniFFI support on Rust ${{ matrix.toolchain }} if: "matrix.platform != 'windows-latest' && matrix.build-uniffi" run: | - RUSTFLAGS="--cfg cycle_tests" cargo test --no-default-features --features uniffi-default + RUSTFLAGS="--cfg cycle_tests --cfg buggy_electrum_sync" cargo test --no-default-features --features uniffi-default,chain-electrum linting: name: Linting diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f1f8d9769..a9ecd76287 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,22 @@ - `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. +- The `chain-electrum` feature is no longer enabled by default, including in `uniffi-default`. + Following LDK, which considers its Electrum syncing unreliable for Lightning use, the Electrum + chain source is now only compiled when building with `RUSTFLAGS="--cfg buggy_electrum_sync"` + in addition to enabling `chain-electrum`. +- `Node::sign_message` now returns a `Result` and fails with `NodeError::MessageSigningFailed` if + the prefixed message would serialize as a signed gossip message, as LDK refuses to sign such + messages. ## Feature and API updates - `Node::splice_out_max` withdraws the maximum available channel balance to an on-chain address. @@ -101,8 +117,8 @@ `Node::splice_in_with_all` without spending the anchor reserve or failing for lack of a change output. The splice now spends the wallet's confirmed UTXOs in full, so a bump is paid by adding less to the channel, and any required anchor reserve is kept as a fixed output back to the - wallet. A bump past the splice's maximum feerate rebuilds it from all confirmed funds, - including coins confirmed since. (#1168) + wallet. If adding less would leave less than dust to add, the bump instead rebuilds the + splice from all confirmed funds, including coins confirmed since. (#1168) - Building a fresh node against a Bitcoin Core RPC or REST chain source that fails to return the current chain tip now aborts with a new `BuildError::ChainTipFetchFailed` variant instead of silently pinning the wallet birthday to genesis, which would have forced a full-history rescan diff --git a/Cargo.toml b/Cargo.toml index 24f5a9ce0e..b84ab7c9ea 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,6 @@ panic = 'abort' # Abort on panic [features] default = [ "chain-esplora", - "chain-electrum", "chain-bitcoind", "storage-sqlite", "storage-filesystem", @@ -45,6 +44,8 @@ chain-esplora = [ "lightning-transaction-sync/esplora-async-https", "lightning-transaction-sync/time", ] +# Requires building with `RUSTFLAGS="--cfg buggy_electrum_sync"`, as LDK only provides Electrum +# syncing behind that flag. Without it, the Electrum chain source is not compiled. chain-electrum = [ "dep:bdk_electrum", "dep:electrum-client", @@ -66,7 +67,6 @@ uniffi = ["dep:uniffi"] uniffi-default = [ "uniffi", "chain-esplora", - "chain-electrum", "storage-sqlite", "storage-vss", "unified-payments", @@ -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 = "faf1e513b8e58acba9cd6c6d18d538d27aee1de6", features = ["std"] } +lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "faf1e513b8e58acba9cd6c6d18d538d27aee1de6" } +lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "faf1e513b8e58acba9cd6c6d18d538d27aee1de6", features = ["std"] } +lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "faf1e513b8e58acba9cd6c6d18d538d27aee1de6" } +lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "faf1e513b8e58acba9cd6c6d18d538d27aee1de6", features = ["tokio"], optional = true } +lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "faf1e513b8e58acba9cd6c6d18d538d27aee1de6" } +lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "faf1e513b8e58acba9cd6c6d18d538d27aee1de6" } +lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "faf1e513b8e58acba9cd6c6d18d538d27aee1de6", features = ["rest-client", "rpc-client", "tokio"], optional = true } +lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "faf1e513b8e58acba9cd6c6d18d538d27aee1de6", optional = true } +lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "faf1e513b8e58acba9cd6c6d18d538d27aee1de6", features = ["std"] } +lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "faf1e513b8e58acba9cd6c6d18d538d27aee1de6" } +lightning-dns-resolver = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "faf1e513b8e58acba9cd6c6d18d538d27aee1de6", 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 } @@ -132,14 +132,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 = "f94a645161c24dcbe09eac5a62925a207701c588", 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 = "faf1e513b8e58acba9cd6c6d18d538d27aee1de6", features = ["std", "_test_utils"] } +lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "faf1e513b8e58acba9cd6c6d18d538d27aee1de6", features = ["tokio"] } rand = { version = "0.9.2", default-features = false, features = ["std", "thread_rng", "os_rng"] } proptest = "1.0.0" regex = "1.5.6" @@ -181,6 +181,7 @@ check-cfg = [ "cfg(cycle_tests)", "cfg(hrn_tests)", "cfg(zero_fee_commitment_tests)", + "cfg(buggy_electrum_sync)", ] [[bench]] diff --git a/README.md b/README.md index 1652541137..377c402e96 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ LDK Node's optional dependencies are grouped by the functionality they provide: | Feature | Functionality | | --- | --- | | `chain-esplora` | Esplora chain source | -| `chain-electrum` | Electrum chain source | +| `chain-electrum` | Electrum chain source; also requires `RUSTFLAGS="--cfg buggy_electrum_sync"` | | `chain-bitcoind` | Bitcoin Core RPC and REST chain source | | `storage-sqlite` | SQLite storage | | `storage-filesystem` | Filesystem storage | diff --git a/bindings/ldk_node.udl b/bindings/ldk_node.udl index 2344451b64..5ea3e8b4a0 100644 --- a/bindings/ldk_node.udl +++ b/bindings/ldk_node.udl @@ -120,6 +120,7 @@ interface Node { sequence list_peers(); sequence list_channels(); NetworkGraph network_graph(); + [Throws=NodeError] string sign_message([ByRef]sequence msg); boolean verify_signature([ByRef]sequence msg, [ByRef]string sig, [ByRef]PublicKey pkey); [Throws=NodeError] @@ -175,6 +176,7 @@ enum NodeError { "WalletOperationTimeout", "PayerProofCreationFailed", "OnchainTxSigningFailed", + "MessageSigningFailed", "TxSyncFailed", "TxSyncTimeout", "GossipUpdateFailed", diff --git a/src/builder.rs b/src/builder.rs index 964684a660..fe1de27843 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -57,12 +57,13 @@ use vss_client::headers::VssHeaderProvider; use crate::chain::ChainSource; #[cfg(feature = "chain-bitcoind")] use crate::config::BitcoindRestClientConfig; +#[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] +use crate::config::ElectrumSyncConfig; use crate::config::{ default_user_config, may_announce_channel, AnnounceError, AsyncPaymentsRole, Config, - ElectrumSyncConfig, EsploraSyncConfig, HRNResolverConfig, TorConfig, - CHANNEL_TX_FACTS_CACHE_CAPACITY, CHANNEL_TX_FACTS_CACHE_WARMUP_COUNT, - DEFAULT_ESPLORA_SERVER_URL, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, PAYMENT_CACHE_CAPACITY, - PAYMENT_CACHE_WARMUP_COUNT, + EsploraSyncConfig, HRNResolverConfig, TorConfig, CHANNEL_TX_FACTS_CACHE_CAPACITY, + CHANNEL_TX_FACTS_CACHE_WARMUP_COUNT, DEFAULT_ESPLORA_SERVER_URL, DEFAULT_LOG_FILENAME, + DEFAULT_LOG_LEVEL, PAYMENT_CACHE_CAPACITY, PAYMENT_CACHE_WARMUP_COUNT, }; use crate::connection::ConnectionManager; use crate::data_store::{KeepAllEntries, KeepLeastRecentlyUsed}; @@ -130,7 +131,7 @@ enum ChainDataSourceConfig { headers: HashMap, sync_config: Option, }, - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] Electrum { server_url: String, sync_config: Option }, #[cfg(feature = "chain-bitcoind")] Bitcoind { @@ -433,7 +434,7 @@ impl NodeBuilder { /// /// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more /// information. - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] pub fn set_chain_source_electrum( &mut self, server_url: String, sync_config: Option, ) -> &mut Self { @@ -1099,7 +1100,7 @@ impl Builder { } } -#[cfg(all(feature = "uniffi", feature = "chain-electrum"))] +#[cfg(all(feature = "uniffi", feature = "chain-electrum", buggy_electrum_sync))] #[uniffi::export] impl Builder { /// Configures the [`Node`] instance to source its chain data from the given Electrum server. @@ -1691,7 +1692,7 @@ fn build_with_store_internal( ) .map_err(|()| BuildError::ChainSourceSetupFailed)? }, - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] Some(ChainDataSourceConfig::Electrum { server_url, sync_config }) => { let sync_config = sync_config.unwrap_or(ElectrumSyncConfig::default()); ChainSource::new_electrum( diff --git a/src/chain/mod.rs b/src/chain/mod.rs index 36325cf3c5..28a16f4f5d 100644 --- a/src/chain/mod.rs +++ b/src/chain/mod.rs @@ -7,7 +7,7 @@ #[cfg(feature = "chain-bitcoind")] pub(crate) mod bitcoind; -#[cfg(feature = "chain-electrum")] +#[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] mod electrum; #[cfg(feature = "chain-esplora")] mod esplora; @@ -25,13 +25,13 @@ use lightning::chain::{BlockLocator, Filter}; #[cfg(feature = "chain-bitcoind")] use crate::chain::bitcoind::{BitcoindChainSource, UtxoSourceClient}; -#[cfg(feature = "chain-electrum")] +#[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] use crate::chain::electrum::ElectrumChainSource; #[cfg(feature = "chain-esplora")] use crate::chain::esplora::EsploraChainSource; #[cfg(feature = "chain-bitcoind")] use crate::config::BitcoindRestClientConfig; -#[cfg(feature = "chain-electrum")] +#[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] use crate::config::ElectrumSyncConfig; #[cfg(feature = "chain-esplora")] use crate::config::EsploraSyncConfig; @@ -157,7 +157,7 @@ pub(crate) struct ChainSource { enum ChainSourceKind { #[cfg(feature = "chain-esplora")] Esplora(EsploraChainSource), - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] Electrum(ElectrumChainSource), #[cfg(feature = "chain-bitcoind")] Bitcoind(BitcoindChainSource), @@ -272,7 +272,7 @@ impl ChainSource { Ok((Self { kind, registered_txids, tx_broadcaster, logger }, None)) } - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] pub(crate) fn new_electrum( server_url: String, sync_config: ElectrumSyncConfig, fee_estimator: Arc, tx_broadcaster: Arc, @@ -342,9 +342,10 @@ impl ChainSource { (Self { kind, registered_txids, tx_broadcaster, logger }, best_block) } + #[cfg_attr(not(all(feature = "chain-electrum", buggy_electrum_sync)), allow(unused_variables))] pub(crate) fn start(&self, runtime: Arc) -> Result<(), Error> { match &self.kind { - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] ChainSourceKind::Electrum(electrum_chain_source) => electrum_chain_source.start(runtime)?, _ => { // Nothing to do for other chain sources. @@ -355,7 +356,7 @@ impl ChainSource { pub(crate) fn stop(&self) { match &self.kind { - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] ChainSourceKind::Electrum(electrum_chain_source) => electrum_chain_source.stop(), _ => { // Nothing to do for other chain sources. @@ -365,7 +366,7 @@ impl ChainSource { pub(crate) fn begin_shutdown(&self) { match &self.kind { - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] ChainSourceKind::Electrum(electrum_chain_source) => electrum_chain_source.begin_shutdown(), _ => { // Other chain sources don't leave synchronous callbacks running after their @@ -392,7 +393,7 @@ impl ChainSource { match &self.kind { #[cfg(feature = "chain-esplora")] ChainSourceKind::Esplora(_) => true, - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] ChainSourceKind::Electrum { .. } => true, #[cfg(feature = "chain-bitcoind")] ChainSourceKind::Bitcoind { .. } => false, @@ -442,7 +443,7 @@ impl ChainSource { ) .await }, - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] ChainSourceKind::Electrum(source) => { source .sync_lightning_wallet( @@ -488,7 +489,7 @@ impl ChainSource { return; } }, - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] ChainSourceKind::Electrum(electrum_chain_source) => { if let Some(background_sync_config) = electrum_chain_source.sync_config.background_sync_config.as_ref() @@ -600,7 +601,7 @@ impl ChainSource { ChainSourceKind::Esplora(esplora_chain_source) => { esplora_chain_source.sync_onchain_wallet(onchain_wallet).await }, - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] ChainSourceKind::Electrum(electrum_chain_source) => { electrum_chain_source.sync_onchain_wallet(onchain_wallet).await }, @@ -632,7 +633,7 @@ impl ChainSource { ) .await }, - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] ChainSourceKind::Electrum(electrum_chain_source) => { electrum_chain_source .sync_lightning_wallet( @@ -673,7 +674,7 @@ impl ChainSource { // `sync_onchain_wallet` and `sync_lightning_wallet`. So nothing to do here. unreachable!("Listeners will be synced via transction-based syncing") }, - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] ChainSourceKind::Electrum { .. } => { // In Electrum mode we sync lightning and onchain wallets via // `sync_onchain_wallet` and `sync_lightning_wallet`. So nothing to do here. @@ -700,7 +701,7 @@ impl ChainSource { ChainSourceKind::Esplora(esplora_chain_source) => { esplora_chain_source.update_fee_rate_estimates().await }, - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] ChainSourceKind::Electrum(electrum_chain_source) => { electrum_chain_source.update_fee_rate_estimates().await }, @@ -723,7 +724,7 @@ impl ChainSource { ChainSourceKind::Esplora(esplora_chain_source) => { esplora_chain_source.validate_zero_fee_commitments_support().await }, - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] ChainSourceKind::Electrum(electrum_chain_source) => { electrum_chain_source.validate_zero_fee_commitments_support().await }, @@ -743,7 +744,7 @@ impl ChainSource { ChainSourceKind::Esplora(esplora_chain_source) => { esplora_chain_source.process_transaction_broadcast(package).await }, - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] ChainSourceKind::Electrum(electrum_chain_source) => { electrum_chain_source.process_transaction_broadcast(package).await }, @@ -784,7 +785,7 @@ impl Filter for ChainSource { ChainSourceKind::Esplora(esplora_chain_source) => { esplora_chain_source.register_tx(txid, script_pubkey) }, - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] ChainSourceKind::Electrum(electrum_chain_source) => { electrum_chain_source.register_tx(txid, script_pubkey) }, @@ -796,7 +797,7 @@ impl Filter for ChainSource { match &self.kind { #[cfg(feature = "chain-esplora")] ChainSourceKind::Esplora(esplora_chain_source) => esplora_chain_source.register_output(output), - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] ChainSourceKind::Electrum(electrum_chain_source) => { electrum_chain_source.register_output(output) }, diff --git a/src/config.rs b/src/config.rs index b7a63b94f1..0488342336 100644 --- a/src/config.rs +++ b/src/config.rs @@ -19,7 +19,8 @@ use lightning::ln::outbound_payment::Retry; 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; @@ -882,19 +883,34 @@ impl From for ChannelConfig { } } -impl From 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 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 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() diff --git a/src/error.rs b/src/error.rs index 202cb38878..5ff0045dc4 100644 --- a/src/error.rs +++ b/src/error.rs @@ -60,6 +60,8 @@ pub enum Error { PayerProofCreationFailed, /// A signing operation for transaction failed. OnchainTxSigningFailed, + /// Signing a message failed. + MessageSigningFailed, /// A transaction sync operation failed. TxSyncFailed, /// A transaction sync operation timed out. @@ -183,6 +185,7 @@ impl fmt::Display for Error { Self::WalletOperationTimeout => write!(f, "A wallet operation timed out."), Self::PayerProofCreationFailed => write!(f, "Failed to create payer proof."), Self::OnchainTxSigningFailed => write!(f, "Failed to sign given transaction."), + Self::MessageSigningFailed => write!(f, "Failed to sign given message."), Self::TxSyncFailed => write!(f, "Failed to sync transactions."), Self::TxSyncTimeout => write!(f, "Syncing transactions timed out."), Self::GossipUpdateFailed => write!(f, "Failed to update gossip data."), @@ -287,7 +290,7 @@ impl From for Error { } } -#[cfg(any(feature = "chain-esplora", feature = "chain-electrum"))] +#[cfg(any(feature = "chain-esplora", all(feature = "chain-electrum", buggy_electrum_sync)))] impl From for Error { fn from(_e: lightning_transaction_sync::TxSyncError) -> Self { Self::TxSyncFailed diff --git a/src/event.rs b/src/event.rs index ed6a8e738f..0b3f466f70 100644 --- a/src/event.rs +++ b/src/event.rs @@ -2023,6 +2023,7 @@ where LdkEvent::OpenChannelRequest { temporary_channel_id, counterparty_node_id, + inbound_channel_request_counter, funding_satoshis, channel_type, channel_negotiation_type: _, @@ -2123,6 +2124,7 @@ where self.channel_manager.accept_inbound_channel_from_trusted_peer( &temporary_channel_id, &counterparty_node_id, + inbound_channel_request_counter, user_channel_id, TrustedChannelFeatures::ZeroConf, channel_override_config, @@ -2131,6 +2133,7 @@ where self.channel_manager.accept_inbound_channel( &temporary_channel_id, &counterparty_node_id, + inbound_channel_request_counter, user_channel_id, channel_override_config, ) @@ -2249,6 +2252,7 @@ where .handle_payment_forwarded( Some(next_htlc.channel_id), skimmed_fee_msat.unwrap_or(0), + &prev_htlcs, ) .await; } diff --git a/src/lib.rs b/src/lib.rs index 26f04298c8..cbdfeb4dd8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,7 +83,7 @@ #[cfg(not(any( feature = "chain-esplora", - feature = "chain-electrum", + all(feature = "chain-electrum", buggy_electrum_sync), feature = "chain-bitcoind" )))] compile_error!("at least one chain source feature must be enabled"); @@ -1527,7 +1527,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. @@ -2507,9 +2507,8 @@ impl Node { /// [`NodeError::ChannelSplicingFailed`]. /// /// 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 @@ -2580,8 +2579,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); @@ -2789,10 +2788,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 { @@ -2986,8 +2985,11 @@ impl Node { /// can be sure that the signature was generated by the caller. /// Signatures are EC recoverable, meaning that given the message and the /// signature the `PublicKey` of the signer can be extracted. - pub fn sign_message(&self, msg: &[u8]) -> String { - self.keys_manager.sign_message(msg) + /// + /// Returns [`Error::MessageSigningFailed`] if the prefixed message would serialize as a signed + /// gossip message, as the signature could otherwise be replayed as a forged gossip signature. + pub fn sign_message(&self, msg: &[u8]) -> Result { + self.keys_manager.sign_message(msg).map_err(|()| Error::MessageSigningFailed) } /// Verifies that the given ECDSA signature was created for the given message with the diff --git a/src/liquidity/service/lsps2.rs b/src/liquidity/service/lsps2.rs index ce0acc79ee..49749b6906 100644 --- a/src/liquidity/service/lsps2.rs +++ b/src/liquidity/service/lsps2.rs @@ -11,7 +11,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH}; use bitcoin::secp256k1::PublicKey; use bitcoin::Transaction; -use lightning::events::HTLCHandlingFailureType; +use lightning::events::{HTLCHandlingFailureType, InboundHTLCLocator}; use lightning::ln::channelmanager::InterceptId; use lightning::ln::types::ChannelId; use lightning::sign::EntropySource; @@ -245,11 +245,13 @@ where pub(crate) async fn handle_payment_forwarded( &self, next_channel_id: Option, skimmed_fee_msat: u64, + prev_htlcs: &[InboundHTLCLocator], ) { if let Some(next_channel_id) = next_channel_id { if let Some(lsps2_service_handler) = self.liquidity_manager.lsps2_service_handler() { - if let Err(e) = - lsps2_service_handler.payment_forwarded(next_channel_id, skimmed_fee_msat).await + if let Err(e) = lsps2_service_handler + .payment_forwarded(next_channel_id, skimmed_fee_msat, prev_htlcs) + .await { log_error!( self.logger, @@ -456,6 +458,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.",); @@ -579,6 +582,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, diff --git a/src/payment/bolt11.rs b/src/payment/bolt11.rs index d9ef1fdd32..da1a69155a 100644 --- a/src/payment/bolt11.rs +++ b/src/payment/bolt11.rs @@ -225,6 +225,13 @@ impl Bolt11Payment { log_error!(self.logger, "{}", invalid_amount_log); return Err(Error::InvalidInvoice); }, + Err(Bolt11PaymentError::UnsupportedChain) => { + log_error!( + self.logger, + "Failed to send payment: invoice is for a different network" + ); + return Err(Error::InvalidNetwork); + }, Err(Bolt11PaymentError::SendingFailed(e)) => { log_error!(self.logger, "Failed to send payment: {:?}", e); match e { diff --git a/src/runtime.rs b/src/runtime.rs index 8f9e94ccf3..5e4bd24f35 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -166,6 +166,7 @@ impl Runtime { *background_processor_task = Some(handle); } + #[cfg_attr(not(all(feature = "chain-electrum", buggy_electrum_sync)), allow(dead_code))] pub fn spawn_blocking(&self, func: F) -> JoinHandle where F: FnOnce() -> R + Send + 'static, diff --git a/src/tx_broadcaster.rs b/src/tx_broadcaster.rs index f544cd13bc..e839811c75 100644 --- a/src/tx_broadcaster.rs +++ b/src/tx_broadcaster.rs @@ -103,6 +103,7 @@ impl SortedTransactions { SortedTransactions(txs) } + #[cfg_attr(not(all(feature = "chain-electrum", buggy_electrum_sync)), allow(dead_code))] pub(crate) fn into_inner(self) -> Vec { self.0 } diff --git a/src/wallet/mod.rs b/src/wallet/mod.rs index 58036e60cf..71f8c0a232 100644 --- a/src/wallet/mod.rs +++ b/src/wallet/mod.rs @@ -502,6 +502,7 @@ impl Wallet { self.inner.lock().expect("lock").start_sync_with_revealed_spks().build() } + #[cfg_attr(not(all(feature = "chain-electrum", buggy_electrum_sync)), allow(dead_code))] pub(crate) fn get_cached_txs(&self) -> Vec> { self.inner.lock().expect("lock").tx_graph().full_txs().map(|tx_node| tx_node.tx).collect() } @@ -4766,7 +4767,7 @@ impl WalletKeysManager { Self { inner, wallet, logger } } - pub fn sign_message(&self, msg: &[u8]) -> String { + pub fn sign_message(&self, msg: &[u8]) -> Result { message_signing::sign(msg, &self.inner.get_node_secret_key()) } @@ -4927,7 +4928,10 @@ fn ldk_to_bdk_satisfaction_weight(ldk_satisfaction_weight: u64) -> Weight { ) } -#[cfg(all(test, any(feature = "chain-esplora", feature = "chain-electrum")))] +#[cfg(all( + test, + any(feature = "chain-esplora", all(feature = "chain-electrum", buggy_electrum_sync)) +))] mod tests { use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; @@ -4941,7 +4945,11 @@ mod tests { use lightning::util::persist::{KVStore, PageToken, PaginatedKVStore, PaginatedListResponse}; use super::*; - #[cfg(all(not(feature = "chain-esplora"), feature = "chain-electrum"))] + #[cfg(all( + not(feature = "chain-esplora"), + feature = "chain-electrum", + buggy_electrum_sync + ))] use crate::config::ElectrumSyncConfig; #[cfg(feature = "chain-esplora")] use crate::config::EsploraSyncConfig; @@ -5290,7 +5298,11 @@ mod tests { node_metrics, ) .unwrap(); - #[cfg(all(not(feature = "chain-esplora"), feature = "chain-electrum"))] + #[cfg(all( + not(feature = "chain-esplora"), + feature = "chain-electrum", + buggy_electrum_sync + ))] let (chain_source, _) = ChainSource::new_electrum( "tcp://localhost:1".to_string(), ElectrumSyncConfig::default(), diff --git a/tests/common/mod.rs b/tests/common/mod.rs index e733806b93..fe2d92d3ee 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -39,7 +39,7 @@ use electrsd::corepc_node::{Client as BitcoindClient, Node as BitcoinD}; use electrsd::electrum_client::ElectrumApi; use electrsd::{corepc_node, ElectrsD}; use ldk_node::bip39::{Mnemonic, WordCount}; -#[cfg(feature = "chain-electrum")] +#[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] use ldk_node::config::ElectrumSyncConfig; #[cfg(feature = "chain-esplora")] use ldk_node::config::EsploraSyncConfig; @@ -390,7 +390,7 @@ pub(crate) fn random_chain_source<'a>( let mut sources = Vec::new(); #[cfg(feature = "chain-esplora")] sources.push("ESPLORA".to_string()); - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] sources.push("ELECTRUM".to_string()); #[cfg(feature = "chain-bitcoind")] { @@ -406,7 +406,7 @@ pub(crate) fn random_chain_source<'a>( println!("Randomly setting up Esplora chain syncing..."); TestChainSource::Esplora(electrsd) }, - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] "ELECTRUM" => { println!("Randomly setting up Electrum chain syncing..."); TestChainSource::Electrum(electrsd) @@ -661,7 +661,7 @@ async fn settle_force_close_balance( pub(crate) enum TestChainSource<'a> { #[cfg(feature = "chain-esplora")] Esplora(&'a ElectrsD), - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] Electrum(&'a ElectrsD), #[cfg(feature = "chain-bitcoind")] BitcoindRpcSync(&'a BitcoinD), @@ -752,7 +752,7 @@ pub(crate) fn configure_chain_source( } builder.set_chain_source_esplora(esplora_url.clone(), Some(sync_config)); }, - #[cfg(feature = "chain-electrum")] + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] TestChainSource::Electrum(electrsd) => { let electrum_url = format!("tcp://{}", electrsd.electrum_url); let mut sync_config = ElectrumSyncConfig::default(); diff --git a/tests/integration_tests_rust.rs b/tests/integration_tests_rust.rs index c307d02b4e..625508093e 100644 --- a/tests/integration_tests_rust.rs +++ b/tests/integration_tests_rust.rs @@ -7,6 +7,12 @@ mod common; +#[cfg(all( + feature = "chain-esplora", + feature = "chain-electrum", + buggy_electrum_sync, + feature = "chain-bitcoind" +))] use std::collections::HashSet; use std::future::Future; use std::str::FromStr; @@ -19,23 +25,37 @@ use bitcoin::hashes::hex::FromHex; use bitcoin::hashes::sha256::Hash as Sha256Hash; use bitcoin::hashes::Hash; use bitcoin::hex::DisplayHex; -use bitcoin::{Address, Amount, FeeRate, ScriptBuf, Transaction, Txid}; +#[cfg(all( + feature = "chain-esplora", + feature = "chain-electrum", + buggy_electrum_sync, + feature = "chain-bitcoind" +))] +use bitcoin::ScriptBuf; +use bitcoin::{Address, Amount, FeeRate, Transaction, Txid}; use common::logging::{ init_log_logger, validate_log_entry, CollectingLogWriter, MarkerLogWriter, MultiNodeLogger, TestLogWriter, }; +#[cfg(all( + feature = "chain-esplora", + feature = "chain-electrum", + buggy_electrum_sync, + feature = "chain-bitcoind" +))] +use common::{bump_fee_and_broadcast, prepare_rbf}; use common::{ - bump_fee_and_broadcast, configure_chain_source, distribute_funds_unconfirmed, - do_channel_full_cycle, expect_channel_pending_event, expect_channel_ready_event, - expect_channel_ready_events, expect_event, expect_payment_claimable_event, - expect_payment_received_event, expect_payment_successful_event, expect_splice_negotiated_event, - generate_blocks_and_wait, generate_listening_addresses, invalidate_blocks, open_channel, - open_channel_no_wait, open_channel_push_amt, open_channel_with_all, - premine_and_distribute_funds, premine_blocks, prepare_rbf, random_chain_source, random_config, - setup_bitcoind_and_electrsd, setup_bitcoind_and_electrsd_for_splice_rbf, setup_builder, - setup_node, setup_node_with_store, setup_two_nodes, splice_in_with_all, wait_for_block, - wait_for_channel_ready_to_send, wait_for_outpoint_spend, wait_for_tx, InMemoryStore, - NodePaymentExt, TestChainSource, TestConfig, TestNode, TestStoreType, TestSyncStore, + configure_chain_source, distribute_funds_unconfirmed, do_channel_full_cycle, + expect_channel_pending_event, expect_channel_ready_event, expect_channel_ready_events, + expect_event, expect_payment_claimable_event, expect_payment_received_event, + expect_payment_successful_event, expect_splice_negotiated_event, generate_blocks_and_wait, + generate_listening_addresses, invalidate_blocks, open_channel, open_channel_no_wait, + open_channel_push_amt, open_channel_with_all, premine_and_distribute_funds, premine_blocks, + random_chain_source, random_config, setup_bitcoind_and_electrsd, + setup_bitcoind_and_electrsd_for_splice_rbf, setup_builder, setup_node, setup_node_with_store, + setup_two_nodes, splice_in_with_all, wait_for_block, wait_for_channel_ready_to_send, + wait_for_outpoint_spend, wait_for_tx, InMemoryStore, NodePaymentExt, TestChainSource, + TestConfig, TestNode, TestStoreType, TestSyncStore, }; use electrsd::corepc_node::Node as BitcoinD; use electrsd::electrum_client::ElectrumApi; @@ -1971,7 +1991,7 @@ async fn startup_syncs_lightning_wallet_esplora() { .await; } -#[cfg(feature = "chain-electrum")] +#[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn startup_syncs_lightning_wallet_electrum() { let (bitcoind, electrsd) = setup_bitcoind_and_electrsd(); @@ -1983,7 +2003,7 @@ async fn startup_syncs_lightning_wallet_electrum() { .await; } -#[cfg(any(feature = "chain-esplora", feature = "chain-electrum"))] +#[cfg(any(feature = "chain-esplora", all(feature = "chain-electrum", buggy_electrum_sync)))] async fn do_test_startup_syncs_lightning_wallet( chain_source: TestChainSource<'_>, bitcoind: &BitcoinD, electrsd: &ElectrsD, ) { @@ -2164,6 +2184,7 @@ async fn failed_start_winds_down_background_tasks() { // on the next `start`, leaving the node blind to confirmations and spends of, e.g., its funding // outputs. So here we assert the chain source replays its registrations across a `stop`/`start` // cycle. +#[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn electrum_registrations_survive_chain_source_restart() { let (bitcoind, electrsd) = setup_bitcoind_and_electrsd(); @@ -2732,6 +2753,7 @@ async fn onchain_wallet_full_scan_stop_gap_recovers_far_esplora_and_electrum_fun &electrsd, ) .await; + #[cfg(all(feature = "chain-electrum", buggy_electrum_sync))] do_onchain_wallet_full_scan_stop_gap_recovers_far_funds( TestChainSource::Electrum(&electrsd), &bitcoind, @@ -2981,13 +3003,23 @@ async fn build_aborts_on_first_startup_bitcoind_tip_fetch_failure() { } } -#[cfg(all(feature = "chain-esplora", feature = "chain-electrum", feature = "chain-bitcoind"))] +#[cfg(all( + feature = "chain-esplora", + feature = "chain-electrum", + buggy_electrum_sync, + feature = "chain-bitcoind" +))] #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_rbf_via_mempool() { run_rbf_test(false).await; } -#[cfg(all(feature = "chain-esplora", feature = "chain-electrum", feature = "chain-bitcoind"))] +#[cfg(all( + feature = "chain-esplora", + feature = "chain-electrum", + buggy_electrum_sync, + feature = "chain-bitcoind" +))] #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_rbf_via_direct_block_insertion() { run_rbf_test(true).await; @@ -2996,7 +3028,12 @@ async fn test_rbf_via_direct_block_insertion() { // `is_insert_block`: // - `true`: transaction is mined immediately (no mempool), testing confirmed-Tx handling. // - `false`: transaction stays in mempool until confirmation, testing unconfirmed-Tx handling. -#[cfg(all(feature = "chain-esplora", feature = "chain-electrum", feature = "chain-bitcoind"))] +#[cfg(all( + feature = "chain-esplora", + feature = "chain-electrum", + buggy_electrum_sync, + feature = "chain-bitcoind" +))] async fn run_rbf_test(is_insert_block: bool) { let (bitcoind, electrsd) = setup_bitcoind_and_electrsd(); let chain_source_bitcoind = TestChainSource::BitcoindRpcSync(&bitcoind); @@ -3128,7 +3165,7 @@ async fn sign_verify_msg() { // Tests arbitrary message signing and later verification let msg = "OK computer".as_bytes(); - let sig = node.sign_message(msg); + let sig = node.sign_message(msg).unwrap(); let pkey = node.node_id(); assert!(node.verify_signature(msg, sig.as_str(), &pkey)); } @@ -3552,9 +3589,10 @@ async fn splice_channel() { ); } -/// Two splices of this node in flight on a zero-conf channel — the second submitted right after -/// the first locked — are two payments: the second splice's round is recorded under an id of its -/// own rather than under the first splice's record. +/// Two splices of this node on a zero-conf channel — the second submitted right after the first +/// locked — are two payments: the second splice's round is recorded under an id of its own rather +/// than under the first splice's record. The splices themselves are not zero-conf: each locks +/// once it reaches the default splice minimum depth. /// /// Pinned to Esplora, as the sibling below is: both wait for a record of a splice round that is /// still unconfirmed, and wallet sync creates it from what the wallet has seen. A bitcoind chain @@ -3563,7 +3601,7 @@ async fn splice_channel() { /// it confirms. #[cfg(feature = "chain-esplora")] #[tokio::test(flavor = "multi_thread", worker_threads = 1)] -async fn zero_conf_queued_splice_is_recorded_as_its_own_payment() { +async fn zero_conf_channel_second_splice_is_recorded_as_its_own_payment() { let (bitcoind, electrsd) = setup_bitcoind_and_electrsd(); let chain_source = TestChainSource::Esplora(&electrsd); @@ -3572,7 +3610,7 @@ async fn zero_conf_queued_splice_is_recorded_as_its_own_payment() { config_b.node_config.trusted_peers_0conf.push(node_a.node_id()); let node_b = setup_node(&chain_source, config_b); - // Two coins: the second splice-in below cannot spend the first one's unconfirmed change. + // Two coins, one for each splice-in. let address_a = node_a.onchain_payment().new_address().unwrap(); let second_address_a = node_a.onchain_payment().new_address().unwrap(); premine_and_distribute_funds( @@ -3594,14 +3632,21 @@ async fn zero_conf_queued_splice_is_recorded_as_its_own_payment() { node_a.splice_in(&user_channel_id_a, node_b.node_id(), 1_000_000, None).unwrap(); let first = expect_splice_negotiated_event!(node_a, node_b.node_id()); wait_for_classified_funding_payment(&node_a, first.txid).await; - // The zero-conf splice locks without confirmations, re-signaled as `ChannelReady`. + // The splice locks once confirmed, re-signaled as `ChannelReady`. + wait_for_tx(&electrsd.client, first.txid).await; + generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 6).await; + node_a.sync_wallets().unwrap(); + node_b.sync_wallets().unwrap(); expect_channel_ready_event!(node_a, node_b.node_id()); expect_channel_ready_event!(node_b, node_a.node_id()); - node_a.sync_wallets().unwrap(); node_a.splice_in(&user_channel_id_a, node_b.node_id(), 1_000_000, None).unwrap(); let second = expect_splice_negotiated_event!(node_a, node_b.node_id()); wait_for_classified_funding_payment(&node_a, second.txid).await; + wait_for_tx(&electrsd.client, second.txid).await; + generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 6).await; + node_a.sync_wallets().unwrap(); + node_b.sync_wallets().unwrap(); expect_channel_ready_event!(node_a, node_b.node_id()); expect_channel_ready_event!(node_b, node_a.node_id()); @@ -4686,33 +4731,55 @@ async fn run_splice_in_with_all_bump_fee_test(per_channel_reserve_sats: Option 0); + let balances = node_b.list_balances(); + assert_eq!(balances.total_onchain_balance_sats, first_coin_amount_sat); + assert_eq!(balances.total_anchor_channels_reserve_sats, anchor_reserve_sats); - // Well above the regtest estimate, so the bump below exceeds 1.5 times this feerate without - // the estimate having a say. - let fee_rate = FeeRate::from_sat_per_kwu(1_000); node_b.splice_in_with_all(&user_channel_id_b, node_a.node_id(), Some(fee_rate.into())).unwrap(); let original_txo = expect_splice_negotiated_event!(node_b, node_a.node_id()); @@ -4761,17 +4826,12 @@ async fn splice_in_with_all_bump_fee_above_max_feerate_adds_new_coins() { let original_fee_msat = original.fee_paid_msat.expect("splice payment has a fee"); assert_eq!( original_amount_msat + original_fee_msat, - (premine_amount_sat - anchor_reserve_sats) * 1000, + (first_coin_amount_sat - anchor_reserve_sats) * 1000, ); - // Above the first round's maximum feerate. - // TODO: Once the LDK pin includes - // https://git.rust-bitcoin.org/lightningdevkit/rust-lightning/pulls/5297, the adjustment is - // bounded by the bump's own maximum and succeeds in place, so the bump keeps the first round's - // inputs and the coin assertion below fails. Make the first round's inputs unable to cover the - // bump's fee instead, sized as in `splice_in_with_all_bump_fee_leaving_dust_fails`, so the - // rebuild is still what adds the coin. - let bump_fee_rate = FeeRate::from_sat_per_kwu(2_000); + // At the pending splice's maximum feerate, paying the bump from the same inputs would leave + // less than dust to add to the channel. + let bump_fee_rate = FeeRate::from_sat_per_kwu(3_000); node_b .bump_channel_funding_fee(&user_channel_id_b, node_a.node_id(), Some(bump_fee_rate.into())) .unwrap(); @@ -4797,7 +4857,7 @@ async fn splice_in_with_all_bump_fee_above_max_feerate_adds_new_coins() { assert!(bumped_amount_msat > original_amount_msat, "the new coin was not added"); assert_eq!( bumped_amount_msat + bumped_fee_msat, - (premine_amount_sat + coin_amount_sat - anchor_reserve_sats) * 1000, + (first_coin_amount_sat + coin_amount_sat - anchor_reserve_sats) * 1000, ); generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 6).await; @@ -5442,9 +5502,6 @@ const RECLAIMED_ADDRESSES: &str = "Reclaiming unused wallet state from channel"; /// Unlike [`CLOSED_CHANNEL_PAYMENT_RESOLVED`], logged whatever was found, so also when no payment /// of the channel is left to resolve. const CLOSED_CHANNEL_ROUNDS_RESOLVED: &str = "round(s) its monitor watches"; -/// Logged by a node as it records that LDK promoted a splice round of ours to the channel's -/// funding. -const ROUND_LOCKED: &str = "locked as the funding of channel"; /// A splice round this node signed keeps its place in the channel's recorded splice history when /// the channel closes before the counterparty's `tx_signatures` arrive, if the channel's monitor @@ -5841,20 +5898,17 @@ async fn signed_splice_round_the_monitor_does_not_watch_is_dropped_at_close() { node_b.stop().unwrap(); } -/// A zero-conf splice round of ours stays recorded when the channel closes after a later splice -/// built on it. LDK promoted the round to the funding as `splice_locked` was exchanged, before its -/// transaction confirmed, and moved on again as the later splice locked, so at the close neither -/// the channel manager lists the round nor the monitor watches it — although it can still confirm, -/// the later round and the commitment transaction both descending from it. Node A splices into its -/// zero-conf channel with node B, then splices out of it, and force-closes before either round -/// confirms; the first round's payment is kept, and both graduate once the rounds confirm. Pinned -/// to Esplora so the wallet syncs only on demand. +/// Splices on a zero-conf channel are not zero-conf themselves: LDK requires the channel's +/// `inbound_splice_min_depth` and `outbound_splice_min_depth`, which default to six, independent of +/// the channel's own minimum depth. Node B accepts node A's channel as zero-conf, yet node A's +/// splice only locks once it has six confirmations. Pinned to Esplora so the wallet syncs only on +/// demand. #[cfg(feature = "chain-esplora")] #[tokio::test(flavor = "multi_thread", worker_threads = 1)] -async fn superseded_zero_conf_splice_round_keeps_its_payment_at_close() { +async fn splice_on_zero_conf_channel_requires_confirmations() { let (bitcoind, electrsd) = setup_bitcoind_and_electrsd(); let chain_source = TestChainSource::Esplora(&electrsd); - let (node_a, logs_a) = setup_logged_node(&chain_source, random_config()); + let node_a = setup_node(&chain_source, random_config()); let mut config_b = random_config(); config_b.node_config.trusted_peers_0conf.push(node_a.node_id()); let node_b = setup_node(&chain_source, config_b); @@ -5869,57 +5923,32 @@ async fn superseded_zero_conf_splice_round_keeps_its_payment_at_close() { .await; node_a.sync_wallets().unwrap(); + // The channel itself is zero-conf, so it is ready before its funding confirms. open_channel(&node_a, &node_b, 2_000_000, false, &electrsd).await; let user_channel_id_a = expect_channel_ready_event!(node_a, node_b.node_id()); expect_channel_ready_event!(node_b, node_a.node_id()); - // Confirm the original funding so the splices below are the only unconfirmed rounds and node - // A's change from the open is spendable for the splice-in. generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 6).await; node_a.sync_wallets().unwrap(); node_b.sync_wallets().unwrap(); node_a.splice_in(&user_channel_id_a, node_b.node_id(), 1_000_000, None).unwrap(); - let first = expect_splice_negotiated_event!(node_a, node_b.node_id()); - wait_for_classified_funding_payment(&node_a, first.txid).await; - // The zero-conf splice locks without confirmations, re-signaled as `ChannelReady`, and node A - // records the promotion as it handles it. - expect_channel_ready_event!(node_a, node_b.node_id()); - expect_channel_ready_event!(node_b, node_a.node_id()); - assert_eq!(logs_a.count(ROUND_LOCKED), 1, "the promotion of the first round was not recorded"); + let splice = expect_splice_negotiated_event!(node_a, node_b.node_id()); + wait_for_classified_funding_payment(&node_a, splice.txid).await; + wait_for_tx(&electrsd.client, splice.txid).await; - let address = node_a.onchain_payment().new_address().unwrap(); - node_a.splice_out(&user_channel_id_a, node_b.node_id(), &address, 500_000, None).unwrap(); - let second = expect_splice_negotiated_event!(node_a, node_b.node_id()); - wait_for_classified_funding_payment(&node_a, second.txid).await; - expect_channel_ready_event!(node_a, node_b.node_id()); - expect_channel_ready_event!(node_b, node_a.node_id()); - assert_eq!(logs_a.count(ROUND_LOCKED), 2, "the promotion of the second round was not recorded"); - assert_eq!(funding_payment(&node_a, first.txid).status, PaymentStatus::Pending); - assert_eq!(funding_payment(&node_a, second.txid).status, PaymentStatus::Pending); - - node_a.force_close_channel(&user_channel_id_a, node_b.node_id(), None).unwrap(); - expect_event!(node_a, ChannelClosed); - assert!( - logs_a.wait_for_count(CLOSED_CHANNEL_PAYMENT_RESOLVED, 2).await, - "the close did not resolve both funding payments" - ); - assert!(!logs_a.contains(NO_ROUND_CAN_CONFIRM), "the superseded round's payment was failed"); - assert_eq!(funding_payment(&node_a, first.txid).status, PaymentStatus::Pending); - assert_eq!(funding_payment(&node_a, second.txid).status, PaymentStatus::Pending); + // One confirmation short of the default splice minimum depth, the splice does not lock. + generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 5).await; + node_a.sync_wallets().unwrap(); + node_b.sync_wallets().unwrap(); + tokio::time::sleep(std::time::Duration::from_secs(2)).await; + assert_eq!(node_a.next_event(), None); + assert_eq!(node_b.next_event(), None); - // Both rounds confirm, the second spending the first, and the payments graduate. Six blocks are - // the exact minimum, so wait for the rounds to reach the chain source before mining them. - wait_for_tx(&electrsd.client, second.txid).await; - generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 6).await; + generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 1).await; node_a.sync_wallets().unwrap(); - for txid in [first.txid, second.txid] { - let payment = funding_payment(&node_a, txid); - assert_eq!(payment.status, PaymentStatus::Succeeded, "round {} did not graduate", txid); - assert!(matches!( - payment.kind, - PaymentKind::Onchain { status: ConfirmationStatus::Confirmed { .. }, .. } - )); - } + node_b.sync_wallets().unwrap(); + expect_channel_ready_event!(node_a, node_b.node_id()); + expect_channel_ready_event!(node_b, node_a.node_id()); node_a.stop().unwrap(); node_b.stop().unwrap(); @@ -5931,20 +5960,20 @@ async fn superseded_zero_conf_splice_round_keeps_its_payment_at_close() { /// pass and on peer traffic, and the monitor's own events are handled right after the manager's. /// Each event then finds the channel listed and, both rounds having been broadcast, only returns /// the round's contribution, leaving the payment to the `ChannelClosed` that follows, which fails -/// it, no round of ours being watched anymore. Node A splices into its channel with node B and, -/// once another coin has confirmed, bumps the round's fee past its maximum feerate, so the bump is -/// rebuilt with that coin and the two rounds are contributions of their own; node B closes while -/// node A's event handler sits in a blocked event-queue write — for a channel node C opened to it — -/// until the close and its maturity are synced. Pinned to Esplora so the wallet syncs only on -/// demand. +/// it, no round of ours being watched anymore. Node A splices into its channel with node B, +/// leaving no change, and, once another coin has confirmed, bumps the round's fee, which coin +/// selection draws from that coin, so the two rounds are contributions of their own; node B +/// closes while node A's event handler sits in a blocked event-queue write — for a channel node C +/// opened to it — until the close and its maturity are synced. Pinned to Esplora so the wallet +/// syncs only on demand. #[cfg(feature = "chain-esplora")] #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn splice_rounds_discarded_while_the_channel_is_listed_fail_at_close() { let (bitcoind, electrsd) = setup_bitcoind_and_electrsd(); let chain_source = TestChainSource::Esplora(&electrsd); let node_b = setup_node(&chain_source, random_config()); - // Keeping no anchor reserve back from node B, node A's splice-in takes its whole balance into - // the funding, with no output of its own. + // Keeping no anchor reserve back from node B, node A's splice-in can take nearly its whole + // balance into the funding, with no output of its own. let mut config_a = random_config(); config_a.node_config.anchor_channels_config.trusted_peers_no_reserve.push(node_b.node_id()); let (node_a, store_a, logs_a) = @@ -5971,14 +6000,18 @@ async fn splice_rounds_discarded_while_the_channel_is_listed_fail_at_close() { let user_channel_id_a = expect_channel_ready_event!(node_a, node_b.node_id()); let user_channel_id_b = expect_channel_ready_event!(node_b, node_a.node_id()); - // Node B contributes nothing to either round, so only node A hears of them. - node_a.splice_in_with_all(&user_channel_id_a, node_b.node_id(), None).unwrap(); + // Node B contributes nothing to either round, so only node A hears of them. The splice-in + // spends node A's only coin, leaving less than dust over its fee of about 220 sats, which goes + // to the fee rather than to change. + let splice_amount_sat = node_a.list_balances().spendable_onchain_balance_sats - 400; + node_a.splice_in(&user_channel_id_a, node_b.node_id(), splice_amount_sat, None).unwrap(); let first_txo = expect_splice_negotiated_event!(node_a, node_b.node_id()); let first_round = wait_for_transaction(&bitcoind, &electrsd, first_txo.txid).await; wait_for_classified_funding_payment(&node_a, first_txo.txid).await; assert_eq!(first_round.output.len(), 1, "the splice-in left change"); - // The wallet learns the round from the sync and gets a fresh coin. The bump asks for more than - // the round's maximum feerate allows, so it is rebuilt from the round's inputs and the coin. + // The wallet learns the round from the sync and gets a fresh coin. With no change to pay the + // bump's higher fee from, coin selection runs again and funds the bump from the coin alone, the + // round's own input being spent by the round. node_a.sync_wallets().unwrap(); let coin_address = node_a.onchain_payment().new_address().unwrap(); let coin_txid = distribute_funds_unconfirmed( @@ -5991,12 +6024,6 @@ async fn splice_rounds_discarded_while_the_channel_is_listed_fail_at_close() { mine_block_with(&bitcoind, &electrsd, &[raw_transaction_hex(&bitcoind, coin_txid)]).await; node_a.sync_wallets().unwrap(); - // Past the first round's maximum feerate, so the bump is rebuilt with the coin. - // TODO: Once the LDK pin includes - // https://git.rust-bitcoin.org/lightningdevkit/rust-lightning/pulls/5297, the adjustment is - // bounded by the bump's own maximum and succeeds in place, so the bump keeps the first round's - // inputs and the input assertions below fail. Make the first round a fixed-amount `splice_in` - // that leaves no change instead, with coin selection then drawing the bump's fee from the coin. let bump_fee_rate = FeeRate::from_sat_per_kwu(1_000); node_a .bump_channel_funding_fee(&user_channel_id_a, node_b.node_id(), Some(bump_fee_rate.into())) @@ -6008,10 +6035,12 @@ async fn splice_rounds_discarded_while_the_channel_is_listed_fail_at_close() { let first_inputs: Vec<_> = first_round.input.iter().map(|input| input.previous_output).collect(); let bump_inputs: Vec<_> = bump_round.input.iter().map(|input| input.previous_output).collect(); - assert!( - first_inputs.iter().all(|outpoint| bump_inputs.contains(outpoint)), - "the bump did not reuse the first round's inputs" - ); + // Both rounds spend the channel's funding output; beyond it, the bump swaps the round's input + // for the coin. + assert!(bump_inputs.contains(&funding_txo), "the bump did not spend the funding output"); + let dropped_inputs: Vec<_> = + first_inputs.iter().filter(|outpoint| !bump_inputs.contains(outpoint)).collect(); + assert_eq!(dropped_inputs.len(), 1, "the bump kept the round's own input"); let added_inputs: Vec<_> = bump_inputs.iter().filter(|outpoint| !first_inputs.contains(outpoint)).collect(); assert_eq!(added_inputs.len(), 1, "the bump added more than the coin"); @@ -6063,7 +6092,7 @@ async fn splice_rounds_discarded_while_the_channel_is_listed_fail_at_close() { kept_before, "a discard while the channel was listed resolved the payment" ); - // The bump added the coin to the first round's inputs, so each round's discard carries a + // The bump spends the coin in place of the round's input, so each round's discard carries a // contribution of its own to return. assert_eq!( logs_a.count(RECLAIMED_ADDRESSES), @@ -8387,6 +8416,109 @@ async fn drop_in_async_context() { node.stop().unwrap(); } +/// The LSPS2 service only opens a JIT channel if the client's `to_self_delay` stays within the +/// `max_client_to_self_delay` agreed upon in the selected opening fee parameters. The client uses +/// LDK's default of `BREAKDOWN_TIMEOUT`, so a limit one block below it aborts the open, while a +/// limit equal to it lets the open go through. +#[tokio::test(flavor = "multi_thread", worker_threads = 1)] +async fn lsps2_service_enforces_max_client_to_self_delay() { + do_lsps2_service_enforces_max_client_to_self_delay(BREAKDOWN_TIMEOUT as u32 - 1, false).await; + do_lsps2_service_enforces_max_client_to_self_delay(BREAKDOWN_TIMEOUT as u32, true).await; +} + +async fn do_lsps2_service_enforces_max_client_to_self_delay( + max_client_to_self_delay: u32, expect_open: bool, +) { + let (bitcoind, electrsd) = setup_bitcoind_and_electrsd(); + let esplora_url = format!("http://{}", electrsd.esplora_url.as_ref().unwrap()); + + let mut sync_config = EsploraSyncConfig::default(); + sync_config.background_sync_config = None; + + let lsps2_service_config = LSPS2ServiceConfig { + require_token: None, + advertise_service: false, + channel_opening_fee_ppm: 10_000, + channel_over_provisioning_ppm: 100_000, + max_payment_size_msat: 1_000_000_000, + min_payment_size_msat: 0, + min_channel_lifetime: 100, + min_channel_opening_fee_msat: 1_000, + max_client_to_self_delay, + client_trusts_lsp: false, + disable_client_reserve: false, + }; + + let service_config = random_config(); + setup_builder!(service_builder, service_config.node_config); + service_builder.set_chain_source_esplora(esplora_url.clone(), Some(sync_config)); + service_builder.enable_liquidity_provider(lsps2_service_config); + let service_node = service_builder.build(service_config.node_entropy.into()).unwrap(); + service_node.start().unwrap(); + + let service_node_id = service_node.node_id(); + let service_addr = service_node.listening_addresses().unwrap().first().unwrap().clone(); + + let client_config = random_config(); + setup_builder!(client_builder, client_config.node_config); + client_builder.set_chain_source_esplora(esplora_url.clone(), Some(sync_config)); + client_builder.add_liquidity_source(service_node_id, service_addr, None, false); + let client_node = client_builder.build(client_config.node_entropy.into()).unwrap(); + client_node.start().unwrap(); + + let payer_config = random_config(); + setup_builder!(payer_builder, payer_config.node_config); + payer_builder.set_chain_source_esplora(esplora_url.clone(), Some(sync_config)); + let payer_node = payer_builder.build(payer_config.node_entropy.into()).unwrap(); + payer_node.start().unwrap(); + + let service_addr = service_node.onchain_payment().new_address().unwrap(); + let payer_addr = payer_node.onchain_payment().new_address().unwrap(); + premine_and_distribute_funds( + &bitcoind.client, + &electrsd.client, + vec![service_addr, payer_addr], + Amount::from_sat(10_000_000), + ) + .await; + service_node.sync_wallets().unwrap(); + payer_node.sync_wallets().unwrap(); + + open_channel(&payer_node, &service_node, 5_000_000, false, &electrsd).await; + generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 6).await; + service_node.sync_wallets().unwrap(); + payer_node.sync_wallets().unwrap(); + expect_channel_ready_event!(payer_node, service_node.node_id()); + expect_channel_ready_event!(service_node, payer_node.node_id()); + + let invoice_description = + Bolt11InvoiceDescription::Direct(Description::new(String::from("asdf")).unwrap()); + let jit_invoice = client_node + .bolt11_payment() + .receive_via_jit_channel(100_000_000, &invoice_description.into(), 1024) + .unwrap(); + payer_node.bolt11_payment().send(&jit_invoice, None).unwrap(); + + if expect_open { + expect_channel_pending_event!(service_node, client_node.node_id()); + expect_channel_pending_event!(client_node, service_node.node_id()); + } else { + // The client's `accept_channel` exceeds our `to_self_delay` limit, so the channel is + // closed before it is ever funded. + expect_event!(service_node, ChannelClosed); + expect_event!(client_node, ChannelClosed); + assert!(service_node + .list_channels() + .iter() + .all(|c| c.counterparty.node_id != client_node.node_id())); + assert!(client_node.list_channels().is_empty()); + } + + service_node.stop().unwrap(); + client_node.stop().unwrap(); + payer_node.stop().unwrap(); +} + #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn lsps2_client_trusts_lsp() { let (bitcoind, electrsd) = setup_bitcoind_and_electrsd(); From 5c071686735902d111fbad0ad3b108a1eab44ea5 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Thu, 3 Dec 2026 14:12:50 -0600 Subject: [PATCH 2/2] Allow deprecated rustls ring provider rustls 0.23.48 deprecates the ring CryptoProvider as it lacks post-quantum key exchange, which fails our CI builds that deny warnings. There is no non-deprecated ring provider to switch to, and moving to aws-lc-rs would mean a new dependency, so allow the deprecation where we install the default provider. Developed with assistance from Claude Code. --- src/builder.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/builder.rs b/src/builder.rs index fe1de27843..89d8c12e1f 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -2724,6 +2724,9 @@ pub(crate) fn optionally_install_rustls_cryptoprovider() { INIT_CRYPTO.call_once(|| { // Ensure we always install a `CryptoProvider` for `rustls` if it was somehow not previously installed by now. if rustls::crypto::CryptoProvider::get_default().is_none() { + // rustls 0.23.48 deprecates the `ring` provider for lacking post-quantum key exchange, + // but it remains the backend our dependencies are built with. + #[allow(deprecated)] let _ = rustls::crypto::ring::default_provider().install_default(); }