Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

identity init

commandidentity.init
KindLocal write
NeedsMCLI_DIR or a home directory. No MOSTRO_PUBKEY, RELAYS, stdin or --yes
PublishesNothing; contacts no relay or node
Local writeCreates the data directory and mcli.db with a fresh mnemonic; never changes an existing store
Statusesok, error
Schemasschemas/identity.init.input.json, schemas/identity.init.output.json

Creates the local identity store that every signing command needs. It is the only JSON command that creates an identity: the others fail with identity_missing when there is none.

Invocation

mostro-cli --output json identity init

It does what the first run of a legacy command does (the two share one implementation), without needing the node’s configuration or a connection.

Input

None. Any option of its own is invalid_arguments (exit 2). Root options such as --mostro-pubkey or --relays are accepted and ignored.

Behavior

  1. Uses MCLI_DIR, else .mcli in the home directory. Creates that directory owner-only (0700 on Unix, one level deep); an existing directory is tightened to owner-only.
  2. If mcli.db or one of its SQLite companion files (mcli.db-journal, mcli.db-wal, mcli.db-shm) already exists, it changes nothing and fails with identity_exists. It never deletes or repairs a store: move the old files away first.
  3. Creates mcli.db owner-only (0600 on Unix) with the same tables as the legacy first run and one user row holding a fresh 12-word mnemonic and no trade index.
  4. If the file was created but could not be completed, it is removed again (persistence: failed).

Two runs at the same time create one store; the other reports identity_exists.

The mnemonic and every private key stay in mcli.db. No mode, stream or error shows them, and there is no option to reveal them. Back the file up yourself.

Success data: IdentityInitData

FieldTypeMeaning
identity_pubkeyhex64The identity public key of the new store (index 0 of the new mnemonic)

Outcomes

CasestatuscodeStages (publication / daemon / persistence)
Store createdoknot_applicable / not_applicable / applied
mcli.db or a companion file existserroridentity_existsnot_applicable / not_applicable / not_attempted
No data directory can be determined, or the directory or file cannot be createderrorstore_unwritablenot_applicable / not_applicable / not_attempted
The file was created but not completed (removed again)errorstore_unwritablenot_applicable / not_applicable / failed
An option was givenerrorinvalid_arguments (exit 2)not_applicable ×3

Errors

invalid_arguments, identity_exists, store_unwritable, internal_error. Nothing was published in any case. After identity_exists, use identity show to read the existing identity.

Warnings

None. The schema’s shared WarningCode list names invalid_event_timestamp and cleanup_incomplete, but this command emits no warning.

Examples

A new store with a fresh mnemonic

identity.init/created · status ok · exit 0 · fixture

mostro-cli --output json identity init
{
  "schema_version": "1",
  "command": "identity.init",
  "status": "ok",
  "data": {
    "identity_pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"
  },
  "error": null,
  "warnings": [],
  "meta": {
    "publication": "not_applicable",
    "daemon_acceptance": "not_applicable",
    "persistence": "applied",
    "snapshot": null
  }
}

The data directory cannot be created: nothing written

identity.init/directory_not_created · status error · store_unwritable · exit 1 · fixture

mostro-cli --output json identity init
{
  "schema_version": "1",
  "command": "identity.init",
  "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": null
  }
}

A store (or a companion file) is already there: nothing changed

identity.init/identity_exists · status error · identity_exists · exit 1 · fixture

mostro-cli --output json identity init
{
  "schema_version": "1",
  "command": "identity.init",
  "status": "error",
  "data": null,
  "error": {
    "code": "identity_exists",
    "message": "A local identity already exists, so nothing was changed."
  },
  "warnings": [],
  "meta": {
    "publication": "not_applicable",
    "daemon_acceptance": "not_applicable",
    "persistence": "not_attempted",
    "snapshot": null
  }
}

The file was created but not completed, and removed again

identity.init/store_not_completed · status error · store_unwritable · exit 1 · fixture

mostro-cli --output json identity init
{
  "schema_version": "1",
  "command": "identity.init",
  "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": "failed",
    "snapshot": null
  }
}

identity init takes no options

identity.init/invalid_arguments · status error · invalid_arguments · exit 2 · fixture

mostro-cli --output json identity init --bogus
{
  "schema_version": "1",
  "command": "identity.init",
  "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
  }
}

Next

identity show reads the key back; then order list and a first order new or take.