Skip to content

feat(orders): refresh order details from Mostro with Shift+U - #145

Open
amuntri wants to merge 1 commit into
MostroP2P:mainfrom
amuntri:feat/orders-info
Open

feat(orders): refresh order details from Mostro with Shift+U#145
amuntri wants to merge 1 commit into
MostroP2P:mainfrom
amuntri:feat/orders-info

Conversation

@amuntri

@amuntri amuntri commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What

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.

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 runs order_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::Orders is account-scoped: the daemon resolves the ids against the requesting identity pubkey (get_user_orders_by_id in src/app/orders.rs) and answers CantDo(NotFound) when none match. I confirmed this empirically — mostro-cli ordersinfo against 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:

  • Only rows already present locally are merged; the trade keys live there and must not be invented, and an id never traded has nothing to merge onto. Anything else is logged and counted.
  • The request goes out with the cached kind-38385 instance info, which carries the PoW difficulty. Instances that enforce PoW reject a request sent without it — the live instance requires 6 bits today, which is exactly the error mostro-cli gives when run without POW=6.
  • 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 appear without a restart.

Tests

cargo test --all-features → 426/427 passed. Clippy -D warnings and fmt clean. New: summary wording, the resync trigger, and the Shift+U help entry.

Note for #114

This also unblocks the is_mine limitation 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 iff kind == Buy && trade_pubkey == buyer_trade_pubkey, or kind == Sell && trade_pubkey == seller_trade_pubkey. Happy to wire that into restore once this lands, if you want it.

🤖 Generated with Claude Code

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>
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 49 minutes.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 60d81fd0-114c-4b37-9a47-74c696e69f3b

📥 Commits

Reviewing files that changed from the base of the PR and between c4f72b6 and 627102b.

📒 Files selected for processing (9)
  • src/main.rs
  • src/ui/constants.rs
  • src/ui/help_popup.rs
  • src/ui/key_handler/mod.rs
  • src/ui/operation_result.rs
  • src/ui/orders.rs
  • src/util/dm_utils/order_ch_mng.rs
  • src/util/order_utils/execute_orders_info.rs
  • src/util/order_utils/mod.rs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant