@secondts/bark 0.10.0 → 0.11.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.
@@ -67,6 +67,40 @@ export interface ExitTransactionStatus {
67
67
  transactionCount: number;
68
68
  }
69
69
 
70
+ /**
71
+ * Optional arguments for [`Wallet::open`]
72
+ *
73
+ * Every field has a default, so callers only set what they need.
74
+ */
75
+ export interface OpenWalletArgs {
76
+ /**
77
+ * Whether to run the background daemon
78
+ *
79
+ * When disabled, you must manually call `Wallet::sync` to sync the wallet.
80
+ *
81
+ * Default: true
82
+ */
83
+ runDaemon?: boolean;
84
+ /**
85
+ * Optional name for IndexedDb
86
+ *
87
+ * Default: name based on wallet fingerprint
88
+ */
89
+ indexedDbName?: string;
90
+ /**
91
+ * Whether to create a new wallet if no wallet exists
92
+ *
93
+ * Default: true
94
+ */
95
+ createIfNotExists?: boolean;
96
+ /**
97
+ * Whether to create a new wallet even if the Ark server cannot be reached
98
+ *
99
+ * Default: false
100
+ */
101
+ createWithoutServer?: boolean;
102
+ }
103
+
70
104
  /**
71
105
  * Parameters for creating a CPFP (Child Pays For Parent) transaction
72
106
  */
