@secondts/bark 0.9.0 → 0.11.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.
@@ -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 {
@@ -244,6 +278,9 @@ export interface Movement {
244
278
  createdAt: string;
245
279
  updatedAt: string;
246
280
  completedAt: string | undefined;
281
+ paymentHash: string | undefined;
282
+ lightningInvoice: string | undefined;
283
+ lightningOffer: string | undefined;
247
284
  }
248
285
 
249
286
  export interface OffboardResult {
@@ -257,6 +294,7 @@ export interface OnchainBalance {
257
294
  }
258
295
 
259
296
  export interface OnchainWalletDefaultArgs {
297
+ network: Network;
260
298
  mnemonic: string;
261
299
  config: Config;
262
300
  dbName: string;
@@ -265,13 +303,13 @@ export interface OnchainWalletDefaultArgs {
265
303
  export interface PayLightningInvoiceArgs {
266
304
  invoice: string;
267
305
  amountSats?: number;
268
- wait: boolean;
306
+ wait?: boolean;
269
307
  }
270
308
 
271
309
  export interface PayLightningOfferArgs {
272
310
  offer: string;
273
311
  amountSats?: number;
274
- wait: boolean;
312
+ wait?: boolean;
275
313
  }
276
314
 
277
315
  export interface PendingBoard {
@@ -285,12 +323,12 @@ export interface ProgressExitsArgs {
285
323
  }
286
324
 
287
325
  export interface TryClaimAllLightningReceivesArgs {
288
- wait: boolean;
326
+ wait?: boolean;
289
327
  }
290
328
 
291
329
  export interface TryClaimLightningReceiveArgs {
292
330
  paymentHash: string;
293
- wait: boolean;
331
+ wait?: boolean;
294
332
  }
295
333
 
296
334
  export interface Vtxo {
@@ -311,19 +349,6 @@ export interface Vtxo {
311
349
  exitTxWeightWu: number;
312
350
  }
313
351
 
314
- export interface WalletCreateArgs {
315
- mnemonic: string;
316
- config: Config;
317
- dbName: string;
318
- forceRescan: boolean;
319
- }
320
-
321
- export interface WalletOpenArgs {
322
- mnemonic: string;
323
- config: Config;
324
- dbName: string;
325
- }
326
-
327
352
  export interface WalletProperties {
328
353
  network: Network;
329
354
  fingerprint: string;
@@ -424,9 +449,13 @@ export class Wallet {
424
449
  cancelPendingRound(roundId: number): Promise<void>;
425
450
  checkLightningPayment(args: CheckLightningPaymentArgs): Promise<LightningSendStatus>;
426
451
  claimableLightningReceiveBalanceSats(): Promise<number>;
427
- config(): Promise<Config>;
428
- static create(args: WalletCreateArgs): Promise<Wallet>;
429
- 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>;
430
459
  drainExits(args: DrainExitsArgs): Promise<ExitClaimTransaction>;
431
460
  estimateArkoorPaymentFee(amountSats: number): Promise<FeeEstimate>;
432
461
  estimateBoardFee(amountSats: number): Promise<FeeEstimate>;
@@ -459,7 +488,6 @@ export class Wallet {
459
488
  maintenanceRefresh(): Promise<string | undefined>;
460
489
  maintenanceWithOnchain(onchainWallet: OnchainWallet): Promise<void>;
461
490
  maintenanceWithOnchainDelegated(onchainWallet: OnchainWallet): Promise<void>;
462
- maybeScheduleMaintenanceRefresh(): Promise<number | undefined>;
463
491
  network(): Promise<Network>;
464
492
  newAddress(): Promise<string>;
465
493
  newAddressWithIndex(): Promise<AddressWithIndex>;
@@ -467,8 +495,17 @@ export class Wallet {
467
495
  notifications(): NotificationHolder;
468
496
  offboardAll(bitcoinAddress: string): Promise<OffboardResult>;
469
497
  offboardVtxos(vtxoIds: string[], bitcoinAddress: string): Promise<string>;
470
- static open(args: WalletOpenArgs): Promise<Wallet>;
471
- 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>;
472
509
  payLightningInvoice(args: PayLightningInvoiceArgs): Promise<LightningSendStatus>;
473
510
  payLightningOffer(args: PayLightningOfferArgs): Promise<LightningSendStatus>;
474
511
  peekAddress(index: number): Promise<string>;
@@ -486,7 +523,7 @@ export class Wallet {
486
523
  refreshServer(): Promise<void>;
487
524
  refreshVtxos(vtxoIds: string[]): Promise<string | undefined>;
488
525
  refreshVtxosDelegated(vtxoIds: string[]): Promise<RoundState | undefined>;
489
- sendArkoorPayment(arkAddress: string, amountSats: number): Promise<string>;
526
+ sendArkoorPayment(arkAddress: string, amountSats: number): Promise<void>;
490
527
  sendOnchain(address: string, amountSats: number): Promise<string>;
491
528
  signExitClaimInputs(psbtBase64: string): Promise<string>;
492
529
  spendableVtxos(): Promise<Vtxo[]>;
@@ -495,6 +532,12 @@ export class Wallet {
495
532
  stuckFailedLightningSends(): Promise<LightningSend[]>;
496
533
  sync(): Promise<void>;
497
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>;
498
541
  syncPendingBoards(): Promise<void>;
499
542
  tryClaimAllLightningReceives(args: TryClaimAllLightningReceivesArgs): Promise<LightningReceive[]>;
500
543
  tryClaimLightningReceive(args: TryClaimLightningReceiveArgs): Promise<void>;