@1sat/cli 0.0.132 → 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 +53 -38
- package/package.json +10 -10
- package/src/args.ts +6 -2
- package/src/commands/init.ts +4 -2
- package/src/commands/messagebox.ts +11 -6
- package/src/commands/serve.ts +1 -1
- package/src/commands/storage.ts +1 -1
- package/src/commands/sweep.ts +7 -4
- package/src/help.ts +8 -3
- package/src/main.ts +2 -1
package/dist/cli.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
function parseGlobalFlags(args) {
|
|
15
|
+
function parseGlobalFlags(args, defaultChain = "main") {
|
|
8
16
|
let json = false;
|
|
9
17
|
let quiet = false;
|
|
10
18
|
let yes = false;
|
|
11
|
-
let chain =
|
|
19
|
+
let chain = defaultChain;
|
|
12
20
|
let help = false;
|
|
13
21
|
let version = false;
|
|
14
22
|
const envFiles = [];
|
|
@@ -622,11 +630,11 @@ async function handleActionCommand(args, opts) {
|
|
|
622
630
|
Registered actions:
|
|
623
631
|
`);
|
|
624
632
|
const grouped = new Map;
|
|
625
|
-
for (const
|
|
626
|
-
const cat =
|
|
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(
|
|
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
|
|
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
|
|
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)
|
|
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,
|
|
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
|
|
2193
|
-
wif =
|
|
2194
|
-
const
|
|
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:")} ${
|
|
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?"
|
|
@@ -2253,7 +2266,7 @@ async function handleInitCommand(_args, opts) {
|
|
|
2253
2266
|
storageIdentityKey: storageId
|
|
2254
2267
|
});
|
|
2255
2268
|
const pk = PrivateKey2.fromWif(wif);
|
|
2256
|
-
const address = pk.toPublicKey().toAddress();
|
|
2269
|
+
const address = pk.toPublicKey().toAddress(chain === "test" ? "test" : "main");
|
|
2257
2270
|
outro(formatSuccess(`Wallet configured! Address: ${address}`));
|
|
2258
2271
|
console.log();
|
|
2259
2272
|
console.log(` Want hosted storage? Run ${formatValue("1sat remote add <url>")} to attach a backup remote,`);
|
|
@@ -2614,7 +2627,7 @@ var init_mcp_proxy = __esm(() => {
|
|
|
2614
2627
|
});
|
|
2615
2628
|
|
|
2616
2629
|
// src/commands/messagebox.ts
|
|
2617
|
-
import { syncMessages,
|
|
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
|
|
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(`
|
|
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
|
|
3548
|
+
const removed = await store.deleteAllForOriginator(originator);
|
|
3534
3549
|
if (opts.json) {
|
|
3535
|
-
output({ originator, removed
|
|
3550
|
+
output({ originator, removed, store: path }, opts);
|
|
3536
3551
|
return;
|
|
3537
3552
|
}
|
|
3538
|
-
output(`revoked ${
|
|
3553
|
+
output(`revoked ${removed} grant(s) for ${originator}`, opts);
|
|
3539
3554
|
return;
|
|
3540
3555
|
}
|
|
3541
3556
|
let specs;
|
|
@@ -4259,7 +4274,7 @@ async function resolveServe(opts) {
|
|
|
4259
4274
|
fatal("server.storage.provider is pg but server.storage.dbUrl is not set. " + "Set it with: 1sat config set server.storage.dbUrl postgres://…");
|
|
4260
4275
|
}
|
|
4261
4276
|
const dataDir = ensureDataDir();
|
|
4262
|
-
const chain = opts.chain
|
|
4277
|
+
const chain = opts.chain;
|
|
4263
4278
|
let privateKey;
|
|
4264
4279
|
try {
|
|
4265
4280
|
privateKey = await loadKey();
|
|
@@ -4685,7 +4700,7 @@ function parseWindow(raw) {
|
|
|
4685
4700
|
}
|
|
4686
4701
|
async function openServeStorage(opts) {
|
|
4687
4702
|
const config = loadConfig();
|
|
4688
|
-
const chain = opts.chain
|
|
4703
|
+
const chain = opts.chain;
|
|
4689
4704
|
const storageConfig = config.server?.storage ?? { provider: "bun-sqlite" };
|
|
4690
4705
|
const baseOptions = StorageProvider2.createStorageBaseOptions(chain);
|
|
4691
4706
|
let storage;
|
|
@@ -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
|
|
4735
|
-
if (
|
|
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
|
|
4753
|
+
return selected;
|
|
4739
4754
|
}
|
|
4740
4755
|
const selected = new Set(SWEEP_CLASSES);
|
|
4741
4756
|
if (skip) {
|
|
@@ -4869,13 +4884,13 @@ async function handleSweepCommand(args, opts) {
|
|
|
4869
4884
|
}
|
|
4870
4885
|
}
|
|
4871
4886
|
}
|
|
4872
|
-
function loadSweepKey(args) {
|
|
4887
|
+
function loadSweepKey(args, chain) {
|
|
4873
4888
|
const wif = extractFlag(args, "--wif");
|
|
4874
4889
|
if (!wif)
|
|
4875
4890
|
fatal("Missing --wif <private-key>");
|
|
4876
4891
|
try {
|
|
4877
4892
|
const pk = PrivateKey4.fromWif(wif);
|
|
4878
|
-
return { wif, address: pk.toPublicKey().toAddress() };
|
|
4893
|
+
return { wif, address: pk.toPublicKey().toAddress(chain) };
|
|
4879
4894
|
} catch {
|
|
4880
4895
|
fatal("Invalid WIF private key");
|
|
4881
4896
|
}
|
|
@@ -4958,7 +4973,7 @@ function printInventory(address, plan, opts, mode) {
|
|
|
4958
4973
|
${transferable} transferable UTXO(s) in selected classes.`);
|
|
4959
4974
|
}
|
|
4960
4975
|
async function sweepScan(args, opts) {
|
|
4961
|
-
const { address } = loadSweepKey(args);
|
|
4976
|
+
const { address } = loadSweepKey(args, opts.chain);
|
|
4962
4977
|
const classes = loadClasses(args);
|
|
4963
4978
|
const privateKey = await loadKey();
|
|
4964
4979
|
const { ctx, destroy } = await loadContext(privateKey, {
|
|
@@ -4974,7 +4989,7 @@ async function sweepScan(args, opts) {
|
|
|
4974
4989
|
}
|
|
4975
4990
|
}
|
|
4976
4991
|
async function sweepImport(args, opts) {
|
|
4977
|
-
const { wif, address } = loadSweepKey(args);
|
|
4992
|
+
const { wif, address } = loadSweepKey(args, opts.chain);
|
|
4978
4993
|
const classes = loadClasses(args);
|
|
4979
4994
|
const dryRun = hasFlag(args, "--dry-run");
|
|
4980
4995
|
const sweepKey = PrivateKey4.fromWif(wif);
|
|
@@ -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
|
|
5836
|
-
console.log(` ${out.outpoint} | ${out.satoshis} sats | tags: ${
|
|
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";
|
|
@@ -6065,7 +6079,7 @@ function applyEnvFiles(paths) {
|
|
|
6065
6079
|
}
|
|
6066
6080
|
}
|
|
6067
6081
|
async function main() {
|
|
6068
|
-
const flags = parseGlobalFlags(rawArgs);
|
|
6082
|
+
const flags = parseGlobalFlags(rawArgs, loadConfig().chain);
|
|
6069
6083
|
if (flags.envFiles.length > 0) {
|
|
6070
6084
|
applyEnvFiles(flags.envFiles);
|
|
6071
6085
|
}
|
|
@@ -6178,6 +6192,7 @@ var init_main = __esm(() => {
|
|
|
6178
6192
|
init_tokens();
|
|
6179
6193
|
init_tx();
|
|
6180
6194
|
init_wallet();
|
|
6195
|
+
init_config();
|
|
6181
6196
|
init_help();
|
|
6182
6197
|
init_monitor_once();
|
|
6183
6198
|
init_output();
|
|
@@ -6192,4 +6207,4 @@ var init_main = __esm(() => {
|
|
|
6192
6207
|
|
|
6193
6208
|
// src/cli.ts
|
|
6194
6209
|
process.env.DOTENV_CONFIG_QUIET = "true";
|
|
6195
|
-
await Promise.resolve().then(() => (init_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
|
|
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
|
|
31
|
-
"@1sat/client": "0.0
|
|
32
|
-
"@1sat/types": "0.0
|
|
33
|
-
"@1sat/wallet": "0.0
|
|
34
|
-
"@1sat/wallet-node": "0.0
|
|
35
|
-
"@1sat/wallet-server": "0.0
|
|
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": "
|
|
38
|
-
"@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@2.
|
|
39
|
-
"@bsv/wallet-toolbox-client": "npm:@bopen-io/wallet-toolbox-client@2.
|
|
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",
|
package/src/args.ts
CHANGED
|
@@ -18,12 +18,16 @@ export interface GlobalFlags {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Parse global flags from raw argv, returning structured flags and remaining args.
|
|
21
|
+
* `chain` is `--chain` when given, otherwise `defaultChain` (the configured chain).
|
|
21
22
|
*/
|
|
22
|
-
export function parseGlobalFlags(
|
|
23
|
+
export function parseGlobalFlags(
|
|
24
|
+
args: string[],
|
|
25
|
+
defaultChain: 'main' | 'test' = 'main',
|
|
26
|
+
): GlobalFlags {
|
|
23
27
|
let json = false
|
|
24
28
|
let quiet = false
|
|
25
29
|
let yes = false
|
|
26
|
-
let chain
|
|
30
|
+
let chain = defaultChain
|
|
27
31
|
let help = false
|
|
28
32
|
let version = false
|
|
29
33
|
const envFiles: string[] = []
|
package/src/commands/init.ts
CHANGED
|
@@ -85,7 +85,9 @@ export async function handleInitCommand(
|
|
|
85
85
|
if (keySource === 'generate') {
|
|
86
86
|
const pk = PrivateKey.fromRandom()
|
|
87
87
|
wif = pk.toWif()
|
|
88
|
-
const address = pk
|
|
88
|
+
const address = pk
|
|
89
|
+
.toPublicKey()
|
|
90
|
+
.toAddress(chain === 'test' ? 'test' : 'main')
|
|
89
91
|
|
|
90
92
|
console.log()
|
|
91
93
|
console.log(formatWarning(' IMPORTANT: Back up your private key!'))
|
|
@@ -159,7 +161,7 @@ export async function handleInitCommand(
|
|
|
159
161
|
})
|
|
160
162
|
|
|
161
163
|
const pk = PrivateKey.fromWif(wif)
|
|
162
|
-
const address = pk.toPublicKey().toAddress()
|
|
164
|
+
const address = pk.toPublicKey().toAddress(chain === 'test' ? 'test' : 'main')
|
|
163
165
|
|
|
164
166
|
outro(formatSuccess(`Wallet configured! Address: ${address}`))
|
|
165
167
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MessageBox commands — pull paymail / P2P inbox and
|
|
3
|
-
*
|
|
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,
|
|
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
|
-
|
|
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
|
-
`
|
|
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/commands/serve.ts
CHANGED
package/src/commands/storage.ts
CHANGED
|
@@ -91,7 +91,7 @@ function parseWindow(raw: string): number | undefined {
|
|
|
91
91
|
/** Open the serve wallet's storage exactly as `1sat serve` resolves it. */
|
|
92
92
|
async function openServeStorage(opts: GlobalFlags): Promise<StorageProvider> {
|
|
93
93
|
const config = loadConfig()
|
|
94
|
-
const chain = opts.chain
|
|
94
|
+
const chain = opts.chain
|
|
95
95
|
const storageConfig = config.server?.storage ?? { provider: 'bun-sqlite' }
|
|
96
96
|
const baseOptions = StorageProvider.createStorageBaseOptions(chain)
|
|
97
97
|
|
package/src/commands/sweep.ts
CHANGED
|
@@ -56,12 +56,15 @@ export async function handleSweepCommand(
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
function loadSweepKey(
|
|
59
|
+
function loadSweepKey(
|
|
60
|
+
args: string[],
|
|
61
|
+
chain: 'main' | 'test',
|
|
62
|
+
): { wif: string; address: string } {
|
|
60
63
|
const wif = extractFlag(args, '--wif')
|
|
61
64
|
if (!wif) fatal('Missing --wif <private-key>')
|
|
62
65
|
try {
|
|
63
66
|
const pk = PrivateKey.fromWif(wif)
|
|
64
|
-
return { wif, address: pk.toPublicKey().toAddress() }
|
|
67
|
+
return { wif, address: pk.toPublicKey().toAddress(chain) }
|
|
65
68
|
} catch {
|
|
66
69
|
fatal('Invalid WIF private key')
|
|
67
70
|
}
|
|
@@ -174,7 +177,7 @@ function printInventory(
|
|
|
174
177
|
}
|
|
175
178
|
|
|
176
179
|
async function sweepScan(args: string[], opts: GlobalFlags): Promise<void> {
|
|
177
|
-
const { address } = loadSweepKey(args)
|
|
180
|
+
const { address } = loadSweepKey(args, opts.chain)
|
|
178
181
|
const classes = loadClasses(args)
|
|
179
182
|
|
|
180
183
|
const privateKey = await loadKey()
|
|
@@ -192,7 +195,7 @@ async function sweepScan(args: string[], opts: GlobalFlags): Promise<void> {
|
|
|
192
195
|
}
|
|
193
196
|
|
|
194
197
|
async function sweepImport(args: string[], opts: GlobalFlags): Promise<void> {
|
|
195
|
-
const { wif, address } = loadSweepKey(args)
|
|
198
|
+
const { wif, address } = loadSweepKey(args, opts.chain)
|
|
196
199
|
const classes = loadClasses(args)
|
|
197
200
|
const dryRun = hasFlag(args, '--dry-run')
|
|
198
201
|
const sweepKey = PrivateKey.fromWif(wif)
|
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
|
|
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
|
|
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
|
-
'
|
|
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
|
},
|
package/src/main.ts
CHANGED
|
@@ -30,6 +30,7 @@ import { handleSweepCommand } from './commands/sweep.js'
|
|
|
30
30
|
import { handleTokensCommand } from './commands/tokens.js'
|
|
31
31
|
import { handleTxCommand } from './commands/tx.js'
|
|
32
32
|
import { handleWalletCommand } from './commands/wallet.js'
|
|
33
|
+
import { loadConfig } from './config.js'
|
|
33
34
|
import {
|
|
34
35
|
getCommand,
|
|
35
36
|
printCommandHelp,
|
|
@@ -56,7 +57,7 @@ function applyEnvFiles(paths: string[]): void {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
async function main(): Promise<void> {
|
|
59
|
-
const flags = parseGlobalFlags(rawArgs)
|
|
60
|
+
const flags = parseGlobalFlags(rawArgs, loadConfig().chain)
|
|
60
61
|
if (flags.envFiles.length > 0) {
|
|
61
62
|
applyEnvFiles(flags.envFiles)
|
|
62
63
|
}
|