@1sat/cli 0.0.129 → 0.0.131

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
@@ -1,7 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { createRequire } from "node:module";
3
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
4
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
2
+ var __esm = (fn, res, err) => () => {
3
+ if (fn)
4
+ try {
5
+ res = fn(fn = 0);
6
+ } catch (e) {
7
+ err = [e];
8
+ }
9
+ if (err)
10
+ throw err[0];
11
+ return res;
12
+ };
5
13
 
6
14
  // src/args.ts
7
15
  function parseGlobalFlags(args) {
@@ -622,11 +630,11 @@ async function handleActionCommand(args, opts) {
622
630
  Registered actions:
623
631
  `);
624
632
  const grouped = new Map;
625
- for (const action2 of actions) {
626
- const cat = action2.meta.category;
633
+ for (const action of actions) {
634
+ const cat = action.meta.category;
627
635
  if (!grouped.has(cat))
628
636
  grouped.set(cat, []);
629
- grouped.get(cat).push(action2);
637
+ grouped.get(cat).push(action);
630
638
  }
631
639
  for (const [category, categoryActions] of grouped) {
632
640
  console.log(` ${category}:`);
@@ -1423,11 +1431,11 @@ var init_help = __esm(() => {
1423
1431
  {
1424
1432
  group: "Wallet",
1425
1433
  name: "messagebox",
1426
- description: "MessageBox inbox (paymail remittances). Not the same as `wallet sync` (address/owner scan).",
1434
+ description: "MessageBox inboxes (paymail remittances, BRC-169 handle payments). Not the same as `wallet sync` (address/owner scan).",
1427
1435
  subcommands: [
1428
1436
  {
1429
1437
  name: "sync",
1430
- description: "Pull payment_inbox (default) and internalize paymail payments",
1438
+ description: "Pull payment_inbox (default) and internalize paymail payments, then metanet_inbox (BRC-169 handle payments)",
1431
1439
  args: [
1432
1440
  {
1433
1441
  flag: "--url",
@@ -1437,7 +1445,7 @@ var init_help = __esm(() => {
1437
1445
  {
1438
1446
  flag: "--box",
1439
1447
  values: "<name>",
1440
- description: "Inbox name (default payment_inbox)"
1448
+ description: "Paymail inbox name (default payment_inbox); metanet_inbox is always pulled"
1441
1449
  }
1442
1450
  ]
1443
1451
  }
@@ -1665,7 +1673,7 @@ function createApprovalAuth(wallet) {
1665
1673
  get(target, property) {
1666
1674
  if (property === "createAction")
1667
1675
  return async (...args) => {
1668
- const satoshis = args[0].outputs?.reduce((sum, output2) => sum + output2.satoshis, 0) ?? 0;
1676
+ const satoshis = args[0].outputs?.reduce((sum, output) => sum + output.satoshis, 0) ?? 0;
1669
1677
  if (!Number.isSafeInteger(satoshis) || satoshis <= 0)
1670
1678
  throw new Error("Invalid HTTP payment amount");
1671
1679
  if (approved === false)
@@ -2189,15 +2197,15 @@ async function handleInitCommand(_args, opts) {
2189
2197
  }
2190
2198
  let wif;
2191
2199
  if (keySource === "generate") {
2192
- const pk2 = PrivateKey2.fromRandom();
2193
- wif = pk2.toWif();
2194
- const address2 = pk2.toPublicKey().toAddress();
2200
+ const pk = PrivateKey2.fromRandom();
2201
+ wif = pk.toWif();
2202
+ const address = pk.toPublicKey().toAddress();
2195
2203
  console.log();
2196
2204
  console.log(formatWarning(" IMPORTANT: Back up your private key!"));
2197
2205
  console.log(formatWarning(" If you lose it, your funds are gone forever."));
2198
2206
  console.log();
2199
2207
  console.log(` ${formatValue("WIF:")} ${wif}`);
2200
- console.log(` ${formatValue("Address:")} ${address2}`);
2208
+ console.log(` ${formatValue("Address:")} ${address}`);
2201
2209
  console.log();
2202
2210
  const confirmed = await confirm2({
2203
2211
  message: "Have you saved your private key somewhere safe?"
@@ -2614,7 +2622,7 @@ var init_mcp_proxy = __esm(() => {
2614
2622
  });
2615
2623
 
2616
2624
  // src/commands/messagebox.ts
2617
- import { syncMessages } from "@1sat/actions";
2625
+ import { syncMessages, syncMetanetInbox } from "@1sat/actions";
2618
2626
  async function handleMessageboxCommand(args, opts) {
2619
2627
  const [subcommand, ...rest] = args;
2620
2628
  switch (subcommand) {
@@ -2639,13 +2647,20 @@ async function messageboxSync(args, opts) {
2639
2647
  ...url ? { messageboxUrl: url } : {},
2640
2648
  ...box ? { messageBox: box } : {}
2641
2649
  });
2650
+ const metanet = await syncMetanetInbox.execute(ctx, {
2651
+ ...url ? { messageboxUrl: url } : {}
2652
+ });
2642
2653
  if (opts.json) {
2643
- output(result, opts);
2654
+ output({ ...result, metanet }, opts);
2644
2655
  return;
2645
2656
  }
2646
2657
  console.log(`
2647
- processed: ${result.processed} failed: ${result.failed}
2648
- `);
2658
+ processed: ${result.processed} failed: ${result.failed}`);
2659
+ console.log(`metanet_inbox: received ${metanet.received.length} skipped ${metanet.skipped.length}${metanet.error ? ` error: ${metanet.error}` : ""}`);
2660
+ for (const s of metanet.skipped) {
2661
+ console.log(` skipped ${s.messageId}: ${s.reason}`);
2662
+ }
2663
+ console.log();
2649
2664
  } finally {
2650
2665
  await destroy();
2651
2666
  }
