@1sat/cli 0.0.133 → 0.1.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/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, defaultChain = "main") {
@@ -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 inboxes (paymail remittances, BRC-169 handle payments). Not the same as `wallet sync` (address/owner scan).",
1434
+ description: "MessageBox inboxes (paymail remittances; BRC-232 deliveries: 1Color tokens and 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, then metanet_inbox (BRC-169 handle payments)",
1438
+ description: "Pull payment_inbox (default) and internalize paymail payments, then the transaction-delivery box (BRC-169 handle payments; 1Color tokens, submitted to --overlay first)",
1431
1439
  args: [
1432
1440
  {
1433
1441
  flag: "--url",
@@ -1437,7 +1445,12 @@ var init_help = __esm(() => {
1437
1445
  {
1438
1446
  flag: "--box",
1439
1447
  values: "<name>",
1440
- description: "Paymail inbox name (default payment_inbox); metanet_inbox is always pulled"
1448
+ description: "Paymail inbox name (default payment_inbox)"
1449
+ },
1450
+ {
1451
+ flag: "--overlay",
1452
+ values: "<url>",
1453
+ description: "BRC-22 overlay that received 1Color tokens are submitted to before internalizing (no default; without it, 1Color deliveries stay in the box)"
1441
1454
  }
1442
1455
  ]
1443
1456
  }
@@ -1665,7 +1678,7 @@ function createApprovalAuth(wallet) {
1665
1678
  get(target, property) {
1666
1679
  if (property === "createAction")
1667
1680
  return async (...args) => {
1668
- const satoshis = args[0].outputs?.reduce((sum, output2) => sum + output2.satoshis, 0) ?? 0;
1681
+ const satoshis = args[0].outputs?.reduce((sum, output) => sum + output.satoshis, 0) ?? 0;
1669
1682
  if (!Number.isSafeInteger(satoshis) || satoshis <= 0)
1670
1683
  throw new Error("Invalid HTTP payment amount");
1671
1684
  if (approved === false)
@@ -2189,15 +2202,15 @@ async function handleInitCommand(_args, opts) {
2189
2202
  }
2190
2203
  let wif;
2191
2204
  if (keySource === "generate") {
2192
- const pk2 = PrivateKey2.fromRandom();
2193
- wif = pk2.toWif();
2194
- const address2 = pk2.toPublicKey().toAddress(chain === "test" ? "test" : "main");
2205
+ const pk = PrivateKey2.fromRandom();
2206
+ wif = pk.toWif();
2207
+ const address = pk.toPublicKey().toAddress(chain === "test" ? "test" : "main");
2195
2208
  console.log();
2196
2209
  console.log(formatWarning(" IMPORTANT: Back up your private key!"));
2197
2210
  console.log(formatWarning(" If you lose it, your funds are gone forever."));
2198
2211
  console.log();
2199
2212
  console.log(` ${formatValue("WIF:")} ${wif}`);
2200
- console.log(` ${formatValue("Address:")} ${address2}`);
2213
+ console.log(` ${formatValue("Address:")} ${address}`);
2201
2214
  console.log();
2202
2215
  const confirmed = await confirm2({
2203
2216
  message: "Have you saved your private key somewhere safe?"
@@ -2614,7 +2627,7 @@ var init_mcp_proxy = __esm(() => {
2614
2627
  });
2615
2628
 
2616
2629
  // src/commands/messagebox.ts
2617
- import { syncMessages, syncMetanetInbox } from "@1sat/actions";
2630
+ import { syncMessages, syncTransactionInbox } from "@1sat/actions";
2618
2631
  async function handleMessageboxCommand(args, opts) {
2619
2632
  const [subcommand, ...rest] = args;
2620
2633
  switch (subcommand) {
@@ -2630,6 +2643,7 @@ async function handleMessageboxCommand(args, opts) {
2630
2643
  async function messageboxSync(args, opts) {
2631
2644
  const url = extractFlag(args, "--url");
2632
2645
  const box = extractFlag(args, "--box");
2646
+ const overlay = extractFlag(args, "--overlay");
2633
2647
  const privateKey = await loadKey();
2634
2648
  const { ctx, destroy } = await loadContext(privateKey, {
2635
2649
  chain: opts.chain
@@ -2639,8 +2653,9 @@ async function messageboxSync(args, opts) {
2639
2653
  ...url ? { messageboxUrl: url } : {},
2640
2654
  ...box ? { messageBox: box } : {}
2641
2655
  });
2642
- const metanet = await syncMetanetInbox.execute(ctx, {
2643
- ...url ? { messageboxUrl: url } : {}
2656
+ const metanet = await syncTransactionInbox.execute(ctx, {
2657
+ ...url ? { messageboxUrl: url } : {},
2658
+ ...overlay ? { overlay } : {}
2644
2659
  });
2645
2660
  if (opts.json) {
2646
2661
  output({ ...result, metanet }, opts);
@@ -2648,7 +2663,7 @@ async function messageboxSync(args, opts) {
2648
2663
  }
2649
2664
  console.log(`
2650
2665
  processed: ${result.processed} failed: ${result.failed}`);
2651
- console.log(`metanet_inbox: received ${metanet.received.length} skipped ${metanet.skipped.length}${metanet.error ? ` error: ${metanet.error}` : ""}`);
2666
+ console.log(`transaction-delivery: received ${metanet.received.length} skipped ${metanet.skipped.length}${metanet.error ? ` error: ${metanet.error}` : ""}`);
2652
2667
  for (const s of metanet.skipped) {
2653
2668
  console.log(` skipped ${s.messageId}: ${s.reason}`);
2654
2669
  }
@@ -3530,12 +3545,12 @@ async function permissionsRevoke(args, opts) {
3530
3545
  const originator = normalizeOriginator2(origin);
3531
3546
  const { store, path } = openStore(opts);
3532
3547
  if (hasFlag(args, "--all")) {
3533
- const removed2 = await store.deleteAllForOriginator(originator);
3548
+ const removed = await store.deleteAllForOriginator(originator);
3534
3549
  if (opts.json) {
3535
- output({ originator, removed: removed2, store: path }, opts);
3550
+ output({ originator, removed, store: path }, opts);
3536
3551
  return;
3537
3552
  }
3538
- output(`revoked ${removed2} grant(s) for ${originator}`, opts);
3553
+ output(`revoked ${removed} grant(s) for ${originator}`, opts);
3539
3554
  return;
3540
3555
  }
3541
3556
  let specs;
@@ -4731,11 +4746,11 @@ function selectedSweepClasses(only, skip) {
4731
4746
  throw new Error("--only and --skip are mutually exclusive");
4732
4747
  }
4733
4748
  if (only) {
4734
- const selected2 = parseSweepClasses(only, "--only");
4735
- if (selected2.size === 0) {
4749
+ const selected = parseSweepClasses(only, "--only");
4750
+ if (selected.size === 0) {
4736
4751
  throw new Error("--only requires at least one class");
4737
4752
  }
4738
- return selected2;
4753
+ return selected;
4739
4754
  }
4740
4755
  const selected = new Set(SWEEP_CLASSES);
4741
4756
  if (skip) {
@@ -5832,8 +5847,8 @@ async function walletListOutputs(args, opts) {
5832
5847
  ${result.totalOutputs} total outputs in basket '${basket}':
5833
5848
  `);
5834
5849
  for (const out of result.outputs) {
5835
- const tags2 = out.tags?.join(", ") || "none";
5836
- console.log(` ${out.outpoint} | ${out.satoshis} sats | tags: ${tags2}`);
5850
+ const tags = out.tags?.join(", ") || "none";
5851
+ console.log(` ${out.outpoint} | ${out.satoshis} sats | tags: ${tags}`);
5837
5852
  }
5838
5853
  console.log();
5839
5854
  }
@@ -6048,7 +6063,6 @@ var init_wallet = __esm(() => {
6048
6063
  });
6049
6064
 
6050
6065
  // src/main.ts
6051
- var exports_main = {};
6052
6066
  import { existsSync as existsSync5 } from "node:fs";
6053
6067
  import { resolve } from "node:path";
6054
6068
  import { config as loadEnv } from "dotenv";
@@ -6193,4 +6207,4 @@ var init_main = __esm(() => {
6193
6207
 
6194
6208
  // src/cli.ts
6195
6209
  process.env.DOTENV_CONFIG_QUIET = "true";
6196
- await Promise.resolve().then(() => (init_main(), exports_main));
6210
+ 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.133",
3
+ "version": "0.1.0",
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.235",
31
- "@1sat/client": "0.0.64",
32
- "@1sat/types": "0.0.53",
33
- "@1sat/wallet": "0.0.121",
34
- "@1sat/wallet-node": "0.0.88",
35
- "@1sat/wallet-server": "0.0.66",
30
+ "@1sat/actions": "0.1.0",
31
+ "@1sat/client": "0.1.0",
32
+ "@1sat/types": "0.1.0",
33
+ "@1sat/wallet": "0.1.0",
34
+ "@1sat/wallet-node": "0.1.0",
35
+ "@1sat/wallet-server": "0.1.0",
36
36
  "@bopen-io/messagebox-server": "^1.3.2",
37
- "@bsv/sdk": "^2.6.0",
38
- "@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@2.14.8",
39
- "@bsv/wallet-toolbox-client": "npm:@bopen-io/wallet-toolbox-client@2.14.8",
37
+ "@bsv/sdk": "npm:@bopen-io/sdk@4.0.0",
38
+ "@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@2.15.0",
39
+ "@bsv/wallet-toolbox-client": "npm:@bopen-io/wallet-toolbox-client@2.15.0",
40
40
  "@clack/prompts": "^0.8.0",
41
41
  "bitcoin-backup": "^0.0.11",
42
42
  "chalk": "^5.0.0",
@@ -1,11 +1,12 @@
1
1
  /**
2
- * MessageBox commands — pull paymail / P2P inbox and BRC-169 handle
3
- * payments (`metanet_inbox`) into the wallet.
2
+ * MessageBox commands — pull the paymail / P2P inbox and the
3
+ * `transaction-delivery` box (BRC-232 deliveries, 1Color tokens, BRC-169
4
+ * handle payments) into the wallet.
4
5
  *
5
- * 1sat messagebox sync [--url <host>] [--box <name>]
6
+ * 1sat messagebox sync [--url <host>] [--box <name>] [--overlay <url>]
6
7
  */
7
8
 
8
- import { syncMessages, syncMetanetInbox } from '@1sat/actions'
9
+ import { syncMessages, syncTransactionInbox } from '@1sat/actions'
9
10
  import type { GlobalFlags } from '../args.js'
10
11
  import { extractFlag } from '../args.js'
11
12
  import { loadContext } from '../context.js'
@@ -36,6 +37,7 @@ async function messageboxSync(
36
37
  ): Promise<void> {
37
38
  const url = extractFlag(args, '--url')
38
39
  const box = extractFlag(args, '--box')
40
+ const overlay = extractFlag(args, '--overlay')
39
41
 
40
42
  const privateKey = await loadKey()
41
43
  const { ctx, destroy } = await loadContext(privateKey, {
@@ -47,8 +49,11 @@ async function messageboxSync(
47
49
  ...(url ? { messageboxUrl: url } : {}),
48
50
  ...(box ? { messageBox: box } : {}),
49
51
  })
50
- const metanet = await syncMetanetInbox.execute(ctx, {
52
+ // 1Color receipts need an overlay to submit to; without one they stay
53
+ // in the box (overlay-required) and everything else is processed.
54
+ const metanet = await syncTransactionInbox.execute(ctx, {
51
55
  ...(url ? { messageboxUrl: url } : {}),
56
+ ...(overlay ? { overlay } : {}),
52
57
  })
53
58
 
54
59
  if (opts.json) {
@@ -58,7 +63,7 @@ async function messageboxSync(
58
63
 
59
64
  console.log(`\nprocessed: ${result.processed} failed: ${result.failed}`)
60
65
  console.log(
61
- `metanet_inbox: received ${metanet.received.length} skipped ${metanet.skipped.length}${metanet.error ? ` error: ${metanet.error}` : ''}`,
66
+ `transaction-delivery: received ${metanet.received.length} skipped ${metanet.skipped.length}${metanet.error ? ` error: ${metanet.error}` : ''}`,
62
67
  )
63
68
  for (const s of metanet.skipped) {
64
69
  console.log(` skipped ${s.messageId}: ${s.reason}`)
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 inboxes (paymail remittances, BRC-169 handle payments). Not the same as `wallet sync` (address/owner scan).',
674
+ 'MessageBox inboxes (paymail remittances; BRC-232 deliveries: 1Color tokens and 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, then metanet_inbox (BRC-169 handle payments)',
679
+ 'Pull payment_inbox (default) and internalize paymail payments, then the transaction-delivery box (BRC-169 handle payments; 1Color tokens, submitted to --overlay first)',
680
680
  args: [
681
681
  {
682
682
  flag: '--url',
@@ -687,8 +687,13 @@ export const COMMANDS: CommandSpec[] = [
687
687
  {
688
688
  flag: '--box',
689
689
  values: '<name>',
690
+ description: 'Paymail inbox name (default payment_inbox)',
691
+ },
692
+ {
693
+ flag: '--overlay',
694
+ values: '<url>',
690
695
  description:
691
- 'Paymail inbox name (default payment_inbox); metanet_inbox is always pulled',
696
+ 'BRC-22 overlay that received 1Color tokens are submitted to before internalizing (no default; without it, 1Color deliveries stay in the box)',
692
697
  },
693
698
  ],
694
699
  },