fix: cancel hold invoice when expiring ACTIVE orders#837
Conversation
When the cancel-orders job expires an order, run the transition under the per-order mutex and re-read the order so it does not stomp an order that advanced concurrently (e.g. a release/payout in flight under the same lock). For ACTIVE orders the buyer never signalled fiat-sent, so cancel the hold invoice and refund the seller instead of orphaning the payment hash. Previously the order was marked EXPIRED without canceling the hold invoice, and since the expired-hold-invoice check ignores EXPIRED orders, the seller's funds stayed locked until the on-chain CLTV timeout. FIAT_SENT orders are not auto-refunded here (the buyer claims to have paid) and are left for the dispute/admin flow. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 8 minutes and 28 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
package.json was bumped to 0.15.2 (commit 056284a) but package-lock.json still declared 0.15.1. The CI 'Run prettier' step runs 'npm install' followed by 'git diff --exit-code', and npm rewrites the lockfile version to match package.json, producing an uncommitted diff that fails the check. Sync the lockfile version so the working tree stays clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@codex review |
Summary
Ensures that when the cancel-orders job expires an
ACTIVEorder, the associated Lightning hold invoice is canceled so the seller's locked funds are refunded promptly, instead of being orphaned until the on-chain CLTV timeout. The expiry transition is also serialized under the per-order mutex with a state re-check to avoid racing concurrent flows.Previously, the job marked expired orders as
EXPIREDwithout canceling the hold invoice. Because the expired-hold-invoice check ignoresEXPIREDorders, the seller's funds remained locked until the on-chain timeout.Changes
jobs/cancel_orders.ts— Run the expiry transition insidePerOrderIdMutex.instance.runExclusive(orderId, ...)and re-read the order under the lock so the job does not stomp an order that advanced concurrently (e.g. a release/payout in flight under the same lock). OnlyACTIVEandFIAT_SENTorders are expired:ACTIVE— the buyer never signalled fiat-sent, so cancel the hold invoice (refund the seller) before marking the orderEXPIRED.FIAT_SENT— the buyer claims to have paid; the hold invoice is left open and the case is logged for the dispute/admin flow rather than auto-refunded.Testing
npx tsc --noEmitpasses.prettier --checkandeslintpass.