Skip to content

fix(core): handle quote expiry in MeltBolt11Handler.recoverExecuting() #1

Description

@4xvgal

When a melt operation is stuck in executing state and the quote expires on the mint, recoverExecutingOperation() fails permanently, leaving
proofs locked forever.

MeltBolt11Handler.recoverExecuting() calls checkMeltQuoteState() which throws MintOperationError(20007) when the quote has expired. This
error is unhandled — it propagates up to tryRecoverExecutingOperation() which swallows it with only a warning log. No proof restoration
occurs.

Since recoverPendingOperations() on app restart calls the same code path, the operation remains stuck across restarts indefinitely.

Reproduction

  1. prepareMeltBolt11() → executeMelt() → mint network error during execution
  2. State transitions to executing, tryRecoverExecutingOperation() fails (mint unreachable)
  3. Wait for quote to expire on mint
  4. Restart app → recoverPendingOperations() → recoverExecutingOperation()
  5. checkMeltQuoteState() throws MintOperationError(20007)
  6. Error swallowed, proofs remain locked in executing state permanently

Root cause

MeltBolt11Handler.recoverExecuting() (packages/core/infra/handlers/melt/MeltBolt11Handler.ts:576) only handles PAID/PENDING/UNPAID responses
from checkMeltQuoteState(). It does not catch MintOperationError for quote expiry.

Note: MintBolt11Handler.recoverExecuting() (packages/core/infra/handlers/mint/MintBolt11Handler.ts:131) already handles this case for mint
operations:

} else if (err.code === 20007) {
return {
status: 'TERMINAL',
error: Recovered: quote ${quoteId} expired while executing mint,
};
}

Expected fix

In MeltBolt11Handler.recoverExecuting(), catch MintOperationError(20007) and treat it as UNPAID — the quote expired means the LN payment was
never completed, so proofs can be safely restored.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions