@secondts/bark-react-native 0.23.0 → 0.24.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.
@@ -84,6 +84,23 @@ const uniffiIsDebug =
84
84
  false;
85
85
  // Public interface members begin here.
86
86
 
87
+ /**
88
+ * Default for `Config.vtxo_key_gap_limit`: the run of consecutive unused
89
+ * seed-derived VTXO key indices a scan crosses before concluding a VTXO
90
+ * isn't ours.
91
+ */
92
+ export function defaultVtxoKeyGapLimit(): /*u32*/ number {
93
+ return FfiConverterUInt32.lift(
94
+ uniffiCaller.rustCall(
95
+ /*caller:*/ (callStatus) => {
96
+ return nativeModule().ubrn_uniffi_bark_ffi_fn_func_default_vtxo_key_gap_limit(
97
+ callStatus
98
+ );
99
+ },
100
+ /*liftString:*/ FfiConverterString.lift
101
+ )
102
+ );
103
+ }
87
104
  /**
88
105
  * Extract a signed transaction from a PSBT
89
106
  *
@@ -128,6 +145,23 @@ export function generateMnemonic(): string /*throws*/ {
128
145
  )
129
146
  );
130
147
  }
148
+ /**
149
+ * Largest value `Config.vtxo_key_gap_limit` (or an import/recovery
150
+ * `gap_limit` override) accepts. A scan that matches nothing runs the limit
151
+ * to its end, so an unbounded limit is unbounded work.
152
+ */
153
+ export function maxVtxoKeyGapLimit(): /*u32*/ number {
154
+ return FfiConverterUInt32.lift(
155
+ uniffiCaller.rustCall(
156
+ /*caller:*/ (callStatus) => {
157
+ return nativeModule().ubrn_uniffi_bark_ffi_fn_func_max_vtxo_key_gap_limit(
158
+ callStatus
159
+ );
160
+ },
161
+ /*liftString:*/ FfiConverterString.lift
162
+ )
163
+ );
164
+ }
131
165
  /**
132
166
  * Validate an Ark address (basic format check only)
133
167
  *
@@ -626,6 +660,20 @@ export type Config = {
626
660
  daemonManualSync?: boolean;
627
661
  lightningReceiveClaimRetries?: /*u8*/ number;
628
662
  userAgent?: string;
663
+ /**
664
+ * How many consecutive unused seed-derived VTXO key indices a scan
665
+ * crosses before concluding a VTXO isn't ours.
666
+ *
667
+ * Used by `Wallet::recover_vtxos` and `Wallet::import_vtxo(s)`, and by
668
+ * the seed-recovery scan that runs at wallet creation. Every match
669
+ * extends the window, so this bounds the run of unused indices, not the
670
+ * total keys derived. Raise it for a wallet that handed out many
671
+ * addresses without receiving into them.
672
+ *
673
+ * Default: 250. Capped at 100_000; a higher value is rejected when the
674
+ * wallet is opened or created.
675
+ */
676
+ vtxoKeyGapLimit?: /*u32*/ number;
629
677
  };
630
678
 
