@buildonspark/spark-sdk 0.3.5 → 0.3.7

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 (113) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/bare/index.cjs +4079 -4662
  3. package/dist/bare/index.d.cts +689 -89
  4. package/dist/bare/index.d.ts +689 -89
  5. package/dist/bare/index.js +5565 -5972
  6. package/dist/{chunk-JE73HB26.js → chunk-KDEVNW7C.js} +12671 -13161
  7. package/dist/chunk-P4HYYSMU.js +7 -0
  8. package/dist/chunk-SRPKOCG4.js +139 -0
  9. package/dist/chunk-UYTT3C6H.js +605 -0
  10. package/dist/{client-DWml6sjL.d.cts → client-Bcb7TUIp.d.cts} +12 -10
  11. package/dist/{client-DBZ43pJT.d.ts → client-D9T58OY8.d.ts} +12 -10
  12. package/dist/debug.cjs +9248 -9782
  13. package/dist/debug.d.cts +8 -8
  14. package/dist/debug.d.ts +8 -8
  15. package/dist/debug.js +5 -3
  16. package/dist/graphql/objects/index.d.cts +3 -3
  17. package/dist/graphql/objects/index.d.ts +3 -3
  18. package/dist/index.cjs +695 -1286
  19. package/dist/index.d.cts +7 -18
  20. package/dist/index.d.ts +7 -18
  21. package/dist/index.js +5 -4
  22. package/dist/index.node.cjs +1365 -1496
  23. package/dist/index.node.d.cts +6 -7
  24. package/dist/index.node.d.ts +6 -7
  25. package/dist/index.node.js +7 -66
  26. package/dist/{logging-Dt2ooQiP.d.ts → logging-JIaZZIbR.d.ts} +3 -3
  27. package/dist/{logging-BUpzk4Z6.d.cts → logging-zkr4UlOi.d.cts} +3 -3
  28. package/dist/native/{chunk-D3SZRO65.js → chunk-X2QXUON7.js} +15 -0
  29. package/dist/native/{index.cjs → index.react-native.cjs} +875 -1274
  30. package/dist/native/{index.d.cts → index.react-native.d.cts} +1124 -520
  31. package/dist/native/{index.d.ts → index.react-native.d.ts} +1124 -520
  32. package/dist/native/{index.js → index.react-native.js} +870 -1100
  33. package/dist/native/{wasm-KT5NZXRN.js → wasm-GKEDPGTM.js} +1 -2
  34. package/dist/proto/spark.d.cts +1 -1
  35. package/dist/proto/spark.d.ts +1 -1
  36. package/dist/proto/spark_token.d.cts +1 -1
  37. package/dist/proto/spark_token.d.ts +1 -1
  38. package/dist/{spark-DasxuVfm.d.cts → spark-WA_4wcBr.d.cts} +1 -1
  39. package/dist/{spark-DasxuVfm.d.ts → spark-WA_4wcBr.d.ts} +1 -1
  40. package/dist/{spark-wallet-jlC0XN5f.d.ts → spark-wallet-BuFrUWeE.d.cts} +107 -75
  41. package/dist/{spark-wallet-BoMIOPWW.d.cts → spark-wallet-CE5PYiIb.d.ts} +107 -75
  42. package/dist/spark-wallet.browser-BwYkkOBU.d.ts +26 -0
  43. package/dist/spark-wallet.browser-DC3jdQPW.d.cts +26 -0
  44. package/dist/spark-wallet.node-C9d2W-Nb.d.ts +90 -0
  45. package/dist/spark-wallet.node-CR_zNxmy.d.cts +90 -0
  46. package/dist/tests/test-utils.cjs +17563 -7501
  47. package/dist/tests/test-utils.d.cts +8 -22
  48. package/dist/tests/test-utils.d.ts +8 -22
  49. package/dist/tests/test-utils.js +30 -4
  50. package/dist/{token-transactions-DscJaJOE.d.ts → token-transactions-BZoJuvuE.d.ts} +2 -2
  51. package/dist/{token-transactions-BDzCrQSk.d.cts → token-transactions-I_OFIoNH.d.cts} +2 -2
  52. package/dist/types/index.d.cts +2 -2
  53. package/dist/types/index.d.ts +2 -2
  54. package/package.json +20 -16
  55. package/src/bare/index.ts +1 -1
  56. package/src/debug.ts +1 -1
  57. package/src/graphql/client.ts +6 -9
  58. package/src/graphql/mutations/CompleteCoopExit.ts +1 -1
  59. package/src/graphql/mutations/RequestCoopExit.ts +3 -1
  60. package/src/graphql/mutations/RequestLightningSend.ts +3 -1
  61. package/src/graphql/objects/CompleteCoopExitInput.ts +22 -33
  62. package/src/graphql/objects/RequestCoopExitInput.ts +39 -45
  63. package/src/graphql/objects/RequestLightningSendInput.ts +31 -39
  64. package/src/index.node.ts +2 -1
  65. package/src/index.react-native.ts +21 -0
  66. package/src/index.ts +2 -1
  67. package/src/services/config.ts +2 -2
  68. package/src/services/connection/connection.browser.ts +130 -0
  69. package/src/services/connection/connection.node.ts +158 -0
  70. package/src/services/{connection.ts → connection/connection.ts} +58 -259
  71. package/src/services/coop-exit.ts +8 -4
  72. package/src/services/deposit.ts +1 -1
  73. package/src/services/index.ts +1 -1
  74. package/src/services/lightning.ts +1 -1
  75. package/src/services/token-transactions.ts +9 -9
  76. package/src/services/transfer.ts +1 -1
  77. package/src/spark-wallet/spark-wallet.bare.ts +12 -0
  78. package/src/spark-wallet/spark-wallet.browser.ts +9 -24
  79. package/src/spark-wallet/spark-wallet.node.ts +4 -24
  80. package/src/spark-wallet/spark-wallet.react-native.ts +17 -0
  81. package/src/spark-wallet/spark-wallet.ts +130 -82
  82. package/src/spark-wallet/types.ts +4 -2
  83. package/src/tests/integration/coop-exit.test.ts +5 -3
  84. package/src/tests/integration/lightning.test.ts +9 -5
  85. package/src/tests/integration/ssp/coop-exit-validation.test.ts +8 -11
  86. package/src/tests/integration/ssp/coop-exit.test.ts +3 -5
  87. package/src/tests/integration/ssp/lightning.test.ts +1 -1
  88. package/src/tests/integration/ssp/static-deposit-validation.test.ts +2 -2
  89. package/src/tests/integration/ssp/static_deposit.test.ts +94 -101
  90. package/src/tests/integration/ssp/swap.test.ts +4 -5
  91. package/src/tests/integration/ssp/transfers.test.ts +10 -11
  92. package/src/tests/integration/static_deposit.test.ts +4 -4
  93. package/src/tests/integration/token-output.test.ts +2 -2
  94. package/src/tests/integration/transfer.test.ts +30 -26
  95. package/src/tests/integration/watchtower.test.ts +3 -3
  96. package/src/tests/optimize.test.ts +45 -0
  97. package/src/tests/spark-wallet/queryNodes.test.ts +1 -2
  98. package/src/tests/test-utils.ts +3 -3
  99. package/src/tests/token-outputs.test.ts +61 -2
  100. package/src/tests/utils/spark-testing-wallet.ts +18 -58
  101. package/src/tests/utils/test-faucet.ts +12 -8
  102. package/src/tests/utils/utils.ts +63 -0
  103. package/src/tests/wrapWithOtelSpan.test.ts +7 -0
  104. package/src/utils/network.ts +11 -10
  105. package/src/utils/optimize.ts +226 -0
  106. package/dist/bare/xhr-transport-EEEC7FYA.js +0 -165
  107. package/dist/chunk-DIXXHATX.js +0 -70
  108. package/dist/native/chunk-C3WN3D4O.js +0 -19
  109. package/dist/native/xhr-transport-TNCG4HTW.js +0 -168
  110. package/dist/spark-wallet.node-07PksUHH.d.cts +0 -12
  111. package/dist/spark-wallet.node-CdWkKMSq.d.ts +0 -12
  112. package/dist/xhr-transport-IWJPYF7F.js +0 -167
  113. package/src/native/index.ts +0 -20
@@ -1,13 +1,12 @@
1
- import { B as BitcoinNetwork, M as MayHaveSspClientOptions, t as SspClientOptions, H as HasSspClientOptions, S as SparkSigner, l as KeyDerivation, i as SigningCommitmentWithOptionalNonce, V as VerifiableSecretShare, W as WalletTransfer, L as LeavesSwapFeeEstimateOutput, u as StaticDepositQuoteOutput, C as ClaimStaticDepositOutput, w as WalletLeaf, x as LightningReceiveRequest, y as LightningSendRequest, z as LightningSendFeeEstimateInput, E as ExitSpeed, F as CoopExitFeeQuote, G as CoopExitRequest, I as TransferWithUserRequest } from './client-DWml6sjL.cjs';
2
- import { N as Network$1, E as Empty, c as SparkServiceClient, d as SparkInvoiceFields, R as RequestedSigningCommitments, U as UserSignedTxSigningJob, b as TreeNode, T as Transfer, L as LeafRefundTxSigningResult, e as NodeSignatures, F as FinalizeNodeSignaturesResponse, Q as QueryTransfersResponse, O as OutputWithPreviousTransactionData, f as QuerySparkInvoicesResponse } from './spark-DasxuVfm.cjs';
3
- import { SparkTokenServiceClient, TokenMetadata, QueryTokenTransactionsResponse } from './proto/spark_token.cjs';
1
+ import { B as BitcoinNetwork, M as MayHaveSspClientOptions, t as SspClientOptions, H as HasSspClientOptions, S as SparkSigner, l as KeyDerivation, i as SigningCommitmentWithOptionalNonce, V as VerifiableSecretShare, W as WalletTransfer, D as DefaultSparkSigner, L as LeavesSwapFeeEstimateOutput, u as StaticDepositQuoteOutput, C as ClaimStaticDepositOutput, w as WalletLeaf, x as LightningReceiveRequest, y as LightningSendRequest, z as LightningSendFeeEstimateInput, E as ExitSpeed, F as CoopExitFeeQuote, G as CoopExitRequest, I as TransferWithUserRequest } from './client-D9T58OY8.js';
2
+ import { N as Network$1, d as SparkServiceClient, b as SparkServiceDefinition, e as SparkInvoiceFields, R as RequestedSigningCommitments, U as UserSignedTxSigningJob, c as TreeNode, T as Transfer, L as LeafRefundTxSigningResult, f as NodeSignatures, F as FinalizeNodeSignaturesResponse, Q as QueryTransfersResponse, O as OutputWithPreviousTransactionData, g as QuerySparkInvoicesResponse } from './spark-WA_4wcBr.js';
3
+ import { SparkTokenServiceClient, SparkTokenServiceDefinition, TokenMetadata, QueryTokenTransactionsResponse } from './proto/spark_token.js';
4
4
  import * as btc from '@scure/btc-signer';
5
5
  import { Transaction } from '@scure/btc-signer';
6
- import * as bitcoin from 'bitcoinjs-lib';
7
6
  import { Channel } from 'nice-grpc';
7
+ import { CallOptions, ClientMiddlewareCall, Metadata } from 'nice-grpc-common';
8
8
  import { Channel as Channel$1 } from 'nice-grpc-web';
9
9
  import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
10
- import { CallOptions } from 'nice-grpc-common';
11
10
  import * as _scure_base from '@scure/base';
12
11
  import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
13
12
  import { EventEmitter } from 'eventemitter3';
@@ -23,13 +22,6 @@ type NetworkType = keyof typeof Network;
23
22
  declare const NetworkToProto: Record<Network, Network$1>;
24
23
  declare const protoToNetwork: (protoNetwork: Network$1) => Network | undefined;
25
24
  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
25
  /**
34
26
  * Utility function to determine the network from a Bitcoin address.
35
27
  *
@@ -81,7 +73,7 @@ declare class WalletConfigService implements HasSspClientOptions {
81
73
  private readonly config;
82
74
  readonly signer: SparkSigner;
83
75
  readonly sspClientOptions: SspClientOptions;
84
- constructor(options?: ConfigOptions, signer?: SparkSigner);
76
+ constructor(options: ConfigOptions | undefined, signer: SparkSigner);
85
77
  private getDefaultConfig;
86
78
  getCoordinatorAddress(): string;
87
79
  getSigningOperators(): Readonly<Record<string, SigningOperator>>;
@@ -101,50 +93,83 @@ declare class WalletConfigService implements HasSspClientOptions {
101
93
  getConsoleOptions(): ConsoleOptions;
102
94
  }
103
95
 
104
- declare enum InterruptTransferRequest_InterruptTransferAction {
105
- NONE = 0,
106
- INTERRUPT = 1,
107
- RESUME = 2,
108
- UNRECOGNIZED = -1
109
- }
110
- declare enum InterruptCoopExitRequest_InterruptCoopExitAction {
111
- NONE = 0,
112
- INTERRUPT = 1,
113
- RESUME = 2,
114
- UNRECOGNIZED = -1
96
+ /** Challenge represents the core challenge data */
97
+ interface Challenge {
98
+ /** Protocol version for backward compatibility */
99
+ version: number;
100
+ /** Timestamp when challenge was issued (UTC Unix seconds) */
101
+ timestamp: number;
102
+ /** Random nonce to prevent replay attacks (32 bytes) */
103
+ nonce: Uint8Array;
104
+ /** The public key this challenge is intended for (uncompressed secp256k1 public key) */
105
+ publicKey: Uint8Array;
115
106
  }
