@1sat/cli 0.0.133 → 0.1.1

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}:`);
@@ -658,9 +666,6 @@ Run '1sat action' to list available actions.`);
658
666
  try {
659
667
  const result = await action.execute(ctx, input);
660
668
  output(result, opts);
661
- if (actionName === "cancelOwnedListings" && result !== null && typeof result === "object" && "errors" in result && Array.isArray(result.errors) && result.errors.length > 0) {
662
- process.exitCode = 1;
663
- }
664
669
  } finally {
665
670
  await destroy();
666
671
  }
@@ -1423,11 +1428,11 @@ var init_help = __esm(() => {
1423
1428
  {
1424
1429
  group: "Wallet",
1425
1430
  name: "messagebox",
1426
- description: "MessageBox inboxes (paymail remittances, BRC-169 handle payments). Not the same as `wallet sync` (address/owner scan).",
1431
+ 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
1432
  subcommands: [
1428
1433
  {
1429
1434
  name: "sync",
1430
- description: "Pull payment_inbox (default) and internalize paymail payments, then metanet_inbox (BRC-169 handle payments)",
1435
+ 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
1436
  args: [
1432
1437
  {
1433
1438
  flag: "--url",
@@ -1437,7 +1442,12 @@ var init_help = __esm(() => {
1437
1442
  {
1438
1443
  flag: "--box",
1439
1444
  values: "<name>",
1440
- description: "Paymail inbox name (default payment_inbox); metanet_inbox is always pulled"
1445
+ description: "Paymail inbox name (default payment_inbox)"
1446
+ },
1447
+ {
1448
+ flag: "--overlay",
1449
+ values: "<url>",
1450
+ description: "BRC-22 overlay that received 1Color tokens are submitted to before internalizing (no default; without it, 1Color deliveries stay in the box)"
1441
1451
  }
1442
1452
  ]
1443
1453
  }
@@ -1665,7 +1675,7 @@ function createApprovalAuth(wallet) {
1665
1675
  get(target, property) {
1666
1676
  if (property === "createAction")
1667
1677
  return async (...args) => {
1668
- const satoshis = args[0].outputs?.reduce((sum, output2) => sum + output2.satoshis, 0) ?? 0;
1678
+ const satoshis = args[0].outputs?.reduce((sum, output) => sum + output.satoshis, 0) ?? 0;
1669
1679
  if (!Number.isSafeInteger(satoshis) || satoshis <= 0)
1670
1680
  throw new Error("Invalid HTTP payment amount");
1671
1681
  if (approved === false)
@@ -2189,15 +2199,15 @@ async function handleInitCommand(_args, opts) {
2189
2199
  }
2190
2200
  let wif;
2191
2201
  if (keySource === "generate") {
2192
- const pk2 = PrivateKey2.fromRandom();
2193
- wif = pk2.toWif();
2194
- const address2 = pk2.toPublicKey().toAddress(chain === "test" ? "test" : "main");
2202
+ const pk = PrivateKey2.fromRandom();
2203
+ wif = pk.toWif();
2204
+ const address = pk.toPublicKey().toAddress(chain === "test" ? "test" : "main");
2195
2205
  console.log();
2196
2206
  console.log(formatWarning(" IMPORTANT: Back up your private key!"));
2197
2207
  console.log(formatWarning(" If you lose it, your funds are gone forever."));
2198
2208
  console.log();
2199
2209
  console.log(` ${formatValue("WIF:")} ${wif}`);
2200
- console.log(` ${formatValue("Address:")} ${address2}`);
2210
+ console.log(` ${formatValue("Address:")} ${address}`);
2201
2211
  console.log();
2202
2212
  const confirmed = await confirm2({
2203
2213
  message: "Have you saved your private key somewhere safe?"
@@ -2614,7 +2624,7 @@ var init_mcp_proxy = __esm(() => {
2614
2624
  });
2615
2625
 
2616
2626
  // src/commands/messagebox.ts
2617
- import { syncMessages, syncMetanetInbox } from "@1sat/actions";
2627
+ import { syncMessages, syncTransactionInbox } from "@1sat/actions";
2618
2628
  async function handleMessageboxCommand(args, opts) {
2619
2629
  const [subcommand, ...rest] = args;
2620
2630
  switch (subcommand) {
@@ -2630,6 +2640,7 @@ async function handleMessageboxCommand(args, opts) {
2630
2640
  async function messageboxSync(args, opts) {
2631
2641
  const url = extractFlag(args, "--url");
2632
2642
  const box = extractFlag(args, "--box");
2643
+ const overlay = extractFlag(args, "--overlay");
2633
2644
  const privateKey = await loadKey();
2634
2645
  const { ctx, destroy } = await loadContext(privateKey, {
2635
2646
  chain: opts.chain
@@ -2639,8 +2650,9 @@ async function messageboxSync(args, opts) {
2639
2650
  ...url ? { messageboxUrl: url } : {},
2640
2651
  ...box ? { messageBox: box } : {}
2641
2652
  });
2642
- const metanet = await syncMetanetInbox.execute(ctx, {
2643
- ...url ? { messageboxUrl: url } : {}
2653
+ const metanet = await syncTransactionInbox.execute(ctx, {
2654
+ ...url ? { messageboxUrl: url } : {},
2655
+ ...overlay ? { overlay } : {}
2644
2656
  });
2645
2657
  if (opts.json) {
2646
2658
  output({ ...result, metanet }, opts);
@@ -2648,7 +2660,7 @@ async function messageboxSync(args, opts) {
2648
2660
  }
2649
2661
  console.log(`
2650
2662
  processed: ${result.processed} failed: ${result.failed}`);
2651
- console.log(`metanet_inbox: received ${metanet.received.length} skipped ${metanet.skipped.length}${metanet.error ? ` error: ${metanet.error}` : ""}`);
2663
+ console.log(`transaction-delivery: received ${metanet.received.length} skipped ${metanet.skipped.length}${metanet.error ? ` error: ${metanet.error}` : ""}`);
2652
2664
  for (const s of metanet.skipped) {
2653
2665
  console.log(` skipped ${s.messageId}: ${s.reason}`);
2654
2666
  }
@@ -2676,7 +2688,7 @@ import {
2676
2688
  sellOpns,
2677
2689
  sendOpns
2678
2690
  } from "@1sat/actions";
2679
- import { P1SAT_PROTOCOL } from "@1sat/types";
2691
+ import { ORDLOCK_V2_TAG, P1SAT_PROTOCOL } from "@1sat/types";
2680
2692
  import { confirm as confirm4, isCancel as isCancel5 } from "@clack/prompts";
2681
2693
  async function handleOpnsCommand(args, opts) {
2682
2694
  const [subcommand, ...rest] = args;
@@ -2793,7 +2805,7 @@ async function opnsLookup(args, opts) {
2793
2805
  const nameTag = getDisplayValue(o, "name", "name") ?? "";
2794
2806
  const publishedTag = o.tags?.find((t) => t === "opns:published");
2795
2807
  const status = publishedTag ? "registered" : "unregistered";
2796
- const price = o.tags?.some((t) => t === "ordlock") ? o.tags?.find((t) => t.startsWith("price:"))?.slice("price:".length) ?? "?" : undefined;
2808
+ const price = o.tags?.some((t) => t === ORDLOCK_V2_TAG) ? o.tags?.find((t) => t.startsWith("price:"))?.slice("price:".length) ?? "?" : undefined;
2797
2809
  const listed = price ? ` ${formatLabel(`listed @ ${price}`)}` : "";
2798
2810
  console.log(` ${formatValue(id)} ${formatValue(o.outpoint)} ${nameTag ? formatValue(nameTag) : ""} ${formatLabel(status)}${listed}`);
2799
2811
  }
@@ -3530,12 +3542,12 @@ async function permissionsRevoke(args, opts) {
3530
3542
  const originator = normalizeOriginator2(origin);
3531
3543
  const { store, path } = openStore(opts);
3532
3544
  if (hasFlag(args, "--all")) {
3533
- const removed2 = await store.deleteAllForOriginator(originator);
3545
+ const removed = await store.deleteAllForOriginator(originator);
3534
3546
  if (opts.json) {
3535
- output({ originator, removed: removed2, store: path }, opts);
3547
+ output({ originator, removed, store: path }, opts);
3536
3548
  return;
3537
3549
  }
3538
- output(`revoked ${removed2} grant(s) for ${originator}`, opts);
3550
+ output(`revoked ${removed} grant(s) for ${originator}`, opts);
3539
3551
  return;
3540
3552
  }
3541
3553
  let specs;
@@ -4731,11 +4743,11 @@ function selectedSweepClasses(only, skip) {
4731
4743
  throw new Error("--only and --skip are mutually exclusive");
4732
4744
  }
4733
4745
  if (only) {
4734
- const selected2 = parseSweepClasses(only, "--only");
4735
- if (selected2.size === 0) {
4746
+ const selected = parseSweepClasses(only, "--only");
4747
+ if (selected.size === 0) {
4736
4748
  throw new Error("--only requires at least one class");
4737
4749
  }
4738
- return selected2;
4750
+ return selected;
4739
4751
  }
4740
4752
  const selected = new Set(SWEEP_CLASSES);
4741
4753
  if (skip) {
@@ -5832,8 +5844,8 @@ async function walletListOutputs(args, opts) {
5832
5844
  ${result.totalOutputs} total outputs in basket '${basket}':
5833
5845
  `);
5834
5846
  for (const out of result.outputs) {
5835
- const tags2 = out.tags?.join(", ") || "none";
5836
- console.log(` ${out.outpoint} | ${out.satoshis} sats | tags: ${tags2}`);
5847
+ const tags = out.tags?.join(", ") || "none";
5848
+ console.log(` ${out.outpoint} | ${out.satoshis} sats | tags: ${tags}`);
5837
5849
  }
5838
5850
  console.log();
5839
5851
  }
@@ -6048,7 +6060,6 @@ var init_wallet = __esm(() => {
6048
6060
  });
6049
6061
 
6050
6062
  // src/main.ts
6051
- var exports_main = {};
6052
6063
  import { existsSync as existsSync5 } from "node:fs";
6053
6064
  import { resolve } from "node:path";
6054
6065
  import { config as loadEnv } from "dotenv";
@@ -6193,4 +6204,4 @@ var init_main = __esm(() => {
6193
6204
 
6194
6205
  // src/cli.ts
6195
6206
  process.env.DOTENV_CONFIG_QUIET = "true";
6196
- await Promise.resolve().then(() => (init_main(), exports_main));
6207
+ 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.1",
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.1",
31
+ "@1sat/client": "0.1.1",
32
+ "@1sat/types": "0.1.1",
33
+ "@1sat/wallet": "0.1.1",
34
+ "@1sat/wallet-node": "0.1.1",
35
+ "@1sat/wallet-server": "0.1.1",
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": "^4.0.0",
38
+ "@bsv/wallet-toolbox": "^2.15.0",
39
+ "@bsv/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",
@@ -73,16 +73,6 @@ export async function handleActionCommand(
73
73
  try {
74
74
  const result = await action.execute(ctx, input)
75
75
  output(result, opts)
76
- if (
77
- actionName === 'cancelOwnedListings' &&
78
- result !== null &&
79
- typeof result === 'object' &&
80
- 'errors' in result &&
81
- Array.isArray(result.errors) &&
82
- result.errors.length > 0
83
- ) {
84
- process.exitCode = 1
85
- }
86
76
  } finally {
87
77
  await destroy()
88
78
  }
@@ -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}`)
@@ -13,7 +13,7 @@ import {
13
13
  sellOpns,
14
14
  sendOpns,
15
15
  } from '@1sat/actions'
16
- import { P1SAT_PROTOCOL } from '@1sat/types'
16
+ import { ORDLOCK_V2_TAG, P1SAT_PROTOCOL } from '@1sat/types'
17
17
  import { confirm, isCancel } from '@clack/prompts'
18
18
  import type { GlobalFlags } from '../args.js'
19
19
  import { extractFlag } from '../args.js'
@@ -160,7 +160,7 @@ async function opnsLookup(args: string[], opts: GlobalFlags): Promise<void> {
160
160
  const nameTag = getDisplayValue(o, 'name', 'name') ?? ''
161
161
  const publishedTag = o.tags?.find((t) => t === 'opns:published')
162
162
  const status = publishedTag ? 'registered' : 'unregistered'
163
- const price = o.tags?.some((t) => t === 'ordlock')
163
+ const price = o.tags?.some((t) => t === ORDLOCK_V2_TAG)
164
164
  ? (o.tags
165
165
  ?.find((t) => t.startsWith('price:'))
166
166
  ?.slice('price:'.length) ?? '?')
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
  },