Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

fix(restore): a restored taker trade loses its invoice step (deadline and hold invoice)

Open
#591 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
dart, rust
Domain
backend

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's created_at, so started_at is when the order was published, not when it was taken.
  • persist_restored_trade_row moves the status cursor to the restore time (record_status_event(sent_at), :4828), and restore_session persists these rows before it re-issues the kind-14 filter, so the replay always arrives afterwards and older. When the old AddInvoice / PayInvoice comes back, the arm drops it at status_write_blocked (:3674, :3778), before record_invoice_step_start (:3680, :3783). So the step start is never saved.
  • With no step start, invoiceDeadlineProvider falls back to startedAt + 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. PayInvoice saves the bolt11 through sync_trade_fields_if_changed (:3795), after the same status_write_blocked return, and nothing else writes hold_invoice. The pay-invoice screen opens with nothing to pay.
  • A restored buyer at WaitingPayment has 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

  1. 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.
  2. 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 WaitingBuyerInvoice plus the replayed AddInvoice records the step start at the message time. Same for a seller taker with PayInvoice, 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 WaitingPayment has 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_invoice still None
  • restored buyer at WaitingPayment + replayed WaitingSellerToPay → no step start
  • control, same AddInvoice without 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MostroP2P/app

All issues in MostroP2P/app

Similar issues

More Dart issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.