@buildonspark/spark-sdk 0.1.45 → 0.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/{chunk-I54FARY2.js → chunk-EAP3U3CW.js} +14 -14
  3. package/dist/chunk-GWFQ7EBA.js +3773 -0
  4. package/dist/{chunk-J2IE4Z7Y.js → chunk-NNX4OK44.js} +3487 -934
  5. package/dist/{RequestLightningSendInput-Du0z7Om7.d.cts → client-CvpTRpcw.d.cts} +422 -212
  6. package/dist/{RequestLightningSendInput-DEPd_fPO.d.ts → client-D7KgLN44.d.ts} +422 -212
  7. package/dist/graphql/objects/index.d.cts +5 -9
  8. package/dist/graphql/objects/index.d.ts +5 -9
  9. package/dist/graphql/objects/index.js +1 -1
  10. package/dist/index.cjs +20461 -23377
  11. package/dist/index.d.cts +15 -769
  12. package/dist/index.d.ts +15 -769
  13. package/dist/index.js +81 -71
  14. package/dist/index.node.cjs +21994 -25018
  15. package/dist/index.node.d.cts +312 -34
  16. package/dist/index.node.d.ts +312 -34
  17. package/dist/index.node.js +82 -176
  18. package/dist/native/index.cjs +22847 -25841
  19. package/dist/native/index.d.cts +974 -1138
  20. package/dist/native/index.d.ts +974 -1138
  21. package/dist/native/index.js +10604 -13592
  22. package/dist/proto/lrc20.d.cts +2 -2
  23. package/dist/proto/lrc20.d.ts +2 -2
  24. package/dist/proto/lrc20.js +3098 -46
  25. package/dist/proto/spark.d.cts +1 -1
  26. package/dist/proto/spark.d.ts +1 -1
  27. package/dist/proto/spark_token.d.cts +1 -1
  28. package/dist/proto/spark_token.d.ts +1 -1
  29. package/dist/{sdk-types-Cc4l4kb1.d.ts → sdk-types-BGCeea0G.d.ts} +1 -1
  30. package/dist/{sdk-types-B0SwjolI.d.cts → sdk-types-XUeQMLFP.d.cts} +1 -1
  31. package/dist/{spark-dM7EYXYQ.d.cts → spark-BbUrbvZz.d.cts} +1 -1
  32. package/dist/{spark-dM7EYXYQ.d.ts → spark-BbUrbvZz.d.ts} +1 -1
  33. package/dist/spark-wallet-BAFPpPtY.d.cts +923 -0
  34. package/dist/spark-wallet-CJkQW8pK.d.ts +923 -0
  35. package/dist/spark_bindings/native/index.d.cts +1 -1
  36. package/dist/spark_bindings/native/index.d.ts +1 -1
  37. package/dist/spark_bindings/wasm/index.d.cts +1 -1
  38. package/dist/spark_bindings/wasm/index.d.ts +1 -1
  39. package/dist/{services/index.cjs → tests/test-utils.cjs} +2512 -4380
  40. package/dist/tests/test-utils.d.cts +79 -0
  41. package/dist/tests/test-utils.d.ts +79 -0
  42. package/dist/tests/test-utils.js +85 -0
  43. package/dist/types/index.d.cts +5 -9
  44. package/dist/types/index.d.ts +5 -9
  45. package/dist/types/index.js +5 -5
  46. package/dist/{types-C-Rp0Oo7.d.cts → types-BADxR3bm.d.cts} +1 -1
  47. package/dist/{types-C-Rp0Oo7.d.ts → types-BADxR3bm.d.ts} +1 -1
  48. package/package.json +7 -35
  49. package/src/graphql/client.ts +59 -20
  50. package/src/index.node.ts +28 -2
  51. package/src/index.ts +31 -1
  52. package/src/native/index.ts +16 -2
  53. package/src/services/config.ts +4 -6
  54. package/src/services/connection.ts +131 -64
  55. package/src/services/lightning.ts +1 -2
  56. package/src/services/token-transactions.ts +7 -7
  57. package/src/services/transfer.ts +1 -1
  58. package/src/services/tree-creation.ts +1 -1
  59. package/src/services/wallet-config.ts +18 -10
  60. package/src/signer/signer.react-native.ts +2 -5
  61. package/src/signer/signer.ts +138 -64
  62. package/src/signer/types.ts +52 -0
  63. package/src/spark-wallet/spark-wallet.ts +79 -36
  64. package/src/spark-wallet/types.ts +4 -4
  65. package/src/tests/integration/coop-exit.test.ts +2 -1
  66. package/src/tests/integration/lightning.test.ts +2 -2
  67. package/src/tests/integration/swap.test.ts +1 -1
  68. package/src/tests/integration/transfer.test.ts +5 -5
  69. package/src/tests/integration/tree-creation.test.ts +1 -1
  70. package/src/tests/integration/wallet.test.ts +1 -0
  71. package/src/tests/isHermeticTest.ts +3 -24
  72. package/src/tests/{test-util.ts → test-utils.ts} +3 -7
  73. package/src/tests/wrapWithOtelSpan.test.ts +1 -1
  74. package/src/{address → utils}/address.ts +1 -1
  75. package/src/utils/crypto.ts +19 -9
  76. package/src/utils/index.ts +2 -0
  77. package/src/utils/network.ts +17 -0
  78. package/src/utils/secret-sharing.ts +1 -2
  79. package/src/utils/signing.ts +1 -1
  80. package/src/utils/token-transactions.ts +3 -3
  81. package/src/utils/unilateral-exit.ts +32 -0
  82. package/src/utils/xchain-address.ts +1 -1
  83. package/dist/BitcoinNetwork-TnABML0T.d.cts +0 -18
  84. package/dist/BitcoinNetwork-TnABML0T.d.ts +0 -18
  85. package/dist/LightningSendFeeEstimateInput-BgOhEAI-.d.cts +0 -10
  86. package/dist/LightningSendFeeEstimateInput-BgOhEAI-.d.ts +0 -10
  87. package/dist/address/index.cjs +0 -458
  88. package/dist/address/index.d.cts +0 -32
  89. package/dist/address/index.d.ts +0 -32
  90. package/dist/address/index.js +0 -17
  91. package/dist/chunk-5FUB65LX.js +0 -838
  92. package/dist/chunk-6264CGDM.js +0 -113
  93. package/dist/chunk-7V6N75CC.js +0 -24
  94. package/dist/chunk-C2S227QR.js +0 -2336
  95. package/dist/chunk-GSI4OLXZ.js +0 -117
  96. package/dist/chunk-GZ5IPPJ2.js +0 -170
  97. package/dist/chunk-HWJWKEIU.js +0 -75
  98. package/dist/chunk-KMUMFYFX.js +0 -137
  99. package/dist/chunk-L3EHBOUX.js +0 -0
  100. package/dist/chunk-NSJF5F5O.js +0 -325
  101. package/dist/chunk-NTFKFRQ2.js +0 -3146
  102. package/dist/chunk-PQN3C2MF.js +0 -1122
  103. package/dist/chunk-QNNSEJ4P.js +0 -232
  104. package/dist/chunk-R5PXJZQS.js +0 -277
  105. package/dist/chunk-VTUGIIWI.js +0 -0
  106. package/dist/chunk-YUPMXTCJ.js +0 -622
  107. package/dist/chunk-Z5HIAYFT.js +0 -84
  108. package/dist/index-B2AwKW5J.d.cts +0 -214
  109. package/dist/index-CJDi1HWc.d.ts +0 -214
  110. package/dist/network-BTJl-Sul.d.ts +0 -46
  111. package/dist/network-CqgsdUF2.d.cts +0 -46
  112. package/dist/services/config.cjs +0 -2354
  113. package/dist/services/config.d.cts +0 -42
  114. package/dist/services/config.d.ts +0 -42
  115. package/dist/services/config.js +0 -17
  116. package/dist/services/connection.cjs +0 -17691
  117. package/dist/services/connection.d.cts +0 -95
  118. package/dist/services/connection.d.ts +0 -95
  119. package/dist/services/connection.js +0 -11
  120. package/dist/services/index.d.cts +0 -21
  121. package/dist/services/index.d.ts +0 -21
  122. package/dist/services/index.js +0 -58
  123. package/dist/services/lrc-connection.cjs +0 -4713
  124. package/dist/services/lrc-connection.d.cts +0 -34
  125. package/dist/services/lrc-connection.d.ts +0 -34
  126. package/dist/services/lrc-connection.js +0 -11
  127. package/dist/services/token-transactions.cjs +0 -2877
  128. package/dist/services/token-transactions.d.cts +0 -75
  129. package/dist/services/token-transactions.d.ts +0 -75
  130. package/dist/services/token-transactions.js +0 -15
  131. package/dist/services/wallet-config.cjs +0 -340
  132. package/dist/services/wallet-config.d.cts +0 -56
  133. package/dist/services/wallet-config.d.ts +0 -56
  134. package/dist/services/wallet-config.js +0 -33
  135. package/dist/signer/signer.cjs +0 -2004
  136. package/dist/signer/signer.d.cts +0 -10
  137. package/dist/signer/signer.d.ts +0 -10
  138. package/dist/signer/signer.js +0 -24
  139. package/dist/signer-BocS_J6B.d.ts +0 -187
  140. package/dist/signer-DKS0AJkw.d.cts +0 -187
  141. package/dist/utils/index.cjs +0 -2947
  142. package/dist/utils/index.d.cts +0 -18
  143. package/dist/utils/index.d.ts +0 -18
  144. package/dist/utils/index.js +0 -157
  145. package/src/address/index.ts +0 -1
  146. package/src/services/lrc-connection.ts +0 -215