631
679
  /**
@@ -665,6 +713,7 @@ const FfiConverterTypeConfig = (() => {
665
713
  daemonManualSync: FfiConverterOptionalBool.read(from),
666
714
  lightningReceiveClaimRetries: FfiConverterOptionalUInt8.read(from),
667
715
  userAgent: FfiConverterOptionalString.read(from),
716
+ vtxoKeyGapLimit: FfiConverterOptionalUInt32.read(from),
668
717
  };
669
718
  }
670
719
  write(value: TypeName, into: RustBuffer): void {
@@ -691,6 +740,7 @@ const FfiConverterTypeConfig = (() => {
691
740
  FfiConverterOptionalBool.write(value.daemonManualSync, into);
692
741
  FfiConverterOptionalUInt8.write(value.lightningReceiveClaimRetries, into);
693
742
  FfiConverterOptionalString.write(value.userAgent, into);
743
+ FfiConverterOptionalUInt32.write(value.vtxoKeyGapLimit, into);
694
744
  }
695
745
  allocationSize(value: TypeName): number {
696
746
  return (
@@ -720,7 +770,8 @@ const FfiConverterTypeConfig = (() => {
720
770
  FfiConverterOptionalUInt8.allocationSize(
721
771
  value.lightningReceiveClaimRetries
722
772
  ) +
723
- FfiConverterOptionalString.allocationSize(value.userAgent)
773
+ FfiConverterOptionalString.allocationSize(value.userAgent) +
774
+ FfiConverterOptionalUInt32.allocationSize(value.vtxoKeyGapLimit)
724
775
  );
725
776
  }
726
777
  }
@@ -1411,6 +1462,84 @@ const FfiConverterTypeFeeSchedule = (() => {
1411
1462
  return new FFIConverter();
1412
1463
  })();
1413
1464
 
1465
+ /**
1466
+ * Arguments for `Wallet::import_vtxo` / `Wallet::import_vtxos`, mirroring
1467
+ * `bark::ImportVtxoArgs`.
1468
+ *
1469
+ * Every field has a default, so callers only set what they need.
1470
+ */
1471
+ export type ImportVtxoArgs = {
1472
+ /**
1473
+ * Gap limit for the key scan that decides whether we own the VTXOs,
1474
+ * overriding `Config.vtxo_key_gap_limit` for this call.
1475
+ *
1476
+ * Default: none (use the wallet's configured limit)
1477
+ */
1478
+ gapLimit?: /*u32*/ number;
1479
+ /**
1480
+ * Import as spendable without asking the server for each VTXO's state.
1481
+ * Skipping the check is faster but can leave the wallet holding spent
1482
+ * VTXOs marked spendable, which then fail when selected as inputs.
1483
+ *
1484
+ * Default: false
1485
+ */
1486
+ skipStatusCheck: boolean;
1487
+ /**
1488
+ * Keep the VTXOs that import successfully even when another one in the
1489
+ * batch fails; the returned ids are the ones that were kept.
1490
+ *
1491
+ * Default: false, so a single failure discards the whole batch.
1492
+ */
1493
+ allowPartial: boolean;
1494
+ };
1495
+
1496
+ /**
1497
+ * Generated factory for {@link ImportVtxoArgs} record objects.
1498
+ */
1499
+ export const ImportVtxoArgs = (() => {
1500
+ const defaults = () => ({
1501
+ gapLimit: undefined,
1502
+ skipStatusCheck: false,
1503
+ allowPartial: false,
1504
+ });
1505
+ const create = (() => {
1506
+ return uniffiCreateRecord<ImportVtxoArgs, ReturnType<typeof defaults>>(
1507
+ defaults
1508
+ );
1509
+ })();
1510
+ return Object.freeze({
1511
+ create,
1512
+ new: create,
1513
+ defaults: () => Object.freeze(defaults()) as Partial<ImportVtxoArgs>,
1514
+ });
1515
+ })();
1516
+
1517
+ const FfiConverterTypeImportVtxoArgs = (() => {
1518
+ type TypeName = ImportVtxoArgs;
1519
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1520
+ read(from: RustBuffer): TypeName {
1521
+ return {
1522
+ gapLimit: FfiConverterOptionalUInt32.read(from),
1523
+ skipStatusCheck: FfiConverterBool.read(from),
1524
+ allowPartial: FfiConverterBool.read(from),
1525
+ };
1526
+ }
1527
+ write(value: TypeName, into: RustBuffer): void {
1528
+ FfiConverterOptionalUInt32.write(value.gapLimit, into);
1529
+ FfiConverterBool.write(value.skipStatusCheck, into);
1530
+ FfiConverterBool.write(value.allowPartial, into);
1531
+ }
1532
+ allocationSize(value: TypeName): number {
1533
+ return (
1534
+ FfiConverterOptionalUInt32.allocationSize(value.gapLimit) +
1535
+ FfiConverterBool.allocationSize(value.skipStatusCheck) +
1536
+ FfiConverterBool.allocationSize(value.allowPartial)
1537
+ );
1538
+ }
1539
+ }
1540
+ return new FFIConverter();
1541
+ })();
1542
+
1414
1543
  export type LightningInvoice = {
1415
1544
  invoice: string;
1416
1545
  paymentHash: string;
@@ -2196,11 +2325,12 @@ export type RecoveryReport = {
2196
2325
  */
2197
2326
  skipped: RecoveryBucket;
2198
2327
  /**
2199
- * No matching key could be derived within the gap limit (50 consecutive
2200
- * unused indices). For a mailbox scan these are most likely this wallet's
2328
+ * No matching key could be derived within the gap limit (the configured
2329
+ * run of consecutive unused key indices, 250 by default). For a mailbox scan these are most likely this wallet's
2201
2330
  * own VTXOs, keyed beyond the limit, so funds may be missing; retrying
2202
- * won't help, only a wider gap limit. For `recover_vtxos` it just means
2203
- * the caller passed an id this wallet doesn't own.
2331
+ * won't help, only a wider gap limit (see `Config.vtxo_key_gap_limit` and
2332
+ * the `gap_limit` override on `recover_vtxos`). For `recover_vtxos` it
2333
+ * just means the caller passed an id this wallet doesn't own.
2204
2334
  */
2205
2335
  foreign: RecoveryBucket;
2206
2336
  /**
@@ -2522,7 +2652,6 @@ export type WalletOpenArgs = {
2522
2652
  export const WalletOpenArgs = (() => {
2523
2653
  const defaults = () => ({
2524
2654
  runDaemon: true,
2525
- onchain: undefined,
2526
2655
  createIfNotExists: true,
2527
2656
  createWithoutServer: false,
2528
2657
  skipRecovery: false,
@@ -7473,14 +7602,34 @@ export interface WalletLike {
7473
7602
  /**
7474
7603
  * Import a VTXO from its serialized form (hex or base64).
7475
7604
  *
7476
- * The parameter keeps its historical `vtxo_base64` name for foreign
7605
+ * The VTXO is stored in the state the server reports for it, so one that
7606
+ * was already spent is recorded as spent rather than refused. Pass `args`
7607
+ * to widen the key-scan gap limit, skip the server status check, or allow
7608
+ * partial success; omit it for the defaults.
7609
+ *
7610
+ * The first parameter keeps its historical `vtxo_base64` name for foreign
7477
7611
  * binding compatibility (uniffi exposes parameter names), but hex as
7478
7612
  * returned by [`Wallet::vtxo_encoded`] is accepted too.
7479
7613
  */
7480
7614
  importVtxo(
7481
7615
  vtxoBase64: string,
7616
+ args: ImportVtxoArgs | undefined,
7482
7617
  asyncOpts_?: { signal: AbortSignal }
7483
7618
  ): /*throws*/ Promise<void>;
7619
+ /**
7620
+ * Import several VTXOs (hex or base64) under a single key scan and a
7621
+ * single write, which is why this is not just a loop over `import_vtxo`.
7622
+ *
7623
+ * Returns the ids now held — whether this call stored them or found them
7624
+ * already present — so a failed batch can be retried. One VTXO that cannot
7625
+ * be imported discards the whole batch unless `args.allow_partial` is set,
7626
+ * in which case the ones that did import are kept.
7627
+ */
7628
+ importVtxos(
7629
+ encodedVtxos: Array<string>,
7630
+ args: ImportVtxoArgs | undefined,
7631
+ asyncOpts_?: { signal: AbortSignal }
7632
+ ): /*throws*/ Promise<Array<string>>;
7484
7633
  isInvoicePaid(
7485
7634
  paymentHash: string,
7486
7635
  asyncOpts_?: { signal: AbortSignal }
@@ -7609,9 +7758,14 @@ export interface WalletLike {
7609
7758
  * Recover the given VTXO ids from the server, importing the ones this
7610
7759
  * wallet owns that are still spendable. Use it to retry ids a previous
7611
7760
  * scan reported as `failed`.
7761
+ *
7762
+ * `gap_limit` overrides `Config.vtxo_key_gap_limit` for the key scan that
7763
+ * decides which of `vtxo_ids` this wallet owns. Widen it to reach ids a
7764
+ * previous scan bucketed as `foreign`.
7612
7765
  */
7613
7766
  recoverVtxos(
7614
7767
  vtxoIds: Array<string>,
7768
+ gapLimit: /*u32*/ number | undefined,
7615
7769
  asyncOpts_?: { signal: AbortSignal }
7616
7770
  ): /*throws*/ Promise<RecoveryReport>;
7617
7771
  /**
@@ -9311,12 +9465,18 @@ export class Wallet extends UniffiAbstractObject implements WalletLike {
9311
9465
  /**
9312
9466
  * Import a VTXO from its serialized form (hex or base64).
9313
9467
  *
9314
- * The parameter keeps its historical `vtxo_base64` name for foreign
9468
+ * The VTXO is stored in the state the server reports for it, so one that
9469
+ * was already spent is recorded as spent rather than refused. Pass `args`
9470
+ * to widen the key-scan gap limit, skip the server status check, or allow
9471
+ * partial success; omit it for the defaults.
9472
+ *
9473
+ * The first parameter keeps its historical `vtxo_base64` name for foreign
9315
9474
  * binding compatibility (uniffi exposes parameter names), but hex as
9316
9475
  * returned by [`Wallet::vtxo_encoded`] is accepted too.
9317
9476
  */
9318
9477
  async importVtxo(
9319
9478
  vtxoBase64: string,
9479
+ args: ImportVtxoArgs | undefined = undefined,
9320
9480
  asyncOpts_?: { signal: AbortSignal }
9321
9481
  ): Promise<void> /*throws*/ {
9322
9482
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
@@ -9326,7 +9486,8 @@ export class Wallet extends UniffiAbstractObject implements WalletLike {
9326
9486
  /*rustFutureFunc:*/ () => {
9327
9487
  return nativeModule().ubrn_uniffi_bark_ffi_fn_method_wallet_import_vtxo(
9328
9488
  uniffiTypeWalletObjectFactory.clonePointer(this),
9329
- FfiConverterString.lower(vtxoBase64)
9489
+ FfiConverterString.lower(vtxoBase64),
9490
+ FfiConverterOptionalTypeImportVtxoArgs.lower(args)
9330
9491
  );
9331
9492
  },
9332
9493
  /*pollFunc:*/ nativeModule().ubrn_ffi_bark_ffi_rust_future_poll_void,
@@ -9348,6 +9509,54 @@ export class Wallet extends UniffiAbstractObject implements WalletLike {
9348
9509
  }
9349
9510
  }
9350
9511
 
9512
+ /**
9513
+ * Import several VTXOs (hex or base64) under a single key scan and a
9514
+ * single write, which is why this is not just a loop over `import_vtxo`.
9515
+ *
9516
+ * Returns the ids now held — whether this call stored them or found them
9517
+ * already present — so a failed batch can be retried. One VTXO that cannot
9518
+ * be imported discards the whole batch unless `args.allow_partial` is set,
9519
+ * in which case the ones that did import are kept.
9520
+ */
9521
+ async importVtxos(
9522
+ encodedVtxos: Array<string>,
9523
+ args: ImportVtxoArgs | undefined = undefined,
9524
+ asyncOpts_?: { signal: AbortSignal }
9525
+ ): Promise<Array<string>> /*throws*/ {
9526
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
9527
+ try {
9528
+ return await uniffiRustCallAsync(
9529
+ /*rustCaller:*/ uniffiCaller,
9530
+ /*rustFutureFunc:*/ () => {
9531
+ return nativeModule().ubrn_uniffi_bark_ffi_fn_method_wallet_import_vtxos(
9532
+ uniffiTypeWalletObjectFactory.clonePointer(this),
9533
+ FfiConverterArrayString.lower(encodedVtxos),
9534
+ FfiConverterOptionalTypeImportVtxoArgs.lower(args)
9535
+ );
9536
+ },
9537
+ /*pollFunc:*/ nativeModule()
9538
+ .ubrn_ffi_bark_ffi_rust_future_poll_rust_buffer,
9539
+ /*cancelFunc:*/ nativeModule()
9540
+ .ubrn_ffi_bark_ffi_rust_future_cancel_rust_buffer,
9541
+ /*completeFunc:*/ nativeModule()
9542
+ .ubrn_ffi_bark_ffi_rust_future_complete_rust_buffer,
9543
+ /*freeFunc:*/ nativeModule()
9544
+ .ubrn_ffi_bark_ffi_rust_future_free_rust_buffer,
9545
+ /*liftFunc:*/ FfiConverterArrayString.lift.bind(
9546
+ FfiConverterArrayString
9547
+ ),
9548
+ /*liftString:*/ FfiConverterString.lift,
9549
+ /*asyncOpts:*/ asyncOpts_,
9550
+ /*errorHandler:*/ FfiConverterTypeError.lift.bind(FfiConverterTypeError)
9551
+ );
9552
+ } catch (__error: any) {
9553
+ if (uniffiIsDebug && __error instanceof Error) {
9554
+ __error.stack = __stack;
9555
+ }
9556
+ throw __error;
9557
+ }
9558
+ }
9559
+
9351
9560
  async isInvoicePaid(
9352
9561
  paymentHash: string,
9353
9562
  asyncOpts_?: { signal: AbortSignal }
@@ -10472,9 +10681,14 @@ export class Wallet extends UniffiAbstractObject implements WalletLike {
10472
10681
  * Recover the given VTXO ids from the server, importing the ones this
10473
10682
  * wallet owns that are still spendable. Use it to retry ids a previous
10474
10683
  * scan reported as `failed`.
10684
+ *
10685
+ * `gap_limit` overrides `Config.vtxo_key_gap_limit` for the key scan that
10686
+ * decides which of `vtxo_ids` this wallet owns. Widen it to reach ids a
10687
+ * previous scan bucketed as `foreign`.
10475
10688
  */
10476
10689
  async recoverVtxos(
10477
10690
  vtxoIds: Array<string>,
10691
+ gapLimit: /*u32*/ number | undefined = undefined,
10478
10692
  asyncOpts_?: { signal: AbortSignal }
10479
10693
  ): Promise<RecoveryReport> /*throws*/ {
10480
10694
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
@@ -10484,7 +10698,8 @@ export class Wallet extends UniffiAbstractObject implements WalletLike {
10484
10698
  /*rustFutureFunc:*/ () => {
10485
10699
  return nativeModule().ubrn_uniffi_bark_ffi_fn_method_wallet_recover_vtxos(
10486
10700
  uniffiTypeWalletObjectFactory.clonePointer(this),
10487
- FfiConverterArrayString.lower(vtxoIds)
10701
+ FfiConverterArrayString.lower(vtxoIds),
10702
+ FfiConverterOptionalUInt32.lower(gapLimit)
10488
10703
  );
10489
10704
  },
10490
10705
  /*pollFunc:*/ nativeModule()
@@ -11539,6 +11754,11 @@ const FfiConverterOptionalTypeExitTransactionStatus = new FfiConverterOptional(
11539
11754
  FfiConverterTypeExitTransactionStatus
11540
11755
  );
11541
11756
 
11757
+ // FfiConverter for ImportVtxoArgs | undefined
11758
+ const FfiConverterOptionalTypeImportVtxoArgs = new FfiConverterOptional(
11759
+ FfiConverterTypeImportVtxoArgs
11760
+ );
11761
+
11542
11762
  // FfiConverter for RecoveryReport | undefined
11543
11763
  const FfiConverterOptionalTypeRecoveryReport = new FfiConverterOptional(
11544
11764
  FfiConverterTypeRecoveryReport
@@ -11682,6 +11902,14 @@ function uniffiEnsureInitialized() {
11682
11902
  bindingsContractVersion
11683
11903
  );
11684
11904
  }
11905
+ if (
11906
+ nativeModule().ubrn_uniffi_bark_ffi_checksum_func_default_vtxo_key_gap_limit() !==
11907
+ 3344
11908
+ ) {
11909
+ throw new UniffiInternalError.ApiChecksumMismatch(
11910
+ "uniffi_bark_ffi_checksum_func_default_vtxo_key_gap_limit"
11911
+ );
11912
+ }
11685
11913
  if (
11686
11914
  nativeModule().ubrn_uniffi_bark_ffi_checksum_func_extract_tx_from_psbt() !==
11687
11915
  8893
@@ -11698,6 +11926,14 @@ function uniffiEnsureInitialized() {
11698
11926
  "uniffi_bark_ffi_checksum_func_generate_mnemonic"
11699
11927
  );
11700
11928
  }
11929
+ if (
11930
+ nativeModule().ubrn_uniffi_bark_ffi_checksum_func_max_vtxo_key_gap_limit() !==
11931
+ 15808
11932
+ ) {
11933
+ throw new UniffiInternalError.ApiChecksumMismatch(
11934
+ "uniffi_bark_ffi_checksum_func_max_vtxo_key_gap_limit"
11935
+ );
11936
+ }
11701
11937
  if (
11702
11938
  nativeModule().ubrn_uniffi_bark_ffi_checksum_func_validate_ark_address() !==
11703
11939
  43084
@@ -12242,12 +12478,20 @@ function uniffiEnsureInitialized() {
12242
12478
  }
12243
12479
  if (
12244
12480
  nativeModule().ubrn_uniffi_bark_ffi_checksum_method_wallet_import_vtxo() !==
12245
- 48135
12481
+ 26027
12246
12482
  ) {
12247
12483
  throw new UniffiInternalError.ApiChecksumMismatch(
12248
12484
  "uniffi_bark_ffi_checksum_method_wallet_import_vtxo"
12249
12485
  );
12250
12486
  }
12487
+ if (
12488
+ nativeModule().ubrn_uniffi_bark_ffi_checksum_method_wallet_import_vtxos() !==
12489
+ 13727
12490
+ ) {
12491
+ throw new UniffiInternalError.ApiChecksumMismatch(
12492
+ "uniffi_bark_ffi_checksum_method_wallet_import_vtxos"
12493
+ );
12494
+ }
12251
12495
  if (
12252
12496
  nativeModule().ubrn_uniffi_bark_ffi_checksum_method_wallet_is_invoice_paid() !==
12253
12497
  31079
@@ -12514,7 +12758,7 @@ function uniffiEnsureInitialized() {
12514
12758
  }
12515
12759
  if (
12516
12760
  nativeModule().ubrn_uniffi_bark_ffi_checksum_method_wallet_recover_vtxos() !==
12517
- 640
12761
+ 56476
12518
12762
  ) {
12519
12763
  throw new UniffiInternalError.ApiChecksumMismatch(
12520
12764
  "uniffi_bark_ffi_checksum_method_wallet_recover_vtxos"
@@ -12793,6 +13037,7 @@ export default Object.freeze({
12793
13037
  FfiConverterTypeFeeEstimate,
12794
13038
  FfiConverterTypeFeeRates,
12795
13039
  FfiConverterTypeFeeSchedule,
13040
+ FfiConverterTypeImportVtxoArgs,
12796
13041
  FfiConverterTypeLightningInvoice,
12797
13042
  FfiConverterTypeLightningReceive,
12798
13043
  FfiConverterTypeLightningReceiveFees,