@xyo-network/wallet-xl1-cli 0.1.19 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +154 -8
  2. package/dist/bin/wallet.mjs +77083 -73993
  3. package/package.json +13 -9
package/README.md CHANGED
@@ -67,7 +67,8 @@ Wallet CLI data is stored under `~/.xl1/wallet/cli` by default.
67
67
  | --- | --- |
68
68
  | `XL1_WALLET_HOME` | Overrides the wallet storage directory. |
69
69
  | `ARIES_WALLET_HOME` | Legacy fallback storage override. Used only when `XL1_WALLET_HOME` is not set. |
70
- | `ARIES_WALLET_PASSWORD` | Supplies the wallet password for non-interactive runs and tests. |
70
+ | `ARIES_WALLET_PASSWORD` | Supplies the wallet password. A nonempty value is validated before any cached session is used. For a new store, it sets the initial password. |
71
+ | `ARIES_WALLET_NON_INTERACTIVE=1` | Refuses terminal password and recovery-phrase prompts. Private-key access requires an unlocked session or `ARIES_WALLET_PASSWORD`; import requires `--phrase-stdin` or `--phrase`. |
71
72
 
72
73
  Wallet seed phrases are encrypted at rest. Commands that need private key access prompt for the wallet password unless `ARIES_WALLET_PASSWORD` is set.
73
74
 
@@ -97,10 +98,45 @@ xl1-wallet network use xl1-sequence
97
98
  Add a local or custom network:
98
99
 
99
100
  ```sh
100
- xl1-wallet network add local http://127.0.0.1:8080/rpc --label "Local XL1" --chain-id 0x1234
101
+ xl1-wallet network add local http://127.0.0.1:8080/rpc --label "Local XL1" --chain-id 1234
101
102
  xl1-wallet network use local
102
103
  ```
103
104
 
105
+ Adding a network preserves the current selection and rejects duplicate IDs.
106
+ New IDs must be nonblank, contain no control characters, fit within 256 UTF-8
107
+ bytes, and not begin with `-`. Optional labels are preserved exactly and may
108
+ contain up to 1024 UTF-8 bytes. Optional chain IDs use the XL1 protocol's
109
+ nonempty lowercase hexadecimal form without a `0x` prefix; there is no fixed
110
+ length requirement. The chain ID is stored metadata: adding a network does not
111
+ probe the endpoint or verify its chain.
112
+
113
+ For endpoints containing path or query credentials, pass the complete URL via
114
+ private stdin instead of a positional argument. Stdin must contain only the URL
115
+ as UTF-8, with no trailing newline, and is limited to 16 KiB. URLs must be complete
116
+ HTTP or HTTPS URLs without controls or fragments. Local HTTP endpoints are
117
+ supported. URL username/password information is rejected because the RPC fetch
118
+ transport does not support it.
119
+
120
+ ```sh
121
+ printf '%s' "$RPC_URL" | xl1-wallet network inspect-add custom \
122
+ --rpc-url-stdin --label="Custom XL1" --chain-id=1234 --json
123
+ printf '%s' "$RPC_URL" | xl1-wallet network add custom \
124
+ --rpc-url-stdin --label="Custom XL1" --chain-id=1234 \
125
+ --expected-state="$REVIEWED_STATE_HASH" --json
126
+ ```
127
+
128
+ `inspect-add` validates the proposed entry and returns its ID, label, optional
129
+ chain ID, current active ID, canonical wallet root, and `stateHash`. Use that
130
+ hash as `REVIEWED_STATE_HASH` for the corresponding add. Inspection does not
131
+ create `networks.json`; the add writes defaults and the custom entry atomically
132
+ under the wallet store lease. If any wallet file changes after review, the
133
+ guarded add fails and must be reviewed again. `--rpc-url-stdin` and a positional
134
+ URL are mutually exclusive.
135
+
136
+ Network list and add support `--json`. Network summaries and
137
+ success messages omit the entire RPC URL, including its hostname. The URL is
138
+ stored in the private wallet configuration for RPC use.
139
+
104
140
  Remove a custom network:
105
141
 
