@buildonspark/spark-sdk 0.1.44 → 0.1.46
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 +17 -0
- package/dist/{RequestLightningSendInput-BxbCtwpV.d.cts → RequestLightningSendInput-2cSh_In4.d.cts} +1 -1
- package/dist/{RequestLightningSendInput-RGel43ks.d.ts → RequestLightningSendInput-CN6BNg_g.d.ts} +1 -1
- package/dist/address/index.cjs +2 -2
- package/dist/address/index.d.cts +2 -2
- package/dist/address/index.d.ts +2 -2
- package/dist/address/index.js +2 -2
- package/dist/{chunk-EKFD62HN.js → chunk-4EMV7HHW.js} +2 -1
- package/dist/{chunk-4Q2ZDYYU.js → chunk-BGGEVUJK.js} +1157 -208
- package/dist/{chunk-CIZNCBKE.js → chunk-C2S227QR.js} +648 -45
- package/dist/{chunk-WPTRVD2V.js → chunk-DXR2PXJU.js} +15 -15
- package/dist/{chunk-NBCNYDWJ.js → chunk-HHNQ3ZHC.js} +2 -2
- package/dist/{chunk-DAXGVPVM.js → chunk-HSCLBJEL.js} +2 -2
- package/dist/{chunk-6AFUC5M2.js → chunk-HWJWKEIU.js} +8 -2
- package/dist/{chunk-A2ZLMH6I.js → chunk-JB64OQES.js} +259 -327
- package/dist/{chunk-KEKGSH7B.js → chunk-KMUMFYFX.js} +3 -3
- package/dist/chunk-LHRD2WT6.js +2374 -0
- package/dist/{chunk-HTMXTJRK.js → chunk-N5VZVCGJ.js} +4 -4
- package/dist/{chunk-SQKXGAIR.js → chunk-NTFKFRQ2.js} +1 -1
- package/dist/{chunk-K4BJARWM.js → chunk-OBFKIEMP.js} +1 -1
- package/dist/{chunk-UBT6EDVJ.js → chunk-OFCJFZ4I.js} +1 -1
- package/dist/{chunk-XX4RRWOX.js → chunk-UXDODSDT.js} +8 -10
- package/dist/graphql/objects/index.d.cts +5 -4
- package/dist/graphql/objects/index.d.ts +5 -4
- package/dist/index-CKL5DodV.d.cts +214 -0
- package/dist/index-COm59SPw.d.ts +214 -0
- package/dist/index.cjs +4026 -1315
- package/dist/index.d.cts +764 -19
- package/dist/index.d.ts +764 -19
- package/dist/index.js +23 -27
- package/dist/index.node.cjs +4026 -1319
- package/dist/index.node.d.cts +10 -8
- package/dist/index.node.d.ts +10 -8
- package/dist/index.node.js +23 -31
- package/dist/native/index.cjs +4027 -1316
- package/dist/native/index.d.cts +281 -85
- package/dist/native/index.d.ts +281 -85
- package/dist/native/index.js +4018 -1307
- package/dist/{network-CfxLnaot.d.cts → network-Css46DAz.d.cts} +1 -1
- package/dist/{network-CroCOQ0B.d.ts → network-hynb7iTZ.d.ts} +1 -1
- package/dist/proto/lrc20.cjs +222 -19
- package/dist/proto/lrc20.d.cts +1 -1
- package/dist/proto/lrc20.d.ts +1 -1
- package/dist/proto/lrc20.js +2 -2
- package/dist/proto/spark.cjs +1154 -205
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark.js +3 -1
- package/dist/proto/spark_token.cjs +1377 -58
- package/dist/proto/spark_token.d.cts +153 -15
- package/dist/proto/spark_token.d.ts +153 -15
- package/dist/proto/spark_token.js +40 -4
- package/dist/{sdk-types-CTbTdDbE.d.ts → sdk-types-CKBsylfW.d.ts} +1 -1
- package/dist/{sdk-types-BeCBoozO.d.cts → sdk-types-Ct8xmN7l.d.cts} +1 -1
- package/dist/services/config.cjs +2 -2
- package/dist/services/config.d.cts +5 -4
- package/dist/services/config.d.ts +5 -4
- package/dist/services/config.js +6 -6
- package/dist/services/connection.cjs +2438 -262
- package/dist/services/connection.d.cts +5 -4
- package/dist/services/connection.d.ts +5 -4
- package/dist/services/connection.js +4 -4
- package/dist/services/index.cjs +5937 -3154
- package/dist/services/index.d.cts +7 -6
- package/dist/services/index.d.ts +7 -6
- package/dist/services/index.js +17 -15
- package/dist/services/lrc-connection.cjs +223 -20
- package/dist/services/lrc-connection.d.cts +5 -4
- package/dist/services/lrc-connection.d.ts +5 -4
- package/dist/services/lrc-connection.js +4 -4
- package/dist/services/token-transactions.cjs +840 -236
- package/dist/services/token-transactions.d.cts +25 -7
- package/dist/services/token-transactions.d.ts +25 -7
- package/dist/services/token-transactions.js +5 -4
- package/dist/services/wallet-config.cjs +3 -1
- package/dist/services/wallet-config.d.cts +7 -5
- package/dist/services/wallet-config.d.ts +7 -5
- package/dist/services/wallet-config.js +3 -1
- package/dist/signer/signer.cjs +1 -1
- package/dist/signer/signer.d.cts +3 -2
- package/dist/signer/signer.d.ts +3 -2
- package/dist/signer/signer.js +2 -2
- package/dist/{signer-D7vfYik9.d.ts → signer-BP6F__oR.d.cts} +2 -6
- package/dist/{signer-DaY8c60s.d.cts → signer-BVZJXcq7.d.ts} +2 -6
- package/dist/{spark-C4ZrsgjC.d.cts → spark-DbzGfse6.d.cts} +93 -15
- package/dist/{spark-C4ZrsgjC.d.ts → spark-DbzGfse6.d.ts} +93 -15
- package/dist/spark_bindings/native/index.cjs +183 -0
- package/dist/spark_bindings/native/index.d.cts +14 -0
- package/dist/spark_bindings/native/index.d.ts +14 -0
- package/dist/spark_bindings/native/index.js +141 -0
- package/dist/spark_bindings/wasm/index.cjs +1093 -0
- package/dist/spark_bindings/wasm/index.d.cts +47 -0
- package/dist/spark_bindings/wasm/index.d.ts +47 -0
- package/dist/{chunk-K4C4W5FC.js → spark_bindings/wasm/index.js} +7 -6
- package/dist/types/index.cjs +1156 -208
- package/dist/types/index.d.cts +5 -4
- package/dist/types/index.d.ts +5 -4
- package/dist/types/index.js +2 -2
- package/dist/types-C-Rp0Oo7.d.cts +46 -0
- package/dist/types-C-Rp0Oo7.d.ts +46 -0
- package/dist/utils/index.cjs +65 -13
- package/dist/utils/index.d.cts +14 -134
- package/dist/utils/index.d.ts +14 -134
- package/dist/utils/index.js +13 -13
- package/package.json +22 -2
- package/src/index.node.ts +0 -1
- package/src/index.ts +0 -1
- package/src/native/index.ts +1 -2
- package/src/proto/common.ts +5 -5
- package/src/proto/google/protobuf/descriptor.ts +34 -34
- package/src/proto/google/protobuf/duration.ts +2 -2
- package/src/proto/google/protobuf/empty.ts +2 -2
- package/src/proto/google/protobuf/timestamp.ts +2 -2
- package/src/proto/mock.ts +4 -4
- package/src/proto/spark.ts +1452 -185
- package/src/proto/spark_authn.ts +7 -7
- package/src/proto/spark_token.ts +1668 -105
- package/src/proto/validate/validate.ts +24 -24
- package/src/services/bolt11-spark.ts +62 -187
- package/src/services/coop-exit.ts +3 -0
- package/src/services/lrc20.ts +1 -1
- package/src/services/token-transactions.ts +197 -9
- package/src/services/transfer.ts +22 -0
- package/src/services/tree-creation.ts +13 -0
- package/src/services/wallet-config.ts +2 -2
- package/src/spark-wallet/spark-wallet.node.ts +0 -4
- package/src/spark-wallet/spark-wallet.ts +76 -108
- package/src/spark-wallet/types.ts +39 -3
- package/src/tests/bolt11-spark.test.ts +7 -15
- package/src/tests/integration/ssp/coop-exit.test.ts +7 -7
- package/src/tests/integration/swap.test.ts +453 -433
- package/src/tests/integration/transfer.test.ts +261 -248
- package/src/tests/token-identifier.test.ts +54 -0
- package/src/tests/tokens.test.ts +218 -23
- package/src/utils/token-hashing.ts +320 -44
- package/src/utils/token-identifier.ts +88 -0
- package/src/utils/token-transaction-validation.ts +350 -5
- package/src/utils/token-transactions.ts +12 -8
- package/src/utils/transaction.ts +0 -6
- package/dist/chunk-B3AMIGJG.js +0 -1073
- package/dist/index-CZmDdSts.d.cts +0 -829
- package/dist/index-ClIRO_3y.d.ts +0 -829
- package/dist/wasm-7OWFHDMS.js +0 -21
package/dist/index.d.cts
CHANGED
|
@@ -1,28 +1,773 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
import './
|
|
1
|
+
import { m as LeavesSwapFeeEstimateOutput, D as StaticDepositQuoteOutput, C as ClaimStaticDepositOutput, q as LightningReceiveRequest, u as LightningSendRequest, E as ExitSpeed, f as CoopExitFeeQuote, i as CoopExitRequest, T as Transfer$1 } from './RequestLightningSendInput-2cSh_In4.cjs';
|
|
2
|
+
import { L as LightningSendFeeEstimateInput } from './LightningSendFeeEstimateInput-BgOhEAI-.cjs';
|
|
3
|
+
import { h as SigningCommitment, V as VerifiableSecretShare, S as SparkSigner } from './signer-BP6F__oR.cjs';
|
|
4
|
+
export { d as bigIntToPrivateKey, c as computerLagrangeCoefficients, e as evaluatePolynomial, f as fieldDiv, a as generatePolynomialForSecretSharing, g as getRandomBigInt, m as modInverse, r as recoverSecret, s as splitSecret, b as splitSecretWithProofs, v as validateShare } from './signer-BP6F__oR.cjs';
|
|
5
|
+
import { h as RequestedSigningCommitments, U as UserSignedTxSigningJob, b as TreeNode, e as Transfer, L as LeafRefundTxSigningResult, i as NodeSignatures, F as FinalizeNodeSignaturesResponse, Q as QueryTransfersResponse, j as OutputWithPreviousTransactionData } from './spark-DbzGfse6.cjs';
|
|
6
|
+
import { WalletConfigService } from './services/config.cjs';
|
|
7
|
+
import { ConnectionManager } from './services/connection.cjs';
|
|
8
|
+
import { Lrc20ConnectionManager } from './services/lrc-connection.cjs';
|
|
9
|
+
import { Transaction } from '@scure/btc-signer';
|
|
10
|
+
import { ConfigOptions } from './services/wallet-config.cjs';
|
|
11
|
+
import { LRCWallet } from '@buildonspark/lrc20-sdk';
|
|
12
|
+
import { EventEmitter } from 'eventemitter3';
|
|
13
|
+
import { SparkAddressFormat } from './address/index.cjs';
|
|
14
|
+
import { a as WalletTransfer, W as WalletLeaf } from './sdk-types-Ct8xmN7l.cjs';
|
|
15
|
+
import { S as SparkWalletProps, I as InitWalletResponse, b as TokenBalanceMap, T as TransferParams, C as CreateLightningInvoiceParams, P as PayLightningInvoiceParams } from './index-CKL5DodV.cjs';
|
|
16
|
+
export { a6 as BroadcastConfig, a7 as BroadcastResult, U as DEFAULT_FEE_SATS, a4 as FeeBumpTxChain, a3 as FeeBumpTxPackage, a2 as FeeRate, a0 as LeafInfo, a5 as TxChain, a1 as Utxo, t as addPrivateKeys, q as addPublicKeys, e as applyAdaptorToSignature, r as applyAdditiveTweakToPublicKey, N as calculateAvailableTokenAmount, O as checkIfSelectedOutputsAreAvailable, Z as checkIfValidSequence, B as collectResponses, f as computeTaprootKeyNoScript, ab as constructFeeBumpTx, aa as constructUnilateralExitFeeBumpPackages, a9 as constructUnilateralExitTxs, W as createRefundTx, K as createSigningCommitment, F as createSigningNonce, M as decodeBytesToSigningCommitment, J as decodeBytesToSigningNonce, L as encodeSigningCommitmentToBytes, H as encodeSigningNonceToBytes, Q as filterTokenBalanceForTokenPublicKey, d as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, X as getCurrentTimelock, $ as getEphemeralAnchorOutput, y as getLatestDepositTxId, _ as getNextTransactionSequence, j as getP2TRAddressFromPkScript, i as getP2TRAddressFromPublicKey, h as getP2TRScriptFromPublicKey, k as getP2WPKHAddressFromPublicKey, E as getRandomSigningNonce, n as getSigHashFromTx, G as getSigningCommitmentFromNonce, ac as getSparkAddressFromTaproot, Y as getTransactionSequence, R as getTransferPackageSigningPayload, m as getTxFromRawTxBytes, l as getTxFromRawTxHex, o as getTxId, p as getTxIdNoReverse, a8 as isEphemeralAnchorOutput, z as isTxBroadcast, x as lastKeyWithTarget, V as maybeApplyFee, A as proofOfPossessionMessageHashForDepositAddress, u as subtractPrivateKeys, s as subtractPublicKeys, w as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './index-CKL5DodV.cjs';
|
|
17
|
+
import { TokenTransactionWithStatus } from './proto/spark_token.cjs';
|
|
18
|
+
export { L as LRC_WALLET_NETWORK, c as LRC_WALLET_NETWORK_TYPE, N as Network, b as NetworkToProto, a as NetworkType, g as getNetwork, d as getNetworkFromAddress, e as getNetworkFromString } from './network-Css46DAz.cjs';
|
|
6
19
|
import '@lightsparkdev/core';
|
|
7
20
|
import './BitcoinNetwork-TnABML0T.cjs';
|
|
8
|
-
import './LightningSendFeeEstimateInput-BgOhEAI-.cjs';
|
|
9
|
-
import './spark-C4ZrsgjC.cjs';
|
|
10
|
-
import '@bufbuild/protobuf/wire';
|
|
11
|
-
import 'nice-grpc-common';
|
|
12
|
-
import './services/config.cjs';
|
|
13
|
-
import '@buildonspark/lrc20-sdk';
|
|
14
|
-
import './services/wallet-config.cjs';
|
|
15
21
|
import '@scure/bip32';
|
|
16
|
-
import '
|
|
22
|
+
import './types-C-Rp0Oo7.cjs';
|
|
17
23
|
import 'bitcoinjs-lib';
|
|
18
24
|
import '@buildonspark/lrc20-sdk/lrc/types';
|
|
19
|
-
import '
|
|
25
|
+
import '@bufbuild/protobuf/wire';
|
|
26
|
+
import 'nice-grpc-common';
|
|
20
27
|
import 'nice-grpc';
|
|
21
28
|
import 'nice-grpc-web';
|
|
22
|
-
import './proto/spark_token.cjs';
|
|
23
|
-
import './services/lrc-connection.cjs';
|
|
24
29
|
import './proto/lrc20.cjs';
|
|
25
|
-
import 'eventemitter3';
|
|
26
|
-
import './address/index.cjs';
|
|
27
|
-
import './sdk-types-BeCBoozO.cjs';
|
|
28
30
|
import '@scure/btc-signer/psbt';
|
|
31
|
+
|
|
32
|
+
declare class SparkSDKError extends Error {
|
|
33
|
+
readonly context: Record<string, unknown>;
|
|
34
|
+
readonly originalError?: Error;
|
|
35
|
+
constructor(message: string, context?: Record<string, unknown>, originalError?: Error);
|
|
36
|
+
toString(): string;
|
|
37
|
+
toJSON(): Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* NetworkError should be used for any errors related to network communication,
|
|
42
|
+
* such as failed HTTP requests, timeouts, or connection issues.
|
|
43
|
+
* This includes:
|
|
44
|
+
* - Failed API calls
|
|
45
|
+
* - Network timeouts
|
|
46
|
+
* - Connection refused
|
|
47
|
+
* - DNS resolution failures
|
|
48
|
+
* - SSL/TLS errors
|
|
49
|
+
*/
|
|
50
|
+
declare class NetworkError extends SparkSDKError {
|
|
51
|
+
constructor(message: string, context?: {
|
|
52
|
+
url?: string;
|
|
53
|
+
method?: string;
|
|
54
|
+
statusCode?: number;
|
|
55
|
+
response?: unknown;
|
|
56
|
+
errorCount?: number;
|
|
57
|
+
errors?: string;
|
|
58
|
+
operation?: string;
|
|
59
|
+
nodeSignaturesCount?: number;
|
|
60
|
+
}, originalError?: Error);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* ValidationError should be used for any errors related to data validation in regards to the user's input,
|
|
64
|
+
* This includes:
|
|
65
|
+
* - Invalid signatures
|
|
66
|
+
* - Malformed addresses
|
|
67
|
+
* - Invalid proof of possession
|
|
68
|
+
* - Invalid cryptographic parameters
|
|
69
|
+
* - Data format validation failures
|
|
70
|
+
*/
|
|
71
|
+
declare class ValidationError extends SparkSDKError {
|
|
72
|
+
constructor(message: string, context?: {
|
|
73
|
+
field?: string;
|
|
74
|
+
value?: unknown;
|
|
75
|
+
expected?: unknown;
|
|
76
|
+
expectedLength?: number;
|
|
77
|
+
actualLength?: number;
|
|
78
|
+
rValue?: bigint;
|
|
79
|
+
fieldPrime?: bigint;
|
|
80
|
+
sValue?: bigint;
|
|
81
|
+
groupOrder?: bigint;
|
|
82
|
+
index?: number;
|
|
83
|
+
treeLength?: number;
|
|
84
|
+
addressNodesLength?: number;
|
|
85
|
+
}, originalError?: Error);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* InternalValidationError should be used for any errors related to internal data validation
|
|
89
|
+
* that is not related to the user's input.
|
|
90
|
+
* This includes:
|
|
91
|
+
* - Invalid SO responses
|
|
92
|
+
*/
|
|
93
|
+
declare class InternalValidationError extends SparkSDKError {
|
|
94
|
+
constructor(message: string, context?: {
|
|
95
|
+
field?: string;
|
|
96
|
+
value?: unknown;
|
|
97
|
+
expected?: unknown;
|
|
98
|
+
outputIndex?: number;
|
|
99
|
+
keyshareInfo?: unknown;
|
|
100
|
+
signingOperators?: unknown;
|
|
101
|
+
}, originalError?: Error);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* AuthenticationError should be used specifically for authentication and authorization failures,
|
|
105
|
+
* such as invalid credentials or insufficient permissions.
|
|
106
|
+
* This includes:
|
|
107
|
+
* - Invalid API keys
|
|
108
|
+
* - Expired tokens
|
|
109
|
+
* - Insufficient permissions
|
|
110
|
+
* - Authentication token validation failures
|
|
111
|
+
* - Authorization failures
|
|
112
|
+
*/
|
|
113
|
+
declare class AuthenticationError extends SparkSDKError {
|
|
114
|
+
constructor(message: string, context?: {
|
|
115
|
+
endpoint?: string;
|
|
116
|
+
reason?: string;
|
|
117
|
+
}, originalError?: Error);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* RPCError should be used for errors that occur during RPC (Remote Procedure Call) operations,
|
|
121
|
+
* such as invalid RPC parameters or RPC-specific failures.
|
|
122
|
+
* This includes:
|
|
123
|
+
* - Invalid RPC method calls
|
|
124
|
+
* - RPC parameter validation failures
|
|
125
|
+
* - RPC-specific error codes
|
|
126
|
+
* - RPC protocol errors
|
|
127
|
+
*/
|
|
128
|
+
declare class RPCError extends SparkSDKError {
|
|
129
|
+
constructor(message: string, context?: {
|
|
130
|
+
method?: string;
|
|
131
|
+
params?: unknown;
|
|
132
|
+
code?: number;
|
|
133
|
+
}, originalError?: Error);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* ConfigurationError should be used for errors related to SDK configuration,
|
|
137
|
+
* such as missing or invalid configuration values.
|
|
138
|
+
* This includes:
|
|
139
|
+
* - Missing required configuration
|
|
140
|
+
* - Invalid configuration values
|
|
141
|
+
* - Configuration format errors
|
|
142
|
+
* - Environment-specific configuration issues
|
|
143
|
+
*/
|
|
144
|
+
declare class ConfigurationError extends SparkSDKError {
|
|
145
|
+
constructor(message: string, context?: {
|
|
146
|
+
configKey?: string;
|
|
147
|
+
value?: unknown;
|
|
148
|
+
}, originalError?: Error);
|
|
149
|
+
}
|
|
150
|
+
/***
|
|
151
|
+
* NotImplementedError should be used for any errors related to features that are not yet implemented.
|
|
152
|
+
*/
|
|
153
|
+
declare class NotImplementedError extends SparkSDKError {
|
|
154
|
+
constructor(message: string, context?: Record<string, unknown>, originalError?: Error);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
declare class SigningService {
|
|
158
|
+
private readonly config;
|
|
159
|
+
constructor(config: WalletConfigService);
|
|
160
|
+
signRefunds(leaves: LeafKeyTweak[], signingCommitments: RequestedSigningCommitments[], receiverIdentityPubkey: Uint8Array): Promise<UserSignedTxSigningJob[]>;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
type LeafKeyTweak = {
|
|
164
|
+
leaf: TreeNode;
|
|
165
|
+
signingPubKey: Uint8Array;
|
|
166
|
+
newSigningPubKey: Uint8Array;
|
|
167
|
+
};
|
|
168
|
+
type ClaimLeafData = {
|
|
169
|
+
signingPubKey: Uint8Array;
|
|
170
|
+
tx?: Transaction;
|
|
171
|
+
refundTx?: Transaction;
|
|
172
|
+
signingNonceCommitment: SigningCommitment;
|
|
173
|
+
vout?: number;
|
|
174
|
+
};
|
|
175
|
+
type LeafRefundSigningData = {
|
|
176
|
+
signingPubKey: Uint8Array;
|
|
177
|
+
receivingPubkey: Uint8Array;
|
|
178
|
+
tx: Transaction;
|
|
179
|
+
refundTx?: Transaction;
|
|
180
|
+
signingNonceCommitment: SigningCommitment;
|
|
181
|
+
vout: number;
|
|
182
|
+
};
|
|
183
|
+
declare class BaseTransferService {
|
|
184
|
+
protected readonly config: WalletConfigService;
|
|
185
|
+
protected readonly connectionManager: ConnectionManager;
|
|
186
|
+
protected readonly signingService: SigningService;
|
|
187
|
+
constructor(config: WalletConfigService, connectionManager: ConnectionManager, signingService: SigningService);
|
|
188
|
+
sendTransferTweakKey(transfer: Transfer, leaves: LeafKeyTweak[], refundSignatureMap: Map<string, Uint8Array>): Promise<Transfer>;
|
|
189
|
+
deliverTransferPackage(transfer: Transfer, leaves: LeafKeyTweak[], refundSignatureMap: Map<string, Uint8Array>): Promise<Transfer>;
|
|
190
|
+
sendTransferWithKeyTweaks(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array): Promise<Transfer>;
|
|
191
|
+
private prepareTransferPackage;
|
|
192
|
+
private finalizeTransfer;
|
|
193
|
+
signRefunds(leafDataMap: Map<string, ClaimLeafData>, operatorSigningResults: LeafRefundTxSigningResult[], adaptorPubKey?: Uint8Array): Promise<NodeSignatures[]>;
|
|
194
|
+
private prepareSendTransferKeyTweaks;
|
|
195
|
+
private prepareSingleSendTransferKeyTweak;
|
|
196
|
+
protected findShare(shares: VerifiableSecretShare[], operatorID: number): VerifiableSecretShare | undefined;
|
|
197
|
+
private compareTransfers;
|
|
198
|
+
}
|
|
199
|
+
declare class TransferService extends BaseTransferService {
|
|
200
|
+
constructor(config: WalletConfigService, connectionManager: ConnectionManager, signingService: SigningService);
|
|
201
|
+
/**
|
|
202
|
+
* @deprecated Use sendTransferWithKeyTweaks instead
|
|
203
|
+
* Deprecated in v0.1.32
|
|
204
|
+
*/
|
|
205
|
+
sendTransfer(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array): Promise<Transfer>;
|
|
206
|
+
claimTransfer(transfer: Transfer, leaves: LeafKeyTweak[]): Promise<FinalizeNodeSignaturesResponse>;
|
|
207
|
+
queryPendingTransfers(): Promise<QueryTransfersResponse>;
|
|
208
|
+
queryAllTransfers(limit: number, offset: number): Promise<QueryTransfersResponse>;
|
|
209
|
+
verifyPendingTransfer(transfer: Transfer): Promise<Map<string, Uint8Array>>;
|
|
210
|
+
queryTransfer(transferId: string): Promise<Transfer | undefined>;
|
|
211
|
+
sendTransferSignRefund(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date): Promise<{
|
|
212
|
+
transfer: Transfer;
|
|
213
|
+
signatureMap: Map<string, Uint8Array>;
|
|
214
|
+
leafDataMap: Map<string, LeafRefundSigningData>;
|
|
215
|
+
}>;
|
|
216
|
+
startSwapSignRefund(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date): Promise<{
|
|
217
|
+
transfer: Transfer;
|
|
218
|
+
signatureMap: Map<string, Uint8Array>;
|
|
219
|
+
leafDataMap: Map<string, LeafRefundSigningData>;
|
|
220
|
+
}>;
|
|
221
|
+
counterSwapSignRefund(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date, adaptorPubKey?: Uint8Array): Promise<{
|
|
222
|
+
transfer: Transfer;
|
|
223
|
+
signatureMap: Map<string, Uint8Array>;
|
|
224
|
+
leafDataMap: Map<string, LeafRefundSigningData>;
|
|
225
|
+
signingResults: LeafRefundTxSigningResult[];
|
|
226
|
+
}>;
|
|
227
|
+
sendTransferSignRefundInternal(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date, forSwap: boolean, adaptorPubKey?: Uint8Array): Promise<{
|
|
228
|
+
transfer: Transfer;
|
|
229
|
+
signatureMap: Map<string, Uint8Array>;
|
|
230
|
+
leafDataMap: Map<string, LeafRefundSigningData>;
|
|
231
|
+
signingResults: LeafRefundTxSigningResult[];
|
|
232
|
+
}>;
|
|
233
|
+
private prepareRefundSoSigningJobs;
|
|
234
|
+
claimTransferTweakKeys(transfer: Transfer, leaves: LeafKeyTweak[]): Promise<Map<string, Uint8Array[]>>;
|
|
235
|
+
private prepareClaimLeavesKeyTweaks;
|
|
236
|
+
private prepareClaimLeafKeyTweaks;
|
|
237
|
+
claimTransferSignRefunds(transfer: Transfer, leafKeys: LeafKeyTweak[], proofMap?: Map<string, Uint8Array[]>): Promise<NodeSignatures[]>;
|
|
238
|
+
private finalizeNodeSignatures;
|
|
239
|
+
cancelTransfer(transfer: Transfer, operatorAddress: string): Promise<Transfer | undefined>;
|
|
240
|
+
queryPendingTransfersBySender(operatorAddress: string): Promise<QueryTransfersResponse>;
|
|
241
|
+
refreshTimelockNodes(nodes: TreeNode[], parentNode: TreeNode, signingPubKey: Uint8Array): Promise<FinalizeNodeSignaturesResponse>;
|
|
242
|
+
extendTimelock(node: TreeNode, signingPubKey: Uint8Array): Promise<FinalizeNodeSignaturesResponse>;
|
|
243
|
+
refreshTimelockRefundTx(node: TreeNode, signingPubKey: Uint8Array): Promise<FinalizeNodeSignaturesResponse>;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* The SparkWallet class is the primary interface for interacting with the Spark network.
|
|
248
|
+
* It provides methods for creating and managing wallets, handling deposits, executing transfers,
|
|
249
|
+
* and interacting with the Lightning Network.
|
|
250
|
+
*/
|
|
251
|
+
declare class SparkWallet extends EventEmitter {
|
|
252
|
+
protected config: WalletConfigService;
|
|
253
|
+
protected connectionManager: ConnectionManager;
|
|
254
|
+
protected lrc20ConnectionManager: Lrc20ConnectionManager;
|
|
255
|
+
protected lrc20Wallet: LRCWallet | undefined;
|
|
256
|
+
protected transferService: TransferService;
|
|
257
|
+
protected tracerId: string;
|
|
258
|
+
private depositService;
|
|
259
|
+
private treeCreationService;
|
|
260
|
+
private lightningService;
|
|
261
|
+
private coopExitService;
|
|
262
|
+
private signingService;
|
|
263
|
+
private tokenTransactionService;
|
|
264
|
+
private claimTransferMutex;
|
|
265
|
+
private leavesMutex;
|
|
266
|
+
private optimizationInProgress;
|
|
267
|
+
private sspClient;
|
|
268
|
+
private mutexes;
|
|
269
|
+
private pendingWithdrawnOutputIds;
|
|
270
|
+
private sparkAddress;
|
|
271
|
+
private streamController;
|
|
272
|
+
protected leaves: TreeNode[];
|
|
273
|
+
protected tokenOutputs: Map<string, OutputWithPreviousTransactionData[]>;
|
|
274
|
+
private claimTransfersInterval;
|
|
275
|
+
protected wrapWithOtelSpan<T>(name: string, fn: (...args: any[]) => Promise<T>): (...args: any[]) => Promise<T>;
|
|
276
|
+
protected constructor(options?: ConfigOptions, signer?: SparkSigner);
|
|
277
|
+
static initialize({ mnemonicOrSeed, accountNumber, signer, options, }: SparkWalletProps): Promise<{
|
|
278
|
+
mnemonic?: string | undefined;
|
|
279
|
+
wallet: SparkWallet;
|
|
280
|
+
}>;
|
|
281
|
+
private initializeWallet;
|
|
282
|
+
private getSspClient;
|
|
283
|
+
private handleStreamEvent;
|
|
284
|
+
protected setupBackgroundStream(): Promise<void>;
|
|
285
|
+
getLeaves(isBalanceCheck?: boolean): Promise<TreeNode[]>;
|
|
286
|
+
private selectLeaves;
|
|
287
|
+
private selectLeavesForSwap;
|
|
288
|
+
private areLeavesInefficient;
|
|
289
|
+
private optimizeLeaves;
|
|
290
|
+
private syncWallet;
|
|
291
|
+
private withLeaves;
|
|
292
|
+
/**
|
|
293
|
+
* Gets the identity public key of the wallet.
|
|
294
|
+
*
|
|
295
|
+
* @returns {Promise<string>} The identity public key as a hex string.
|
|
296
|
+
*/
|
|
297
|
+
getIdentityPublicKey(): Promise<string>;
|
|
298
|
+
/**
|
|
299
|
+
* Gets the Spark address of the wallet.
|
|
300
|
+
*
|
|
301
|
+
* @returns {Promise<string>} The Spark address as a hex string.
|
|
302
|
+
*/
|
|
303
|
+
getSparkAddress(): Promise<SparkAddressFormat>;
|
|
304
|
+
createSparkPaymentIntent(assetIdentifier?: string, assetAmount?: bigint, memo?: string): Promise<SparkAddressFormat>;
|
|
305
|
+
/**
|
|
306
|
+
* Initializes the wallet using either a mnemonic phrase or a raw seed.
|
|
307
|
+
* initWallet will also claim any pending incoming lightning payment, spark transfer,
|
|
308
|
+
* or bitcoin deposit.
|
|
309
|
+
*
|
|
310
|
+
* @param {Uint8Array | string} [mnemonicOrSeed] - (Optional) Either:
|
|
311
|
+
* - A BIP-39 mnemonic phrase as string
|
|
312
|
+
* - A raw seed as Uint8Array or hex string
|
|
313
|
+
* If not provided, generates a new mnemonic and uses it to create a new wallet
|
|
314
|
+
*
|
|
315
|
+
* @param {number} [accountNumber] - (Optional) The account number to use for the wallet. Defaults to 1 to maintain backwards compatability for legacy mainnet wallets.
|
|
316
|
+
*
|
|
317
|
+
* @returns {Promise<Object>} Object containing:
|
|
318
|
+
* - mnemonic: The mnemonic if one was generated (undefined for raw seed)
|
|
319
|
+
* - balance: The wallet's initial balance in satoshis
|
|
320
|
+
* - tokenBalance: Map of token balances
|
|
321
|
+
* @private
|
|
322
|
+
*/
|
|
323
|
+
protected initWallet(mnemonicOrSeed?: Uint8Array | string, accountNumber?: number): Promise<InitWalletResponse | undefined>;
|
|
324
|
+
/**
|
|
325
|
+
* Initializes a wallet from a seed.
|
|
326
|
+
*
|
|
327
|
+
* @param {Uint8Array | string} seed - The seed to initialize the wallet from
|
|
328
|
+
* @returns {Promise<string>} The identity public key
|
|
329
|
+
* @private
|
|
330
|
+
*/
|
|
331
|
+
private initWalletFromSeed;
|
|
332
|
+
/**
|
|
333
|
+
* Gets the estimated fee for a swap of leaves.
|
|
334
|
+
*
|
|
335
|
+
* @param amountSats - The amount of sats to swap
|
|
336
|
+
* @returns {Promise<LeavesSwapFeeEstimateOutput>} The estimated fee for the swap
|
|
337
|
+
*/
|
|
338
|
+
getSwapFeeEstimate(amountSats: number): Promise<LeavesSwapFeeEstimateOutput>;
|
|
339
|
+
/**
|
|
340
|
+
* Requests a swap of leaves to optimize wallet structure.
|
|
341
|
+
*
|
|
342
|
+
* @param {Object} params - Parameters for the leaves swap
|
|
343
|
+
* @param {number} [params.targetAmount] - Target amount for the swap
|
|
344
|
+
* @param {TreeNode[]} [params.leaves] - Specific leaves to swap
|
|
345
|
+
* @returns {Promise<Object>} The completed swap response
|
|
346
|
+
* @private
|
|
347
|
+
*/
|
|
348
|
+
private requestLeavesSwap;
|
|
349
|
+
/**
|
|
350
|
+
* Processes a single batch of leaves for swapping.
|
|
351
|
+
*/
|
|
352
|
+
private processSwapBatch;
|
|
353
|
+
/**
|
|
354
|
+
* Gets all transfers for the wallet.
|
|
355
|
+
*
|
|
356
|
+
* @param {number} [limit=20] - Maximum number of transfers to return
|
|
357
|
+
* @param {number} [offset=0] - Offset for pagination
|
|
358
|
+
* @returns {Promise<QueryTransfersResponse>} Response containing the list of transfers
|
|
359
|
+
*/
|
|
360
|
+
getTransfers(limit?: number, offset?: number): Promise<{
|
|
361
|
+
transfers: WalletTransfer[];
|
|
362
|
+
offset: number;
|
|
363
|
+
}>;
|
|
364
|
+
/**
|
|
365
|
+
* Gets the current balance of the wallet.
|
|
366
|
+
* You can use the forceRefetch option to synchronize your wallet and claim any
|
|
367
|
+
* pending incoming lightning payment, spark transfer, or bitcoin deposit before returning the balance.
|
|
368
|
+
*
|
|
369
|
+
* @returns {Promise<Object>} Object containing:
|
|
370
|
+
* - balance: The wallet's current balance in satoshis
|
|
371
|
+
* - tokenBalances: Map of the human readable token identifier to token balances and token info
|
|
372
|
+
*/
|
|
373
|
+
getBalance(): Promise<{
|
|
374
|
+
balance: bigint;
|
|
375
|
+
tokenBalances: TokenBalanceMap;
|
|
376
|
+
}>;
|
|
377
|
+
private getTokenBalance;
|
|
378
|
+
private getInternalBalance;
|
|
379
|
+
/**
|
|
380
|
+
* Generates a new deposit address for receiving bitcoin funds.
|
|
381
|
+
* Note that this function returns a bitcoin address, not a spark address, and this address is single use.
|
|
382
|
+
* Once you deposit funds to this address, it cannot be used again.
|
|
383
|
+
* For Layer 1 Bitcoin deposits, Spark generates Pay to Taproot (P2TR) addresses.
|
|
384
|
+
* These addresses start with "bc1p" and can be used to receive Bitcoin from any wallet.
|
|
385
|
+
*
|
|
386
|
+
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
387
|
+
*/
|
|
388
|
+
getSingleUseDepositAddress(): Promise<string>;
|
|
389
|
+
/**
|
|
390
|
+
* Generates a new static deposit address for receiving bitcoin funds.
|
|
391
|
+
* This address is permanent and can be used multiple times.
|
|
392
|
+
*
|
|
393
|
+
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
394
|
+
*/
|
|
395
|
+
getStaticDepositAddress(): Promise<string>;
|
|
396
|
+
/**
|
|
397
|
+
* Generates a deposit address for receiving funds.
|
|
398
|
+
*
|
|
399
|
+
* @param {boolean} static - Whether the address is static or single use
|
|
400
|
+
* @returns {Promise<string>} A deposit address
|
|
401
|
+
* @private
|
|
402
|
+
*/
|
|
403
|
+
private generateDepositAddress;
|
|
404
|
+
queryStaticDepositAddresses(): Promise<string[]>;
|
|
405
|
+
/**
|
|
406
|
+
* Get a quote on how much credit you can claim for a deposit from the SSP.
|
|
407
|
+
*
|
|
408
|
+
* @param {string} transactionId - The ID of the transaction
|
|
409
|
+
* @param {number} [outputIndex] - The index of the output
|
|
410
|
+
* @returns {Promise<StaticDepositQuoteOutput>} Quote for claiming a deposit to a static deposit address
|
|
411
|
+
*/
|
|
412
|
+
getClaimStaticDepositQuote(transactionId: string, outputIndex?: number): Promise<StaticDepositQuoteOutput>;
|
|
413
|
+
/**
|
|
414
|
+
* Claims a deposit to a static deposit address.
|
|
415
|
+
*
|
|
416
|
+
* @param {string} transactionId - The ID of the transaction
|
|
417
|
+
* @param {number} creditAmountSats - The amount of credit to claim
|
|
418
|
+
* @param {string} sspSignature - The SSP signature for the deposit
|
|
419
|
+
* @param {number} [outputIndex] - The index of the output
|
|
420
|
+
* @returns {Promise<RequestClaimDepositQuoteOutput | null>} Quote for claiming a deposit to a static deposit address
|
|
421
|
+
*/
|
|
422
|
+
claimStaticDeposit({ transactionId, creditAmountSats, sspSignature, outputIndex, }: {
|
|
423
|
+
transactionId: string;
|
|
424
|
+
creditAmountSats: number;
|
|
425
|
+
sspSignature: string;
|
|
426
|
+
outputIndex?: number;
|
|
427
|
+
}): Promise<ClaimStaticDepositOutput | null>;
|
|
428
|
+
/**
|
|
429
|
+
* Refunds a static deposit to a destination address.
|
|
430
|
+
*
|
|
431
|
+
* @param {string} depositTransactionId - The ID of the transaction
|
|
432
|
+
* @param {number} [outputIndex] - The index of the output
|
|
433
|
+
* @param {string} destinationAddress - The destination address
|
|
434
|
+
* @param {number} fee - The fee to refund
|
|
435
|
+
* @returns {Promise<string>} The hex of the refund transaction
|
|
436
|
+
*/
|
|
437
|
+
refundStaticDeposit({ depositTransactionId, outputIndex, destinationAddress, fee, }: {
|
|
438
|
+
depositTransactionId: string;
|
|
439
|
+
outputIndex?: number;
|
|
440
|
+
destinationAddress: string;
|
|
441
|
+
fee: number;
|
|
442
|
+
}): Promise<string>;
|
|
443
|
+
private getStaticDepositSigningPayload;
|
|
444
|
+
private getDepositTransactionVout;
|
|
445
|
+
private getDepositTransaction;
|
|
446
|
+
/**
|
|
447
|
+
* Finalizes a deposit to the wallet.
|
|
448
|
+
*
|
|
449
|
+
* @param {DepositParams} params - Parameters for finalizing the deposit
|
|
450
|
+
* @returns {Promise<void>} The nodes created from the deposit
|
|
451
|
+
* @private
|
|
452
|
+
*/
|
|
453
|
+
private finalizeDeposit;
|
|
454
|
+
/**
|
|
455
|
+
* Gets all unused deposit addresses for the wallet.
|
|
456
|
+
*
|
|
457
|
+
* @returns {Promise<string[]>} The unused deposit addresses
|
|
458
|
+
*/
|
|
459
|
+
getUnusedDepositAddresses(): Promise<string[]>;
|
|
460
|
+
/**
|
|
461
|
+
* Gets all unused deposit addresses for the wallet.
|
|
462
|
+
*
|
|
463
|
+
* @param {Object} params - Parameters for querying unused deposit addresses
|
|
464
|
+
* @param {Uint8Array<ArrayBufferLike>} [params.identityPublicKey] - The identity public key
|
|
465
|
+
* @param {NetworkProto} [params.network] - The network
|
|
466
|
+
* @returns {Promise<DepositAddressQueryResult[]>} The unused deposit addresses
|
|
467
|
+
*/
|
|
468
|
+
private queryAllUnusedDepositAddresses;
|
|
469
|
+
/**
|
|
470
|
+
* Claims a deposit to the wallet.
|
|
471
|
+
* Note that if you used advancedDeposit, you don't need to call this function.
|
|
472
|
+
* @param {string} txid - The transaction ID of the deposit
|
|
473
|
+
* @returns {Promise<WalletLeaf[] | undefined>} The nodes resulting from the deposit
|
|
474
|
+
*/
|
|
475
|
+
claimDeposit(txid: string): Promise<WalletLeaf[]>;
|
|
476
|
+
/**
|
|
477
|
+
* Non-trusty flow for depositing funds to the wallet.
|
|
478
|
+
* Construct the tx spending from an L1 wallet to the Spark address.
|
|
479
|
+
* After calling this function, you must sign and broadcast the tx.
|
|
480
|
+
*
|
|
481
|
+
* @param {string} txHex - The hex string of the transaction to deposit
|
|
482
|
+
* @returns {Promise<TreeNode[] | undefined>} The nodes resulting from the deposit
|
|
483
|
+
*/
|
|
484
|
+
advancedDeposit(txHex: string): Promise<TreeNode[]>;
|
|
485
|
+
/**
|
|
486
|
+
* Transfers deposit to self to claim ownership.
|
|
487
|
+
*
|
|
488
|
+
* @param {TreeNode[]} leaves - The leaves to transfer
|
|
489
|
+
* @param {Uint8Array} signingPubKey - The signing public key
|
|
490
|
+
* @returns {Promise<TreeNode[] | undefined>} The nodes resulting from the transfer
|
|
491
|
+
* @private
|
|
492
|
+
*/
|
|
493
|
+
private transferLeavesToSelf;
|
|
494
|
+
/**
|
|
495
|
+
* Sends a transfer to another Spark user.
|
|
496
|
+
*
|
|
497
|
+
* @param {TransferParams} params - Parameters for the transfer
|
|
498
|
+
* @param {string} params.receiverSparkAddress - The recipient's Spark address
|
|
499
|
+
* @param {number} params.amountSats - Amount to send in satoshis
|
|
500
|
+
* @returns {Promise<WalletTransfer>} The completed transfer details
|
|
501
|
+
*/
|
|
502
|
+
transfer({ amountSats, receiverSparkAddress, }: TransferParams): Promise<WalletTransfer>;
|
|
503
|
+
private checkExtendTimeLockNodes;
|
|
504
|
+
/**
|
|
505
|
+
* Internal method to refresh timelock nodes.
|
|
506
|
+
*
|
|
507
|
+
* @param {string} nodeId - The optional ID of the node to refresh. If not provided, all nodes will be checked.
|
|
508
|
+
* @returns {Promise<void>}
|
|
509
|
+
* @private
|
|
510
|
+
*/
|
|
511
|
+
private checkRefreshTimelockNodes;
|
|
512
|
+
/**
|
|
513
|
+
* Claims a specific transfer.
|
|
514
|
+
*
|
|
515
|
+
* @param {Transfer} transfer - The transfer to claim
|
|
516
|
+
* @returns {Promise<Object>} The claim result
|
|
517
|
+
*/
|
|
518
|
+
private claimTransfer;
|
|
519
|
+
/**
|
|
520
|
+
* Claims all pending transfers.
|
|
521
|
+
*
|
|
522
|
+
* @returns {Promise<string[]>} Array of successfully claimed transfer IDs
|
|
523
|
+
* @private
|
|
524
|
+
*/
|
|
525
|
+
private claimTransfers;
|
|
526
|
+
/**
|
|
527
|
+
* Cancels all sender-initiated transfers.
|
|
528
|
+
*
|
|
529
|
+
* @returns {Promise<void>}
|
|
530
|
+
* @private
|
|
531
|
+
*/
|
|
532
|
+
private cancelAllSenderInitiatedTransfers;
|
|
533
|
+
/**
|
|
534
|
+
* Creates a Lightning invoice for receiving payments.
|
|
535
|
+
*
|
|
536
|
+
* @param {Object} params - Parameters for the lightning invoice
|
|
537
|
+
* @param {number} params.amountSats - Amount in satoshis
|
|
538
|
+
* @param {string} [params.memo] - Description for the invoice. Should not be provided if the descriptionHash is provided.
|
|
539
|
+
* @param {number} [params.expirySeconds] - Optional expiry time in seconds
|
|
540
|
+
* @param {boolean} [params.includeSparkAddress] - Optional boolean signalling whether or not to include the spark address in the invoice
|
|
541
|
+
* @param {string} [params.receiverIdentityPubkey] - Optional public key of the wallet receiving the lightning invoice. If not present, the receiver will be the creator of this request.
|
|
542
|
+
* @param {string} [params.descriptionHash] - Optional h tag of the invoice. This is the hash of a longer description to include in the lightning invoice. It is used in LNURL and UMA as the hash of the metadata. This field is mutually exclusive with the memo field. Only one or the other should be provided.
|
|
543
|
+
* @returns {Promise<LightningReceiveRequest>} BOLT11 encoded invoice
|
|
544
|
+
*/
|
|
545
|
+
createLightningInvoice({ amountSats, memo, expirySeconds, includeSparkAddress, receiverIdentityPubkey, descriptionHash, }: CreateLightningInvoiceParams): Promise<LightningReceiveRequest>;
|
|
546
|
+
/**
|
|
547
|
+
* Pays a Lightning invoice.
|
|
548
|
+
*
|
|
549
|
+
* @param {Object} params - Parameters for paying the invoice
|
|
550
|
+
* @param {string} params.invoice - The BOLT11-encoded Lightning invoice to pay
|
|
551
|
+
* @param {boolean} [params.preferSpark] - Whether to prefer a spark transfer over lightning for the payment
|
|
552
|
+
* @param {number} [params.amountSatsToSend] - The amount in sats to send. This is only valid for 0 amount lightning invoices.
|
|
553
|
+
* @returns {Promise<LightningSendRequest>} The Lightning payment request details
|
|
554
|
+
*/
|
|
555
|
+
payLightningInvoice({ invoice, maxFeeSats, preferSpark, amountSatsToSend, }: PayLightningInvoiceParams): Promise<LightningSendRequest | WalletTransfer>;
|
|
556
|
+
/**
|
|
557
|
+
* Gets fee estimate for sending Lightning payments.
|
|
558
|
+
*
|
|
559
|
+
* @param {LightningSendFeeEstimateInput} params - Input parameters for fee estimation
|
|
560
|
+
* @returns {Promise<number>} Fee estimate for sending Lightning payments
|
|
561
|
+
*/
|
|
562
|
+
getLightningSendFeeEstimate({ encodedInvoice, amountSats, }: LightningSendFeeEstimateInput): Promise<number>;
|
|
563
|
+
/**
|
|
564
|
+
* Generates a deposit address for a tree.
|
|
565
|
+
*
|
|
566
|
+
* @param {number} vout - The vout index
|
|
567
|
+
* @param {Uint8Array} parentSigningPubKey - The parent signing public key
|
|
568
|
+
* @param {Transaction} [parentTx] - Optional parent transaction
|
|
569
|
+
* @param {TreeNode} [parentNode] - Optional parent node
|
|
570
|
+
* @returns {Promise<Object>} Deposit address information
|
|
571
|
+
* @private
|
|
572
|
+
*/
|
|
573
|
+
private generateDepositAddressForTree;
|
|
574
|
+
/**
|
|
575
|
+
* Creates a tree structure.
|
|
576
|
+
*
|
|
577
|
+
* @param {number} vout - The vout index
|
|
578
|
+
* @param {DepositAddressTree} root - The root of the tree
|
|
579
|
+
* @param {boolean} createLeaves - Whether to create leaves
|
|
580
|
+
* @param {Transaction} [parentTx] - Optional parent transaction
|
|
581
|
+
* @param {TreeNode} [parentNode] - Optional parent node
|
|
582
|
+
* @returns {Promise<Object>} The created tree
|
|
583
|
+
* @private
|
|
584
|
+
*/
|
|
585
|
+
private createTree;
|
|
586
|
+
/**
|
|
587
|
+
* Initiates a withdrawal to move funds from the Spark network to an on-chain Bitcoin address.
|
|
588
|
+
*
|
|
589
|
+
* @param {Object} params - Parameters for the withdrawal
|
|
590
|
+
* @param {string} params.onchainAddress - The Bitcoin address where the funds should be sent
|
|
591
|
+
* @param {CoopExitFeeQuote} params.feeQuote - The fee quote for the withdrawal
|
|
592
|
+
* @param {ExitSpeed} params.exitSpeed - The exit speed chosen for the withdrawal
|
|
593
|
+
* @param {number} [params.amountSats] - The amount in satoshis to withdraw. If not specified, attempts to withdraw all available funds and deductFeeFromWithdrawalAmount is set to true.
|
|
594
|
+
* @param {boolean} [params.deductFeeFromWithdrawalAmount] - Controls how the withdrawal fee is handled. If true, the fee is deducted from the withdrawal amount (amountSats), meaning the recipient will receive amountSats minus the fee. If false, the fee is paid separately from the wallet balance, meaning the recipient will receive the full amountSats.
|
|
595
|
+
* @returns {Promise<CoopExitRequest | null | undefined>} The withdrawal request details, or null/undefined if the request cannot be completed
|
|
596
|
+
*/
|
|
597
|
+
withdraw({ onchainAddress, exitSpeed, feeQuote, amountSats, deductFeeFromWithdrawalAmount, }: {
|
|
598
|
+
onchainAddress: string;
|
|
599
|
+
exitSpeed: ExitSpeed;
|
|
600
|
+
feeQuote: CoopExitFeeQuote;
|
|
601
|
+
amountSats?: number;
|
|
602
|
+
deductFeeFromWithdrawalAmount?: boolean;
|
|
603
|
+
}): Promise<CoopExitRequest | null>;
|
|
604
|
+
/**
|
|
605
|
+
* Internal method to perform a cooperative exit (withdrawal).
|
|
606
|
+
*
|
|
607
|
+
* @param {string} onchainAddress - The Bitcoin address where the funds should be sent
|
|
608
|
+
* @param {number} [targetAmountSats] - The amount in satoshis to withdraw
|
|
609
|
+
* @returns {Promise<Object | null | undefined>} The exit request details
|
|
610
|
+
* @private
|
|
611
|
+
*/
|
|
612
|
+
private coopExit;
|
|
613
|
+
/**
|
|
614
|
+
* Gets fee estimate for cooperative exit (on-chain withdrawal).
|
|
615
|
+
*
|
|
616
|
+
* @param {Object} params - Input parameters for fee estimation
|
|
617
|
+
* @param {number} params.amountSats - The amount in satoshis to withdraw
|
|
618
|
+
* @param {string} params.withdrawalAddress - The Bitcoin address where the funds should be sent
|
|
619
|
+
* @returns {Promise<CoopExitFeeQuote | null>} Fee estimate for the withdrawal
|
|
620
|
+
*/
|
|
621
|
+
getWithdrawalFeeQuote({ amountSats, withdrawalAddress, }: {
|
|
622
|
+
amountSats: number;
|
|
623
|
+
withdrawalAddress: string;
|
|
624
|
+
}): Promise<CoopExitFeeQuote | null>;
|
|
625
|
+
/**
|
|
626
|
+
* Gets a transfer that has been sent by the SSP to the wallet.
|
|
627
|
+
*
|
|
628
|
+
* @param {string} id - The ID of the transfer
|
|
629
|
+
* @returns {Promise<GraphQLTransferObj | null>} The transfer
|
|
630
|
+
*/
|
|
631
|
+
getTransferFromSsp(id: string): Promise<Transfer$1 | null>;
|
|
632
|
+
/**
|
|
633
|
+
* Gets a transfer, that the wallet is a participant of, in the Spark network.
|
|
634
|
+
* Only contains data about the spark->spark transfer, use getTransferFromSsp if you're
|
|
635
|
+
* looking for information related to a lightning transfer.
|
|
636
|
+
*
|
|
637
|
+
* @param {string} id - The ID of the transfer
|
|
638
|
+
* @returns {Promise<Transfer | undefined>} The transfer
|
|
639
|
+
*/
|
|
640
|
+
getTransfer(id: string): Promise<WalletTransfer | undefined>;
|
|
641
|
+
/**
|
|
642
|
+
* Synchronizes token outputs for the wallet.
|
|
643
|
+
*
|
|
644
|
+
* @returns {Promise<void>}
|
|
645
|
+
* @private
|
|
646
|
+
*/
|
|
647
|
+
protected syncTokenOutputs(): Promise<void>;
|
|
648
|
+
/**
|
|
649
|
+
* Transfers tokens to another user.
|
|
650
|
+
*
|
|
651
|
+
* @param {Object} params - Parameters for the token transfer
|
|
652
|
+
* @param {string} params.tokenPublicKey - The public key of the token to transfer
|
|
653
|
+
* @param {bigint} params.tokenAmount - The amount of tokens to transfer
|
|
654
|
+
* @param {string} params.receiverSparkAddress - The recipient's public key
|
|
655
|
+
* @param {OutputWithPreviousTransactionData[]} [params.selectedOutputs] - Optional specific leaves to use for the transfer
|
|
656
|
+
* @returns {Promise<string>} The transaction ID of the token transfer
|
|
657
|
+
*/
|
|
658
|
+
transferTokens({ tokenPublicKey, tokenAmount, receiverSparkAddress, outputSelectionStrategy, selectedOutputs, }: {
|
|
659
|
+
tokenPublicKey: string;
|
|
660
|
+
tokenAmount: bigint;
|
|
661
|
+
receiverSparkAddress: string;
|
|
662
|
+
outputSelectionStrategy?: "SMALL_FIRST" | "LARGE_FIRST";
|
|
663
|
+
selectedOutputs?: OutputWithPreviousTransactionData[];
|
|
664
|
+
}): Promise<string>;
|
|
665
|
+
/**
|
|
666
|
+
* Transfers tokens with multiple outputs
|
|
667
|
+
*
|
|
668
|
+
* @param {Array} receiverOutputs - Array of transfer parameters
|
|
669
|
+
* @param {string} receiverOutputs[].tokenPublicKey - The public key of the token to transfer
|
|
670
|
+
* @param {bigint} receiverOutputs[].tokenAmount - The amount of tokens to transfer
|
|
671
|
+
* @param {string} receiverOutputs[].receiverSparkAddress - The recipient's public key
|
|
672
|
+
* @param {OutputWithPreviousTransactionData[]} [selectedOutputs] - Optional specific leaves to use for the transfer
|
|
673
|
+
* @returns {Promise<string[]>} Array of transaction IDs for the token transfers
|
|
674
|
+
*/
|
|
675
|
+
batchTransferTokens(receiverOutputs: {
|
|
676
|
+
tokenPublicKey: string;
|
|
677
|
+
tokenAmount: bigint;
|
|
678
|
+
receiverSparkAddress: string;
|
|
679
|
+
}[], outputSelectionStrategy?: "SMALL_FIRST" | "LARGE_FIRST", selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
|
|
680
|
+
/**
|
|
681
|
+
* Retrieves token transaction history for specified tokens owned by the wallet.
|
|
682
|
+
* Can optionally filter by specific transaction hashes.
|
|
683
|
+
*
|
|
684
|
+
* @param ownerPublicKeys - Optional array of owner public keys to query transactions for
|
|
685
|
+
* @param issuerPublicKeys - Optional array of issuer public keys to query transactions for
|
|
686
|
+
* @param tokenTransactionHashes - Optional array of specific transaction hashes to filter by
|
|
687
|
+
* @param tokenIdentifiers - Optional array of token identifiers to filter by
|
|
688
|
+
* @param outputIds - Optional array of output IDs to filter by
|
|
689
|
+
* @returns Promise resolving to array of token transactions with their current status
|
|
690
|
+
*/
|
|
691
|
+
queryTokenTransactions(ownerPublicKeys?: string[], issuerPublicKeys?: string[], tokenTransactionHashes?: string[], tokenIdentifiers?: string[], outputIds?: string[]): Promise<TokenTransactionWithStatus[]>;
|
|
692
|
+
getTokenL1Address(): Promise<string>;
|
|
693
|
+
/**
|
|
694
|
+
* Signs a message with the identity key.
|
|
695
|
+
*
|
|
696
|
+
* @param {string} message - The message to sign
|
|
697
|
+
* @param {boolean} [compact] - Whether to use compact encoding. If false, the message will be encoded as DER.
|
|
698
|
+
* @returns {Promise<string>} The signed message
|
|
699
|
+
*/
|
|
700
|
+
signMessageWithIdentityKey(message: string, compact?: boolean): Promise<string>;
|
|
701
|
+
/**
|
|
702
|
+
* Validates a message with the identity key.
|
|
703
|
+
*
|
|
704
|
+
* @param {string} message - The original message that was signed
|
|
705
|
+
* @param {string | Uint8Array} signature - Signature to validate
|
|
706
|
+
* @returns {Promise<boolean>} Whether the message is valid
|
|
707
|
+
*/
|
|
708
|
+
validateMessageWithIdentityKey(message: string, signature: string | Uint8Array): Promise<boolean>;
|
|
709
|
+
/**
|
|
710
|
+
* Signs a transaction with wallet keys.
|
|
711
|
+
*
|
|
712
|
+
* @param {string} txHex - The transaction hex to sign
|
|
713
|
+
* @param {string} keyType - The type of key to use for signing ("identity", "deposit", or "auto-detect")
|
|
714
|
+
* @returns {Promise<string>} The signed transaction hex
|
|
715
|
+
*/
|
|
716
|
+
signTransaction(txHex: string, keyType?: string): Promise<string>;
|
|
717
|
+
/**
|
|
718
|
+
* Helper method to auto-detect which key should be used for signing a transaction.
|
|
719
|
+
*/
|
|
720
|
+
private detectKeyForTransaction;
|
|
721
|
+
/**
|
|
722
|
+
* Get a Lightning receive request by ID.
|
|
723
|
+
*
|
|
724
|
+
* @param {string} id - The ID of the Lightning receive request
|
|
725
|
+
* @returns {Promise<LightningReceiveRequest | null>} The Lightning receive request
|
|
726
|
+
*/
|
|
727
|
+
getLightningReceiveRequest(id: string): Promise<LightningReceiveRequest | null>;
|
|
728
|
+
/**
|
|
729
|
+
* Get a Lightning send request by ID.
|
|
730
|
+
*
|
|
731
|
+
* @param {string} id - The ID of the Lightning send request
|
|
732
|
+
* @returns {Promise<LightningSendRequest | null>} The Lightning send request
|
|
733
|
+
*/
|
|
734
|
+
getLightningSendRequest(id: string): Promise<LightningSendRequest | null>;
|
|
735
|
+
/**
|
|
736
|
+
* Get a coop exit request by ID.
|
|
737
|
+
*
|
|
738
|
+
* @param {string} id - The ID of the coop exit request
|
|
739
|
+
* @returns {Promise<CoopExitRequest | null>} The coop exit request
|
|
740
|
+
*/
|
|
741
|
+
getCoopExitRequest(id: string): Promise<CoopExitRequest | null>;
|
|
742
|
+
/**
|
|
743
|
+
* Check the remaining timelock on a given node.
|
|
744
|
+
*
|
|
745
|
+
* @param {string} nodeId - The ID of the node to check
|
|
746
|
+
* @returns {Promise<{nodeTimelock: number, refundTimelock: number}>} The remaining timelocks in blocks for both node and refund transactions
|
|
747
|
+
*/
|
|
748
|
+
checkTimelock(nodeId: string): Promise<{
|
|
749
|
+
nodeTimelock: number;
|
|
750
|
+
refundTimelock: number;
|
|
751
|
+
}>;
|
|
752
|
+
/**
|
|
753
|
+
* Refresh the timelock of a specific node.
|
|
754
|
+
*
|
|
755
|
+
* @param {string} nodeId - The ID of the node to refresh
|
|
756
|
+
* @returns {Promise<void>} Promise that resolves when the timelock is refreshed
|
|
757
|
+
*/
|
|
758
|
+
testOnly_expireTimelock(nodeId: string): Promise<void>;
|
|
759
|
+
/**
|
|
760
|
+
* Refresh the timelock of a specific node's refund transaction only.
|
|
761
|
+
*
|
|
762
|
+
* @param {string} nodeId - The ID of the node whose refund transaction to refresh
|
|
763
|
+
* @returns {Promise<void>} Promise that resolves when the refund timelock is refreshed
|
|
764
|
+
*/
|
|
765
|
+
testOnly_expireTimelockRefundTx(nodeId: string): Promise<void>;
|
|
766
|
+
private cleanup;
|
|
767
|
+
cleanupConnections(): Promise<void>;
|
|
768
|
+
private startPeriodicClaimTransfers;
|
|
769
|
+
private updateLeaves;
|
|
770
|
+
private queryNodes;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
export { AuthenticationError, ConfigurationError, InternalValidationError, NetworkError, NotImplementedError, RPCError, SparkSDKError, SparkWallet, ValidationError, VerifiableSecretShare };
|