@@ -1,214 +0,0 @@
1
- import * as btc from '@scure/btc-signer';
2
- import { Transaction } from '@scure/btc-signer';
3
- import { TransactionOutput, TransactionInput } from '@scure/btc-signer/psbt';
4
- import { N as Network } from './network-CqgsdUF2.cjs';
5
- import { S as SparkSigner, i as SigningNonce, h as SigningCommitment } from './signer-DKS0AJkw.cjs';
6
- import { j as OutputWithPreviousTransactionData, l as TransferPackage, g as SparkServiceClient } from './spark-dM7EYXYQ.cjs';
7
- import { ConfigOptions } from './services/wallet-config.cjs';
8
- import { SparkAddressFormat } from './address/index.cjs';
9
-
10
- type HumanReadableTokenIdentifier = `btk1${string}` | `btkrt1${string}` | `btkt1${string}` | `btks1${string}` | `btkl1${string}`;
11
-
12
- type CreateLightningInvoiceParams = {
13
- amountSats: number;
14
- memo?: string;
15
- expirySeconds?: number;
16
- includeSparkAddress?: boolean;
17
- receiverIdentityPubkey?: string;
18
- descriptionHash?: string;
19
- };
20
- type PayLightningInvoiceParams = {
21
- invoice: string;
22
- maxFeeSats: number;
23
- preferSpark?: boolean;
24
- amountSatsToSend?: number;
25
- };
26
- type TransferParams = {
27
- amountSats: number;
28
- receiverSparkAddress: string;
29
- };
30
- type DepositParams = {
31
- signingPubKey: Uint8Array;
32
- verifyingKey: Uint8Array;
33
- depositTx: Transaction;
34
- vout: number;
35
- };
36
- /**
37
- * Token metadata containing essential information about a token.
38
- * This is the wallet's internal representation with JavaScript-friendly types.
39
- *
40
- * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human readable token identifier.
41
- *
42
- * tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
43
- *
44
- * @example
45
- * ```typescript
46
- * const tokenMetadata: TokenMetadata = {
47
- * rawTokenIdentifier: new Uint8Array([1, 2, 3]),
48
- * tokenPublicKey: "0348fbb...",
49
- * tokenName: "SparkToken",
50
- * tokenTicker: "SPK",
51
- * decimals: 8,
52
- * maxSupply: 1000000n
53
- * };
54
- * ```
55
- */
56
- type TokenMetadata = {
57
- /** Raw binary token identifier - This is used to encode the human readable token identifier */
58
- rawTokenIdentifier: Uint8Array;
59
- /** Hex-encoded public key of the token issuer - Same as issuerPublicKey */
60
- tokenPublicKey: string;
61
- /** Human-readable name of the token (e.g., SparkToken)*/
62
- tokenName: string;
63
- /** Short ticker symbol for the token (e.g., "SPK") */
64
- tokenTicker: string;
65
- /** Number of decimal places for token amounts */
66
- decimals: number;
67
- /** Maximum supply of tokens that can ever be minted */
68
- maxSupply: bigint;
69
- };
70
- type TokenBalanceMap = Map<HumanReadableTokenIdentifier, {
71
- balance: bigint;
72
- tokenMetadata: TokenMetadata;
73
- }>;
74
- type InitWalletResponse = {
75
- mnemonic?: string | undefined;
76
- };
77
- interface SparkWalletProps {
78
- mnemonicOrSeed?: Uint8Array | string;
79
- accountNumber?: number;
80
- signer?: SparkSigner;
81
- options?: ConfigOptions;
82
- }
83
- interface SparkWalletEvents {
84
- /** Emitted when an incoming transfer is successfully claimed. Includes the transfer ID and new total balance. */
85
- "transfer:claimed": (transferId: string, updatedBalance: number) => void;
86
- /** Emitted when a deposit is marked as available. Includes the deposit ID and new total balance. */
87
- "deposit:confirmed": (depositId: string, updatedBalance: number) => void;
88
- /** Emitted when the stream is connected */
89
- "stream:connected": () => void;
90
- /** Emitted when the stream disconnects and fails to reconnect after max attempts */
91
- "stream:disconnected": (reason: string) => void;
92
- /** Emitted when attempting to reconnect the stream */
93
- "stream:reconnecting": (attempt: number, maxAttempts: number, delayMs: number, error: string) => void;
94
- }
95
-
96
- declare function generateSignatureFromExistingAdaptor(signature: Uint8Array, adaptorPrivateKeyBytes: Uint8Array): Uint8Array;
97
- declare function generateAdaptorFromSignature(signature: Uint8Array): {
98
- adaptorSignature: Uint8Array;
99
- adaptorPrivateKey: Uint8Array;
100
- };
101
- declare function validateOutboundAdaptorSignature(pubkey: Uint8Array, hash: Uint8Array, signature: Uint8Array, adaptorPubkey: Uint8Array): boolean;
102
- declare function applyAdaptorToSignature(pubkey: Uint8Array, hash: Uint8Array, signature: Uint8Array, adaptorPrivateKeyBytes: Uint8Array): Uint8Array;
103
-
104
- declare function computeTaprootKeyNoScript(pubkey: Uint8Array): Uint8Array;
105
- declare function getP2TRScriptFromPublicKey(pubKey: Uint8Array, network: Network): Uint8Array;
106
- declare function getP2TRAddressFromPublicKey(pubKey: Uint8Array, network: Network): string;
107
- declare function getP2TRAddressFromPkScript(pkScript: Uint8Array, network: Network): string;
108
- declare function getP2WPKHAddressFromPublicKey(pubKey: Uint8Array, network: Network): string;
109
- declare function getTxFromRawTxHex(rawTxHex: string): btc.Transaction;
110
- declare function getTxFromRawTxBytes(rawTxBytes: Uint8Array): btc.Transaction;
111
- declare function getSigHashFromTx(tx: btc.Transaction, inputIndex: number, prevOutput: TransactionOutput): Uint8Array;
112
- declare function getTxId(tx: btc.Transaction): string;
113
- declare function getTxIdNoReverse(tx: btc.Transaction): string;
114
-
115
- declare function addPublicKeys(a: Uint8Array, b: Uint8Array): Uint8Array;
116
- declare function applyAdditiveTweakToPublicKey(pubkey: Uint8Array, tweak: Uint8Array): Uint8Array<ArrayBufferLike>;
117
- declare function subtractPublicKeys(a: Uint8Array, b: Uint8Array): Uint8Array<ArrayBufferLike>;
118
- declare function addPrivateKeys(a: Uint8Array, b: Uint8Array): Uint8Array<ArrayBufferLike>;
119
- declare function subtractPrivateKeys(a: Uint8Array, b: Uint8Array): Uint8Array<ArrayBufferLike>;
120
- declare function sumOfPrivateKeys(keys: Uint8Array[]): Uint8Array<ArrayBufferLike>;
121
- declare function lastKeyWithTarget(target: Uint8Array, keys: Uint8Array[]): Uint8Array<ArrayBufferLike>;
122
-
123
- declare function getLatestDepositTxId(address: string): Promise<string | null>;
124
- declare function isTxBroadcast(txid: string, baseUrl: string, network?: any): Promise<boolean>;
125
-
126
- declare function proofOfPossessionMessageHashForDepositAddress(userPubkey: Uint8Array, operatorPubkey: Uint8Array, depositAddress: string): Uint8Array;
127
-
128
- declare function collectResponses<T>(responses: PromiseSettledResult<T>[]): T[];
129
-
130
- declare function getRandomSigningNonce(): SigningNonce;
131
- declare function createSigningNonce(binding: Uint8Array, hiding: Uint8Array): SigningNonce;
132
- declare function getSigningCommitmentFromNonce(nonce: SigningNonce): SigningCommitment;
133
- declare function encodeSigningNonceToBytes(nonce: SigningNonce): Uint8Array;
134
- declare function decodeBytesToSigningNonce(bytes: Uint8Array): SigningNonce;
135
- declare function createSigningCommitment(binding: Uint8Array, hiding: Uint8Array): SigningCommitment;
136
- declare function encodeSigningCommitmentToBytes(commitment: SigningCommitment): Uint8Array;
137
- declare function decodeBytesToSigningCommitment(bytes: Uint8Array): SigningCommitment;
138
-
139
- declare function calculateAvailableTokenAmount(outputLeaves: OutputWithPreviousTransactionData[]): bigint;
140
- declare function checkIfSelectedOutputsAreAvailable(selectedOutputs: OutputWithPreviousTransactionData[], tokenOutputs: Map<string, OutputWithPreviousTransactionData[]>, tokenPublicKey: Uint8Array): boolean;
141
- declare function filterTokenBalanceForTokenPublicKey(tokenBalances: TokenBalanceMap, publicKey: string): {
142
- balance: bigint;
143
- };
144
-
145
- declare function getTransferPackageSigningPayload(transferID: string, transferPackage: TransferPackage): Uint8Array;
146
-
147
- declare const DEFAULT_FEE_SATS: number;
148
- /**
149
- * Subtracts the default fee from the amount if it's greater than the fee.
150
- * Returns the original amount if it's less than or equal to the fee.
151
- */
152
- declare function maybeApplyFee(amount: bigint): bigint;
153
- declare function createRefundTx(sequence: number, nodeOutPoint: TransactionInput, amountSats: bigint, receivingPubkey: Uint8Array, network: Network): Transaction;
154
- declare function getCurrentTimelock(currSequence?: number): number;
155
- declare function getTransactionSequence(currSequence?: number): number;
156
- declare function checkIfValidSequence(currSequence?: number): void;
157
- declare function getNextTransactionSequence(currSequence?: number, forRefresh?: boolean): {
158
- nextSequence: number;
159
- needRefresh: boolean;
160
- };
161
- declare function getEphemeralAnchorOutput(): TransactionOutput;
162
-
163
- interface LeafInfo {
164
- leafId: string;
165
- nodeTx: string;
166
- refundTx: string;
167
- }
168
- interface Utxo {
169
- txid: string;
170
- vout: number;
171
- value: bigint;
172
- script: string;
173
- publicKey: string;
174
- }
175
- interface FeeRate {
176
- satPerVbyte: number;
177
- }
178
- interface FeeBumpTxPackage {
179
- tx: string;
180
- feeBumpPsbt?: string;
181
- }
182
- interface FeeBumpTxChain {
183
- leafId: string;
184
- txPackages: FeeBumpTxPackage[];
185
- }
186
- interface TxChain {
187
- leafId: string;
188
- transactions: string[];
189
- }
190
- interface BroadcastConfig {
191
- bitcoinCoreRpcUrl?: string;
192
- rpcUsername?: string;
193
- rpcPassword?: string;
194
- autoBroadcast?: boolean;
195
- network?: "MAINNET" | "REGTEST" | "TESTNET" | "SIGNET" | "LOCAL";
196
- }
197
- interface BroadcastResult {
198
- success: boolean;
199
- txids?: string[];
200
- error?: string;
201
- broadcastedPackages?: number;
202
- }
203
- declare function isEphemeralAnchorOutput(script?: Uint8Array, amount?: bigint): boolean;
204
- declare function constructUnilateralExitTxs(nodeHexStrings: string[], sparkClient?: SparkServiceClient, network?: any): Promise<TxChain[]>;
205
- declare function constructUnilateralExitFeeBumpPackages(nodeHexStrings: string[], utxos: Utxo[], feeRate: FeeRate, electrsUrl: string, sparkClient?: SparkServiceClient, network?: any): Promise<FeeBumpTxChain[]>;
206
- declare function constructFeeBumpTx(txHex: string, utxos: Utxo[], feeRate: FeeRate, previousFeeBumpTx?: string): {
207
- feeBumpPsbt: string;
208
- usedUtxos: Utxo[];
209
- correctedParentTx?: string;
210
- };
211
-
212
- declare function getSparkAddressFromTaproot(taprootAddress: string): SparkAddressFormat;
213
-
214
- export { getEphemeralAnchorOutput as $, proofOfPossessionMessageHashForDepositAddress as A, collectResponses as B, type CreateLightningInvoiceParams as C, type DepositParams as D, getRandomSigningNonce as E, createSigningNonce as F, getSigningCommitmentFromNonce as G, encodeSigningNonceToBytes as H, type InitWalletResponse as I, decodeBytesToSigningNonce as J, createSigningCommitment as K, encodeSigningCommitmentToBytes as L, decodeBytesToSigningCommitment as M, calculateAvailableTokenAmount as N, checkIfSelectedOutputsAreAvailable as O, type PayLightningInvoiceParams as P, filterTokenBalanceForTokenPublicKey as Q, getTransferPackageSigningPayload as R, type SparkWalletProps as S, type TransferParams as T, DEFAULT_FEE_SATS as U, maybeApplyFee as V, createRefundTx as W, getCurrentTimelock as X, getTransactionSequence as Y, checkIfValidSequence as Z, getNextTransactionSequence as _, type TokenMetadata as a, type LeafInfo as a0, type Utxo as a1, type FeeRate as a2, type FeeBumpTxPackage as a3, type FeeBumpTxChain as a4, type TxChain as a5, type BroadcastConfig as a6, type BroadcastResult as a7, isEphemeralAnchorOutput as a8, constructUnilateralExitTxs as a9, constructUnilateralExitFeeBumpPackages as aa, constructFeeBumpTx as ab, getSparkAddressFromTaproot as ac, type TokenBalanceMap as b, type SparkWalletEvents as c, generateAdaptorFromSignature as d, applyAdaptorToSignature as e, computeTaprootKeyNoScript as f, generateSignatureFromExistingAdaptor as g, getP2TRScriptFromPublicKey as h, getP2TRAddressFromPublicKey as i, getP2TRAddressFromPkScript as j, getP2WPKHAddressFromPublicKey as k, getTxFromRawTxHex as l, getTxFromRawTxBytes as m, getSigHashFromTx as n, getTxId as o, getTxIdNoReverse as p, addPublicKeys as q, applyAdditiveTweakToPublicKey as r, subtractPublicKeys as s, addPrivateKeys as t, subtractPrivateKeys as u, validateOutboundAdaptorSignature as v, sumOfPrivateKeys as w, lastKeyWithTarget as x, getLatestDepositTxId as y, isTxBroadcast as z };
@@ -1,214 +0,0 @@
1
- import * as btc from '@scure/btc-signer';
2
- import { Transaction } from '@scure/btc-signer';
3
- import { TransactionOutput, TransactionInput } from '@scure/btc-signer/psbt';
4
- import { N as Network } from './network-BTJl-Sul.js';
5
- import { S as SparkSigner, i as SigningNonce, h as SigningCommitment } from './signer-BocS_J6B.js';
6
- import { j as OutputWithPreviousTransactionData, l as TransferPackage, g as SparkServiceClient } from './spark-dM7EYXYQ.js';
7
- import { ConfigOptions } from './services/wallet-config.js';
8
- import { SparkAddressFormat } from './address/index.js';
9
-
10
- type HumanReadableTokenIdentifier = `btk1${string}` | `btkrt1${string}` | `btkt1${string}` | `btks1${string}` | `btkl1${string}`;
11
-
12
- type CreateLightningInvoiceParams = {
13
- amountSats: number;
14
- memo?: string;
15
- expirySeconds?: number;
16
- includeSparkAddress?: boolean;
17
- receiverIdentityPubkey?: string;
18
- descriptionHash?: string;
19
- };
20
- type PayLightningInvoiceParams = {
21
- invoice: string;
22
- maxFeeSats: number;
23
- preferSpark?: boolean;
24
- amountSatsToSend?: number;
25
- };
26
- type TransferParams = {
27
- amountSats: number;
28
- receiverSparkAddress: string;
29
- };
30
- type DepositParams = {
31
- signingPubKey: Uint8Array;
32
- verifyingKey: Uint8Array;
33
- depositTx: Transaction;
34
- vout: number;
35
- };
36
- /**
37
- * Token metadata containing essential information about a token.
38
- * This is the wallet's internal representation with JavaScript-friendly types.
39
- *
40
- * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human readable token identifier.
41
- *
42
- * tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
43
- *
44
- * @example
45
- * ```typescript
46
- * const tokenMetadata: TokenMetadata = {
47
- * rawTokenIdentifier: new Uint8Array([1, 2, 3]),
48
- * tokenPublicKey: "0348fbb...",
49
- * tokenName: "SparkToken",
50
- * tokenTicker: "SPK",
51
- * decimals: 8,
52
- * maxSupply: 1000000n
53
- * };
54
- * ```
55
- */
56
- type TokenMetadata = {
57
- /** Raw binary token identifier - This is used to encode the human readable token identifier */
58
- rawTokenIdentifier: Uint8Array;
59
- /** Hex-encoded public key of the token issuer - Same as issuerPublicKey */
60
- tokenPublicKey: string;
61
- /** Human-readable name of the token (e.g., SparkToken)*/
62
- tokenName: string;
63
- /** Short ticker symbol for the token (e.g., "SPK") */
64
- tokenTicker: string;
65
- /** Number of decimal places for token amounts */
66
- decimals: number;
67
- /** Maximum supply of tokens that can ever be minted */
68
- maxSupply: bigint;
69
- };
70
- type TokenBalanceMap = Map<HumanReadableTokenIdentifier, {
71
- balance: bigint;
72
- tokenMetadata: TokenMetadata;
73
- }>;
74
- type InitWalletResponse = {
75
- mnemonic?: string | undefined;
76
- };
77
- interface SparkWalletProps {
78
- mnemonicOrSeed?: Uint8Array | string;
79
- accountNumber?: number;
80
- signer?: SparkSigner;
81
- options?: ConfigOptions;
82
- }
83
- interface SparkWalletEvents {
84
- /** Emitted when an incoming transfer is successfully claimed. Includes the transfer ID and new total balance. */
85
- "transfer:claimed": (transferId: string, updatedBalance: number) => void;
86
- /** Emitted when a deposit is marked as available. Includes the deposit ID and new total balance. */
87
- "deposit:confirmed": (depositId: string, updatedBalance: number) => void;
88
- /** Emitted when the stream is connected */
89
- "stream:connected": () => void;
90
- /** Emitted when the stream disconnects and fails to reconnect after max attempts */
91
- "stream:disconnected": (reason: string) => void;
92
- /** Emitted when attempting to reconnect the stream */
93
- "stream:reconnecting": (attempt: number, maxAttempts: number, delayMs: number, error: string) => void;
94
- }
95
-
96
- declare function generateSignatureFromExistingAdaptor(signature: Uint8Array, adaptorPrivateKeyBytes: Uint8Array): Uint8Array;
97
- declare function generateAdaptorFromSignature(signature: Uint8Array): {
98
- adaptorSignature: Uint8Array;
99
- adaptorPrivateKey: Uint8Array;
100
- };
101
- declare function validateOutboundAdaptorSignature(pubkey: Uint8Array, hash: Uint8Array, signature: Uint8Array, adaptorPubkey: Uint8Array): boolean;
102
- declare function applyAdaptorToSignature(pubkey: Uint8Array, hash: Uint8Array, signature: Uint8Array, adaptorPrivateKeyBytes: Uint8Array): Uint8Array;
103
-
104
- declare function computeTaprootKeyNoScript(pubkey: Uint8Array): Uint8Array;
105
- declare function getP2TRScriptFromPublicKey(pubKey: Uint8Array, network: Network): Uint8Array;
106
- declare function getP2TRAddressFromPublicKey(pubKey: Uint8Array, network: Network): string;
107
- declare function getP2TRAddressFromPkScript(pkScript: Uint8Array, network: Network): string;
108
- declare function getP2WPKHAddressFromPublicKey(pubKey: Uint8Array, network: Network): string;
109
- declare function getTxFromRawTxHex(rawTxHex: string): btc.Transaction;
110
- declare function getTxFromRawTxBytes(rawTxBytes: Uint8Array): btc.Transaction;
111
- declare function getSigHashFromTx(tx: btc.Transaction, inputIndex: number, prevOutput: TransactionOutput): Uint8Array;
112
- declare function getTxId(tx: btc.Transaction): string;
113
- declare function getTxIdNoReverse(tx: btc.Transaction): string;
114
-
115
- declare function addPublicKeys(a: Uint8Array, b: Uint8Array): Uint8Array;
116
- declare function applyAdditiveTweakToPublicKey(pubkey: Uint8Array, tweak: Uint8Array): Uint8Array<ArrayBufferLike>;
117
- declare function subtractPublicKeys(a: Uint8Array, b: Uint8Array): Uint8Array<ArrayBufferLike>;
118
- declare function addPrivateKeys(a: Uint8Array, b: Uint8Array): Uint8Array<ArrayBufferLike>;
119
- declare function subtractPrivateKeys(a: Uint8Array, b: Uint8Array): Uint8Array<ArrayBufferLike>;
120
- declare function sumOfPrivateKeys(keys: Uint8Array[]): Uint8Array<ArrayBufferLike>;
121
- declare function lastKeyWithTarget(target: Uint8Array, keys: Uint8Array[]): Uint8Array<ArrayBufferLike>;
122
-
123
- declare function getLatestDepositTxId(address: string): Promise<string | null>;
124
- declare function isTxBroadcast(txid: string, baseUrl: string, network?: any): Promise<boolean>;
125
-
126
- declare function proofOfPossessionMessageHashForDepositAddress(userPubkey: Uint8Array, operatorPubkey: Uint8Array, depositAddress: string): Uint8Array;
127
-
128
- declare function collectResponses<T>(responses: PromiseSettledResult<T>[]): T[];
129
-
130
- declare function getRandomSigningNonce(): SigningNonce;
131
- declare function createSigningNonce(binding: Uint8Array, hiding: Uint8Array): SigningNonce;
132
- declare function getSigningCommitmentFromNonce(nonce: SigningNonce): SigningCommitment;
133
- declare function encodeSigningNonceToBytes(nonce: SigningNonce): Uint8Array;
134
- declare function decodeBytesToSigningNonce(bytes: Uint8Array): SigningNonce;
135
- declare function createSigningCommitment(binding: Uint8Array, hiding: Uint8Array): SigningCommitment;
136
- declare function encodeSigningCommitmentToBytes(commitment: SigningCommitment): Uint8Array;
137
- declare function decodeBytesToSigningCommitment(bytes: Uint8Array): SigningCommitment;
138
-
139
- declare function calculateAvailableTokenAmount(outputLeaves: OutputWithPreviousTransactionData[]): bigint;
140
- declare function checkIfSelectedOutputsAreAvailable(selectedOutputs: OutputWithPreviousTransactionData[], tokenOutputs: Map<string, OutputWithPreviousTransactionData[]>, tokenPublicKey: Uint8Array): boolean;
141
- declare function filterTokenBalanceForTokenPublicKey(tokenBalances: TokenBalanceMap, publicKey: string): {
142
- balance: bigint;
143
- };
144
-
145
- declare function getTransferPackageSigningPayload(transferID: string, transferPackage: TransferPackage): Uint8Array;
146
-
147
- declare const DEFAULT_FEE_SATS: number;
148
- /**
149
- * Subtracts the default fee from the amount if it's greater than the fee.
150
- * Returns the original amount if it's less than or equal to the fee.
151
- */
152
- declare function maybeApplyFee(amount: bigint): bigint;
153
- declare function createRefundTx(sequence: number, nodeOutPoint: TransactionInput, amountSats: bigint, receivingPubkey: Uint8Array, network: Network): Transaction;
154
- declare function getCurrentTimelock(currSequence?: number): number;
155
- declare function getTransactionSequence(currSequence?: number): number;
156
- declare function checkIfValidSequence(currSequence?: number): void;
157
- declare function getNextTransactionSequence(currSequence?: number, forRefresh?: boolean): {
158
- nextSequence: number;
159
- needRefresh: boolean;
160
- };
161
- declare function getEphemeralAnchorOutput(): TransactionOutput;
162
-
163
- interface LeafInfo {
164
- leafId: string;
165
- nodeTx: string;
166
- refundTx: string;
167
- }
168
- interface Utxo {
169
- txid: string;
170
- vout: number;
171
- value: bigint;
172
- script: string;
173
- publicKey: string;
174
- }
175
- interface FeeRate {
176
- satPerVbyte: number;
177
- }
178
- interface FeeBumpTxPackage {
179
- tx: string;
180
- feeBumpPsbt?: string;
181
- }
182
- interface FeeBumpTxChain {
183
- leafId: string;
184
- txPackages: FeeBumpTxPackage[];
185
- }
186
- interface TxChain {
187
- leafId: string;
188
- transactions: string[];
189
- }
190
- interface BroadcastConfig {
191
- bitcoinCoreRpcUrl?: string;
192
- rpcUsername?: string;
193
- rpcPassword?: string;
194
- autoBroadcast?: boolean;
195
- network?: "MAINNET" | "REGTEST" | "TESTNET" | "SIGNET" | "LOCAL";
196
- }
197
- interface BroadcastResult {
198
- success: boolean;
199
- txids?: string[];
200
- error?: string;
201
- broadcastedPackages?: number;
202
- }
203
- declare function isEphemeralAnchorOutput(script?: Uint8Array, amount?: bigint): boolean;
204
- declare function constructUnilateralExitTxs(nodeHexStrings: string[], sparkClient?: SparkServiceClient, network?: any): Promise<TxChain[]>;
205
- declare function constructUnilateralExitFeeBumpPackages(nodeHexStrings: string[], utxos: Utxo[], feeRate: FeeRate, electrsUrl: string, sparkClient?: SparkServiceClient, network?: any): Promise<FeeBumpTxChain[]>;
206
- declare function constructFeeBumpTx(txHex: string, utxos: Utxo[], feeRate: FeeRate, previousFeeBumpTx?: string): {
207
- feeBumpPsbt: string;
208
- usedUtxos: Utxo[];
209
- correctedParentTx?: string;
210
- };
211
-
212
- declare function getSparkAddressFromTaproot(taprootAddress: string): SparkAddressFormat;
213
-
214
- export { getEphemeralAnchorOutput as $, proofOfPossessionMessageHashForDepositAddress as A, collectResponses as B, type CreateLightningInvoiceParams as C, type DepositParams as D, getRandomSigningNonce as E, createSigningNonce as F, getSigningCommitmentFromNonce as G, encodeSigningNonceToBytes as H, type InitWalletResponse as I, decodeBytesToSigningNonce as J, createSigningCommitment as K, encodeSigningCommitmentToBytes as L, decodeBytesToSigningCommitment as M, calculateAvailableTokenAmount as N, checkIfSelectedOutputsAreAvailable as O, type PayLightningInvoiceParams as P, filterTokenBalanceForTokenPublicKey as Q, getTransferPackageSigningPayload as R, type SparkWalletProps as S, type TransferParams as T, DEFAULT_FEE_SATS as U, maybeApplyFee as V, createRefundTx as W, getCurrentTimelock as X, getTransactionSequence as Y, checkIfValidSequence as Z, getNextTransactionSequence as _, type TokenMetadata as a, type LeafInfo as a0, type Utxo as a1, type FeeRate as a2, type FeeBumpTxPackage as a3, type FeeBumpTxChain as a4, type TxChain as a5, type BroadcastConfig as a6, type BroadcastResult as a7, isEphemeralAnchorOutput as a8, constructUnilateralExitTxs as a9, constructUnilateralExitFeeBumpPackages as aa, constructFeeBumpTx as ab, getSparkAddressFromTaproot as ac, type TokenBalanceMap as b, type SparkWalletEvents as c, generateAdaptorFromSignature as d, applyAdaptorToSignature as e, computeTaprootKeyNoScript as f, generateSignatureFromExistingAdaptor as g, getP2TRScriptFromPublicKey as h, getP2TRAddressFromPublicKey as i, getP2TRAddressFromPkScript as j, getP2WPKHAddressFromPublicKey as k, getTxFromRawTxHex as l, getTxFromRawTxBytes as m, getSigHashFromTx as n, getTxId as o, getTxIdNoReverse as p, addPublicKeys as q, applyAdditiveTweakToPublicKey as r, subtractPublicKeys as s, addPrivateKeys as t, subtractPrivateKeys as u, validateOutboundAdaptorSignature as v, sumOfPrivateKeys as w, lastKeyWithTarget as x, getLatestDepositTxId as y, isTxBroadcast as z };
@@ -1,46 +0,0 @@
1
- import { NetworkType as NetworkType$1 } from '@buildonspark/lrc20-sdk';
2
- import * as btc from '@scure/btc-signer';
3
- import * as bitcoin from 'bitcoinjs-lib';
4
- import { N as Network$1 } from './spark-dM7EYXYQ.js';
5
- import { B as BitcoinNetwork } from './BitcoinNetwork-TnABML0T.js';
6
-
7
- declare enum Network {
8
- MAINNET = 0,
9
- TESTNET = 1,
10
- SIGNET = 2,
11
- REGTEST = 3,
12
- LOCAL = 4
13
- }
14
- type NetworkType = keyof typeof Network;
15
- declare const NetworkToProto: Record<Network, Network$1>;
16
- declare const getNetwork: (network: Network) => typeof btc.NETWORK;
17
- declare const LRC_WALLET_NETWORK: Readonly<{
18
- 0: bitcoin.networks.Network;
19
- 1: bitcoin.networks.Network;
20
- 2: bitcoin.networks.Network;
21
- 3: bitcoin.networks.Network;
22
- 4: bitcoin.networks.Network;
23
- }>;
24
- declare const LRC_WALLET_NETWORK_TYPE: Readonly<{
25
- 0: NetworkType$1.MAINNET;
26
- 1: NetworkType$1.TESTNET;
27
- 2: NetworkType$1.TESTNET;
28
- 3: NetworkType$1.REGTEST;
29
- 4: NetworkType$1.LOCAL;
30
- }>;
31
- /**
32
- * Utility function to determine the network from a Bitcoin address.
33
- *
34
- * @param {string} address - The Bitcoin address
35
- * @returns {BitcoinNetwork | null} The detected network or null if not detected
36
- */
37
- declare function getNetworkFromAddress(address: string): BitcoinNetwork.MAINNET | BitcoinNetwork.REGTEST | null;
38
- /**
39
- * Utility function to get the network enum value from a string.
40
- *
41
- * @param {string} network - The Bitcoin network to turn into an enum value
42
- * @returns {Network} The enum value matching the string
43
- */
44
- declare function getNetworkFromString(network?: string): Network;
45
-
46
- export { LRC_WALLET_NETWORK as L, Network as N, type NetworkType as a, NetworkToProto as b, LRC_WALLET_NETWORK_TYPE as c, getNetworkFromAddress as d, getNetworkFromString as e, getNetwork as g };
@@ -1,46 +0,0 @@
1
- import { NetworkType as NetworkType$1 } from '@buildonspark/lrc20-sdk';
2
- import * as btc from '@scure/btc-signer';
3
- import * as bitcoin from 'bitcoinjs-lib';
4
- import { N as Network$1 } from './spark-dM7EYXYQ.cjs';
5
- import { B as BitcoinNetwork } from './BitcoinNetwork-TnABML0T.cjs';
6
-
7
- declare enum Network {
8
- MAINNET = 0,
9
- TESTNET = 1,
10
- SIGNET = 2,
11
- REGTEST = 3,
12
- LOCAL = 4
13
- }
14
- type NetworkType = keyof typeof Network;
15
- declare const NetworkToProto: Record<Network, Network$1>;
16
- declare const getNetwork: (network: Network) => typeof btc.NETWORK;
17
- declare const LRC_WALLET_NETWORK: Readonly<{
18
- 0: bitcoin.networks.Network;
19
- 1: bitcoin.networks.Network;
20
- 2: bitcoin.networks.Network;
21
- 3: bitcoin.networks.Network;
22
- 4: bitcoin.networks.Network;
23
- }>;
24
- declare const LRC_WALLET_NETWORK_TYPE: Readonly<{
25
- 0: NetworkType$1.MAINNET;
26
- 1: NetworkType$1.TESTNET;
27
- 2: NetworkType$1.TESTNET;
28
- 3: NetworkType$1.REGTEST;
29
- 4: NetworkType$1.LOCAL;
30
- }>;
31
- /**
32
- * Utility function to determine the network from a Bitcoin address.
33
- *
34
- * @param {string} address - The Bitcoin address
35
- * @returns {BitcoinNetwork | null} The detected network or null if not detected
36
- */
37
- declare function getNetworkFromAddress(address: string): BitcoinNetwork.MAINNET | BitcoinNetwork.REGTEST | null;
38
- /**
39
- * Utility function to get the network enum value from a string.
40
- *
41
- * @param {string} network - The Bitcoin network to turn into an enum value
42
- * @returns {Network} The enum value matching the string
43
- */
44
- declare function getNetworkFromString(network?: string): Network;
45
-
46
- export { LRC_WALLET_NETWORK as L, Network as N, type NetworkType as a, NetworkToProto as b, LRC_WALLET_NETWORK_TYPE as c, getNetworkFromAddress as d, getNetworkFromString as e, getNetwork as g };