@buildonspark/spark-sdk 0.1.45 → 0.1.47

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 (146) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/{chunk-I54FARY2.js → chunk-EAP3U3CW.js} +14 -14
  3. package/dist/chunk-GWFQ7EBA.js +3773 -0
  4. package/dist/{chunk-J2IE4Z7Y.js → chunk-NNX4OK44.js} +3487 -934
  5. package/dist/{RequestLightningSendInput-Du0z7Om7.d.cts → client-CvpTRpcw.d.cts} +422 -212
  6. package/dist/{RequestLightningSendInput-DEPd_fPO.d.ts → client-D7KgLN44.d.ts} +422 -212
  7. package/dist/graphql/objects/index.d.cts +5 -9
  8. package/dist/graphql/objects/index.d.ts +5 -9
  9. package/dist/graphql/objects/index.js +1 -1
  10. package/dist/index.cjs +20461 -23377
  11. package/dist/index.d.cts +15 -769
  12. package/dist/index.d.ts +15 -769
  13. package/dist/index.js +81 -71
  14. package/dist/index.node.cjs +21994 -25018
  15. package/dist/index.node.d.cts +312 -34
  16. package/dist/index.node.d.ts +312 -34
  17. package/dist/index.node.js +82 -176
  18. package/dist/native/index.cjs +22847 -25841
  19. package/dist/native/index.d.cts +974 -1138
  20. package/dist/native/index.d.ts +974 -1138
  21. package/dist/native/index.js +10604 -13592
  22. package/dist/proto/lrc20.d.cts +2 -2
  23. package/dist/proto/lrc20.d.ts +2 -2
  24. package/dist/proto/lrc20.js +3098 -46
  25. package/dist/proto/spark.d.cts +1 -1
  26. package/dist/proto/spark.d.ts +1 -1
  27. package/dist/proto/spark_token.d.cts +1 -1
  28. package/dist/proto/spark_token.d.ts +1 -1
  29. package/dist/{sdk-types-Cc4l4kb1.d.ts → sdk-types-BGCeea0G.d.ts} +1 -1
  30. package/dist/{sdk-types-B0SwjolI.d.cts → sdk-types-XUeQMLFP.d.cts} +1 -1
  31. package/dist/{spark-dM7EYXYQ.d.cts → spark-BbUrbvZz.d.cts} +1 -1
  32. package/dist/{spark-dM7EYXYQ.d.ts → spark-BbUrbvZz.d.ts} +1 -1
  33. package/dist/spark-wallet-BAFPpPtY.d.cts +923 -0
  34. package/dist/spark-wallet-CJkQW8pK.d.ts +923 -0
  35. package/dist/spark_bindings/native/index.d.cts +1 -1
  36. package/dist/spark_bindings/native/index.d.ts +1 -1
  37. package/dist/spark_bindings/wasm/index.d.cts +1 -1
  38. package/dist/spark_bindings/wasm/index.d.ts +1 -1
  39. package/dist/{services/index.cjs → tests/test-utils.cjs} +2512 -4380
  40. package/dist/tests/test-utils.d.cts +79 -0
  41. package/dist/tests/test-utils.d.ts +79 -0
  42. package/dist/tests/test-utils.js +85 -0
  43. package/dist/types/index.d.cts +5 -9
  44. package/dist/types/index.d.ts +5 -9
  45. package/dist/types/index.js +5 -5
  46. package/dist/{types-C-Rp0Oo7.d.cts → types-BADxR3bm.d.cts} +1 -1
  47. package/dist/{types-C-Rp0Oo7.d.ts → types-BADxR3bm.d.ts} +1 -1
  48. package/package.json +7 -35
  49. package/src/graphql/client.ts +59 -20
  50. package/src/index.node.ts +28 -2
  51. package/src/index.ts +31 -1
  52. package/src/native/index.ts +16 -2
  53. package/src/services/config.ts +4 -6
  54. package/src/services/connection.ts +131 -64
  55. package/src/services/lightning.ts +1 -2
  56. package/src/services/token-transactions.ts +7 -7
  57. package/src/services/transfer.ts +1 -1
  58. package/src/services/tree-creation.ts +1 -1
  59. package/src/services/wallet-config.ts +18 -10
  60. package/src/signer/signer.react-native.ts +2 -5
  61. package/src/signer/signer.ts +138 -64
  62. package/src/signer/types.ts +52 -0
  63. package/src/spark-wallet/spark-wallet.ts +79 -36
  64. package/src/spark-wallet/types.ts +4 -4
  65. package/src/tests/integration/coop-exit.test.ts +2 -1
  66. package/src/tests/integration/lightning.test.ts +2 -2
  67. package/src/tests/integration/swap.test.ts +1 -1
  68. package/src/tests/integration/transfer.test.ts +5 -5
  69. package/src/tests/integration/tree-creation.test.ts +1 -1
  70. package/src/tests/integration/wallet.test.ts +1 -0
  71. package/src/tests/isHermeticTest.ts +3 -24
  72. package/src/tests/{test-util.ts → test-utils.ts} +3 -7
  73. package/src/tests/wrapWithOtelSpan.test.ts +1 -1
  74. package/src/{address → utils}/address.ts +1 -1
  75. package/src/utils/crypto.ts +19 -9
  76. package/src/utils/index.ts +2 -0
  77. package/src/utils/network.ts +17 -0
  78. package/src/utils/secret-sharing.ts +1 -2
  79. package/src/utils/signing.ts +1 -1
  80. package/src/utils/token-transactions.ts +3 -3
  81. package/src/utils/unilateral-exit.ts +32 -0
  82. package/src/utils/xchain-address.ts +1 -1
  83. package/dist/BitcoinNetwork-TnABML0T.d.cts +0 -18
  84. package/dist/BitcoinNetwork-TnABML0T.d.ts +0 -18
  85. package/dist/LightningSendFeeEstimateInput-BgOhEAI-.d.cts +0 -10
  86. package/dist/LightningSendFeeEstimateInput-BgOhEAI-.d.ts +0 -10
  87. package/dist/address/index.cjs +0 -458
  88. package/dist/address/index.d.cts +0 -32
  89. package/dist/address/index.d.ts +0 -32
  90. package/dist/address/index.js +0 -17
  91. package/dist/chunk-5FUB65LX.js +0 -838
  92. package/dist/chunk-6264CGDM.js +0 -113
  93. package/dist/chunk-7V6N75CC.js +0 -24
  94. package/dist/chunk-C2S227QR.js +0 -2336
  95. package/dist/chunk-GSI4OLXZ.js +0 -117
  96. package/dist/chunk-GZ5IPPJ2.js +0 -170
  97. package/dist/chunk-HWJWKEIU.js +0 -75
  98. package/dist/chunk-KMUMFYFX.js +0 -137
  99. package/dist/chunk-L3EHBOUX.js +0 -0
  100. package/dist/chunk-NSJF5F5O.js +0 -325
  101. package/dist/chunk-NTFKFRQ2.js +0 -3146
  102. package/dist/chunk-PQN3C2MF.js +0 -1122
  103. package/dist/chunk-QNNSEJ4P.js +0 -232
  104. package/dist/chunk-R5PXJZQS.js +0 -277
  105. package/dist/chunk-VTUGIIWI.js +0 -0
  106. package/dist/chunk-YUPMXTCJ.js +0 -622
  107. package/dist/chunk-Z5HIAYFT.js +0 -84
  108. package/dist/index-B2AwKW5J.d.cts +0 -214
  109. package/dist/index-CJDi1HWc.d.ts +0 -214
  110. package/dist/network-BTJl-Sul.d.ts +0 -46
  111. package/dist/network-CqgsdUF2.d.cts +0 -46
  112. package/dist/services/config.cjs +0 -2354
  113. package/dist/services/config.d.cts +0 -42
  114. package/dist/services/config.d.ts +0 -42
  115. package/dist/services/config.js +0 -17
  116. package/dist/services/connection.cjs +0 -17691
  117. package/dist/services/connection.d.cts +0 -95
  118. package/dist/services/connection.d.ts +0 -95
  119. package/dist/services/connection.js +0 -11
  120. package/dist/services/index.d.cts +0 -21
  121. package/dist/services/index.d.ts +0 -21
  122. package/dist/services/index.js +0 -58
  123. package/dist/services/lrc-connection.cjs +0 -4713
  124. package/dist/services/lrc-connection.d.cts +0 -34
  125. package/dist/services/lrc-connection.d.ts +0 -34
  126. package/dist/services/lrc-connection.js +0 -11
  127. package/dist/services/token-transactions.cjs +0 -2877
  128. package/dist/services/token-transactions.d.cts +0 -75
  129. package/dist/services/token-transactions.d.ts +0 -75
  130. package/dist/services/token-transactions.js +0 -15
  131. package/dist/services/wallet-config.cjs +0 -340
  132. package/dist/services/wallet-config.d.cts +0 -56
  133. package/dist/services/wallet-config.d.ts +0 -56
  134. package/dist/services/wallet-config.js +0 -33
  135. package/dist/signer/signer.cjs +0 -2004
  136. package/dist/signer/signer.d.cts +0 -10
  137. package/dist/signer/signer.d.ts +0 -10
  138. package/dist/signer/signer.js +0 -24
  139. package/dist/signer-BocS_J6B.d.ts +0 -187
  140. package/dist/signer-DKS0AJkw.d.cts +0 -187
  141. package/dist/utils/index.cjs +0 -2947
  142. package/dist/utils/index.d.cts +0 -18
  143. package/dist/utils/index.d.ts +0 -18
  144. package/dist/utils/index.js +0 -157
  145. package/src/address/index.ts +0 -1
  146. package/src/services/lrc-connection.ts +0 -215
@@ -1,6 +1,210 @@
1
1
  import { Query } from '@lightsparkdev/core';
2
- import { B as BitcoinNetwork } from './BitcoinNetwork-TnABML0T.js';
3
- import { S as SparkSigner } from './signer-BocS_J6B.js';
2
+ import { d as TreeNode } from './spark-BbUrbvZz.js';
3
+ import { TokenSigner, Receipt } from '@buildonspark/lrc20-sdk';
4
+ import { Transaction } from '@scure/btc-signer';
5
+ import { Psbt } from 'bitcoinjs-lib';
6
+ import { HDKey } from '@scure/bip32';
7
+ import { b as ISigningCommitment } from './types-BADxR3bm.js';
8
+
9
+ /** This is an enum identifying a particular Bitcoin Network. **/
10
+ declare enum BitcoinNetwork {
11
+ /**
12
+ * This is an enum value that represents values that could be added in the future.
13
+ * Clients should support unknown values as more of them could be added without notice.
14
+ */
15
+ FUTURE_VALUE = "FUTURE_VALUE",
16
+ /** The production version of the Bitcoin Blockchain. **/
17
+ MAINNET = "MAINNET",
18
+ /** A test version of the Bitcoin Blockchain, maintained by Lightspark. **/
19
+ REGTEST = "REGTEST",
20
+ /** A test version of the Bitcoin Blockchain, maintained by a centralized organization. Not in use at Lightspark. **/
21
+ SIGNET = "SIGNET",
22
+ /** A test version of the Bitcoin Blockchain, publicly available. **/
23
+ TESTNET = "TESTNET"
24
+ }
25
+
26
+ type Polynomial = {
27
+ fieldModulus: bigint;
28
+ coefficients: bigint[];
29
+ proofs: Uint8Array[];
30
+ };
31
+ type SecretShare = {
32
+ fieldModulus: bigint;
33
+ threshold: number;
34
+ index: bigint;
35
+ share: bigint;
36
+ };
37
+ type VerifiableSecretShare = SecretShare & {
38
+ proofs: Uint8Array[];
39
+ };
40
+ declare function getRandomBigInt(max: bigint): bigint;
41
+ declare function modInverse(a: bigint, m: bigint): bigint;
42
+ declare function evaluatePolynomial(polynomial: Polynomial, x: bigint): bigint;
43
+ declare function fieldDiv(numerator: bigint, denominator: bigint, fieldModulus: bigint): bigint;
44
+ declare function computerLagrangeCoefficients(index: bigint, points: SecretShare[]): bigint;
45
+ declare function generatePolynomialForSecretSharing(fieldModulus: bigint, secret: bigint, degree: number): Polynomial;
46
+ declare function splitSecret(fieldModulus: bigint, secret: bigint, threshold: number, numberOfShares: number): SecretShare[];
47
+ declare function splitSecretWithProofs(secret: bigint, fieldModulus: bigint, threshold: number, numberOfShares: number): VerifiableSecretShare[];
48
+ declare function recoverSecret(shares: VerifiableSecretShare[]): bigint;
49
+ declare function validateShare(share: VerifiableSecretShare): void;
50
+ declare function bigIntToPrivateKey(value: bigint): Uint8Array;
51
+
52
+ type SigningNonce = {
53
+ binding: Uint8Array;
54
+ hiding: Uint8Array;
55
+ };
56
+ type SigningCommitment = {
57
+ binding: Uint8Array;
58
+ hiding: Uint8Array;
59
+ };
60
+ type SignFrostParams = {
61
+ message: Uint8Array;
62
+ privateAsPubKey: Uint8Array;
63
+ publicKey: Uint8Array;
64
+ verifyingKey: Uint8Array;
65
+ selfCommitment: ISigningCommitment;
66
+ statechainCommitments?: {
67
+ [key: string]: ISigningCommitment;
68
+ } | undefined;
69
+ adaptorPubKey?: Uint8Array | undefined;
70
+ };
71
+ type AggregateFrostParams = Omit<SignFrostParams, "privateAsPubKey"> & {
72
+ selfSignature: Uint8Array;
73
+ statechainSignatures?: {
74
+ [key: string]: Uint8Array;
75
+ } | undefined;
76
+ statechainPublicKeys?: {
77
+ [key: string]: Uint8Array;
78
+ } | undefined;
79
+ };
80
+ type SplitSecretWithProofsParams = {
81
+ secret: Uint8Array;
82
+ curveOrder: bigint;
83
+ threshold: number;
84
+ numShares: number;
85
+ isSecretPubkey?: boolean;
86
+ };
87
+ type DerivedHDKey = {
88
+ hdKey: HDKey;
89
+ privateKey: Uint8Array;
90
+ publicKey: Uint8Array;
91
+ };
92
+ type KeyPair = {
93
+ privateKey: Uint8Array;
94
+ publicKey: Uint8Array;
95
+ };
96
+
97
+ interface SparkKeysGenerator {
98
+ deriveKeysFromSeed(seed: Uint8Array, accountNumber: number): Promise<{
99
+ masterPublicKey: Uint8Array;
100
+ identityKey: KeyPair;
101
+ signingHDKey: DerivedHDKey;
102
+ depositKey: KeyPair;
103
+ staticDepositHDKey: DerivedHDKey;
104
+ }>;
105
+ }
106
+ declare class TaprootOutputKeysGenerator implements SparkKeysGenerator {
107
+ private readonly useAddressIndex;
108
+ constructor(useAddressIndex?: boolean);
109
+ deriveKeysFromSeed(seed: Uint8Array, accountNumber: number): Promise<{
110
+ masterPublicKey: Uint8Array;
111
+ identityKey: KeyPair;
112
+ signingHDKey: DerivedHDKey;
113
+ depositKey: KeyPair;
114
+ staticDepositHDKey: DerivedHDKey;
115
+ }>;
116
+ }
117
+ interface SparkSigner extends TokenSigner {
118
+ getIdentityPublicKey(): Promise<Uint8Array>;
119
+ getDepositSigningKey(): Promise<Uint8Array>;
120
+ generateStaticDepositKey(idx: number): Promise<Uint8Array>;
121
+ getStaticDepositSigningKey(idx: number): Promise<Uint8Array>;
122
+ getStaticDepositSecretKey(idx: number): Promise<Uint8Array>;
123
+ generateMnemonic(): Promise<string>;
124
+ mnemonicToSeed(mnemonic: string): Promise<Uint8Array>;
125
+ createSparkWalletFromSeed(seed: Uint8Array | string, accountNumber?: number): Promise<string>;
126
+ restoreSigningKeysFromLeafs(leafs: TreeNode[]): Promise<void>;
127
+ getTrackedPublicKeys(): Promise<Uint8Array[]>;
128
+ generatePublicKey(hash?: Uint8Array): Promise<Uint8Array>;
129
+ removePublicKey(publicKey: Uint8Array): Promise<void>;
130
+ getSchnorrPublicKey(publicKey: Uint8Array): Promise<Uint8Array>;
131
+ signSchnorr(message: Uint8Array, publicKey: Uint8Array): Promise<Uint8Array>;
132
+ signSchnorrWithIdentityKey(message: Uint8Array): Promise<Uint8Array>;
133
+ subtractPrivateKeysGivenPublicKeys(first: Uint8Array, second: Uint8Array): Promise<Uint8Array>;
134
+ splitSecretWithProofs(params: SplitSecretWithProofsParams): Promise<VerifiableSecretShare[]>;
135
+ signFrost(params: SignFrostParams): Promise<Uint8Array>;
136
+ aggregateFrost(params: AggregateFrostParams): Promise<Uint8Array>;
137
+ signMessageWithPublicKey(message: Uint8Array, publicKey: Uint8Array, compact?: boolean): Promise<Uint8Array>;
138
+ signMessageWithIdentityKey(message: Uint8Array, compact?: boolean): Promise<Uint8Array>;
139
+ validateMessageWithIdentityKey(message: Uint8Array, signature: Uint8Array): Promise<boolean>;
140
+ signTransactionIndex(tx: Transaction, index: number, publicKey: Uint8Array): void;
141
+ encryptLeafPrivateKeyEcies(receiverPublicKey: Uint8Array, publicKey: Uint8Array): Promise<Uint8Array>;
142
+ decryptEcies(ciphertext: Uint8Array): Promise<Uint8Array>;
143
+ getRandomSigningCommitment(): Promise<SigningCommitment>;
144
+ hashRandomPrivateKey(): Promise<Uint8Array>;
145
+ generateAdaptorFromSignature(signature: Uint8Array): Promise<{
146
+ adaptorSignature: Uint8Array;
147
+ adaptorPublicKey: Uint8Array;
148
+ }>;
149
+ getDepositSigningKey(): Promise<Uint8Array>;
150
+ getMasterPublicKey(): Promise<Uint8Array>;
151
+ }
152
+ declare class DefaultSparkSigner implements SparkSigner {
153
+ private masterPublicKey;
154
+ private identityKey;
155
+ private signingKey;
156
+ private depositKey;
157
+ private staticDepositKey;
158
+ private staticDepositKeyMap;
159
+ protected publicKeyToPrivateKeyMap: Map<string, string>;
160
+ protected commitmentToNonceMap: Map<SigningCommitment, SigningNonce>;
161
+ private readonly keysGenerator;
162
+ constructor({ sparkKeysGenerator, }?: {
163
+ sparkKeysGenerator?: SparkKeysGenerator;
164
+ });
165
+ private deriveSigningKey;
166
+ restoreSigningKeysFromLeafs(leafs: TreeNode[]): Promise<void>;
167
+ getSchnorrPublicKey(publicKey: Uint8Array): Promise<Uint8Array>;
168
+ signSchnorr(message: Uint8Array, publicKey: Uint8Array): Promise<Uint8Array>;
169
+ signSchnorrWithIdentityKey(message: Uint8Array): Promise<Uint8Array>;
170
+ getIdentityPublicKey(): Promise<Uint8Array>;
171
+ getDepositSigningKey(): Promise<Uint8Array>;
172
+ generateStaticDepositKey(idx: number): Promise<Uint8Array>;
173
+ getStaticDepositSigningKey(idx: number): Promise<Uint8Array>;
174
+ getStaticDepositSecretKey(idx: number): Promise<Uint8Array>;
175
+ generateMnemonic(): Promise<string>;
176
+ mnemonicToSeed(mnemonic: string): Promise<Uint8Array>;
177
+ getTrackedPublicKeys(): Promise<Uint8Array[]>;
178
+ generatePublicKey(hash?: Uint8Array): Promise<Uint8Array>;
179
+ removePublicKey(publicKey: Uint8Array): Promise<void>;
180
+ subtractPrivateKeysGivenPublicKeys(first: Uint8Array, second: Uint8Array): Promise<Uint8Array>;
181
+ splitSecretWithProofs({ secret, curveOrder, threshold, numShares, isSecretPubkey, }: SplitSecretWithProofsParams): Promise<VerifiableSecretShare[]>;
182
+ signFrost({ message, privateAsPubKey, publicKey, verifyingKey, selfCommitment, statechainCommitments, adaptorPubKey, }: SignFrostParams): Promise<Uint8Array>;
183
+ aggregateFrost({ message, publicKey, verifyingKey, selfCommitment, statechainCommitments, adaptorPubKey, selfSignature, statechainSignatures, statechainPublicKeys, }: AggregateFrostParams): Promise<Uint8Array>;
184
+ createSparkWalletFromSeed(seed: Uint8Array | string, accountNumber?: number): Promise<string>;
185
+ signMessageWithPublicKey(message: Uint8Array, publicKey: Uint8Array, compact?: boolean): Promise<Uint8Array>;
186
+ signMessageWithIdentityKey(message: Uint8Array, compact?: boolean): Promise<Uint8Array>;
187
+ encryptLeafPrivateKeyEcies(receiverPublicKey: Uint8Array, publicKey: Uint8Array): Promise<Uint8Array>;
188
+ decryptEcies(ciphertext: Uint8Array): Promise<Uint8Array>;
189
+ getRandomSigningCommitment(): Promise<SigningCommitment>;
190
+ hashRandomPrivateKey(): Promise<Uint8Array>;
191
+ generateAdaptorFromSignature(signature: Uint8Array): Promise<{
192
+ adaptorSignature: Uint8Array;
193
+ adaptorPublicKey: Uint8Array;
194
+ }>;
195
+ getMasterPublicKey(): Promise<Uint8Array>;
196
+ validateMessageWithIdentityKey(message: Uint8Array, signature: Uint8Array): Promise<boolean>;
197
+ signPsbt(psbt: Psbt, input: number, sighashTypes?: number[], receipt?: Receipt): Promise<Psbt>;
198
+ private getReceiptPrivateKey;
199
+ signTransactionIndex(tx: Transaction, index: number, publicKey: Uint8Array): void;
200
+ }
201
+ declare class TaprootSparkSigner extends DefaultSparkSigner {
202
+ constructor(useAddressIndex?: boolean);
203
+ }
204
+
205
+ interface ClaimStaticDepositOutput {
206
+ transferId: string;
207
+ }
4
208
 
