@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
@@ -0,0 +1,923 @@
1
+ import { B as BitcoinNetwork, M as MayHaveSspClientOptions, N as SspClientOptions, K as SparkSigner, O as HasSspClientOptions, Q as SigningCommitment, W as VerifiableSecretShare, m as LeavesSwapFeeEstimateOutput, H as StaticDepositQuoteOutput, C as ClaimStaticDepositOutput, q as LightningReceiveRequest, v as LightningSendRequest, s as LightningSendFeeEstimateInput, E as ExitSpeed, f as CoopExitFeeQuote, i as CoopExitRequest, T as Transfer$1 } from './client-D7KgLN44.js';
2
+ import { N as Network$1, P as PaymentIntentFields, E as Empty, g as SparkServiceClient, h as RequestedSigningCommitments, U as UserSignedTxSigningJob, d as TreeNode, f as Transfer, L as LeafRefundTxSigningResult, i as NodeSignatures, F as FinalizeNodeSignaturesResponse, Q as QueryTransfersResponse, j as OutputWithPreviousTransactionData } from './spark-BbUrbvZz.js';
3
+ import { NetworkType as NetworkType$1, MayHaveLrc20WalletApiConfig, LRC20WalletApiConfig, HasLrc20WalletApiConfig, LRCWallet } from '@buildonspark/lrc20-sdk';
4
+ import * as btc from '@scure/btc-signer';
5
+ import { Transaction } from '@scure/btc-signer';
6
+ import * as bitcoin from 'bitcoinjs-lib';
7
+ import { Channel } from 'nice-grpc';
8
+ import { Channel as Channel$1 } from 'nice-grpc-web';
9
+ import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
10
+ import { CallOptions } from 'nice-grpc-common';
11
+ import { SparkTokenServiceClient, TokenMetadata, TokenTransactionWithStatus } from './proto/spark_token.js';
12
+ import { EventEmitter } from 'eventemitter3';
13
+ import { a as WalletTransfer, W as WalletLeaf } from './sdk-types-BGCeea0G.js';
14
+
15
+ declare enum Network {
16
+ MAINNET = 0,
17
+ TESTNET = 1,
18
+ SIGNET = 2,
19
+ REGTEST = 3,
20
+ LOCAL = 4
21
+ }
22
+ type NetworkType = keyof typeof Network;
23
+ declare const NetworkToProto: Record<Network, Network$1>;
24
+ declare const protoToNetwork: (protoNetwork: Network$1) => Network | undefined;
25
+ declare const getNetwork: (network: Network) => typeof btc.NETWORK;
26
+ declare const LRC_WALLET_NETWORK: Readonly<{
27
+ 0: bitcoin.networks.Network;
28
+ 1: bitcoin.networks.Network;
29
+ 2: bitcoin.networks.Network;
30
+ 3: bitcoin.networks.Network;
31
+ 4: bitcoin.networks.Network;
32
+ }>;
33
+ declare const LRC_WALLET_NETWORK_TYPE: Readonly<{
34
+ 0: NetworkType$1.MAINNET;
35
+ 1: NetworkType$1.TESTNET;
36
+ 2: NetworkType$1.TESTNET;
37
+ 3: NetworkType$1.REGTEST;
38
+ 4: NetworkType$1.LOCAL;
39
+ }>;
40
+ /**
41
+ * Utility function to determine the network from a Bitcoin address.
42
+ *
43
+ * @param {string} address - The Bitcoin address
44
+ * @returns {BitcoinNetwork | null} The detected network or null if not detected
45
+ */
46
+ declare function getNetworkFromAddress(address: string): BitcoinNetwork.MAINNET | BitcoinNetwork.REGTEST | null;
47
+ /**
48
+ * Utility function to get the network enum value from a string.
49
+ *
50
+ * @param {string} network - The Bitcoin network to turn into an enum value
51
+ * @returns {Network} The enum value matching the string
52
+ */
53
+ declare function getNetworkFromString(network?: string): Network;
54
+
55
+ declare const AddressNetwork: Record<NetworkType, string>;
56
+ type SparkAddressFormat = `${(typeof AddressNetwork)[keyof typeof AddressNetwork]}1${string}`;
57
+ interface SparkAddressData {
58
+ identityPublicKey: string;
59
+ network: NetworkType;
60
+ paymentIntentFields?: PaymentIntentFields;
61
+ }
62
+ interface DecodedSparkAddressData {
63
+ identityPublicKey: string;
64
+ network: NetworkType;
65
+ paymentIntentFields?: {
66
+ id: string;
67
+ assetIdentifier?: string;
68
+ assetAmount: bigint;
69
+ memo?: string;
70
+ };
71
+ }
72
+ declare function encodeSparkAddress(payload: SparkAddressData): SparkAddressFormat;
73
+ declare function decodeSparkAddress(address: string, network: NetworkType): DecodedSparkAddressData;
74
+ declare function isValidSparkAddress(address: string): boolean;
75
+ declare function isValidPublicKey(publicKey: string): void;
76
+
77
+ type HumanReadableTokenIdentifier = `btk1${string}` | `btkrt1${string}` | `btkt1${string}` | `btks1${string}` | `btkl1${string}`;
78
+ interface HumanReadableTokenIdentifierData {
79
+ tokenIdentifier: Uint8Array;
80
+ network: NetworkType;
81
+ }
82
+ declare function encodeHumanReadableTokenIdentifier(payload: HumanReadableTokenIdentifierData): HumanReadableTokenIdentifier;
83
+ declare function decodeHumanReadableTokenIdentifier(humanReadableTokenIdentifier: HumanReadableTokenIdentifier, network: NetworkType): HumanReadableTokenIdentifierData;
84
+
85
+ type SigningOperator = {
86
+ readonly id: number;
87
+ readonly identifier: string;
88
+ readonly address: string;
89
+ readonly identityPublicKey: string;
90
+ };
91
+ type ConfigOptions = MayHaveLrc20WalletApiConfig & MayHaveSspClientOptions & {
92
+ readonly network?: NetworkType;
93
+ readonly signingOperators?: Readonly<Record<string, SigningOperator>>;
94
+ readonly coodinatorIdentifier?: string;
95
+ readonly frostSignerAddress?: string;
96
+ readonly lrc20Address?: string;
97
+ readonly threshold?: number;
98
+ readonly tokenSignatures?: "ECDSA" | "SCHNORR";
99
+ readonly tokenValidityDurationSeconds?: number;
100
+ readonly tokenTransactionVersion?: "V0" | "V1";
101
+ readonly electrsUrl?: string;
102
+ readonly lrc20ApiConfig?: LRC20WalletApiConfig;
103
+ readonly sspClientOptions?: SspClientOptions;
104
+ readonly expectedWithdrawBondSats?: number;
105
+ readonly expectedWithdrawRelativeBlockLocktime?: number;
106
+ };
107
+ declare const WalletConfig: {
108
+ LOCAL: Required<ConfigOptions>;
109
+ LOCAL_SCHNORR: Required<ConfigOptions>;
110
+ LOCAL_ECDSA: Required<ConfigOptions>;
111
+ REGTEST: Required<ConfigOptions>;
112
+ MAINNET: Required<ConfigOptions>;
113
+ };
114
+
115
+ type CreateLightningInvoiceParams = {
116
+ amountSats: number;
117
+ memo?: string;
118
+ expirySeconds?: number;
119
+ includeSparkAddress?: boolean;
120
+ receiverIdentityPubkey?: string;
121
+ descriptionHash?: string;
122
+ };
123
+ type PayLightningInvoiceParams = {
124
+ invoice: string;
125
+ maxFeeSats: number;
126
+ preferSpark?: boolean;
127
+ amountSatsToSend?: number;
128
+ };
129
+ type TransferParams = {
130
+ amountSats: number;
131
+ receiverSparkAddress: string;
132
+ };
133
+ type DepositParams = {
134
+ signingPubKey: Uint8Array;
135
+ verifyingKey: Uint8Array;
136
+ depositTx: Transaction;
137
+ vout: number;
138
+ };
139
+ /**
140
+ * Token metadata containing essential information about a token.
141
+ * This is the wallet's internal representation with JavaScript-friendly types.
142
+ *
143
+ * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human readable token identifier.
144
+ *
145
+ * tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * const tokenMetadata: UserTokenMetadata = {
150
+ * rawTokenIdentifier: new Uint8Array([1, 2, 3]),
151
+ * tokenPublicKey: "0348fbb...",
152
+ * tokenName: "SparkToken",
153
+ * tokenTicker: "SPK",
154
+ * decimals: 8,
155
+ * maxSupply: 1000000n
156
+ * };
157
+ * ```
158
+ */
159
+ type UserTokenMetadata = {
160
+ /** Raw binary token identifier - This is used to encode the human readable token identifier */
161
+ rawTokenIdentifier: Uint8Array;
162
+ /** Public key of the token issuer - Same as issuerPublicKey */
163
+ tokenPublicKey: string;
164
+ /** Human-readable name of the token (e.g., SparkToken)*/
165
+ tokenName: string;
166
+ /** Short ticker symbol for the token (e.g., "SPK") */
167
+ tokenTicker: string;
168
+ /** Number of decimal places for token amounts */
169
+ decimals: number;
170
+ /** Maximum supply of tokens that can ever be minted */
171
+ maxSupply: bigint;
172
+ };
173
+ type TokenBalanceMap = Map<HumanReadableTokenIdentifier, {
174
+ balance: bigint;
175
+ tokenMetadata: UserTokenMetadata;
176
+ }>;
177
+ type InitWalletResponse = {
178
+ mnemonic?: string | undefined;
179
+ };
180
+ interface SparkWalletProps {
181
+ mnemonicOrSeed?: Uint8Array | string;
182
+ accountNumber?: number;
183
+ signer?: SparkSigner;
184
+ options?: ConfigOptions;
185
+ }
186
+ interface SparkWalletEvents {
187
+ /** Emitted when an incoming transfer is successfully claimed. Includes the transfer ID and new total balance. */
188
+ "transfer:claimed": (transferId: string, updatedBalance: number) => void;
189
+ /** Emitted when a deposit is marked as available. Includes the deposit ID and new total balance. */
190
+ "deposit:confirmed": (depositId: string, updatedBalance: number) => void;
191
+ /** Emitted when the stream is connected */
192
+ "stream:connected": () => void;
193
+ /** Emitted when the stream disconnects and fails to reconnect after max attempts */
194
+ "stream:disconnected": (reason: string) => void;
195
+ /** Emitted when attempting to reconnect the stream */
196
+ "stream:reconnecting": (attempt: number, maxAttempts: number, delayMs: number, error: string) => void;
197
+ }
198
+
199
+ declare class WalletConfigService implements HasLrc20WalletApiConfig, HasSspClientOptions {
200
+ private readonly config;
201
+ readonly signer: SparkSigner;
202
+ readonly lrc20ApiConfig: LRC20WalletApiConfig;
203
+ readonly sspClientOptions: SspClientOptions;
204
+ constructor(options?: ConfigOptions, signer?: SparkSigner);
205
+ private getDefaultConfig;
206
+ getCoordinatorAddress(): string;
207
+ getLrc20Address(): string;
208
+ getSigningOperators(): Readonly<Record<string, SigningOperator>>;
209
+ getThreshold(): number;
210
+ getCoordinatorIdentifier(): string;
211
+ getExpectedWithdrawBondSats(): number;
212
+ getExpectedWithdrawRelativeBlockLocktime(): number;
213
+ getSspNetwork(): BitcoinNetwork;
214
+ getNetwork(): Network;
215
+ getNetworkType(): NetworkType;
216
+ getNetworkProto(): number;
217
+ getTokenSignatures(): "ECDSA" | "SCHNORR";
218
+ getTokenTransactionVersion(): "V0" | "V1";
219
+ getTokenValidityDurationSeconds(): number;
220
+ getElectrsUrl(): string;
221
+ getSspIdentityPublicKey(): string;
222
+ }
223
+
224
+ declare enum InterruptTransferRequest_InterruptTransferAction {
225
+ NONE = 0,
226
+ INTERRUPT = 1,
227
+ RESUME = 2,
228
+ UNRECOGNIZED = -1
229
+ }
230
+ interface CleanUpPreimageShareRequest {
231
+ paymentHash: Uint8Array;
232
+ }
233
+ declare const CleanUpPreimageShareRequest: MessageFns<CleanUpPreimageShareRequest>;
234
+ interface InterruptTransferRequest {
235
+ action: InterruptTransferRequest_InterruptTransferAction;
236
+ }
237
+ declare const InterruptTransferRequest: MessageFns<InterruptTransferRequest>;
238
+ interface UpdateNodesStatusRequest {
239
+ nodeIds: string[];
240
+ status: string;
241
+ }
242
+ declare const UpdateNodesStatusRequest: MessageFns<UpdateNodesStatusRequest>;
243
+ interface MockServiceClient<CallOptionsExt = {}> {
244
+ clean_up_preimage_share(request: DeepPartial<CleanUpPreimageShareRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
245
+ interrupt_transfer(request: DeepPartial<InterruptTransferRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
246
+ update_nodes_status(request: DeepPartial<UpdateNodesStatusRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
247
+ }
248
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
249
+ type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
250
+ $case: string;
251
+ } ? {
252
+ [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]>;
253
+ } & {
254
+ $case: T["$case"];
255
+ } : T extends {} ? {
256
+ [K in keyof T]?: DeepPartial<T[K]>;
257
+ } : Partial<T>;
258
+ interface MessageFns<T> {
259
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
260
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
261
+ fromJSON(object: any): T;
262
+ toJSON(message: T): unknown;
263
+ create(base?: DeepPartial<T>): T;
264
+ fromPartial(object: DeepPartial<T>): T;
265
+ }
266
+
267
+ declare class ConnectionManager {
268
+ private config;
269
+ private clients;
270
+ private tokenClients;
271
+ private streamClients;
272
+ private authPromises;
273
+ constructor(config: WalletConfigService);
274
+ createClients(): Promise<void>;
275
+ closeConnections(): Promise<void>;
276
+ createMockClient(address: string): Promise<MockServiceClient & {
277
+ close: () => void;
278
+ }>;
279
+ private createChannelWithTLS;
280
+ createSparkStreamClient(address: string, certPath?: string): Promise<SparkServiceClient & {
281
+ close?: () => void;
282
+ }>;
283
+ createSparkClient(address: string, certPath?: string): Promise<SparkServiceClient & {
284
+ close?: () => void;
285
+ }>;
286
+ createSparkTokenClient(address: string, certPath?: string): Promise<SparkTokenServiceClient & {
287
+ close?: () => void;
288
+ }>;
289
+ getStreamChannel(address: string): Promise<Channel | Channel$1 | undefined>;
290
+ private authenticate;
291
+ private createSparkAuthnGrpcConnection;
292
+ private createAuthnMiddleware;
293
+ private createMiddleware;
294
+ private handleMiddlewareError;
295
+ private createNodeMiddleware;
296
+ private createBrowserMiddleware;
297
+ private createGrpcClient;
298
+ }
299
+
300
+ declare class SigningService {
301
+ private readonly config;
302
+ constructor(config: WalletConfigService);
303
+ signRefunds(leaves: LeafKeyTweak[], signingCommitments: RequestedSigningCommitments[], receiverIdentityPubkey: Uint8Array): Promise<UserSignedTxSigningJob[]>;
304
+ }
305
+
306
+ type LeafKeyTweak = {
307
+ leaf: TreeNode;
308
+ signingPubKey: Uint8Array;
309
+ newSigningPubKey: Uint8Array;
310
+ };
311
+ type ClaimLeafData = {
312
+ signingPubKey: Uint8Array;
313
+ tx?: Transaction;
314
+ refundTx?: Transaction;
315
+ signingNonceCommitment: SigningCommitment;
316
+ vout?: number;
317
+ };
318
+ type LeafRefundSigningData = {
319
+ signingPubKey: Uint8Array;
320
+ receivingPubkey: Uint8Array;
321
+ tx: Transaction;
322
+ refundTx?: Transaction;
323
+ signingNonceCommitment: SigningCommitment;
324
+ vout: number;
325
+ };
326
+ declare class BaseTransferService {
327
+ protected readonly config: WalletConfigService;
328
+ protected readonly connectionManager: ConnectionManager;
329
+ protected readonly signingService: SigningService;
330
+ constructor(config: WalletConfigService, connectionManager: ConnectionManager, signingService: SigningService);
331
+ sendTransferTweakKey(transfer: Transfer, leaves: LeafKeyTweak[], refundSignatureMap: Map<string, Uint8Array>): Promise<Transfer>;
332
+ deliverTransferPackage(transfer: Transfer, leaves: LeafKeyTweak[], refundSignatureMap: Map<string, Uint8Array>): Promise<Transfer>;
333
+ sendTransferWithKeyTweaks(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array): Promise<Transfer>;
334
+ private prepareTransferPackage;
335
+ private finalizeTransfer;
336
+ signRefunds(leafDataMap: Map<string, ClaimLeafData>, operatorSigningResults: LeafRefundTxSigningResult[], adaptorPubKey?: Uint8Array): Promise<NodeSignatures[]>;
337
+ private prepareSendTransferKeyTweaks;
338
+ private prepareSingleSendTransferKeyTweak;
339
+ protected findShare(shares: VerifiableSecretShare[], operatorID: number): VerifiableSecretShare | undefined;
340
+ private compareTransfers;
341
+ }
342
+ declare class TransferService extends BaseTransferService {
343
+ constructor(config: WalletConfigService, connectionManager: ConnectionManager, signingService: SigningService);
344
+ /**
345
+ * @deprecated Use sendTransferWithKeyTweaks instead
346
+ * Deprecated in v0.1.32
347
+ */
348
+ sendTransfer(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array): Promise<Transfer>;
349
+ claimTransfer(transfer: Transfer, leaves: LeafKeyTweak[]): Promise<FinalizeNodeSignaturesResponse>;
350
+ queryPendingTransfers(): Promise<QueryTransfersResponse>;
351
+ queryAllTransfers(limit: number, offset: number): Promise<QueryTransfersResponse>;
352
+ verifyPendingTransfer(transfer: Transfer): Promise<Map<string, Uint8Array>>;
353
+ queryTransfer(transferId: string): Promise<Transfer | undefined>;
354
+ sendTransferSignRefund(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date): Promise<{
355
+ transfer: Transfer;
356
+ signatureMap: Map<string, Uint8Array>;
357
+ leafDataMap: Map<string, LeafRefundSigningData>;
358
+ }>;
359
+ startSwapSignRefund(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date): Promise<{
360
+ transfer: Transfer;
361
+ signatureMap: Map<string, Uint8Array>;
362
+ leafDataMap: Map<string, LeafRefundSigningData>;
363
+ }>;
364
+ counterSwapSignRefund(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date, adaptorPubKey?: Uint8Array): Promise<{
365
+ transfer: Transfer;
366
+ signatureMap: Map<string, Uint8Array>;
367
+ leafDataMap: Map<string, LeafRefundSigningData>;
368
+ signingResults: LeafRefundTxSigningResult[];
369
+ }>;
370
+ sendTransferSignRefundInternal(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date, forSwap: boolean, adaptorPubKey?: Uint8Array): Promise<{
371
+ transfer: Transfer;
372
+ signatureMap: Map<string, Uint8Array>;
373
+ leafDataMap: Map<string, LeafRefundSigningData>;
374
+ signingResults: LeafRefundTxSigningResult[];
375
+ }>;
376
+ private prepareRefundSoSigningJobs;
377
+ claimTransferTweakKeys(transfer: Transfer, leaves: LeafKeyTweak[]): Promise<Map<string, Uint8Array[]>>;
378
+ private prepareClaimLeavesKeyTweaks;
379
+ private prepareClaimLeafKeyTweaks;
380
+ claimTransferSignRefunds(transfer: Transfer, leafKeys: LeafKeyTweak[], proofMap?: Map<string, Uint8Array[]>): Promise<NodeSignatures[]>;
381
+ private finalizeNodeSignatures;
382
+ cancelTransfer(transfer: Transfer, operatorAddress: string): Promise<Transfer | undefined>;
383
+ queryPendingTransfersBySender(operatorAddress: string): Promise<QueryTransfersResponse>;
384
+ refreshTimelockNodes(nodes: TreeNode[], parentNode: TreeNode, signingPubKey: Uint8Array): Promise<FinalizeNodeSignaturesResponse>;
385
+ extendTimelock(node: TreeNode, signingPubKey: Uint8Array): Promise<FinalizeNodeSignaturesResponse>;
386
+ refreshTimelockRefundTx(node: TreeNode, signingPubKey: Uint8Array): Promise<FinalizeNodeSignaturesResponse>;
387
+ }
388
+
389
+ /**
390
+ * The SparkWallet class is the primary interface for interacting with the Spark network.
391
+ * It provides methods for creating and managing wallets, handling deposits, executing transfers,
392
+ * and interacting with the Lightning Network.
393
+ */
394
+ declare class SparkWallet extends EventEmitter {
395
+ protected config: WalletConfigService;
396
+ protected connectionManager: ConnectionManager;
397
+ protected lrc20Wallet: LRCWallet | undefined;
398
+ protected transferService: TransferService;
399
+ protected tracerId: string;
400
+ private depositService;
401
+ private treeCreationService;
402
+ private lightningService;
403
+ private coopExitService;
404
+ private signingService;
405
+ private tokenTransactionService;
406
+ private claimTransferMutex;
407
+ private leavesMutex;
408
+ private optimizationInProgress;
409
+ private sspClient;
410
+ private mutexes;
411
+ private pendingWithdrawnOutputIds;
412
+ private sparkAddress;
413
+ private streamController;
414
+ protected leaves: TreeNode[];
415
+ protected tokenOutputs: Map<string, OutputWithPreviousTransactionData[]>;
416
+ protected tokenMetadata: Map<string, TokenMetadata>;
417
+ private claimTransfersInterval;
418
+ protected wrapWithOtelSpan<T>(name: string, fn: (...args: any[]) => Promise<T>): (...args: any[]) => Promise<T>;
419
+ protected constructor(options?: ConfigOptions, signer?: SparkSigner);
420
+ static initialize({ mnemonicOrSeed, accountNumber, signer, options, }: SparkWalletProps): Promise<{
421
+ mnemonic?: string | undefined;
422
+ wallet: SparkWallet;
423
+ }>;
424
+ private initializeWallet;
425
+ private getSspClient;
426
+ private handleStreamEvent;
427
+ protected setupBackgroundStream(): Promise<void>;
428
+ getLeaves(isBalanceCheck?: boolean): Promise<TreeNode[]>;
429
+ private selectLeaves;
430
+ private selectLeavesForSwap;
431
+ private areLeavesInefficient;
432
+ private optimizeLeaves;
433
+ private syncWallet;
434
+ private withLeaves;
435
+ /**
436
+ * Gets the identity public key of the wallet.
437
+ *
438
+ * @returns {Promise<string>} The identity public key as a hex string.
439
+ */
440
+ getIdentityPublicKey(): Promise<string>;
441
+ /**
442
+ * Gets the Spark address of the wallet.
443
+ *
444
+ * @returns {Promise<string>} The Spark address as a hex string.
445
+ */
446
+ getSparkAddress(): Promise<SparkAddressFormat>;
447
+ createSparkPaymentIntent(assetIdentifier?: string, assetAmount?: bigint, memo?: string): Promise<SparkAddressFormat>;
448
+ /**
449
+ * Initializes the wallet using either a mnemonic phrase or a raw seed.
450
+ * initWallet will also claim any pending incoming lightning payment, spark transfer,
451
+ * or bitcoin deposit.
452
+ *
453
+ * @param {Uint8Array | string} [mnemonicOrSeed] - (Optional) Either:
454
+ * - A BIP-39 mnemonic phrase as string
455
+ * - A raw seed as Uint8Array or hex string
456
+ * If not provided, generates a new mnemonic and uses it to create a new wallet
457
+ *
458
+ * @param {number} [accountNumber] - (Optional) The account number to use for the wallet. Defaults to 1 to maintain backwards compatability for legacy mainnet wallets.
459
+ *
460
+ * @returns {Promise<Object>} Object containing:
461
+ * - mnemonic: The mnemonic if one was generated (undefined for raw seed)
462
+ * - balance: The wallet's initial balance in satoshis
463
+ * - tokenBalance: Map of token balances
464
+ * @private
465
+ */
466
+ protected initWallet(mnemonicOrSeed?: Uint8Array | string, accountNumber?: number): Promise<InitWalletResponse | undefined>;
467
+ /**
468
+ * Initializes a wallet from a seed.
469
+ *
470
+ * @param {Uint8Array | string} seed - The seed to initialize the wallet from
471
+ * @returns {Promise<string>} The identity public key
472
+ * @private
473
+ */
474
+ private initWalletFromSeed;
475
+ /**
476
+ * Gets the estimated fee for a swap of leaves.
477
+ *
478
+ * @param amountSats - The amount of sats to swap
479
+ * @returns {Promise<LeavesSwapFeeEstimateOutput>} The estimated fee for the swap
480
+ */
481
+ getSwapFeeEstimate(amountSats: number): Promise<LeavesSwapFeeEstimateOutput>;
482
+ /**
483
+ * Requests a swap of leaves to optimize wallet structure.
484
+ *
485
+ * @param {Object} params - Parameters for the leaves swap
486
+ * @param {number} [params.targetAmount] - Target amount for the swap
487
+ * @param {TreeNode[]} [params.leaves] - Specific leaves to swap
488
+ * @returns {Promise<Object>} The completed swap response
489
+ * @private
490
+ */
491
+ private requestLeavesSwap;
492
+ /**
493
+ * Processes a single batch of leaves for swapping.
494
+ */
495
+ private processSwapBatch;
496
+ /**
497
+ * Gets all transfers for the wallet.
498
+ *
499
+ * @param {number} [limit=20] - Maximum number of transfers to return
500
+ * @param {number} [offset=0] - Offset for pagination
501
+ * @returns {Promise<QueryTransfersResponse>} Response containing the list of transfers
502
+ */
503
+ getTransfers(limit?: number, offset?: number): Promise<{
504
+ transfers: WalletTransfer[];
505
+ offset: number;
506
+ }>;
507
+ /**
508
+ * Gets the current balance of the wallet.
509
+ * You can use the forceRefetch option to synchronize your wallet and claim any
510
+ * pending incoming lightning payment, spark transfer, or bitcoin deposit before returning the balance.
511
+ *
512
+ * @returns {Promise<Object>} Object containing:
513
+ * - balance: The wallet's current balance in satoshis
514
+ * - tokenBalances: Map of the human readable token identifier to token balances and token info
515
+ */
516
+ getBalance(): Promise<{
517
+ balance: bigint;
518
+ tokenBalances: TokenBalanceMap;
519
+ }>;
520
+ private getTokenMetadata;
521
+ private getTokenBalance;
522
+ private getInternalBalance;
523
+ /**
524
+ * Generates a new deposit address for receiving bitcoin funds.
525
+ * Note that this function returns a bitcoin address, not a spark address, and this address is single use.
526
+ * Once you deposit funds to this address, it cannot be used again.
527
+ * For Layer 1 Bitcoin deposits, Spark generates Pay to Taproot (P2TR) addresses.
528
+ * These addresses start with "bc1p" and can be used to receive Bitcoin from any wallet.
529
+ *
530
+ * @returns {Promise<string>} A Bitcoin address for depositing funds
531
+ */
532
+ getSingleUseDepositAddress(): Promise<string>;
533
+ /**
534
+ * Generates a new static deposit address for receiving bitcoin funds.
535
+ * This address is permanent and can be used multiple times.
536
+ *
537
+ * @returns {Promise<string>} A Bitcoin address for depositing funds
538
+ */
539
+ getStaticDepositAddress(): Promise<string>;
540
+ /**
541
+ * Generates a deposit address for receiving funds.
542
+ *
543
+ * @param {boolean} static - Whether the address is static or single use
544
+ * @returns {Promise<string>} A deposit address
545
+ * @private
546
+ */
547
+ private generateDepositAddress;
548
+ queryStaticDepositAddresses(): Promise<string[]>;
549
+ /**
550
+ * Get a quote on how much credit you can claim for a deposit from the SSP.
551
+ *
552
+ * @param {string} transactionId - The ID of the transaction
553
+ * @param {number} [outputIndex] - The index of the output
554
+ * @returns {Promise<StaticDepositQuoteOutput>} Quote for claiming a deposit to a static deposit address
555
+ */
556
+ getClaimStaticDepositQuote(transactionId: string, outputIndex?: number): Promise<StaticDepositQuoteOutput>;
557
+ /**
558
+ * Claims a deposit to a static deposit address.
559
+ *
560
+ * @param {string} transactionId - The ID of the transaction
561
+ * @param {number} creditAmountSats - The amount of credit to claim
562
+ * @param {string} sspSignature - The SSP signature for the deposit
563
+ * @param {number} [outputIndex] - The index of the output
564
+ * @returns {Promise<RequestClaimDepositQuoteOutput | null>} Quote for claiming a deposit to a static deposit address
565
+ */
566
+ claimStaticDeposit({ transactionId, creditAmountSats, sspSignature, outputIndex, }: {
567
+ transactionId: string;
568
+ creditAmountSats: number;
569
+ sspSignature: string;
570
+ outputIndex?: number;
571
+ }): Promise<ClaimStaticDepositOutput | null>;
572
+ /**
573
+ * Refunds a static deposit to a destination address.
574
+ *
575
+ * @param {string} depositTransactionId - The ID of the transaction
576
+ * @param {number} [outputIndex] - The index of the output
577
+ * @param {string} destinationAddress - The destination address
578
+ * @param {number} fee - The fee to refund
579
+ * @returns {Promise<string>} The hex of the refund transaction
580
+ */
581
+ refundStaticDeposit({ depositTransactionId, outputIndex, destinationAddress, fee, }: {
582
+ depositTransactionId: string;
583
+ outputIndex?: number;
584
+ destinationAddress: string;
585
+ fee: number;
586
+ }): Promise<string>;
587
+ private getStaticDepositSigningPayload;
588
+ private getDepositTransactionVout;
589
+ private getDepositTransaction;
590
+ /**
591
+ * Finalizes a deposit to the wallet.
592
+ *
593
+ * @param {DepositParams} params - Parameters for finalizing the deposit
594
+ * @returns {Promise<void>} The nodes created from the deposit
595
+ * @private
596
+ */
597
+ private finalizeDeposit;
598
+ /**
599
+ * Gets all unused deposit addresses for the wallet.
600
+ *
601
+ * @returns {Promise<string[]>} The unused deposit addresses
602
+ */
603
+ getUnusedDepositAddresses(): Promise<string[]>;
604
+ /**
605
+ * Gets all unused deposit addresses for the wallet.
606
+ *
607
+ * @param {Object} params - Parameters for querying unused deposit addresses
608
+ * @param {Uint8Array<ArrayBufferLike>} [params.identityPublicKey] - The identity public key
609
+ * @param {NetworkProto} [params.network] - The network
610
+ * @returns {Promise<DepositAddressQueryResult[]>} The unused deposit addresses
611
+ */
612
+ private queryAllUnusedDepositAddresses;
613
+ /**
614
+ * Claims a deposit to the wallet.
615
+ * Note that if you used advancedDeposit, you don't need to call this function.
616
+ * @param {string} txid - The transaction ID of the deposit
617
+ * @returns {Promise<WalletLeaf[] | undefined>} The nodes resulting from the deposit
618
+ */
619
+ claimDeposit(txid: string): Promise<WalletLeaf[]>;
620
+ /**
621
+ * Non-trusty flow for depositing funds to the wallet.
622
+ * Construct the tx spending from an L1 wallet to the Spark address.
623
+ * After calling this function, you must sign and broadcast the tx.
624
+ *
625
+ * @param {string} txHex - The hex string of the transaction to deposit
626
+ * @returns {Promise<TreeNode[] | undefined>} The nodes resulting from the deposit
627
+ */
628
+ advancedDeposit(txHex: string): Promise<TreeNode[]>;
629
+ /**
630
+ * Transfers deposit to self to claim ownership.
631
+ *
632
+ * @param {TreeNode[]} leaves - The leaves to transfer
633
+ * @param {Uint8Array} signingPubKey - The signing public key
634
+ * @returns {Promise<TreeNode[] | undefined>} The nodes resulting from the transfer
635
+ * @private
636
+ */
637
+ private transferLeavesToSelf;
638
+ /**
639
+ * Sends a transfer to another Spark user.
640
+ *
641
+ * @param {TransferParams} params - Parameters for the transfer
642
+ * @param {string} params.receiverSparkAddress - The recipient's Spark address
643
+ * @param {number} params.amountSats - Amount to send in satoshis
644
+ * @returns {Promise<WalletTransfer>} The completed transfer details
645
+ */
646
+ transfer({ amountSats, receiverSparkAddress, }: TransferParams): Promise<WalletTransfer>;
647
+ private checkExtendTimeLockNodes;
648
+ /**
649
+ * Internal method to refresh timelock nodes.
650
+ *
651
+ * @param {string} nodeId - The optional ID of the node to refresh. If not provided, all nodes will be checked.
652
+ * @returns {Promise<void>}
653
+ * @private
654
+ */
655
+ private checkRefreshTimelockNodes;
656
+ /**
657
+ * Claims a specific transfer.
658
+ *
659
+ * @param {Transfer} transfer - The transfer to claim
660
+ * @returns {Promise<Object>} The claim result
661
+ */
662
+ private claimTransfer;
663
+ /**
664
+ * Claims all pending transfers.
665
+ *
666
+ * @returns {Promise<string[]>} Array of successfully claimed transfer IDs
667
+ * @private
668
+ */
669
+ private claimTransfers;
670
+ /**
671
+ * Cancels all sender-initiated transfers.
672
+ *
673
+ * @returns {Promise<void>}
674
+ * @private
675
+ */
676
+ private cancelAllSenderInitiatedTransfers;
677
+ /**
678
+ * Creates a Lightning invoice for receiving payments.
679
+ *
680
+ * @param {Object} params - Parameters for the lightning invoice
681
+ * @param {number} params.amountSats - Amount in satoshis
682
+ * @param {string} [params.memo] - Description for the invoice. Should not be provided if the descriptionHash is provided.
683
+ * @param {number} [params.expirySeconds] - Optional expiry time in seconds
684
+ * @param {boolean} [params.includeSparkAddress] - Optional boolean signalling whether or not to include the spark address in the invoice
685
+ * @param {string} [params.receiverIdentityPubkey] - Optional public key of the wallet receiving the lightning invoice. If not present, the receiver will be the creator of this request.
686
+ * @param {string} [params.descriptionHash] - Optional h tag of the invoice. This is the hash of a longer description to include in the lightning invoice. It is used in LNURL and UMA as the hash of the metadata. This field is mutually exclusive with the memo field. Only one or the other should be provided.
687
+ * @returns {Promise<LightningReceiveRequest>} BOLT11 encoded invoice
688
+ */
689
+ createLightningInvoice({ amountSats, memo, expirySeconds, includeSparkAddress, receiverIdentityPubkey, descriptionHash, }: CreateLightningInvoiceParams): Promise<LightningReceiveRequest>;
690
+ /**
691
+ * Pays a Lightning invoice.
692
+ *
693
+ * @param {Object} params - Parameters for paying the invoice
694
+ * @param {string} params.invoice - The BOLT11-encoded Lightning invoice to pay
695
+ * @param {boolean} [params.preferSpark] - Whether to prefer a spark transfer over lightning for the payment
696
+ * @param {number} [params.amountSatsToSend] - The amount in sats to send. This is only valid for 0 amount lightning invoices.
697
+ * @returns {Promise<LightningSendRequest>} The Lightning payment request details
698
+ */
699
+ payLightningInvoice({ invoice, maxFeeSats, preferSpark, amountSatsToSend, }: PayLightningInvoiceParams): Promise<LightningSendRequest | WalletTransfer>;
700
+ /**
701
+ * Gets fee estimate for sending Lightning payments.
702
+ *
703
+ * @param {LightningSendFeeEstimateInput} params - Input parameters for fee estimation
704
+ * @returns {Promise<number>} Fee estimate for sending Lightning payments
705
+ */
706
+ getLightningSendFeeEstimate({ encodedInvoice, amountSats, }: LightningSendFeeEstimateInput): Promise<number>;
707
+ /**
708
+ * Generates a deposit address for a tree.
709
+ *
710
+ * @param {number} vout - The vout index
711
+ * @param {Uint8Array} parentSigningPubKey - The parent signing public key
712
+ * @param {Transaction} [parentTx] - Optional parent transaction
713
+ * @param {TreeNode} [parentNode] - Optional parent node
714
+ * @returns {Promise<Object>} Deposit address information
715
+ * @private
716
+ */
717
+ private generateDepositAddressForTree;
718
+ /**
719
+ * Creates a tree structure.
720
+ *
721
+ * @param {number} vout - The vout index
722
+ * @param {DepositAddressTree} root - The root of the tree
723
+ * @param {boolean} createLeaves - Whether to create leaves
724
+ * @param {Transaction} [parentTx] - Optional parent transaction
725
+ * @param {TreeNode} [parentNode] - Optional parent node
726
+ * @returns {Promise<Object>} The created tree
727
+ * @private
728
+ */
729
+ private createTree;
730
+ /**
731
+ * Initiates a withdrawal to move funds from the Spark network to an on-chain Bitcoin address.
732
+ *
733
+ * @param {Object} params - Parameters for the withdrawal
734
+ * @param {string} params.onchainAddress - The Bitcoin address where the funds should be sent
735
+ * @param {CoopExitFeeQuote} params.feeQuote - The fee quote for the withdrawal
736
+ * @param {ExitSpeed} params.exitSpeed - The exit speed chosen for the withdrawal
737
+ * @param {number} [params.amountSats] - The amount in satoshis to withdraw. If not specified, attempts to withdraw all available funds and deductFeeFromWithdrawalAmount is set to true.
738
+ * @param {boolean} [params.deductFeeFromWithdrawalAmount] - Controls how the withdrawal fee is handled. If true, the fee is deducted from the withdrawal amount (amountSats), meaning the recipient will receive amountSats minus the fee. If false, the fee is paid separately from the wallet balance, meaning the recipient will receive the full amountSats.
739
+ * @returns {Promise<CoopExitRequest | null | undefined>} The withdrawal request details, or null/undefined if the request cannot be completed
740
+ */
741
+ withdraw({ onchainAddress, exitSpeed, feeQuote, amountSats, deductFeeFromWithdrawalAmount, }: {
742
+ onchainAddress: string;
743
+ exitSpeed: ExitSpeed;
744
+ feeQuote: CoopExitFeeQuote;
745
+ amountSats?: number;
746
+ deductFeeFromWithdrawalAmount?: boolean;
747
+ }): Promise<CoopExitRequest | null>;
748
+ /**
749
+ * Internal method to perform a cooperative exit (withdrawal).
750
+ *
751
+ * @param {string} onchainAddress - The Bitcoin address where the funds should be sent
752
+ * @param {number} [targetAmountSats] - The amount in satoshis to withdraw
753
+ * @returns {Promise<Object | null | undefined>} The exit request details
754
+ * @private
755
+ */
756
+ private coopExit;
757
+ /**
758
+ * Gets fee estimate for cooperative exit (on-chain withdrawal).
759
+ *
760
+ * @param {Object} params - Input parameters for fee estimation
761
+ * @param {number} params.amountSats - The amount in satoshis to withdraw
762
+ * @param {string} params.withdrawalAddress - The Bitcoin address where the funds should be sent
763
+ * @returns {Promise<CoopExitFeeQuote | null>} Fee estimate for the withdrawal
764
+ */
765
+ getWithdrawalFeeQuote({ amountSats, withdrawalAddress, }: {
766
+ amountSats: number;
767
+ withdrawalAddress: string;
768
+ }): Promise<CoopExitFeeQuote | null>;
769
+ /**
770
+ * Gets a transfer that has been sent by the SSP to the wallet.
771
+ *
772
+ * @param {string} id - The ID of the transfer
773
+ * @returns {Promise<GraphQLTransferObj | null>} The transfer
774
+ */
775
+ getTransferFromSsp(id: string): Promise<Transfer$1 | null>;
776
+ /**
777
+ * Gets a transfer, that the wallet is a participant of, in the Spark network.
778
+ * Only contains data about the spark->spark transfer, use getTransferFromSsp if you're
779
+ * looking for information related to a lightning transfer.
780
+ *
781
+ * @param {string} id - The ID of the transfer
782
+ * @returns {Promise<Transfer | undefined>} The transfer
783
+ */
784
+ getTransfer(id: string): Promise<WalletTransfer | undefined>;
785
+ /**
786
+ * Synchronizes token outputs for the wallet.
787
+ *
788
+ * @returns {Promise<void>}
789
+ * @private
790
+ */
791
+ protected syncTokenOutputs(): Promise<void>;
792
+ /**
793
+ * Transfers tokens to another user.
794
+ *
795
+ * @param {Object} params - Parameters for the token transfer
796
+ * @param {string} params.tokenPublicKey - The public key of the token to transfer
797
+ * @param {bigint} params.tokenAmount - The amount of tokens to transfer
798
+ * @param {string} params.receiverSparkAddress - The recipient's public key
799
+ * @param {OutputWithPreviousTransactionData[]} [params.selectedOutputs] - Optional specific leaves to use for the transfer
800
+ * @returns {Promise<string>} The transaction ID of the token transfer
801
+ */
802
+ transferTokens({ tokenPublicKey, tokenAmount, receiverSparkAddress, outputSelectionStrategy, selectedOutputs, }: {
803
+ tokenPublicKey: string;
804
+ tokenAmount: bigint;
805
+ receiverSparkAddress: string;
806
+ outputSelectionStrategy?: "SMALL_FIRST" | "LARGE_FIRST";
807
+ selectedOutputs?: OutputWithPreviousTransactionData[];
808
+ }): Promise<string>;
809
+ /**
810
+ * Transfers tokens with multiple outputs
811
+ *
812
+ * @param {Array} receiverOutputs - Array of transfer parameters
813
+ * @param {string} receiverOutputs[].tokenPublicKey - The public key of the token to transfer
814
+ * @param {bigint} receiverOutputs[].tokenAmount - The amount of tokens to transfer
815
+ * @param {string} receiverOutputs[].receiverSparkAddress - The recipient's public key
816
+ * @param {OutputWithPreviousTransactionData[]} [selectedOutputs] - Optional specific leaves to use for the transfer
817
+ * @returns {Promise<string[]>} Array of transaction IDs for the token transfers
818
+ */
819
+ batchTransferTokens(receiverOutputs: {
820
+ tokenPublicKey: string;
821
+ tokenAmount: bigint;
822
+ receiverSparkAddress: string;
823
+ }[], outputSelectionStrategy?: "SMALL_FIRST" | "LARGE_FIRST", selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
824
+ /**
825
+ * Retrieves token transaction history for specified tokens
826
+ * Can optionally filter by specific transaction hashes.
827
+ *
828
+ * @param ownerPublicKeys - Optional array of owner public keys to query transactions for
829
+ * @param issuerPublicKeys - Optional array of issuer public keys to query transactions for
830
+ * @param tokenTransactionHashes - Optional array of specific transaction hashes to filter by
831
+ * @param tokenIdentifiers - Optional array of token identifiers to filter by
832
+ * @param outputIds - Optional array of output IDs to filter by
833
+ * @returns Promise resolving to array of token transactions with their current status
834
+ */
835
+ queryTokenTransactions({ ownerPublicKeys, issuerPublicKeys, tokenTransactionHashes, tokenIdentifiers, outputIds, }: {
836
+ ownerPublicKeys?: string[];
837
+ issuerPublicKeys?: string[];
838
+ tokenTransactionHashes?: string[];
839
+ tokenIdentifiers?: string[];
840
+ outputIds?: string[];
841
+ }): Promise<TokenTransactionWithStatus[]>;
842
+ getTokenL1Address(): Promise<string>;
843
+ /**
844
+ * Signs a message with the identity key.
845
+ *
846
+ * @param {string} message - The message to sign
847
+ * @param {boolean} [compact] - Whether to use compact encoding. If false, the message will be encoded as DER.
848
+ * @returns {Promise<string>} The signed message
849
+ */
850
+ signMessageWithIdentityKey(message: string, compact?: boolean): Promise<string>;
851
+ /**
852
+ * Validates a message with the identity key.
853
+ *
854
+ * @param {string} message - The original message that was signed
855
+ * @param {string | Uint8Array} signature - Signature to validate
856
+ * @returns {Promise<boolean>} Whether the message is valid
857
+ */
858
+ validateMessageWithIdentityKey(message: string, signature: string | Uint8Array): Promise<boolean>;
859
+ /**
860
+ * Signs a transaction with wallet keys.
861
+ *
862
+ * @param {string} txHex - The transaction hex to sign
863
+ * @param {string} keyType - The type of key to use for signing ("identity", "deposit", or "auto-detect")
864
+ * @returns {Promise<string>} The signed transaction hex
865
+ */
866
+ signTransaction(txHex: string, keyType?: string): Promise<string>;
867
+ /**
868
+ * Helper method to auto-detect which key should be used for signing a transaction.
869
+ */
870
+ private detectKeyForTransaction;
871
+ /**
872
+ * Get a Lightning receive request by ID.
873
+ *
874
+ * @param {string} id - The ID of the Lightning receive request
875
+ * @returns {Promise<LightningReceiveRequest | null>} The Lightning receive request
876
+ */
877
+ getLightningReceiveRequest(id: string): Promise<LightningReceiveRequest | null>;
878
+ /**
879
+ * Get a Lightning send request by ID.
880
+ *
881
+ * @param {string} id - The ID of the Lightning send request
882
+ * @returns {Promise<LightningSendRequest | null>} The Lightning send request
883
+ */
884
+ getLightningSendRequest(id: string): Promise<LightningSendRequest | null>;
885
+ /**
886
+ * Get a coop exit request by ID.
887
+ *
888
+ * @param {string} id - The ID of the coop exit request
889
+ * @returns {Promise<CoopExitRequest | null>} The coop exit request
890
+ */
891
+ getCoopExitRequest(id: string): Promise<CoopExitRequest | null>;
892
+ /**
893
+ * Check the remaining timelock on a given node.
894
+ *
895
+ * @param {string} nodeId - The ID of the node to check
896
+ * @returns {Promise<{nodeTimelock: number, refundTimelock: number}>} The remaining timelocks in blocks for both node and refund transactions
897
+ */
898
+ checkTimelock(nodeId: string): Promise<{
899
+ nodeTimelock: number;
900
+ refundTimelock: number;
901
+ }>;
902
+ /**
903
+ * Refresh the timelock of a specific node.
904
+ *
905
+ * @param {string} nodeId - The ID of the node to refresh
906
+ * @returns {Promise<void>} Promise that resolves when the timelock is refreshed
907
+ */
908
+ testOnly_expireTimelock(nodeId: string): Promise<void>;
909
+ /**
910
+ * Refresh the timelock of a specific node's refund transaction only.
911
+ *
912
+ * @param {string} nodeId - The ID of the node whose refund transaction to refresh
913
+ * @returns {Promise<void>} Promise that resolves when the refund timelock is refreshed
914
+ */
915
+ testOnly_expireTimelockRefundTx(nodeId: string): Promise<void>;
916
+ private cleanup;
917
+ cleanupConnections(): Promise<void>;
918
+ private startPeriodicClaimTransfers;
919
+ private updateLeaves;
920
+ private queryNodes;
921
+ }
922
+
923
+ export { type ConfigOptions as C, type DecodedSparkAddressData as D, type HumanReadableTokenIdentifier as H, type InitWalletResponse as I, LRC_WALLET_NETWORK as L, Network as N, type PayLightningInvoiceParams as P, SparkWallet as S, type TokenBalanceMap as T, type UserTokenMetadata as U, WalletConfigService as W, type SparkWalletProps as a, type SparkAddressFormat as b, ConnectionManager as c, WalletConfig as d, type SparkAddressData as e, encodeSparkAddress as f, decodeSparkAddress as g, isValidPublicKey as h, isValidSparkAddress as i, type NetworkType as j, NetworkToProto as k, getNetwork as l, LRC_WALLET_NETWORK_TYPE as m, getNetworkFromAddress as n, getNetworkFromString as o, protoToNetwork as p, type HumanReadableTokenIdentifierData as q, encodeHumanReadableTokenIdentifier as r, decodeHumanReadableTokenIdentifier as s, type CreateLightningInvoiceParams as t, type TransferParams as u, type DepositParams as v, type SparkWalletEvents as w };