106
142
  ```sh
@@ -115,15 +151,16 @@ xl1-wallet network remove local
115
151
  | --- | --- |
116
152
  | `xl1-wallet create` | Create a new wallet. |
117
153
  | `xl1-wallet import` | Import a recovery phrase. |
118
- | `xl1-wallet export` | Print a wallet recovery phrase after password confirmation. |
154
+ | `xl1-wallet export` | Print a wallet recovery phrase using a password or unlocked session. |
119
155
  | `xl1-wallet list` | List wallets in the current wallet home. |
120
156
  | `xl1-wallet use <id>` | Set the active wallet. |
121
157
  | `xl1-wallet rename <id> <label>` | Rename a wallet. |
122
- | `xl1-wallet remove <id>` | Remove a wallet from local storage. |
123
- | `xl1-wallet reset` | Delete local wallet CLI data after confirmation. |
158
+ | `xl1-wallet remove [id]` | Authenticate and remove a wallet; `--wallet-id` targets an exact ID. |
159
+ | `xl1-wallet reset` | Delete known wallet files after confirmation, preserving unrelated files. |
124
160
  | `xl1-wallet unlock` | Cache an encrypted wallet session for a limited time. |
125
161
  | `xl1-wallet lock` | Clear the cached wallet session. |
126
- | `xl1-wallet password change` | Change the active wallet password. |
162
+ | `xl1-wallet password change` | Change the shared password for every wallet in the store. |
163
+ | `xl1-wallet lifecycle preview --json` | Inspect the canonical store path, state fingerprint, wallets, and known files. |
127
164
 
128
165
  Examples:
129
166
 
@@ -135,17 +172,63 @@ xl1-wallet import --label quant-recovery --phrase "..." --algorithm ml-dsa-65
135
172
  xl1-wallet list
136
173
  xl1-wallet use <wallet-id>
137
174
  xl1-wallet export --id <wallet-id>
175
+ xl1-wallet export --wallet-id <exact-wallet-id> --json
138
176
  ```
139
177
 
140
178
  `create` and `import` default to `--algorithm secp256k1`. Use `--algorithm ml-dsa-65` for `QuantHDWallet` wallets, which derive `qm65...` bech32m addresses. Wallet-signed JWT commands require secp256k1 because ML-DSA-65 does not yet have a standardized JOSE algorithm.
141
- Wallet labels must be unique. If `create` is run without `--label`, the CLI uses the first available `wallet#` label, starting with `wallet0`.
179
+ Wallet labels must be unique, nonblank, and free of NUL characters. Other label text, including surrounding spaces, is preserved. If `create` is run without `--label`, the CLI uses the first available `wallet#` label, starting with `wallet0`.
180
+ Commands accepting a wallet ID or label prefer an exact ID match before looking
181
+ for a matching label.
182
+
183
+ For unattended imports, `--phrase-stdin` reads raw UTF-8 from standard input
184
+ until EOF, up to 16 KiB, and trims surrounding whitespace. It is mutually
185
+ exclusive with `--phrase`. The algorithm, label, and recovery phrase are
186
+ validated before the command initializes a password or stores a wallet.
187
+
188
+ `export --wallet-id` accepts only an exact stored ID and cannot be combined
189
+ with `--id`. The existing `--id` option also accepts labels; omitting both
190
+ options reveals the active wallet.
191
+
192
+ `create --json` and `export --json` emit only
193
+ `{id, label, algorithm, mnemonic}` to stdout. This output contains the recovery
194
+ phrase. `import --json` emits only `{id, label, algorithm}` and does not include
195
+ the phrase. Text output remains the default.
196
+
197
+ Password change requires the current password even with an unlocked session.
198
+ `ARIES_WALLET_PASSWORD` supplies only that current password. For automation,
199
+ `password change --new-password-stdin --json` reads the new password as raw UTF-8
200
+ until EOF, preserving all whitespace, with a 4096-byte limit and no NUL
201
+ characters. Its JSON result is `{changed: true}`. Interactive mode asks for and
202
+ confirms the new password separately. Rotation clears the cached session.
203
+
204
+ `remove --wallet-id=<exact-id> --json` returns `{id, label, removed: true}`.
205
+ The named selector cannot be combined with the positional ID/label. A supplied
206
+ wrong password fails even if an unlocked session exists.
207
+
208
+ Password change, removal, and reset accept `--expected-state=<stateHash>` from
209
+ `lifecycle preview --json`. The CLI checks this fingerprint under its filesystem
210
+ lease before writing; a changed store requires a new review. Preview returns
211
+ `{root, stateHash, wallets, files}` without credentials. If wallet metadata is
212
+ corrupt, `wallets` is `null` with a `metadataError`, so reset can still be reviewed.
213
+
214
+ Updated CLI processes share a canonical-path filesystem lease. Overlapping
215
+ operations report a busy store; a killed owner's lease expires after 30 seconds.
216
+ Older CLI versions and other programs that ignore the lease are not coordinated.
217
+ Password rotation, removal, and reset commit a durable roll-forward journal
218
+ before replacing data files. The journal contains encrypted wallet records and
219
+ password-verifier metadata, never plaintext passwords or recovery phrases.
220
+ The next leased operation completes a valid pending transaction before reading
221
+ the store. After an interrupted rotation, try the new password first. Individual
222
+ files and journals are limited to 16 MiB. File data is synced; directory syncing
223
+ is best effort on Windows where unsupported. A corrupt or unrecoverable journal
224
+ blocks operations, including reset: preserve its files for repair.
142
225
 
143
226
  ### Accounts
144
227
 
145
228
  | Command | Description |
146
229
  | --- | --- |
147
230
  | `xl1-wallet account derive <offset>` | Derive and store an account at an offset. |