@@ -3523,12 +3538,12 @@ async function permissionsRevoke(args, opts) {
3523
3538
  const originator = normalizeOriginator2(origin);
3524
3539
  const { store, path } = openStore(opts);
3525
3540
  if (hasFlag(args, "--all")) {
3526
- const removed2 = await store.deleteAllForOriginator(originator);
3541
+ const removed = await store.deleteAllForOriginator(originator);
3527
3542
  if (opts.json) {
3528
- output({ originator, removed: removed2, store: path }, opts);
3543
+ output({ originator, removed, store: path }, opts);
3529
3544
  return;
3530
3545
  }
3531
- output(`revoked ${removed2} grant(s) for ${originator}`, opts);
3546
+ output(`revoked ${removed} grant(s) for ${originator}`, opts);
3532
3547
  return;
3533
3548
  }
3534
3549
  let specs;
@@ -4724,11 +4739,11 @@ function selectedSweepClasses(only, skip) {
4724
4739
  throw new Error("--only and --skip are mutually exclusive");
4725
4740
  }
4726
4741
  if (only) {
4727
- const selected2 = parseSweepClasses(only, "--only");
4728
- if (selected2.size === 0) {
4742
+ const selected = parseSweepClasses(only, "--only");
4743
+ if (selected.size === 0) {
4729
4744
  throw new Error("--only requires at least one class");
4730
4745
  }
4731
- return selected2;
4746
+ return selected;
4732
4747
  }
4733
4748
  const selected = new Set(SWEEP_CLASSES);
4734
4749
  if (skip) {
@@ -5825,8 +5840,8 @@ async function walletListOutputs(args, opts) {
5825
5840
  ${result.totalOutputs} total outputs in basket '${basket}':
5826
5841
  `);
5827
5842
  for (const out of result.outputs) {
5828
- const tags2 = out.tags?.join(", ") || "none";
5829
- console.log(` ${out.outpoint} | ${out.satoshis} sats | tags: ${tags2}`);
5843
+ const tags = out.tags?.join(", ") || "none";
5844
+ console.log(` ${out.outpoint} | ${out.satoshis} sats | tags: ${tags}`);
5830
5845
  }
5831
5846
  console.log();
5832
5847
  }
@@ -6041,7 +6056,6 @@ var init_wallet = __esm(() => {
6041
6056
  });
6042
6057
 
6043
6058
  // src/main.ts
6044
- var exports_main = {};
6045
6059
  import { existsSync as existsSync5 } from "node:fs";
6046
6060
  import { resolve } from "node:path";
6047
6061
  import { config as loadEnv } from "dotenv";
@@ -6185,4 +6199,4 @@ var init_main = __esm(() => {
6185
6199
 
6186
6200
  // src/cli.ts
6187
6201
  process.env.DOTENV_CONFIG_QUIET = "true";
6188
- await Promise.resolve().then(() => (init_main(), exports_main));
6202
+ await Promise.resolve().then(() => (init_main(), {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/cli",
3
- "version": "0.0.129",
3
+ "version": "0.0.131",
4
4
  "description": "CLI for 1Sat Ordinals SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/cli.js",
@@ -27,16 +27,16 @@
27
27
  ],
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
- "@1sat/actions": "0.0.231",
31
- "@1sat/client": "0.0.60",
32
- "@1sat/types": "0.0.51",
33
- "@1sat/wallet": "0.0.117",
34
- "@1sat/wallet-node": "0.0.84",
35
- "@1sat/wallet-server": "0.0.62",
30
+ "@1sat/actions": "0.0.233",
31
+ "@1sat/client": "0.0.62",
32
+ "@1sat/types": "0.0.52",
33
+ "@1sat/wallet": "0.0.119",
34
+ "@1sat/wallet-node": "0.0.86",
35
+ "@1sat/wallet-server": "0.0.64",
36
36
  "@bopen-io/messagebox-server": "^1.3.2",
37
37
  "@bsv/sdk": "^2.6.0",
38
- "@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@2.14.6",
39
- "@bsv/wallet-toolbox-client": "npm:@bopen-io/wallet-toolbox-client@2.14.6",
38
+ "@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@2.14.7",
39
+ "@bsv/wallet-toolbox-client": "npm:@bopen-io/wallet-toolbox-client@2.14.7",
40
40
  "@clack/prompts": "^0.8.0",
41
41
  "bitcoin-backup": "^0.0.11",
42
42
  "chalk": "^5.0.0",
@@ -1,10 +1,11 @@
1
1
  /**
2
- * MessageBox commands — pull paymail / P2P inbox into the wallet.
2
+ * MessageBox commands — pull paymail / P2P inbox and BRC-169 handle
3
+ * payments (`metanet_inbox`) into the wallet.
3
4
  *
4
5
  * 1sat messagebox sync [--url <host>] [--box <name>]
5
6
  */
6
7
 
7
- import { syncMessages } from '@1sat/actions'
8
+ import { syncMessages, syncMetanetInbox } from '@1sat/actions'
8
9
  import type { GlobalFlags } from '../args.js'
9
10
  import { extractFlag } from '../args.js'
10
11
  import { loadContext } from '../context.js'
@@ -46,13 +47,23 @@ async function messageboxSync(
46
47
  ...(url ? { messageboxUrl: url } : {}),
47
48
  ...(box ? { messageBox: box } : {}),
48
49
  })
50
+ const metanet = await syncMetanetInbox.execute(ctx, {
51
+ ...(url ? { messageboxUrl: url } : {}),
52
+ })
49
53
 
50
54
  if (opts.json) {
51
- output(result, opts)
55
+ output({ ...result, metanet }, opts)
52
56
  return
53
57
  }
54
58
 
55
- console.log(`\nprocessed: ${result.processed} failed: ${result.failed}\n`)
59
+ console.log(`\nprocessed: ${result.processed} failed: ${result.failed}`)
60
+ console.log(
61
+ `metanet_inbox: received ${metanet.received.length} skipped ${metanet.skipped.length}${metanet.error ? ` error: ${metanet.error}` : ''}`,
62
+ )
63
+ for (const s of metanet.skipped) {
64
+ console.log(` skipped ${s.messageId}: ${s.reason}`)
65
+ }
66
+ console.log()
56
67
  } finally {
57
68
  await destroy()
58
69
  }
package/src/help.ts CHANGED
@@ -671,12 +671,12 @@ export const COMMANDS: CommandSpec[] = [
671
671
  group: 'Wallet',
672
672
  name: 'messagebox',
673
673
  description:
674
- 'MessageBox inbox (paymail remittances). Not the same as `wallet sync` (address/owner scan).',
674
+ 'MessageBox inboxes (paymail remittances, BRC-169 handle payments). Not the same as `wallet sync` (address/owner scan).',
675
675
  subcommands: [
676
676
  {
677
677
  name: 'sync',
678
678
  description:
679
- 'Pull payment_inbox (default) and internalize paymail payments',
679
+ 'Pull payment_inbox (default) and internalize paymail payments, then metanet_inbox (BRC-169 handle payments)',
680
680
  args: [
681
681
  {
682
682
  flag: '--url',
@@ -687,7 +687,8 @@ export const COMMANDS: CommandSpec[] = [
687
687
  {
688
688
  flag: '--box',
689
689
  values: '<name>',
690
- description: 'Inbox name (default payment_inbox)',
690
+ description:
691
+ 'Paymail inbox name (default payment_inbox); metanet_inbox is always pulled',
691
692
  },
692
693
  ],
693
694
  },