@xyo-network/wallet-xl1-cli 0.1.4
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.
- package/README.md +329 -0
- package/dist/bin/wallet.mjs +184055 -0
- package/package.json +101 -0
package/README.md
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
# @xyo-network/wallet-xl1-cli
|
|
2
|
+
|
|
3
|
+
[![npm][npm-badge]][npm-link]
|
|
4
|
+
[![license][license-badge]][license-link]
|
|
5
|
+
|
|
6
|
+
> Standalone XL1 wallet CLI for seed phrases, accounts, balances, transfers, payload signing, and wallet-signed JWTs.
|
|
7
|
+
|
|
8
|
+
## Description
|
|
9
|
+
|
|
10
|
+
`@xyo-network/wallet-xl1-cli` provides the `xl1-wallet` command. It is a focused XL1 wallet tool that can create or import wallets, derive accounts, manage network and contact metadata, sign transactions and payloads, send XL1, and mint or verify wallet-backed JWTs.
|
|
11
|
+
|
|
12
|
+
The Aries CLI uses this same package for `aries wallet ...`, so the standalone and nested command surfaces stay aligned.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
### Prerequisites
|
|
17
|
+
|
|
18
|
+
- Node.js `>=18.17.1`
|
|
19
|
+
- A package manager such as `npm`, `pnpm`, or `yarn`
|
|
20
|
+
|
|
21
|
+
### Global Install
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm install -g @xyo-network/wallet-xl1-cli
|
|
25
|
+
xl1-wallet --help
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Run From This Repository
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
pnpm xy compile @xyo-network/wallet-xl1-cli
|
|
32
|
+
pnpm xl1-wallet --help
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
Create a new wallet, derive an account, check its balance, then dry-run a transfer:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
xl1-wallet create --label primary
|
|
41
|
+
xl1-wallet account derive 0 --label main
|
|
42
|
+
xl1-wallet balance 0
|
|
43
|
+
xl1-wallet send 0x0000000000000000000000000000000000000000 1 --xl1 --dry-run
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Import an existing recovery phrase instead:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
xl1-wallet import --label primary --phrase "test test test test test test test test test test test junk"
|
|
50
|
+
xl1-wallet use <wallet-id>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Use the same wallet CLI through Aries:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
aries wallet balance 0
|
|
57
|
+
aries wallet send 0x0000000000000000000000000000000000000000 1.25 --milli --json
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Wallet Storage
|
|
61
|
+
|
|
62
|
+
Wallet CLI data is stored under `~/.xl1/wallet/cli` by default.
|
|
63
|
+
|
|
64
|
+
| Variable | Purpose |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `XL1_WALLET_HOME` | Overrides the wallet storage directory. |
|
|
67
|
+
| `ARIES_WALLET_HOME` | Legacy fallback storage override. Used only when `XL1_WALLET_HOME` is not set. |
|
|
68
|
+
| `ARIES_WALLET_PASSWORD` | Supplies the wallet password for non-interactive runs and tests. |
|
|
69
|
+
|
|
70
|
+
Wallet seed phrases are encrypted at rest. Commands that need private key access prompt for the wallet password unless `ARIES_WALLET_PASSWORD` is set.
|
|
71
|
+
|
|
72
|
+
`unlock` stores a short-lived encrypted session so follow-up commands can run without repeatedly prompting:
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
xl1-wallet unlock --ttl 900
|
|
76
|
+
xl1-wallet lock
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Networks
|
|
80
|
+
|
|
81
|
+
The CLI ships with XL1 mainnet and XL1 Sequence testnet network definitions.
|
|
82
|
+
|
|
83
|
+
| ID | Label | RPC URL |
|
|
84
|
+
| --- | --- | --- |
|
|
85
|
+
| `xl1-mainnet` | `XL1 (Mainnet)` | `https://api.chain.xyo.network/rpc` |
|
|
86
|
+
| `xl1-sequence` | `XL1 Sequence (Testnet)` | `https://beta.api.chain.xyo.network/rpc` |
|
|
87
|
+
|
|
88
|
+
List and switch networks:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
xl1-wallet network list
|
|
92
|
+
xl1-wallet network use xl1-sequence
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Add a local or custom network:
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
xl1-wallet network add local http://127.0.0.1:8080/rpc --label "Local XL1" --chain-id 0x1234
|
|
99
|
+
xl1-wallet network use local
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Remove a custom network:
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
xl1-wallet network remove local
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Commands
|
|
109
|
+
|
|
110
|
+
### Wallets
|
|
111
|
+
|
|
112
|
+
| Command | Description |
|
|
113
|
+
| --- | --- |
|
|
114
|
+
| `xl1-wallet create` | Create a new wallet. |
|
|
115
|
+
| `xl1-wallet import` | Import a recovery phrase. |
|
|
116
|
+
| `xl1-wallet export` | Print a wallet recovery phrase after password confirmation. |
|
|
117
|
+
| `xl1-wallet list` | List wallets in the current wallet home. |
|
|
118
|
+
| `xl1-wallet use <id>` | Set the active wallet. |
|
|
119
|
+
| `xl1-wallet rename <id> <label>` | Rename a wallet. |
|
|
120
|
+
| `xl1-wallet remove <id>` | Remove a wallet from local storage. |
|
|
121
|
+
| `xl1-wallet reset` | Delete local wallet CLI data after confirmation. |
|
|
122
|
+
| `xl1-wallet unlock` | Cache an encrypted wallet session for a limited time. |
|
|
123
|
+
| `xl1-wallet lock` | Clear the cached wallet session. |
|
|
124
|
+
| `xl1-wallet password change` | Change the active wallet password. |
|
|
125
|
+
|
|
126
|
+
Examples:
|
|
127
|
+
|
|
128
|
+
```sh
|
|
129
|
+
xl1-wallet create --label primary
|
|
130
|
+
xl1-wallet import --label recovery --phrase "..."
|
|
131
|
+
xl1-wallet list
|
|
132
|
+
xl1-wallet use <wallet-id>
|
|
133
|
+
xl1-wallet export --id <wallet-id>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Accounts
|
|
137
|
+
|
|
138
|
+
| Command | Description |
|
|
139
|
+
| --- | --- |
|
|
140
|
+
| `xl1-wallet account derive <offset>` | Derive and store an account at an offset. |
|
|
141
|
+
| `xl1-wallet account list` | List stored accounts for the active wallet. |
|
|
142
|
+
| `xl1-wallet account show <offset>` | Show a derived account address. |
|
|
143
|
+
| `xl1-wallet account label <offset> <label>` | Label an account. |
|
|
144
|
+
| `xl1-wallet account remove <offset>` | Remove a stored account record. |
|
|
145
|
+
|
|
146
|
+
Examples:
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
xl1-wallet account derive 0 --label main
|
|
150
|
+
xl1-wallet account show 0
|
|
151
|
+
xl1-wallet account list
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Balances And Transfers
|
|
155
|
+
|
|
156
|
+
| Command | Description |
|
|
157
|
+
| --- | --- |
|
|
158
|
+
| `xl1-wallet balance [offset]` | Get the XL1 balance for an account offset. |
|
|
159
|
+
| `xl1-wallet send <recipient> <amount>` | Send XL1 from an account in the active wallet to an address. |
|
|
160
|
+
|
|
161
|
+
Examples:
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
xl1-wallet balance 0
|
|
165
|
+
xl1-wallet send 0x1111111111111111111111111111111111111111 1 --xl1
|
|
166
|
+
xl1-wallet send 0x1111111111111111111111111111111111111111 250 --micro --offset 0
|
|
167
|
+
xl1-wallet send 0x1111111111111111111111111111111111111111 1.5 --milli --dry-run
|
|
168
|
+
xl1-wallet send 0x1111111111111111111111111111111111111111 1000000000000000000 --atto --json
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
`send` supports `--dry-run`, which signs and validates the transaction plan without submitting it to the network.
|
|
172
|
+
|
|
173
|
+
Use `--json` when scripting:
|
|
174
|
+
|
|
175
|
+
```sh
|
|
176
|
+
xl1-wallet send 0x1111111111111111111111111111111111111111 1 --xl1 --json
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Amount Units
|
|
180
|
+
|
|
181
|
+
Amounts are converted to attoXL1 before signing.
|
|
182
|
+
|
|
183
|
+
| Flag | Unit | Atto multiplier | Fractional input |
|
|
184
|
+
| --- | --- | ---: | --- |
|
|
185
|
+
| `--xl1` | XL1 | `1000000000000000000` | Yes |
|
|
186
|
+
| `--milli` | milliXL1 | `1000000000000000` | Yes |
|
|
187
|
+
| `--micro` | microXL1 | `1000000000000` | Yes |
|
|
188
|
+
| `--nano` | nanoXL1 | `1000000000` | Yes |
|
|
189
|
+
| `--pico` | picoXL1 | `1000000` | Yes |
|
|
190
|
+
| `--femto` | femtoXL1 | `1000` | Yes |
|
|
191
|
+
| `--atto` | attoXL1 | `1` | No |
|
|
192
|
+
|
|
193
|
+
If no unit flag is supplied, `send` defaults to `--xl1`.
|
|
194
|
+
|
|
195
|
+
### Contacts
|
|
196
|
+
|
|
197
|
+
| Command | Description |
|
|
198
|
+
| --- | --- |
|
|
199
|
+
| `xl1-wallet contact add <address> <label>` | Save a contact. |
|
|
200
|
+
| `xl1-wallet contact list` | List saved contacts. |
|
|
201
|
+
| `xl1-wallet contact rename <address> <label>` | Rename a contact. |
|
|
202
|
+
| `xl1-wallet contact remove <address>` | Remove a contact. |
|
|
203
|
+
|
|
204
|
+
Examples:
|
|
205
|
+
|
|
206
|
+
```sh
|
|
207
|
+
xl1-wallet contact add 0x1111111111111111111111111111111111111111 treasury
|
|
208
|
+
xl1-wallet contact list
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Transaction Files And Payloads
|
|
212
|
+
|
|
213
|
+
Use `sign` to sign a payload JSON file directly:
|
|
214
|
+
|
|
215
|
+
```sh
|
|
216
|
+
xl1-wallet sign payload.json --output signed-payload.json
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Use `tx sign` and `tx broadcast` for XL1 transaction files. This path supports on-chain payloads. Replace the `chain` value with the target XL1 chain id.
|
|
220
|
+
|
|
221
|
+
```json
|
|
222
|
+
{
|
|
223
|
+
"chain": "0x1234",
|
|
224
|
+
"nbf": 0,
|
|
225
|
+
"exp": 4102444800,
|
|
226
|
+
"onChainPayloads": [
|
|
227
|
+
{
|
|
228
|
+
"schema": "network.xyo.example",
|
|
229
|
+
"payload": {
|
|
230
|
+
"message": "hello xl1"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
```sh
|
|
238
|
+
xl1-wallet tx sign unsigned-transaction.json --output signed-transaction.json
|
|
239
|
+
xl1-wallet tx broadcast signed-transaction.json
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### JWTs
|
|
243
|
+
|
|
244
|
+
Create, verify, and decode wallet-signed JWTs:
|
|
245
|
+
|
|
246
|
+
```sh
|
|
247
|
+
xl1-wallet jwt create --audience https://example.com --claim role=operator
|
|
248
|
+
xl1-wallet jwt verify <token> --audience https://example.com
|
|
249
|
+
xl1-wallet jwt decode <token>
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Create a JWT from a payload file:
|
|
253
|
+
|
|
254
|
+
```sh
|
|
255
|
+
xl1-wallet jwt create \
|
|
256
|
+
--audience https://example.com \
|
|
257
|
+
--schema network.xyo.example \
|
|
258
|
+
--payload-file payload.json \
|
|
259
|
+
--output token.jwt
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Backup And Reset
|
|
263
|
+
|
|
264
|
+
Backup exports and imports wallet CLI metadata such as contacts and address books. It does not replace saving wallet recovery phrases.
|
|
265
|
+
|
|
266
|
+
```sh
|
|
267
|
+
xl1-wallet backup export wallet-metadata.json
|
|
268
|
+
xl1-wallet backup import wallet-metadata.json
|
|
269
|
+
xl1-wallet reset
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Output And Automation
|
|
273
|
+
|
|
274
|
+
Most commands print readable text by default. Commands intended for automation, such as `send`, also support JSON output:
|
|
275
|
+
|
|
276
|
+
```sh
|
|
277
|
+
xl1-wallet send 0x1111111111111111111111111111111111111111 1 --xl1 --json
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
For isolated test runs, set a temporary wallet home:
|
|
281
|
+
|
|
282
|
+
```sh
|
|
283
|
+
XL1_WALLET_HOME="$(mktemp -d)" ARIES_WALLET_PASSWORD="test-password" xl1-wallet create
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Development
|
|
287
|
+
|
|
288
|
+
Compile the package:
|
|
289
|
+
|
|
290
|
+
```sh
|
|
291
|
+
pnpm xy compile @xyo-network/wallet-xl1-cli
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Run the wallet CLI test suite:
|
|
295
|
+
|
|
296
|
+
```sh
|
|
297
|
+
pnpm exec vitest run packages/wallet-cli-lib/src/spec/*.spec.ts --project node
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Smoke-test the built bin:
|
|
301
|
+
|
|
302
|
+
```sh
|
|
303
|
+
node packages/wallet-cli/dist/bin/wallet.mjs --help
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## License
|
|
307
|
+
|
|
308
|
+
LGPL-3.0-only
|
|
309
|
+
|
|
310
|
+
[license-badge]: https://img.shields.io/npm/l/@xyo-network/wallet-xl1-cli.svg
|
|
311
|
+
[license-link]: ./package.json
|
|
312
|
+
[npm-badge]: https://img.shields.io/npm/v/@xyo-network/wallet-xl1-cli.svg
|
|
313
|
+
[npm-link]: https://www.npmjs.com/package/@xyo-network/wallet-xl1-cli
|
|
314
|
+
|
|
315
|
+
## Machine-readable output
|
|
316
|
+
|
|
317
|
+
The read/listing commands accept `--json` to emit structured JSON instead of formatted text:
|
|
318
|
+
|
|
319
|
+
```sh
|
|
320
|
+
xl1-wallet list --json
|
|
321
|
+
xl1-wallet account list --json
|
|
322
|
+
xl1-wallet account show 0 --json
|
|
323
|
+
xl1-wallet balance --json
|
|
324
|
+
xl1-wallet network list --json
|
|
325
|
+
xl1-wallet contact list --json
|
|
326
|
+
xl1-wallet export --json
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
In `--json` mode the command prints only JSON to stdout (no decoration), so the output can be piped directly into `jq` or another parser.
|