@buildonspark/spark-sdk 0.4.1 → 0.4.2

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/bare/index.cjs +1038 -236
  3. package/dist/bare/index.d.cts +143 -14
  4. package/dist/bare/index.d.ts +143 -14
  5. package/dist/bare/index.js +1043 -240
  6. package/dist/{chunk-4E23VB7E.js → chunk-6UVL674M.js} +2 -2
  7. package/dist/{chunk-YEBEN7XD.js → chunk-BHFVMNXO.js} +623 -16
  8. package/dist/{chunk-EV2PTGGR.js → chunk-JZODGME5.js} +1 -1
  9. package/dist/{chunk-JLF6WJ7K.js → chunk-LUOP2ATD.js} +1 -1
  10. package/dist/{chunk-4YFT7DAE.js → chunk-Q537QTDY.js} +1 -1
  11. package/dist/{chunk-W2S4FPZ4.js → chunk-SUGTL4PD.js} +250 -27
  12. package/dist/{chunk-JR7ZU6LX.js → chunk-U7EELMDO.js} +1 -1
  13. package/dist/{client-BaQf-5gD.d.ts → client-3MdPdtnA.d.ts} +1 -1
  14. package/dist/{client-BIqiUNy4.d.cts → client-BZFWaZ1l.d.cts} +1 -1
  15. package/dist/debug.cjs +1038 -241
  16. package/dist/debug.d.cts +5 -5
  17. package/dist/debug.d.ts +5 -5
  18. package/dist/debug.js +5 -5
  19. package/dist/graphql/objects/index.d.cts +3 -3
  20. package/dist/graphql/objects/index.d.ts +3 -3
  21. package/dist/index.cjs +923 -119
  22. package/dist/index.d.cts +6 -6
  23. package/dist/index.d.ts +6 -6
  24. package/dist/index.js +6 -6
  25. package/dist/index.node.cjs +923 -119
  26. package/dist/index.node.d.cts +6 -6
  27. package/dist/index.node.d.ts +6 -6
  28. package/dist/index.node.js +5 -5
  29. package/dist/{logging-BLzoEEoP.d.ts → logging-g6Oib3Ua.d.ts} +3 -3
  30. package/dist/{logging-Cl-gGtZz.d.cts → logging-miPhbIyT.d.cts} +3 -3
  31. package/dist/native/index.react-native.cjs +923 -119
  32. package/dist/native/index.react-native.d.cts +141 -16
  33. package/dist/native/index.react-native.d.ts +141 -16
  34. package/dist/native/index.react-native.js +926 -121
  35. package/dist/proto/spark.cjs +623 -16
  36. package/dist/proto/spark.d.cts +1 -1
  37. package/dist/proto/spark.d.ts +1 -1
  38. package/dist/proto/spark.js +19 -1
  39. package/dist/proto/spark_token.d.cts +1 -1
  40. package/dist/proto/spark_token.d.ts +1 -1
  41. package/dist/proto/spark_token.js +2 -2
  42. package/dist/{spark-DOpheE8_.d.cts → spark-BWkABx3N.d.cts} +124 -3
  43. package/dist/{spark-DOpheE8_.d.ts → spark-BWkABx3N.d.ts} +124 -3
  44. package/dist/{spark-wallet.browser-XT25hMYM.d.ts → spark-wallet.browser-Cm-JMRQB.d.ts} +2 -2
  45. package/dist/{spark-wallet.browser-BGMpYML0.d.cts → spark-wallet.browser-M7zcmZYm.d.cts} +2 -2
  46. package/dist/{spark-wallet.node-CAfuCfrU.d.ts → spark-wallet.node-B4y08Ri5.d.ts} +2 -2
  47. package/dist/{spark-wallet.node-C8dbiFsD.d.cts → spark-wallet.node-BotQbNoI.d.cts} +2 -2
  48. package/dist/tests/test-utils.cjs +1030 -60
  49. package/dist/tests/test-utils.d.cts +4 -4
  50. package/dist/tests/test-utils.d.ts +4 -4
  51. package/dist/tests/test-utils.js +7 -7
  52. package/dist/{token-transactions-DhVLTxEY.d.cts → token-transactions-C95IPSyM.d.cts} +2 -2
  53. package/dist/{token-transactions-vcOZg63D.d.ts → token-transactions-SPf4ygYc.d.ts} +2 -2
  54. package/dist/types/index.cjs +614 -16
  55. package/dist/types/index.d.cts +2 -2
  56. package/dist/types/index.d.ts +2 -2
  57. package/dist/types/index.js +5 -5
  58. package/dist/{wallet-config-w9e62Plc.d.ts → wallet-config-CQW-mDqN.d.ts} +41 -17
  59. package/dist/{wallet-config-DVEoQg3w.d.cts → wallet-config-JYsN3izc.d.cts} +41 -17
  60. package/package.json +1 -1
  61. package/src/proto/spark.ts +842 -80
  62. package/src/services/lightning.ts +1 -1
  63. package/src/services/transfer.ts +0 -1
  64. package/src/spark-wallet/proto-descriptors.ts +1 -1
  65. package/src/spark-wallet/spark-wallet.ts +279 -16
  66. package/src/spark-wallet/types.ts +6 -7
  67. package/src/spark_descriptors.pb +0 -0
  68. package/src/tests/address.test.ts +10 -103
  69. package/src/tests/integration/address.test.ts +7 -17
  70. package/src/tests/integration/ssp/coop-exit.test.ts +0 -1
  71. package/src/tests/integration/ssp/lightning.test.ts +67 -2
  72. package/src/tests/integration/ssp/swap.test.ts +0 -1
  73. package/src/tests/integration/static_deposit.test.ts +2 -1
  74. package/src/tests/integration/transfer.test.ts +8 -28
  75. package/src/tests/token-hashing.test.ts +4 -4
  76. package/src/tests/xchain-address.test.ts +3 -3
  77. package/src/utils/address.ts +6 -4