116
- interface CleanUpPreimageShareRequest {
117
- paymentHash: Uint8Array;
107
+ declare const Challenge: MessageFns<Challenge>;
108
+ /** ProtectedChallenge wraps a Challenge with a server HMAC */
109
+ interface ProtectedChallenge {
110
+ /** Protocol version for backward compatibility */
111
+ version: number;
112
+ /** The core challenge data */
113
+ challenge: Challenge | undefined;
114
+ /** Server's HMAC of the Challenge */
115
+ serverHmac: Uint8Array;
118
116
  }
119
- declare const CleanUpPreimageShareRequest: MessageFns<CleanUpPreimageShareRequest>;
120
- interface InterruptTransferRequest {
121
- action: InterruptTransferRequest_InterruptTransferAction;
117
+ declare const ProtectedChallenge: MessageFns<ProtectedChallenge>;
118
+ /** Request to initiate an authentication challenge */
119
+ interface GetChallengeRequest {
120
+ /** Client's public key (uncompressed secp256k1 public key) */
121
+ publicKey: Uint8Array;
122
122
  }
123
- declare const InterruptTransferRequest: MessageFns<InterruptTransferRequest>;
124
- interface UpdateNodesStatusRequest {
125
- nodeIds: string[];
126
- status: string;
123
+ declare const GetChallengeRequest: MessageFns<GetChallengeRequest>;
124
+ /** Response containing the protected challenge */
125
+ interface GetChallengeResponse {
126
+ /** The protected challenge from the server */
127
+ protectedChallenge: ProtectedChallenge | undefined;
127
128
  }
128
- declare const UpdateNodesStatusRequest: MessageFns<UpdateNodesStatusRequest>;
129
- /** TriggerTaskRequest is used to trigger a scheduled task immediately in hermetic tests. */
130
- interface TriggerTaskRequest {
131
- taskName: string;
129
+ declare const GetChallengeResponse: MessageFns<GetChallengeResponse>;
130
+ /** Request to verify a signed challenge */
131
+ interface VerifyChallengeRequest {
132
+ /** The protected challenge from the server */
133
+ protectedChallenge: ProtectedChallenge | undefined;
134
+ /** Client's secp256k1 signature of the Challenge */
135
+ signature: Uint8Array;
136
+ /** Client's public key (uncompressed secp256k1 public key) */
137
+ publicKey: Uint8Array;
132
138
  }
133
- declare const TriggerTaskRequest: MessageFns<TriggerTaskRequest>;
134
- interface InterruptCoopExitRequest {
135
- action: InterruptCoopExitRequest_InterruptCoopExitAction;
136
- /** optional, defaults to MockAction.TargetOperatorID */
137
- targetOperator: string;
138
- }
139
- declare const InterruptCoopExitRequest: MessageFns<InterruptCoopExitRequest>;
140
- interface MockServiceClient<CallOptionsExt = {}> {
141
- clean_up_preimage_share(request: DeepPartial<CleanUpPreimageShareRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
142
- interrupt_transfer(request: DeepPartial<InterruptTransferRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
143
- interrupt_coop_exit(request: DeepPartial<InterruptCoopExitRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
144
- update_nodes_status(request: DeepPartial<UpdateNodesStatusRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
145
- /** Triggers the execution of a scheduled task immediately by name. Used by hermetic tests */
146
- trigger_task(request: DeepPartial<TriggerTaskRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
139
+ declare const VerifyChallengeRequest: MessageFns<VerifyChallengeRequest>;
140
+ /** Response after successful authentication */
141
+ interface VerifyChallengeResponse {
142
+ /** Session token for subsequent API calls */
143
+ sessionToken: string;
144
+ /** Token expiration timestamp (UTC Unix seconds) */
145
+ expirationTimestamp: number;
147
146
  }
147
+ declare const VerifyChallengeResponse: MessageFns<VerifyChallengeResponse>;
148
+ type SparkAuthnServiceDefinition = typeof SparkAuthnServiceDefinition;
149
+ declare const SparkAuthnServiceDefinition: {
150
+ readonly name: "SparkAuthnService";
151
+ readonly fullName: "spark_authn.SparkAuthnService";
152
+ readonly methods: {
153
+ /** Request a new authentication challenge for a public key */
154
+ readonly get_challenge: {
155
+ readonly name: "get_challenge";
156
+ readonly requestType: MessageFns<GetChallengeRequest>;
157
+ readonly requestStream: false;
158
+ readonly responseType: MessageFns<GetChallengeResponse>;
159
+ readonly responseStream: false;
160
+ readonly options: {};
161
+ };
162
+ /** Verify a signed challenge and return a session token */
163
+ readonly verify_challenge: {
164
+ readonly name: "verify_challenge";
165
+ readonly requestType: MessageFns<VerifyChallengeRequest>;
166
+ readonly requestStream: false;
167
+ readonly responseType: MessageFns<VerifyChallengeResponse>;
168
+ readonly responseStream: false;
169
+ readonly options: {};
170
+ };
171
+ };
172
+ };
148
173
  type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
149
174
  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 {
150
175
  $case: string;
@@ -164,19 +189,27 @@ interface MessageFns<T> {
164
189
  fromPartial(object: DeepPartial<T>): T;
165
190
  }
166
191
 
192
+ interface RetryOptions {
193
+ retry?: boolean;
194
+ retryMaxAttempts?: number;
195
+ }
196
+ type SparkCallOptions = CallOptions & RetryOptions;
197
+
167
198
  declare class ConnectionManager {
168
199
  private config;
169
- private clients;
200
+ protected clients: Map<string, {
201
+ client: SparkServiceClient & {
202
+ close?: () => void;
203
+ };
204
+ authToken: string;
205
+ }>;
170
206
  private tokenClients;
171
207
  private streamClients;
172
208
  private authPromises;
173
209
  constructor(config: WalletConfigService);
174
210
  createClients(): Promise<void>;
175
211
  closeConnections(): Promise<void>;
176
- createMockClient(address: string): Promise<MockServiceClient & {
177
- close: () => void;
178
- }>;
179
- private createChannelWithTLS;
212
+ protected createChannelWithTLS(address: string, certPath?: string): Promise<Channel | Channel$1>;
180
213
  createSparkStreamClient(address: string, certPath?: string): Promise<SparkServiceClient & {
181
214
  close?: () => void;
182
215
  }>;
@@ -189,12 +222,12 @@ declare class ConnectionManager {
189
222
  getStreamChannel(address: string): Promise<Channel | Channel$1 | undefined>;
190
223
  private authenticate;
191
224
  private createSparkAuthnGrpcConnection;
192
- private createAuthnMiddleware;
193
- private createMiddleware;
194
- private handleMiddlewareError;
195
- private createNodeMiddleware;
196
- private createBrowserMiddleware;
197
- private createGrpcClient;
225
+ protected createAuthnMiddleware(): (call: ClientMiddlewareCall<any, any>, options: SparkCallOptions) => AsyncGenerator<any, any, undefined>;
226
+ protected createMiddleware(address: string, authToken: string): ((call: ClientMiddlewareCall<any, any>, options: SparkCallOptions) => AsyncGenerator<any, any, undefined>) | undefined;
227
+ protected handleMiddlewareError(error: unknown, address: string, call: ClientMiddlewareCall<any, any>, metadata: Metadata, options: SparkCallOptions): AsyncGenerator<any, any, undefined>;
228
+ protected createGrpcClient<T>(defintion: SparkAuthnServiceDefinition | SparkServiceDefinition | SparkTokenServiceDefinition, channel: Channel | Channel$1, withRetries: boolean, middleware?: any): Promise<T & {
229
+ close?: () => void;
230
+ }>;
198
231
  }
199
232
 
200
233
  declare const AddressNetwork: Record<NetworkType, string>;
@@ -456,8 +489,9 @@ type RawTokenIdentifierHex = string & {
456
489
  };
457
490
  type TokenOutputsMap = Map<Bech32mTokenIdentifier, OutputWithPreviousTransactionData[]>;
458
491
  type TokenMetadataMap = Map<Bech32mTokenIdentifier, TokenMetadata>;
459
- type InitWalletResponse = {
460
- mnemonic?: string | undefined;
492
+ type InitWalletResponse<T extends SparkWallet = SparkWallet> = {
493
+ wallet: T;
494
+ mnemonic: string | undefined;
461
495
  };
462
496
  interface SparkWalletProps {
463
497
  mnemonicOrSeed?: Uint8Array | string;
@@ -493,7 +527,7 @@ interface SparkWalletEvents {
493
527
  * It provides methods for creating and managing wallets, handling deposits, executing transfers,
494
528
  * and interacting with the Lightning Network.
495
529
  */
496
- declare class SparkWallet extends EventEmitter<SparkWalletEvents> {
530
+ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
497
531
  protected config: WalletConfigService;
498
532
  protected connectionManager: ConnectionManager;
499
533
  protected transferService: TransferService;
@@ -516,13 +550,12 @@ declare class SparkWallet extends EventEmitter<SparkWalletEvents> {
516
550
  protected tokenOutputs: TokenOutputsMap;
517
551
  private claimTransfersInterval;
518
552
  private tracer;
519
- protected constructor(options?: ConfigOptions, signer?: SparkSigner);
520
- static initialize({ mnemonicOrSeed, accountNumber, signer, options, }: SparkWalletProps): Promise<{
521
- mnemonic?: string | undefined;
522
- wallet: SparkWallet;
523
- }>;
524
- private initializeWallet;
553
+ constructor(options?: ConfigOptions, signerArg?: SparkSigner);
554
+ static initialize<T extends SparkWallet>(this: new (options?: ConfigOptions, signer?: SparkSigner) => T, { mnemonicOrSeed, accountNumber, signer, options }: SparkWalletProps): Promise<InitWalletResponse<T>>;
555
+ private createClientsAndSyncWallet;
525
556
  private getSspClient;
557
+ protected buildSigner(): DefaultSparkSigner;
558
+ protected buildConnectionManager(config: WalletConfigService): ConnectionManager;
526
559
  private handleStreamEvent;
527
560
  protected setupBackgroundStream(): Promise<void>;
528
561
  getLeaves(isBalanceCheck?: boolean): Promise<TreeNode[]>;
@@ -595,11 +628,10 @@ declare class SparkWallet extends EventEmitter<SparkWalletEvents> {
595
628
  *
596
629
  * @returns {Promise<Object>} Object containing:
597
630
  * - mnemonic: The mnemonic if one was generated (undefined for raw seed)
598
- * - balance: The wallet's initial balance in satoshis
599
- * - tokenBalance: Map of token balances
631
+ * - wallet: The wallet instance
600
632
  * @private
601
633
  */
602
- protected initWallet(mnemonicOrSeed?: Uint8Array | string, accountNumber?: number): Promise<InitWalletResponse | undefined>;
634
+ protected initWallet(mnemonicOrSeed?: Uint8Array | string, accountNumber?: number, options?: ConfigOptions): Promise<InitWalletResponse<this>>;
603
635
  /**
604
636
  * Initializes the wallet without a seed. Meant for use with a signer with pre-existing keys.
605
637
  * @private
@@ -1110,4 +1142,4 @@ declare class SparkWallet extends EventEmitter<SparkWalletEvents> {
1110
1142
  private wrapSparkWalletMethodsWithTracing;
1111
1143
  }
1112
1144
 
1113
- export { type SparkWalletEvents as $, getNetworkFromBech32mTokenIdentifier as A, type Bech32mTokenIdentifier as B, ConnectionManager as C, type DecodedSparkAddressData as D, type CreateLightningInvoiceParams as E, type TransferWithInvoiceParams as F, type TransferWithInvoiceOutcome as G, type FulfillSparkInvoiceResponse as H, type TokenInvoice as I, type InvalidInvoice as J, type GroupSparkInvoicesResult as K, type LegacySparkAddressFormat as L, type DepositParams as M, Network as N, type TokenBalanceMap as O, type PayLightningInvoiceParams as P, type TokenOutputsMap as Q, type RawTokenIdentifierHex as R, type SparkAddressFormat as S, type TransferParams as T, type UserTokenMetadata as U, type TokenMetadataMap as V, WalletConfigService as W, type InitWalletResponse as X, type SparkWalletProps as Y, SparkWalletEvent as Z, type SparkWalletEventType as _, WalletConfig as a, SparkWallet as a0, type ConfigOptions as b, type SparkAddressData as c, encodeSparkAddressWithSignature as d, encodeSparkAddress as e, decodeSparkAddress as f, getNetworkFromSparkAddress as g, isValidSparkAddress as h, isLegacySparkAddress as i, isValidPublicKey as j, validateSparkInvoiceSignature as k, assertBech32 as l, bech32mDecode as m, isSafeForNumber as n, type NetworkType as o, NetworkToProto as p, protoToNetwork as q, getNetwork as r, LRC_WALLET_NETWORK as s, toProtoTimestamp as t, getNetworkFromAddress as u, validateSparkInvoiceFields as v, getNetworkFromString as w, type Bech32mTokenIdentifierData as x, encodeBech32mTokenIdentifier as y, decodeBech32mTokenIdentifier as z };
1145
+ export { type SparkCallOptions as $, type CreateLightningInvoiceParams as A, type Bech32mTokenIdentifier as B, ConnectionManager as C, type DecodedSparkAddressData as D, type TransferWithInvoiceParams as E, type TransferWithInvoiceOutcome as F, type FulfillSparkInvoiceResponse as G, type TokenInvoice as H, type InvalidInvoice as I, type GroupSparkInvoicesResult as J, type DepositParams as K, type LegacySparkAddressFormat as L, type TokenBalanceMap as M, Network as N, type TokenOutputsMap as O, type PayLightningInvoiceParams as P, type TokenMetadataMap as Q, type RawTokenIdentifierHex as R, type SparkAddressFormat as S, type TransferParams as T, type UserTokenMetadata as U, type InitWalletResponse as V, WalletConfigService as W, type SparkWalletProps as X, SparkWalletEvent as Y, type SparkWalletEventType as Z, type SparkWalletEvents as _, WalletConfig as a, SparkAuthnServiceDefinition as a0, SparkWallet as a1, type ConfigOptions as b, type SparkAddressData as c, encodeSparkAddressWithSignature as d, encodeSparkAddress as e, decodeSparkAddress as f, getNetworkFromSparkAddress as g, isValidSparkAddress as h, isLegacySparkAddress as i, isValidPublicKey as j, validateSparkInvoiceSignature as k, assertBech32 as l, bech32mDecode as m, isSafeForNumber as n, type NetworkType as o, NetworkToProto as p, protoToNetwork as q, getNetwork as r, getNetworkFromAddress as s, toProtoTimestamp as t, getNetworkFromString as u, validateSparkInvoiceFields as v, type Bech32mTokenIdentifierData as w, encodeBech32mTokenIdentifier as x, decodeBech32mTokenIdentifier as y, getNetworkFromBech32mTokenIdentifier as z };
@@ -0,0 +1,26 @@
1
+ import { C as ConnectionManager, W as WalletConfigService, $ as SparkCallOptions, a0 as SparkAuthnServiceDefinition, a1 as SparkWallet } from './spark-wallet-CE5PYiIb.js';
2
+ import * as nice_grpc_web_lib_client_Transport_js from 'nice-grpc-web/lib/client/Transport.js';
3
+ import { createChannel, Channel } from 'nice-grpc-web';
4
+ import { ClientMiddlewareCall } from 'nice-grpc-common';
5
+ import { b as SparkServiceDefinition } from './spark-WA_4wcBr.js';
6
+ import { SparkTokenServiceDefinition } from './proto/spark_token.js';
7
+
8
+ type Transport = NonNullable<Parameters<typeof createChannel>[1]>;
9
+ declare class ConnectionManagerBrowser extends ConnectionManager {
10
+ protected transport: Transport;
11
+ constructor(config: WalletConfigService, transport?: nice_grpc_web_lib_client_Transport_js.Transport);
12
+ protected createChannelWithTLS(address: string, certPath?: string): Promise<Channel>;
13
+ protected createAuthnMiddleware(): (call: ClientMiddlewareCall<any, any>, options: SparkCallOptions) => AsyncGenerator<any, any, undefined>;
14
+ protected createMiddleware(address: string, initialAuthToken: string): (call: ClientMiddlewareCall<any, any>, options: SparkCallOptions) => AsyncGenerator<any, any, undefined>;
15
+ protected createGrpcClient<T>(defintion: SparkAuthnServiceDefinition | SparkServiceDefinition | SparkTokenServiceDefinition, channel: Channel, withRetries: boolean, middleware?: any): Promise<T & {
16
+ close: undefined;
17
+ }>;
18
+ }
19
+
20
+ declare class SparkWalletBrowser extends SparkWallet {
21
+ protected buildConnectionManager(config: WalletConfigService): ConnectionManagerBrowser;
22
+ protected initializeTracerEnv({ spanProcessors, traceUrls, }: Parameters<SparkWallet["initializeTracerEnv"]>[0]): void;
23
+ }
24
+ declare function initializeTracerEnvBrowser({ spanProcessors, traceUrls, }: Parameters<SparkWallet["initializeTracerEnv"]>[0]): void;
25
+
26
+ export { ConnectionManagerBrowser as C, SparkWalletBrowser as S, initializeTracerEnvBrowser as i };
@@ -0,0 +1,26 @@
1
+ import { C as ConnectionManager, W as WalletConfigService, $ as SparkCallOptions, a0 as SparkAuthnServiceDefinition, a1 as SparkWallet } from './spark-wallet-BuFrUWeE.cjs';
2
+ import * as nice_grpc_web_lib_client_Transport_js from 'nice-grpc-web/lib/client/Transport.js';
3
+ import { createChannel, Channel } from 'nice-grpc-web';
4
+ import { ClientMiddlewareCall } from 'nice-grpc-common';
5
+ import { b as SparkServiceDefinition } from './spark-WA_4wcBr.cjs';
6
+ import { SparkTokenServiceDefinition } from './proto/spark_token.cjs';
7
+
8
+ type Transport = NonNullable<Parameters<typeof createChannel>[1]>;
9
+ declare class ConnectionManagerBrowser extends ConnectionManager {
10
+ protected transport: Transport;
11
+ constructor(config: WalletConfigService, transport?: nice_grpc_web_lib_client_Transport_js.Transport);
12
+ protected createChannelWithTLS(address: string, certPath?: string): Promise<Channel>;
13
+ protected createAuthnMiddleware(): (call: ClientMiddlewareCall<any, any>, options: SparkCallOptions) => AsyncGenerator<any, any, undefined>;
14
+ protected createMiddleware(address: string, initialAuthToken: string): (call: ClientMiddlewareCall<any, any>, options: SparkCallOptions) => AsyncGenerator<any, any, undefined>;
15
+ protected createGrpcClient<T>(defintion: SparkAuthnServiceDefinition | SparkServiceDefinition | SparkTokenServiceDefinition, channel: Channel, withRetries: boolean, middleware?: any): Promise<T & {
16
+ close: undefined;
17
+ }>;
18
+ }
19
+
20
+ declare class SparkWalletBrowser extends SparkWallet {
21
+ protected buildConnectionManager(config: WalletConfigService): ConnectionManagerBrowser;
22
+ protected initializeTracerEnv({ spanProcessors, traceUrls, }: Parameters<SparkWallet["initializeTracerEnv"]>[0]): void;
23
+ }
24
+ declare function initializeTracerEnvBrowser({ spanProcessors, traceUrls, }: Parameters<SparkWallet["initializeTracerEnv"]>[0]): void;
25
+
26
+ export { ConnectionManagerBrowser as C, SparkWalletBrowser as S, initializeTracerEnvBrowser as i };
@@ -0,0 +1,90 @@
1
+ import { C as ConnectionManager, W as WalletConfigService, $ as SparkCallOptions, a0 as SparkAuthnServiceDefinition, a1 as SparkWallet } from './spark-wallet-CE5PYiIb.js';
2
+ import { Channel } from 'nice-grpc';
3
+ import { CallOptions, ClientMiddlewareCall } from 'nice-grpc-common';
4
+ import { E as Empty, b as SparkServiceDefinition } from './spark-WA_4wcBr.js';
5
+ import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
6
+ import { SparkTokenServiceDefinition } from './proto/spark_token.js';
7
+
8
+ declare enum InterruptTransferRequest_InterruptTransferAction {
9
+ NONE = 0,
10
+ INTERRUPT = 1,
11
+ RESUME = 2,
12
+ UNRECOGNIZED = -1
13
+ }
14
+ declare enum InterruptCoopExitRequest_InterruptCoopExitAction {
15
+ NONE = 0,
16
+ INTERRUPT = 1,
17
+ RESUME = 2,
18
+ UNRECOGNIZED = -1
19
+ }
20
+ interface CleanUpPreimageShareRequest {
21
+ paymentHash: Uint8Array;
22
+ }
23
+ declare const CleanUpPreimageShareRequest: MessageFns<CleanUpPreimageShareRequest>;
24
+ interface InterruptTransferRequest {
25
+ action: InterruptTransferRequest_InterruptTransferAction;
26
+ }
27
+ declare const InterruptTransferRequest: MessageFns<InterruptTransferRequest>;
28
+ interface UpdateNodesStatusRequest {
29
+ nodeIds: string[];
30
+ status: string;
31
+ }
32
+ declare const UpdateNodesStatusRequest: MessageFns<UpdateNodesStatusRequest>;
33
+ /** TriggerTaskRequest is used to trigger a scheduled task immediately in hermetic tests. */
34
+ interface TriggerTaskRequest {
35
+ taskName: string;
36
+ }
37
+ declare const TriggerTaskRequest: MessageFns<TriggerTaskRequest>;
38
+ interface InterruptCoopExitRequest {
39
+ action: InterruptCoopExitRequest_InterruptCoopExitAction;
40
+ /** optional, defaults to MockAction.TargetOperatorID */
41
+ targetOperator: string;
42
+ }
43
+ declare const InterruptCoopExitRequest: MessageFns<InterruptCoopExitRequest>;
44
+ interface MockServiceClient<CallOptionsExt = {}> {
45
+ clean_up_preimage_share(request: DeepPartial<CleanUpPreimageShareRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
46
+ interrupt_transfer(request: DeepPartial<InterruptTransferRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
47
+ interrupt_coop_exit(request: DeepPartial<InterruptCoopExitRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
48
+ update_nodes_status(request: DeepPartial<UpdateNodesStatusRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
49
+ /** Triggers the execution of a scheduled task immediately by name. Used by hermetic tests */
50
+ trigger_task(request: DeepPartial<TriggerTaskRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
51
+ }
52
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
53
+ 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 {
54
+ $case: string;
55
+ } ? {
56
+ [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]>;
57
+ } & {
58
+ $case: T["$case"];
59
+ } : T extends {} ? {
60
+ [K in keyof T]?: DeepPartial<T[K]>;
61
+ } : Partial<T>;
62
+ interface MessageFns<T> {
63
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
64
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
65
+ fromJSON(object: any): T;
66
+ toJSON(message: T): unknown;
67
+ create(base?: DeepPartial<T>): T;
68
+ fromPartial(object: DeepPartial<T>): T;
69
+ }
70
+
71
+ declare class ConnectionManagerNodeJS extends ConnectionManager {
72
+ constructor(config: WalletConfigService);
73
+ createMockClient(address: string): Promise<MockServiceClient & {
74
+ close: () => void;
75
+ }>;
76
+ protected createChannelWithTLS(address: string, certPath?: string): Promise<Channel>;
77
+ protected createAuthnMiddleware(): (call: ClientMiddlewareCall<any, any>, options: SparkCallOptions) => AsyncGenerator<any, any, undefined>;
78
+ protected createMiddleware(address: string, initialAuthToken: string): (call: ClientMiddlewareCall<any, any>, options: SparkCallOptions) => AsyncGenerator<any, any, undefined>;
79
+ protected createGrpcClient<T>(defintion: SparkAuthnServiceDefinition | SparkServiceDefinition | SparkTokenServiceDefinition, channel: Channel, withRetries: boolean, middleware?: any): Promise<T & {
80
+ close: () => void;
81
+ }>;
82
+ }
83
+
84
+ declare class SparkWalletNodeJS extends SparkWallet {
85
+ protected buildConnectionManager(config: WalletConfigService): ConnectionManagerNodeJS;
86
+ protected initializeTracerEnv({ spanProcessors, traceUrls, }: Parameters<SparkWallet["initializeTracerEnv"]>[0]): void;
87
+ }
88
+ declare function initializeTracerEnvNodeJS({ spanProcessors, traceUrls, }: Parameters<SparkWallet["initializeTracerEnv"]>[0]): void;
89
+
90
+ export { ConnectionManagerNodeJS as C, SparkWalletNodeJS as S, initializeTracerEnvNodeJS as i };
@@ -0,0 +1,90 @@
1
+ import { C as ConnectionManager, W as WalletConfigService, $ as SparkCallOptions, a0 as SparkAuthnServiceDefinition, a1 as SparkWallet } from './spark-wallet-BuFrUWeE.cjs';
2
+ import { Channel } from 'nice-grpc';
3
+ import { CallOptions, ClientMiddlewareCall } from 'nice-grpc-common';
4
+ import { E as Empty, b as SparkServiceDefinition } from './spark-WA_4wcBr.cjs';
5
+ import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
6
+ import { SparkTokenServiceDefinition } from './proto/spark_token.cjs';
7
+
8
+ declare enum InterruptTransferRequest_InterruptTransferAction {
9
+ NONE = 0,
10
+ INTERRUPT = 1,
11
+ RESUME = 2,
12
+ UNRECOGNIZED = -1
13
+ }
14
+ declare enum InterruptCoopExitRequest_InterruptCoopExitAction {
15
+ NONE = 0,
16
+ INTERRUPT = 1,
17
+ RESUME = 2,
18
+ UNRECOGNIZED = -1
19
+ }
20
+ interface CleanUpPreimageShareRequest {
21
+ paymentHash: Uint8Array;
22
+ }
23
+ declare const CleanUpPreimageShareRequest: MessageFns<CleanUpPreimageShareRequest>;
24
+ interface InterruptTransferRequest {
25
+ action: InterruptTransferRequest_InterruptTransferAction;
26
+ }
27
+ declare const InterruptTransferRequest: MessageFns<InterruptTransferRequest>;
28
+ interface UpdateNodesStatusRequest {
29
+ nodeIds: string[];
30
+ status: string;
31
+ }
32
+ declare const UpdateNodesStatusRequest: MessageFns<UpdateNodesStatusRequest>;
33
+ /** TriggerTaskRequest is used to trigger a scheduled task immediately in hermetic tests. */
34
+ interface TriggerTaskRequest {
35
+ taskName: string;
36
+ }
37
+ declare const TriggerTaskRequest: MessageFns<TriggerTaskRequest>;
38
+ interface InterruptCoopExitRequest {
39
+ action: InterruptCoopExitRequest_InterruptCoopExitAction;
40
+ /** optional, defaults to MockAction.TargetOperatorID */
41
+ targetOperator: string;
42
+ }
43
+ declare const InterruptCoopExitRequest: MessageFns<InterruptCoopExitRequest>;
44
+ interface MockServiceClient<CallOptionsExt = {}> {
45
+ clean_up_preimage_share(request: DeepPartial<CleanUpPreimageShareRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
46
+ interrupt_transfer(request: DeepPartial<InterruptTransferRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
47
+ interrupt_coop_exit(request: DeepPartial<InterruptCoopExitRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
48
+ update_nodes_status(request: DeepPartial<UpdateNodesStatusRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
49
+ /** Triggers the execution of a scheduled task immediately by name. Used by hermetic tests */
50
+ trigger_task(request: DeepPartial<TriggerTaskRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
51
+ }
52
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
53
+ 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 {
54
+ $case: string;
55
+ } ? {
56
+ [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]>;
57
+ } & {
58
+ $case: T["$case"];
59
+ } : T extends {} ? {
60
+ [K in keyof T]?: DeepPartial<T[K]>;
61
+ } : Partial<T>;
62
+ interface MessageFns<T> {
63
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
64
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
65
+ fromJSON(object: any): T;
66
+ toJSON(message: T): unknown;
67
+ create(base?: DeepPartial<T>): T;
68
+ fromPartial(object: DeepPartial<T>): T;
69
+ }
70
+
71
+ declare class ConnectionManagerNodeJS extends ConnectionManager {
72
+ constructor(config: WalletConfigService);
73
+ createMockClient(address: string): Promise<MockServiceClient & {
74
+ close: () => void;
75
+ }>;
76
+ protected createChannelWithTLS(address: string, certPath?: string): Promise<Channel>;
77
+ protected createAuthnMiddleware(): (call: ClientMiddlewareCall<any, any>, options: SparkCallOptions) => AsyncGenerator<any, any, undefined>;
78
+ protected createMiddleware(address: string, initialAuthToken: string): (call: ClientMiddlewareCall<any, any>, options: SparkCallOptions) => AsyncGenerator<any, any, undefined>;
79
+ protected createGrpcClient<T>(defintion: SparkAuthnServiceDefinition | SparkServiceDefinition | SparkTokenServiceDefinition, channel: Channel, withRetries: boolean, middleware?: any): Promise<T & {
80
+ close: () => void;
81
+ }>;
82
+ }
83
+
84
+ declare class SparkWalletNodeJS extends SparkWallet {
85
+ protected buildConnectionManager(config: WalletConfigService): ConnectionManagerNodeJS;
86
+ protected initializeTracerEnv({ spanProcessors, traceUrls, }: Parameters<SparkWallet["initializeTracerEnv"]>[0]): void;
87
+ }
88
+ declare function initializeTracerEnvNodeJS({ spanProcessors, traceUrls, }: Parameters<SparkWallet["initializeTracerEnv"]>[0]): void;
89
+
90
+ export { ConnectionManagerNodeJS as C, SparkWalletNodeJS as S, initializeTracerEnvNodeJS as i };