@buildonspark/spark-sdk 0.1.46 → 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 +14 -0
  2. package/dist/{chunk-I54FARY2.js → chunk-EAP3U3CW.js} +14 -14
  3. package/dist/chunk-GWFQ7EBA.js +3773 -0
  4. package/dist/{chunk-JB64OQES.js → chunk-NNX4OK44.js} +3488 -935
  5. package/dist/{RequestLightningSendInput-CN6BNg_g.d.ts → client-CvpTRpcw.d.cts} +422 -212
  6. package/dist/{RequestLightningSendInput-2cSh_In4.d.cts → 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 +20460 -23376
  11. package/dist/index.d.cts +15 -769
  12. package/dist/index.d.ts +15 -769
  13. package/dist/index.js +83 -73
  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 +84 -178
  18. package/dist/native/index.cjs +17112 -20106
  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-CKBsylfW.d.ts → sdk-types-BGCeea0G.d.ts} +1 -1
  30. package/dist/{sdk-types-Ct8xmN7l.d.cts → sdk-types-XUeQMLFP.d.cts} +1 -1
  31. package/dist/{spark-DbzGfse6.d.cts → spark-BbUrbvZz.d.cts} +1 -1
  32. package/dist/{spark-DbzGfse6.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} +2511 -4379
  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 +6 -34
  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 +17 -9
  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-4EMV7HHW.js +0 -277
  92. package/dist/chunk-C2S227QR.js +0 -2336
  93. package/dist/chunk-DXR2PXJU.js +0 -1122
  94. package/dist/chunk-GSI4OLXZ.js +0 -117
  95. package/dist/chunk-HHNQ3ZHC.js +0 -170
  96. package/dist/chunk-HSCLBJEL.js +0 -113
  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-N5VZVCGJ.js +0 -622
  101. package/dist/chunk-NSJF5F5O.js +0 -325
  102. package/dist/chunk-NTFKFRQ2.js +0 -3146
  103. package/dist/chunk-OFCJFZ4I.js +0 -24
  104. package/dist/chunk-QNNSEJ4P.js +0 -232
  105. package/dist/chunk-UXDODSDT.js +0 -838
  106. package/dist/chunk-VTUGIIWI.js +0 -0
  107. package/dist/chunk-Z5HIAYFT.js +0 -84
  108. package/dist/index-CKL5DodV.d.cts +0 -214
  109. package/dist/index-COm59SPw.d.ts +0 -214
  110. package/dist/network-Css46DAz.d.cts +0 -46
  111. package/dist/network-hynb7iTZ.d.ts +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-BP6F__oR.d.cts +0 -187
  140. package/dist/signer-BVZJXcq7.d.ts +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,237 +1,135 @@
