feat(orders): refresh order details from Mostro with Shift+U - #145
Open
amuntri wants to merge 1 commit into
Open
feat(orders): refresh order details from Mostro with Shift+U#145amuntri wants to merge 1 commit into
amuntri wants to merge 1 commit into
Conversation
Closes the last gap against mostro-cli's `ordersinfo`: mostrix had no way to ask Mostro for the authoritative state of an order. Shift+U on My Trades sends `Action::Orders` with `Payload::Ids` for the selected order and merges the answer into SQLite. Account-scoped like restore: the daemon resolves ids against the requesting *identity* (`get_user_orders_by_id`) and answers `CantDo(NotFound)` for anything that is not yours, so the exchange runs on the identity keys and carries no trade index. Verified against the live instance — querying someone else's order id returns exactly that. Why it is worth having beyond a refresh button: the public kind-38383 events only carry the terms of *pending* orders, while this answer comes from Mostro's database and includes the buyer and seller trade pubkeys. Merging therefore goes through `Order::upsert_from_small_order_dm`, which keeps trade keys, dispute and chat columns intact and can derive the peer chat secret once those pubkeys are known. The request is sent with the cached kind-38385 instance info, which carries the PoW difficulty: instances that enforce PoW reject a request sent without it (the live one requires 6 bits today). The live Mostro pubkey is read at spawn time rather than the settings snapshot, and the response sender is validated against it. `OperationResult::OrdersRefreshed` re-runs the same DB-to-UI sync as the history-cleanup path, so refreshed rows show up without a restart. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
Warning Review limit reachedNext included review available in 49 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes the last gap against
mostro-cli'sordersinfo: mostrix had no way to ask Mostro for the authoritative state of an order.Shift+U on My Trades sends
Action::OrderswithPayload::Idsfor the selected order and merges the answer into SQLite.Why it is more than a refresh button
The public kind-38383 events only carry the terms of pending orders. This answer comes from Mostro's own database and includes the buyer and seller trade pubkeys, which the relay events never expose.
Merging therefore goes through
Order::upsert_from_small_order_dm, which keeps the row's trade keys, dispute and chat columns intact — and, because it runsorder_chat_counterparty_and_shared_hex, can derive the peer chat secret for a row that was missing it.Scoping (verified against the live instance)
Action::Ordersis account-scoped: the daemon resolves the ids against the requesting identity pubkey (get_user_orders_by_idinsrc/app/orders.rs) and answersCantDo(NotFound)when none match. I confirmed this empirically —mostro-cli ordersinfoagainst an order id taken from the public book returns "Resource not found". So this is "refresh my orders", not an arbitrary lookup, and the whole exchange runs on the identity keys with no trade index, like restore.Consequences honoured in the implementation:
mostro-cligives when run withoutPOW=6.OperationResult::OrdersRefreshedre-runs the same DB-to-UI sync as the history-cleanup path, so refreshed rows appear without a restart.Tests
cargo test --all-features→ 426/427 passed. Clippy-D warningsand fmt clean. New: summary wording, the resync trigger, and the Shift+U help entry.Note for #114
This also unblocks the
is_minelimitation documented there. The reviewers asked for maker/taker to be inferred from the restored trade pubkey versus the order's buyer/seller pubkeys — impossible from relay data, but exactly what this answer carries: you are the maker iffkind == Buy && trade_pubkey == buyer_trade_pubkey, orkind == Sell && trade_pubkey == seller_trade_pubkey. Happy to wire that into restore once this lands, if you want it.🤖 Generated with Claude Code