order cancel
command | order.cancel |
| Kind | Write (trade step) |
| Who | The maker of a pending order, or either party of a trade |
| Needs | MOSTRO_PUBKEY, RELAYS, identity, the order’s local row, --yes in JSON mode |
| Publishes | One cancel request signed with the order’s trade key |
| Local write | Status → canceled or cooperatively-canceled; nothing for a cancel request |
| Statuses | ok, error, uncertain |
| Schemas | schemas/order.cancel.input.json, schemas/order.cancel.output.json |
Cancels an order. Depending on its state the node either cancels it at once, or (in a running trade) starts a cooperative cancel that the other party must confirm with the same command.
Invocation
mostro-cli --output json order cancel --order UUID --yes
Replaces cancel -o ....
Input
| Option | Required | Rule |
|---|---|---|
--order | yes | UUID of an order in the local store |
--yes | yes in JSON |
Behavior
Looks up the trade key, publishes cancel, waits for the reply. Never carries a next trade
key, never spends an index.
result | Meaning | next_step | Local status |
|---|---|---|---|
canceled | Canceled outright (e.g. your own pending order) | null | canceled |
cancel_requested | You started a cooperative cancel | wait_for_peer_cancel | unchanged |
cancel_accepted | The other party had requested it; now canceled by both | null | cooperatively-canceled |
Success data: StepData
See order fiat-sent; next_trade_index is
always null here.
Outcomes
As order fiat-sent, plus:
| Case | status | Stages |
|---|---|---|
cancel_requested (nothing to record) | ok | published / accepted / not_attempted |
Errors
As order add-invoice. A typical refusal reason is
order_already_canceled.
Warnings
local_status_stale, invalid_event_timestamp, cleanup_incomplete. The schema also
lists trade_index_not_recorded (shared with the other steps), but cancel never sends a
next trade key, so it does not occur.
Examples
The counterparty had requested a cancel: now canceled by both
order.cancel/cancel_accepted · status ok · exit 0 · fixture
mostro-cli --output json order cancel --order 00000000-0000-0000-0000-000000000001 --yes
{
"schema_version": "1",
"command": "order.cancel",
"status": "ok",
"data": {
"next_step": null,
"next_trade_index": null,
"node_pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"order_id": "00000000-0000-0000-0000-000000000001",
"result": "cancel_accepted",
"trade_pubkey": "c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"
},
"error": null,
"warnings": [],
"meta": {
"publication": "published",
"daemon_acceptance": "accepted",
"persistence": "applied",
"snapshot": null
}
}
In an active trade: a cooperative cancel was started
order.cancel/cancel_requested · status ok · exit 0 · fixture
mostro-cli --output json order cancel --order 00000000-0000-0000-0000-000000000001 --yes
{
"schema_version": "1",
"command": "order.cancel",
"status": "ok",
"data": {
"next_step": "wait_for_peer_cancel",
"next_trade_index": null,
"node_pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"order_id": "00000000-0000-0000-0000-000000000001",
"result": "cancel_requested",
"trade_pubkey": "c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"
},
"error": null,
"warnings": [],
"meta": {
"publication": "published",
"daemon_acceptance": "accepted",
"persistence": "not_attempted",
"snapshot": null
}
}
A pending order canceled
order.cancel/canceled · status ok · exit 0 · fixture
mostro-cli --output json order cancel --order 00000000-0000-0000-0000-000000000001 --yes
{
"schema_version": "1",
"command": "order.cancel",
"status": "ok",
"data": {
"next_step": null,
"next_trade_index": null,
"node_pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"order_id": "00000000-0000-0000-0000-000000000001",
"result": "canceled",
"trade_pubkey": "c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"
},
"error": null,
"warnings": [],
"meta": {
"publication": "published",
"daemon_acceptance": "accepted",
"persistence": "applied",
"snapshot": null
}
}
An unusable answer: the cancel may have happened
order.cancel/reply_malformed_uncertain · status uncertain · reply_malformed · exit 1 · fixture
mostro-cli --output json order cancel --order 00000000-0000-0000-0000-000000000001 --yes
{
"schema_version": "1",
"command": "order.cancel",
"status": "uncertain",
"data": null,
"error": {
"code": "reply_malformed",
"message": "The reply from the node could not be used."
},
"warnings": [],
"meta": {
"publication": "published",
"daemon_acceptance": "unknown",
"persistence": "not_attempted",
"snapshot": null
}
}
Refused with reason order_already_canceled
order.cancel/node_refused · status error · node_refused · exit 1 · fixture
mostro-cli --output json order cancel --order 00000000-0000-0000-0000-000000000001 --yes
{
"schema_version": "1",
"command": "order.cancel",
"status": "error",
"data": null,
"error": {
"code": "node_refused",
"message": "The node refused the request.",
"reason": "order_already_canceled"
},
"warnings": [],
"meta": {
"publication": "published",
"daemon_acceptance": "rejected",
"persistence": "not_attempted",
"snapshot": null
}
}
Declined at the human prompt
order.cancel/order_declined · status error · order_declined · exit 1 · fixture
mostro-cli order cancel --order 00000000-0000-0000-0000-000000000001
{
"schema_version": "1",
"command": "order.cancel",
"status": "error",
"data": null,
"error": {
"code": "order_declined",
"message": "The order was not confirmed, so nothing was sent."
},
"warnings": [],
"meta": {
"publication": "not_attempted",
"daemon_acceptance": "unknown",
"persistence": "not_attempted",
"snapshot": null
}
}
Local store not writable: nothing sent
order.cancel/store_unwritable · status error · store_unwritable · exit 1 · authored
mostro-cli --output json order cancel --order 00000000-0000-0000-0000-000000000001 --yes
{
"schema_version": "1",
"command": "order.cancel",
"status": "error",
"data": null,
"error": {
"code": "store_unwritable",
"message": "The local store cannot be written, so nothing was sent."
},
"warnings": [],
"meta": {
"publication": "not_attempted",
"daemon_acceptance": "unknown",
"persistence": "not_attempted",
"snapshot": null
}
}
JSON mode without –yes
order.cancel/yes_required · status error · invalid_arguments · exit 2 · captured
mostro-cli --output json order cancel --order 00000000-0000-0000-0000-000000000001
{
"schema_version": "1",
"command": "order.cancel",
"status": "error",
"data": null,
"error": {
"code": "invalid_arguments",
"message": "The command arguments are invalid."
},
"warnings": [],
"meta": {
"publication": "not_attempted",
"daemon_acceptance": "unknown",
"persistence": "not_attempted",
"snapshot": null
}
}