restore does not persist recovered orders, so recovered trades cannot be continued
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start in the RestoreSession branch of src/parser/dms.rs, which prints restore_orders and restore_disputes without saving them, and read the context passed through src/cli/restore.rs. Check the orders schema in src/db.rs and how Order::get_by_id and User::get_trade_keys are used. Done means a restored order can be resolved by release or fiatsent without manual steps, and restore no longer claims success when nothing was persisted.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
mostro-cli restore asks Mostro for the user's active orders and disputes and prints them, but it never writes them into the local orders table. Every command that acts on a specific order looks it up there first, so after a mnemonic-only recovery the user can see their in-flight trades but cannot act on any of them.
This makes the documented "restore on a new machine" path incomplete: it recovers your identity, but not your ability to finish a trade that was already open.
Found while auditing the README against the code (#186), which now documents the limitation. This issue tracks closing the gap in the code.
Reproduction
On a machine whose ~/.mcli/mcli.db has been recreated from a backed-up mnemonic, with an order in progress:
$ mostro-cli restore
🔄 Restore Session Response
📋 Found 1 pending order(s):
1. Order ID: <uuid>
Trade Index: 7
Status: FiatSent
✅ Session restore completed successfully!
$ mostro-cli release -o <uuid>
no rows returned by a query that expected to return at least one row
The restore reports success, and the very next step fails.
Root cause
Action::RestoreSession in src/parser/dms.rs:826 iterates restore_data.restore_orders and restore_data.restore_disputes purely to println! them:
for (i, order_info) in restore_data.restore_orders.iter().enumerate() {
println!(" {}. Order ID: {}", i + 1, order_info.order_id);
println!(" Trade Index: {}", order_info.trade_index);
println!(" Status: {:?}", order_info.status);
println!();
}
No Order is constructed and Order::save is never called, so the orders table is untouched. src/cli/restore.rs has a &Context (and therefore the pool) available — it is passed down to print_commands_results — so nothing structural prevents persisting here.
Impact
Every command that resolves an order through Order::get_by_id fails on a restored order. All of these hard-error, none degrade gracefully:
| Command | Call site |
|---|---|
release, cancel, fiatsent, dispute |
src/cli/send_msg.rs:89, :159 |
addinvoice |
src/cli/add_invoice.rs:15 |
addbondinvoice |
src/cli/add_bond_invoice.rs:20 |
rate |
src/cli/rate_user.rs:39 |
senddm |
src/cli/send_dm.rs:45 |
dmtouser |
src/cli/dm_to_user.rs:21 |
getdmuser |
src/cli/get_dm_user.rs:31 |
sendadmindmattach |
src/cli/send_admin_dm_attach.rs:212 |
Worth noting the failure is opaque: release surfaces sqlx's no rows returned by a query that expected to return at least one row, which gives the user no clue that the order is simply absent from the local cache.
Why this should be tractable
What those commands actually need from the row is order.trade_keys — the keypair the order was opened with. That is derivable, because RestoredOrdersInfo (mostro-core 0.14.1, src/message.rs:484) carries exactly the missing piece:
pub struct RestoredOrdersInfo {
pub order_id: Uuid,
pub trade_index: i64,
pub status: String,
}
User::get_trade_keys(pool, trade_index) already derives a keypair from an index, so trade_index → trade keys → a usable local row is a short path. RestoredDisputesInfo likewise carries order_id, trade_index, status, initiator and solver_pubkey.
Suggested approach
-
In the
RestoreSessionhandler, for each restored order: derive the trade keys fromtrade_index, and upsert anordersrow keyed onorder_id(upsert rather than insert, so re-runningrestoreis idempotent and does not clobber a row that is already richer). -
Decide what to do about the columns the payload does not carry.
ordersdeclareskind,status,amount,fiat_code,fiat_amount,payment_methodandpremiumasNOT NULL(src/db.rs:29-46), so a row cannot be written fromRestoredOrdersInfoalone. Two options:- fetch the public kind-
38383event for each order id and fill the real values — theordersinfopath already does this kind of lookup, so it could be reused; - or relax those columns to nullable and treat a restored row as a stub that later messages backfill.
The first keeps the local cache faithful; the second is smaller but spreads
Optionhandling into the printing code. - fetch the public kind-
-
Consider persisting disputes too, so a restored user can keep talking to their solver.
-
Whatever is chosen,
restoreshould stop printing✅ Session restore completed successfully!when the orders were only displayed — the message currently overstates what happened.
Acceptance
After mostro-cli restore on a database rebuilt from the mnemonic, an order that Mostro reports as active can be carried to completion — at minimum release / fiatsent / senddm work against it without further manual steps.
- Lingua principale
- Rust
- Stelle
- 39
- Fork
- 16
- Merge medio
- 11h 7m
- PR unite (30g)
- 7
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MostroP2P/mostro-cli
-
Difficoltà 3/5 Mezza giornata Idoneità per principianti 74/100
MostroP2P/mostro-cli#200 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 56/100
MostroP2P/mostro-cli#187 ·
-
Implement Cashu 2-of-3 multisig escrow (client-side)Forse di nuovo libera @AndreaDiazCorreia l’ha presa 136 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement
MostroP2P/mostro-cli#175 · 1 assegnatario ·
-
Storing trade_keys encryptedApertabug enhancement good first issue help wanted
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
MostroP2P/mostro-cli#107 · 1 commento ·
-
enhancement good first issue help wanted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
MostroP2P/mostro-cli#67 · 10 commenti · 1 reazione ·
Tutte le issue di MostroP2P/mostro-cli
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
bytecodealliance/rustix#1703 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
linux build warningAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
Pomax/vst-plugins#24 ·
I maintainer di solito rispondono entro 1 giorno
-
V1 manifest lists written by Java lose added/existing/deleted file countsForse già presa @kacper-li-airspace-intelligence l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/iceberg-rust#3445 ·
I maintainer di solito rispondono entro 4 giorni
-
Slack integration: links on self-hosted domains never unfurl (parseCapShareUrl only accepts cap.so / cap.link)Forse già presa @mangeshraut712 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
CapSoftware/Cap#2546 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno