@@ -95,7 +95,8 @@ class LightningService {
9595 onchainWalletSyncIntervalSecs: Env . walletSyncIntervalSecs,
9696 lightningWalletSyncIntervalSecs: Env . walletSyncIntervalSecs,
9797 feeRateCacheUpdateIntervalSecs: Env . walletSyncIntervalSecs
98- )
98+ ) ,
99+ connectionTimeoutSecs: 10
99100 )
100101 builder. setChainSourceElectrum ( serverUrl: resolvedElectrumServerUrl, config: electrumConfig)
101102
@@ -124,19 +125,46 @@ class LightningService {
124125 builder. setEntropyBip39Mnemonic ( mnemonic: mnemonic, passphrase: passphrase)
125126
126127 try await ServiceQueue . background ( . ldk) {
127- if !lnurlAuthServerUrl. isEmpty {
128- self . node = try builder. buildWithVssStore (
129- vssUrl: vssUrl,
130- storeId: storeId,
131- lnurlAuthServerUrl: lnurlAuthServerUrl,
132- fixedHeaders: [ : ]
133- )
134- } else {
135- self . node = try builder. buildWithVssStoreAndFixedHeaders (
136- vssUrl: vssUrl,
137- storeId: storeId,
138- fixedHeaders: [ : ]
128+ do {
129+ if !lnurlAuthServerUrl. isEmpty {
130+ self . node = try builder. buildWithVssStore (
131+ vssUrl: vssUrl,
132+ storeId: storeId,
133+ lnurlAuthServerUrl: lnurlAuthServerUrl,
134+ fixedHeaders: [ : ]
135+ )
136+ } else {
137+ self . node = try builder. buildWithVssStoreAndFixedHeaders (
138+ vssUrl: vssUrl,
139+ storeId: storeId,
140+ fixedHeaders: [ : ]
141+ )
142+ }
143+ } catch let error as BuildError {
144+ guard case . DangerousValue = error else { throw error }
145+
146+ // Stale ChannelMonitor vs ChannelManager — retry with accept_stale to recover.
147+ Logger . warn (
148+ " Build failed with DangerousValue. Retrying with accept_stale_channel_monitors for recovery. " ,
149+ context: " Recovery "
139150 )
151+ builder. setAcceptStaleChannelMonitors ( accept: true )
152+
153+ if !lnurlAuthServerUrl. isEmpty {
154+ self . node = try builder. buildWithVssStore (
155+ vssUrl: vssUrl,
156+ storeId: storeId,
157+ lnurlAuthServerUrl: lnurlAuthServerUrl,
158+ fixedHeaders: [ : ]
159+ )
160+ } else {
161+ self . node = try builder. buildWithVssStoreAndFixedHeaders (
162+ vssUrl: vssUrl,
163+ storeId: storeId,
164+ fixedHeaders: [ : ]
165+ )
166+ }
167+ Logger . info ( " Stale monitor recovery: build succeeded with accept_stale " , context: " Recovery " )
140168 }
141169 }
142170
0 commit comments