@1sat/cli 0.0.43 → 0.0.44

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/cli",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "description": "CLI for 1Sat Ordinals SDK",
5
5
  "type": "module",
6
6
  "main": "./src/cli.ts",
@@ -25,7 +25,7 @@
25
25
  ],
26
26
  "license": "MIT",
27
27
  "dependencies": {
28
- "@1sat/actions": "0.0.109",
28
+ "@1sat/actions": "0.0.110",
29
29
  "@1sat/client": "0.0.24",
30
30
  "@1sat/types": "0.0.18",
31
31
  "@1sat/wallet-node": "0.0.39",
@@ -3,7 +3,12 @@
3
3
  * BRC-100 interface commands - list-outputs, relinquish-output, list-actions, etc.
4
4
  */
5
5
 
6
- import { deriveDepositAddresses, sendAllBsv, sendBsv } from '@1sat/actions'
6
+ import {
7
+ deriveDepositAddresses,
8
+ sendAllBsv,
9
+ sendBsv,
10
+ syncAddresses,
11
+ } from '@1sat/actions'
7
12
  import { confirm, isCancel } from '@clack/prompts'
8
13
  import type { GlobalFlags } from '../args'
9
14
  import { extractFlag, extractFlags } from '../args'
@@ -27,6 +32,8 @@ export async function handleWalletCommand(
27
32
  return walletSend(rest, opts)
28
33
  case 'send-all':
29
34
  return walletSendAll(rest, opts)
35
+ case 'sync':
36
+ return walletSync(rest, opts)
30
37
  case 'info':
31
38
  return walletInfo(rest, opts)
32
39
  case 'list-outputs':
@@ -51,6 +58,7 @@ export async function handleWalletCommand(
51
58
  address: 'Show deposit address',
52
59
  send: 'Send BSV to an address (--to <addr> --sats <amount>)',
53
60
  'send-all': 'Send all BSV to an address (--to <addr>)',
61
+ sync: 'Sync inbound payments at BRC-29 deposit addresses [--prefix <p>] [--start-index <n>] [--count <n>]',
54
62
  info: 'Show wallet info (address, balance, network)',
55
63
  'list-outputs':
56
64
  'List wallet outputs (--basket <name> [--tags <t1,t2>] [--limit N] [--include-tags] [--include <val>])',
@@ -198,6 +206,52 @@ async function walletSendAll(args: string[], opts: GlobalFlags): Promise<void> {
198
206
  }
199
207
  }
200
208
 
209
+ async function walletSync(args: string[], opts: GlobalFlags): Promise<void> {
210
+ const prefix = extractFlag(args, '--prefix')
211
+ const startIndexRaw = extractFlag(args, '--start-index')
212
+ const countRaw = extractFlag(args, '--count')
213
+
214
+ const startIndex =
215
+ startIndexRaw !== undefined ? Number.parseInt(startIndexRaw, 10) : undefined
216
+ const count = countRaw !== undefined ? Number.parseInt(countRaw, 10) : undefined
217
+
218
+ if (startIndex !== undefined && (!Number.isFinite(startIndex) || startIndex < 0)) {
219
+ fatal('--start-index must be a non-negative integer')
220
+ }
221
+ if (count !== undefined && (!Number.isFinite(count) || count < 1)) {
222
+ fatal('--count must be a positive integer')
223
+ }
224
+
225
+ const privateKey = await loadKey(resolvePassword())
226
+ const { ctx, destroy } = await loadContext(privateKey, {
227
+ chain: opts.chain,
228
+ })
229
+
230
+ try {
231
+ const result = await syncAddresses.execute(ctx, {
232
+ ...(prefix ? { prefix } : {}),
233
+ ...(startIndex !== undefined ? { startIndex } : {}),
234
+ ...(count !== undefined ? { count } : {}),
235
+ })
236
+
237
+ if (opts.json) {
238
+ output(result, opts)
239
+ return
240
+ }
241
+
242
+ console.log(
243
+ `\nprocessed: ${result.processed} failed: ${result.failed} lastScore: ${result.lastScore}`,
244
+ )
245
+ if (result.addresses.length > 0) {
246
+ console.log('addresses:')
247
+ for (const addr of result.addresses) console.log(` ${addr}`)
248
+ }
249
+ console.log()
250
+ } finally {
251
+ await destroy()
252
+ }
253
+ }
254
+
201
255
  async function walletInfo(_args: string[], opts: GlobalFlags): Promise<void> {
202
256
  const privateKey = await loadKey(resolvePassword())
203
257
  const { ctx, destroy } = await loadContext(privateKey, {