@@ -862,6 +862,12 @@ declare enum Order {
862
862
  ASCENDING = 1,
863
863
  UNRECOGNIZED = -1
864
864
  }
865
+ declare enum PreimageRequestStatus {
866
+ PREIMAGE_REQUEST_STATUS_WAITING_FOR_PREIMAGE = 0,
867
+ PREIMAGE_REQUEST_STATUS_PREIMAGE_SHARED = 1,
868
+ PREIMAGE_REQUEST_STATUS_RETURNED = 2,
869
+ UNRECOGNIZED = -1
870
+ }
865
871
  /** Static deposit address flow messages */
866
872
  declare enum UtxoSwapRequestType {
867
873
  Fixed = 0,
@@ -1149,7 +1155,6 @@ interface RenewNodeZeroTimelockSigningJob {
1149
1155
  */
1150
1156
  refundTxSigningJob: UserSignedTxSigningJob | undefined;
1151
1157
  directNodeTxSigningJob: UserSignedTxSigningJob | undefined;
1152
- directRefundTxSigningJob: UserSignedTxSigningJob | undefined;
1153
1158
  directFromCpfpRefundTxSigningJob: UserSignedTxSigningJob | undefined;
1154
1159
  }
1155
1160
  declare const RenewNodeZeroTimelockSigningJob: MessageFns$2<RenewNodeZeroTimelockSigningJob>;
@@ -1592,6 +1597,10 @@ declare const LeafRefundTxSigningJob: MessageFns$2<LeafRefundTxSigningJob>;
1592
1597
  interface UserSignedTxSigningJob {
1593
1598
  leafId: string;
1594
1599
  signingPublicKey: Uint8Array;
1600
+ /**
1601
+ * CPFP Refund Tx that is created when the User signs refunds. It spends the
1602
+ * node transaction to the receiver.
1603
+ */
1595
1604
  rawTx: Uint8Array;
1596
1605
  signingNonceCommitment: SigningCommitment | undefined;
1597
1606
  userSignature: Uint8Array;
@@ -1929,6 +1938,34 @@ interface QueryUserSignedRefundsResponse {
1929
1938
  transfer: Transfer | undefined;
1930
1939
  }
1931
1940
  declare const QueryUserSignedRefundsResponse: MessageFns$2<QueryUserSignedRefundsResponse>;
1941
+ interface PreimageRequestWithTransfer {
1942
+ /** Preimage request data */
1943
+ paymentHash: Uint8Array;
1944
+ receiverIdentityPubkey: Uint8Array;
1945
+ status: PreimageRequestStatus;
1946
+ createdTime: Date | undefined;
1947
+ /** Associated transfer (if exists) */
1948
+ transfer?: Transfer | undefined;
1949
+ /** Preimage data (if available) */
1950
+ preimage?: Uint8Array | undefined;
1951
+ }
1952
+ declare const PreimageRequestWithTransfer: MessageFns$2<PreimageRequestWithTransfer>;
1953
+ interface QueryHtlcRequest {
1954
+ paymentHashes: Uint8Array[];
1955
+ identityPublicKey: Uint8Array;
1956
+ status?: PreimageRequestStatus | undefined;
1957
+ /** defaults to 100 if not set. */
1958
+ limit: number;
1959
+ /** defaults to 0 if not set. */
1960
+ offset: number;
1961
+ }
1962
+ declare const QueryHtlcRequest: MessageFns$2<QueryHtlcRequest>;
1963
+ interface QueryHtlcResponse {
1964
+ preimageRequests: PreimageRequestWithTransfer[];
1965
+ /** defaults to -1 if there are no more results */
1966
+ offset: number;
1967
+ }
1968
+ declare const QueryHtlcResponse: MessageFns$2<QueryHtlcResponse>;
1932
1969
  interface ProvidePreimageRequest {
1933
1970
  paymentHash: Uint8Array;
1934
1971
  preimage: Uint8Array;
@@ -2211,6 +2248,33 @@ interface TokenTransfer {
2211
2248
  finalTokenTransactionHash: Uint8Array;
2212
2249
  }
2213
2250
  declare const TokenTransfer: MessageFns$2<TokenTransfer>;
2251
+ interface InitiateSwapPrimaryTransferRequest {
2252
+ /** Transfer with refunds and key tweaks signed */
2253
+ transfer: StartTransferRequest | undefined;
2254
+ /**
2255
+ * Adaptor public keys to verify the signatures of refunds for the primary
2256
+ * transfer in the swap
2257
+ */
2258
+ adaptorPublicKeys: AdaptorPublicKeyPackage | undefined;
2259
+ }
2260
+ declare const InitiateSwapPrimaryTransferRequest: MessageFns$2<InitiateSwapPrimaryTransferRequest>;
2261
+ interface InitiateSwapPrimaryTransferResponse {
2262
+ transfer: Transfer | undefined;
2263
+ signingResults: LeafRefundTxSigningResult[];
2264
+ }
2265
+ declare const InitiateSwapPrimaryTransferResponse: MessageFns$2<InitiateSwapPrimaryTransferResponse>;
2266
+ /**
2267
+ * Adaptor public key is derived from the secret `t` using formula:
2268
+ * ```
2269
+ * T = t * G
2270
+ * ```
2271
+ */
2272
+ interface AdaptorPublicKeyPackage {
2273
+ adaptorPublicKey: Uint8Array;
2274
+ directAdaptorPublicKey: Uint8Array;
2275
+ directFromCpfpAdaptorPublicKey: Uint8Array;
2276
+ }
2277
+ declare const AdaptorPublicKeyPackage: MessageFns$2<AdaptorPublicKeyPackage>;
2214
2278
  type SparkServiceDefinition = typeof SparkServiceDefinition;
2215
2279
  declare const SparkServiceDefinition: {
2216
2280
  readonly name: "SparkService";
@@ -2375,6 +2439,14 @@ declare const SparkServiceDefinition: {
2375
2439
  readonly responseStream: false;
2376
2440
  readonly options: {};
2377
2441
  };
2442
+ readonly query_htlc: {
2443
+ readonly name: "query_htlc";
2444
+ readonly requestType: MessageFns$2<QueryHtlcRequest>;
2445
+ readonly requestStream: false;
2446
+ readonly responseType: MessageFns$2<QueryHtlcResponse>;
2447
+ readonly responseStream: false;
2448
+ readonly options: {};
2449
+ };
2378
2450
  /**
2379
2451
  * This is the exact same as start_transfer, but expresses to the SO
2380
2452
  * this transfer is specifically for a leaf swap.
@@ -2654,6 +2726,14 @@ declare const SparkServiceDefinition: {
2654
2726
  readonly responseStream: false;
2655
2727
  readonly options: {};
2656
2728
  };
2729
+ readonly initiate_preimage_swap_v3: {
2730
+ readonly name: "initiate_preimage_swap_v3";
2731
+ readonly requestType: MessageFns$2<InitiatePreimageSwapRequest>;
2732
+ readonly requestStream: false;
2733
+ readonly responseType: MessageFns$2<InitiatePreimageSwapResponse>;
2734
+ readonly responseStream: false;
2735
+ readonly options: {};
2736
+ };
2657
2737
  readonly start_leaf_swap_v2: {
2658
2738
  readonly name: "start_leaf_swap_v2";
2659
2739
  readonly requestType: MessageFns$2<StartTransferRequest>;
@@ -2702,6 +2782,19 @@ declare const SparkServiceDefinition: {
2702
2782
  readonly responseStream: false;
2703
2783
  readonly options: {};
2704
2784
  };
2785
+ /**
2786
+ * Inititiates a primary transfer in a Swap V3 protocol. The sender submits the
2787
+ * transfer package, but the SOs will not tweak the keys at this stage of the flow.
2788
+ * It will be done later, when the SSP initiates a counter swap.
2789
+ */
2790
+ readonly initiate_swap_primary_transfer: {
2791
+ readonly name: "initiate_swap_primary_transfer";
2792
+ readonly requestType: MessageFns$2<InitiateSwapPrimaryTransferRequest>;
2793
+ readonly requestStream: false;
2794
+ readonly responseType: MessageFns$2<InitiateSwapPrimaryTransferResponse>;
2795
+ readonly responseStream: false;
2796
+ readonly options: {};
2797
+ };
2705
2798
  };
2706
2799
  };
2707
2800
  interface SparkServiceClient<CallOptionsExt = {}> {
@@ -2738,6 +2831,7 @@ interface SparkServiceClient<CallOptionsExt = {}> {
2738
2831
  cooperative_exit(request: DeepPartial$2<CooperativeExitRequest>, options?: CallOptions & CallOptionsExt): Promise<CooperativeExitResponse>;
2739
2832
  initiate_preimage_swap(request: DeepPartial$2<InitiatePreimageSwapRequest>, options?: CallOptions & CallOptionsExt): Promise<InitiatePreimageSwapResponse>;
2740
2833
  provide_preimage(request: DeepPartial$2<ProvidePreimageRequest>, options?: CallOptions & CallOptionsExt): Promise<ProvidePreimageResponse>;
2834
+ query_htlc(request: DeepPartial$2<QueryHtlcRequest>, options?: CallOptions & CallOptionsExt): Promise<QueryHtlcResponse>;
2741
2835
  /**
2742
2836
  * This is the exact same as start_transfer, but expresses to the SO
2743
2837
  * this transfer is specifically for a leaf swap.
@@ -2807,12 +2901,19 @@ interface SparkServiceClient<CallOptionsExt = {}> {
2807
2901
  claim_transfer_sign_refunds_v2(request: DeepPartial$2<ClaimTransferSignRefundsRequest>, options?: CallOptions & CallOptionsExt): Promise<ClaimTransferSignRefundsResponse>;
2808
2902
  finalize_node_signatures_v2(request: DeepPartial$2<FinalizeNodeSignaturesRequest>, options?: CallOptions & CallOptionsExt): Promise<FinalizeNodeSignaturesResponse>;
2809
2903
  initiate_preimage_swap_v2(request: DeepPartial$2<InitiatePreimageSwapRequest>, options?: CallOptions & CallOptionsExt): Promise<InitiatePreimageSwapResponse>;
2904
+ initiate_preimage_swap_v3(request: DeepPartial$2<InitiatePreimageSwapRequest>, options?: CallOptions & CallOptionsExt): Promise<InitiatePreimageSwapResponse>;
2810
2905
  start_leaf_swap_v2(request: DeepPartial$2<StartTransferRequest>, options?: CallOptions & CallOptionsExt): Promise<StartTransferResponse>;
2811
2906
  counter_leaf_swap_v2(request: DeepPartial$2<CounterLeafSwapRequest>, options?: CallOptions & CallOptionsExt): Promise<CounterLeafSwapResponse>;
2812
2907
  start_transfer_v2(request: DeepPartial$2<StartTransferRequest>, options?: CallOptions & CallOptionsExt): Promise<StartTransferResponse>;
2813
2908
  refresh_timelock_v2(request: DeepPartial$2<RefreshTimelockRequest>, options?: CallOptions & CallOptionsExt): Promise<RefreshTimelockResponse>;
2814
2909
  get_utxos_for_address(request: DeepPartial$2<GetUtxosForAddressRequest>, options?: CallOptions & CallOptionsExt): Promise<GetUtxosForAddressResponse>;
2815
2910
  query_spark_invoices(request: DeepPartial$2<QuerySparkInvoicesRequest>, options?: CallOptions & CallOptionsExt): Promise<QuerySparkInvoicesResponse>;
2911
+ /**
2912
+ * Inititiates a primary transfer in a Swap V3 protocol. The sender submits the
2913
+ * transfer package, but the SOs will not tweak the keys at this stage of the flow.
2914
+ * It will be done later, when the SSP initiates a counter swap.
2915
+ */
2916
+ initiate_swap_primary_transfer(request: DeepPartial$2<InitiateSwapPrimaryTransferRequest>, options?: CallOptions & CallOptionsExt): Promise<InitiateSwapPrimaryTransferResponse>;
2816
2917
  }
2817
2918
  type Builtin$2 = Date | Function | Uint8Array | string | number | boolean | undefined;
2818
2919
  type DeepPartial$2<T> = T extends Builtin$2 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$2<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$2<U>> : T extends {
@@ -3556,8 +3657,8 @@ interface DecodedSparkAddressData {
3556
3657
  };
3557
3658
  signature?: string;
3558
3659
  }
3559
- declare function encodeSparkAddress(payload: SparkAddressData): LegacySparkAddressFormat;
3560
- declare function encodeSparkAddressWithSignature(payload: SparkAddressData, signature?: Uint8Array): LegacySparkAddressFormat;
3660
+ declare function encodeSparkAddress(payload: SparkAddressData): SparkAddressFormat;
3661
+ declare function encodeSparkAddressWithSignature(payload: SparkAddressData, signature?: Uint8Array): SparkAddressFormat;
3561
3662
  declare function decodeSparkAddress(address: string, network: NetworkType): DecodedSparkAddressData;
3562
3663
  declare function getNetworkFromSparkAddress(address: string): NetworkType;
3563
3664
  declare function isLegacySparkAddress(address: string): address is LegacySparkAddressFormat;
@@ -3607,20 +3708,23 @@ type FulfillSparkInvoiceResponse = {
3607
3708
  }[];
3608
3709
  tokenTransactionSuccess: {
3609
3710
  tokenIdentifier: Bech32mTokenIdentifier;
3711
+ invoices: SparkAddressFormat[];
3610
3712
  txid: string;
3611
3713
  }[];
3612
3714
  satsTransactionErrors: {
3613
- invoice: string;
3715
+ invoice: SparkAddressFormat;
3614
3716
  error: Error;
3615
3717
  }[];
3616
3718
  tokenTransactionErrors: {
3617
3719
  tokenIdentifier: Bech32mTokenIdentifier;
3720
+ invoices: SparkAddressFormat[];
3618
3721
  error: Error;
3619
3722
  }[];
3620
- invalidInvoices: {
3621
- invoice: string;
3622
- error: Error;
3623
- }[];
3723
+ invalidInvoices: InvalidInvoice[];
3724
+ };
3725
+ type InvalidInvoice = {
3726
+ invoice: SparkAddressFormat;
3727
+ error: Error;
3624
3728
  };
3625
3729
  /**
3626
3730
  * Token metadata containing essential information about a token.
@@ -4098,14 +4202,14 @@ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
4098
4202
  * @param {Object} params - Parameters for the sats payment
4099
4203
  * @param {number} params.amount - The amount of sats to receive
4100
4204
  * @param {string} [params.memo] - The memo for the payment
4101
- * @param {string} [params.senderPublicKey] - The public key of the expected sender
4205
+ * @param {string} [params.senderSparkAddress] - The spark address of the expected sender
4102
4206
  * @param {Date} [params.expiryTime] - The expiry time of the payment
4103
4207
  * @returns {Promise<SparkAddressFormat>} The Spark address for the sats payment
4104
4208
  */
4105
- createSatsInvoice({ amount, memo, senderPublicKey, expiryTime, }: {
4209
+ createSatsInvoice({ amount, memo, senderSparkAddress, expiryTime, }: {
4106
4210
  amount?: number;
4107
4211
  memo?: string;
4108
- senderPublicKey?: string;
4212
+ senderSparkAddress?: SparkAddressFormat;
4109
4213
  expiryTime?: Date;
4110
4214
  }): Promise<SparkAddressFormat>;
4111
4215
  /**
@@ -4115,15 +4219,15 @@ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
4115
4219
  * @param {bigint} [params.amount] - The amount of tokens to receive
4116
4220
  * @param {Bech32mTokenIdentifier} [params.tokenIdentifier] - The token identifier
4117
4221
  * @param {string} [params.memo] - The memo for the payment
4118
- * @param {string} [params.senderPublicKey] - The public key of the expected sender
4222
+ * @param {string} [params.senderSparkAddress] - The spark address of the expected sender
4119
4223
  * @param {Date} [params.expiryTime] - The expiry time of the payment
4120
4224
  * @returns {Promise<SparkAddressFormat>} The Spark address for the tokens payment
4121
4225
  */
4122
- createTokensInvoice({ amount, tokenIdentifier, memo, senderPublicKey, expiryTime, }: {
4226
+ createTokensInvoice({ amount, tokenIdentifier, memo, senderSparkAddress, expiryTime, }: {
4123
4227
  tokenIdentifier?: Bech32mTokenIdentifier;
4124
4228
  amount?: bigint;
4125
4229
  memo?: string;
4126
- senderPublicKey?: string;
4230
+ senderSparkAddress?: SparkAddressFormat;
4127
4231
  expiryTime?: Date;
4128
4232
  }): Promise<SparkAddressFormat>;
4129
4233
  /**
@@ -4422,6 +4526,31 @@ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
4422
4526
  * @returns {Promise<LightningSendRequest>} The Lightning payment request details
4423
4527
  */
4424
4528
  payLightningInvoice({ invoice, maxFeeSats, preferSpark, amountSatsToSend, }: PayLightningInvoiceParams): Promise<LightningSendRequest | WalletTransfer>;
4529
+ /**
4530
+ * Fulfills one or more Spark invoices.
4531
+ *
4532
+ * Processes each provided invoice and attempts to pay it according to the wallet’s
4533
+ * funding/selection strategy.
4534
+ *
4535
+ * @param sparkInvoices - Invoices to fulfill.
4536
+ * @param sparkInvoices[].invoice - The parsed Spark address/invoice to pay.
4537
+ * Must be a valid Spark address or invoice.
4538
+ * Must use spark1... prefixed invoices.
4539
+ * Deprecated sp1... prefixed invoices are not supported.
4540
+ * @param sparkInvoices[].amount - Used to define an amount for invoices without an amount encoded.
4541
+ * For sats invoices, this is the amount in sats. For token invoices, this is the amount in tokens.
4542
+ * Amount encoded in the invoice takes precedence if both are provided.
4543
+ *
4544
+ * @returns Promise<string> A payment or transaction identifier (implementation‑specific).
4545
+ *
4546
+ * @throws {ValidationError} If validation fails (malformed invoice, zero/negative amount, unsupported network),
4547
+ *
4548
+ * @example
4549
+ * await wallet.fulfillSparkInvoice([
4550
+ * { invoice: invoiceWithNilAmount, amount: 1000n },
4551
+ * { invoice: invoiceWithEncodedAmount }, // uses amount encoded in the invoice
4552
+ * ]);
4553
+ */
4425
4554
  fulfillSparkInvoice(sparkInvoices: {
4426
4555
  invoice: SparkAddressFormat;
4427
4556
  amount?: bigint;
@@ -862,6 +862,12 @@ declare enum Order {
862
862
  ASCENDING = 1,
863
863
  UNRECOGNIZED = -1
864
864
  }
865
+ declare enum PreimageRequestStatus {
866
+ PREIMAGE_REQUEST_STATUS_WAITING_FOR_PREIMAGE = 0,
867
+ PREIMAGE_REQUEST_STATUS_PREIMAGE_SHARED = 1,
868
+ PREIMAGE_REQUEST_STATUS_RETURNED = 2,
869
+ UNRECOGNIZED = -1
870
+ }
865
871
  /** Static deposit address flow messages */
866
872
  declare enum UtxoSwapRequestType {
867
873
  Fixed = 0,
@@ -1149,7 +1155,6 @@ interface RenewNodeZeroTimelockSigningJob {
1149
1155
  */
1150
1156
  refundTxSigningJob: UserSignedTxSigningJob | undefined;
1151
1157
  directNodeTxSigningJob: UserSignedTxSigningJob | undefined;
1152
- directRefundTxSigningJob: UserSignedTxSigningJob | undefined;
1153
1158
  directFromCpfpRefundTxSigningJob: UserSignedTxSigningJob | undefined;
1154
1159
  }
1155
1160
  declare const RenewNodeZeroTimelockSigningJob: MessageFns$2<RenewNodeZeroTimelockSigningJob>;
@@ -1592,6 +1597,10 @@ declare const LeafRefundTxSigningJob: MessageFns$2<LeafRefundTxSigningJob>;
1592
1597
  interface UserSignedTxSigningJob {
1593
1598
  leafId: string;
1594
1599
  signingPublicKey: Uint8Array;
1600
+ /**
1601
+ * CPFP Refund Tx that is created when the User signs refunds. It spends the
1602
+ * node transaction to the receiver.
1603
+ */
1595
1604
  rawTx: Uint8Array;
1596
1605
  signingNonceCommitment: SigningCommitment | undefined;
1597
1606
  userSignature: Uint8Array;
@@ -1929,6 +1938,34 @@ interface QueryUserSignedRefundsResponse {
1929
1938
  transfer: Transfer | undefined;
1930
1939
  }
1931
1940
  declare const QueryUserSignedRefundsResponse: MessageFns$2<QueryUserSignedRefundsResponse>;
1941
+ interface PreimageRequestWithTransfer {
1942
+ /** Preimage request data */
1943
+ paymentHash: Uint8Array;
1944
+ receiverIdentityPubkey: Uint8Array;
1945
+ status: PreimageRequestStatus;
1946
+ createdTime: Date | undefined;
1947
+ /** Associated transfer (if exists) */
1948
+ transfer?: Transfer | undefined;
1949
+ /** Preimage data (if available) */
1950
+ preimage?: Uint8Array | undefined;
1951
+ }
1952
+ declare const PreimageRequestWithTransfer: MessageFns$2<PreimageRequestWithTransfer>;
1953
+ interface QueryHtlcRequest {
1954
+ paymentHashes: Uint8Array[];
1955
+ identityPublicKey: Uint8Array;
1956
+ status?: PreimageRequestStatus | undefined;
1957
+ /** defaults to 100 if not set. */
1958
+ limit: number;
1959
+ /** defaults to 0 if not set. */
1960
+ offset: number;
1961
+ }
1962
+ declare const QueryHtlcRequest: MessageFns$2<QueryHtlcRequest>;
1963
+ interface QueryHtlcResponse {
1964
+ preimageRequests: PreimageRequestWithTransfer[];
1965
+ /** defaults to -1 if there are no more results */
1966
+ offset: number;
1967
+ }
1968
+ declare const QueryHtlcResponse: MessageFns$2<QueryHtlcResponse>;
1932
1969
  interface ProvidePreimageRequest {
1933
1970
  paymentHash: Uint8Array;
1934
1971
  preimage: Uint8Array;
@@ -2211,6 +2248,33 @@ interface TokenTransfer {
2211
2248
  finalTokenTransactionHash: Uint8Array;
2212
2249
  }
2213
2250
  declare const TokenTransfer: MessageFns$2<TokenTransfer>;
2251
+ interface InitiateSwapPrimaryTransferRequest {
2252
+ /** Transfer with refunds and key tweaks signed */
2253
+ transfer: StartTransferRequest | undefined;
2254
+ /**
2255
+ * Adaptor public keys to verify the signatures of refunds for the primary
2256
+ * transfer in the swap
2257
+ */
2258
+ adaptorPublicKeys: AdaptorPublicKeyPackage | undefined;
2259
+ }
2260
+ declare const InitiateSwapPrimaryTransferRequest: MessageFns$2<InitiateSwapPrimaryTransferRequest>;
2261
+ interface InitiateSwapPrimaryTransferResponse {
2262
+ transfer: Transfer | undefined;
2263
+ signingResults: LeafRefundTxSigningResult[];
2264
+ }
2265
+ declare const InitiateSwapPrimaryTransferResponse: MessageFns$2<InitiateSwapPrimaryTransferResponse>;
2266
+ /**
2267
+ * Adaptor public key is derived from the secret `t` using formula:
2268
+ * ```
2269
+ * T = t * G
2270
+ * ```
2271
+ */
2272
+ interface AdaptorPublicKeyPackage {
2273
+ adaptorPublicKey: Uint8Array;
2274
+ directAdaptorPublicKey: Uint8Array;
2275
+ directFromCpfpAdaptorPublicKey: Uint8Array;
2276
+ }
2277
+ declare const AdaptorPublicKeyPackage: MessageFns$2<AdaptorPublicKeyPackage>;
2214
2278
  type SparkServiceDefinition = typeof SparkServiceDefinition;
2215
2279
  declare const SparkServiceDefinition: {
2216
2280
  readonly name: "SparkService";
@@ -2375,6 +2439,14 @@ declare const SparkServiceDefinition: {
2375
2439
  readonly responseStream: false;
2376
2440
  readonly options: {};
2377
2441
  };
2442
+ readonly query_htlc: {
2443
+ readonly name: "query_htlc";
2444
+ readonly requestType: MessageFns$2<QueryHtlcRequest>;
2445
+ readonly requestStream: false;
2446
+ readonly responseType: MessageFns$2<QueryHtlcResponse>;
2447
+ readonly responseStream: false;
2448
+ readonly options: {};
2449
+ };
2378
2450
  /**
2379
2451
  * This is the exact same as start_transfer, but expresses to the SO
2380
2452
  * this transfer is specifically for a leaf swap.
@@ -2654,6 +2726,14 @@ declare const SparkServiceDefinition: {
2654
2726
  readonly responseStream: false;
2655
2727
  readonly options: {};
2656
2728
  };
2729
+ readonly initiate_preimage_swap_v3: {
2730
+ readonly name: "initiate_preimage_swap_v3";
2731
+ readonly requestType: MessageFns$2<InitiatePreimageSwapRequest>;
2732
+ readonly requestStream: false;
2733
+ readonly responseType: MessageFns$2<InitiatePreimageSwapResponse>;
2734
+ readonly responseStream: false;
2735
+ readonly options: {};
2736
+ };
2657
2737
  readonly start_leaf_swap_v2: {
2658
2738
  readonly name: "start_leaf_swap_v2";
2659
2739
  readonly requestType: MessageFns$2<StartTransferRequest>;
@@ -2702,6 +2782,19 @@ declare const SparkServiceDefinition: {
2702
2782
  readonly responseStream: false;
2703
2783
  readonly options: {};
2704
2784
  };
2785
+ /**
2786
+ * Inititiates a primary transfer in a Swap V3 protocol. The sender submits the
2787
+ * transfer package, but the SOs will not tweak the keys at this stage of the flow.
2788
+ * It will be done later, when the SSP initiates a counter swap.
2789
+ */
2790
+ readonly initiate_swap_primary_transfer: {
2791
+ readonly name: "initiate_swap_primary_transfer";
2792
+ readonly requestType: MessageFns$2<InitiateSwapPrimaryTransferRequest>;
2793
+ readonly requestStream: false;
2794
+ readonly responseType: MessageFns$2<InitiateSwapPrimaryTransferResponse>;
2795
+ readonly responseStream: false;
2796
+ readonly options: {};
2797
+ };
2705
2798
  };
2706
2799
  };
2707
2800
  interface SparkServiceClient<CallOptionsExt = {}> {
@@ -2738,6 +2831,7 @@ interface SparkServiceClient<CallOptionsExt = {}> {
2738
2831
  cooperative_exit(request: DeepPartial$2<CooperativeExitRequest>, options?: CallOptions & CallOptionsExt): Promise<CooperativeExitResponse>;
2739
2832
  initiate_preimage_swap(request: DeepPartial$2<InitiatePreimageSwapRequest>, options?: CallOptions & CallOptionsExt): Promise<InitiatePreimageSwapResponse>;
2740
2833
  provide_preimage(request: DeepPartial$2<ProvidePreimageRequest>, options?: CallOptions & CallOptionsExt): Promise<ProvidePreimageResponse>;
2834
+ query_htlc(request: DeepPartial$2<QueryHtlcRequest>, options?: CallOptions & CallOptionsExt): Promise<QueryHtlcResponse>;
2741
2835
  /**
2742
2836
  * This is the exact same as start_transfer, but expresses to the SO
2743
2837
  * this transfer is specifically for a leaf swap.
@@ -2807,12 +2901,19 @@ interface SparkServiceClient<CallOptionsExt = {}> {
2807
2901
  claim_transfer_sign_refunds_v2(request: DeepPartial$2<ClaimTransferSignRefundsRequest>, options?: CallOptions & CallOptionsExt): Promise<ClaimTransferSignRefundsResponse>;
2808
2902
  finalize_node_signatures_v2(request: DeepPartial$2<FinalizeNodeSignaturesRequest>, options?: CallOptions & CallOptionsExt): Promise<FinalizeNodeSignaturesResponse>;
2809
2903
  initiate_preimage_swap_v2(request: DeepPartial$2<InitiatePreimageSwapRequest>, options?: CallOptions & CallOptionsExt): Promise<InitiatePreimageSwapResponse>;
2904
+ initiate_preimage_swap_v3(request: DeepPartial$2<InitiatePreimageSwapRequest>, options?: CallOptions & CallOptionsExt): Promise<InitiatePreimageSwapResponse>;
2810
2905
  start_leaf_swap_v2(request: DeepPartial$2<StartTransferRequest>, options?: CallOptions & CallOptionsExt): Promise<StartTransferResponse>;
2811
2906
  counter_leaf_swap_v2(request: DeepPartial$2<CounterLeafSwapRequest>, options?: CallOptions & CallOptionsExt): Promise<CounterLeafSwapResponse>;
2812
2907
  start_transfer_v2(request: DeepPartial$2<StartTransferRequest>, options?: CallOptions & CallOptionsExt): Promise<StartTransferResponse>;
2813
2908
  refresh_timelock_v2(request: DeepPartial$2<RefreshTimelockRequest>, options?: CallOptions & CallOptionsExt): Promise<RefreshTimelockResponse>;
2814
2909
  get_utxos_for_address(request: DeepPartial$2<GetUtxosForAddressRequest>, options?: CallOptions & CallOptionsExt): Promise<GetUtxosForAddressResponse>;
2815
2910
  query_spark_invoices(request: DeepPartial$2<QuerySparkInvoicesRequest>, options?: CallOptions & CallOptionsExt): Promise<QuerySparkInvoicesResponse>;
2911
+ /**
2912
+ * Inititiates a primary transfer in a Swap V3 protocol. The sender submits the
2913
+ * transfer package, but the SOs will not tweak the keys at this stage of the flow.
2914
+ * It will be done later, when the SSP initiates a counter swap.
2915
+ */
2916
+ initiate_swap_primary_transfer(request: DeepPartial$2<InitiateSwapPrimaryTransferRequest>, options?: CallOptions & CallOptionsExt): Promise<InitiateSwapPrimaryTransferResponse>;
2816
2917
  }
2817
2918
  type Builtin$2 = Date | Function | Uint8Array | string | number | boolean | undefined;
2818
2919
  type DeepPartial$2<T> = T extends Builtin$2 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$2<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$2<U>> : T extends {
@@ -3556,8 +3657,8 @@ interface DecodedSparkAddressData {
3556
3657
  };
3557
3658
  signature?: string;
3558
3659
  }
3559
- declare function encodeSparkAddress(payload: SparkAddressData): LegacySparkAddressFormat;
3560
- declare function encodeSparkAddressWithSignature(payload: SparkAddressData, signature?: Uint8Array): LegacySparkAddressFormat;
3660
+ declare function encodeSparkAddress(payload: SparkAddressData): SparkAddressFormat;
3661
+ declare function encodeSparkAddressWithSignature(payload: SparkAddressData, signature?: Uint8Array): SparkAddressFormat;
3561
3662
  declare function decodeSparkAddress(address: string, network: NetworkType): DecodedSparkAddressData;
3562
3663
  declare function getNetworkFromSparkAddress(address: string): NetworkType;
3563
3664
  declare function isLegacySparkAddress(address: string): address is LegacySparkAddressFormat;
@@ -3607,20 +3708,23 @@ type FulfillSparkInvoiceResponse = {
3607
3708
  }[];
3608
3709
  tokenTransactionSuccess: {
3609
3710
  tokenIdentifier: Bech32mTokenIdentifier;
3711
+ invoices: SparkAddressFormat[];
3610
3712
  txid: string;
3611
3713
  }[];
3612
3714
  satsTransactionErrors: {
3613
- invoice: string;
3715
+ invoice: SparkAddressFormat;
3614
3716
  error: Error;
3615
3717
  }[];
3616
3718
  tokenTransactionErrors: {
3617
3719
  tokenIdentifier: Bech32mTokenIdentifier;
3720
+ invoices: SparkAddressFormat[];
3618
3721
  error: Error;
3619
3722
  }[];
3620
- invalidInvoices: {
3621
- invoice: string;
3622
- error: Error;
3623
- }[];
3723
+ invalidInvoices: InvalidInvoice[];
3724
+ };
3725
+ type InvalidInvoice = {
3726
+ invoice: SparkAddressFormat;
3727
+ error: Error;
3624
3728
  };
3625
3729
  /**
3626
3730
  * Token metadata containing essential information about a token.
@@ -4098,14 +4202,14 @@ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
4098
4202
  * @param {Object} params - Parameters for the sats payment
4099
4203
  * @param {number} params.amount - The amount of sats to receive
4100
4204
  * @param {string} [params.memo] - The memo for the payment
4101
- * @param {string} [params.senderPublicKey] - The public key of the expected sender
4205
+ * @param {string} [params.senderSparkAddress] - The spark address of the expected sender
4102
4206
  * @param {Date} [params.expiryTime] - The expiry time of the payment
4103
4207
  * @returns {Promise<SparkAddressFormat>} The Spark address for the sats payment
4104
4208
  */
4105
- createSatsInvoice({ amount, memo, senderPublicKey, expiryTime, }: {
4209
+ createSatsInvoice({ amount, memo, senderSparkAddress, expiryTime, }: {
4106
4210
  amount?: number;
4107
4211
  memo?: string;
4108
- senderPublicKey?: string;
4212
+ senderSparkAddress?: SparkAddressFormat;
4109
4213
  expiryTime?: Date;
4110
4214
  }): Promise<SparkAddressFormat>;
4111
4215
  /**
@@ -4115,15 +4219,15 @@ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
4115
4219
  * @param {bigint} [params.amount] - The amount of tokens to receive
4116
4220
  * @param {Bech32mTokenIdentifier} [params.tokenIdentifier] - The token identifier
4117
4221
  * @param {string} [params.memo] - The memo for the payment
4118
- * @param {string} [params.senderPublicKey] - The public key of the expected sender
4222
+ * @param {string} [params.senderSparkAddress] - The spark address of the expected sender
4119
4223
  * @param {Date} [params.expiryTime] - The expiry time of the payment
4120
4224
  * @returns {Promise<SparkAddressFormat>} The Spark address for the tokens payment
4121
4225
  */
4122
- createTokensInvoice({ amount, tokenIdentifier, memo, senderPublicKey, expiryTime, }: {
4226
+ createTokensInvoice({ amount, tokenIdentifier, memo, senderSparkAddress, expiryTime, }: {
4123
4227
  tokenIdentifier?: Bech32mTokenIdentifier;
4124
4228
  amount?: bigint;
4125
4229
  memo?: string;
4126
- senderPublicKey?: string;
4230
+ senderSparkAddress?: SparkAddressFormat;
4127
4231
  expiryTime?: Date;
4128
4232
  }): Promise<SparkAddressFormat>;
4129
4233
  /**
@@ -4422,6 +4526,31 @@ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
4422
4526
  * @returns {Promise<LightningSendRequest>} The Lightning payment request details
4423
4527
  */
4424
4528
  payLightningInvoice({ invoice, maxFeeSats, preferSpark, amountSatsToSend, }: PayLightningInvoiceParams): Promise<LightningSendRequest | WalletTransfer>;
4529
+ /**
4530
+ * Fulfills one or more Spark invoices.
4531
+ *
4532
+ * Processes each provided invoice and attempts to pay it according to the wallet’s
4533
+ * funding/selection strategy.
4534
+ *
4535
+ * @param sparkInvoices - Invoices to fulfill.
4536
+ * @param sparkInvoices[].invoice - The parsed Spark address/invoice to pay.
4537
+ * Must be a valid Spark address or invoice.
4538
+ * Must use spark1... prefixed invoices.
4539
+ * Deprecated sp1... prefixed invoices are not supported.
4540
+ * @param sparkInvoices[].amount - Used to define an amount for invoices without an amount encoded.
4541
+ * For sats invoices, this is the amount in sats. For token invoices, this is the amount in tokens.
4542
+ * Amount encoded in the invoice takes precedence if both are provided.
4543
+ *
4544
+ * @returns Promise<string> A payment or transaction identifier (implementation‑specific).
4545
+ *
4546
+ * @throws {ValidationError} If validation fails (malformed invoice, zero/negative amount, unsupported network),
4547
+ *
4548
+ * @example
4549
+ * await wallet.fulfillSparkInvoice([
4550
+ * { invoice: invoiceWithNilAmount, amount: 1000n },
4551
+ * { invoice: invoiceWithEncodedAmount }, // uses amount encoded in the invoice
4552
+ * ]);
4553
+ */
4425
4554
  fulfillSparkInvoice(sparkInvoices: {
4426
4555
  invoice: SparkAddressFormat;
4427
4556
  amount?: bigint;