@breeztech/breez-sdk-spark-react-native 0.1.9-dev1 → 0.1.9-dev2

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.
@@ -508,6 +508,12 @@ export type Config = {
508
508
  * The domain used for receiving through lnurl-pay and lightning address.
509
509
  */
510
510
  lnurlDomain: string | undefined;
511
+ /**
512
+ * When this is set to `true` we will prefer to use spark payments over
513
+ * lightning when sending and receiving. This has the benefit of lower fees
514
+ * but is at the cost of privacy.
515
+ */
516
+ preferSparkOverLightning: boolean;
511
517
  };
512
518
 
513
519
  /**
@@ -548,6 +554,7 @@ const FfiConverterTypeConfig = (() => {
548
554
  syncIntervalSecs: FfiConverterUInt32.read(from),
549
555
  maxDepositClaimFee: FfiConverterOptionalTypeFee.read(from),
550
556
  lnurlDomain: FfiConverterOptionalString.read(from),
557
+ preferSparkOverLightning: FfiConverterBool.read(from),
551
558
  };
552
559
  }
553
560
  write(value: TypeName, into: RustBuffer): void {
@@ -556,6 +563,7 @@ const FfiConverterTypeConfig = (() => {
556
563
  FfiConverterUInt32.write(value.syncIntervalSecs, into);
557
564
  FfiConverterOptionalTypeFee.write(value.maxDepositClaimFee, into);
558
565
  FfiConverterOptionalString.write(value.lnurlDomain, into);
566
+ FfiConverterBool.write(value.preferSparkOverLightning, into);
559
567
  }
560
568
  allocationSize(value: TypeName): number {
561
569
  return (
@@ -563,7 +571,8 @@ const FfiConverterTypeConfig = (() => {
563
571
  FfiConverterTypeNetwork.allocationSize(value.network) +
564
572
  FfiConverterUInt32.allocationSize(value.syncIntervalSecs) +
565
573
  FfiConverterOptionalTypeFee.allocationSize(value.maxDepositClaimFee) +
566
- FfiConverterOptionalString.allocationSize(value.lnurlDomain)
574
+ FfiConverterOptionalString.allocationSize(value.lnurlDomain) +
575
+ FfiConverterBool.allocationSize(value.preferSparkOverLightning)
567
576
  );
568
577
  }
569
578
  }
@@ -3327,6 +3336,55 @@ const FfiConverterTypeFee = (() => {
3327
3336
  return new FFIConverter();
3328
3337
  })();
3329
3338
 
3339
+ export enum KeySetType {
3340
+ Default,
3341
+ Taproot,
3342
+ NativeSegwit,
3343
+ WrappedSegwit,
3344
+ Legacy,
3345
+ }
3346
+
3347
+ const FfiConverterTypeKeySetType = (() => {
3348
+ const ordinalConverter = FfiConverterInt32;
3349
+ type TypeName = KeySetType;
3350
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
3351
+ read(from: RustBuffer): TypeName {
3352
+ switch (ordinalConverter.read(from)) {
3353
+ case 1:
3354
+ return KeySetType.Default;
3355
+ case 2:
3356
+ return KeySetType.Taproot;
3357
+ case 3:
3358
+ return KeySetType.NativeSegwit;
3359
+ case 4:
3360
+ return KeySetType.WrappedSegwit;
3361
+ case 5:
3362
+ return KeySetType.Legacy;
3363
+ default:
3364
+ throw new UniffiInternalError.UnexpectedEnumCase();
3365
+ }
3366
+ }
3367
+ write(value: TypeName, into: RustBuffer): void {
3368
+ switch (value) {
3369
+ case KeySetType.Default:
3370
+ return ordinalConverter.write(1, into);
3371
+ case KeySetType.Taproot:
3372
+ return ordinalConverter.write(2, into);
3373
+ case KeySetType.NativeSegwit:
3374
+ return ordinalConverter.write(3, into);
3375
+ case KeySetType.WrappedSegwit:
3376
+ return ordinalConverter.write(4, into);
3377
+ case KeySetType.Legacy:
3378
+ return ordinalConverter.write(5, into);
3379
+ }
3380
+ }
3381
+ allocationSize(value: TypeName): number {
3382
+ return ordinalConverter.allocationSize(0);
3383
+ }
3384
+ }
3385
+ return new FFIConverter();
3386
+ })();
3387
+
3330
3388
  export enum Network {
3331
3389
  Mainnet,
3332
3390
  Regtest,
@@ -4642,6 +4700,7 @@ export enum SdkEvent_Tags {
4642
4700
  ClaimDepositsFailed = 'ClaimDepositsFailed',
4643
4701
  ClaimDepositsSucceeded = 'ClaimDepositsSucceeded',
4644
4702
  PaymentSucceeded = 'PaymentSucceeded',
4703
+ PaymentFailed = 'PaymentFailed',
4645
4704
  }
4646
4705
  /**
4647
4706
  * Events emitted by the SDK
@@ -4771,6 +4830,33 @@ export const SdkEvent = (() => {
4771
4830
  }
4772
4831
  }
4773
4832
 
4833
+ type PaymentFailed__interface = {
4834
+ tag: SdkEvent_Tags.PaymentFailed;
4835
+ inner: Readonly<{ payment: Payment }>;
4836
+ };
4837
+
4838
+ class PaymentFailed_ extends UniffiEnum implements PaymentFailed__interface {
4839
+ /**
4840
+ * @private
4841
+ * This field is private and should not be used, use `tag` instead.
4842
+ */
4843
+ readonly [uniffiTypeNameSymbol] = 'SdkEvent';
4844
+ readonly tag = SdkEvent_Tags.PaymentFailed;
4845
+ readonly inner: Readonly<{ payment: Payment }>;
4846
+ constructor(inner: { payment: Payment }) {
4847
+ super('SdkEvent', 'PaymentFailed');
4848
+ this.inner = Object.freeze(inner);
4849
+ }
4850
+
4851
+ static new(inner: { payment: Payment }): PaymentFailed_ {
4852
+ return new PaymentFailed_(inner);
4853
+ }
4854
+
4855
+ static instanceOf(obj: any): obj is PaymentFailed_ {
4856
+ return obj.tag === SdkEvent_Tags.PaymentFailed;
4857
+ }
4858
+ }
4859
+
4774
4860
  function instanceOf(obj: any): obj is SdkEvent {
4775
4861
  return obj[uniffiTypeNameSymbol] === 'SdkEvent';
4776
4862
  }
