diff --git a/lamassu-next/apps/machine/src/services/lightning.ts b/lamassu-next/apps/machine/src/services/lightning.ts index f522bba..7e76b65 100644 --- a/lamassu-next/apps/machine/src/services/lightning.ts +++ b/lamassu-next/apps/machine/src/services/lightning.ts @@ -280,8 +280,12 @@ function startLnurlCompletionPolling( const data = await response.json() - // Check if the link has been used - if (data.link?.used > 0 || data.used > 0) { + // The LNURL endpoint returns: + // - { tag: 'withdrawRequest', ... } when link is still available + // - { status: 'ERROR', reason: 'Withdraw link is spent.' } when claimed + const isSpent = data.status === 'ERROR' && data.reason?.includes('spent') + + if (isSpent) { console.log('[LNURL Poll] Withdrawal claimed!', uniqueHash) clearInterval(pollInterval) @@ -294,6 +298,7 @@ function startLnurlCompletionPolling( // Use a placeholder preimage since LNURL-withdraw doesn't provide one directly onComplete(`lnurl-withdraw-${uniqueHash}`) } + // Note: Don't log on every poll - it can cause EPIPE errors in Electron } catch (e) { console.warn('[LNURL Poll] Error checking status:', e) }