fix(machine): detect LNURL-withdraw completion from spent status
The polling was checking for `data.used > 0` but the LNURL endpoint
returns `{ status: 'ERROR', reason: 'Withdraw link is spent.' }` when
the link has been claimed. Check for this error response instead.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
021aa6e168
commit
d650647d8f
1 changed files with 7 additions and 2 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue