@breeztech/breez-sdk-spark-react-native 0.6.4-rc3 → 0.6.6

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.
@@ -61,6 +61,7 @@ import {
61
61
  FfiConverterUInt16,
62
62
  FfiConverterUInt32,
63
63
  FfiConverterUInt64,
64
+ FfiConverterUInt8,
64
65
  RustBuffer,
65
66
  UniffiAbstractObject,
66
67
  UniffiEnum,
@@ -1792,6 +1793,14 @@ export type Config = {
1792
1793
  * If set to false, no changes will be made to the Spark private mode.
1793
1794
  */
1794
1795
  privateEnabledDefault: boolean;
1796
+ /**
1797
+ * Configuration for leaf optimization.
1798
+ *
1799
+ * Leaf optimization controls the denominations of leaves that are held in the wallet.
1800
+ * Fewer, bigger leaves allow for more funds to be exited unilaterally.
1801
+ * More leaves allow payments to be made without needing a swap, reducing payment latency.
1802
+ */
1803
+ optimizationConfig: OptimizationConfig;
1795
1804
  };
1796
1805
 
1797
1806
  /**
@@ -1838,6 +1847,7 @@ const FfiConverterTypeConfig = (() => {
1838
1847
  useDefaultExternalInputParsers: FfiConverterBool.read(from),
1839
1848
  realTimeSyncServerUrl: FfiConverterOptionalString.read(from),
1840
1849
  privateEnabledDefault: FfiConverterBool.read(from),
1850
+ optimizationConfig: FfiConverterTypeOptimizationConfig.read(from),
1841
1851
  };
1842
1852
  }
1843
1853
  write(value: TypeName, into: RustBuffer): void {
@@ -1854,6 +1864,7 @@ const FfiConverterTypeConfig = (() => {
1854
1864
  FfiConverterBool.write(value.useDefaultExternalInputParsers, into);
1855
1865
  FfiConverterOptionalString.write(value.realTimeSyncServerUrl, into);
1856
1866
  FfiConverterBool.write(value.privateEnabledDefault, into);
1867
+ FfiConverterTypeOptimizationConfig.write(value.optimizationConfig, into);
1857
1868
  }
1858
1869
  allocationSize(value: TypeName): number {
1859
1870
  return (
@@ -1870,7 +1881,10 @@ const FfiConverterTypeConfig = (() => {
1870
1881
  ) +
1871
1882
  FfiConverterBool.allocationSize(value.useDefaultExternalInputParsers) +
1872
1883
  FfiConverterOptionalString.allocationSize(value.realTimeSyncServerUrl) +
1873
- FfiConverterBool.allocationSize(value.privateEnabledDefault)
1884
+ FfiConverterBool.allocationSize(value.privateEnabledDefault) +
1885
+ FfiConverterTypeOptimizationConfig.allocationSize(
1886
+ value.optimizationConfig
1887
+ )
1874
1888
  );
1875
1889
  }
1876
1890
  }
@@ -4466,6 +4480,144 @@ const FfiConverterTypeMintIssuerTokenRequest = (() => {
4466
4480
  return new FFIConverter();
4467
4481
  })();
4468
4482
 
4483
+ export type OptimizationConfig = {
4484
+ /**
4485
+ * Whether automatic leaf optimization is enabled.
4486
+ *
4487
+ * If set to true, the SDK will automatically optimize the leaf set when it changes.
4488
+ * Otherwise, the manual optimization API must be used to optimize the leaf set.
4489
+ *
4490
+ * Default value is true.
4491
+ */
4492
+ autoEnabled: boolean;
4493
+ /**
4494
+ * The desired multiplicity for the leaf set. Acceptable values are 0-5.
4495
+ *
4496
+ * Setting this to 0 will optimize for maximizing unilateral exit.
4497
+ * Higher values will optimize for minimizing transfer swaps, with higher values
4498
+ * being more aggressive.
4499
+ *
4500
+ * Default value is 1.
4501
+ */
4502
+ multiplicity: /*u8*/ number;
4503
+ };
4504
+
4505
+ /**
4506
+ * Generated factory for {@link OptimizationConfig} record objects.
4507
+ */
4508
+ export const OptimizationConfig = (() => {
4509
+ const defaults = () => ({});
4510
+ const create = (() => {
4511
+ return uniffiCreateRecord<OptimizationConfig, ReturnType<typeof defaults>>(
4512
+ defaults
4513
+ );
4514
+ })();
4515
+ return Object.freeze({
4516
+ /**
4517
+ * Create a frozen instance of {@link OptimizationConfig}, with defaults specified
4518
+ * in Rust, in the {@link breez_sdk_spark} crate.
4519
+ */
4520
+ create,
4521
+
4522
+ /**
4523
+ * Create a frozen instance of {@link OptimizationConfig}, with defaults specified
4524
+ * in Rust, in the {@link breez_sdk_spark} crate.
4525
+ */
4526
+ new: create,
4527
+
4528
+ /**
4529
+ * Defaults specified in the {@link breez_sdk_spark} crate.
4530
+ */
4531
+ defaults: () => Object.freeze(defaults()) as Partial<OptimizationConfig>,
4532
+ });
4533
+ })();
4534
+
4535
+ const FfiConverterTypeOptimizationConfig = (() => {
4536
+ type TypeName = OptimizationConfig;
4537
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
4538
+ read(from: RustBuffer): TypeName {
4539
+ return {
4540
+ autoEnabled: FfiConverterBool.read(from),
4541
+ multiplicity: FfiConverterUInt8.read(from),
4542
+ };
4543
+ }
4544
+ write(value: TypeName, into: RustBuffer): void {
4545
+ FfiConverterBool.write(value.autoEnabled, into);
4546
+ FfiConverterUInt8.write(value.multiplicity, into);
4547
+ }
4548
+ allocationSize(value: TypeName): number {
4549
+ return (
4550
+ FfiConverterBool.allocationSize(value.autoEnabled) +
4551
+ FfiConverterUInt8.allocationSize(value.multiplicity)
4552
+ );
4553
+ }
4554
+ }
4555
+ return new FFIConverter();
4556
+ })();
4557
+
4558
+ export type OptimizationProgress = {
4559
+ isRunning: boolean;
4560
+ currentRound: /*u32*/ number;
4561
+ totalRounds: /*u32*/ number;
4562
+ };
4563
+
4564
+ /**
4565
+ * Generated factory for {@link OptimizationProgress} record objects.
4566
+ */
4567
+ export const OptimizationProgress = (() => {
4568
+ const defaults = () => ({});
4569
+ const create = (() => {
4570
+ return uniffiCreateRecord<
4571
+ OptimizationProgress,
4572
+ ReturnType<typeof defaults>
4573
+ >(defaults);
4574
+ })();
4575
+ return Object.freeze({
4576
+ /**
4577
+ * Create a frozen instance of {@link OptimizationProgress}, with defaults specified
4578
+ * in Rust, in the {@link breez_sdk_spark} crate.
4579
+ */
4580
+ create,
4581
+
4582
+ /**
4583
+ * Create a frozen instance of {@link OptimizationProgress}, with defaults specified
4584
+ * in Rust, in the {@link breez_sdk_spark} crate.
4585
+ */
4586
+ new: create,
4587
+
4588
+ /**
4589
+ * Defaults specified in the {@link breez_sdk_spark} crate.
4590
+ */
4591
+ defaults: () => Object.freeze(defaults()) as Partial<OptimizationProgress>,
4592
+ });
4593
+ })();
4594
+
4595
+ const FfiConverterTypeOptimizationProgress = (() => {
4596
+ type TypeName = OptimizationProgress;
4597
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
4598
+ read(from: RustBuffer): TypeName {
4599
+ return {
4600
+ isRunning: FfiConverterBool.read(from),
4601
+ currentRound: FfiConverterUInt32.read(from),
4602
+ totalRounds: FfiConverterUInt32.read(from),
4603
+ };
4604
+ }
4605
+ write(value: TypeName, into: RustBuffer): void {
4606
+ FfiConverterBool.write(value.isRunning, into);
4607
+ FfiConverterUInt32.write(value.currentRound, into);
4608
+ FfiConverterUInt32.write(value.totalRounds, into);
4609
+ }
4610
+ allocationSize(value: TypeName): number {
4611
+ return (
4612
+ FfiConverterBool.allocationSize(value.isRunning) +
4613
+ FfiConverterUInt32.allocationSize(value.currentRound) +
4614
+ FfiConverterUInt32.allocationSize(value.totalRounds)
4615
+ );
4616
+ }
4617
+ }
4618
+ return new FFIConverter();
4619
+ })();
4620
+
4469
4621
  export type OutgoingChange = {
4470
4622
  change: RecordChange;
4471
4623
  parent: Record | undefined;
@@ -9662,6 +9814,327 @@ const FfiConverterTypeOnchainConfirmationSpeed = (() => {
9662
9814
  return new FFIConverter();
9663
9815
  })();
9664
9816
 
9817
+ // Enum: OptimizationEvent
9818
+ export enum OptimizationEvent_Tags {
9819
+ Started = 'Started',
9820
+ RoundCompleted = 'RoundCompleted',
9821
+ Completed = 'Completed',
9822
+ Cancelled = 'Cancelled',
9823
+ Failed = 'Failed',
9824
+ Skipped = 'Skipped',
9825
+ }
9826
+ export const OptimizationEvent = (() => {
9827
+ type Started__interface = {
9828
+ tag: OptimizationEvent_Tags.Started;
9829
+ inner: Readonly<{ totalRounds: /*u32*/ number }>;
9830
+ };
9831
+
9832
+ /**
9833
+ * Optimization has started with the given number of rounds.
9834
+ */
9835
+ class Started_ extends UniffiEnum implements Started__interface {
9836
+ /**
9837
+ * @private
9838
+ * This field is private and should not be used, use `tag` instead.
9839
+ */
9840
+ readonly [uniffiTypeNameSymbol] = 'OptimizationEvent';
9841
+ readonly tag = OptimizationEvent_Tags.Started;
9842
+ readonly inner: Readonly<{ totalRounds: /*u32*/ number }>;
9843
+ constructor(inner: { totalRounds: /*u32*/ number }) {
9844
+ super('OptimizationEvent', 'Started');
9845
+ this.inner = Object.freeze(inner);
9846
+ }
9847
+
9848
+ static new(inner: { totalRounds: /*u32*/ number }): Started_ {
9849
+ return new Started_(inner);
9850
+ }
9851
+
9852
+ static instanceOf(obj: any): obj is Started_ {
9853
+ return obj.tag === OptimizationEvent_Tags.Started;
9854
+ }
9855
+ }
9856
+
9857
+ type RoundCompleted__interface = {
9858
+ tag: OptimizationEvent_Tags.RoundCompleted;
9859
+ inner: Readonly<{
9860
+ currentRound: /*u32*/ number;
9861
+ totalRounds: /*u32*/ number;
9862
+ }>;
9863
+ };
9864
+
9865
+ /**
9866
+ * A round has completed.
9867
+ */
9868
+ class RoundCompleted_
9869
+ extends UniffiEnum
9870
+ implements RoundCompleted__interface
9871
+ {
9872
+ /**
9873
+ * @private
9874
+ * This field is private and should not be used, use `tag` instead.
9875
+ */
9876
+ readonly [uniffiTypeNameSymbol] = 'OptimizationEvent';
9877
+ readonly tag = OptimizationEvent_Tags.RoundCompleted;
9878
+ readonly inner: Readonly<{
9879
+ currentRound: /*u32*/ number;
9880
+ totalRounds: /*u32*/ number;
9881
+ }>;
9882
+ constructor(inner: {
9883
+ currentRound: /*u32*/ number;
9884
+ totalRounds: /*u32*/ number;
9885
+ }) {
9886
+ super('OptimizationEvent', 'RoundCompleted');
9887
+ this.inner = Object.freeze(inner);
9888
+ }
9889
+
9890
+ static new(inner: {
9891
+ currentRound: /*u32*/ number;
9892
+ totalRounds: /*u32*/ number;
9893
+ }): RoundCompleted_ {
9894
+ return new RoundCompleted_(inner);
9895
+ }
9896
+
9897
+ static instanceOf(obj: any): obj is RoundCompleted_ {
9898
+ return obj.tag === OptimizationEvent_Tags.RoundCompleted;
9899
+ }
9900
+ }
9901
+
9902
+ type Completed__interface = {
9903
+ tag: OptimizationEvent_Tags.Completed;
9904
+ };
9905
+
9906
+ /**
9907
+ * Optimization completed successfully.
9908
+ */
9909
+ class Completed_ extends UniffiEnum implements Completed__interface {
9910
+ /**
9911
+ * @private
9912
+ * This field is private and should not be used, use `tag` instead.
9913
+ */
9914
+ readonly [uniffiTypeNameSymbol] = 'OptimizationEvent';
9915
+ readonly tag = OptimizationEvent_Tags.Completed;
9916
+ constructor() {
9917
+ super('OptimizationEvent', 'Completed');
9918
+ }
9919
+
9920
+ static new(): Completed_ {
9921
+ return new Completed_();
9922
+ }
9923
+
9924
+ static instanceOf(obj: any): obj is Completed_ {
9925
+ return obj.tag === OptimizationEvent_Tags.Completed;
9926
+ }
9927
+ }
9928
+
9929
+ type Cancelled__interface = {
9930
+ tag: OptimizationEvent_Tags.Cancelled;
9931
+ };
9932
+
9933
+ /**
9934
+ * Optimization was cancelled.
9935
+ */
9936
+ class Cancelled_ extends UniffiEnum implements Cancelled__interface {
9937
+ /**
9938
+ * @private
9939
+ * This field is private and should not be used, use `tag` instead.
9940
+ */
9941
+ readonly [uniffiTypeNameSymbol] = 'OptimizationEvent';
9942
+ readonly tag = OptimizationEvent_Tags.Cancelled;
9943
+ constructor() {
9944
+ super('OptimizationEvent', 'Cancelled');
9945
+ }
9946
+
9947
+ static new(): Cancelled_ {
9948
+ return new Cancelled_();
9949
+ }
9950
+
9951
+ static instanceOf(obj: any): obj is Cancelled_ {
9952
+ return obj.tag === OptimizationEvent_Tags.Cancelled;
9953
+ }
9954
+ }
9955
+
9956
+ type Failed__interface = {
9957
+ tag: OptimizationEvent_Tags.Failed;
9958
+ inner: Readonly<{ error: string }>;
9959
+ };
9960
+
9961
+ /**
9962
+ * Optimization failed with an error.
9963
+ */
9964
+ class Failed_ extends UniffiEnum implements Failed__interface {
9965
+ /**
9966
+ * @private
9967
+ * This field is private and should not be used, use `tag` instead.
9968
+ */
9969
+ readonly [uniffiTypeNameSymbol] = 'OptimizationEvent';
9970
+ readonly tag = OptimizationEvent_Tags.Failed;
9971
+ readonly inner: Readonly<{ error: string }>;
9972
+ constructor(inner: { error: string }) {
9973
+ super('OptimizationEvent', 'Failed');
9974
+ this.inner = Object.freeze(inner);
9975
+ }
9976
+
9977
+ static new(inner: { error: string }): Failed_ {
9978
+ return new Failed_(inner);
9979
+ }
9980
+
9981
+ static instanceOf(obj: any): obj is Failed_ {
9982
+ return obj.tag === OptimizationEvent_Tags.Failed;
9983
+ }
9984
+ }
9985
+
9986
+ type Skipped__interface = {
9987
+ tag: OptimizationEvent_Tags.Skipped;
9988
+ };
9989
+
9990
+ /**
9991
+ * Optimization was skipped because leaves are already optimal.
9992
+ */
9993
+ class Skipped_ extends UniffiEnum implements Skipped__interface {
9994
+ /**
9995
+ * @private
9996
+ * This field is private and should not be used, use `tag` instead.
9997
+ */
9998
+ readonly [uniffiTypeNameSymbol] = 'OptimizationEvent';
9999
+ readonly tag = OptimizationEvent_Tags.Skipped;
10000
+ constructor() {
10001
+ super('OptimizationEvent', 'Skipped');
10002
+ }
10003
+
10004
+ static new(): Skipped_ {
10005
+ return new Skipped_();
10006
+ }
10007
+
10008
+ static instanceOf(obj: any): obj is Skipped_ {
10009
+ return obj.tag === OptimizationEvent_Tags.Skipped;
10010
+ }
10011
+ }
10012
+
10013
+ function instanceOf(obj: any): obj is OptimizationEvent {
10014
+ return obj[uniffiTypeNameSymbol] === 'OptimizationEvent';
10015
+ }
10016
+
10017
+ return Object.freeze({
10018
+ instanceOf,
10019
+ Started: Started_,
10020
+ RoundCompleted: RoundCompleted_,
10021
+ Completed: Completed_,
10022
+ Cancelled: Cancelled_,
10023
+ Failed: Failed_,
10024
+ Skipped: Skipped_,
10025
+ });
10026
+ })();
10027
+
10028
+ export type OptimizationEvent = InstanceType<
10029
+ (typeof OptimizationEvent)[keyof Omit<typeof OptimizationEvent, 'instanceOf'>]
10030
+ >;
10031
+
10032
+ // FfiConverter for enum OptimizationEvent
10033
+ const FfiConverterTypeOptimizationEvent = (() => {
10034
+ const ordinalConverter = FfiConverterInt32;
10035
+ type TypeName = OptimizationEvent;
10036
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
10037
+ read(from: RustBuffer): TypeName {
10038
+ switch (ordinalConverter.read(from)) {
10039
+ case 1:
10040
+ return new OptimizationEvent.Started({
10041
+ totalRounds: FfiConverterUInt32.read(from),
10042
+ });
10043
+ case 2:
10044
+ return new OptimizationEvent.RoundCompleted({
10045
+ currentRound: FfiConverterUInt32.read(from),
10046
+ totalRounds: FfiConverterUInt32.read(from),
10047
+ });
10048
+ case 3:
10049
+ return new OptimizationEvent.Completed();
10050
+ case 4:
10051
+ return new OptimizationEvent.Cancelled();
10052
+ case 5:
10053
+ return new OptimizationEvent.Failed({
10054
+ error: FfiConverterString.read(from),
10055
+ });
10056
+ case 6:
10057
+ return new OptimizationEvent.Skipped();
10058
+ default:
10059
+ throw new UniffiInternalError.UnexpectedEnumCase();
10060
+ }
10061
+ }
10062
+ write(value: TypeName, into: RustBuffer): void {
10063
+ switch (value.tag) {
10064
+ case OptimizationEvent_Tags.Started: {
10065
+ ordinalConverter.write(1, into);
10066
+ const inner = value.inner;
10067
+ FfiConverterUInt32.write(inner.totalRounds, into);
10068
+ return;
10069
+ }
10070
+ case OptimizationEvent_Tags.RoundCompleted: {
10071
+ ordinalConverter.write(2, into);
10072
+ const inner = value.inner;
10073
+ FfiConverterUInt32.write(inner.currentRound, into);
10074
+ FfiConverterUInt32.write(inner.totalRounds, into);
10075
+ return;
10076
+ }
10077
+ case OptimizationEvent_Tags.Completed: {
10078
+ ordinalConverter.write(3, into);
10079
+ return;
10080
+ }
10081
+ case OptimizationEvent_Tags.Cancelled: {
10082
+ ordinalConverter.write(4, into);
10083
+ return;
10084
+ }
10085
+ case OptimizationEvent_Tags.Failed: {
10086
+ ordinalConverter.write(5, into);
10087
+ const inner = value.inner;
10088
+ FfiConverterString.write(inner.error, into);
10089
+ return;
10090
+ }
10091
+ case OptimizationEvent_Tags.Skipped: {
10092
+ ordinalConverter.write(6, into);
10093
+ return;
10094
+ }
10095
+ default:
10096
+ // Throwing from here means that OptimizationEvent_Tags hasn't matched an ordinal.
10097
+ throw new UniffiInternalError.UnexpectedEnumCase();
10098
+ }
10099
+ }
10100
+ allocationSize(value: TypeName): number {
10101
+ switch (value.tag) {
10102
+ case OptimizationEvent_Tags.Started: {
10103
+ const inner = value.inner;
10104
+ let size = ordinalConverter.allocationSize(1);
10105
+ size += FfiConverterUInt32.allocationSize(inner.totalRounds);
10106
+ return size;
10107
+ }
10108
+ case OptimizationEvent_Tags.RoundCompleted: {
10109
+ const inner = value.inner;
10110
+ let size = ordinalConverter.allocationSize(2);
10111
+ size += FfiConverterUInt32.allocationSize(inner.currentRound);
10112
+ size += FfiConverterUInt32.allocationSize(inner.totalRounds);
10113
+ return size;
10114
+ }
10115
+ case OptimizationEvent_Tags.Completed: {
10116
+ return ordinalConverter.allocationSize(3);
10117
+ }
10118
+ case OptimizationEvent_Tags.Cancelled: {
10119
+ return ordinalConverter.allocationSize(4);
10120
+ }
10121
+ case OptimizationEvent_Tags.Failed: {
10122
+ const inner = value.inner;
10123
+ let size = ordinalConverter.allocationSize(5);
10124
+ size += FfiConverterString.allocationSize(inner.error);
10125
+ return size;
10126
+ }
10127
+ case OptimizationEvent_Tags.Skipped: {
10128
+ return ordinalConverter.allocationSize(6);
10129
+ }
10130
+ default:
10131
+ throw new UniffiInternalError.UnexpectedEnumCase();
10132
+ }
10133
+ }
10134
+ }
10135
+ return new FFIConverter();
10136
+ })();
10137
+
9665
10138
  // Enum: PaymentDetails
