diff --git a/src/lib.rs b/src/lib.rs index d5b6505..d814528 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,7 +38,7 @@ use ldk_node::{ hashes::{Hash, sha256}, secp256k1::PublicKey, }, - config::Config, + config::{Config, EsploraSyncConfig}, generate_entropy_mnemonic, lightning::ln::channelmanager::PaymentId, lightning::sign::{KeysManager as LdkKeysManager, NodeSigner, Recipient}, @@ -373,7 +373,12 @@ impl MdkNode { let mut builder = Builder::from_config(config); builder.set_network(network); - builder.set_chain_source_esplora(options.esplora_url, None); + // Disable background wallet syncing. These nodes are intended to be short + // lived and are kept in sync via other means. + let esplora_sync_config = EsploraSyncConfig { + background_sync_config: None, + }; + builder.set_chain_source_esplora(options.esplora_url, Some(esplora_sync_config)); builder.set_gossip_source_rgs(options.rgs_url); builder.set_entropy_bip39_mnemonic(mnemonic, None); let logger_arc = Arc::clone(logger_instance()); @@ -441,18 +446,12 @@ impl MdkNode { } } - /// Start the node and sync wallets. Call once before polling for events. + /// Start the node. Call once before polling for events. #[napi] pub fn start_receiving(&self) -> napi::Result<()> { self.node().start().map_err(|e| { eprintln!("[lightning-js] Failed to start node in start_receiving: {e}"); napi::Error::from_reason(format!("Failed to start: {e}")) - })?; - - self.node().sync_wallets().map_err(|e| { - eprintln!("[lightning-js] Failed to sync wallets in start_receiving: {e}"); - let _ = self.node().stop(); - napi::Error::from_reason(format!("Failed to sync: {e}")) }) } @@ -717,11 +716,6 @@ impl MdkNode { return received_payments; } - if let Err(err) = self.node().sync_wallets() { - eprintln!("[lightning-js] Failed to sync wallets: {err}"); - panic!("failed to sync wallets: {err}"); - } - let start_sync_at = std::time::Instant::now(); let mut last_event_time = start_sync_at; @@ -848,10 +842,6 @@ impl MdkNode { eprintln!("[lightning-js] Failed to start node for get_invoice: {err}"); panic!("failed to start node for get_invoice: {err}"); } - if let Err(err) = self.node().sync_wallets() { - eprintln!("[lightning-js] Failed to sync wallets: {err}"); - panic!("failed to sync wallets: {err}"); - } let result = self.get_invoice_impl(Some(amount), description, expiry_secs); @@ -1154,15 +1144,6 @@ impl MdkNode { napi::Error::new(Status::GenericFailure, format!("failed to start node: {e}")) })?; - // Sync wallets - if let Err(e) = self.node().sync_wallets() { - let _ = self.node().stop(); - return Err(napi::Error::new( - Status::GenericFailure, - format!("failed to sync wallets: {e}"), - )); - } - let result = self.execute_payment_impl(&payment_target, wait_secs); let _ = self.node().stop(); result