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 {