9666
10139
  export enum PaymentDetails_Tags {
9667
10140
  Spark = 'Spark',
@@ -10820,6 +11293,7 @@ export const ReceivePaymentMethod = (() => {
10820
11293
  inner: Readonly<{
10821
11294
  description: string;
10822
11295
  amountSats: /*u64*/ bigint | undefined;
11296
+ expirySecs: /*u32*/ number | undefined;
10823
11297
  }>;
10824
11298
  };
10825
11299
 
@@ -10833,10 +11307,14 @@ export const ReceivePaymentMethod = (() => {
10833
11307
  readonly inner: Readonly<{
10834
11308
  description: string;
10835
11309
  amountSats: /*u64*/ bigint | undefined;
11310
+ expirySecs: /*u32*/ number | undefined;
10836
11311
  }>;
10837
11312
  constructor(inner: {
10838
11313
  description: string;
10839
11314
  amountSats: /*u64*/ bigint | undefined;
11315
+ /**
11316
+ * The expiry time of the invoice in seconds
11317
+ */ expirySecs: /*u32*/ number | undefined;
10840
11318
  }) {
10841
11319
  super('ReceivePaymentMethod', 'Bolt11Invoice');
10842
11320
  this.inner = Object.freeze(inner);
@@ -10845,6 +11323,9 @@ export const ReceivePaymentMethod = (() => {
10845
11323
  static new(inner: {
10846
11324
  description: string;
10847
11325
  amountSats: /*u64*/ bigint | undefined;
11326
+ /**
11327
+ * The expiry time of the invoice in seconds
11328
+ */ expirySecs: /*u32*/ number | undefined;
10848
11329
  }): Bolt11Invoice_ {
10849
11330
  return new Bolt11Invoice_(inner);
10850
11331
  }
@@ -10897,6 +11378,7 @@ const FfiConverterTypeReceivePaymentMethod = (() => {
10897
11378
  return new ReceivePaymentMethod.Bolt11Invoice({
10898
11379
  description: FfiConverterString.read(from),
10899
11380
  amountSats: FfiConverterOptionalUInt64.read(from),
11381
+ expirySecs: FfiConverterOptionalUInt32.read(from),
10900
11382
  });
10901
11383
  default:
10902
11384
  throw new UniffiInternalError.UnexpectedEnumCase();
@@ -10927,6 +11409,7 @@ const FfiConverterTypeReceivePaymentMethod = (() => {
10927
11409
  const inner = value.inner;
10928
11410
  FfiConverterString.write(inner.description, into);
10929
11411
  FfiConverterOptionalUInt64.write(inner.amountSats, into);
11412
+ FfiConverterOptionalUInt32.write(inner.expirySecs, into);
10930
11413
  return;
10931
11414
  }
10932
11415
  default:
@@ -10961,6 +11444,7 @@ const FfiConverterTypeReceivePaymentMethod = (() => {
10961
11444
  let size = ordinalConverter.allocationSize(4);
10962
11445
  size += FfiConverterString.allocationSize(inner.description);
10963
11446
  size += FfiConverterOptionalUInt64.allocationSize(inner.amountSats);
11447
+ size += FfiConverterOptionalUInt32.allocationSize(inner.expirySecs);
10964
11448
  return size;
10965
11449
  }
10966
11450
  default:
@@ -11613,6 +12097,7 @@ export enum SdkEvent_Tags {
11613
12097
  PaymentSucceeded = 'PaymentSucceeded',
11614
12098
  PaymentPending = 'PaymentPending',
11615
12099
  PaymentFailed = 'PaymentFailed',
12100
+ Optimization = 'Optimization',
11616
12101
  }
11617
12102
  /**
11618
12103
  * Events emitted by the SDK
@@ -11799,6 +12284,33 @@ export const SdkEvent = (() => {
11799
12284
  }
11800
12285
  }
11801
12286
 
12287
+ type Optimization__interface = {
12288
+ tag: SdkEvent_Tags.Optimization;
12289
+ inner: Readonly<{ optimizationEvent: OptimizationEvent }>;
12290
+ };
12291
+
12292
+ class Optimization_ extends UniffiEnum implements Optimization__interface {
12293
+ /**
12294
+ * @private
12295
+ * This field is private and should not be used, use `tag` instead.
12296
+ */
12297
+ readonly [uniffiTypeNameSymbol] = 'SdkEvent';
12298
+ readonly tag = SdkEvent_Tags.Optimization;
12299
+ readonly inner: Readonly<{ optimizationEvent: OptimizationEvent }>;
12300
+ constructor(inner: { optimizationEvent: OptimizationEvent }) {
12301
+ super('SdkEvent', 'Optimization');
12302
+ this.inner = Object.freeze(inner);
12303
+ }
12304
+
12305
+ static new(inner: { optimizationEvent: OptimizationEvent }): Optimization_ {
12306
+ return new Optimization_(inner);
12307
+ }
12308
+
12309
+ static instanceOf(obj: any): obj is Optimization_ {
12310
+ return obj.tag === SdkEvent_Tags.Optimization;
12311
+ }
12312
+ }
12313
+
11802
12314
  function instanceOf(obj: any): obj is SdkEvent {
11803
12315
  return obj[uniffiTypeNameSymbol] === 'SdkEvent';
11804
12316
  }
@@ -11811,6 +12323,7 @@ export const SdkEvent = (() => {
11811
12323
  PaymentSucceeded: PaymentSucceeded_,
11812
12324
  PaymentPending: PaymentPending_,
11813
12325
  PaymentFailed: PaymentFailed_,
12326
+ Optimization: Optimization_,
11814
12327
  });
11815
12328
  })();
11816
12329
 
@@ -11851,6 +12364,10 @@ const FfiConverterTypeSdkEvent = (() => {
11851
12364
  return new SdkEvent.PaymentFailed({
11852
12365
  payment: FfiConverterTypePayment.read(from),
11853
12366
  });
12367
+ case 7:
12368
+ return new SdkEvent.Optimization({
12369
+ optimizationEvent: FfiConverterTypeOptimizationEvent.read(from),
12370
+ });
11854
12371
  default:
11855
12372
  throw new UniffiInternalError.UnexpectedEnumCase();
11856
12373
  }
@@ -11891,6 +12408,15 @@ const FfiConverterTypeSdkEvent = (() => {
11891
12408
  FfiConverterTypePayment.write(inner.payment, into);
11892
12409
  return;
11893
12410
  }
12411
+ case SdkEvent_Tags.Optimization: {
12412
+ ordinalConverter.write(7, into);
12413
+ const inner = value.inner;
12414
+ FfiConverterTypeOptimizationEvent.write(
12415
+ inner.optimizationEvent,
12416
+ into
12417
+ );
12418
+ return;
12419
+ }
11894
12420
  default:
11895
12421
  // Throwing from here means that SdkEvent_Tags hasn't matched an ordinal.
11896
12422
  throw new UniffiInternalError.UnexpectedEnumCase();
@@ -11935,6 +12461,14 @@ const FfiConverterTypeSdkEvent = (() => {
11935
12461
  size += FfiConverterTypePayment.allocationSize(inner.payment);
11936
12462
  return size;
11937
12463
  }
12464
+ case SdkEvent_Tags.Optimization: {
12465
+ const inner = value.inner;
12466
+ let size = ordinalConverter.allocationSize(7);
12467
+ size += FfiConverterTypeOptimizationEvent.allocationSize(
12468
+ inner.optimizationEvent
12469
+ );
12470
+ return size;
12471
+ }
11938
12472
  default:
11939
12473
  throw new UniffiInternalError.UnexpectedEnumCase();
11940
12474
  }
@@ -14918,6 +15452,19 @@ export interface BreezSdkInterface {
14918
15452
  listener: EventListener,
14919
15453
  asyncOpts_?: { signal: AbortSignal }
14920
15454
  ): Promise<string>;
15455
+ /**
15456
+ * Cancels the ongoing leaf optimization.
15457
+ *
15458
+ * This method cancels the ongoing optimization and waits for it to fully stop.
15459
+ * The current round will complete before stopping. This method blocks
15460
+ * until the optimization has fully stopped and leaves reserved for optimization
15461
+ * are available again.
15462
+ *
15463
+ * If no optimization is running, this method returns immediately.
15464
+ */
15465
+ cancelLeafOptimization(asyncOpts_?: {
15466
+ signal: AbortSignal;
15467
+ }): /*throws*/ Promise<void>;
14921
15468
  checkLightningAddressAvailable(
14922
15469
  req: CheckLightningAddressRequest,
14923
15470
  asyncOpts_?: { signal: AbortSignal }
@@ -14960,6 +15507,10 @@ export interface BreezSdkInterface {
14960
15507
  request: GetInfoRequest,
14961
15508
  asyncOpts_?: { signal: AbortSignal }
14962
15509
  ): /*throws*/ Promise<GetInfoResponse>;
15510
+ /**
15511
+ * Returns the current optimization progress snapshot.
15512
+ */
15513
+ getLeafOptimizationProgress(): OptimizationProgress;
14963
15514
  getLightningAddress(asyncOpts_?: {
14964
15515
  signal: AbortSignal;
14965
15516
  }): /*throws*/ Promise<LightningAddressInfo | undefined>;
@@ -15121,6 +15672,14 @@ export interface BreezSdkInterface {
15121
15672
  request: SignMessageRequest,
15122
15673
  asyncOpts_?: { signal: AbortSignal }
15123
15674
  ): /*throws*/ Promise<SignMessageResponse>;
15675
+ /**
15676
+ * Starts leaf optimization in the background.
15677
+ *
15678
+ * This method spawns the optimization work in a background task and returns
15679
+ * immediately. Progress is reported via events.
15680
+ * If optimization is already running, no new task will be started.
15681
+ */
15682
+ startLeafOptimization(): void;
15124
15683
  /**
15125
15684
  * Synchronizes the wallet with the Spark network
15126
15685
  */
@@ -15203,6 +15762,51 @@ export class BreezSdk
15203
15762
  }
15204
15763
  }
15205
15764
 
15765
+ /**
15766
+ * Cancels the ongoing leaf optimization.
15767
+ *
15768
+ * This method cancels the ongoing optimization and waits for it to fully stop.
15769
+ * The current round will complete before stopping. This method blocks
15770
+ * until the optimization has fully stopped and leaves reserved for optimization
15771
+ * are available again.
15772
+ *
15773
+ * If no optimization is running, this method returns immediately.
15774
+ */
15775
+ public async cancelLeafOptimization(asyncOpts_?: {
15776
+ signal: AbortSignal;
15777
+ }): Promise<void> /*throws*/ {
15778
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
15779
+ try {
15780
+ return await uniffiRustCallAsync(
15781
+ /*rustCaller:*/ uniffiCaller,
15782
+ /*rustFutureFunc:*/ () => {
15783
+ return nativeModule().ubrn_uniffi_breez_sdk_spark_fn_method_breezsdk_cancel_leaf_optimization(
15784
+ uniffiTypeBreezSdkObjectFactory.clonePointer(this)
15785
+ );
15786
+ },
15787
+ /*pollFunc:*/ nativeModule()
15788
+ .ubrn_ffi_breez_sdk_spark_rust_future_poll_void,
15789
+ /*cancelFunc:*/ nativeModule()
15790
+ .ubrn_ffi_breez_sdk_spark_rust_future_cancel_void,
15791
+ /*completeFunc:*/ nativeModule()
15792
+ .ubrn_ffi_breez_sdk_spark_rust_future_complete_void,
15793
+ /*freeFunc:*/ nativeModule()
15794
+ .ubrn_ffi_breez_sdk_spark_rust_future_free_void,
15795
+ /*liftFunc:*/ (_v) => {},
15796
+ /*liftString:*/ FfiConverterString.lift,
15797
+ /*asyncOpts:*/ asyncOpts_,
15798
+ /*errorHandler:*/ FfiConverterTypeSdkError.lift.bind(
15799
+ FfiConverterTypeSdkError
15800
+ )
15801
+ );
15802
+ } catch (__error: any) {
15803
+ if (uniffiIsDebug && __error instanceof Error) {
15804
+ __error.stack = __stack;
15805
+ }
15806
+ throw __error;
15807
+ }
15808
+ }
15809
+
15206
15810
  public async checkLightningAddressAvailable(
15207
15811
  req: CheckLightningAddressRequest,
15208
15812
  asyncOpts_?: { signal: AbortSignal }
@@ -15484,6 +16088,23 @@ export class BreezSdk
15484
16088
  }
15485
16089
  }
15486
16090
 
16091
+ /**
16092
+ * Returns the current optimization progress snapshot.
16093
+ */
16094
+ public getLeafOptimizationProgress(): OptimizationProgress {
16095
+ return FfiConverterTypeOptimizationProgress.lift(
16096
+ uniffiCaller.rustCall(
16097
+ /*caller:*/ (callStatus) => {
16098
+ return nativeModule().ubrn_uniffi_breez_sdk_spark_fn_method_breezsdk_get_leaf_optimization_progress(
16099
+ uniffiTypeBreezSdkObjectFactory.clonePointer(this),
16100
+ callStatus
16101
+ );
16102
+ },
16103
+ /*liftString:*/ FfiConverterString.lift
16104
+ )
16105
+ );
16106
+ }
16107
+
15487
16108
  public async getLightningAddress(asyncOpts_?: {
15488
16109
  signal: AbortSignal;
15489
16110
  }): Promise<LightningAddressInfo | undefined> /*throws*/ {
@@ -16348,6 +16969,25 @@ export class BreezSdk
16348
16969
  }
16349
16970
  }
16350
16971
 
16972
+ /**
16973
+ * Starts leaf optimization in the background.
16974
+ *
16975
+ * This method spawns the optimization work in a background task and returns
16976
+ * immediately. Progress is reported via events.
16977
+ * If optimization is already running, no new task will be started.
16978
+ */
16979
+ public startLeafOptimization(): void {
16980
+ uniffiCaller.rustCall(
16981
+ /*caller:*/ (callStatus) => {
16982
+ nativeModule().ubrn_uniffi_breez_sdk_spark_fn_method_breezsdk_start_leaf_optimization(
16983
+ uniffiTypeBreezSdkObjectFactory.clonePointer(this),
16984
+ callStatus
16985
+ );
16986
+ },
16987
+ /*liftString:*/ FfiConverterString.lift
16988
+ );
16989
+ }
16990
+
16351
16991
  /**
16352
16992
  * Synchronizes the wallet with the Spark network
16353
16993
  */
@@ -21483,6 +22123,14 @@ function uniffiEnsureInitialized() {
21483
22123
  'uniffi_breez_sdk_spark_checksum_method_breezsdk_add_event_listener'
21484
22124
  );
21485
22125
  }
22126
+ if (
22127
+ nativeModule().ubrn_uniffi_breez_sdk_spark_checksum_method_breezsdk_cancel_leaf_optimization() !==
22128
+ 56996
22129
+ ) {
22130
+ throw new UniffiInternalError.ApiChecksumMismatch(
22131
+ 'uniffi_breez_sdk_spark_checksum_method_breezsdk_cancel_leaf_optimization'
22132
+ );
22133
+ }
21486
22134
  if (
21487
22135
  nativeModule().ubrn_uniffi_breez_sdk_spark_checksum_method_breezsdk_check_lightning_address_available() !==
21488
22136
  31624
@@ -21539,6 +22187,14 @@ function uniffiEnsureInitialized() {
21539
22187
  'uniffi_breez_sdk_spark_checksum_method_breezsdk_get_info'
21540
22188
  );
21541
22189
  }
22190
+ if (
22191
+ nativeModule().ubrn_uniffi_breez_sdk_spark_checksum_method_breezsdk_get_leaf_optimization_progress() !==
22192
+ 38008
22193
+ ) {
22194
+ throw new UniffiInternalError.ApiChecksumMismatch(
22195
+ 'uniffi_breez_sdk_spark_checksum_method_breezsdk_get_leaf_optimization_progress'
22196
+ );
22197
+ }
21542
22198
  if (
21543
22199
  nativeModule().ubrn_uniffi_breez_sdk_spark_checksum_method_breezsdk_get_lightning_address() !==
21544
22200
  36552
@@ -21707,6 +22363,14 @@ function uniffiEnsureInitialized() {
21707
22363
  'uniffi_breez_sdk_spark_checksum_method_breezsdk_sign_message'
21708
22364
  );
21709
22365
  }
22366
+ if (
22367
+ nativeModule().ubrn_uniffi_breez_sdk_spark_checksum_method_breezsdk_start_leaf_optimization() !==
22368
+ 22827
22369
+ ) {
22370
+ throw new UniffiInternalError.ApiChecksumMismatch(
22371
+ 'uniffi_breez_sdk_spark_checksum_method_breezsdk_start_leaf_optimization'
22372
+ );
22373
+ }
21710
22374
  if (
21711
22375
  nativeModule().ubrn_uniffi_breez_sdk_spark_checksum_method_breezsdk_sync_wallet() !==
21712
22376
  30368
@@ -22207,6 +22871,9 @@ export default Object.freeze({
22207
22871
  FfiConverterTypeMintIssuerTokenRequest,
22208
22872
  FfiConverterTypeNetwork,
22209
22873
  FfiConverterTypeOnchainConfirmationSpeed,
22874
+ FfiConverterTypeOptimizationConfig,
22875
+ FfiConverterTypeOptimizationEvent,
22876
+ FfiConverterTypeOptimizationProgress,
22210
22877
  FfiConverterTypeOutgoingChange,
22211
22878
  FfiConverterTypePayment,
22212
22879
  FfiConverterTypePaymentDetails,