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