@blockrun/clawrouter 0.12.17 → 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
@@ -3826,6 +3826,43 @@ async function resolveOrGenerateWalletKey() {
3826
3826
  solanaPrivateKeyBytes: result.solanaPrivateKeyBytes
3827
3827
  };
3828
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
+ }
3829
3866
  async function loadPaymentChain() {
3830
3867
  try {
3831
3868
  const content = (await readTextFile(CHAIN_FILE)).trim();
@@ -7571,6 +7608,7 @@ Commands:
7571
7608
  doctor opus Use Opus for deeper analysis (~$0.01)
7572
7609
  partners List available partner APIs with pricing
7573
7610
  partners test Test partner API endpoints (expect 402 = alive)
7611
+ wallet recover Restore wallet.key from mnemonic (if generated by ClawRouter)
7574
7612
 
7575
7613
  Examples:
7576
7614
  # Start standalone proxy
@@ -7605,6 +7643,7 @@ function parseArgs(args) {
7605
7643
  report: false,
7606
7644
  reportPeriod: "daily",
7607
7645
  reportJson: false,
7646
+ walletRecover: false,
7608
7647
  port: void 0
7609
7648
  };
7610
7649
  for (let i = 0; i < args.length; i++) {
@@ -7635,6 +7674,9 @@ function parseArgs(args) {
7635
7674
  result.reportJson = true;
7636
7675
  i++;
7637
7676
  }
7677
+ } else if (arg === "wallet" && args[i + 1] === "recover") {
7678
+ result.walletRecover = true;
7679
+ i++;
7638
7680
  } else if (arg === "--port" && args[i + 1]) {
7639
7681
  result.port = parseInt(args[i + 1], 10);
7640
7682
  i++;
@@ -7705,6 +7747,10 @@ ClawRouter Partner APIs (v${VERSION})
7705
7747
  }
7706
7748
  process.exit(0);
7707
7749
  }
7750
+ if (args.walletRecover) {
7751
+ await recoverWalletFromMnemonic();
7752
+ process.exit(0);
7753
+ }
7708
7754
  if (args.report) {
7709
7755
  const report = await generateReport(args.reportPeriod, args.reportJson);
7710
7756
  console.log(report);