1
1
  import {
2
- SparkWallet
3
- } from "./chunk-JB64OQES.js";
4
- import {
5
- DEFAULT_FEE_SATS,
6
- checkIfValidSequence,
7
- computeTaprootKeyNoScript,
2
+ MultisigReceiptInput,
3
+ SparkWallet,
4
+ TokenTransactionService,
5
+ checkIfSelectedOutputsAreAvailable,
6
+ collectResponses,
8
7
  constructFeeBumpTx,
9
8
  constructUnilateralExitFeeBumpPackages,
10
9
  constructUnilateralExitTxs,
11
- createRefundTx,
12
- getCurrentTimelock,
13
- getEphemeralAnchorOutput,
10
+ decodeHumanReadableTokenIdentifier,
11
+ decodeSparkAddress,
12
+ encodeHumanReadableTokenIdentifier,
13
+ encodeSparkAddress,
14
+ filterTokenBalanceForTokenPublicKey,
14
15
  getLatestDepositTxId,
15
- getNextTransactionSequence,
16
- getP2TRAddressFromPkScript,
17
- getP2TRAddressFromPublicKey,
18
- getP2TRScriptFromPublicKey,
19
- getP2WPKHAddressFromPublicKey,
20
- getSigHashFromTx,
21
16
  getSparkAddressFromTaproot,
22
- getTransactionSequence,
23
17
  getTransferPackageSigningPayload,
24
- getTxFromRawTxBytes,
25
- getTxFromRawTxHex,
26
- getTxId,
27
- getTxIdNoReverse,
28
18
  isEphemeralAnchorOutput,
29
19
  isTxBroadcast,
30
- maybeApplyFee,
31
- proofOfPossessionMessageHashForDepositAddress
32
- } from "./chunk-UXDODSDT.js";
33
- import "./chunk-HSCLBJEL.js";
20
+ isValidPublicKey,
21
+ isValidSparkAddress,
22
+ sumAvailableTokens
23
+ } from "./chunk-NNX4OK44.js";
24
+ import "./chunk-OBFKIEMP.js";
34
25
  import {
26
+ AuthenticationError,
27
+ ConfigurationError,
28
+ DEFAULT_FEE_SATS,
29
+ DefaultSparkSigner,
30
+ InternalValidationError,
35
31
  LRC_WALLET_NETWORK,
36
32
  LRC_WALLET_NETWORK_TYPE,
37
33
  Network,
34
+ NetworkError,
38
35
  NetworkToProto,
39
- getNetwork,
40
- getNetworkFromAddress,
41
- getNetworkFromString
42
- } from "./chunk-Z5HIAYFT.js";
43
- import "./chunk-DXR2PXJU.js";
44
- import "./chunk-HHNQ3ZHC.js";
45
- import "./chunk-C2S227QR.js";
46
- import {
47
- calculateAvailableTokenAmount,
48
- checkIfSelectedOutputsAreAvailable,
49
- collectResponses,
50
- filterTokenBalanceForTokenPublicKey
51
- } from "./chunk-HWJWKEIU.js";
52
- import "./chunk-4EMV7HHW.js";
53
- import "./chunk-L3EHBOUX.js";
54
- import "./chunk-KMUMFYFX.js";
55
- import "./chunk-NTFKFRQ2.js";
56
- import "./chunk-LHRD2WT6.js";
57
- import "./chunk-N5VZVCGJ.js";
58
- import {
36
+ NotImplementedError,
37
+ RPCError,
38
+ SparkSDKError,
39
+ TaprootOutputKeysGenerator,
40
+ TaprootSparkSigner,
41
+ ValidationError,
42
+ WalletConfig,
59
43
  addPrivateKeys,
60
44
  addPublicKeys,
61
45
  applyAdaptorToSignature,
62
46
  applyAdditiveTweakToPublicKey,
47
+ bigIntToPrivateKey,
48
+ checkIfValidSequence,
49
+ computeTaprootKeyNoScript,
50
+ computerLagrangeCoefficients,
51
+ createRefundTx,
63
52
  createSigningCommitment,
64
53
  createSigningNonce,
65
54
  decodeBytesToSigningCommitment,
66
55
  decodeBytesToSigningNonce,
67
56
  encodeSigningCommitmentToBytes,
68
57
  encodeSigningNonceToBytes,
58
+ evaluatePolynomial,
59
+ fieldDiv,
69
60
  generateAdaptorFromSignature,
61
+ generatePolynomialForSecretSharing,
70
62
  generateSignatureFromExistingAdaptor,
63
+ getCurrentTimelock,
64
+ getEphemeralAnchorOutput,
65
+ getNetwork,
66
+ getNetworkFromAddress,
67
+ getNetworkFromString,
68
+ getNextTransactionSequence,
69
+ getP2TRAddressFromPkScript,
70
+ getP2TRAddressFromPublicKey,
71
+ getP2TRScriptFromPublicKey,
72
+ getP2WPKHAddressFromPublicKey,
73
+ getRandomBigInt,
71
74
  getRandomSigningNonce,
75
+ getSigHashFromTx,
72
76
  getSigningCommitmentFromNonce,
77
+ getTransactionSequence,
78
+ getTxFromRawTxBytes,
79
+ getTxFromRawTxHex,
80
+ getTxId,
81
+ getTxIdNoReverse,
73
82
  lastKeyWithTarget,
74
- subtractPrivateKeys,
75
- subtractPublicKeys,
76
- sumOfPrivateKeys,
77
- validateOutboundAdaptorSignature
78
- } from "./chunk-NSJF5F5O.js";
79
- import "./chunk-OFCJFZ4I.js";
80
- import {
81
- bigIntToPrivateKey,
82
- computerLagrangeCoefficients,
83
- evaluatePolynomial,
84
- fieldDiv,
85
- generatePolynomialForSecretSharing,
86
- getRandomBigInt,
83
+ maybeApplyFee,
87
84
  modInverse,
85
+ proofOfPossessionMessageHashForDepositAddress,
86
+ protoToNetwork,
88
87
  recoverSecret,
88
+ setCrypto,
89
89
  splitSecret,
90
90
  splitSecretWithProofs,
91
+ subtractPrivateKeys,
92
+ subtractPublicKeys,
93
+ sumOfPrivateKeys,
94
+ validateOutboundAdaptorSignature,
91
95
  validateShare
92
- } from "./chunk-QNNSEJ4P.js";
93
- import "./chunk-VTUGIIWI.js";
94
- import {
95
- AuthenticationError,
96
- ConfigurationError,
97
- InternalValidationError,
98
- NetworkError,
99
- NotImplementedError,
100
- RPCError,
101
- SparkSDKError,
102
- ValidationError
103
- } from "./chunk-GSI4OLXZ.js";
104
- import "./chunk-OBFKIEMP.js";
105
- import "./chunk-I54FARY2.js";
106
- import "./chunk-HMLOC6TE.js";
96
+ } from "./chunk-GWFQ7EBA.js";
97
+ import "./chunk-LHRD2WT6.js";
107
98
  import "./chunk-BGGEVUJK.js";
