fix(restore): a restored taker trade loses its invoice step (deadline and hold invoice)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
Start with orders.rs at restored_trade_row, persist_restored_trade_row, and the AddInvoice/PayInvoice handling in dispatch_mostro_message; trace how restored status and step starts are recorded. Then inspect invoiceDeadlineProvider and the restore/replay tests. Done means the proposed replay, missing-message, and live-trade cases behave as listed, including the seller hold invoice; this issue depends on #574.
Written by the indexing model from the issue text.
Description
After restoring from the seed, a taker whose trade is waiting for an invoice (or for the hold invoice to be paid) gets the add-invoice / pay-invoice screen opened automatically, and it already says the time is up, even if the step is still running.
Why
restored_trade_row(orders.rs:4666) dates the row with the order'screated_at, sostarted_atis when the order was published, not when it was taken.persist_restored_trade_rowmoves the status cursor to the restore time (record_status_event(sent_at),:4828), andrestore_sessionpersists these rows before it re-issues the kind-14 filter, so the replay always arrives afterwards and older. When the oldAddInvoice/PayInvoicecomes back, the arm drops it atstatus_write_blocked(:3674,:3778), beforerecord_invoice_step_start(:3680,:3783). So the step start is never saved.- With no step start,
invoiceDeadlineProviderfalls back tostartedAt + window, which is the order's creation date plus the window. That is already in the past.
Unlike #568 there's no race here: this happens every time.
Same cause, two more symptoms
- A restored seller gets no hold invoice.
PayInvoicesaves the bolt11 throughsync_trade_fields_if_changed(:3795), after the samestatus_write_blockedreturn, and nothing else writeshold_invoice. The pay-invoice screen opens with nothing to pay. - A restored buyer at
WaitingPaymenthas no arm that records its step start at all, so the trade-detail countdown (#564) shows it expired too. Fix 1 below does not cover it, unless we confirm when mostrod starts that timer; fix 2 must.
Proposed fix
- Let the replayed message record the step start, and the bolt11 for
PayInvoice, even when its status write is blocked, but only if it matches the row's current status and trade key. The trade-key check is what #574 adds, so this should build on it. - If that message is no longer on the relays, or the step has no message that records it (the buyer at
WaitingPayment), show no deadline for the restored row instead of guessing. This must apply only to restored rows, not globally: a live taker has no recorded step start either, and a genuinely expired step must keep saying so (see #577).
Tests
- A restored buyer taker at
WaitingBuyerInvoiceplus the replayedAddInvoicerecords the step start at the message time. Same for a seller taker withPayInvoice, which also gets its hold invoice. - A message from an earlier take of the same order records nothing.
- A restored row whose message never arrives has no deadline.
- A restored buyer at
WaitingPaymenthas no deadline. - A live taker past the window still shows "time is up".
Verified
Reproduced on main with a test that drives the real persist_restored_trade_row and dispatch_mostro_message (order at t=1000, step message at t=50000, restore at t=60000):
- restored buyer + replayed
AddInvoice→ no step start - restored seller + replayed
PayInvoice→ no step start,hold_invoicestillNone - restored buyer at
WaitingPayment+ replayedWaitingSellerToPay→ no step start - control, same
AddInvoicewithout the restore → step start recorded at t=50000
Related: #568, #577, #564. Depends on #574.
- Dominant language
- Dart
- Stars
- 11
- Forks
- 9
- Avg merge
- 13h 4m
- Merged PRs (30d)
- 259
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MostroP2P/app
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Add-invoice screen stays on "Sent, waiting for the node" after a late acceptance on a sell orderOpenbug priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
area: ui
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
MostroP2P/app#341 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
bggRGjQaUbCoE/PiliPlus#3235 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
intel/rohd-wave-viewer#11 ·
-
DOCS UPDATE: README.md and BACKEND.md reference a search-meetings edge function that does not existOpendocumentation
Difficulty 1/5 1-3 hours Newbie friendliness 93/100
AOSSIE-Org/Ell-ena#337 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
cat: puzzle
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
lichess-org/mobile#3826 ·
Maintainers usually reply within 2 days