@@ -4781,6 +4867,7 @@ export const SdkEvent = (() => {
4781
4867
  ClaimDepositsFailed: ClaimDepositsFailed_,
4782
4868
  ClaimDepositsSucceeded: ClaimDepositsSucceeded_,
4783
4869
  PaymentSucceeded: PaymentSucceeded_,
4870
+ PaymentFailed: PaymentFailed_,
4784
4871
  });
4785
4872
  })();
4786
4873
 
@@ -4813,6 +4900,10 @@ const FfiConverterTypeSdkEvent = (() => {
4813
4900
  return new SdkEvent.PaymentSucceeded({
4814
4901
  payment: FfiConverterTypePayment.read(from),
4815
4902
  });
4903
+ case 5:
4904
+ return new SdkEvent.PaymentFailed({
4905
+ payment: FfiConverterTypePayment.read(from),
4906
+ });
4816
4907
  default:
4817
4908
  throw new UniffiInternalError.UnexpectedEnumCase();
4818
4909
  }
@@ -4841,6 +4932,12 @@ const FfiConverterTypeSdkEvent = (() => {
4841
4932
  FfiConverterTypePayment.write(inner.payment, into);
4842
4933
  return;
4843
4934
  }
4935
+ case SdkEvent_Tags.PaymentFailed: {
4936
+ ordinalConverter.write(5, into);
4937
+ const inner = value.inner;
4938
+ FfiConverterTypePayment.write(inner.payment, into);
4939
+ return;
4940
+ }
4844
4941
  default:
4845
4942
  // Throwing from here means that SdkEvent_Tags hasn't matched an ordinal.
4846
4943
  throw new UniffiInternalError.UnexpectedEnumCase();
@@ -4873,6 +4970,12 @@ const FfiConverterTypeSdkEvent = (() => {
4873
4970
  size += FfiConverterTypePayment.allocationSize(inner.payment);
4874
4971
  return size;
4875
4972
  }
4973
+ case SdkEvent_Tags.PaymentFailed: {
4974
+ const inner = value.inner;
4975
+ let size = ordinalConverter.allocationSize(5);
4976
+ size += FfiConverterTypePayment.allocationSize(inner.payment);
4977
+ return size;
4978
+ }
4876
4979
  default:
4877
4980
  throw new UniffiInternalError.UnexpectedEnumCase();
4878
4981
  }
@@ -6093,7 +6196,7 @@ export interface BreezSdkInterface {
6093
6196
  request: LnurlPayRequest,
6094
6197
  asyncOpts_?: { signal: AbortSignal }
6095
6198
  ) /*throws*/ : Promise<LnurlPayResponse>;
6096
- pollLightningSendPayment(paymentId: string): void;
6199
+ pollLightningSendPayment(payment: Payment, sspId: string): void;
6097
6200
  prepareLnurlPay(
6098
6201
  request: PrepareLnurlPayRequest,
6099
6202
  asyncOpts_?: { signal: AbortSignal }
@@ -6579,12 +6682,13 @@ export class BreezSdk
6579
6682
  }
6580
6683
  }
6581
6684
 
6582
- public pollLightningSendPayment(paymentId: string): void {
6685
+ public pollLightningSendPayment(payment: Payment, sspId: string): void {
6583
6686
  uniffiCaller.rustCall(
6584
6687
  /*caller:*/ (callStatus) => {
6585
6688
  nativeModule().ubrn_uniffi_breez_sdk_spark_fn_method_breezsdk_poll_lightning_send_payment(
6586
6689
  uniffiTypeBreezSdkObjectFactory.clonePointer(this),
6587
- FfiConverterString.lower(paymentId),
6690
+ FfiConverterTypePayment.lower(payment),
6691
+ FfiConverterString.lower(sspId),
6588
6692
  callStatus
6589
6693
  );
6590
6694
  },
@@ -7057,6 +7161,17 @@ export interface SdkBuilderInterface {
7057
7161
  chainService: BitcoinChainService,
7058
7162
  asyncOpts_?: { signal: AbortSignal }
7059
7163
  ): Promise<void>;
7164
+ /**
7165
+ * Sets the key set type to be used by the SDK.
7166
+ * Arguments:
7167
+ * - `key_set_type`: The key set type which determines the derivation path.
7168
+ * - `use_address_index`: Controls the structure of the BIP derivation path.
7169
+ */
7170
+ withKeySet(
7171
+ keySetType: KeySetType,
7172
+ useAddressIndex: boolean,
7173
+ asyncOpts_?: { signal: AbortSignal }
7174
+ ): Promise<void>;
7060
7175
  withLnurlClient(
7061
7176
  lnurlClient: RestClient,
7062
7177
  asyncOpts_?: { signal: AbortSignal }
@@ -7188,6 +7303,48 @@ export class SdkBuilder
7188
7303
  }
7189
7304
  }
7190
7305
 
7306
+ /**
7307
+ * Sets the key set type to be used by the SDK.
7308
+ * Arguments:
7309
+ * - `key_set_type`: The key set type which determines the derivation path.
7310
+ * - `use_address_index`: Controls the structure of the BIP derivation path.
7311
+ */
7312
+ public async withKeySet(
7313
+ keySetType: KeySetType,
7314
+ useAddressIndex: boolean,
7315
+ asyncOpts_?: { signal: AbortSignal }
7316
+ ): Promise<void> {
7317
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
7318
+ try {
7319
+ return await uniffiRustCallAsync(
7320
+ /*rustCaller:*/ uniffiCaller,
7321
+ /*rustFutureFunc:*/ () => {
7322
+ return nativeModule().ubrn_uniffi_breez_sdk_spark_fn_method_sdkbuilder_with_key_set(
7323
+ uniffiTypeSdkBuilderObjectFactory.clonePointer(this),
7324
+ FfiConverterTypeKeySetType.lower(keySetType),
7325
+ FfiConverterBool.lower(useAddressIndex)
7326
+ );
7327
+ },
7328
+ /*pollFunc:*/ nativeModule()
7329
+ .ubrn_ffi_breez_sdk_spark_rust_future_poll_void,
7330
+ /*cancelFunc:*/ nativeModule()
7331
+ .ubrn_ffi_breez_sdk_spark_rust_future_cancel_void,
7332
+ /*completeFunc:*/ nativeModule()
7333
+ .ubrn_ffi_breez_sdk_spark_rust_future_complete_void,
7334
+ /*freeFunc:*/ nativeModule()
7335
+ .ubrn_ffi_breez_sdk_spark_rust_future_free_void,
7336
+ /*liftFunc:*/ (_v) => {},
7337
+ /*liftString:*/ FfiConverterString.lift,
7338
+ /*asyncOpts:*/ asyncOpts_
7339
+ );
7340
+ } catch (__error: any) {
7341
+ if (uniffiIsDebug && __error instanceof Error) {
7342
+ __error.stack = __stack;
7343
+ }
7344
+ throw __error;
7345
+ }
7346
+ }
7347
+
7191
7348
  public async withLnurlClient(
7192
7349
  lnurlClient: RestClient,
7193
7350
  asyncOpts_?: { signal: AbortSignal }
@@ -8860,7 +9017,7 @@ function uniffiEnsureInitialized() {
8860
9017
  }
8861
9018
  if (
8862
9019
  nativeModule().ubrn_uniffi_breez_sdk_spark_checksum_method_breezsdk_poll_lightning_send_payment() !==
8863
- 5478
9020
+ 57601
8864
9021
  ) {
8865
9022
  throw new UniffiInternalError.ApiChecksumMismatch(
8866
9023
  'uniffi_breez_sdk_spark_checksum_method_breezsdk_poll_lightning_send_payment'
@@ -8962,6 +9119,14 @@ function uniffiEnsureInitialized() {
8962
9119
  'uniffi_breez_sdk_spark_checksum_method_sdkbuilder_with_chain_service'
8963
9120
  );
8964
9121
  }
9122
+ if (
9123
+ nativeModule().ubrn_uniffi_breez_sdk_spark_checksum_method_sdkbuilder_with_key_set() !==
9124
+ 55523
9125
+ ) {
9126
+ throw new UniffiInternalError.ApiChecksumMismatch(
9127
+ 'uniffi_breez_sdk_spark_checksum_method_sdkbuilder_with_key_set'
9128
+ );
9129
+ }
8965
9130
  if (
8966
9131
  nativeModule().ubrn_uniffi_breez_sdk_spark_checksum_method_sdkbuilder_with_lnurl_client() !==
8967
9132
  61720
@@ -9115,6 +9280,7 @@ export default Object.freeze({
9115
9280
  FfiConverterTypeGetInfoResponse,
9116
9281
  FfiConverterTypeGetPaymentRequest,
9117
9282
  FfiConverterTypeGetPaymentResponse,
9283
+ FfiConverterTypeKeySetType,
9118
9284
  FfiConverterTypeLightningAddressInfo,
9119
9285
  FfiConverterTypeListPaymentsRequest,
9120
9286
  FfiConverterTypeListPaymentsResponse,