5
209
  /** This enum identifies the unit of currency associated with a CurrencyAmount. **/
6
210
  declare enum CurrencyUnit {
@@ -51,19 +255,38 @@ interface CurrencyAmount {
51
255
  preferredCurrencyValueApprox: number;
52
256
  }
53
257
 
54
- interface ClaimStaticDepositOutput {
55
- transferId: string;
258
+ declare enum ExitSpeed {
259
+ /**
260
+ * This is an enum value that represents values that could be added in the future.
261
+ * Clients should support unknown values as more of them could be added without notice.
262
+ */
263
+ FUTURE_VALUE = "FUTURE_VALUE",
264
+ FAST = "FAST",
265
+ MEDIUM = "MEDIUM",
266
+ SLOW = "SLOW"
56
267
  }
57
268
 
58
- interface CompleteCoopExitInput {
59
- userOutboundTransferExternalId: string;
60
- coopExitRequestId: string;
269
+ declare enum SparkCoopExitRequestStatus {
270
+ /**
271
+ * This is an enum value that represents values that could be added in the future.
272
+ * Clients should support unknown values as more of them could be added without notice.
273
+ */
274
+ FUTURE_VALUE = "FUTURE_VALUE",
275
+ INITIATED = "INITIATED",
276
+ INBOUND_TRANSFER_CHECKED = "INBOUND_TRANSFER_CHECKED",
277
+ TX_SIGNED = "TX_SIGNED",
278
+ TX_BROADCASTED = "TX_BROADCASTED",
279
+ WAITING_ON_TX_CONFIRMATIONS = "WAITING_ON_TX_CONFIRMATIONS",
280
+ SUCCEEDED = "SUCCEEDED",
281
+ EXPIRED = "EXPIRED",
282
+ FAILED = "FAILED"
61
283
  }
62
284
 
63
- interface CompleteLeavesSwapInput {
64
- adaptorSecretKey: string;
65
- userOutboundTransferExternalId: string;
66
- leavesSwapRequestId: string;
285
+ interface Leaf {
286
+ /** The amount of the leaf. **/
287
+ amount: CurrencyAmount;
288
+ /** The id of the leaf known at signing operators. **/
289
+ sparkNodeId: string;
67
290
  }
68
291
 
69
292
  /** This is an object representing information about a page returned by the Lightspark API. For more information, please see the “Pagination” section of our API docs for more information about its usage. **/
@@ -74,6 +297,94 @@ interface PageInfo {
74
297
  endCursor?: string | undefined;
75
298
  }
76
299
 
300
+ interface SparkTransferToLeavesConnection {
301
+ /**
302
+ * The total count of objects in this connection, using the current filters. It is different from the
303
+ * number of objects returned in the current page (in the `entities` field).
304
+ **/
305
+ count: number;
306
+ /** An object that holds pagination information about the objects in this connection. **/
307
+ pageInfo: PageInfo;
308
+ /** The leaves for the current page of this connection. **/
309
+ entities: Leaf[];
310
+ /** The typename of the object **/
311
+ typename: string;
312
+ }
313
+
314
+ declare class Transfer {
315
+ /** The total amount of the transfer. **/
316
+ readonly totalAmount: CurrencyAmount;
317
+ /** The id of the transfer known at signing operators. If not set, the transfer hasn't been
318
+ * initialized. **/
319
+ readonly sparkId?: string | undefined;
320
+ /** The user request this transfer belongs to, if there is any **/
321
+ readonly userRequestId?: string | undefined;
322
+ constructor(
323
+ /** The total amount of the transfer. **/
324
+ totalAmount: CurrencyAmount,
325
+ /** The id of the transfer known at signing operators. If not set, the transfer hasn't been
326
+ * initialized. **/
327
+ sparkId?: string | undefined,
328
+ /** The user request this transfer belongs to, if there is any **/
329
+ userRequestId?: string | undefined);
330
+ getLeaves(client: SspClient, first?: number | undefined, after?: string | undefined): Promise<SparkTransferToLeavesConnection>;
331
+ toJson(): {
332
+ transfer_total_amount: any;
333
+ transfer_spark_id: string | undefined;
334
+ transfer_user_request: {
335
+ id: string | undefined;
336
+ };
337
+ };
338
+ }
339
+
340
+ interface CoopExitRequest {
341
+ /**
342
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
343
+ * string.
344
+ **/
345
+ id: string;
346
+ /** The date and time when the entity was first created. **/
347
+ createdAt: string;
348
+ /** The date and time when the entity was last updated. **/
349
+ updatedAt: string;
350
+ /** The network the lightning send request is on. **/
351
+ network: BitcoinNetwork;
352
+ /** The fee user pays for the coop exit not including the L1 broadcast fee. **/
353
+ fee: CurrencyAmount;
354
+ /** The L1 broadcast fee user pays for the coop exit. **/
355
+ l1BroadcastFee: CurrencyAmount;
356
+ /** The status of this coop exit request. **/
357
+ status: SparkCoopExitRequestStatus;
358
+ /** The time when the coop exit request expires and the UTXOs are released. **/
359
+ expiresAt: string;
360
+ /** The raw connector transaction. **/
361
+ rawConnectorTransaction: string;
362
+ /** The raw coop exit L1 transaction. **/
363
+ rawCoopExitTransaction: string;
364
+ /** The transaction id of the coop exit transaction. **/
365
+ coopExitTxid: string;
366
+ /** The typename of the object **/
367
+ typename: string;
368
+ /** The fee quote user requested for this coop exit. **/
369
+ feeQuoteId?: string | undefined;
370
+ /** The exit speed user requested for this coop exit. **/
371
+ exitSpeed?: ExitSpeed | undefined;
372
+ /** The swap transfer. **/
373
+ transfer?: Transfer | undefined;
374
+ }
375
+ declare const getCoopExitRequestQuery: (id: string) => Query<CoopExitRequest>;
376
+
377
+ interface CompleteCoopExitInput {
378
+ userOutboundTransferExternalId: string;
379
+ coopExitRequestId: string;
380
+ }
381
+
382
+ interface CompleteLeavesSwapInput {
383
+ adaptorSecretKey: string;
384
+ userOutboundTransferExternalId: string;
385
+ leavesSwapRequestId: string;
386
+ }
387
+
77
388
  interface CoopExitFeeEstimate {
78
389
  userFee: CurrencyAmount;
79
390
  l1BroadcastFee: CurrencyAmount;
@@ -128,31 +439,22 @@ interface CoopExitFeeQuoteInput {
128
439
  withdrawalAddress: string;
129
440
  }
130
441
 
131
- declare enum ExitSpeed {
132
- /**
133
- * This is an enum value that represents values that could be added in the future.
134
- * Clients should support unknown values as more of them could be added without notice.
135
- */
136
- FUTURE_VALUE = "FUTURE_VALUE",
137
- FAST = "FAST",
138
- MEDIUM = "MEDIUM",
139
- SLOW = "SLOW"
442
+ interface GetChallengeOutput {
443
+ protectedChallenge: string;
140
444
  }
141
445
 
142
- declare enum SparkCoopExitRequestStatus {
143
- /**
144
- * This is an enum value that represents values that could be added in the future.
145
- * Clients should support unknown values as more of them could be added without notice.
146
- */
147
- FUTURE_VALUE = "FUTURE_VALUE",
148
- INITIATED = "INITIATED",
149
- INBOUND_TRANSFER_CHECKED = "INBOUND_TRANSFER_CHECKED",
150
- TX_SIGNED = "TX_SIGNED",
151
- TX_BROADCASTED = "TX_BROADCASTED",
152
- WAITING_ON_TX_CONFIRMATIONS = "WAITING_ON_TX_CONFIRMATIONS",
153
- SUCCEEDED = "SUCCEEDED",
154
- EXPIRED = "EXPIRED",
155
- FAILED = "FAILED"
446
+ interface Invoice {
447
+ encodedInvoice: string;
448
+ bitcoinNetwork: BitcoinNetwork;
449
+ paymentHash: string;
450
+ amount: CurrencyAmount;
451
+ createdAt: string;
452
+ expiresAt: string;
453
+ memo?: string | undefined;
454
+ }
455
+
456
+ interface LeavesSwapFeeEstimateOutput {
457
+ feeEstimate: CurrencyAmount;
156
458
  }
157
459
 
158
460
  declare enum SparkLeavesSwapRequestStatus {
@@ -210,16 +512,6 @@ interface LeavesSwapRequest {
210
512
  }
211
513
  declare const getLeavesSwapRequestQuery: (id: string) => Query<LeavesSwapRequest>;
212
514
 
213
- interface Invoice {
214
- encodedInvoice: string;
215
- bitcoinNetwork: BitcoinNetwork;
216
- paymentHash: string;
217
- amount: CurrencyAmount;
218
- createdAt: string;
219
- expiresAt: string;
220
- memo?: string | undefined;
221
- }
222
-
223
515
  declare enum LightningReceiveRequestStatus {
224
516
  /**
225
517
  * This is an enum value that represents values that could be added in the future.
@@ -265,176 +557,16 @@ interface LightningReceiveRequest {
265
557
  }
266
558
  declare const getLightningReceiveRequestQuery: (id: string) => Query<LightningReceiveRequest>;
267
559
 
268
- interface LightningSendFeeEstimateOutput {
269
- feeEstimate: CurrencyAmount;
270
- }
271
-
272
- interface StaticDepositQuoteInput {
273
- /** The transaction id of the deposit. **/
274
- transactionId: string;
275
- /** The output index of the deposit. **/
276
- outputIndex: number;
277
- /** The bitcoin network of the deposit. **/
278
- network: BitcoinNetwork;
279
- }
280
-
281
- interface StaticDepositQuoteOutput {
282
- /** The transaction id of the deposit. **/
283
- transactionId: string;
284
- /** The output index of the deposit. **/
285
- outputIndex: number;
286
- /** The bitcoin network of the deposit. **/
287
- network: BitcoinNetwork;
288
- /** The amount of sats that will be credited to the user's balance. **/
289
- creditAmountSats: number;
290
- /** The signature of the quote. **/
291
- signature: string;
292
- }
293
-
294
- interface VerifyChallengeOutput {
295
- validUntil: string;
296
- sessionToken: string;
297
- }
298
-
299
- interface SspClientOptions {
300
- baseUrl: string;
301
- identityPublicKey: string;
302
- schemaEndpoint?: string;
303
- }
304
- interface MayHaveSspClientOptions {
305
- readonly sspClientOptions?: SspClientOptions;
306
- }
307
- interface HasSspClientOptions {
308
- readonly sspClientOptions: SspClientOptions;
309
- }
310
- declare class SspClient {
311
- private readonly requester;
312
- private readonly signer;
313
- private readonly authProvider;
314
- constructor(config: HasSspClientOptions & {
315
- signer: SparkSigner;
316
- });
317
- executeRawQuery<T>(query: Query<T>, needsAuth?: boolean): Promise<T | null>;
318
- getSwapFeeEstimate(amountSats: number): Promise<LeavesSwapFeeEstimateOutput | null>;
319
- getLightningSendFeeEstimate(encodedInvoice: string, amountSats?: number): Promise<LightningSendFeeEstimateOutput | null>;
320
- getCoopExitFeeEstimate({ leafExternalIds, withdrawalAddress, }: CoopExitFeeEstimatesInput): Promise<CoopExitFeeEstimatesOutput | null>;
321
- getCurrentUser(): Promise<void>;
322
- completeCoopExit({ userOutboundTransferExternalId, coopExitRequestId, }: CompleteCoopExitInput): Promise<CoopExitRequest | null>;
323
- requestCoopExit({ leafExternalIds, withdrawalAddress, idempotencyKey, exitSpeed, feeLeafExternalIds, feeQuoteId, withdrawAll, }: RequestCoopExitInput): Promise<CoopExitRequest | null>;
324
- requestLightningReceive({ amountSats, network, paymentHash, expirySecs, memo, includeSparkAddress, receiverIdentityPubkey, descriptionHash, }: RequestLightningReceiveInput): Promise<LightningReceiveRequest | null>;
325
- requestLightningSend({ encodedInvoice, idempotencyKey, amountSats, }: RequestLightningSendInput): Promise<LightningSendRequest | null>;
326
- requestLeaveSwap({ adaptorPubkey, totalAmountSats, targetAmountSats, feeSats, userLeaves, idempotencyKey, targetAmountSatsList, }: RequestLeavesSwapInput): Promise<LeavesSwapRequest | null>;
327
- completeLeaveSwap({ adaptorSecretKey, userOutboundTransferExternalId, leavesSwapRequestId, }: CompleteLeavesSwapInput): Promise<LeavesSwapRequest | null>;
328
- getLightningReceiveRequest(id: string): Promise<LightningReceiveRequest | null>;
329
- getLightningSendRequest(id: string): Promise<LightningSendRequest | null>;
330
- getLeaveSwapRequest(id: string): Promise<LeavesSwapRequest | null>;
331
- getCoopExitRequest(id: string): Promise<CoopExitRequest | null>;
332
- getClaimDepositQuote({ transactionId, outputIndex, network, }: StaticDepositQuoteInput): Promise<StaticDepositQuoteOutput | null>;
333
- claimStaticDeposit({ transactionId, outputIndex, network, creditAmountSats, depositSecretKey, signature, sspSignature, }: {
334
- transactionId: string;
335
- outputIndex: number;
336
- network: BitcoinNetwork;
337
- creditAmountSats: number;
338
- depositSecretKey: string;
339
- signature: string;
340
- sspSignature: string;
341
- }): Promise<ClaimStaticDepositOutput | null>;
342
- getTransfer(id: string): Promise<Transfer | null>;
343
- getChallenge(): Promise<GetChallengeOutput | null>;
344
- verifyChallenge(signature: string, protectedChallenge: string): Promise<VerifyChallengeOutput | null>;
345
- authenticate(): Promise<void>;
346
- getCoopExitFeeQuote({ leafExternalIds, withdrawalAddress, }: CoopExitFeeQuoteInput): Promise<CoopExitFeeQuote | null>;
347
- }
348
-
349
- interface Leaf {
350
- /** The amount of the leaf. **/
351
- amount: CurrencyAmount;
352
- /** The id of the leaf known at signing operators. **/
353
- sparkNodeId: string;
354
- }
355
-
356
- interface SparkTransferToLeavesConnection {
357
- /**
358
- * The total count of objects in this connection, using the current filters. It is different from the
359
- * number of objects returned in the current page (in the `entities` field).
360
- **/
361
- count: number;
362
- /** An object that holds pagination information about the objects in this connection. **/
363
- pageInfo: PageInfo;
364
- /** The leaves for the current page of this connection. **/
365
- entities: Leaf[];
366
- /** The typename of the object **/
367
- typename: string;
368
- }
369
-
370
- declare class Transfer {
371
- /** The total amount of the transfer. **/
372
- readonly totalAmount: CurrencyAmount;
373
- /** The id of the transfer known at signing operators. If not set, the transfer hasn't been
374
- * initialized. **/
375
- readonly sparkId?: string | undefined;
376
- /** The user request this transfer belongs to, if there is any **/
377
- readonly userRequestId?: string | undefined;
378
- constructor(
379
- /** The total amount of the transfer. **/
380
- totalAmount: CurrencyAmount,
381
- /** The id of the transfer known at signing operators. If not set, the transfer hasn't been
382
- * initialized. **/
383
- sparkId?: string | undefined,
384
- /** The user request this transfer belongs to, if there is any **/
385
- userRequestId?: string | undefined);
386
- getLeaves(client: SspClient, first?: number | undefined, after?: string | undefined): Promise<SparkTransferToLeavesConnection>;
387
- toJson(): {
388
- transfer_total_amount: any;
389
- transfer_spark_id: string | undefined;
390
- transfer_user_request: {
391
- id: string | undefined;
392
- };
393
- };
394
- }
395
-
396
- interface CoopExitRequest {
560
+ interface LightningSendFeeEstimateInput {
561
+ encodedInvoice: string;
397
562
  /**
398
- * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
399
- * string.
400
- **/
401
- id: string;
402
- /** The date and time when the entity was first created. **/
403
- createdAt: string;
404
- /** The date and time when the entity was last updated. **/
405
- updatedAt: string;
406
- /** The network the lightning send request is on. **/
407
- network: BitcoinNetwork;
408
- /** The fee user pays for the coop exit not including the L1 broadcast fee. **/
409
- fee: CurrencyAmount;
410
- /** The L1 broadcast fee user pays for the coop exit. **/
411
- l1BroadcastFee: CurrencyAmount;
412
- /** The status of this coop exit request. **/
413
- status: SparkCoopExitRequestStatus;
414
- /** The time when the coop exit request expires and the UTXOs are released. **/
415
- expiresAt: string;
416
- /** The raw connector transaction. **/
417
- rawConnectorTransaction: string;
418
- /** The raw coop exit L1 transaction. **/
419
- rawCoopExitTransaction: string;
420
- /** The transaction id of the coop exit transaction. **/
421
- coopExitTxid: string;
422
- /** The typename of the object **/
423
- typename: string;
424
- /** The fee quote user requested for this coop exit. **/
425
- feeQuoteId?: string | undefined;
426
- /** The exit speed user requested for this coop exit. **/
427
- exitSpeed?: ExitSpeed | undefined;
428
- /** The swap transfer. **/
429
- transfer?: Transfer | undefined;
430
- }
431
- declare const getCoopExitRequestQuery: (id: string) => Query<CoopExitRequest>;
432
-
433
- interface GetChallengeOutput {
434
- protectedChallenge: string;
563
+ * The amount you will pay for this invoice in sats. It should ONLY be set when the invoice amount is
564
+ * zero.
565
+ **/
566
+ amountSats?: number | undefined;
435
567
  }
436
568
 
437
- interface LeavesSwapFeeEstimateOutput {
569
+ interface LightningSendFeeEstimateOutput {
438
570
  feeEstimate: CurrencyAmount;
439
571
  }
440
572
 
@@ -551,4 +683,82 @@ interface RequestLightningSendInput {
551
683
  amountSats?: number | undefined;
552
684
  }
553
685
 
554
- export { type SparkTransferToLeavesConnection as A, type StaticDepositQuoteInput as B, type ClaimStaticDepositOutput as C, type StaticDepositQuoteOutput as D, ExitSpeed as E, type SwapLeaf as F, type GetChallengeOutput as G, type HasSspClientOptions as H, type Invoice as I, type SspClientOptions as J, SspClient as K, type Leaf as L, type MayHaveSspClientOptions as M, type PageInfo as P, type RequestCoopExitInput as R, SparkCoopExitRequestStatus as S, Transfer as T, type UserLeafInput as U, type VerifyChallengeOutput as V, type CompleteCoopExitInput as a, type CompleteLeavesSwapInput as b, type CoopExitFeeEstimate as c, type CoopExitFeeEstimatesInput as d, type CoopExitFeeEstimatesOutput as e, type CoopExitFeeQuote as f, getCoopExitFeeQuoteQuery as g, type CoopExitFeeQuoteInput as h, type CoopExitRequest as i, getCoopExitRequestQuery as j, type CurrencyAmount as k, CurrencyUnit as l, type LeavesSwapFeeEstimateOutput as m, getLeavesSwapRequestQuery as n, type LeavesSwapRequest as o, getLightningReceiveRequestQuery as p, type LightningReceiveRequest as q, LightningReceiveRequestStatus as r, type LightningSendFeeEstimateOutput as s, getLightningSendRequestQuery as t, type LightningSendRequest as u, LightningSendRequestStatus as v, type RequestLeavesSwapInput as w, type RequestLightningReceiveInput as x, type RequestLightningSendInput as y, SparkLeavesSwapRequestStatus as z };
686
+ interface StaticDepositQuoteInput {
687
+ /** The transaction id of the deposit. **/
688
+ transactionId: string;
689
+ /** The output index of the deposit. **/
690
+ outputIndex: number;
691
+ /** The bitcoin network of the deposit. **/
692
+ network: BitcoinNetwork;
693
+ }
694
+
695
+ interface StaticDepositQuoteOutput {
696
+ /** The transaction id of the deposit. **/
697
+ transactionId: string;
698
+ /** The output index of the deposit. **/
699
+ outputIndex: number;
700
+ /** The bitcoin network of the deposit. **/
701
+ network: BitcoinNetwork;
702
+ /** The amount of sats that will be credited to the user's balance. **/
703
+ creditAmountSats: number;
704
+ /** The signature of the quote. **/
705
+ signature: string;
706
+ }
707
+
708
+ interface VerifyChallengeOutput {
709
+ validUntil: string;
710
+ sessionToken: string;
711
+ }
712
+
713
+ interface SspClientOptions {
714
+ baseUrl: string;
715
+ identityPublicKey: string;
716
+ schemaEndpoint?: string;
717
+ }
718
+ interface MayHaveSspClientOptions {
719
+ readonly sspClientOptions?: SspClientOptions;
720
+ }
721
+ interface HasSspClientOptions {
722
+ readonly sspClientOptions: SspClientOptions;
723
+ }
724
+ declare class SspClient {
725
+ private readonly requester;
726
+ private readonly signer;
727
+ private readonly authProvider;
728
+ private authPromise?;
729
+ constructor(config: HasSspClientOptions & {
730
+ signer: SparkSigner;
731
+ });
732
+ executeRawQuery<T>(query: Query<T>, needsAuth?: boolean): Promise<T | null>;
733
+ getSwapFeeEstimate(amountSats: number): Promise<LeavesSwapFeeEstimateOutput | null>;
734
+ getLightningSendFeeEstimate(encodedInvoice: string, amountSats?: number): Promise<LightningSendFeeEstimateOutput | null>;
735
+ getCoopExitFeeEstimate({ leafExternalIds, withdrawalAddress, }: CoopExitFeeEstimatesInput): Promise<CoopExitFeeEstimatesOutput | null>;
736
+ getCurrentUser(): Promise<void>;
737
+ completeCoopExit({ userOutboundTransferExternalId, coopExitRequestId, }: CompleteCoopExitInput): Promise<CoopExitRequest | null>;
738
+ requestCoopExit({ leafExternalIds, withdrawalAddress, idempotencyKey, exitSpeed, feeLeafExternalIds, feeQuoteId, withdrawAll, }: RequestCoopExitInput): Promise<CoopExitRequest | null>;
739
+ requestLightningReceive({ amountSats, network, paymentHash, expirySecs, memo, includeSparkAddress, receiverIdentityPubkey, descriptionHash, }: RequestLightningReceiveInput): Promise<LightningReceiveRequest | null>;
740
+ requestLightningSend({ encodedInvoice, idempotencyKey, amountSats, }: RequestLightningSendInput): Promise<LightningSendRequest | null>;
741
+ requestLeaveSwap({ adaptorPubkey, totalAmountSats, targetAmountSats, feeSats, userLeaves, idempotencyKey, targetAmountSatsList, }: RequestLeavesSwapInput): Promise<LeavesSwapRequest | null>;
742
+ completeLeaveSwap({ adaptorSecretKey, userOutboundTransferExternalId, leavesSwapRequestId, }: CompleteLeavesSwapInput): Promise<LeavesSwapRequest | null>;
743
+ getLightningReceiveRequest(id: string): Promise<LightningReceiveRequest | null>;
744
+ getLightningSendRequest(id: string): Promise<LightningSendRequest | null>;
745
+ getLeaveSwapRequest(id: string): Promise<LeavesSwapRequest | null>;
746
+ getCoopExitRequest(id: string): Promise<CoopExitRequest | null>;
747
+ getClaimDepositQuote({ transactionId, outputIndex, network, }: StaticDepositQuoteInput): Promise<StaticDepositQuoteOutput | null>;
748
+ claimStaticDeposit({ transactionId, outputIndex, network, creditAmountSats, depositSecretKey, signature, sspSignature, }: {
749
+ transactionId: string;
750
+ outputIndex: number;
751
+ network: BitcoinNetwork;
752
+ creditAmountSats: number;
753
+ depositSecretKey: string;
754
+ signature: string;
755
+ sspSignature: string;
756
+ }): Promise<ClaimStaticDepositOutput | null>;
757
+ getTransfer(id: string): Promise<Transfer | null>;
758
+ getChallenge(): Promise<GetChallengeOutput | null>;
759
+ verifyChallenge(signature: string, protectedChallenge: string): Promise<VerifyChallengeOutput | null>;
760
+ authenticate(): Promise<void>;
761
+ getCoopExitFeeQuote({ leafExternalIds, withdrawalAddress, }: CoopExitFeeQuoteInput): Promise<CoopExitFeeQuote | null>;
762
+ }
763
+
764
+ export { TaprootOutputKeysGenerator as $, SparkLeavesSwapRequestStatus as A, BitcoinNetwork as B, type ClaimStaticDepositOutput as C, type SparkTransferToLeavesConnection as D, ExitSpeed as E, type StaticDepositQuoteInput as F, type GetChallengeOutput as G, type StaticDepositQuoteOutput as H, type Invoice as I, type SwapLeaf as J, type SparkSigner as K, type Leaf as L, type MayHaveSspClientOptions as M, type SspClientOptions as N, type HasSspClientOptions as O, type PageInfo as P, type SigningCommitment as Q, type RequestCoopExitInput as R, SparkCoopExitRequestStatus as S, Transfer as T, type UserLeafInput as U, type VerifyChallengeOutput as V, type VerifiableSecretShare as W, SspClient as X, type SigningNonce as Y, DefaultSparkSigner as Z, TaprootSparkSigner as _, type CompleteCoopExitInput as a, getRandomBigInt as a0, modInverse as a1, evaluatePolynomial as a2, fieldDiv as a3, computerLagrangeCoefficients as a4, generatePolynomialForSecretSharing as a5, splitSecret as a6, splitSecretWithProofs as a7, recoverSecret as a8, validateShare as a9, bigIntToPrivateKey as aa, type SignFrostParams as ab, type AggregateFrostParams as ac, type SplitSecretWithProofsParams as ad, type DerivedHDKey as ae, type KeyPair as af, type CompleteLeavesSwapInput as b, type CoopExitFeeEstimate as c, type CoopExitFeeEstimatesInput as d, type CoopExitFeeEstimatesOutput as e, type CoopExitFeeQuote as f, getCoopExitFeeQuoteQuery as g, type CoopExitFeeQuoteInput as h, type CoopExitRequest as i, getCoopExitRequestQuery as j, type CurrencyAmount as k, CurrencyUnit as l, type LeavesSwapFeeEstimateOutput as m, getLeavesSwapRequestQuery as n, type LeavesSwapRequest as o, getLightningReceiveRequestQuery as p, type LightningReceiveRequest as q, LightningReceiveRequestStatus as r, type LightningSendFeeEstimateInput as s, type LightningSendFeeEstimateOutput as t, getLightningSendRequestQuery as u, type LightningSendRequest as v, LightningSendRequestStatus as w, type RequestLeavesSwapInput as x, type RequestLightningReceiveInput as y, type RequestLightningSendInput as z };