From 72c9872b23e418e28df55838d92df580982183a7 Mon Sep 17 00:00:00 2001 From: Patrick Mulligan Date: Wed, 4 Mar 2026 12:23:14 -0500 Subject: [PATCH] fix(watchdog): handle LND restarts without locking outgoing operations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the payment index advances (e.g. after an LND restart or external payment), update the cached offset instead of immediately locking. Only lock if both a history mismatch AND a balance discrepancy are detected — indicating a real security concern rather than a benign LND restart. Co-Authored-By: Claude Opus 4.6 --- src/services/main/watchdog.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/services/main/watchdog.ts b/src/services/main/watchdog.ts index d9d585ba..3c12b676 100644 --- a/src/services/main/watchdog.ts +++ b/src/services/main/watchdog.ts @@ -238,13 +238,17 @@ export class Watchdog { const knownMaxIndex = Math.max(maxFromDb, this.latestPaymentIndexOffset) const newLatest = await this.lnd.GetLatestPaymentIndex(knownMaxIndex) const historyMismatch = newLatest > knownMaxIndex - const deny = await this.checkBalanceUpdate(deltaLnd, deltaUsers) if (historyMismatch) { - getLogger({ component: 'bark' })("History mismatch detected in absolute update, locking outgoing operations") - this.lnd.LockOutgoingOperations() - return + this.log("Payment index advanced from", knownMaxIndex, "to", newLatest, "- updating offset (likely LND restart or external payment)") + this.latestPaymentIndexOffset = newLatest } + const deny = await this.checkBalanceUpdate(deltaLnd, deltaUsers) if (deny) { + if (historyMismatch) { + getLogger({ component: 'bark' })("Balance mismatch with unexpected payment history, locking outgoing operations") + this.lnd.LockOutgoingOperations() + return + } this.log("Balance mismatch detected in absolute update, but history is ok") } this.lnd.UnlockOutgoingOperations()