@vultisig/cli 0.2.0-beta.9 → 0.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,123 @@
1
1
  # @vultisig/cli
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#64](https://github.com/vultisig/vultisig-sdk/pull/64) [`a36a7f6`](https://github.com/vultisig/vultisig-sdk/commit/a36a7f614c03e32ebc7e843cbf1ab30b6be0d4af) Thanks [@bornslippynuxx](https://github.com/bornslippynuxx)! - feat(sdk): add broadcastRawTx() for broadcasting pre-signed transactions
8
+
9
+ Adds `broadcastRawTx()` method supporting all chain families:
10
+ - EVM: Ethereum, Polygon, BSC, Arbitrum, Base, etc. (hex-encoded)
11
+ - UTXO: Bitcoin, Litecoin, Dogecoin, etc. (hex-encoded)
12
+ - Solana: Base58 or Base64 encoded transaction bytes
13
+ - Cosmos: JSON `{tx_bytes}` or raw base64 protobuf (10 chains)
14
+ - TON: BOC as base64 string
15
+ - Polkadot: Hex-encoded extrinsic
16
+ - Ripple: Hex-encoded transaction blob
17
+ - Sui: JSON `{unsignedTx, signature}`
18
+ - Tron: JSON transaction object
19
+
20
+ CLI commands added:
21
+ - `vultisig sign --chain <chain> --bytes <base64>` - sign pre-hashed data
22
+ - `vultisig broadcast --chain <chain> --raw-tx <data>` - broadcast raw tx
23
+
24
+ Documentation updated with complete workflow examples for EVM, UTXO, Solana, and Sui.
25
+
26
+ - [#62](https://github.com/vultisig/vultisig-sdk/pull/62) [`008db7f`](https://github.com/vultisig/vultisig-sdk/commit/008db7fb27580ec78df3bbc41b25aac24924ffd8) Thanks [@bornslippynuxx](https://github.com/bornslippynuxx)! - feat: separate unlock and export passwords in CLI export command
27
+
28
+ The export command now has two distinct password options:
29
+ - `--password`: Unlocks the vault (decrypts stored keyshares for encrypted vaults)
30
+ - `--exportPassword`: Encrypts the exported file (defaults to `--password` if not specified)
31
+
32
+ This fixes the "Password required but callback returned empty value" error when exporting encrypted vaults.
33
+
34
+ Password resolution now uses an in-memory cache that persists across SDK callbacks, allowing the CLI to pre-cache the unlock password before vault loading.
35
+
36
+ - [#60](https://github.com/vultisig/vultisig-sdk/pull/60) [`b4cf357`](https://github.com/vultisig/vultisig-sdk/commit/b4cf357c98ef493b48c807e5bb45cd40b9893295) Thanks [@bornslippynuxx](https://github.com/bornslippynuxx)! - feat: Add SecureVault support for multi-device MPC vaults
37
+ - Implement SecureVault.create() for multi-device keygen ceremony
38
+ - Add RelaySigningService for coordinated signing via relay server
39
+ - Implement SecureVault.sign() and signBytes() methods
40
+ - Add QR code generation for mobile app pairing (compatible with Vultisig iOS/Android)
41
+ - CLI: Add `vault create --type secure` with terminal QR display
42
+ - CLI: Support secure vault signing with device coordination
43
+ - Add comprehensive unit, integration, and E2E tests
44
+
45
+ - [#68](https://github.com/vultisig/vultisig-sdk/pull/68) [`7979f3c`](https://github.com/vultisig/vultisig-sdk/commit/7979f3c502ea04db3c3de551bee297b8a9f9808b) Thanks [@bornslippynuxx](https://github.com/bornslippynuxx)! - Add seedphrase (BIP39 mnemonic) import functionality
46
+
47
+ This release adds the ability to import existing wallets from BIP39 mnemonic phrases (12 or 24 words) into Vultisig vaults, mirroring the iOS implementation.
48
+
49
+ **New SDK Methods:**
50
+ - `sdk.validateSeedphrase()` - Validate a BIP39 mnemonic phrase
51
+ - `sdk.discoverChainsFromSeedphrase()` - Discover chains with balances before import
52
+ - `sdk.importSeedphraseAsFastVault()` - Import as FastVault (2-of-2 with VultiServer)
53
+ - `sdk.importSeedphraseAsSecureVault()` - Import as SecureVault (N-of-M multi-device)
54
+
55
+ **Features:**
56
+ - Chain discovery with progress callbacks to find existing balances
57
+ - Auto-enable chains with balances during import
58
+ - EdDSA key transformation using SHA-512 clamping for Schnorr TSS compatibility
59
+ - Full ECDSA (secp256k1) and EdDSA (ed25519) master key derivation
60
+
61
+ **New exported types:**
62
+ - `SeedphraseValidation`, `ChainDiscoveryProgress`, `ChainDiscoveryResult`
63
+ - `ChainDiscoveryPhase`, `DerivedMasterKeys`
64
+ - `ImportSeedphraseAsFastVaultOptions`, `ImportSeedphraseAsSecureVaultOptions`
65
+ - `SeedphraseImportResult`
66
+
67
+ **New services:**
68
+ - `SeedphraseValidator` - BIP39 validation using WalletCore
69
+ - `MasterKeyDeriver` - Key derivation from mnemonic
70
+ - `ChainDiscoveryService` - Balance scanning across chains
71
+ - `FastVaultSeedphraseImportService` - FastVault import orchestration
72
+ - `SecureVaultSeedphraseImportService` - SecureVault import orchestration
73
+
74
+ **New CLI Commands:**
75
+ - `vultisig import-seedphrase fast` - Import as FastVault (2-of-2 with VultiServer)
76
+ - `vultisig import-seedphrase secure` - Import as SecureVault (N-of-M multi-device)
77
+
78
+ **CLI Features:**
79
+ - Secure seedphrase input (masked with `*`)
80
+ - `--discover-chains` flag to scan for existing balances
81
+ - `--chains` flag to specify chains (comma-separated)
82
+ - Interactive shell support with tab completion
83
+ - Progress spinners during import
84
+
85
+ ### Patch Changes
86
+
87
+ - [#57](https://github.com/vultisig/vultisig-sdk/pull/57) [`22bb16b`](https://github.com/vultisig/vultisig-sdk/commit/22bb16be8421a51aa32da6c1166539015380651e) Thanks [@bornslippynuxx](https://github.com/bornslippynuxx)! - Optimize SDK bundling configuration
88
+ - Add terser minification (~60% bundle size reduction)
89
+ - Add clean script to remove stale dist files before builds
90
+ - Centralize duplicated onwarn handler in rollup config
91
+ - Add package.json exports for react-native and electron platforms
92
+
93
+ - [`cc96f64`](https://github.com/vultisig/vultisig-sdk/commit/cc96f64622a651eb6156f279afbbfe0aa4219179) - fix: re-release as alpha (0.1.0 was accidentally published as stable)
94
+
95
+ - [#55](https://github.com/vultisig/vultisig-sdk/pull/55) [`95ba10b`](https://github.com/vultisig/vultisig-sdk/commit/95ba10baf2dc2dc4ba8e48825f10f34ec275a73c) Thanks [@bornslippynuxx](https://github.com/bornslippynuxx)! - Replace development command references (`npm run wallet`) with production CLI name (`vultisig`) in all user-facing messages.
96
+
97
+ - [#55](https://github.com/vultisig/vultisig-sdk/pull/55) [`95ba10b`](https://github.com/vultisig/vultisig-sdk/commit/95ba10baf2dc2dc4ba8e48825f10f34ec275a73c) Thanks [@bornslippynuxx](https://github.com/bornslippynuxx)! - Fix interactive shell prompts by replacing REPL with readline to prevent stdin conflicts with inquirer
98
+
99
+ - [#58](https://github.com/vultisig/vultisig-sdk/pull/58) [`c9b7d88`](https://github.com/vultisig/vultisig-sdk/commit/c9b7d888e21e9db1b928ddc929294aa15157e476) Thanks [@bornslippynuxx](https://github.com/bornslippynuxx)! - Fix password prompt being swallowed by spinner during signing
100
+ - Add `--password` option to `send` and `swap` commands for non-interactive use
101
+ - Pre-unlock vault before signing spinner starts to prevent prompt interference
102
+ - Password prompt now appears before spinner when not provided via CLI flag
103
+
104
+ - [`9dcfb8b`](https://github.com/vultisig/vultisig-sdk/commit/9dcfb8b4b29de73b1301f791b50dc417a8f899f3) - fix: use yarn npm publish to properly resolve workspace protocols
105
+
106
+ - [`0985a37`](https://github.com/vultisig/vultisig-sdk/commit/0985a375c6009e2550231d759e84b576454ce759) - fix: use workspace:^ for SDK dependency to resolve correctly when publishing
107
+
108
+ - [#62](https://github.com/vultisig/vultisig-sdk/pull/62) [`008db7f`](https://github.com/vultisig/vultisig-sdk/commit/008db7fb27580ec78df3bbc41b25aac24924ffd8) Thanks [@bornslippynuxx](https://github.com/bornslippynuxx)! - Simplify export command by removing `--encrypt` and `--no-encrypt` flags. Password is now optional - if provided, vault is encrypted; if omitted or empty, vault is exported without encryption. Path argument now supports directories (appends SDK-generated filename).
109
+
110
+ - [#55](https://github.com/vultisig/vultisig-sdk/pull/55) [`95ba10b`](https://github.com/vultisig/vultisig-sdk/commit/95ba10baf2dc2dc4ba8e48825f10f34ec275a73c) Thanks [@bornslippynuxx](https://github.com/bornslippynuxx)! - Update browser example and CLI for new fast vault creation API
111
+ - Updated to use new `createFastVault()` that returns just the vaultId
112
+ - Updated to use new `verifyVault()` that returns the FastVault
113
+ - Removed `code` from CLI `CreateVaultOptions` (verification code always prompted interactively)
114
+ - Removed `--code` option from CLI create command
115
+
116
+ - [#55](https://github.com/vultisig/vultisig-sdk/pull/55) [`95ba10b`](https://github.com/vultisig/vultisig-sdk/commit/95ba10baf2dc2dc4ba8e48825f10f34ec275a73c) Thanks [@bornslippynuxx](https://github.com/bornslippynuxx)! - Add inline verification code retry during vault creation. When entering an incorrect code, users can now retry, resend the verification email, or abort gracefully instead of being kicked back to the main menu.
117
+
118
+ - Updated dependencies [[`7979f3c`](https://github.com/vultisig/vultisig-sdk/commit/7979f3c502ea04db3c3de551bee297b8a9f9808b), [`7f60cd5`](https://github.com/vultisig/vultisig-sdk/commit/7f60cd5835510bd9110d6382cf7d03bf1d5e04ff), [`a36a7f6`](https://github.com/vultisig/vultisig-sdk/commit/a36a7f614c03e32ebc7e843cbf1ab30b6be0d4af), [`22bb16b`](https://github.com/vultisig/vultisig-sdk/commit/22bb16be8421a51aa32da6c1166539015380651e), [`7979f3c`](https://github.com/vultisig/vultisig-sdk/commit/7979f3c502ea04db3c3de551bee297b8a9f9808b), [`95ba10b`](https://github.com/vultisig/vultisig-sdk/commit/95ba10baf2dc2dc4ba8e48825f10f34ec275a73c), [`cc96f64`](https://github.com/vultisig/vultisig-sdk/commit/cc96f64622a651eb6156f279afbbfe0aa4219179), [`7979f3c`](https://github.com/vultisig/vultisig-sdk/commit/7979f3c502ea04db3c3de551bee297b8a9f9808b), [`7979f3c`](https://github.com/vultisig/vultisig-sdk/commit/7979f3c502ea04db3c3de551bee297b8a9f9808b), [`22bb16b`](https://github.com/vultisig/vultisig-sdk/commit/22bb16be8421a51aa32da6c1166539015380651e), [`7979f3c`](https://github.com/vultisig/vultisig-sdk/commit/7979f3c502ea04db3c3de551bee297b8a9f9808b), [`008db7f`](https://github.com/vultisig/vultisig-sdk/commit/008db7fb27580ec78df3bbc41b25aac24924ffd8), [`7979f3c`](https://github.com/vultisig/vultisig-sdk/commit/7979f3c502ea04db3c3de551bee297b8a9f9808b), [`b4cf357`](https://github.com/vultisig/vultisig-sdk/commit/b4cf357c98ef493b48c807e5bb45cd40b9893295), [`7979f3c`](https://github.com/vultisig/vultisig-sdk/commit/7979f3c502ea04db3c3de551bee297b8a9f9808b), [`7979f3c`](https://github.com/vultisig/vultisig-sdk/commit/7979f3c502ea04db3c3de551bee297b8a9f9808b), [`91990d3`](https://github.com/vultisig/vultisig-sdk/commit/91990d3fc7ef1a8d7068f5cbae8f8f3dda5b68f3), [`95ba10b`](https://github.com/vultisig/vultisig-sdk/commit/95ba10baf2dc2dc4ba8e48825f10f34ec275a73c), [`7979f3c`](https://github.com/vultisig/vultisig-sdk/commit/7979f3c502ea04db3c3de551bee297b8a9f9808b)]:
119
+ - @vultisig/sdk@0.2.0
120
+
3
121
  ## 0.2.0-beta.9
4
122
 
5
123
  ### Minor Changes
package/README.md CHANGED
@@ -105,6 +105,52 @@ All devices joined. Running keygen...
105
105
  Vault ID: vault_abc123def456
106
106
  ```
107
107
 
108
+ ### Import from Seedphrase
109
+
110
+ Import an existing wallet from a BIP39 recovery phrase (12 or 24 words):
111
+
112
+ ```bash
113
+ # FastVault import (server-assisted 2-of-2)
114
+ vultisig import-seedphrase fast --name "Imported Wallet" --email user@example.com
115
+
116
+ # SecureVault import (multi-device MPC)
117
+ vultisig import-seedphrase secure --name "Team Wallet" --shares 3
118
+ ```
119
+
120
+ **Import options:**
121
+ - `--mnemonic <words>` - Recovery phrase (space-separated words)
122
+ - `--discover-chains` - Scan chains for existing balances before import
123
+ - `--chains <chains>` - Specific chains to enable (comma-separated)
124
+
125
+ When `--mnemonic` is not provided, you'll be prompted to enter it securely (masked input).
126
+
127
+ **Example session:**
128
+ ```bash
129
+ $ vultisig import-seedphrase fast --name "My Wallet" --email user@example.com --discover-chains
130
+
131
+ Enter your 12 or 24-word recovery phrase.
132
+ Words will be hidden as you type.
133
+
134
+ Seedphrase: ************************
135
+ Password: ********
136
+ ✓ Valid 12-word seedphrase
137
+
138
+ Discovering chains with balances...
139
+ Bitcoin: bc1q...xyz 0.05 BTC
140
+ Ethereum: 0x1234... 1.2 ETH
141
+ ✓ Found 2 chains with balances
142
+
143
+ Importing seedphrase... (35%)
144
+ ✓ Keys generated, awaiting email verification
145
+
146
+ Enter verification code: 123456
147
+ ✓ Vault verified successfully!
148
+
149
+ Vault imported: My Wallet
150
+ Bitcoin: bc1q...xyz
151
+ Ethereum: 0x1234...abc
152
+ ```
153
+
108
154
  ### Check Balances
109
155
 
110
156
  ```bash
@@ -173,6 +219,8 @@ vultisig -i
173
219
  | `create` | Create a new fast vault (server-assisted) |
174
220
  | `create --secure` | Create a secure vault (multi-device MPC) |
175
221
  | `import <file>` | Import vault from .vult file |
222
+ | `import-seedphrase fast` | Import seedphrase as FastVault (2-of-2) |
223
+ | `import-seedphrase secure` | Import seedphrase as SecureVault (N-of-M) |
176
224
  | `export [path]` | Export vault to file |
177
225
  | `verify <vaultId>` | Verify vault with email code |
178
226
  | `vaults` | List all stored vaults |
@@ -186,6 +234,23 @@ vultisig -i
186
234
  - `--shares <n>` - Number of devices for secure vault (default: 2)
187
235
  - `--threshold <n>` - Signing threshold (default: ceil((shares+1)/2))
188
236
 
237
+ **Import seedphrase options (fast):**
238
+ - `--name <name>` - Vault name (required)
239
+ - `--email <email>` - Email for verification (required)
240
+ - `--password <password>` - Vault password (required, prompted if not provided)
241
+ - `--mnemonic <words>` - Recovery phrase (prompted securely if not provided)
242
+ - `--discover-chains` - Auto-enable chains with existing balances
243
+ - `--chains <chains>` - Specific chains to enable (comma-separated)
244
+
245
+ **Import seedphrase options (secure):**
246
+ - `--name <name>` - Vault name (required)
247
+ - `--shares <n>` - Number of devices (default: 2)
248
+ - `--threshold <n>` - Signing threshold (default: ceil((shares+1)/2))
249
+ - `--password <password>` - Vault password (optional)
250
+ - `--mnemonic <words>` - Recovery phrase (prompted securely if not provided)
251
+ - `--discover-chains` - Auto-enable chains with existing balances
252
+ - `--chains <chains>` - Specific chains to enable (comma-separated)
253
+
189
254
  **Export options:**
190
255
  - `[path]` - Output file or directory (defaults to SDK-generated filename in current directory)
191
256
  - `--password <password>` - Password to unlock encrypted vaults
@@ -463,6 +528,8 @@ vultisig broadcast --chain sui --raw-tx '{"unsignedTx":"<base64-tx-bytes>","sign
463
528
  | Command | Description |
464
529
  |---------|-------------|
465
530
  | `vault <name>` | Switch to a different vault |
531
+ | `create <fast\|secure>` | Create a new vault |
532
+ | `import-seedphrase <fast\|secure>` | Import wallet from recovery phrase |
466
533
  | `lock` | Lock vault (clear cached password) |
467
534
  | `unlock` | Unlock vault (cache password) |
468
535
  | `status` | Show vault status |
package/dist/index.js CHANGED
@@ -1106,6 +1106,7 @@ import "dotenv/config";
1106
1106
  import { Vultisig as Vultisig4 } from "@vultisig/sdk";
1107
1107
  import chalk12 from "chalk";
1108
1108
  import { program } from "commander";
1109
+ import inquirer8 from "inquirer";
1109
1110
 
1110
1111
  // src/core/command-context.ts
1111
1112
  var DEFAULT_PASSWORD_CACHE_TTL = 5 * 60 * 1e3;
@@ -2211,7 +2212,7 @@ async function executeCreateFast(ctx2, options) {
2211
2212
  if (action === "resend") {
2212
2213
  const resendSpinner = createSpinner("Resending verification email...");
2213
2214
  try {
2214
- await ctx2.sdk.resendVaultVerification(vaultId);
2215
+ await ctx2.sdk.resendVaultVerification({ vaultId, email, password });
2215
2216
  resendSpinner.succeed("Verification email sent!");
2216
2217
  info("Check your inbox for the new code. Note: There may be a ~3 minute cooldown between resends.");
2217
2218
  } catch (resendErr) {
@@ -2312,10 +2313,42 @@ async function executeImport(ctx2, file) {
2312
2313
  }
2313
2314
  async function executeVerify(ctx2, vaultId, options = {}) {
2314
2315
  if (options.resend) {
2316
+ let email = options.email;
2317
+ let password = options.password;
2318
+ if (!email || !password) {
2319
+ info("Email and password are required to resend verification.");
2320
+ const answers = await inquirer4.prompt([
2321
+ ...!email ? [
2322
+ {
2323
+ type: "input",
2324
+ name: "email",
2325
+ message: "Email address:",
2326
+ validate: (input) => input.includes("@") || "Please enter a valid email"
2327
+ }
2328
+ ] : [],
2329
+ ...!password ? [
2330
+ {
2331
+ type: "password",
2332
+ name: "password",
2333
+ message: "Vault password:",
2334
+ mask: "*",
2335
+ validate: (input) => input.length >= 8 || "Password must be at least 8 characters"
2336
+ }
2337
+ ] : []
2338
+ ]);
2339
+ email = email || answers.email;
2340
+ password = password || answers.password;
2341
+ }
2315
2342
  const spinner2 = createSpinner("Resending verification email...");
2316
- await ctx2.sdk.resendVaultVerification(vaultId);
2317
- spinner2.succeed("Verification email sent!");
2318
- info("Check your inbox for the new verification code.");
2343
+ try {
2344
+ await ctx2.sdk.resendVaultVerification({ vaultId, email, password });
2345
+ spinner2.succeed("Verification email sent!");
2346
+ info("Check your inbox for the new verification code.");
2347
+ } catch (resendErr) {
2348
+ spinner2.fail("Failed to resend verification email");
2349
+ error(resendErr.message || "Could not resend email. You may need to wait a few minutes.");
2350
+ return false;
2351
+ }
2319
2352
  }
2320
2353
  let code = options.code;
2321
2354
  if (!code) {
@@ -2473,6 +2506,223 @@ async function executeInfo(ctx2) {
2473
2506
  }
2474
2507
  displayVaultInfo(vault);
2475
2508
  }
2509
+ async function executeImportSeedphraseFast(ctx2, options) {
2510
+ const { mnemonic, name, password, email, discoverChains, chains, signal } = options;
2511
+ const validateSpinner = createSpinner("Validating seedphrase...");
2512
+ const validation = await ctx2.sdk.validateSeedphrase(mnemonic);
2513
+ if (!validation.valid) {
2514
+ validateSpinner.fail("Invalid seedphrase");
2515
+ if (validation.invalidWords?.length) {
2516
+ warn(`Invalid words: ${validation.invalidWords.join(", ")}`);
2517
+ }
2518
+ throw new Error(validation.error || "Invalid mnemonic phrase");
2519
+ }
2520
+ validateSpinner.succeed(`Valid ${validation.wordCount}-word seedphrase`);
2521
+ if (discoverChains) {
2522
+ const discoverSpinner = createSpinner("Discovering chains with balances...");
2523
+ try {
2524
+ const discovered = await ctx2.sdk.discoverChainsFromSeedphrase(mnemonic, chains, (p) => {
2525
+ discoverSpinner.text = `Discovering: ${p.chain || "scanning"} (${p.chainsProcessed}/${p.chainsTotal})`;
2526
+ });
2527
+ const chainsWithBalance = discovered.filter((c) => c.hasBalance);
2528
+ discoverSpinner.succeed(`Found ${chainsWithBalance.length} chains with balances`);
2529
+ if (chainsWithBalance.length > 0 && !isSilent()) {
2530
+ info("\nChains with balances:");
2531
+ for (const result of chainsWithBalance) {
2532
+ info(` ${result.chain}: ${result.balance} ${result.symbol}`);
2533
+ }
2534
+ info("");
2535
+ }
2536
+ } catch {
2537
+ discoverSpinner.warn("Chain discovery failed, continuing with import...");
2538
+ }
2539
+ }
2540
+ const importSpinner = createSpinner("Importing seedphrase...");
2541
+ const vaultId = await withAbortSignal(
2542
+ ctx2.sdk.importSeedphraseAsFastVault({
2543
+ mnemonic,
2544
+ name,
2545
+ password,
2546
+ email,
2547
+ // Don't pass discoverChains - CLI handles discovery above
2548
+ chains,
2549
+ onProgress: (step) => {
2550
+ importSpinner.text = `${step.message} (${step.progress}%)`;
2551
+ }
2552
+ }),
2553
+ signal
2554
+ );
2555
+ importSpinner.succeed("Keys generated, email verification required");
2556
+ warn("\nA verification code has been sent to your email.");
2557
+ info("Please check your inbox and enter the code.");
2558
+ const MAX_VERIFY_ATTEMPTS = 5;
2559
+ let attempts = 0;
2560
+ while (attempts < MAX_VERIFY_ATTEMPTS) {
2561
+ attempts++;
2562
+ const codeAnswer = await inquirer4.prompt([
2563
+ {
2564
+ type: "input",
2565
+ name: "code",
2566
+ message: `Verification code sent to ${email}. Enter code:`,
2567
+ validate: (input) => /^\d{4,6}$/.test(input) || "Code must be 4-6 digits"
2568
+ }
2569
+ ]);
2570
+ const verifySpinner = createSpinner("Verifying email code...");
2571
+ try {
2572
+ const vault = await ctx2.sdk.verifyVault(vaultId, codeAnswer.code);
2573
+ verifySpinner.succeed("Email verified successfully!");
2574
+ setupVaultEvents(vault);
2575
+ await ctx2.setActiveVault(vault);
2576
+ success("\n+ Vault imported from seedphrase!");
2577
+ info("\nYour vault is ready. Run the following commands:");
2578
+ printResult(chalk5.cyan(" vultisig balance ") + "- View balances");
2579
+ printResult(chalk5.cyan(" vultisig addresses ") + "- View addresses");
2580
+ printResult(chalk5.cyan(" vultisig portfolio ") + "- View portfolio value");
2581
+ return vault;
2582
+ } catch (err) {
2583
+ verifySpinner.fail("Verification failed");
2584
+ error(`
2585
+ \u2717 ${err.message || "Invalid verification code"}`);
2586
+ if (attempts >= MAX_VERIFY_ATTEMPTS) {
2587
+ warn("\nMaximum attempts reached.");
2588
+ warn("\nTo retry verification later, use:");
2589
+ info(` vultisig verify ${vaultId}`);
2590
+ err.exitCode = 1;
2591
+ throw err;
2592
+ }
2593
+ const { action } = await inquirer4.prompt([
2594
+ {
2595
+ type: "list",
2596
+ name: "action",
2597
+ message: `What would you like to do? (${MAX_VERIFY_ATTEMPTS - attempts} attempts remaining)`,
2598
+ choices: [
2599
+ { name: "Enter a different code", value: "retry" },
2600
+ { name: "Resend verification email (rate limited)", value: "resend" },
2601
+ { name: "Abort and verify later", value: "abort" }
2602
+ ]
2603
+ }
2604
+ ]);
2605
+ if (action === "abort") {
2606
+ warn("\nSeedphrase import paused. To complete verification, use:");
2607
+ info(` vultisig verify ${vaultId}`);
2608
+ warn("\nNote: The pending vault is stored in memory only and will be lost if you exit.");
2609
+ return void 0;
2610
+ }
2611
+ if (action === "resend") {
2612
+ const resendSpinner = createSpinner("Resending verification email...");
2613
+ try {
2614
+ await ctx2.sdk.resendVaultVerification({ vaultId, email, password });
2615
+ resendSpinner.succeed("Verification email sent!");
2616
+ info("Check your inbox for the new code.");
2617
+ } catch (resendErr) {
2618
+ resendSpinner.fail("Failed to resend");
2619
+ warn(resendErr.message || "Could not resend email.");
2620
+ }
2621
+ }
2622
+ }
2623
+ }
2624
+ throw new Error("Verification loop exited unexpectedly");
2625
+ }
2626
+ async function executeImportSeedphraseSecure(ctx2, options) {
2627
+ const { mnemonic, name, password, threshold, shares: totalShares, discoverChains, chains, signal } = options;
2628
+ const validateSpinner = createSpinner("Validating seedphrase...");
2629
+ const validation = await ctx2.sdk.validateSeedphrase(mnemonic);
2630
+ if (!validation.valid) {
2631
+ validateSpinner.fail("Invalid seedphrase");
2632
+ if (validation.invalidWords?.length) {
2633
+ warn(`Invalid words: ${validation.invalidWords.join(", ")}`);
2634
+ }
2635
+ throw new Error(validation.error || "Invalid mnemonic phrase");
2636
+ }
2637
+ validateSpinner.succeed(`Valid ${validation.wordCount}-word seedphrase`);
2638
+ if (discoverChains) {
2639
+ const discoverSpinner = createSpinner("Discovering chains with balances...");
2640
+ try {
2641
+ const discovered = await ctx2.sdk.discoverChainsFromSeedphrase(mnemonic, chains, (p) => {
2642
+ discoverSpinner.text = `Discovering: ${p.chain || "scanning"} (${p.chainsProcessed}/${p.chainsTotal})`;
2643
+ });
2644
+ const chainsWithBalance = discovered.filter((c) => c.hasBalance);
2645
+ discoverSpinner.succeed(`Found ${chainsWithBalance.length} chains with balances`);
2646
+ if (chainsWithBalance.length > 0 && !isSilent()) {
2647
+ info("\nChains with balances:");
2648
+ for (const result of chainsWithBalance) {
2649
+ info(` ${result.chain}: ${result.balance} ${result.symbol}`);
2650
+ }
2651
+ info("");
2652
+ }
2653
+ } catch {
2654
+ discoverSpinner.warn("Chain discovery failed, continuing with import...");
2655
+ }
2656
+ }
2657
+ const importSpinner = createSpinner("Importing seedphrase as secure vault...");
2658
+ try {
2659
+ const result = await withAbortSignal(
2660
+ ctx2.sdk.importSeedphraseAsSecureVault({
2661
+ mnemonic,
2662
+ name,
2663
+ password,
2664
+ devices: totalShares,
2665
+ threshold,
2666
+ // Don't pass discoverChains - CLI handles discovery above
2667
+ chains,
2668
+ onProgress: (step) => {
2669
+ importSpinner.text = `${step.message} (${step.progress}%)`;
2670
+ },
2671
+ onQRCodeReady: (qrPayload) => {
2672
+ if (isJsonOutput()) {
2673
+ printResult(qrPayload);
2674
+ } else if (isSilent()) {
2675
+ printResult(`QR Payload: ${qrPayload}`);
2676
+ } else {
2677
+ importSpinner.stop();
2678
+ info("\nScan this QR code with your Vultisig mobile app:");
2679
+ import_qrcode_terminal3.default.generate(qrPayload, { small: true });
2680
+ info(`
2681
+ Or use this URL: ${qrPayload}
2682
+ `);
2683
+ info(chalk5.gray("(Press Ctrl+C to cancel)\n"));
2684
+ importSpinner.start(`Waiting for ${totalShares} devices to join...`);
2685
+ }
2686
+ },
2687
+ onDeviceJoined: (deviceId, totalJoined, required) => {
2688
+ if (!isSilent()) {
2689
+ importSpinner.text = `Device joined: ${totalJoined}/${required} (${deviceId})`;
2690
+ } else if (!isJsonOutput()) {
2691
+ printResult(`Device joined: ${totalJoined}/${required}`);
2692
+ }
2693
+ }
2694
+ }),
2695
+ signal
2696
+ );
2697
+ setupVaultEvents(result.vault);
2698
+ await ctx2.setActiveVault(result.vault);
2699
+ importSpinner.succeed(`Secure vault imported: ${name} (${threshold}-of-${totalShares})`);
2700
+ if (isJsonOutput()) {
2701
+ outputJson({
2702
+ vault: {
2703
+ id: result.vaultId,
2704
+ name,
2705
+ type: "secure",
2706
+ threshold,
2707
+ totalSigners: totalShares
2708
+ },
2709
+ sessionId: result.sessionId
2710
+ });
2711
+ return result.vault;
2712
+ }
2713
+ warn(`
2714
+ Important: Save your vault backup file (.vult) in a secure location.`);
2715
+ warn(`This is a ${threshold}-of-${totalShares} vault. You'll need ${threshold} devices to sign transactions.`);
2716
+ success("\n+ Vault imported from seedphrase!");
2717
+ return result.vault;
2718
+ } catch (err) {
2719
+ importSpinner.fail("Secure vault import failed");
2720
+ if (err.message?.includes("not implemented")) {
2721
+ warn("\nSecure vault seedphrase import is not yet implemented in the SDK");
2722
+ }
2723
+ throw err;
2724
+ }
2725
+ }
2476
2726
 
2477
2727
  // src/commands/swap.ts
2478
2728
  async function executeSwapChains(ctx2) {
@@ -2790,6 +3040,7 @@ var COMMANDS = [
2790
3040
  "vaults",
2791
3041
  "vault",
2792
3042
  "import",
3043
+ "import-seedphrase",
2793
3044
  "create",
2794
3045
  "info",
2795
3046
  "export",
@@ -2848,6 +3099,13 @@ function createCompleter(ctx2) {
2848
3099
  const partial = parts[1] || "";
2849
3100
  return completeChainName(partial);
2850
3101
  }
3102
+ if ((command === "create" || command === "import-seedphrase") && parts.length === 2) {
3103
+ const types = ["fast", "secure"];
3104
+ const partial = parts[1] || "";
3105
+ const partialLower = partial.toLowerCase();
3106
+ const matches = types.filter((t) => t.startsWith(partialLower));
3107
+ return [matches.length ? matches : types, partial];
3108
+ }
2851
3109
  const hits = COMMANDS.filter((c) => c.startsWith(line));
2852
3110
  const show = hits.length ? hits : COMMANDS;
2853
3111
  return [show, line];
@@ -3605,6 +3863,9 @@ Error: ${error2.message}`));
3605
3863
  case "create":
3606
3864
  await this.createVault(args);
3607
3865
  break;
3866
+ case "import-seedphrase":
3867
+ await this.importSeedphrase(args);
3868
+ break;
3608
3869
  case "info":
3609
3870
  await executeInfo(this.ctx);
3610
3871
  break;
@@ -3785,6 +4046,92 @@ Error: ${error2.message}`));
3785
4046
  this.eventBuffer.setupVaultListeners(vault);
3786
4047
  }
3787
4048
  }
4049
+ async importSeedphrase(args) {
4050
+ const type = args[0]?.toLowerCase();
4051
+ if (!type || type !== "fast" && type !== "secure") {
4052
+ console.log(chalk9.cyan("Usage: import-seedphrase <fast|secure>"));
4053
+ console.log(chalk9.gray(" fast - Import with VultiServer (2-of-2)"));
4054
+ console.log(chalk9.gray(" secure - Import with device coordination (N-of-M)"));
4055
+ return;
4056
+ }
4057
+ console.log(chalk9.cyan("\nEnter your recovery phrase (words separated by spaces):"));
4058
+ const mnemonic = await this.promptPassword("Seedphrase");
4059
+ const validation = await this.ctx.sdk.validateSeedphrase(mnemonic);
4060
+ if (!validation.valid) {
4061
+ console.log(chalk9.red(`Invalid seedphrase: ${validation.error}`));
4062
+ if (validation.invalidWords?.length) {
4063
+ console.log(chalk9.yellow(`Invalid words: ${validation.invalidWords.join(", ")}`));
4064
+ }
4065
+ return;
4066
+ }
4067
+ console.log(chalk9.green(`\u2713 Valid ${validation.wordCount}-word seedphrase`));
4068
+ let vault;
4069
+ if (type === "fast") {
4070
+ const name = await this.prompt("Vault name");
4071
+ if (!name) {
4072
+ console.log(chalk9.red("Name is required"));
4073
+ return;
4074
+ }
4075
+ const password = await this.promptPassword("Vault password");
4076
+ if (!password) {
4077
+ console.log(chalk9.red("Password is required"));
4078
+ return;
4079
+ }
4080
+ const email = await this.prompt("Email for verification");
4081
+ if (!email || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
4082
+ console.log(chalk9.red("Valid email is required"));
4083
+ return;
4084
+ }
4085
+ const discoverStr = await this.prompt("Discover chains with balances? (y/n)", "y");
4086
+ const discoverChains = discoverStr.toLowerCase() === "y";
4087
+ vault = await this.withCancellation(
4088
+ (signal) => executeImportSeedphraseFast(this.ctx, {
4089
+ mnemonic,
4090
+ name,
4091
+ password,
4092
+ email,
4093
+ discoverChains,
4094
+ signal
4095
+ })
4096
+ );
4097
+ } else {
4098
+ const name = await this.prompt("Vault name");
4099
+ if (!name) {
4100
+ console.log(chalk9.red("Name is required"));
4101
+ return;
4102
+ }
4103
+ const sharesStr = await this.prompt("Total shares (devices)", "3");
4104
+ const shares = parseInt(sharesStr, 10);
4105
+ if (isNaN(shares) || shares < 2) {
4106
+ console.log(chalk9.red("Must have at least 2 shares"));
4107
+ return;
4108
+ }
4109
+ const thresholdStr = await this.prompt("Signing threshold", "2");
4110
+ const threshold = parseInt(thresholdStr, 10);
4111
+ if (isNaN(threshold) || threshold < 1 || threshold > shares) {
4112
+ console.log(chalk9.red(`Threshold must be between 1 and ${shares}`));
4113
+ return;
4114
+ }
4115
+ const password = await this.promptPassword("Vault password (optional, Enter to skip)");
4116
+ const discoverStr = await this.prompt("Discover chains with balances? (y/n)", "y");
4117
+ const discoverChains = discoverStr.toLowerCase() === "y";
4118
+ vault = await this.withCancellation(
4119
+ (signal) => executeImportSeedphraseSecure(this.ctx, {
4120
+ mnemonic,
4121
+ name,
4122
+ password: password || void 0,
4123
+ threshold,
4124
+ shares,
4125
+ discoverChains,
4126
+ signal
4127
+ })
4128
+ );
4129
+ }
4130
+ if (vault) {
4131
+ this.ctx.addVault(vault);
4132
+ this.eventBuffer.setupVaultListeners(vault);
4133
+ }
4134
+ }
3788
4135
  async runBalance(args) {
3789
4136
  const chainStr = args[0];
3790
4137
  const includeTokens = args.includes("-t") || args.includes("--tokens");
@@ -4040,7 +4387,7 @@ var cachedVersion = null;
4040
4387
  function getVersion() {
4041
4388
  if (cachedVersion) return cachedVersion;
4042
4389
  if (true) {
4043
- cachedVersion = "0.2.0-beta.9";
4390
+ cachedVersion = "0.2.0";
4044
4391
  return cachedVersion;
4045
4392
  }
4046
4393
  try {
@@ -4559,16 +4906,104 @@ program.command("import <file>").description("Import vault from .vult file").act
4559
4906
  await executeImport(context, file);
4560
4907
  })
4561
4908
  );
4562
- program.command("verify <vaultId>").description("Verify vault with email verification code").option("-r, --resend", "Resend verification email").option("--code <code>", "Verification code").action(
4563
- withExit(async (vaultId, options) => {
4564
- const context = await init(program.opts().vault);
4565
- const verified = await executeVerify(context, vaultId, options);
4566
- if (!verified) {
4567
- const err = new Error("Verification failed");
4568
- err.exitCode = 1;
4569
- throw err;
4909
+ var importSeedphraseCmd = program.command("import-seedphrase").description("Import wallet from BIP39 seedphrase");
4910
+ async function promptSeedphrase() {
4911
+ info("\nEnter your 12 or 24-word recovery phrase.");
4912
+ info("Words will be hidden as you type.\n");
4913
+ const answer = await inquirer8.prompt([
4914
+ {
4915
+ type: "password",
4916
+ name: "mnemonic",
4917
+ message: "Seedphrase:",
4918
+ mask: "*",
4919
+ validate: (input) => {
4920
+ const words = input.trim().split(/\s+/);
4921
+ if (words.length !== 12 && words.length !== 24) {
4922
+ return `Expected 12 or 24 words, got ${words.length}`;
4923
+ }
4924
+ return true;
4925
+ }
4570
4926
  }
4571
- })
4927
+ ]);
4928
+ return answer.mnemonic.trim().toLowerCase();
4929
+ }
4930
+ importSeedphraseCmd.command("fast").description("Import as FastVault (server-assisted 2-of-2)").requiredOption("--name <name>", "Vault name").requiredOption("--password <password>", "Vault password").requiredOption("--email <email>", "Email for verification").option("--mnemonic <words>", "Seedphrase (12 or 24 words, space-separated)").option("--discover-chains", "Scan chains for existing balances").option("--chains <chains>", "Specific chains to enable (comma-separated)").action(
4931
+ withExit(
4932
+ async (options) => {
4933
+ const context = await init(program.opts().vault);
4934
+ let mnemonic = options.mnemonic;
4935
+ if (!mnemonic) {
4936
+ mnemonic = await promptSeedphrase();
4937
+ }
4938
+ let chains;
4939
+ if (options.chains) {
4940
+ const chainNames = options.chains.split(",").map((c) => c.trim());
4941
+ chains = [];
4942
+ for (const name of chainNames) {
4943
+ const chain = findChainByName(name);
4944
+ if (chain) {
4945
+ chains.push(chain);
4946
+ } else {
4947
+ console.warn(`Warning: Unknown chain "${name}" - skipping`);
4948
+ }
4949
+ }
4950
+ }
4951
+ await executeImportSeedphraseFast(context, {
4952
+ mnemonic,
4953
+ name: options.name,
4954
+ password: options.password,
4955
+ email: options.email,
4956
+ discoverChains: options.discoverChains,
4957
+ chains
4958
+ });
4959
+ }
4960
+ )
4961
+ );
4962
+ importSeedphraseCmd.command("secure").description("Import as SecureVault (multi-device MPC)").requiredOption("--name <name>", "Vault name").option("--password <password>", "Vault password (optional)").option("--threshold <m>", "Signing threshold", "2").option("--shares <n>", "Total shares", "3").option("--mnemonic <words>", "Seedphrase (12 or 24 words)").option("--discover-chains", "Scan chains for existing balances").option("--chains <chains>", "Specific chains to enable (comma-separated)").action(
4963
+ withExit(
4964
+ async (options) => {
4965
+ const context = await init(program.opts().vault);
4966
+ let mnemonic = options.mnemonic;
4967
+ if (!mnemonic) {
4968
+ mnemonic = await promptSeedphrase();
4969
+ }
4970
+ let chains;
4971
+ if (options.chains) {
4972
+ const chainNames = options.chains.split(",").map((c) => c.trim());
4973
+ chains = [];
4974
+ for (const name of chainNames) {
4975
+ const chain = findChainByName(name);
4976
+ if (chain) {
4977
+ chains.push(chain);
4978
+ } else {
4979
+ console.warn(`Warning: Unknown chain "${name}" - skipping`);
4980
+ }
4981
+ }
4982
+ }
4983
+ await executeImportSeedphraseSecure(context, {
4984
+ mnemonic,
4985
+ name: options.name,
4986
+ password: options.password,
4987
+ threshold: parseInt(options.threshold, 10),
4988
+ shares: parseInt(options.shares, 10),
4989
+ discoverChains: options.discoverChains,
4990
+ chains
4991
+ });
4992
+ }
4993
+ )
4994
+ );
4995
+ program.command("verify <vaultId>").description("Verify vault with email verification code").option("-r, --resend", "Resend verification email").option("--code <code>", "Verification code").option("--email <email>", "Email address (required for --resend)").option("--password <password>", "Vault password (required for --resend)").action(
4996
+ withExit(
4997
+ async (vaultId, options) => {
4998
+ const context = await init(program.opts().vault);
4999
+ const verified = await executeVerify(context, vaultId, options);
5000
+ if (!verified) {
5001
+ const err = new Error("Verification failed");
5002
+ err.exitCode = 1;
5003
+ throw err;
5004
+ }
5005
+ }
5006
+ )
4572
5007
  );
4573
5008
  program.command("balance [chain]").description("Show balance for a chain or all chains").option("-t, --tokens", "Include token balances").action(
4574
5009
  withExit(async (chainStr, options) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vultisig/cli",
3
- "version": "0.2.0-beta.9",
3
+ "version": "0.2.0",
4
4
  "description": "Command-line wallet for Vultisig - multi-chain MPC wallet management",
5
5
  "type": "module",
6
6
  "bin": {
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "homepage": "https://vultisig.com",
50
50
  "dependencies": {
51
- "@vultisig/sdk": "^0.2.0-beta.9",
51
+ "@vultisig/sdk": "^0.2.0",
52
52
  "chalk": "^5.3.0",
53
53
  "cli-table3": "^0.6.5",
54
54
  "commander": "^12.0.0",