148
- | `xl1-wallet account list` | List stored accounts for the active wallet. |
231
+ | `xl1-wallet account list [--wallet <id-or-label>]` | List stored accounts for the active or specified wallet. |
149
232
  | `xl1-wallet account show <offset>` | Show a derived account address. |
150
233
  | `xl1-wallet account label <offset> <label>` | Label an account. |
151
234
  | `xl1-wallet account remove <offset>` | Remove a stored account record. |
@@ -156,8 +239,17 @@ Examples:
156
239
  xl1-wallet account derive 0 --label main
157
240
  xl1-wallet account show 0
158
241
  xl1-wallet account list
242
+ xl1-wallet account derive 4 --wallet-id <wallet-id> --label savings
159
243
  ```
160
244
 
245
+ Account `show`, `derive`, `label`, and `remove` accept `--wallet-id` to target an
246
+ exact stored wallet without changing the active wallet. Labels are not accepted
247
+ by this option. Omitting it keeps the active-wallet default. Desktop account
248
+ changes require an explicit wallet ID so a reviewed change stays attached to
249
+ the intended wallet. Account removal only removes address-book metadata;
250
+ the key remains derivable and funds are unaffected. Account labeling validates
251
+ the derivation path before saving it.
252
+
161
253
  ### Balances And Transfers
162
254
 
163
255
  | Command | Description |
@@ -276,6 +368,60 @@ xl1-wallet backup import wallet-metadata.json
276
368
  xl1-wallet reset
277
369
  ```
278
370
 
371
+ Metadata backups retain the version 1 `network.xyo.wallet.backup` format. They
372
+ contain address-book offsets and labels, and contact addresses, labels, and
373
+ timestamps. They do not contain recovery phrases, passwords, session credentials,
374
+ or network configuration. Imports merge metadata: incoming defined account labels
375
+ and contact labels win, existing account labels survive when incoming labels are omitted, and existing
376
+ contact creation timestamps are preserved. Contact update timestamps never move
377
+ backward when importing an older backup.
378
+
379
+ Review an import or export before applying it:
380
+
381
+ ```sh
382
+ xl1-wallet backup inspect wallet-metadata.json --direction=import --json
383
+ xl1-wallet backup inspect wallet-metadata.json --direction=export --json
384
+ ```
385
+
386
+ The JSON result is `{root, stateHash, path, fileStateHash, exists, addressBooks,
387
+ accounts, contacts}`. `root` and `path` are canonical absolute paths. Counts refer
388
+ to incoming backup entries for import, or the stored metadata to export. The
389
+ inspection exposes only paths, counts, existence, and hashes. To require exactly
390
+ the reviewed wallet and file states, pass both hashes to the subsequent command:
391
+
392
+ ```sh
393
+ xl1-wallet backup import wallet-metadata.json \
394
+ --expected-state=<stateHash> --expected-file-state=<fileStateHash> --json
395
+ xl1-wallet backup export wallet-metadata.json --overwrite \
396
+ --expected-state=<stateHash> --expected-file-state=<fileStateHash> --json
397
+ ```
398
+
399
+ Import returns `{imported: true, addressBooks, accounts, contacts}`; export returns
400
+ `{exported: true, addressBooks, accounts, contacts}`. Existing export destinations
401
+ require `--overwrite`. New exports never overwrite a file created concurrently.
402
+ Exports use private `0600` temporary files, fsync, and atomic publication. Imports
403
+ commit address books and contacts together through the wallet recovery journal
404
+ and never modify their source backup. Cooperating CLI processes coordinate by
405
+ wallet root and export destination, including exports from different wallet roots.
406
+
407
+ Files must be regular files of at most 16 MiB, with one filesystem link. Symlinks,
408
+ directories, special files, wallet storage files, and wallet transaction or lease
409
+ paths are rejected. The parent directory must already exist. Version 1 schemas
410
+ and fields are validated strictly; unknown entries, duplicate books/accounts or
411
+ contacts, invalid legacy or quant addresses, and prototype keys are rejected.
412
+ Labels preserve every string accepted by existing version 1 authoring commands,
413
+ including empty, multiline, and long values, within the overall file size limit.
414
+ Offsets use decimal HD path segments up to `2147483647`, optional hardened
415
+ apostrophes and `m/`, at most 32 segments and 512 characters. Timestamps use UTC
416
+ ISO format with milliseconds, as produced by the CLI.
417
+
418
+ For noninteractive reset, pass both `--confirm=RESET` and `--yes`; `--json`
419
+ returns `{reset: true, removedFiles: number}`. No password is required. Reset
420
+ removes only `password.json`, `phrases.json`, `active.json`, `address-books.json`,
421
+ `contacts.json`, `networks.json`, `session.json`, and `.machine-id`. It preserves
422
+ the directory and unrelated files, and refuses to recurse into a directory
423
+ occupying one of those filenames.
424
+
279
425
  ## Output And Automation
280
426
 
281
427
  Most commands print readable text by default. Commands intended for automation, such as `send`, also support JSON output: