@onekeyfe/hardware-cli 1.1.25-alpha.0

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.
@@ -0,0 +1,478 @@
1
+ ---
2
+ name: hardware-signing
3
+ description: Multi-chain address generation and transaction signing using OneKey
4
+ hardware wallet. Use whenever the user wants to get a receive address, sign
5
+ a transaction, sign a message, or verify an address on any supported blockchain.
6
+ All signing operations require physical confirmation on the hardware device.
7
+ keywords: [sign, address, transaction, message, bitcoin, ethereum, solana, verify,
8
+ btc, eth, sol, evm, cosmos, cardano, polkadot, tron, aptos, sui, near, xrp,
9
+ stellar, ton, nostr]
10
+ ---
11
+
12
+ ## Pre-flight Checks
13
+
14
+ Every time before running any `onekey-hw` command, follow these steps in order.
15
+
16
+ 1. **Check CLI installed**: Run `onekey-hw --version`.
17
+ - Not found → install: `npm install -g @onekeyfe/hardware-cli`
18
+
19
+ 2. **Check device connected**: Run `onekey-hw search --json`.
20
+ - No device → guide troubleshooting (USB cable, unlock device, different port).
21
+ - Device in bootloader mode → cannot sign, guide to `hardware-firmware` skill.
22
+ - Device not initialized → guide user to set up device first.
23
+
24
+ ## Device Interaction — IMPORTANT
25
+
26
+ **All signing commands block while waiting for physical interaction on the device.**
27
+ You MUST follow this pattern for every signing/address command:
28
+
29
+ 1. **BEFORE running the command** → Tell the user:
30
+ "I'm about to [get your address / sign this transaction]. You will need to
31
+ confirm on your OneKey device. You may also need to enter your PIN if the
32
+ device is locked."
33
+
34
+ 2. **Run the command** with `timeout: 120000` (120 seconds minimum).
35
+ The user sees real-time `[onekey-hw]` prompts in their terminal via stderr.
36
+
37
+ 3. **If the command times out or returns `success: false`** → The user likely
38
+ did not confirm on the device. Ask if they want to retry. Do NOT retry automatically.
39
+
40
+ ## Security Rules — ABSOLUTE
41
+
42
+ ### Physical Confirmation Required
43
+
44
+ - ALL signing operations display transaction details on the hardware device screen.
45
+ - The user MUST physically press the confirm button on the device.
46
+ - NEVER tell the user to "just press confirm" without showing them what they should
47
+ verify on the device screen.
48
+ - If a signing request times out, it means the user rejected or did not confirm.
49
+
50
+ ### Address Verification
51
+
52
+ - When generating addresses for receiving funds, ALWAYS use `--show-on-device true`
53
+ so the user can verify the address matches on the hardware screen.
54
+ - NEVER trust an address that wasn't verified on-device.
55
+
56
+ ### Transaction Verification
57
+
58
+ - Before signing, clearly display to the user:
59
+ - Recipient address
60
+ - Amount and token
61
+ - Network/chain
62
+ - Fee estimate (if available)
63
+ - The device screen will show the same details — instruct user to verify they match.
64
+
65
+ ## Supported Chains
66
+
67
+ | Chain | `--chain` Value | Address | Sign TX | Sign Message |
68
+ |---|---|---|---|---|
69
+ | Ethereum / EVM | `evm` | Yes | Yes | Yes (+ EIP-712) |
70
+ | Bitcoin | `btc` | Yes | Yes (+ PSBT) | Yes |
71
+ | Solana | `sol` | Yes | Yes | Yes |
72
+ | Tron | `tron` | Yes | Yes | Yes |
73
+ | Cosmos | `cosmos` | Yes | Yes | No |
74
+ | Cardano | `cardano` | Yes | Yes | Yes |
75
+ | Polkadot | `polkadot` | Yes | Yes | No |
76
+ | Aptos | `aptos` | Yes | Yes | Yes |
77
+ | Sui | `sui` | Yes | Yes | Yes |
78
+ | Near | `near` | Yes | Yes | No |
79
+ | XRP | `xrp` | Yes | Yes | No |
80
+ | Stellar | `stellar` | Yes | Yes | No |
81
+ | TON | `ton` | Yes | No | Yes (transfer-style*) |
82
+ | Nostr | `nostr` | Public Key | No | Yes (+ Schnorr) |
83
+ | Filecoin | `filecoin` | Yes | Yes | No |
84
+ | Kaspa | `kaspa` | Yes | Yes | No |
85
+ | Algorand | `algo` | Yes | Yes | No |
86
+ | Conflux | `conflux` | Yes | Yes | Yes |
87
+ | Nervos | `nervos` | Yes | Yes | No |
88
+ | Alephium | `alephium` | Yes | Yes | Yes |
89
+ | Neo | `neo` | Yes | Yes | No |
90
+ | Starcoin | `starcoin` | Yes | Yes | Yes |
91
+ | NEM | `nem` | Yes | Yes | No |
92
+ | Dynex | `dnx` | Yes | Yes | No |
93
+ | SCDO | `scdo` | Yes | Yes | Yes |
94
+ | Benfen | `benfen` | Yes | Yes | Yes |
95
+ | Nexa | `nexa` | Yes | Yes | No |
96
+
97
+ ## Parameter Rules
98
+
99
+ ### BIP44 Derivation Paths
100
+
101
+ Default paths per chain (user can override with `--path`):
102
+
103
+ | Chain | Default Path | Description |
104
+ |---|---|---|
105
+ | EVM | `m/44'/60'/0'/0/0` | Standard Ethereum |
106
+ | BTC (segwit) | `m/84'/0'/0'/0/0` | Native SegWit (bech32) |
107
+ | BTC (legacy) | `m/44'/0'/0'/0/0` | Legacy P2PKH |
108
+ | BTC (taproot) | `m/86'/0'/0'/0/0` | Taproot P2TR |
109
+ | SOL | `m/44'/501'/0'/0'` | Solana |
110
+ | COSMOS | `m/44'/118'/0'/0/0` | Cosmos Hub |
111
+ | CARDANO | `m/1852'/1815'/0'/0/0` | Cardano Shelley |
112
+
113
+ If the user doesn't specify a path, use the chain's default. If they specify
114
+ an account index (e.g., "second account"), adjust the account segment
115
+ (e.g., `m/44'/60'/1'/0/0`).
116
+
117
+ ### Amount Units
118
+
119
+ For chains that require amounts in transaction data:
120
+ - ALWAYS use the human-readable unit in output display.
121
+ - Transaction data is passed as the chain requires (hex for EVM, etc.).
122
+
123
+ ## Commands
124
+
125
+ ### `onekey-hw get-address`
126
+
127
+ Get a cryptocurrency address from the connected hardware wallet.
128
+
129
+ ```bash
130
+ onekey-hw get-address \
131
+ --chain <chain> \
132
+ [--path <bip44-path>] \
133
+ [--show-on-device <bool>] \
134
+ [--connect-id <id>]
135
+ ```
136
+
137
+ | Parameter | Required | Description |
138
+ |---|---|---|
139
+ | `--chain` | Yes | Target blockchain (see supported chains table) |
140
+ | `--path` | No | BIP44 derivation path (uses chain default if omitted) |
141
+ | `--show-on-device` | No | Display address on device for verification (default: true) |
142
+ | `--connect-id` | No | Device connection ID (auto-detected if single device) |
143
+
144
+ **Returns:**
145
+ ```json
146
+ {
147
+ "success": true,
148
+ "payload": {
149
+ "address": "0x1234...abcd",
150
+ "path": "m/44'/60'/0'/0/0"
151
+ }
152
+ }
153
+ ```
154
+
155
+ **Agent notes:**
156
+ - Default `--show-on-device` is true. When true, instruct user:
157
+ "Please verify the address shown on your OneKey device screen matches."
158
+ - For receiving funds, ALWAYS verify on device.
159
+ - For batch operations (multiple addresses), may set `--show-on-device false` for speed.
160
+
161
+ ### `onekey-hw get-public-key`
162
+
163
+ Get public key (for chains that support it: EVM, BTC, Aptos, Cosmos, Sui, etc.).
164
+
165
+ ```bash
166
+ onekey-hw get-public-key \
167
+ --chain <chain> \
168
+ [--path <bip44-path>] \
169
+ [--connect-id <id>]
170
+ ```
171
+
172
+ **Returns:**
173
+ ```json
174
+ {
175
+ "success": true,
176
+ "payload": {
177
+ "publicKey": "04abcdef...",
178
+ "path": "m/44'/60'/0'/0/0"
179
+ }
180
+ }
181
+ ```
182
+
183
+ ### `onekey-hw sign-transaction`
184
+
185
+ Sign a blockchain transaction using the hardware wallet. Requires physical
186
+ confirmation on the device.
187
+
188
+ ```bash
189
+ onekey-hw sign-transaction \
190
+ --chain <chain> \
191
+ --tx <transaction-json> \
192
+ [--path <bip44-path>] \
193
+ [--connect-id <id>]
194
+ ```
195
+
196
+ | Parameter | Required | Description |
197
+ |---|---|---|
198
+ | `--chain` | Yes | Target blockchain |
199
+ | `--tx` | Yes | Transaction data (JSON object, chain-dependent) |
200
+ | `--path` | No | BIP44 derivation path |
201
+ | `--connect-id` | No | Device connection ID |
202
+
203
+ **EVM Transaction Example (EIP-1559):**
204
+ ```bash
205
+ onekey-hw sign-transaction \
206
+ --chain evm \
207
+ --tx '{"to":"0xAbC...","value":"0xf4240","data":"0x","chainId":1,"nonce":"0x0","maxFeePerGas":"0x14","maxPriorityFeePerGas":"0x0","gasLimit":"0x5208"}'
208
+ ```
209
+
210
+ **BTC Transaction Example (inputs/outputs/refTxs format):**
211
+ ```bash
212
+ onekey-hw sign-transaction \
213
+ --chain btc \
214
+ --tx '{"coin":"btc","inputs":[{"address_n":[2147483692,2147483648,2147483650,1,0],"prev_index":0,"prev_hash":"b035d89d..."}],"outputs":[{"address":"18WL2iZ...","amount":"200000","script_type":"PAYTOADDRESS"}],"refTxs":[...]}'
215
+ ```
216
+
217
+ > **Note:** BTC uses `inputs/outputs/refTxs` format, NOT raw hex or PSBT.
218
+ > For PSBT signing, use `sign-psbt` instead.
219
+
220
+ **Agent notes:**
221
+ - This is the most critical operation — requires physical device confirmation.
222
+ - Before calling, clearly display to the user what will be signed:
223
+ "You are about to sign: Send 0.01 ETH to 0xAbC... on Ethereum Mainnet"
224
+ - Inform user: "Please review and confirm the transaction on your OneKey device."
225
+ - If the call times out or returns `{ success: false }`, the user likely rejected
226
+ on device — do NOT retry automatically.
227
+ - Transaction format varies per chain — refer to the SDK documentation for each chain.
228
+
229
+ ### `onekey-hw sign-message`
230
+
231
+ Sign an arbitrary message (for chains that support message signing).
232
+
233
+ ```bash
234
+ onekey-hw sign-message \
235
+ --chain <chain> \
236
+ --message <message> \
237
+ [--path <bip44-path>] \
238
+ [--connect-id <id>]
239
+ ```
240
+
241
+ | Parameter | Required | Description |
242
+ |---|---|---|
243
+ | `--chain` | Yes | Target blockchain |
244
+ | `--message` | Yes | Message to sign (string or hex) |
245
+ | `--path` | No | BIP44 derivation path |
246
+ | `--connect-id` | No | Device connection ID |
247
+
248
+ **Agent notes:**
249
+ - Device will show the message for user verification.
250
+ - **TON note**: `tonSignMessage` is a transfer-signing method, not arbitrary message
251
+ signing. Pass `--message` as JSON: `'{"destination":"UQ...","tonAmount":100,"seqno":0,"expireAt":1234567890}'`.
252
+
253
+ ### `onekey-hw sign-typed-data`
254
+
255
+ Sign EIP-712 typed data (EVM only).
256
+
257
+ ```bash
258
+ onekey-hw sign-typed-data \
259
+ --data <eip712-json> \
260
+ [--path <bip44-path>] \
261
+ [--metamask-v4-compat] \
262
+ [--connect-id <id>]
263
+ ```
264
+
265
+ | Parameter | Required | Description |
266
+ |---|---|---|
267
+ | `--data` | Yes | EIP-712 typed data as JSON |
268
+ | `--path` | No | BIP44 derivation path (default: m/44'/60'/0'/0/0) |
269
+ | `--metamask-v4-compat` | No | MetaMask V4 compatibility mode (default: true) |
270
+
271
+ ### `onekey-hw sign-psbt`
272
+
273
+ Sign a Bitcoin PSBT (Partially Signed Bitcoin Transaction).
274
+ Only supported on Pro (>= 4.9.3) and Classic1s (>= 3.10.1).
275
+
276
+ ```bash
277
+ onekey-hw sign-psbt \
278
+ --psbt <hex-encoded-psbt> \
279
+ [--coin <coin>] \
280
+ [--connect-id <id>]
281
+ ```
282
+
283
+ | Parameter | Required | Description |
284
+ |---|---|---|
285
+ | `--psbt` | Yes | Hex-encoded PSBT data |
286
+ | `--coin` | No | Bitcoin network: btc, ltc, etc. (default: btc) |
287
+
288
+ **Agent notes:**
289
+ - Simpler than `sign-transaction --chain btc` (no need to construct inputs/outputs/refTxs).
290
+ - Classic1s has a limit of 5 UTXOs per PSBT.
291
+ - Preferred method when the application provides PSBT format.
292
+
293
+ ### `onekey-hw verify-message`
294
+
295
+ Verify a signed message on-device (BTC, EVM, Starcoin).
296
+
297
+ ```bash
298
+ onekey-hw verify-message \
299
+ --chain <chain> \
300
+ --address <address> \
301
+ --message <message> \
302
+ --signature <signature> \
303
+ [--connect-id <id>]
304
+ ```
305
+
306
+ | Parameter | Required | Description |
307
+ |---|---|---|
308
+ | `--chain` | Yes | btc, evm, or starcoin |
309
+ | `--address` | Yes | Signer address (or publicKey for starcoin) |
310
+ | `--message` | Yes | Original message |
311
+ | `--signature` | Yes | Signature to verify |
312
+
313
+ ### `onekey-hw batch-get-address`
314
+
315
+ Get addresses for multiple chains/paths in a single session.
316
+
317
+ ```bash
318
+ onekey-hw batch-get-address \
319
+ --bundle <json-array> \
320
+ [--connect-id <id>]
321
+ ```
322
+
323
+ **Example bundle:**
324
+ ```json
325
+ [
326
+ { "chain": "evm", "path": "m/44'/60'/0'/0/0", "showOnDevice": false },
327
+ { "chain": "btc", "path": "m/84'/0'/0'/0/0", "showOnDevice": false },
328
+ { "chain": "sol", "path": "m/44'/501'/0'/0'", "showOnDevice": false }
329
+ ]
330
+ ```
331
+
332
+ **Agent notes:**
333
+ - Batch mode disables on-device verification for speed.
334
+ - Useful for portfolio dashboards or multi-chain wallet setup.
335
+
336
+ ## Chain-Specific Commands
337
+
338
+ These commands wrap chain-specific SDK methods that don't fit the generic
339
+ `sign-message` / `sign-transaction` pattern.
340
+
341
+ ### `onekey-hw evm-sign-eip712`
342
+
343
+ Sign EIP-712 message by pre-computed domain and message hashes.
344
+
345
+ ```bash
346
+ onekey-hw evm-sign-eip712 --domain-hash <hex> --message-hash <hex> [--path <path>]
347
+ ```
348
+
349
+ ### `onekey-hw sol-sign-offchain`
350
+
351
+ Sign a Solana off-chain message.
352
+
353
+ ```bash
354
+ onekey-hw sol-sign-offchain --message-hex <hex> [--path <path>]
355
+ ```
356
+
357
+ ### `onekey-hw nostr-encrypt` / `nostr-decrypt`
358
+
359
+ Encrypt/decrypt Nostr NIP-04 messages.
360
+
361
+ ```bash
362
+ onekey-hw nostr-encrypt --pubkey <hex> --plaintext <text> [--path <path>]
363
+ onekey-hw nostr-decrypt --pubkey <hex> --ciphertext <text> [--path <path>]
364
+ ```
365
+
366
+ ### `onekey-hw nostr-sign-schnorr`
367
+
368
+ Sign a Schnorr signature (BIP-340) for Nostr.
369
+
370
+ ```bash
371
+ onekey-hw nostr-sign-schnorr --hash <hex> [--path <path>]
372
+ ```
373
+
374
+ ### `onekey-hw lnurl-auth`
375
+
376
+ Authenticate with a service using LNURL-auth (Lightning Network).
377
+
378
+ ```bash
379
+ onekey-hw lnurl-auth --domain <domain> --k1 <hex>
380
+ ```
381
+
382
+ ### `onekey-hw conflux-sign-cip23`
383
+
384
+ Sign a Conflux CIP-23 structured message.
385
+
386
+ ```bash
387
+ onekey-hw conflux-sign-cip23 --domain-hash <hex> --message-hash <hex> [--path <path>]
388
+ ```
389
+
390
+ ### `onekey-hw aptos-sign-in`
391
+
392
+ Sign an Aptos sign-in message (wallet authentication).
393
+
394
+ ```bash
395
+ onekey-hw aptos-sign-in --payload <text> [--path <path>]
396
+ ```
397
+
398
+ ### `onekey-hw ton-sign-proof`
399
+
400
+ Sign a TON Connect proof for wallet authentication.
401
+
402
+ ```bash
403
+ onekey-hw ton-sign-proof --appdomain <domain> --expire-at <timestamp> [--comment <text>] [--path <path>]
404
+ ```
405
+
406
+ ## Workflows
407
+
408
+ ### Get Receive Address
409
+
410
+ ```
411
+ User: "Give me my Ethereum address"
412
+
413
+ Step 1 — Ensure device connected
414
+ → onekey-hw search --json
415
+ → onekey-hw status --connect-id <id>
416
+
417
+ Step 2 — Get address with on-device verification
418
+ → onekey-hw get-address --chain evm --show-on-device true --connect-id <id>
419
+ → "Please verify the address on your OneKey device screen."
420
+ → Display address to user
421
+ ```
422
+
423
+ ### Sign an EVM Transaction
424
+
425
+ ```
426
+ User: "Sign this transaction: send 0.1 ETH to 0xAbc..."
427
+
428
+ Step 1 — Ensure device connected
429
+ → onekey-hw search --json
430
+
431
+ Step 2 — Display transaction details to user
432
+ → "You are about to sign: Send 0.1 ETH to 0xAbc... on Ethereum"
433
+
434
+ Step 3 — Wait for user confirmation in chat
435
+ → User says "yes" / "confirm"
436
+
437
+ Step 4 — Sign
438
+ → onekey-hw sign-transaction --chain evm --tx '{"to":"0xAbc...","value":"0x16345785D8A0000",...}' --connect-id <id>
439
+ → "Please review and confirm on your OneKey device."
440
+
441
+ Step 5 — Return signature
442
+ → Display signed transaction
443
+ ```
444
+
445
+ ### Multi-Chain Address Setup
446
+
447
+ ```
448
+ User: "Set up my wallet with addresses for ETH, BTC, and SOL"
449
+
450
+ Step 1 — Ensure device connected
451
+ → onekey-hw search --json
452
+
453
+ Step 2 — Batch get addresses
454
+ → onekey-hw batch-get-address --bundle '[
455
+ {"chain":"evm","path":"m/44'/60'/0'/0/0","showOnDevice":false},
456
+ {"chain":"btc","path":"m/84'/0'/0'/0/0","showOnDevice":false},
457
+ {"chain":"sol","path":"m/44'/501'/0'/0'","showOnDevice":false}
458
+ ]' --connect-id <id>
459
+
460
+ Step 3 — Present results
461
+ → Display all addresses in a clean table
462
+ ```
463
+
464
+ ## When To Use
465
+
466
+ - User wants to get a cryptocurrency address for receiving funds.
467
+ - User wants to sign any blockchain transaction.
468
+ - User wants to sign or verify a message.
469
+ - User needs public keys for multi-sig or advanced setups.
470
+ - User wants addresses across multiple chains.
471
+
472
+ ## When NOT To Use
473
+
474
+ - User wants to connect or search for devices → use `hardware-device`.
475
+ - User wants to update firmware → use `hardware-firmware`.
476
+ - User wants to change PIN/passphrase → use `hardware-security`.
477
+ - User wants to broadcast a signed transaction → this skill only SIGNS,
478
+ broadcasting is handled by the application layer.