Wait for one Lightning order without polling the whole invoice list
A checkout worker already holding the invoice label can wait for that specific invoice to resolve. A dropped connection should leave the order recoverable.
Start a waiter for a known label
Set LABEL to a previously created local invoice label. waitinvoice returns immediately for an already paid invoice and otherwise waits until payment or expiry.
lightning-cli waitinvoice "$LABEL" | jq '{label, status, payment_hash, amount_received_msat, paid_at}'
Persist the received amount
On success record the payment hash and amount_received_msat alongside the order. Expiry is reported as an RPC error, so inspect the invoice's current status before updating the order on a failed wait. A transport timeout merely interrupts observation. Resume by querying the same label.
docs.corelightning.org waitinvoice · docs.corelightning.org listinvoices