@@ -149,7 +183,7 @@ export interface Bolt11InvoiceArgs {
149
183
 
150
184
  export interface CheckLightningPaymentArgs {
151
185
  paymentHash: string;
152
- wait: boolean;
186
+ wait?: boolean;
153
187
  }
154
188
 
155
189
  export interface Config {
@@ -160,7 +194,6 @@ export interface Config {
160
194
  bitcoindCookiefile?: string;
161
195
  bitcoindUser?: string;
162
196
  bitcoindPass?: string;
163
- network: Network;
164
197
  vtxoRefreshExpiryThreshold?: number;
165
198
  vtxoExitMargin?: number;
166
199
  htlcRecvClaimDelta?: number;
@@ -170,6 +203,7 @@ export interface Config {
170
203
  offboardRequiredConfirmations?: number;
171
204
  daemonManualSync?: boolean;
172
205
  lightningReceiveClaimRetries?: number;
206
+ userAgent?: string;
173
207
  }
174
208
 
175
209
  export interface DrainExitsArgs {
@@ -260,6 +294,7 @@ export interface OnchainBalance {
260
294
  }
261
295
 
262
296
  export interface OnchainWalletDefaultArgs {
297
+ network: Network;
263
298
  mnemonic: string;
264
299
  config: Config;
265
300
  dbName: string;
@@ -268,13 +303,13 @@ export interface OnchainWalletDefaultArgs {
268
303
  export interface PayLightningInvoiceArgs {
269
304
  invoice: string;
270
305
  amountSats?: number;
271
- wait: boolean;
306
+ wait?: boolean;
272
307
  }
273
308
 
274
309
  export interface PayLightningOfferArgs {
275
310
  offer: string;
276
311
  amountSats?: number;
277
- wait: boolean;
312
+ wait?: boolean;
278
313
  }
279
314
 
280
315
  export interface PendingBoard {
@@ -288,12 +323,12 @@ export interface ProgressExitsArgs {
288
323
  }
289
324
 
290
325
  export interface TryClaimAllLightningReceivesArgs {
291
- wait: boolean;
326
+ wait?: boolean;
292
327
  }
293
328
 
294
329
  export interface TryClaimLightningReceiveArgs {
295
330
  paymentHash: string;
296
- wait: boolean;
331
+ wait?: boolean;
297
332
  }
298
333
 
299
334
  export interface Vtxo {
@@ -314,19 +349,6 @@ export interface Vtxo {
314
349
  exitTxWeightWu: number;
315
350
  }
316
351
 
317
- export interface WalletCreateArgs {
318
- mnemonic: string;
319
- config: Config;
320
- dbName: string;
321
- forceRescan: boolean;
322
- }
323
-
324
- export interface WalletOpenArgs {
325
- mnemonic: string;
326
- config: Config;
327
- dbName: string;
328
- }
329
-
330
352
  export interface WalletProperties {
331
353
  network: Network;
332
354
  fingerprint: string;
@@ -427,9 +449,13 @@ export class Wallet {
427
449
  cancelPendingRound(roundId: number): Promise<void>;
428
450
  checkLightningPayment(args: CheckLightningPaymentArgs): Promise<LightningSendStatus>;
429
451
  claimableLightningReceiveBalanceSats(): Promise<number>;
430
- config(): Promise<Config>;
431
- static create(args: WalletCreateArgs): Promise<Wallet>;
432
- static createWithOnchain(onchainWallet: OnchainWallet, args: WalletCreateArgs): Promise<Wallet>;
452
+ config(): Config;
453
+ /**
454
+ * Low-level function to initialize a wallet
455
+ *
456
+ * You probably want to use [`Wallet::open`] instead.
457
+ */
458
+ static create(network: Network, mnemonic_or_seed: string, config: Config, indexedDbName: string | null | undefined, createWithoutServer: boolean): Promise<void>;
433
459
  drainExits(args: DrainExitsArgs): Promise<ExitClaimTransaction>;
434
460
  estimateArkoorPaymentFee(amountSats: number): Promise<FeeEstimate>;
435
461
  estimateBoardFee(amountSats: number): Promise<FeeEstimate>;
@@ -462,7 +488,6 @@ export class Wallet {
462
488
  maintenanceRefresh(): Promise<string | undefined>;
463
489
  maintenanceWithOnchain(onchainWallet: OnchainWallet): Promise<void>;
464
490
  maintenanceWithOnchainDelegated(onchainWallet: OnchainWallet): Promise<void>;
465
- maybeScheduleMaintenanceRefresh(): Promise<number | undefined>;
466
491
  network(): Promise<Network>;
467
492
  newAddress(): Promise<string>;
468
493
  newAddressWithIndex(): Promise<AddressWithIndex>;
@@ -470,8 +495,17 @@ export class Wallet {
470
495
  notifications(): NotificationHolder;
471
496
  offboardAll(bitcoinAddress: string): Promise<OffboardResult>;
472
497
  offboardVtxos(vtxoIds: string[], bitcoinAddress: string): Promise<string>;
473
- static open(args: WalletOpenArgs): Promise<Wallet>;
474
- static openWithOnchain(onchainWallet: OnchainWallet, args: WalletOpenArgs): Promise<Wallet>;
498
+ /**
499
+ * Open a wallet, mirroring [`bark::Wallet::open`]: a single entry point
500
+ * with everything optional. Set `createIfNotExists` to create the wallet
501
+ * if it doesn't exist yet (replacing the old `create` constructor).
502
+ *
503
+ * There is no separate `withOnchain` variant: onchain operations
504
+ * (boarding, exits, ...) take the onchain wallet per-call, and the web
505
+ * build has no background daemon, so the onchain wallet is never needed
506
+ * at open time.
507
+ */
508
+ static open(network: Network, mnemonic_or_seed: string, config: Config, onchain: OnchainWallet | null | undefined, args: OpenWalletArgs): Promise<Wallet>;
475
509
  payLightningInvoice(args: PayLightningInvoiceArgs): Promise<LightningSendStatus>;
476
510
  payLightningOffer(args: PayLightningOfferArgs): Promise<LightningSendStatus>;
477
511
  peekAddress(index: number): Promise<string>;
@@ -489,7 +523,7 @@ export class Wallet {
489
523
  refreshServer(): Promise<void>;
490
524
  refreshVtxos(vtxoIds: string[]): Promise<string | undefined>;
491
525
  refreshVtxosDelegated(vtxoIds: string[]): Promise<RoundState | undefined>;
492
- sendArkoorPayment(arkAddress: string, amountSats: number): Promise<string>;
526
+ sendArkoorPayment(arkAddress: string, amountSats: number): Promise<void>;
493
527
  sendOnchain(address: string, amountSats: number): Promise<string>;
494
528
  signExitClaimInputs(psbtBase64: string): Promise<string>;
495
529
  spendableVtxos(): Promise<Vtxo[]>;
@@ -498,6 +532,12 @@ export class Wallet {
498
532
  stuckFailedLightningSends(): Promise<LightningSend[]>;
499
533
  sync(): Promise<void>;
500
534
  syncExits(onchainWallet: OnchainWallet): Promise<void>;
535
+ /**
536
+ * Scan for VTXOs that were force-exited on-chain without the user asking
537
+ * and route them into the unilateral-exit flow so the funds can be claimed.
538
+ * This already runs automatically as part of `sync`.
539
+ */
540
+ syncForceExitedVtxos(): Promise<void>;
501
541
  syncPendingBoards(): Promise<void>;
502
542
  tryClaimAllLightningReceives(args: TryClaimAllLightningReceivesArgs): Promise<LightningReceive[]>;
503
543
  tryClaimLightningReceive(args: TryClaimLightningReceiveArgs): Promise<void>;