order sync
command | order.sync |
| Kind | Private read with local writes |
| Needs | MOSTRO_PUBKEY, RELAYS, an existing identity, a writable store |
| Publishes | Nothing |
| Local write | Inserts a row for each announced order the store does not know; never changes an existing row |
| Statuses | ok, error, uncertain |
| Schemas | schemas/order.sync.input.json, schemas/order.sync.output.json |
Development branch.
order syncis implemented and tested ondevelopbut not yet in a release. Check that your binary listsorder.syncinschema.
Gives a local row to orders the node announced to your trade keys, so that the commands
that need a row (order cancel, order release, order add-invoice…) work on them.
Its main use is the child order of a range order: after each partial trade the node
creates a new order for the rest of the range under your next trade key, and tells you
with a new-order message. It also recovers any such order the store lost.
Invocation
mostro-cli --output json order sync [--since MINUTES]
No --yes: it publishes nothing and only adds rows.
Input
| Option | Required | Rule |
|---|---|---|
--since | no | How far back to read, in minutes, 1..10080 (7 days). Default 10080 |
Behavior
- Derives your trade keys from index 1 to the recorded last trade index (the newest 200).
- Reads, like
message list, the node’s messages to those keys in the window. - For every
new-ordermessage whose order id is not in the store, saves a row with the order, the key it was announced to and that key’s index, in one transaction per order. - Everything else (other actions, known orders) is counted in
messages_ignored.
It is idempotent: a second run saves nothing and changes nothing. It never overwrites a
row. A save that fails stops the run as uncertain; the rows saved before stay saved.
Success data: SyncData
| Field | Type | Meaning |
|---|---|---|
node_pubkey | hex64 | The node |
since_minutes | decimal string | The window used |
adopted | array of AdoptedOrder | Rows saved by this run, oldest first; empty when nothing was due |
messages_read | decimal string | Messages of the node read in the window |
messages_ignored | decimal string | Messages that led to no row (other actions, known orders) |
truncated | boolean | The read may be incomplete (a relay hit its limit, or more than the record cap matched) |
keys_read | decimal string | Trade keys read |
keys_not_read | decimal string | Older keys beyond the newest 200 |
AdoptedOrder
| Field | Type | Meaning |
|---|---|---|
order | OrderRecord | The order as announced (a range child: pending, min/max = the rest of the range) |
trade_index | decimal string | Index of the key it was announced to |
trade_pubkey | hex64 | That key |
meta.snapshot describes the relay read.
Outcomes
| Case | status | code | Stages (publication / daemon / persistence) |
|---|---|---|---|
| Rows saved | ok | not_applicable / not_applicable / applied | |
| Nothing to save | ok | not_applicable / not_applicable / not_attempted | |
| Failed before reading (arguments, configuration, identity, store) | error | its code | not_applicable / not_applicable / not_applicable |
| Read failed, or a save was due and the store is unwritable | error | its code | not_applicable / not_applicable / not_attempted |
| Some rows saved, then one failed | uncertain | order_not_saved (data present: what was saved) | not_applicable / not_applicable / failed |
On uncertain, simply run it again after fixing the store: it is idempotent.
Errors
invalid_arguments, configuration_missing, configuration_invalid,
relay_connection_failed, relay_read_failed, read_timeout, read_limit_exceeded,
internal_error, identity_missing, identity_unreadable, store_unreadable,
store_unwritable; uncertain: order_not_saved.
Warnings
trade_keys_limited, invalid_order_timestamp, invalid_event_timestamp,
cleanup_incomplete.
Examples
After a range release: the child order announced to trade key 4 gets a local row
order.sync/adopted_child · status ok · exit 0 · authored
mostro-cli --output json order sync
{
"schema_version": "1",
"command": "order.sync",
"status": "ok",
"data": {
"node_pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"since_minutes": "10080",
"adopted": [
{
"order": {
"id": "00000000-0000-0000-0000-000000000006",
"side": "sell",
"status": "pending",
"sats_amount": "0",
"fiat_currency": "USD",
"fiat_amount": "0",
"fiat_amount_min": "10",
"fiat_amount_max": "50",
"payment_method": "bank transfer",
"premium_percent": "1",
"buyer_trade_pubkey": null,
"seller_trade_pubkey": null,
"created_at": "2026-11-02T09:00:00Z",
"created_at_unix": "1793610000",
"expires_at": "2026-11-03T09:00:00Z",
"expires_at_unix": "1793696400"
},
"trade_index": "4",
"trade_pubkey": "f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"
}
],
"messages_read": "12",
"messages_ignored": "11",
"truncated": false,
"keys_read": "4",
"keys_not_read": "0"
},
"error": null,
"warnings": [],
"meta": {
"publication": "not_applicable",
"daemon_acceptance": "not_applicable",
"persistence": "applied",
"snapshot": {
"since": "2026-10-26T10:00:00Z",
"until": null,
"observed_at": "2026-11-02T10:00:03Z",
"per_relay_limit": 50,
"max_unique_events": 10000,
"configured_relays": 2,
"completed_relays": 2,
"received_events": 12,
"completion_policy": "all_relays_eose",
"complete_history": false
}
}
}
Nothing new: idempotent second run, nothing written
order.sync/nothing_to_adopt · status ok · exit 0 · authored
mostro-cli --output json order sync --since 60
{
"schema_version": "1",
"command": "order.sync",
"status": "ok",
"data": {
"node_pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"since_minutes": "60",
"adopted": [],
"messages_read": "3",
"messages_ignored": "3",
"truncated": false,
"keys_read": "4",
"keys_not_read": "0"
},
"error": null,
"warnings": [],
"meta": {
"publication": "not_applicable",
"daemon_acceptance": "not_applicable",
"persistence": "not_attempted",
"snapshot": {
"since": "2026-10-26T10:00:00Z",
"until": null,
"observed_at": "2026-11-02T10:00:03Z",
"per_relay_limit": 50,
"max_unique_events": 10000,
"configured_relays": 2,
"completed_relays": 2,
"received_events": 3,
"completion_policy": "all_relays_eose",
"complete_history": false
}
}
}
One row saved, the next failed: data lists what was saved
order.sync/order_not_saved_uncertain · status uncertain · order_not_saved · exit 1 · authored
mostro-cli --output json order sync
{
"schema_version": "1",
"command": "order.sync",
"status": "uncertain",
"data": {
"node_pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"since_minutes": "10080",
"adopted": [
{
"order": {
"id": "00000000-0000-0000-0000-000000000006",
"side": "sell",
"status": "pending",
"sats_amount": "0",
"fiat_currency": "USD",
"fiat_amount": "0",
"fiat_amount_min": "10",
"fiat_amount_max": "50",
"payment_method": "bank transfer",
"premium_percent": "1",
"buyer_trade_pubkey": null,
"seller_trade_pubkey": null,
"created_at": "2026-11-02T09:00:00Z",
"created_at_unix": "1793610000",
"expires_at": "2026-11-03T09:00:00Z",
"expires_at_unix": "1793696400"
},
"trade_index": "4",
"trade_pubkey": "f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"
}
],
"messages_read": "14",
"messages_ignored": "12",
"truncated": false,
"keys_read": "5",
"keys_not_read": "0"
},
"error": {
"code": "order_not_saved",
"message": "The node created the order but it could not be saved locally."
},
"warnings": [],
"meta": {
"publication": "not_applicable",
"daemon_acceptance": "not_applicable",
"persistence": "failed",
"snapshot": {
"since": "2026-10-26T10:00:00Z",
"until": null,
"observed_at": "2026-11-02T10:00:03Z",
"per_relay_limit": 50,
"max_unique_events": 10000,
"configured_relays": 2,
"completed_relays": 2,
"received_events": 14,
"completion_policy": "all_relays_eose",
"complete_history": false
}
}
}
No local identity
order.sync/identity_missing · status error · identity_missing · exit 1 · captured
mostro-cli --output json --mostro-pubkey 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 --relays ws://127.0.0.1:1 order sync
{
"schema_version": "1",
"command": "order.sync",
"status": "error",
"data": null,
"error": {
"code": "identity_missing",
"message": "No local identity exists."
},
"warnings": [],
"meta": {
"publication": "not_applicable",
"daemon_acceptance": "not_applicable",
"persistence": "not_applicable",
"snapshot": null
}
}
A child was due but the store cannot be written
order.sync/store_unwritable · status error · store_unwritable · exit 1 · authored
mostro-cli --output json order sync
{
"schema_version": "1",
"command": "order.sync",
"status": "error",
"data": null,
"error": {
"code": "store_unwritable",
"message": "The local store cannot be written, so nothing was sent."
},
"warnings": [],
"meta": {
"publication": "not_applicable",
"daemon_acceptance": "not_applicable",
"persistence": "not_attempted",
"snapshot": {
"since": "2026-10-26T10:00:00Z",
"until": null,
"observed_at": "2026-11-02T10:00:03Z",
"per_relay_limit": 50,
"max_unique_events": 10000,
"configured_relays": 2,
"completed_relays": 2,
"received_events": 12,
"completion_policy": "all_relays_eose",
"complete_history": false
}
}
}
–since must be 1..10080
order.sync/since_out_of_range · status error · invalid_arguments · exit 2 · captured
mostro-cli --output json order sync --since 0
{
"schema_version": "1",
"command": "order.sync",
"status": "error",
"data": null,
"error": {
"code": "invalid_arguments",
"message": "The command arguments are invalid."
},
"warnings": [],
"meta": {
"publication": "not_applicable",
"daemon_acceptance": "not_applicable",
"persistence": "not_applicable",
"snapshot": null
}
}