From e6b9e6421906244932b00b3b55239338fbcb8059 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Tue, 18 Aug 2026 21:49:22 -0500 Subject: [PATCH] Run LDK initialization concurrently LDK initialization does not yield while it restores and starts the node, so Spark cannot progress inside the join. Use a separate task to allow both initializers to run concurrently. --- orange-sdk/src/lightning_wallet.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/orange-sdk/src/lightning_wallet.rs b/orange-sdk/src/lightning_wallet.rs index 0d89dfe..ba79e4c 100644 --- a/orange-sdk/src/lightning_wallet.rs +++ b/orange-sdk/src/lightning_wallet.rs @@ -12,6 +12,7 @@ use bitcoin_payment_instructions::amount::Amount; use ldk_node::bitcoin::base64::Engine; use ldk_node::bitcoin::base64::prelude::BASE64_STANDARD; +use ldk_node::bitcoin::io; use ldk_node::bitcoin::secp256k1::PublicKey; use ldk_node::bitcoin::{Address, Network}; use ldk_node::config::{AsyncPaymentsRole, BackgroundSyncConfig, SyncTimeoutsConfig}; @@ -61,6 +62,19 @@ impl LightningWallet { pub(super) async fn init( runtime: Arc, config: WalletConfig, store: Arc, event_queue: Arc, tx_metadata: TxMetadataStore, logger: Arc, + ) -> Result { + let handle = runtime.get_handle(); + handle + .spawn(Self::init_inner(runtime, config, store, event_queue, tx_metadata, logger)) + .await + .map_err(|e| { + io::Error::new(io::ErrorKind::Other, format!("LDK initialization task failed: {e}")) + })? + } + + async fn init_inner( + runtime: Arc, config: WalletConfig, store: Arc, + event_queue: Arc, tx_metadata: TxMetadataStore, logger: Arc, ) -> Result { log_info!(logger, "Creating LDK node..."); let anchor_channels_config = ldk_node::config::AnchorChannelsConfig {