99
+ import "./chunk-EAP3U3CW.js";
100
+ import "./chunk-HMLOC6TE.js";
108
101
  import "./chunk-MVRQ5US7.js";
109
102
 
110
- // src/spark-wallet/spark-wallet.node.ts
111
- var SparkWallet2 = class extends SparkWallet {
112
- tracer = null;
113
- wrapWithOtelSpan(name, fn) {
114
- return async (...args) => {
115
- if (!this.tracer) {
116
- throw new Error("Tracer not initialized");
117
- }
118
- return await this.tracer.startActiveSpan(name, async (span) => {
119
- const traceId = span.spanContext().traceId;
120
- try {
121
- return await fn(...args);
122
- } catch (error) {
123
- if (error instanceof Error) {
124
- error.message += ` [traceId: ${traceId}]`;
125
- } else if (typeof error === "object" && error !== null) {
126
- error.traceId = traceId;
127
- }
128
- throw error;
129
- } finally {
130
- span.end();
131
- }
132
- });
133
- };
134
- }
135
- async initializeTracer(tracerName) {
136
- const { trace, propagation, context } = await import("@opentelemetry/api");
137
- const { W3CTraceContextPropagator } = await import("@opentelemetry/core");
138
- const { AsyncLocalStorageContextManager } = await import("@opentelemetry/context-async-hooks");
139
- const { BasicTracerProvider } = await import("@opentelemetry/sdk-trace-base");
140
- trace.setGlobalTracerProvider(new BasicTracerProvider());
141
- propagation.setGlobalPropagator(new W3CTraceContextPropagator());
142
- context.setGlobalContextManager(new AsyncLocalStorageContextManager());
143
- this.tracer = trace.getTracer(tracerName);
144
- }
145
- wrapSparkWalletWithTracing() {
146
- this.getIdentityPublicKey = this.wrapWithOtelSpan(
147
- "SparkWallet.getIdentityPublicKey",
148
- this.getIdentityPublicKey.bind(this)
149
- );
150
- this.getSparkAddress = this.wrapWithOtelSpan(
151
- "SparkWallet.getSparkAddress",
152
- this.getSparkAddress.bind(this)
153
- );
154
- this.getSwapFeeEstimate = this.wrapWithOtelSpan(
155
- "SparkWallet.getSwapFeeEstimate",
156
- this.getSwapFeeEstimate.bind(this)
157
- );
158
- this.getTransfers = this.wrapWithOtelSpan(
159
- "SparkWallet.getTransfers",
160
- this.getTransfers.bind(this)
161
- );
162
- this.getBalance = this.wrapWithOtelSpan(
163
- "SparkWallet.getBalance",
164
- this.getBalance.bind(this)
165
- );
166
- this.getSingleUseDepositAddress = this.wrapWithOtelSpan(
167
- "SparkWallet.getSingleUseDepositAddress",
168
- this.getSingleUseDepositAddress.bind(this)
169
- );
170
- this.getUnusedDepositAddresses = this.wrapWithOtelSpan(
171
- "SparkWallet.getUnusedDepositAddresses",
172
- this.getUnusedDepositAddresses.bind(this)
173
- );
174
- this.claimDeposit = this.wrapWithOtelSpan(
175
- "SparkWallet.claimDeposit",
176
- this.claimDeposit.bind(this)
177
- );
178
- this.advancedDeposit = this.wrapWithOtelSpan(
179
- "SparkWallet.advancedDeposit",
180
- this.advancedDeposit.bind(this)
181
- );
182
- this.transfer = this.wrapWithOtelSpan(
183
- "SparkWallet.transfer",
184
- this.transfer.bind(this)
185
- );
186
- this.createLightningInvoice = this.wrapWithOtelSpan(
187
- "SparkWallet.createLightningInvoice",
188
- this.createLightningInvoice.bind(this)
189
- );
190
- this.payLightningInvoice = this.wrapWithOtelSpan(
191
- "SparkWallet.payLightningInvoice",
192
- this.payLightningInvoice.bind(this)
193
- );
194
- this.getLightningSendFeeEstimate = this.wrapWithOtelSpan(
195
- "SparkWallet.getLightningSendFeeEstimate",
196
- this.getLightningSendFeeEstimate.bind(this)
197
- );
198
- this.withdraw = this.wrapWithOtelSpan(
199
- "SparkWallet.withdraw",
200
- this.withdraw.bind(this)
201
- );
202
- this.getWithdrawalFeeQuote = this.wrapWithOtelSpan(
203
- "SparkWallet.getWithdrawalFeeQuote",
204
- this.getWithdrawalFeeQuote.bind(this)
205
- );
206
- }
207
- async initWallet(mnemonicOrSeed, accountNumber) {
208
- const res = super.initWallet(mnemonicOrSeed, accountNumber);
209
- await this.initializeTracer(this.tracerId);
210
- this.wrapSparkWalletWithTracing();
211
- return res;
212
- }
213
- };
103
+ // src/index.node.ts
104
+ import nodeCrypto from "crypto";
105
+ var cryptoImpl = typeof global !== "undefined" && global.crypto ? global.crypto : nodeCrypto;
106
+ setCrypto(cryptoImpl);
214
107
  export {
215
108
  AuthenticationError,
216
109
  ConfigurationError,
217
110
  DEFAULT_FEE_SATS,
111
+ DefaultSparkSigner,
218
112
  InternalValidationError,
219
113
  LRC_WALLET_NETWORK,
220
114
  LRC_WALLET_NETWORK_TYPE,
115
+ MultisigReceiptInput,
221
116
  Network,
222
117
  NetworkError,
223
118
  NetworkToProto,
224
119
  NotImplementedError,
225
120
  RPCError,
226
121
  SparkSDKError,
227
- SparkWallet2 as SparkWallet,
122
+ SparkWallet,
123
+ TaprootOutputKeysGenerator,
124
+ TaprootSparkSigner,
125
+ TokenTransactionService,
228
126
  ValidationError,
127
+ WalletConfig,
229
128
  addPrivateKeys,
230
129
  addPublicKeys,
231
130
  applyAdaptorToSignature,
232
131
  applyAdditiveTweakToPublicKey,
233
132
  bigIntToPrivateKey,
234
- calculateAvailableTokenAmount,
235
133
  checkIfSelectedOutputsAreAvailable,
236
134
  checkIfValidSequence,
237
135
  collectResponses,
@@ -245,8 +143,12 @@ export {
245
143
  createSigningNonce,
246
144
  decodeBytesToSigningCommitment,
247
145
  decodeBytesToSigningNonce,
146
+ decodeHumanReadableTokenIdentifier,
147
+ decodeSparkAddress,
148
+ encodeHumanReadableTokenIdentifier,
248
149
  encodeSigningCommitmentToBytes,
249
150
  encodeSigningNonceToBytes,
151
+ encodeSparkAddress,
250
152
  evaluatePolynomial,
251
153
  fieldDiv,
252
154
  filterTokenBalanceForTokenPublicKey,
@@ -277,15 +179,19 @@ export {
277
179
  getTxIdNoReverse,
278
180
  isEphemeralAnchorOutput,
279
181
  isTxBroadcast,
182
+ isValidPublicKey,
183
+ isValidSparkAddress,
280
184
  lastKeyWithTarget,
281
185
  maybeApplyFee,
282
186
  modInverse,
283
187
  proofOfPossessionMessageHashForDepositAddress,
188
+ protoToNetwork,
284
189
  recoverSecret,
285
190
  splitSecret,
286
191
  splitSecretWithProofs,
287
192
  subtractPrivateKeys,
288
193
  subtractPublicKeys,
194
+ sumAvailableTokens,
289
195
  sumOfPrivateKeys,
290
196
  validateOutboundAdaptorSignature,
291
197
  validateShare