@buildonspark/spark-sdk 0.2.3 → 0.2.5

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 (91) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/{chunk-3SEOTO43.js → chunk-3SPMJMUX.js} +3 -2
  3. package/dist/{chunk-CDLETEDT.js → chunk-CQY5ML2A.js} +16 -3
  4. package/dist/{chunk-PTRXJS7Q.js → chunk-LQZL2D3Y.js} +1 -1
  5. package/dist/{chunk-PLLJIZC3.js → chunk-U7LRIWTF.js} +2471 -822
  6. package/dist/{client-CcYzmpmj.d.cts → client-C88GCTPB.d.cts} +211 -104
  7. package/dist/{client-CGTRS23n.d.ts → client-Dg6vS_2I.d.ts} +211 -104
  8. package/dist/debug.cjs +2511 -831
  9. package/dist/debug.d.cts +19 -6
  10. package/dist/debug.d.ts +19 -6
  11. package/dist/debug.js +3 -3
  12. package/dist/graphql/objects/index.cjs +13 -1
  13. package/dist/graphql/objects/index.d.cts +6 -51
  14. package/dist/graphql/objects/index.d.ts +6 -51
  15. package/dist/graphql/objects/index.js +1 -1
  16. package/dist/index.cjs +2491 -797
  17. package/dist/index.d.cts +189 -9
  18. package/dist/index.d.ts +189 -9
  19. package/dist/index.js +32 -4
  20. package/dist/index.node.cjs +2596 -799
  21. package/dist/index.node.d.cts +9 -190
  22. package/dist/index.node.d.ts +9 -190
  23. package/dist/index.node.js +134 -4
  24. package/dist/native/index.cjs +2491 -797
  25. package/dist/native/index.d.cts +309 -174
  26. package/dist/native/index.d.ts +309 -174
  27. package/dist/native/index.js +2495 -814
  28. package/dist/proto/lrc20.d.cts +1 -1
  29. package/dist/proto/lrc20.d.ts +1 -1
  30. package/dist/proto/spark.d.cts +1 -1
  31. package/dist/proto/spark.d.ts +1 -1
  32. package/dist/proto/spark_token.d.cts +1 -1
  33. package/dist/proto/spark_token.d.ts +1 -1
  34. package/dist/{spark-B_7nZx6T.d.cts → spark-ESAfZARg.d.cts} +1 -1
  35. package/dist/{spark-B_7nZx6T.d.ts → spark-ESAfZARg.d.ts} +1 -1
  36. package/dist/{spark-wallet-CxcGPXRB.d.ts → spark-wallet-B2WwKN8W.d.ts} +57 -35
  37. package/dist/{spark-wallet-DJJm19BP.d.cts → spark-wallet-Di65w0Us.d.cts} +57 -35
  38. package/dist/spark-wallet.node-7R0Rxyj9.d.cts +13 -0
  39. package/dist/spark-wallet.node-CSPWOWRu.d.ts +13 -0
  40. package/dist/tests/test-utils.cjs +578 -77
  41. package/dist/tests/test-utils.d.cts +12 -13
  42. package/dist/tests/test-utils.d.ts +12 -13
  43. package/dist/tests/test-utils.js +54 -17
  44. package/dist/types/index.cjs +16 -3
  45. package/dist/types/index.d.cts +3 -4
  46. package/dist/types/index.d.ts +3 -4
  47. package/dist/types/index.js +2 -2
  48. package/dist/{xchain-address-Bh9w1SeC.d.ts → xchain-address-BsveIy5l.d.ts} +56 -8
  49. package/dist/{xchain-address-SZ7dkVUE.d.cts → xchain-address-CqRu3F21.d.cts} +56 -8
  50. package/package.json +1 -1
  51. package/src/graphql/client.ts +57 -8
  52. package/src/graphql/mutations/CompleteLeavesSwap.ts +9 -1
  53. package/src/graphql/mutations/RequestSwapLeaves.ts +4 -0
  54. package/src/graphql/objects/CompleteLeavesSwapInput.ts +34 -34
  55. package/src/graphql/objects/LeavesSwapRequest.ts +4 -0
  56. package/src/graphql/objects/RequestLeavesSwapInput.ts +48 -47
  57. package/src/graphql/objects/SparkWalletUser.ts +1 -1
  58. package/src/graphql/objects/SwapLeaf.ts +40 -32
  59. package/src/graphql/objects/UserLeafInput.ts +24 -0
  60. package/src/graphql/objects/UserRequest.ts +4 -0
  61. package/src/graphql/queries/Transfers.ts +15 -0
  62. package/src/index.node.ts +1 -1
  63. package/src/native/index.ts +4 -5
  64. package/src/services/coop-exit.ts +171 -36
  65. package/src/services/deposit.ts +471 -74
  66. package/src/services/lightning.ts +18 -5
  67. package/src/services/signing.ts +162 -50
  68. package/src/services/transfer.ts +950 -384
  69. package/src/services/tree-creation.ts +342 -121
  70. package/src/spark-wallet/spark-wallet.node.ts +71 -66
  71. package/src/spark-wallet/spark-wallet.ts +561 -192
  72. package/src/tests/integration/coop-exit.test.ts +3 -8
  73. package/src/tests/integration/deposit.test.ts +3 -3
  74. package/src/tests/integration/lightning.test.ts +521 -466
  75. package/src/tests/integration/ssp/static_deposit.test.ts +83 -1
  76. package/src/tests/integration/ssp/transfers.test.ts +97 -0
  77. package/src/tests/integration/swap.test.ts +559 -307
  78. package/src/tests/integration/transfer.test.ts +625 -623
  79. package/src/tests/integration/wallet.test.ts +2 -2
  80. package/src/tests/integration/watchtower.test.ts +211 -0
  81. package/src/tests/test-utils.ts +63 -14
  82. package/src/tests/utils/test-faucet.ts +4 -2
  83. package/src/types/sdk-types.ts +15 -0
  84. package/src/utils/adaptor-signature.ts +15 -5
  85. package/src/utils/bitcoin.ts +13 -0
  86. package/src/utils/fetch.ts +75 -0
  87. package/src/utils/mempool.ts +9 -4
  88. package/src/utils/transaction.ts +388 -26
  89. package/dist/sdk-types-CB9HrW5O.d.cts +0 -44
  90. package/dist/sdk-types-CkRNraXT.d.ts +0 -44
  91. package/src/graphql/queries/Transfer.ts +0 -10
package/dist/index.d.cts CHANGED
@@ -1,20 +1,200 @@
1
- export { AuthenticationError, ConfigurationError, InternalValidationError, NetworkError, NotImplementedError, RPCError, SparkSDKError, TokenTransactionService, ValidationError } from './index.node.cjs';
2
- export { B as Bech32mTokenIdentifier, a as Bech32mTokenIdentifierData, C as ConfigOptions, s as ConnectionManager, u as CreateLightningInvoiceParams, D as DecodedSparkAddressData, w as DepositParams, I as InitWalletResponse, L as LRC_WALLET_NETWORK, b as LRC_WALLET_NETWORK_TYPE, N as Network, c as NetworkToProto, d as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, S as SparkAddressData, e as SparkAddressFormat, o as SparkWallet, y as SparkWalletEvents, q as SparkWalletProps, r as TokenBalanceMap, x as TokenMetadataMap, T as TokenOutputsMap, v as TransferParams, U as UserTokenMetadata, t as WalletConfig, W as WalletConfigService, f as decodeBech32mTokenIdentifier, g as decodeSparkAddress, h as encodeBech32mTokenIdentifier, i as encodeSparkAddress, j as getNetwork, k as getNetworkFromAddress, l as getNetworkFromString, m as isValidPublicKey, n as isValidSparkAddress, p as protoToNetwork } from './spark-wallet-DJJm19BP.cjs';
3
- export { B as BroadcastConfig, a as BroadcastResult, D as DEFAULT_FEE_SATS, F as FeeBumpTxChain, b as FeeBumpTxPackage, c as FeeRate, L as LeafInfo, T as TxChain, U as Utxo, d as addPrivateKeys, e as addPublicKeys, f as applyAdaptorToSignature, g as applyAdditiveTweakToPublicKey, h as checkIfSelectedOutputsAreAvailable, i as checkIfValidSequence, j as collectResponses, k as computeTaprootKeyNoScript, l as constructFeeBumpTx, m as constructUnilateralExitFeeBumpPackages, n as constructUnilateralExitTxs, o as createRefundTx, p as createSigningCommitment, q as createSigningNonce, r as decodeBytesToSigningCommitment, s as decodeBytesToSigningNonce, t as encodeSigningCommitmentToBytes, u as encodeSigningNonceToBytes, v as filterTokenBalanceForTokenPublicKey, w as generateAdaptorFromSignature, x as generateSignatureFromExistingAdaptor, y as getCurrentTimelock, z as getEphemeralAnchorOutput, A as getLatestDepositTxId, C as getNextTransactionSequence, E as getP2TRAddressFromPkScript, G as getP2TRAddressFromPublicKey, H as getP2TRScriptFromPublicKey, I as getP2WPKHAddressFromPublicKey, J as getRandomSigningNonce, K as getSigHashFromTx, M as getSigningCommitmentFromNonce, N as getSparkAddressFromTaproot, O as getTransactionSequence, P as getTransferPackageSigningPayload, Q as getTxFromRawTxBytes, R as getTxFromRawTxHex, S as getTxId, V as getTxIdNoReverse, W as isEphemeralAnchorOutput, X as isTxBroadcast, Y as lastKeyWithTarget, Z as maybeApplyFee, _ as proofOfPossessionMessageHashForDepositAddress, $ as subtractPrivateKeys, a0 as subtractPublicKeys, a1 as sumAvailableTokens, a2 as sumOfPrivateKeys, a3 as validateOutboundAdaptorSignature } from './xchain-address-SZ7dkVUE.cjs';
4
- export { ag as AggregateFrostParams, a2 as DefaultSparkSigner, ai as DerivedHDKey, a6 as KeyDerivation, ae as KeyDerivationType, aj as KeyPair, af as SignFrostParams, a9 as SigningCommitment, a7 as SigningCommitmentWithOptionalNonce, a8 as SigningNonce, a1 as SparkSigner, ah as SplitSecretWithProofsParams, ab as TaprootOutputKeysGenerator, ac as TaprootSparkSigner, ad as UnsafeStatelessSparkSigner, K as VerifiableSecretShare, M as bigIntToPrivateKey, N as computerLagrangeCoefficients, O as evaluatePolynomial, Q as fieldDiv, W as generatePolynomialForSecretSharing, X as getRandomBigInt, Y as modInverse, Z as recoverSecret, _ as splitSecret, $ as splitSecretWithProofs, a0 as validateShare } from './client-CcYzmpmj.cjs';
1
+ import { W as WalletConfigService, C as ConnectionManager, u as TokenOutputsMap, B as Bech32mTokenIdentifier } from './spark-wallet-Di65w0Us.cjs';
2
+ export { n as Bech32mTokenIdentifierData, b as ConfigOptions, r as CreateLightningInvoiceParams, D as DecodedSparkAddressData, s as DepositParams, I as InitWalletResponse, L as LRC_WALLET_NETWORK, k as LRC_WALLET_NETWORK_TYPE, N as Network, h as NetworkToProto, g as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, c as SparkAddressData, S as SparkAddressFormat, y as SparkWallet, x as SparkWalletEvents, w as SparkWalletProps, t as TokenBalanceMap, v as TokenMetadataMap, T as TransferParams, U as UserTokenMetadata, a as WalletConfig, q as decodeBech32mTokenIdentifier, d as decodeSparkAddress, o as encodeBech32mTokenIdentifier, e as encodeSparkAddress, j as getNetwork, l as getNetworkFromAddress, m as getNetworkFromString, f as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork } from './spark-wallet-Di65w0Us.cjs';
3
+ export { ab as BroadcastConfig, ac as BroadcastResult, Q as DEFAULT_FEE_SATS, M as DIRECT_TIMELOCK_OFFSET, a9 as FeeBumpTxChain, a8 as FeeBumpTxPackage, a7 as FeeRate, O as INITIAL_DIRECT_SEQUENCE, N as INITIAL_SEQUENCE, a5 as LeafInfo, P as TEST_UNILATERAL_DIRECT_SEQUENCE, T as TEST_UNILATERAL_SEQUENCE, aa as TxChain, a6 as Utxo, q as addPrivateKeys, o as addPublicKeys, b as applyAdaptorToSignature, p as applyAdditiveTweakToPublicKey, J as checkIfSelectedOutputsAreAvailable, a1 as checkIfValidSequence, z as collectResponses, c as computeTaprootKeyNoScript, ag as constructFeeBumpTx, af as constructUnilateralExitFeeBumpPackages, ae as constructUnilateralExitTxs, _ as createConnectorRefundTransactions, X as createLeafNodeTx, V as createNodeTx, W as createNodeTxs, Y as createRefundTx, Z as createRefundTxs, S as createRootTx, F as createSigningCommitment, B as createSigningNonce, U as createSplitTx, H as decodeBytesToSigningCommitment, E as decodeBytesToSigningNonce, a2 as doesLeafNeedRefresh, G as encodeSigningCommitmentToBytes, D as encodeSigningNonceToBytes, K as filterTokenBalanceForTokenPublicKey, a as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, $ as getCurrentTimelock, a4 as getEphemeralAnchorOutput, w as getLatestDepositTxId, a3 as getNextTransactionSequence, f as getP2TRAddressFromPkScript, e as getP2TRAddressFromPublicKey, d as getP2TRScriptFromPublicKey, h as getP2WPKHAddressFromPublicKey, A as getRandomSigningNonce, k as getSigHashFromTx, C as getSigningCommitmentFromNonce, ah as getSparkAddressFromTaproot, a0 as getTransactionSequence, L as getTransferPackageSigningPayload, n as getTxEstimatedVbytesSizeByNumberOfInputsOutputs, j as getTxFromRawTxBytes, i as getTxFromRawTxHex, l as getTxId, m as getTxIdNoReverse, ad as isEphemeralAnchorOutput, x as isTxBroadcast, u as lastKeyWithTarget, R as maybeApplyFee, y as proofOfPossessionMessageHashForDepositAddress, r as subtractPrivateKeys, s as subtractPublicKeys, I as sumAvailableTokens, t as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './xchain-address-CqRu3F21.cjs';
4
+ export { A as AggregateFrostParams, D as DefaultSparkSigner, p as DerivedHDKey, l as KeyDerivation, K as KeyDerivationType, q as KeyPair, n as SignFrostParams, k as SigningCommitment, i as SigningCommitmentWithOptionalNonce, j as SigningNonce, S as SparkSigner, o as SplitSecretWithProofsParams, T as TaprootOutputKeysGenerator, a as TaprootSparkSigner, U as UnsafeStatelessSparkSigner, V as VerifiableSecretShare, h as bigIntToPrivateKey, c as computerLagrangeCoefficients, e as evaluatePolynomial, f as fieldDiv, b as generatePolynomialForSecretSharing, g as getRandomBigInt, m as modInverse, r as recoverSecret, s as splitSecret, d as splitSecretWithProofs, v as validateShare } from './client-C88GCTPB.cjs';
5
+ import { f as OutputWithPreviousTransactionData, T as TokenTransaction, k as TokenTransactionWithStatus } from './spark-ESAfZARg.cjs';
6
+ import { TokenTransaction as TokenTransaction$1, TokenTransactionWithStatus as TokenTransactionWithStatus$1 } from './proto/spark_token.cjs';
5
7
  export { TokenSigner } from '@buildonspark/lrc20-sdk';
6
8
  export { MultisigReceiptInput } from '@buildonspark/lrc20-sdk/lrc/types';
7
- import './spark-B_7nZx6T.cjs';
8
- import '@bufbuild/protobuf/wire';
9
- import 'nice-grpc-common';
10
- import './proto/spark_token.cjs';
11
9
  import '@scure/btc-signer';
12
10
  import 'bitcoinjs-lib';
13
11
  import 'nice-grpc';
14
12
  import 'nice-grpc-web';
13
+ import '@bufbuild/protobuf/wire';
14
+ import 'nice-grpc-common';
15
15
  import 'eventemitter3';
16
- import './sdk-types-CB9HrW5O.cjs';
17
16
  import '@scure/btc-signer/psbt';
18
17
  import '@lightsparkdev/core';
19
18
  import '@scure/bip32';
20
19
  import './types-BADxR3bm.cjs';
20
+
21
+ declare class SparkSDKError extends Error {
22
+ readonly context: Record<string, unknown>;
23
+ readonly originalError?: Error;
24
+ constructor(message: string, context?: Record<string, unknown>, originalError?: Error);
25
+ toString(): string;
26
+ toJSON(): Record<string, unknown>;
27
+ }
28
+
29
+ /**
30
+ * NetworkError should be used for any errors related to network communication,
31
+ * such as failed HTTP requests, timeouts, or connection issues.
32
+ * This includes:
33
+ * - Failed API calls
34
+ * - Network timeouts
35
+ * - Connection refused
36
+ * - DNS resolution failures
37
+ * - SSL/TLS errors
38
+ */
39
+ declare class NetworkError extends SparkSDKError {
40
+ constructor(message: string, context?: {
41
+ url?: string;
42
+ method?: string;
43
+ statusCode?: number;
44
+ response?: unknown;
45
+ errorCount?: number;
46
+ errors?: string;
47
+ operation?: string;
48
+ nodeSignaturesCount?: number;
49
+ }, originalError?: Error);
50
+ }
51
+ /**
52
+ * ValidationError should be used for any errors related to data validation in regards to the user's input,
53
+ * This includes:
54
+ * - Invalid signatures
55
+ * - Malformed addresses
56
+ * - Invalid proof of possession
57
+ * - Invalid cryptographic parameters
58
+ * - Data format validation failures
59
+ */
60
+ declare class ValidationError extends SparkSDKError {
61
+ constructor(message: string, context?: {
62
+ field?: string;
63
+ value?: unknown;
64
+ expected?: unknown;
65
+ expectedLength?: number;
66
+ actualLength?: number;
67
+ rValue?: bigint;
68
+ fieldPrime?: bigint;
69
+ sValue?: bigint;
70
+ groupOrder?: bigint;
71
+ index?: number;
72
+ treeLength?: number;
73
+ addressNodesLength?: number;
74
+ }, originalError?: Error);
75
+ }
76
+ /**
77
+ * InternalValidationError should be used for any errors related to internal data validation
78
+ * that is not related to the user's input.
79
+ * This includes:
80
+ * - Invalid SO responses
81
+ */
82
+ declare class InternalValidationError extends SparkSDKError {
83
+ constructor(message: string, context?: {
84
+ field?: string;
85
+ value?: unknown;
86
+ expected?: unknown;
87
+ outputIndex?: number;
88
+ keyshareInfo?: unknown;
89
+ signingOperators?: unknown;
90
+ }, originalError?: Error);
91
+ }
92
+ /**
93
+ * AuthenticationError should be used specifically for authentication and authorization failures,
94
+ * such as invalid credentials or insufficient permissions.
95
+ * This includes:
96
+ * - Invalid API keys
97
+ * - Expired tokens
98
+ * - Insufficient permissions
99
+ * - Authentication token validation failures
100
+ * - Authorization failures
101
+ */
102
+ declare class AuthenticationError extends SparkSDKError {
103
+ constructor(message: string, context?: {
104
+ endpoint?: string;
105
+ reason?: string;
106
+ }, originalError?: Error);
107
+ }
108
+ /**
109
+ * RPCError should be used for errors that occur during RPC (Remote Procedure Call) operations,
110
+ * such as invalid RPC parameters or RPC-specific failures.
111
+ * This includes:
112
+ * - Invalid RPC method calls
113
+ * - RPC parameter validation failures
114
+ * - RPC-specific error codes
115
+ * - RPC protocol errors
116
+ */
117
+ declare class RPCError extends SparkSDKError {
118
+ constructor(message: string, context?: {
119
+ method?: string;
120
+ params?: unknown;
121
+ code?: number;
122
+ }, originalError?: Error);
123
+ }
124
+ /**
125
+ * ConfigurationError should be used for errors related to SDK configuration,
126
+ * such as missing or invalid configuration values.
127
+ * This includes:
128
+ * - Missing required configuration
129
+ * - Invalid configuration values
130
+ * - Configuration format errors
131
+ * - Environment-specific configuration issues
132
+ */
133
+ declare class ConfigurationError extends SparkSDKError {
134
+ constructor(message: string, context?: {
135
+ configKey?: string;
136
+ value?: unknown;
137
+ }, originalError?: Error);
138
+ }
139
+ /***
140
+ * NotImplementedError should be used for any errors related to features that are not yet implemented.
141
+ */
142
+ declare class NotImplementedError extends SparkSDKError {
143
+ constructor(message: string, context?: Record<string, unknown>, originalError?: Error);
144
+ }
145
+
146
+ interface FetchOwnedTokenOutputsParams {
147
+ ownerPublicKeys: Uint8Array[];
148
+ issuerPublicKeys?: Uint8Array[];
149
+ tokenIdentifiers?: Uint8Array[];
150
+ }
151
+ interface QueryTokenTransactionsParams {
152
+ ownerPublicKeys?: string[];
153
+ issuerPublicKeys?: string[];
154
+ tokenTransactionHashes?: string[];
155
+ tokenIdentifiers?: string[];
156
+ outputIds?: string[];
157
+ pageSize: number;
158
+ offset: number;
159
+ }
160
+ declare class TokenTransactionService {
161
+ protected readonly config: WalletConfigService;
162
+ protected readonly connectionManager: ConnectionManager;
163
+ constructor(config: WalletConfigService, connectionManager: ConnectionManager);
164
+ tokenTransfer(tokenOutputs: TokenOutputsMap, receiverOutputs: {
165
+ tokenIdentifier: Bech32mTokenIdentifier;
166
+ tokenAmount: bigint;
167
+ receiverSparkAddress: string;
168
+ }[], outputSelectionStrategy?: "SMALL_FIRST" | "LARGE_FIRST", selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
169
+ constructTransferTokenTransactionV0(selectedOutputs: OutputWithPreviousTransactionData[], tokenOutputData: Array<{
170
+ receiverSparkAddress: Uint8Array;
171
+ tokenPublicKey: Uint8Array;
172
+ tokenAmount: bigint;
173
+ }>): Promise<TokenTransaction>;
174
+ constructTransferTokenTransaction(selectedOutputs: OutputWithPreviousTransactionData[], tokenOutputData: Array<{
175
+ receiverSparkAddress: Uint8Array;
176
+ rawTokenIdentifier: Uint8Array;
177
+ tokenAmount: bigint;
178
+ }>): Promise<TokenTransaction$1>;
179
+ collectOperatorIdentityPublicKeys(): Uint8Array[];
180
+ broadcastTokenTransaction(tokenTransaction: TokenTransaction | TokenTransaction$1, outputsToSpendSigningPublicKeys?: Uint8Array[], outputsToSpendCommitments?: Uint8Array[]): Promise<string>;
181
+ private broadcastTokenTransactionV0;
182
+ private broadcastTokenTransactionV1;
183
+ private startTokenTransactionV0;
184
+ private startTokenTransaction;
185
+ private signTokenTransactionV0;
186
+ private signTokenTransaction;
187
+ fetchOwnedTokenOutputs(params: FetchOwnedTokenOutputsParams): Promise<OutputWithPreviousTransactionData[]>;
188
+ queryTokenTransactions(params: QueryTokenTransactionsParams): Promise<TokenTransactionWithStatus[] | TokenTransactionWithStatus$1[]>;
189
+ private fetchOwnedTokenOutputsV0;
190
+ private fetchOwnedTokenOutputsV1;
191
+ private queryTokenTransactionsV0;
192
+ private queryTokenTransactionsV1;
193
+ selectTokenOutputs(tokenOutputs: OutputWithPreviousTransactionData[], tokenAmount: bigint, strategy: "SMALL_FIRST" | "LARGE_FIRST"): OutputWithPreviousTransactionData[];
194
+ private sortTokenOutputsByStrategy;
195
+ private signMessageWithKey;
196
+ private finalizeTokenTransaction;
197
+ private createSignaturesForOperators;
198
+ }
199
+
200
+ export { AuthenticationError, Bech32mTokenIdentifier, ConfigurationError, ConnectionManager, InternalValidationError, NetworkError, NotImplementedError, RPCError, SparkSDKError, TokenOutputsMap, TokenTransactionService, ValidationError, WalletConfigService };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,200 @@
1
- export { AuthenticationError, ConfigurationError, InternalValidationError, NetworkError, NotImplementedError, RPCError, SparkSDKError, TokenTransactionService, ValidationError } from './index.node.js';
2
- export { B as Bech32mTokenIdentifier, a as Bech32mTokenIdentifierData, C as ConfigOptions, s as ConnectionManager, u as CreateLightningInvoiceParams, D as DecodedSparkAddressData, w as DepositParams, I as InitWalletResponse, L as LRC_WALLET_NETWORK, b as LRC_WALLET_NETWORK_TYPE, N as Network, c as NetworkToProto, d as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, S as SparkAddressData, e as SparkAddressFormat, o as SparkWallet, y as SparkWalletEvents, q as SparkWalletProps, r as TokenBalanceMap, x as TokenMetadataMap, T as TokenOutputsMap, v as TransferParams, U as UserTokenMetadata, t as WalletConfig, W as WalletConfigService, f as decodeBech32mTokenIdentifier, g as decodeSparkAddress, h as encodeBech32mTokenIdentifier, i as encodeSparkAddress, j as getNetwork, k as getNetworkFromAddress, l as getNetworkFromString, m as isValidPublicKey, n as isValidSparkAddress, p as protoToNetwork } from './spark-wallet-CxcGPXRB.js';
3
- export { B as BroadcastConfig, a as BroadcastResult, D as DEFAULT_FEE_SATS, F as FeeBumpTxChain, b as FeeBumpTxPackage, c as FeeRate, L as LeafInfo, T as TxChain, U as Utxo, d as addPrivateKeys, e as addPublicKeys, f as applyAdaptorToSignature, g as applyAdditiveTweakToPublicKey, h as checkIfSelectedOutputsAreAvailable, i as checkIfValidSequence, j as collectResponses, k as computeTaprootKeyNoScript, l as constructFeeBumpTx, m as constructUnilateralExitFeeBumpPackages, n as constructUnilateralExitTxs, o as createRefundTx, p as createSigningCommitment, q as createSigningNonce, r as decodeBytesToSigningCommitment, s as decodeBytesToSigningNonce, t as encodeSigningCommitmentToBytes, u as encodeSigningNonceToBytes, v as filterTokenBalanceForTokenPublicKey, w as generateAdaptorFromSignature, x as generateSignatureFromExistingAdaptor, y as getCurrentTimelock, z as getEphemeralAnchorOutput, A as getLatestDepositTxId, C as getNextTransactionSequence, E as getP2TRAddressFromPkScript, G as getP2TRAddressFromPublicKey, H as getP2TRScriptFromPublicKey, I as getP2WPKHAddressFromPublicKey, J as getRandomSigningNonce, K as getSigHashFromTx, M as getSigningCommitmentFromNonce, N as getSparkAddressFromTaproot, O as getTransactionSequence, P as getTransferPackageSigningPayload, Q as getTxFromRawTxBytes, R as getTxFromRawTxHex, S as getTxId, V as getTxIdNoReverse, W as isEphemeralAnchorOutput, X as isTxBroadcast, Y as lastKeyWithTarget, Z as maybeApplyFee, _ as proofOfPossessionMessageHashForDepositAddress, $ as subtractPrivateKeys, a0 as subtractPublicKeys, a1 as sumAvailableTokens, a2 as sumOfPrivateKeys, a3 as validateOutboundAdaptorSignature } from './xchain-address-Bh9w1SeC.js';
4
- export { ag as AggregateFrostParams, a2 as DefaultSparkSigner, ai as DerivedHDKey, a6 as KeyDerivation, ae as KeyDerivationType, aj as KeyPair, af as SignFrostParams, a9 as SigningCommitment, a7 as SigningCommitmentWithOptionalNonce, a8 as SigningNonce, a1 as SparkSigner, ah as SplitSecretWithProofsParams, ab as TaprootOutputKeysGenerator, ac as TaprootSparkSigner, ad as UnsafeStatelessSparkSigner, K as VerifiableSecretShare, M as bigIntToPrivateKey, N as computerLagrangeCoefficients, O as evaluatePolynomial, Q as fieldDiv, W as generatePolynomialForSecretSharing, X as getRandomBigInt, Y as modInverse, Z as recoverSecret, _ as splitSecret, $ as splitSecretWithProofs, a0 as validateShare } from './client-CGTRS23n.js';
1
+ import { W as WalletConfigService, C as ConnectionManager, u as TokenOutputsMap, B as Bech32mTokenIdentifier } from './spark-wallet-B2WwKN8W.js';
2
+ export { n as Bech32mTokenIdentifierData, b as ConfigOptions, r as CreateLightningInvoiceParams, D as DecodedSparkAddressData, s as DepositParams, I as InitWalletResponse, L as LRC_WALLET_NETWORK, k as LRC_WALLET_NETWORK_TYPE, N as Network, h as NetworkToProto, g as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, c as SparkAddressData, S as SparkAddressFormat, y as SparkWallet, x as SparkWalletEvents, w as SparkWalletProps, t as TokenBalanceMap, v as TokenMetadataMap, T as TransferParams, U as UserTokenMetadata, a as WalletConfig, q as decodeBech32mTokenIdentifier, d as decodeSparkAddress, o as encodeBech32mTokenIdentifier, e as encodeSparkAddress, j as getNetwork, l as getNetworkFromAddress, m as getNetworkFromString, f as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork } from './spark-wallet-B2WwKN8W.js';
3
+ export { ab as BroadcastConfig, ac as BroadcastResult, Q as DEFAULT_FEE_SATS, M as DIRECT_TIMELOCK_OFFSET, a9 as FeeBumpTxChain, a8 as FeeBumpTxPackage, a7 as FeeRate, O as INITIAL_DIRECT_SEQUENCE, N as INITIAL_SEQUENCE, a5 as LeafInfo, P as TEST_UNILATERAL_DIRECT_SEQUENCE, T as TEST_UNILATERAL_SEQUENCE, aa as TxChain, a6 as Utxo, q as addPrivateKeys, o as addPublicKeys, b as applyAdaptorToSignature, p as applyAdditiveTweakToPublicKey, J as checkIfSelectedOutputsAreAvailable, a1 as checkIfValidSequence, z as collectResponses, c as computeTaprootKeyNoScript, ag as constructFeeBumpTx, af as constructUnilateralExitFeeBumpPackages, ae as constructUnilateralExitTxs, _ as createConnectorRefundTransactions, X as createLeafNodeTx, V as createNodeTx, W as createNodeTxs, Y as createRefundTx, Z as createRefundTxs, S as createRootTx, F as createSigningCommitment, B as createSigningNonce, U as createSplitTx, H as decodeBytesToSigningCommitment, E as decodeBytesToSigningNonce, a2 as doesLeafNeedRefresh, G as encodeSigningCommitmentToBytes, D as encodeSigningNonceToBytes, K as filterTokenBalanceForTokenPublicKey, a as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, $ as getCurrentTimelock, a4 as getEphemeralAnchorOutput, w as getLatestDepositTxId, a3 as getNextTransactionSequence, f as getP2TRAddressFromPkScript, e as getP2TRAddressFromPublicKey, d as getP2TRScriptFromPublicKey, h as getP2WPKHAddressFromPublicKey, A as getRandomSigningNonce, k as getSigHashFromTx, C as getSigningCommitmentFromNonce, ah as getSparkAddressFromTaproot, a0 as getTransactionSequence, L as getTransferPackageSigningPayload, n as getTxEstimatedVbytesSizeByNumberOfInputsOutputs, j as getTxFromRawTxBytes, i as getTxFromRawTxHex, l as getTxId, m as getTxIdNoReverse, ad as isEphemeralAnchorOutput, x as isTxBroadcast, u as lastKeyWithTarget, R as maybeApplyFee, y as proofOfPossessionMessageHashForDepositAddress, r as subtractPrivateKeys, s as subtractPublicKeys, I as sumAvailableTokens, t as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './xchain-address-BsveIy5l.js';
4
+ export { A as AggregateFrostParams, D as DefaultSparkSigner, p as DerivedHDKey, l as KeyDerivation, K as KeyDerivationType, q as KeyPair, n as SignFrostParams, k as SigningCommitment, i as SigningCommitmentWithOptionalNonce, j as SigningNonce, S as SparkSigner, o as SplitSecretWithProofsParams, T as TaprootOutputKeysGenerator, a as TaprootSparkSigner, U as UnsafeStatelessSparkSigner, V as VerifiableSecretShare, h as bigIntToPrivateKey, c as computerLagrangeCoefficients, e as evaluatePolynomial, f as fieldDiv, b as generatePolynomialForSecretSharing, g as getRandomBigInt, m as modInverse, r as recoverSecret, s as splitSecret, d as splitSecretWithProofs, v as validateShare } from './client-Dg6vS_2I.js';
5
+ import { f as OutputWithPreviousTransactionData, T as TokenTransaction, k as TokenTransactionWithStatus } from './spark-ESAfZARg.js';
6
+ import { TokenTransaction as TokenTransaction$1, TokenTransactionWithStatus as TokenTransactionWithStatus$1 } from './proto/spark_token.js';
5
7
  export { TokenSigner } from '@buildonspark/lrc20-sdk';
6
8
  export { MultisigReceiptInput } from '@buildonspark/lrc20-sdk/lrc/types';
7
- import './spark-B_7nZx6T.js';
8
- import '@bufbuild/protobuf/wire';
9
- import 'nice-grpc-common';
10
- import './proto/spark_token.js';
11
9
  import '@scure/btc-signer';
12
10
  import 'bitcoinjs-lib';
13
11
  import 'nice-grpc';
14
12
  import 'nice-grpc-web';
13
+ import '@bufbuild/protobuf/wire';
14
+ import 'nice-grpc-common';
15
15
  import 'eventemitter3';
16
- import './sdk-types-CkRNraXT.js';
17
16
  import '@scure/btc-signer/psbt';
18
17
  import '@lightsparkdev/core';
19
18
  import '@scure/bip32';
20
19
  import './types-BADxR3bm.js';
20
+
21
+ declare class SparkSDKError extends Error {
22
+ readonly context: Record<string, unknown>;
23
+ readonly originalError?: Error;
24
+ constructor(message: string, context?: Record<string, unknown>, originalError?: Error);
25
+ toString(): string;
26
+ toJSON(): Record<string, unknown>;
27
+ }
28
+
29
+ /**
30
+ * NetworkError should be used for any errors related to network communication,
31
+ * such as failed HTTP requests, timeouts, or connection issues.
32
+ * This includes:
33
+ * - Failed API calls
34
+ * - Network timeouts
35
+ * - Connection refused
36
+ * - DNS resolution failures
37
+ * - SSL/TLS errors
38
+ */
39
+ declare class NetworkError extends SparkSDKError {
40
+ constructor(message: string, context?: {
41
+ url?: string;
42
+ method?: string;
43
+ statusCode?: number;
44
+ response?: unknown;
45
+ errorCount?: number;
46
+ errors?: string;
47
+ operation?: string;
48
+ nodeSignaturesCount?: number;
49
+ }, originalError?: Error);
50
+ }
51
+ /**
52
+ * ValidationError should be used for any errors related to data validation in regards to the user's input,
53
+ * This includes:
54
+ * - Invalid signatures
55
+ * - Malformed addresses
56
+ * - Invalid proof of possession
57
+ * - Invalid cryptographic parameters
58
+ * - Data format validation failures
59
+ */
60
+ declare class ValidationError extends SparkSDKError {
61
+ constructor(message: string, context?: {
62
+ field?: string;
63
+ value?: unknown;
64
+ expected?: unknown;
65
+ expectedLength?: number;
66
+ actualLength?: number;
67
+ rValue?: bigint;
68
+ fieldPrime?: bigint;
69
+ sValue?: bigint;
70
+ groupOrder?: bigint;
71
+ index?: number;
72
+ treeLength?: number;
73
+ addressNodesLength?: number;
74
+ }, originalError?: Error);
75
+ }
76
+ /**
77
+ * InternalValidationError should be used for any errors related to internal data validation
78
+ * that is not related to the user's input.
79
+ * This includes:
80
+ * - Invalid SO responses
81
+ */
82
+ declare class InternalValidationError extends SparkSDKError {
83
+ constructor(message: string, context?: {
84
+ field?: string;
85
+ value?: unknown;
86
+ expected?: unknown;
87
+ outputIndex?: number;
88
+ keyshareInfo?: unknown;
89
+ signingOperators?: unknown;
90
+ }, originalError?: Error);
91
+ }
92
+ /**
93
+ * AuthenticationError should be used specifically for authentication and authorization failures,
94
+ * such as invalid credentials or insufficient permissions.
95
+ * This includes:
96
+ * - Invalid API keys
97
+ * - Expired tokens
98
+ * - Insufficient permissions
99
+ * - Authentication token validation failures
100
+ * - Authorization failures
101
+ */
102
+ declare class AuthenticationError extends SparkSDKError {
103
+ constructor(message: string, context?: {
104
+ endpoint?: string;
105
+ reason?: string;
106
+ }, originalError?: Error);
107
+ }
108
+ /**
109
+ * RPCError should be used for errors that occur during RPC (Remote Procedure Call) operations,
110
+ * such as invalid RPC parameters or RPC-specific failures.
111
+ * This includes:
112
+ * - Invalid RPC method calls
113
+ * - RPC parameter validation failures
114
+ * - RPC-specific error codes
115
+ * - RPC protocol errors
116
+ */
117
+ declare class RPCError extends SparkSDKError {
118
+ constructor(message: string, context?: {
119
+ method?: string;
120
+ params?: unknown;
121
+ code?: number;
122
+ }, originalError?: Error);
123
+ }
124
+ /**
125
+ * ConfigurationError should be used for errors related to SDK configuration,
126
+ * such as missing or invalid configuration values.
127
+ * This includes:
128
+ * - Missing required configuration
129
+ * - Invalid configuration values
130
+ * - Configuration format errors
131
+ * - Environment-specific configuration issues
132
+ */
133
+ declare class ConfigurationError extends SparkSDKError {
134
+ constructor(message: string, context?: {
135
+ configKey?: string;
136
+ value?: unknown;
137
+ }, originalError?: Error);
138
+ }
139
+ /***
140
+ * NotImplementedError should be used for any errors related to features that are not yet implemented.
141
+ */
142
+ declare class NotImplementedError extends SparkSDKError {
143
+ constructor(message: string, context?: Record<string, unknown>, originalError?: Error);
144
+ }
145
+
146
+ interface FetchOwnedTokenOutputsParams {
147
+ ownerPublicKeys: Uint8Array[];
148
+ issuerPublicKeys?: Uint8Array[];
149
+ tokenIdentifiers?: Uint8Array[];
150
+ }
151
+ interface QueryTokenTransactionsParams {
152
+ ownerPublicKeys?: string[];
153
+ issuerPublicKeys?: string[];
154
+ tokenTransactionHashes?: string[];
155
+ tokenIdentifiers?: string[];
156
+ outputIds?: string[];
157
+ pageSize: number;
158
+ offset: number;
159
+ }
160
+ declare class TokenTransactionService {
161
+ protected readonly config: WalletConfigService;
162
+ protected readonly connectionManager: ConnectionManager;
163
+ constructor(config: WalletConfigService, connectionManager: ConnectionManager);
164
+ tokenTransfer(tokenOutputs: TokenOutputsMap, receiverOutputs: {
165
+ tokenIdentifier: Bech32mTokenIdentifier;
166
+ tokenAmount: bigint;
167
+ receiverSparkAddress: string;
168
+ }[], outputSelectionStrategy?: "SMALL_FIRST" | "LARGE_FIRST", selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
169
+ constructTransferTokenTransactionV0(selectedOutputs: OutputWithPreviousTransactionData[], tokenOutputData: Array<{
170
+ receiverSparkAddress: Uint8Array;
171
+ tokenPublicKey: Uint8Array;
172
+ tokenAmount: bigint;
173
+ }>): Promise<TokenTransaction>;
174
+ constructTransferTokenTransaction(selectedOutputs: OutputWithPreviousTransactionData[], tokenOutputData: Array<{
175
+ receiverSparkAddress: Uint8Array;
176
+ rawTokenIdentifier: Uint8Array;
177
+ tokenAmount: bigint;
178
+ }>): Promise<TokenTransaction$1>;
179
+ collectOperatorIdentityPublicKeys(): Uint8Array[];
180
+ broadcastTokenTransaction(tokenTransaction: TokenTransaction | TokenTransaction$1, outputsToSpendSigningPublicKeys?: Uint8Array[], outputsToSpendCommitments?: Uint8Array[]): Promise<string>;
181
+ private broadcastTokenTransactionV0;
182
+ private broadcastTokenTransactionV1;
183
+ private startTokenTransactionV0;
184
+ private startTokenTransaction;
185
+ private signTokenTransactionV0;
186
+ private signTokenTransaction;
187
+ fetchOwnedTokenOutputs(params: FetchOwnedTokenOutputsParams): Promise<OutputWithPreviousTransactionData[]>;
188
+ queryTokenTransactions(params: QueryTokenTransactionsParams): Promise<TokenTransactionWithStatus[] | TokenTransactionWithStatus$1[]>;
189
+ private fetchOwnedTokenOutputsV0;
190
+ private fetchOwnedTokenOutputsV1;
191
+ private queryTokenTransactionsV0;
192
+ private queryTokenTransactionsV1;
193
+ selectTokenOutputs(tokenOutputs: OutputWithPreviousTransactionData[], tokenAmount: bigint, strategy: "SMALL_FIRST" | "LARGE_FIRST"): OutputWithPreviousTransactionData[];
194
+ private sortTokenOutputsByStrategy;
195
+ private signMessageWithKey;
196
+ private finalizeTokenTransaction;
197
+ private createSignaturesForOperators;
198
+ }
199
+
200
+ export { AuthenticationError, Bech32mTokenIdentifier, ConfigurationError, ConnectionManager, InternalValidationError, NetworkError, NotImplementedError, RPCError, SparkSDKError, TokenOutputsMap, TokenTransactionService, ValidationError, WalletConfigService };
package/dist/index.js CHANGED
@@ -1,10 +1,13 @@
1
- import "./chunk-PTRXJS7Q.js";
1
+ import "./chunk-LQZL2D3Y.js";
2
2
  import "./chunk-BYXBJQAS.js";
3
3
  import {
4
4
  AuthenticationError,
5
5
  ConfigurationError,
6
6
  DEFAULT_FEE_SATS,
7
+ DIRECT_TIMELOCK_OFFSET,
7
8
  DefaultSparkSigner,
9
+ INITIAL_DIRECT_SEQUENCE,
10
+ INITIAL_SEQUENCE,
8
11
  InternalValidationError,
9
12
  KeyDerivationType,
10
13
  LRC_WALLET_NETWORK,
@@ -17,6 +20,8 @@ import {
17
20
  RPCError,
18
21
  SparkSDKError,
19
22
  SparkWallet,
23
+ TEST_UNILATERAL_DIRECT_SEQUENCE,
24
+ TEST_UNILATERAL_SEQUENCE,
20
25
  TaprootOutputKeysGenerator,
21
26
  TaprootSparkSigner,
22
27
  TokenTransactionService,
@@ -36,13 +41,21 @@ import {
36
41
  constructFeeBumpTx,
37
42
  constructUnilateralExitFeeBumpPackages,
38
43
  constructUnilateralExitTxs,
44
+ createConnectorRefundTransactions,
45
+ createLeafNodeTx,
46
+ createNodeTx,
47
+ createNodeTxs,
39
48
  createRefundTx,
49
+ createRefundTxs,
50
+ createRootTx,
40
51
  createSigningCommitment,
41
52
  createSigningNonce,
53
+ createSplitTx,
42
54
  decodeBech32mTokenIdentifier,
43
55
  decodeBytesToSigningCommitment,
44
56
  decodeBytesToSigningNonce,
45
57
  decodeSparkAddress,
58
+ doesLeafNeedRefresh,
46
59
  encodeBech32mTokenIdentifier,
47
60
  encodeSigningCommitmentToBytes,
48
61
  encodeSigningNonceToBytes,
@@ -71,6 +84,7 @@ import {
71
84
  getSparkAddressFromTaproot,
72
85
  getTransactionSequence,
73
86
  getTransferPackageSigningPayload,
87
+ getTxEstimatedVbytesSizeByNumberOfInputsOutputs,
74
88
  getTxFromRawTxBytes,
75
89
  getTxFromRawTxHex,
76
90
  getTxId,
@@ -93,17 +107,20 @@ import {
93
107
  sumOfPrivateKeys,
94
108
  validateOutboundAdaptorSignature,
95
109
  validateShare
96
- } from "./chunk-PLLJIZC3.js";
110
+ } from "./chunk-U7LRIWTF.js";
97
111
  import "./chunk-G4MSZ6DE.js";
98
- import "./chunk-3SEOTO43.js";
99
- import "./chunk-CDLETEDT.js";
112
+ import "./chunk-3SPMJMUX.js";
113
+ import "./chunk-CQY5ML2A.js";
100
114
  import "./chunk-AAZWSPUK.js";
101
115
  import "./chunk-MVRQ5US7.js";
102
116
  export {
103
117
  AuthenticationError,
104
118
  ConfigurationError,
105
119
  DEFAULT_FEE_SATS,
120
+ DIRECT_TIMELOCK_OFFSET,
106
121
  DefaultSparkSigner,
122
+ INITIAL_DIRECT_SEQUENCE,
123
+ INITIAL_SEQUENCE,
107
124
  InternalValidationError,
108
125
  KeyDerivationType,
109
126
  LRC_WALLET_NETWORK,
@@ -116,6 +133,8 @@ export {
116
133
  RPCError,
117
134
  SparkSDKError,
118
135
  SparkWallet,
136
+ TEST_UNILATERAL_DIRECT_SEQUENCE,
137
+ TEST_UNILATERAL_SEQUENCE,
119
138
  TaprootOutputKeysGenerator,
120
139
  TaprootSparkSigner,
121
140
  TokenTransactionService,
@@ -135,13 +154,21 @@ export {
135
154
  constructFeeBumpTx,
136
155
  constructUnilateralExitFeeBumpPackages,
137
156
  constructUnilateralExitTxs,
157
+ createConnectorRefundTransactions,
158
+ createLeafNodeTx,
159
+ createNodeTx,
160
+ createNodeTxs,
138
161
  createRefundTx,
162
+ createRefundTxs,
163
+ createRootTx,
139
164
  createSigningCommitment,
140
165
  createSigningNonce,
166
+ createSplitTx,
141
167
  decodeBech32mTokenIdentifier,
142
168
  decodeBytesToSigningCommitment,
143
169
  decodeBytesToSigningNonce,
144
170
  decodeSparkAddress,
171
+ doesLeafNeedRefresh,
145
172
  encodeBech32mTokenIdentifier,
146
173
  encodeSigningCommitmentToBytes,
147
174
  encodeSigningNonceToBytes,
@@ -170,6 +197,7 @@ export {
170
197
  getSparkAddressFromTaproot,
171
198
  getTransactionSequence,
172
199
  getTransferPackageSigningPayload,
200
+ getTxEstimatedVbytesSizeByNumberOfInputsOutputs,
173
201
  getTxFromRawTxBytes,
174
202
  getTxFromRawTxHex,
175
203
  getTxId,