@blockrun/clawrouter 0.12.16 → 0.12.18

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/dist/cli.js CHANGED
@@ -3688,7 +3688,14 @@ async function generateAndSaveWallet() {
3688
3688
  const existingMnemonic = await loadMnemonic();
3689
3689
  if (existingMnemonic) {
3690
3690
  throw new Error(
3691
- `Mnemonic file exists at ${MNEMONIC_FILE} but wallet.key is missing. This means a Solana wallet was derived from this mnemonic. Refusing to generate a new wallet to protect Solana funds. Restore your EVM key with: export BLOCKRUN_WALLET_KEY=<your_key>`
3691
+ `Mnemonic file exists at ${MNEMONIC_FILE} but wallet.key is missing.
3692
+ Refusing to generate a new wallet to protect existing funds.
3693
+
3694
+ Restore your EVM private key using one of:
3695
+ Windows: set BLOCKRUN_WALLET_KEY=0x<your_key>
3696
+ Mac/Linux: export BLOCKRUN_WALLET_KEY=0x<your_key>
3697
+
3698
+ Then run: npx @blockrun/clawrouter`
3692
3699
  );
3693
3700
  }
3694
3701
  const mnemonic = generateWalletMnemonic();
@@ -3819,6 +3826,43 @@ async function resolveOrGenerateWalletKey() {
3819
3826
  solanaPrivateKeyBytes: result.solanaPrivateKeyBytes
3820
3827
  };
3821
3828
  }
3829
+ async function recoverWalletFromMnemonic() {
3830
+ const mnemonic = await loadMnemonic();
3831
+ if (!mnemonic) {
3832
+ console.error(`[ClawRouter] No mnemonic found at ${MNEMONIC_FILE}`);
3833
+ console.error(`[ClawRouter] Cannot recover \u2014 no mnemonic to derive from.`);
3834
+ process.exit(1);
3835
+ }
3836
+ const existing = await loadSavedWallet().catch(() => void 0);
3837
+ if (existing) {
3838
+ console.error(`[ClawRouter] wallet.key already exists at ${WALLET_FILE}`);
3839
+ console.error(`[ClawRouter] Recovery not needed.`);
3840
+ process.exit(1);
3841
+ }
3842
+ const derived = deriveAllKeys(mnemonic);
3843
+ const solanaKeyBytes = deriveSolanaKeyBytes(mnemonic);
3844
+ const solanaAddress = await getSolanaAddress(solanaKeyBytes).catch(() => void 0);
3845
+ console.log(`[ClawRouter]`);
3846
+ console.log(`[ClawRouter] \u26A0 WALLET RECOVERY FROM MNEMONIC`);
3847
+ console.log(`[ClawRouter] \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);
3848
+ console.log(`[ClawRouter] This only works if your mnemonic was originally`);
3849
+ console.log(`[ClawRouter] generated by ClawRouter (not set manually).`);
3850
+ console.log(`[ClawRouter]`);
3851
+ console.log(`[ClawRouter] Derived EVM Address : ${derived.evmAddress}`);
3852
+ if (solanaAddress) {
3853
+ console.log(`[ClawRouter] Derived Solana Address : ${solanaAddress}`);
3854
+ }
3855
+ console.log(`[ClawRouter]`);
3856
+ console.log(`[ClawRouter] If the Solana address above matches your funded`);
3857
+ console.log(`[ClawRouter] wallet, recovery is safe to proceed.`);
3858
+ console.log(`[ClawRouter] \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);
3859
+ console.log(`[ClawRouter]`);
3860
+ await mkdir2(WALLET_DIR, { recursive: true });
3861
+ await writeFile(WALLET_FILE, derived.evmPrivateKey + "\n", { mode: 384 });
3862
+ console.log(`[ClawRouter] \u2713 wallet.key restored at ${WALLET_FILE}`);
3863
+ console.log(`[ClawRouter] Run: npx @blockrun/clawrouter`);
3864
+ console.log(`[ClawRouter]`);
3865
+ }
3822
3866
  async function loadPaymentChain() {
3823
3867
  try {
3824
3868
  const content = (await readTextFile(CHAIN_FILE)).trim();
@@ -7564,6 +7608,7 @@ Commands:
7564
7608
  doctor opus Use Opus for deeper analysis (~$0.01)
7565
7609
  partners List available partner APIs with pricing
7566
7610
  partners test Test partner API endpoints (expect 402 = alive)
7611
+ wallet recover Restore wallet.key from mnemonic (if generated by ClawRouter)
7567
7612
 
7568
7613
  Examples:
7569
7614
  # Start standalone proxy
@@ -7598,6 +7643,7 @@ function parseArgs(args) {
7598
7643
  report: false,
7599
7644
  reportPeriod: "daily",
7600
7645
  reportJson: false,
7646
+ walletRecover: false,
7601
7647
  port: void 0
7602
7648
  };
7603
7649
  for (let i = 0; i < args.length; i++) {
@@ -7628,6 +7674,9 @@ function parseArgs(args) {
7628
7674
  result.reportJson = true;
7629
7675
  i++;
7630
7676
  }
7677
+ } else if (arg === "wallet" && args[i + 1] === "recover") {
7678
+ result.walletRecover = true;
7679
+ i++;
7631
7680
  } else if (arg === "--port" && args[i + 1]) {
7632
7681
  result.port = parseInt(args[i + 1], 10);
7633
7682
  i++;
@@ -7698,6 +7747,10 @@ ClawRouter Partner APIs (v${VERSION})
7698
7747
  }
7699
7748
  process.exit(0);
7700
7749
  }
7750
+ if (args.walletRecover) {
7751
+ await recoverWalletFromMnemonic();
7752
+ process.exit(0);
7753
+ }
7701
7754
  if (args.report) {
7702
7755
  const report = await generateReport(args.reportPeriod, args.reportJson);
7703
7756
  console.log(report);