@buildonspark/spark-sdk 0.1.41 → 0.1.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/android/src/main/jniLibs/arm64-v8a/libuniffi_spark_frost.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libuniffi_spark_frost.so +0 -0
- package/android/src/main/jniLibs/x86/libuniffi_spark_frost.so +0 -0
- package/android/src/main/jniLibs/x86_64/libuniffi_spark_frost.so +0 -0
- package/dist/LightningSendFeeEstimateInput-BgOhEAI-.d.cts +10 -0
- package/dist/LightningSendFeeEstimateInput-BgOhEAI-.d.ts +10 -0
- package/dist/{RequestLightningSendInput-mXUWn_cp.d.ts → RequestLightningSendInput-D7fZdT4A.d.ts} +35 -16
- package/dist/{RequestLightningSendInput-DXcLoiCe.d.cts → RequestLightningSendInput-Na1mHdWg.d.cts} +35 -16
- package/dist/address/index.cjs +38 -7
- package/dist/address/index.d.cts +2 -2
- package/dist/address/index.d.ts +2 -2
- package/dist/address/index.js +3 -3
- package/dist/{chunk-ATEHMLKP.js → chunk-6AFUC5M2.js} +1 -1
- package/dist/{chunk-ZXDE2XMU.js → chunk-BUTZWYBW.js} +9 -6
- package/dist/{chunk-7EFSUADA.js → chunk-DOA6QXYQ.js} +1 -0
- package/dist/{chunk-J5W5Q2ZP.js → chunk-DQYKQJRZ.js} +291 -7
- package/dist/{chunk-TWF35O6M.js → chunk-GSI4OLXZ.js} +32 -1
- package/dist/{chunk-2ZXXLPG2.js → chunk-GYQR4B4P.js} +5 -4
- package/dist/{chunk-ROKY5KS4.js → chunk-HRQRRDSS.js} +53 -15
- package/dist/{chunk-YEZDPUFY.js → chunk-IRW5TWMH.js} +8 -8
- package/dist/{chunk-7VMYMQLF.js → chunk-NSJF5F5O.js} +1 -1
- package/dist/{chunk-TM4TOEOX.js → chunk-O4RYNJNB.js} +3 -3
- package/dist/{chunk-MGPRLH6Q.js → chunk-QNNSEJ4P.js} +1 -1
- package/dist/{chunk-UKT6OFLO.js → chunk-TIUBYNN5.js} +13 -7
- package/dist/{chunk-6YVPOQ2A.js → chunk-TOSP3INR.js} +235 -143
- package/dist/chunk-VFJQNBFX.js +21 -0
- package/dist/{chunk-KKSU7OZO.js → chunk-WWOTVNPP.js} +195 -67
- package/dist/{chunk-HK6LPV6Z.js → chunk-Z5HIAYFT.js} +1 -1
- package/dist/graphql/objects/index.cjs +229 -135
- package/dist/graphql/objects/index.d.cts +54 -9
- package/dist/graphql/objects/index.d.ts +54 -9
- package/dist/graphql/objects/index.js +3 -3
- package/dist/{index-OSDtPMmC.d.ts → index-7RYRH5wc.d.ts} +10 -8
- package/dist/{index-CFh4uWzi.d.cts → index-BJOc8Ur-.d.cts} +10 -8
- package/dist/index.cjs +790 -315
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +26 -26
- package/dist/index.node.cjs +790 -315
- package/dist/index.node.d.cts +9 -8
- package/dist/index.node.d.ts +9 -8
- package/dist/index.node.js +26 -26
- package/dist/native/index.cjs +812 -332
- package/dist/native/index.d.cts +53 -18
- package/dist/native/index.d.ts +53 -18
- package/dist/native/index.js +659 -181
- package/dist/{network-BiwBmoOg.d.cts → network-D5lKssVl.d.cts} +1 -1
- package/dist/{network-BF2GYPye.d.ts → network-xkBSpaTn.d.ts} +1 -1
- package/dist/proto/lrc20.d.cts +1 -1
- package/dist/proto/lrc20.d.ts +1 -1
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark_token.d.cts +1 -1
- package/dist/proto/spark_token.d.ts +1 -1
- package/dist/{sdk-types-CfhdFnsA.d.cts → sdk-types-B-q9py_P.d.cts} +1 -1
- package/dist/{sdk-types-MnQrHolg.d.ts → sdk-types-BPoPgzda.d.ts} +1 -1
- package/dist/services/config.cjs +118 -69
- package/dist/services/config.d.cts +6 -4
- package/dist/services/config.d.ts +6 -4
- package/dist/services/config.js +9 -9
- package/dist/services/connection.cjs +95 -15
- package/dist/services/connection.d.cts +6 -4
- package/dist/services/connection.d.ts +6 -4
- package/dist/services/connection.js +3 -3
- package/dist/services/index.cjs +487 -117
- package/dist/services/index.d.cts +5 -4
- package/dist/services/index.d.ts +5 -4
- package/dist/services/index.js +19 -19
- package/dist/services/lrc-connection.cjs +50 -7
- package/dist/services/lrc-connection.d.cts +5 -4
- package/dist/services/lrc-connection.d.ts +5 -4
- package/dist/services/lrc-connection.js +3 -3
- package/dist/services/token-transactions.cjs +351 -36
- package/dist/services/token-transactions.d.cts +5 -4
- package/dist/services/token-transactions.d.ts +5 -4
- package/dist/services/token-transactions.js +6 -6
- package/dist/services/wallet-config.cjs +1 -0
- package/dist/services/wallet-config.d.cts +6 -4
- package/dist/services/wallet-config.d.ts +6 -4
- package/dist/services/wallet-config.js +1 -1
- package/dist/signer/signer.cjs +117 -64
- package/dist/signer/signer.d.cts +4 -3
- package/dist/signer/signer.d.ts +4 -3
- package/dist/signer/signer.js +15 -7
- package/dist/{signer-CylxIujU.d.ts → signer-IO3oMRNj.d.cts} +2 -1
- package/dist/{signer-BhLS7SYR.d.cts → signer-wqesWifN.d.ts} +2 -1
- package/dist/{spark-DjR1b3TC.d.cts → spark-CDm4gqS6.d.cts} +1 -1
- package/dist/{spark-DjR1b3TC.d.ts → spark-CDm4gqS6.d.ts} +1 -1
- package/dist/types/index.cjs +282 -188
- package/dist/types/index.d.cts +7 -6
- package/dist/types/index.d.ts +7 -6
- package/dist/types/index.js +3 -3
- package/dist/utils/index.cjs +90 -58
- package/dist/utils/index.d.cts +6 -5
- package/dist/utils/index.d.ts +6 -5
- package/dist/utils/index.js +16 -16
- package/ios/spark_frostFFI.xcframework/ios-arm64/SparkFrost +0 -0
- package/ios/spark_frostFFI.xcframework/ios-arm64/spark_frostFFI.framework/spark_frostFFI +0 -0
- package/ios/spark_frostFFI.xcframework/ios-arm64_x86_64-simulator/SparkFrost +0 -0
- package/ios/spark_frostFFI.xcframework/ios-arm64_x86_64-simulator/spark_frostFFI.framework/spark_frostFFI +0 -0
- package/ios/spark_frostFFI.xcframework/macos-arm64_x86_64/spark_frostFFI.framework/spark_frostFFI +0 -0
- package/package.json +4 -4
- package/src/constants.ts +21 -0
- package/src/errors/base.ts +43 -1
- package/src/graphql/client.ts +4 -0
- package/src/graphql/mutations/RequestLightningSend.ts +2 -0
- package/src/graphql/objects/ClaimStaticDepositInput.ts +1 -1
- package/src/graphql/objects/ClaimStaticDepositStatus.ts +4 -2
- package/src/graphql/objects/Connection.ts +7 -7
- package/src/graphql/objects/CoopExitFeeEstimate.ts +1 -1
- package/src/graphql/objects/CoopExitFeeQuote.ts +202 -0
- package/src/graphql/objects/CoopExitFeeQuoteInput.ts +41 -0
- package/src/graphql/objects/CoopExitFeeQuoteOutput.ts +45 -0
- package/src/graphql/objects/CoopExitRequest.ts +21 -0
- package/src/graphql/objects/CurrencyUnit.ts +26 -28
- package/src/graphql/objects/Entity.ts +84 -0
- package/src/graphql/objects/Invoice.ts +2 -2
- package/src/graphql/objects/Leaf.ts +1 -1
- package/src/graphql/objects/LeavesSwapFeeEstimateOutput.ts +1 -1
- package/src/graphql/objects/LeavesSwapRequest.ts +6 -0
- package/src/graphql/objects/LightningReceiveRequest.ts +11 -0
- package/src/graphql/objects/LightningSendFeeEstimateInput.ts +8 -0
- package/src/graphql/objects/LightningSendFeeEstimateOutput.ts +1 -1
- package/src/graphql/objects/LightningSendRequest.ts +3 -0
- package/src/graphql/objects/RequestCoopExitInput.ts +8 -0
- package/src/graphql/objects/RequestLeavesSwapInput.ts +5 -1
- package/src/graphql/objects/RequestLightningReceiveInput.ts +9 -2
- package/src/graphql/objects/RequestLightningSendInput.ts +8 -0
- package/src/graphql/objects/SparkCoopExitRequestStatus.ts +2 -0
- package/src/graphql/objects/SparkUserRequestType.ts +2 -0
- package/src/graphql/objects/SparkWalletUser.ts +20 -0
- package/src/graphql/objects/UserRequest.ts +32 -0
- package/src/graphql/objects/VerifyChallengeInput.ts +1 -1
- package/src/graphql/objects/index.ts +12 -3
- package/src/graphql/queries/LightningSendFeeEstimate.ts +2 -0
- package/src/logger.ts +3 -0
- package/src/native/index.ts +1 -0
- package/src/services/config.ts +4 -0
- package/src/services/connection.ts +68 -29
- package/src/services/coop-exit.ts +1 -1
- package/src/services/lightning.ts +25 -1
- package/src/services/lrc-connection.ts +3 -3
- package/src/services/token-transactions.ts +6 -2
- package/src/services/wallet-config.ts +2 -0
- package/src/signer/signer.ts +4 -1
- package/src/spark-wallet/spark-wallet.ts +51 -15
- package/src/spark-wallet/types.ts +1 -0
- package/src/tests/errors.test.ts +58 -0
- package/src/tests/integration/lightning.test.ts +184 -0
- package/src/tests/integration/ssp/static_deposit.test.ts +1 -2
- package/src/tests/tokens.test.ts +52 -3
- package/src/utils/token-hashing.ts +335 -1
- package/dist/LightningSendFeeEstimateInput-CJvPnCSB.d.cts +0 -5
- package/dist/LightningSendFeeEstimateInput-CJvPnCSB.d.ts +0 -5
- package/dist/chunk-HKAKEKCE.js +0 -8
package/dist/types/index.d.cts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
export { B as BitcoinNetwork } from '../BitcoinNetwork-TnABML0T.cjs';
|
|
2
|
-
export { ClaimStaticDeposit, ClaimStaticDepositInput, ClaimStaticDepositRequestType, ClaimStaticDepositStatus, CompleteCoopExitOutput, CompleteLeavesSwapOutput, CompleteSeedReleaseInput, CompleteSeedReleaseOutput, Connection, Entity, GetChallengeInput, LeavesSwapFeeEstimateInput, NotifyReceiverTransferInput, Provider, RequestCoopExitOutput, RequestLeavesSwapOutput, RequestLightningReceiveOutput, RequestLightningSendOutput, SparkUserRequestStatus, SparkUserRequestType, SparkWalletUser, SparkWalletUserToUserRequestsConnection, StartSeedReleaseInput, UserRequest, VerifyChallengeInput, WalletUserIdentityPublicKeyInput, WalletUserIdentityPublicKeyOutput, getClaimStaticDepositQuery, getUserRequestQuery } from '../graphql/objects/index.cjs';
|
|
3
|
-
export { C as ClaimStaticDepositOutput, a as CompleteCoopExitInput, b as CompleteLeavesSwapInput, c as CoopExitFeeEstimate, d as CoopExitFeeEstimatesInput, e as CoopExitFeeEstimatesOutput, f as CoopExitRequest, h as CurrencyAmount, i as CurrencyUnit, E as ExitSpeed, G as GetChallengeOutput, I as Invoice, L as Leaf, j as LeavesSwapFeeEstimateOutput, l as LeavesSwapRequest, n as LightningReceiveRequest, o as LightningReceiveRequestStatus, p as LightningSendFeeEstimateOutput, r as LightningSendRequest, s as LightningSendRequestStatus, P as PageInfo, R as RequestCoopExitInput, t as RequestLeavesSwapInput, u as RequestLightningReceiveInput, v as RequestLightningSendInput, S as SparkCoopExitRequestStatus, w as SparkLeavesSwapRequestStatus, x as SparkTransferToLeavesConnection, y as StaticDepositQuoteInput, z as StaticDepositQuoteOutput, A as SwapLeaf, T as Transfer, U as UserLeafInput, V as VerifyChallengeOutput, g as getCoopExitRequestQuery, k as getLeavesSwapRequestQuery, m as getLightningReceiveRequestQuery, q as getLightningSendRequestQuery } from '../RequestLightningSendInput-
|
|
4
|
-
export { L as LightningSendFeeEstimateInput } from '../LightningSendFeeEstimateInput-
|
|
5
|
-
export { c as CommonProto, s as SparkProto } from '../spark-
|
|
6
|
-
export { T as TransferDirection, W as WalletLeaf, a as WalletTransfer, b as WalletTransferLeaf, c as mapTransferLeafToWalletTransferLeaf, d as mapTransferToWalletTransfer, m as mapTreeNodeToWalletLeaf } from '../sdk-types-
|
|
2
|
+
export { ClaimStaticDeposit, ClaimStaticDepositInput, ClaimStaticDepositRequestType, ClaimStaticDepositStatus, CompleteCoopExitOutput, CompleteLeavesSwapOutput, CompleteSeedReleaseInput, CompleteSeedReleaseOutput, Connection, CoopExitFeeQuote, CoopExitFeeQuoteInput, CoopExitFeeQuoteOutput, Entity, GetChallengeInput, LeavesSwapFeeEstimateInput, NotifyReceiverTransferInput, Provider, RequestCoopExitOutput, RequestLeavesSwapOutput, RequestLightningReceiveOutput, RequestLightningSendOutput, SparkUserRequestStatus, SparkUserRequestType, SparkWalletUser, SparkWalletUserToUserRequestsConnection, StartSeedReleaseInput, UserRequest, VerifyChallengeInput, WalletUserIdentityPublicKeyInput, WalletUserIdentityPublicKeyOutput, getClaimStaticDepositQuery, getCoopExitFeeQuoteQuery, getUserRequestQuery } from '../graphql/objects/index.cjs';
|
|
3
|
+
export { C as ClaimStaticDepositOutput, a as CompleteCoopExitInput, b as CompleteLeavesSwapInput, c as CoopExitFeeEstimate, d as CoopExitFeeEstimatesInput, e as CoopExitFeeEstimatesOutput, f as CoopExitRequest, h as CurrencyAmount, i as CurrencyUnit, E as ExitSpeed, G as GetChallengeOutput, I as Invoice, L as Leaf, j as LeavesSwapFeeEstimateOutput, l as LeavesSwapRequest, n as LightningReceiveRequest, o as LightningReceiveRequestStatus, p as LightningSendFeeEstimateOutput, r as LightningSendRequest, s as LightningSendRequestStatus, P as PageInfo, R as RequestCoopExitInput, t as RequestLeavesSwapInput, u as RequestLightningReceiveInput, v as RequestLightningSendInput, S as SparkCoopExitRequestStatus, w as SparkLeavesSwapRequestStatus, x as SparkTransferToLeavesConnection, y as StaticDepositQuoteInput, z as StaticDepositQuoteOutput, A as SwapLeaf, T as Transfer, U as UserLeafInput, V as VerifyChallengeOutput, g as getCoopExitRequestQuery, k as getLeavesSwapRequestQuery, m as getLightningReceiveRequestQuery, q as getLightningSendRequestQuery } from '../RequestLightningSendInput-Na1mHdWg.cjs';
|
|
4
|
+
export { L as LightningSendFeeEstimateInput } from '../LightningSendFeeEstimateInput-BgOhEAI-.cjs';
|
|
5
|
+
export { c as CommonProto, s as SparkProto } from '../spark-CDm4gqS6.cjs';
|
|
6
|
+
export { T as TransferDirection, W as WalletLeaf, a as WalletTransfer, b as WalletTransferLeaf, c as mapTransferLeafToWalletTransferLeaf, d as mapTransferToWalletTransfer, m as mapTreeNodeToWalletLeaf } from '../sdk-types-B-q9py_P.cjs';
|
|
7
7
|
import '@lightsparkdev/core';
|
|
8
|
-
import '../signer-
|
|
8
|
+
import '../signer-IO3oMRNj.cjs';
|
|
9
9
|
import '@scure/bip32';
|
|
10
10
|
import '@buildonspark/lrc20-sdk';
|
|
11
11
|
import '@scure/btc-signer';
|
|
12
12
|
import 'bitcoinjs-lib';
|
|
13
|
+
import '@buildonspark/lrc20-sdk/lrc/types';
|
|
13
14
|
import '@bufbuild/protobuf/wire';
|
|
14
15
|
import 'nice-grpc-common';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
export { B as BitcoinNetwork } from '../BitcoinNetwork-TnABML0T.js';
|
|
2
|
-
export { ClaimStaticDeposit, ClaimStaticDepositInput, ClaimStaticDepositRequestType, ClaimStaticDepositStatus, CompleteCoopExitOutput, CompleteLeavesSwapOutput, CompleteSeedReleaseInput, CompleteSeedReleaseOutput, Connection, Entity, GetChallengeInput, LeavesSwapFeeEstimateInput, NotifyReceiverTransferInput, Provider, RequestCoopExitOutput, RequestLeavesSwapOutput, RequestLightningReceiveOutput, RequestLightningSendOutput, SparkUserRequestStatus, SparkUserRequestType, SparkWalletUser, SparkWalletUserToUserRequestsConnection, StartSeedReleaseInput, UserRequest, VerifyChallengeInput, WalletUserIdentityPublicKeyInput, WalletUserIdentityPublicKeyOutput, getClaimStaticDepositQuery, getUserRequestQuery } from '../graphql/objects/index.js';
|
|
3
|
-
export { C as ClaimStaticDepositOutput, a as CompleteCoopExitInput, b as CompleteLeavesSwapInput, c as CoopExitFeeEstimate, d as CoopExitFeeEstimatesInput, e as CoopExitFeeEstimatesOutput, f as CoopExitRequest, h as CurrencyAmount, i as CurrencyUnit, E as ExitSpeed, G as GetChallengeOutput, I as Invoice, L as Leaf, j as LeavesSwapFeeEstimateOutput, l as LeavesSwapRequest, n as LightningReceiveRequest, o as LightningReceiveRequestStatus, p as LightningSendFeeEstimateOutput, r as LightningSendRequest, s as LightningSendRequestStatus, P as PageInfo, R as RequestCoopExitInput, t as RequestLeavesSwapInput, u as RequestLightningReceiveInput, v as RequestLightningSendInput, S as SparkCoopExitRequestStatus, w as SparkLeavesSwapRequestStatus, x as SparkTransferToLeavesConnection, y as StaticDepositQuoteInput, z as StaticDepositQuoteOutput, A as SwapLeaf, T as Transfer, U as UserLeafInput, V as VerifyChallengeOutput, g as getCoopExitRequestQuery, k as getLeavesSwapRequestQuery, m as getLightningReceiveRequestQuery, q as getLightningSendRequestQuery } from '../RequestLightningSendInput-
|
|
4
|
-
export { L as LightningSendFeeEstimateInput } from '../LightningSendFeeEstimateInput-
|
|
5
|
-
export { c as CommonProto, s as SparkProto } from '../spark-
|
|
6
|
-
export { T as TransferDirection, W as WalletLeaf, a as WalletTransfer, b as WalletTransferLeaf, c as mapTransferLeafToWalletTransferLeaf, d as mapTransferToWalletTransfer, m as mapTreeNodeToWalletLeaf } from '../sdk-types-
|
|
2
|
+
export { ClaimStaticDeposit, ClaimStaticDepositInput, ClaimStaticDepositRequestType, ClaimStaticDepositStatus, CompleteCoopExitOutput, CompleteLeavesSwapOutput, CompleteSeedReleaseInput, CompleteSeedReleaseOutput, Connection, CoopExitFeeQuote, CoopExitFeeQuoteInput, CoopExitFeeQuoteOutput, Entity, GetChallengeInput, LeavesSwapFeeEstimateInput, NotifyReceiverTransferInput, Provider, RequestCoopExitOutput, RequestLeavesSwapOutput, RequestLightningReceiveOutput, RequestLightningSendOutput, SparkUserRequestStatus, SparkUserRequestType, SparkWalletUser, SparkWalletUserToUserRequestsConnection, StartSeedReleaseInput, UserRequest, VerifyChallengeInput, WalletUserIdentityPublicKeyInput, WalletUserIdentityPublicKeyOutput, getClaimStaticDepositQuery, getCoopExitFeeQuoteQuery, getUserRequestQuery } from '../graphql/objects/index.js';
|
|
3
|
+
export { C as ClaimStaticDepositOutput, a as CompleteCoopExitInput, b as CompleteLeavesSwapInput, c as CoopExitFeeEstimate, d as CoopExitFeeEstimatesInput, e as CoopExitFeeEstimatesOutput, f as CoopExitRequest, h as CurrencyAmount, i as CurrencyUnit, E as ExitSpeed, G as GetChallengeOutput, I as Invoice, L as Leaf, j as LeavesSwapFeeEstimateOutput, l as LeavesSwapRequest, n as LightningReceiveRequest, o as LightningReceiveRequestStatus, p as LightningSendFeeEstimateOutput, r as LightningSendRequest, s as LightningSendRequestStatus, P as PageInfo, R as RequestCoopExitInput, t as RequestLeavesSwapInput, u as RequestLightningReceiveInput, v as RequestLightningSendInput, S as SparkCoopExitRequestStatus, w as SparkLeavesSwapRequestStatus, x as SparkTransferToLeavesConnection, y as StaticDepositQuoteInput, z as StaticDepositQuoteOutput, A as SwapLeaf, T as Transfer, U as UserLeafInput, V as VerifyChallengeOutput, g as getCoopExitRequestQuery, k as getLeavesSwapRequestQuery, m as getLightningReceiveRequestQuery, q as getLightningSendRequestQuery } from '../RequestLightningSendInput-D7fZdT4A.js';
|
|
4
|
+
export { L as LightningSendFeeEstimateInput } from '../LightningSendFeeEstimateInput-BgOhEAI-.js';
|
|
5
|
+
export { c as CommonProto, s as SparkProto } from '../spark-CDm4gqS6.js';
|
|
6
|
+
export { T as TransferDirection, W as WalletLeaf, a as WalletTransfer, b as WalletTransferLeaf, c as mapTransferLeafToWalletTransferLeaf, d as mapTransferToWalletTransfer, m as mapTreeNodeToWalletLeaf } from '../sdk-types-BPoPgzda.js';
|
|
7
7
|
import '@lightsparkdev/core';
|
|
8
|
-
import '../signer-
|
|
8
|
+
import '../signer-wqesWifN.js';
|
|
9
9
|
import '@scure/bip32';
|
|
10
10
|
import '@buildonspark/lrc20-sdk';
|
|
11
11
|
import '@scure/btc-signer';
|
|
12
12
|
import 'bitcoinjs-lib';
|
|
13
|
+
import '@buildonspark/lrc20-sdk/lrc/types';
|
|
13
14
|
import '@bufbuild/protobuf/wire';
|
|
14
15
|
import 'nice-grpc-common';
|
package/dist/types/index.js
CHANGED
|
@@ -18,12 +18,12 @@ import {
|
|
|
18
18
|
SparkWalletUser_default,
|
|
19
19
|
Transfer_default,
|
|
20
20
|
getClaimStaticDepositQuery,
|
|
21
|
-
|
|
21
|
+
getCoopExitFeeQuoteQuery,
|
|
22
22
|
getLeavesSwapRequestQuery,
|
|
23
23
|
getLightningReceiveRequestQuery,
|
|
24
24
|
getLightningSendRequestQuery,
|
|
25
25
|
getUserRequestQuery
|
|
26
|
-
} from "../chunk-
|
|
26
|
+
} from "../chunk-TOSP3INR.js";
|
|
27
27
|
import {
|
|
28
28
|
BitcoinNetwork_default
|
|
29
29
|
} from "../chunk-HMLOC6TE.js";
|
|
@@ -50,7 +50,7 @@ export {
|
|
|
50
50
|
Transfer_default as Transfer,
|
|
51
51
|
TransferDirection,
|
|
52
52
|
getClaimStaticDepositQuery,
|
|
53
|
-
|
|
53
|
+
getCoopExitFeeQuoteQuery,
|
|
54
54
|
getLeavesSwapRequestQuery,
|
|
55
55
|
getLightningReceiveRequestQuery,
|
|
56
56
|
getLightningSendRequestQuery,
|
package/dist/utils/index.cjs
CHANGED
|
@@ -117,10 +117,11 @@ if (typeof window !== "undefined") {
|
|
|
117
117
|
|
|
118
118
|
// src/utils/adaptor-signature.ts
|
|
119
119
|
var import_modular = require("@noble/curves/abstract/modular");
|
|
120
|
-
var
|
|
120
|
+
var import_utils2 = require("@noble/curves/abstract/utils");
|
|
121
121
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
|
122
122
|
|
|
123
123
|
// src/errors/base.ts
|
|
124
|
+
var import_utils = require("@noble/hashes/utils");
|
|
124
125
|
var SparkSDKError = class extends Error {
|
|
125
126
|
context;
|
|
126
127
|
originalError;
|
|
@@ -152,12 +153,42 @@ var SparkSDKError = class extends Error {
|
|
|
152
153
|
}
|
|
153
154
|
};
|
|
154
155
|
function getMessage(message, context = {}, originalError) {
|
|
155
|
-
const contextStr = Object.entries(context).map(([key, value]) => `${key}: ${
|
|
156
|
+
const contextStr = Object.entries(context).map(([key, value]) => `${key}: ${safeStringify(value)}`).join(", ");
|
|
156
157
|
const originalErrorStr = originalError ? `
|
|
157
158
|
Original Error: ${originalError.message}` : "";
|
|
158
159
|
return `SparkSDKError: ${message}${contextStr ? `
|
|
159
160
|
Context: ${contextStr}` : ""}${originalErrorStr}`;
|
|
160
161
|
}
|
|
162
|
+
function safeStringify(value) {
|
|
163
|
+
const replacer = (_, v) => {
|
|
164
|
+
if (typeof v === "bigint") {
|
|
165
|
+
return v.toString();
|
|
166
|
+
}
|
|
167
|
+
if (v instanceof Uint8Array) {
|
|
168
|
+
return formatUint8Array(v);
|
|
169
|
+
}
|
|
170
|
+
return v;
|
|
171
|
+
};
|
|
172
|
+
if (typeof value === "bigint") {
|
|
173
|
+
return `"${value.toString()}"`;
|
|
174
|
+
}
|
|
175
|
+
if (value instanceof Uint8Array) {
|
|
176
|
+
return `"${formatUint8Array(value)}"`;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
const result = JSON.stringify(value, replacer);
|
|
180
|
+
return result === void 0 ? String(value) : result;
|
|
181
|
+
} catch {
|
|
182
|
+
try {
|
|
183
|
+
return String(value);
|
|
184
|
+
} catch {
|
|
185
|
+
return "[Unserializable]";
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function formatUint8Array(arr) {
|
|
190
|
+
return `Uint8Array(0x${(0, import_utils.bytesToHex)(arr)})`;
|
|
191
|
+
}
|
|
161
192
|
|
|
162
193
|
// src/errors/types.ts
|
|
163
194
|
var NetworkError = class extends SparkSDKError {
|
|
@@ -174,19 +205,19 @@ var ValidationError = class extends SparkSDKError {
|
|
|
174
205
|
// src/utils/adaptor-signature.ts
|
|
175
206
|
function generateSignatureFromExistingAdaptor(signature, adaptorPrivateKeyBytes) {
|
|
176
207
|
const { r, s } = parseSignature(signature);
|
|
177
|
-
const sBigInt = (0,
|
|
178
|
-
const tBigInt = (0,
|
|
208
|
+
const sBigInt = (0, import_utils2.bytesToNumberBE)(s);
|
|
209
|
+
const tBigInt = (0, import_utils2.bytesToNumberBE)(adaptorPrivateKeyBytes);
|
|
179
210
|
const newS = (0, import_modular.mod)(sBigInt - tBigInt, import_secp256k1.secp256k1.CURVE.n);
|
|
180
|
-
const newSignature = new Uint8Array([...r, ...(0,
|
|
211
|
+
const newSignature = new Uint8Array([...r, ...(0, import_utils2.numberToBytesBE)(newS, 32)]);
|
|
181
212
|
return newSignature;
|
|
182
213
|
}
|
|
183
214
|
function generateAdaptorFromSignature(signature) {
|
|
184
215
|
const adaptorPrivateKey = import_secp256k1.secp256k1.utils.randomPrivateKey();
|
|
185
216
|
const { r, s } = parseSignature(signature);
|
|
186
|
-
const sBigInt = (0,
|
|
187
|
-
const tBigInt = (0,
|
|
217
|
+
const sBigInt = (0, import_utils2.bytesToNumberBE)(s);
|
|
218
|
+
const tBigInt = (0, import_utils2.bytesToNumberBE)(adaptorPrivateKey);
|
|
188
219
|
const newS = (0, import_modular.mod)(sBigInt - tBigInt, import_secp256k1.secp256k1.CURVE.n);
|
|
189
|
-
const newSignature = new Uint8Array([...r, ...(0,
|
|
220
|
+
const newSignature = new Uint8Array([...r, ...(0, import_utils2.numberToBytesBE)(newS, 32)]);
|
|
190
221
|
return {
|
|
191
222
|
adaptorSignature: newSignature,
|
|
192
223
|
adaptorPrivateKey
|
|
@@ -203,15 +234,15 @@ function validateOutboundAdaptorSignature(pubkey, hash, signature, adaptorPubkey
|
|
|
203
234
|
}
|
|
204
235
|
function applyAdaptorToSignature(pubkey, hash, signature, adaptorPrivateKeyBytes) {
|
|
205
236
|
const { r, s } = parseSignature(signature);
|
|
206
|
-
const sBigInt = (0,
|
|
207
|
-
const adaptorPrivateKey = (0,
|
|
237
|
+
const sBigInt = (0, import_utils2.bytesToNumberBE)(s);
|
|
238
|
+
const adaptorPrivateKey = (0, import_utils2.bytesToNumberBE)(adaptorPrivateKeyBytes);
|
|
208
239
|
const newS = (0, import_modular.mod)(sBigInt + adaptorPrivateKey, import_secp256k1.secp256k1.CURVE.n);
|
|
209
|
-
const newSig = new Uint8Array([...r, ...(0,
|
|
240
|
+
const newSig = new Uint8Array([...r, ...(0, import_utils2.numberToBytesBE)(newS, 32)]);
|
|
210
241
|
if (import_secp256k1.schnorr.verify(newSig, hash, pubkey)) {
|
|
211
242
|
return newSig;
|
|
212
243
|
}
|
|
213
244
|
const altS = (0, import_modular.mod)(sBigInt - adaptorPrivateKey, import_secp256k1.secp256k1.CURVE.n);
|
|
214
|
-
const altSig = new Uint8Array([...r, ...(0,
|
|
245
|
+
const altSig = new Uint8Array([...r, ...(0, import_utils2.numberToBytesBE)(altS, 32)]);
|
|
215
246
|
if (import_secp256k1.schnorr.verify(altSig, hash, pubkey)) {
|
|
216
247
|
return altSig;
|
|
217
248
|
}
|
|
@@ -221,7 +252,7 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
|
|
|
221
252
|
if (hash.length !== 32) {
|
|
222
253
|
throw new Error(`wrong size for message (got ${hash.length}, want 32)`);
|
|
223
254
|
}
|
|
224
|
-
const pubKey = import_secp256k1.schnorr.utils.lift_x((0,
|
|
255
|
+
const pubKey = import_secp256k1.schnorr.utils.lift_x((0, import_utils2.bytesToNumberBE)(pubKeyBytes));
|
|
225
256
|
pubKey.assertValidity();
|
|
226
257
|
const { r, s } = parseSignature(signature);
|
|
227
258
|
const commitmenet = import_secp256k1.schnorr.utils.taggedHash(
|
|
@@ -233,11 +264,11 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
|
|
|
233
264
|
if (commitmenet.length > 32) {
|
|
234
265
|
throw new Error("hash of (r || P || m) too big");
|
|
235
266
|
}
|
|
236
|
-
const e = (0, import_modular.mod)((0,
|
|
267
|
+
const e = (0, import_modular.mod)((0, import_utils2.bytesToNumberBE)(commitmenet), import_secp256k1.secp256k1.CURVE.n);
|
|
237
268
|
const negE = (0, import_modular.mod)(-e, import_secp256k1.secp256k1.CURVE.n);
|
|
238
269
|
const R = import_secp256k1.secp256k1.ProjectivePoint.BASE.multiplyAndAddUnsafe(
|
|
239
270
|
pubKey,
|
|
240
|
-
(0,
|
|
271
|
+
(0, import_utils2.bytesToNumberBE)(s),
|
|
241
272
|
negE
|
|
242
273
|
);
|
|
243
274
|
if (!R) {
|
|
@@ -253,7 +284,7 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
|
|
|
253
284
|
if (!newR.hasEvenY()) {
|
|
254
285
|
throw new Error("calculated R y-value is odd");
|
|
255
286
|
}
|
|
256
|
-
const rNum = (0,
|
|
287
|
+
const rNum = (0, import_utils2.bytesToNumberBE)(r);
|
|
257
288
|
if (newR.toAffine().x !== rNum) {
|
|
258
289
|
throw new Error("calculated R point was not given R");
|
|
259
290
|
}
|
|
@@ -274,15 +305,15 @@ function parseSignature(signature) {
|
|
|
274
305
|
}
|
|
275
306
|
const r = signature.slice(0, 32);
|
|
276
307
|
const s = signature.slice(32, 64);
|
|
277
|
-
if ((0,
|
|
308
|
+
if ((0, import_utils2.bytesToNumberBE)(r) >= import_secp256k1.secp256k1.CURVE.Fp.ORDER) {
|
|
278
309
|
throw new ValidationError("Invalid signature: r >= field prime", {
|
|
279
|
-
rValue: (0,
|
|
310
|
+
rValue: (0, import_utils2.bytesToNumberBE)(r),
|
|
280
311
|
fieldPrime: import_secp256k1.secp256k1.CURVE.Fp.ORDER
|
|
281
312
|
});
|
|
282
313
|
}
|
|
283
|
-
if ((0,
|
|
314
|
+
if ((0, import_utils2.bytesToNumberBE)(s) >= import_secp256k1.secp256k1.CURVE.n) {
|
|
284
315
|
throw new ValidationError("Invalid signature: s >= group order", {
|
|
285
|
-
sValue: (0,
|
|
316
|
+
sValue: (0, import_utils2.bytesToNumberBE)(s),
|
|
286
317
|
groupOrder: import_secp256k1.secp256k1.CURVE.n
|
|
287
318
|
});
|
|
288
319
|
}
|
|
@@ -290,7 +321,7 @@ function parseSignature(signature) {
|
|
|
290
321
|
}
|
|
291
322
|
|
|
292
323
|
// src/utils/bitcoin.ts
|
|
293
|
-
var
|
|
324
|
+
var import_utils3 = require("@noble/curves/abstract/utils");
|
|
294
325
|
var import_secp256k12 = require("@noble/curves/secp256k1");
|
|
295
326
|
var import_sha2 = require("@noble/hashes/sha2");
|
|
296
327
|
var btc2 = __toESM(require("@scure/btc-signer"), 1);
|
|
@@ -959,7 +990,7 @@ function computeTaprootKeyNoScript(pubkey) {
|
|
|
959
990
|
});
|
|
960
991
|
}
|
|
961
992
|
const taggedHash = import_secp256k12.schnorr.utils.taggedHash("TapTweak", pubkey);
|
|
962
|
-
const tweak = (0,
|
|
993
|
+
const tweak = (0, import_utils3.bytesToNumberBE)(taggedHash);
|
|
963
994
|
const P = import_secp256k12.schnorr.utils.lift_x(import_secp256k12.schnorr.utils.bytesToNumberBE(pubkey));
|
|
964
995
|
const Q = P.add(import_secp256k12.secp256k1.ProjectivePoint.fromPrivateKey(tweak));
|
|
965
996
|
return Q.toRawBytes();
|
|
@@ -1012,7 +1043,7 @@ function getP2TRAddressFromPkScript(pkScript, network) {
|
|
|
1012
1043
|
if (pkScript.length !== 34 || pkScript[0] !== 81 || pkScript[1] !== 32) {
|
|
1013
1044
|
throw new ValidationError("Invalid pkscript", {
|
|
1014
1045
|
field: "pkScript",
|
|
1015
|
-
value: (0,
|
|
1046
|
+
value: (0, import_utils3.bytesToHex)(pkScript),
|
|
1016
1047
|
expected: "34 bytes starting with 0x51 0x20"
|
|
1017
1048
|
});
|
|
1018
1049
|
}
|
|
@@ -1037,7 +1068,7 @@ function getP2WPKHAddressFromPublicKey(pubKey, network) {
|
|
|
1037
1068
|
return address2;
|
|
1038
1069
|
}
|
|
1039
1070
|
function getTxFromRawTxHex(rawTxHex) {
|
|
1040
|
-
const txBytes = (0,
|
|
1071
|
+
const txBytes = (0, import_utils3.hexToBytes)(rawTxHex);
|
|
1041
1072
|
const tx = btc2.Transaction.fromRaw(txBytes, {
|
|
1042
1073
|
allowUnknownOutputs: true
|
|
1043
1074
|
});
|
|
@@ -1084,14 +1115,14 @@ function getSigHashFromTx(tx, inputIndex, prevOutput) {
|
|
|
1084
1115
|
);
|
|
1085
1116
|
}
|
|
1086
1117
|
function getTxId(tx) {
|
|
1087
|
-
return (0,
|
|
1118
|
+
return (0, import_utils3.bytesToHex)((0, import_sha2.sha256)((0, import_sha2.sha256)(tx.toBytes(true))).reverse());
|
|
1088
1119
|
}
|
|
1089
1120
|
function getTxIdNoReverse(tx) {
|
|
1090
|
-
return (0,
|
|
1121
|
+
return (0, import_utils3.bytesToHex)((0, import_sha2.sha256)((0, import_sha2.sha256)(tx.toBytes(true))));
|
|
1091
1122
|
}
|
|
1092
1123
|
|
|
1093
1124
|
// src/utils/keys.ts
|
|
1094
|
-
var
|
|
1125
|
+
var import_utils4 = require("@noble/curves/abstract/utils");
|
|
1095
1126
|
var import_secp256k13 = require("@noble/curves/secp256k1");
|
|
1096
1127
|
function addPublicKeys(a, b) {
|
|
1097
1128
|
if (a.length !== 33 || b.length !== 33) {
|
|
@@ -1149,7 +1180,7 @@ function addPrivateKeys(a, b) {
|
|
|
1149
1180
|
const privA = import_secp256k13.secp256k1.utils.normPrivateKeyToScalar(a);
|
|
1150
1181
|
const privB = import_secp256k13.secp256k1.utils.normPrivateKeyToScalar(b);
|
|
1151
1182
|
const sum = (privA + privB) % import_secp256k13.secp256k1.CURVE.n;
|
|
1152
|
-
return (0,
|
|
1183
|
+
return (0, import_utils4.numberToBytesBE)(sum, 32);
|
|
1153
1184
|
}
|
|
1154
1185
|
function subtractPrivateKeys(a, b) {
|
|
1155
1186
|
if (a.length !== 32 || b.length !== 32) {
|
|
@@ -1162,7 +1193,7 @@ function subtractPrivateKeys(a, b) {
|
|
|
1162
1193
|
const privA = import_secp256k13.secp256k1.utils.normPrivateKeyToScalar(a);
|
|
1163
1194
|
const privB = import_secp256k13.secp256k1.utils.normPrivateKeyToScalar(b);
|
|
1164
1195
|
const sum = (import_secp256k13.secp256k1.CURVE.n - privB + privA) % import_secp256k13.secp256k1.CURVE.n;
|
|
1165
|
-
return (0,
|
|
1196
|
+
return (0, import_utils4.numberToBytesBE)(sum, 32);
|
|
1166
1197
|
}
|
|
1167
1198
|
function sumOfPrivateKeys(keys) {
|
|
1168
1199
|
return keys.reduce((sum, key) => {
|
|
@@ -1320,6 +1351,7 @@ var BASE_CONFIG = {
|
|
|
1320
1351
|
signingOperators: getLocalSigningOperators(),
|
|
1321
1352
|
tokenSignatures: "SCHNORR",
|
|
1322
1353
|
tokenTransactionVersion: "V0",
|
|
1354
|
+
tokenValidityDurationSeconds: 180,
|
|
1323
1355
|
electrsUrl: getElectrsUrl("LOCAL"),
|
|
1324
1356
|
expectedWithdrawBondSats: 1e4,
|
|
1325
1357
|
expectedWithdrawRelativeBlockLocktime: 1e3,
|
|
@@ -1450,7 +1482,7 @@ function getLocalSigningOperators() {
|
|
|
1450
1482
|
// src/graphql/objects/ClaimStaticDeposit.ts
|
|
1451
1483
|
var import_core2 = require("@lightsparkdev/core");
|
|
1452
1484
|
|
|
1453
|
-
// src/graphql/objects/
|
|
1485
|
+
// src/graphql/objects/CoopExitFeeQuote.ts
|
|
1454
1486
|
var import_core3 = require("@lightsparkdev/core");
|
|
1455
1487
|
|
|
1456
1488
|
// src/graphql/objects/LeavesSwapRequest.ts
|
|
@@ -1469,7 +1501,7 @@ var import_core8 = require("@lightsparkdev/core");
|
|
|
1469
1501
|
var import_core7 = require("@lightsparkdev/core");
|
|
1470
1502
|
|
|
1471
1503
|
// src/types/sdk-types.ts
|
|
1472
|
-
var
|
|
1504
|
+
var import_utils5 = require("@noble/curves/abstract/utils");
|
|
1473
1505
|
|
|
1474
1506
|
// src/utils/mempool.ts
|
|
1475
1507
|
async function getLatestDepositTxId(address2) {
|
|
@@ -1551,7 +1583,7 @@ function collectResponses(responses) {
|
|
|
1551
1583
|
}
|
|
1552
1584
|
|
|
1553
1585
|
// src/utils/secret-sharing.ts
|
|
1554
|
-
var
|
|
1586
|
+
var import_utils6 = require("@noble/curves/abstract/utils");
|
|
1555
1587
|
var import_secp256k14 = require("@noble/curves/secp256k1");
|
|
1556
1588
|
|
|
1557
1589
|
// src/utils/crypto.ts
|
|
@@ -1569,7 +1601,7 @@ function getRandomBigInt(max) {
|
|
|
1569
1601
|
const mask = (1n << BigInt(max.toString(2).length)) - 1n;
|
|
1570
1602
|
while (true) {
|
|
1571
1603
|
const randBytes = crypto.getRandomValues(new Uint8Array(byteLength + 1));
|
|
1572
|
-
const randValue = BigInt("0x" + (0,
|
|
1604
|
+
const randValue = BigInt("0x" + (0, import_utils6.bytesToHex)(randBytes)) & mask;
|
|
1573
1605
|
if (randValue < maxBigInt) {
|
|
1574
1606
|
return randValue;
|
|
1575
1607
|
}
|
|
@@ -1747,7 +1779,7 @@ function validateShare(share) {
|
|
|
1747
1779
|
const scaledPoint = import_secp256k14.secp256k1.ProjectivePoint.fromHex(pubkey).multiply(value);
|
|
1748
1780
|
resultPubkey = import_secp256k14.secp256k1.ProjectivePoint.fromHex(resultPubkey).add(scaledPoint).toRawBytes(true);
|
|
1749
1781
|
}
|
|
1750
|
-
if (!(0,
|
|
1782
|
+
if (!(0, import_utils6.equalBytes)(resultPubkey, targetPubkey)) {
|
|
1751
1783
|
throw new ValidationError("Share is not valid", {
|
|
1752
1784
|
field: "share",
|
|
1753
1785
|
value: "Invalid proof",
|
|
@@ -1846,15 +1878,15 @@ function decodeBytesToSigningCommitment(bytes) {
|
|
|
1846
1878
|
}
|
|
1847
1879
|
|
|
1848
1880
|
// src/utils/token-transactions.ts
|
|
1849
|
-
var
|
|
1881
|
+
var import_utils7 = require("@noble/curves/abstract/utils");
|
|
1850
1882
|
function calculateAvailableTokenAmount(outputLeaves) {
|
|
1851
1883
|
return outputLeaves.reduce(
|
|
1852
|
-
(sum, output) => sum + BigInt((0,
|
|
1884
|
+
(sum, output) => sum + BigInt((0, import_utils7.bytesToNumberBE)(output.output.tokenAmount)),
|
|
1853
1885
|
BigInt(0)
|
|
1854
1886
|
);
|
|
1855
1887
|
}
|
|
1856
1888
|
function checkIfSelectedOutputsAreAvailable(selectedOutputs, tokenOutputs, tokenPublicKey) {
|
|
1857
|
-
const tokenPubKeyHex = (0,
|
|
1889
|
+
const tokenPubKeyHex = (0, import_utils7.bytesToHex)(tokenPublicKey);
|
|
1858
1890
|
const tokenOutputsAvailable = tokenOutputs.get(tokenPubKeyHex);
|
|
1859
1891
|
if (!tokenOutputsAvailable) {
|
|
1860
1892
|
return false;
|
|
@@ -1884,7 +1916,7 @@ function filterTokenBalanceForTokenPublicKey(tokenBalances, publicKey) {
|
|
|
1884
1916
|
}
|
|
1885
1917
|
|
|
1886
1918
|
// src/utils/transfer_package.ts
|
|
1887
|
-
var
|
|
1919
|
+
var import_utils8 = require("@noble/curves/abstract/utils");
|
|
1888
1920
|
var import_sha23 = require("@noble/hashes/sha2");
|
|
1889
1921
|
function getTransferPackageSigningPayload(transferID, transferPackage) {
|
|
1890
1922
|
const encryptedPayload = transferPackage.keyTweakPackage;
|
|
@@ -1893,7 +1925,7 @@ function getTransferPackageSigningPayload(transferID, transferPackage) {
|
|
|
1893
1925
|
).map(([key, value]) => ({ key, value }));
|
|
1894
1926
|
pairs.sort((a, b) => a.key.localeCompare(b.key));
|
|
1895
1927
|
const encoder = new TextEncoder();
|
|
1896
|
-
let message = (0,
|
|
1928
|
+
let message = (0, import_utils8.hexToBytes)(transferID.replaceAll("-", ""));
|
|
1897
1929
|
for (const pair of pairs) {
|
|
1898
1930
|
const keyPart = encoder.encode(pair.key + ":");
|
|
1899
1931
|
const separator = encoder.encode(";");
|
|
@@ -1990,7 +2022,7 @@ function getEphemeralAnchorOutput() {
|
|
|
1990
2022
|
}
|
|
1991
2023
|
|
|
1992
2024
|
// src/utils/unilateral-exit.ts
|
|
1993
|
-
var
|
|
2025
|
+
var import_utils9 = require("@noble/curves/abstract/utils");
|
|
1994
2026
|
var import_legacy = require("@noble/hashes/legacy");
|
|
1995
2027
|
var import_sha24 = require("@noble/hashes/sha2");
|
|
1996
2028
|
var btc3 = __toESM(require("@scure/btc-signer"), 1);
|
|
@@ -2005,7 +2037,7 @@ function isEphemeralAnchorOutput(script, amount) {
|
|
|
2005
2037
|
}
|
|
2006
2038
|
async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network) {
|
|
2007
2039
|
const result = [];
|
|
2008
|
-
const nodes = nodeHexStrings.map((hex) => TreeNode.decode((0,
|
|
2040
|
+
const nodes = nodeHexStrings.map((hex) => TreeNode.decode((0, import_utils9.hexToBytes)(hex)));
|
|
2009
2041
|
const nodeMap = /* @__PURE__ */ new Map();
|
|
2010
2042
|
for (const node of nodes) {
|
|
2011
2043
|
nodeMap.set(node.id, node);
|
|
@@ -2061,10 +2093,10 @@ async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network)
|
|
|
2061
2093
|
}
|
|
2062
2094
|
}
|
|
2063
2095
|
for (const chainNode of chain) {
|
|
2064
|
-
const nodeTx = (0,
|
|
2096
|
+
const nodeTx = (0, import_utils9.bytesToHex)(chainNode.nodeTx);
|
|
2065
2097
|
transactions.push(nodeTx);
|
|
2066
2098
|
if (chainNode.id === node.id) {
|
|
2067
|
-
const refundTx = (0,
|
|
2099
|
+
const refundTx = (0, import_utils9.bytesToHex)(chainNode.refundTx);
|
|
2068
2100
|
transactions.push(refundTx);
|
|
2069
2101
|
}
|
|
2070
2102
|
}
|
|
@@ -2094,7 +2126,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
2094
2126
|
`Node hex string at index ${i} appears to be a raw transaction hex, not a TreeNode protobuf. Use 'leafidtohex' command to convert node IDs to proper hex strings.`
|
|
2095
2127
|
);
|
|
2096
2128
|
}
|
|
2097
|
-
const nodeBytes = (0,
|
|
2129
|
+
const nodeBytes = (0, import_utils9.hexToBytes)(hex);
|
|
2098
2130
|
const node = TreeNode.decode(nodeBytes);
|
|
2099
2131
|
if (!node.id) {
|
|
2100
2132
|
throw new Error(
|
|
@@ -2170,7 +2202,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
2170
2202
|
}
|
|
2171
2203
|
}
|
|
2172
2204
|
for (const chainNode of chain) {
|
|
2173
|
-
let nodeTxHex = (0,
|
|
2205
|
+
let nodeTxHex = (0, import_utils9.bytesToHex)(chainNode.nodeTx);
|
|
2174
2206
|
try {
|
|
2175
2207
|
const txObj = getTxFromRawTxHex(nodeTxHex);
|
|
2176
2208
|
const txid = getTxId(txObj);
|
|
@@ -2187,7 +2219,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
2187
2219
|
for (let i = txObj.outputsLength - 1; i >= 0; i--) {
|
|
2188
2220
|
const output = txObj.getOutput(i);
|
|
2189
2221
|
if (output?.amount === 0n && output.script) {
|
|
2190
|
-
anchorOutputScriptHex = (0,
|
|
2222
|
+
anchorOutputScriptHex = (0, import_utils9.bytesToHex)(output.script);
|
|
2191
2223
|
break;
|
|
2192
2224
|
}
|
|
2193
2225
|
}
|
|
@@ -2208,11 +2240,11 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
2208
2240
|
usedUtxos,
|
|
2209
2241
|
correctedParentTx
|
|
2210
2242
|
} = constructFeeBumpTx(nodeTxHex, availableUtxos, feeRate, void 0);
|
|
2211
|
-
const feeBumpTx = btc3.Transaction.fromPSBT((0,
|
|
2243
|
+
const feeBumpTx = btc3.Transaction.fromPSBT((0, import_utils9.hexToBytes)(nodeFeeBumpPsbt));
|
|
2212
2244
|
var feeBumpOut = feeBumpTx.outputsLength === 1 ? feeBumpTx.getOutput(0) : null;
|
|
2213
2245
|
var feeBumpOutPubKey = null;
|
|
2214
2246
|
for (const usedUtxo of usedUtxos) {
|
|
2215
|
-
if (feeBumpOut && (0,
|
|
2247
|
+
if (feeBumpOut && (0, import_utils9.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
|
|
2216
2248
|
feeBumpOutPubKey = usedUtxo.publicKey;
|
|
2217
2249
|
}
|
|
2218
2250
|
const index = availableUtxos.findIndex(
|
|
@@ -2227,20 +2259,20 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
2227
2259
|
txid: getTxId(feeBumpTx),
|
|
2228
2260
|
vout: 0,
|
|
2229
2261
|
value: feeBumpOut.amount,
|
|
2230
|
-
script: (0,
|
|
2262
|
+
script: (0, import_utils9.bytesToHex)(feeBumpOut.script),
|
|
2231
2263
|
publicKey: feeBumpOutPubKey
|
|
2232
2264
|
});
|
|
2233
2265
|
const finalNodeTx = correctedParentTx || nodeTxHex;
|
|
2234
2266
|
txPackages.push({ tx: finalNodeTx, feeBumpPsbt: nodeFeeBumpPsbt });
|
|
2235
2267
|
if (chainNode.id === node.id) {
|
|
2236
|
-
let refundTxHex = (0,
|
|
2268
|
+
let refundTxHex = (0, import_utils9.bytesToHex)(chainNode.refundTx);
|
|
2237
2269
|
try {
|
|
2238
2270
|
const txObj = getTxFromRawTxHex(refundTxHex);
|
|
2239
2271
|
let anchorOutputScriptHex;
|
|
2240
2272
|
for (let i = txObj.outputsLength - 1; i >= 0; i--) {
|
|
2241
2273
|
const output = txObj.getOutput(i);
|
|
2242
2274
|
if (output?.amount === 0n && output.script) {
|
|
2243
|
-
anchorOutputScriptHex = (0,
|
|
2275
|
+
anchorOutputScriptHex = (0, import_utils9.bytesToHex)(output.script);
|
|
2244
2276
|
break;
|
|
2245
2277
|
}
|
|
2246
2278
|
}
|
|
@@ -2354,10 +2386,10 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
|
|
|
2354
2386
|
if (!fundingUtxo) {
|
|
2355
2387
|
throw new Error(`UTXO at index ${i} is undefined`);
|
|
2356
2388
|
}
|
|
2357
|
-
const pubKeyHash = hash160((0,
|
|
2389
|
+
const pubKeyHash = hash160((0, import_utils9.hexToBytes)(fundingUtxo.publicKey));
|
|
2358
2390
|
const scriptToUse = new Uint8Array([0, 20, ...pubKeyHash]);
|
|
2359
|
-
const providedScript = (0,
|
|
2360
|
-
if ((0,
|
|
2391
|
+
const providedScript = (0, import_utils9.hexToBytes)(fundingUtxo.script);
|
|
2392
|
+
if ((0, import_utils9.bytesToHex)(scriptToUse) !== (0, import_utils9.bytesToHex)(providedScript)) {
|
|
2361
2393
|
throw new Error(
|
|
2362
2394
|
`\u274C Derived script doesn't match provided script for UTXO ${i + 1}.`
|
|
2363
2395
|
);
|
|
@@ -2422,7 +2454,7 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
|
|
|
2422
2454
|
}
|
|
2423
2455
|
let psbtHex;
|
|
2424
2456
|
try {
|
|
2425
|
-
psbtHex = (0,
|
|
2457
|
+
psbtHex = (0, import_utils9.bytesToHex)(builder.toPSBT());
|
|
2426
2458
|
} catch (error) {
|
|
2427
2459
|
throw new Error(`Failed to extract transaction: ${error}`);
|
|
2428
2460
|
}
|
|
@@ -2435,10 +2467,10 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
|
|
|
2435
2467
|
|
|
2436
2468
|
// src/address/address.ts
|
|
2437
2469
|
var import_secp256k16 = require("@noble/curves/secp256k1");
|
|
2438
|
-
var
|
|
2470
|
+
var import_utils10 = require("@noble/hashes/utils");
|
|
2439
2471
|
var import_base2 = require("@scure/base");
|
|
2440
2472
|
var import_uuidv7 = require("uuidv7");
|
|
2441
|
-
var
|
|
2473
|
+
var import_utils11 = require("@noble/curves/abstract/utils");
|
|
2442
2474
|
var AddressNetwork = {
|
|
2443
2475
|
MAINNET: "sp",
|
|
2444
2476
|
TESTNET: "spt",
|
|
@@ -2454,7 +2486,7 @@ function encodeSparkAddress(payload) {
|
|
|
2454
2486
|
paymentIntentFields = payload.paymentIntentFields;
|
|
2455
2487
|
}
|
|
2456
2488
|
const sparkAddressProto = SparkAddress.create({
|
|
2457
|
-
identityPublicKey: (0,
|
|
2489
|
+
identityPublicKey: (0, import_utils10.hexToBytes)(payload.identityPublicKey),
|
|
2458
2490
|
paymentIntentFields
|
|
2459
2491
|
});
|
|
2460
2492
|
const serializedPayload = SparkAddress.encode(sparkAddressProto).finish();
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import * as btc from '@scure/btc-signer';
|
|
2
2
|
import { Transaction } from '@scure/btc-signer';
|
|
3
3
|
import { TransactionOutput, TransactionInput } from '@scure/btc-signer/psbt';
|
|
4
|
-
import { N as Network } from '../network-
|
|
5
|
-
export { L as LRC_WALLET_NETWORK, c as LRC_WALLET_NETWORK_TYPE, b as NetworkToProto, a as NetworkType, g as getNetwork, d as getNetworkFromAddress, e as getNetworkFromString } from '../network-
|
|
6
|
-
import { i as SigningNonce, h as SigningCommitment } from '../signer-
|
|
7
|
-
export { V as VerifiableSecretShare, 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-
|
|
8
|
-
import { j as OutputWithPreviousTransactionData, l as TransferPackage, g as SparkServiceClient } from '../spark-
|
|
4
|
+
import { N as Network } from '../network-D5lKssVl.cjs';
|
|
5
|
+
export { L as LRC_WALLET_NETWORK, c as LRC_WALLET_NETWORK_TYPE, b as NetworkToProto, a as NetworkType, g as getNetwork, d as getNetworkFromAddress, e as getNetworkFromString } from '../network-D5lKssVl.cjs';
|
|
6
|
+
import { i as SigningNonce, h as SigningCommitment } from '../signer-IO3oMRNj.cjs';
|
|
7
|
+
export { V as VerifiableSecretShare, 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-IO3oMRNj.cjs';
|
|
8
|
+
import { j as OutputWithPreviousTransactionData, l as TransferPackage, g as SparkServiceClient } from '../spark-CDm4gqS6.cjs';
|
|
9
9
|
import { SparkAddressFormat } from '../address/index.cjs';
|
|
10
10
|
import '@buildonspark/lrc20-sdk';
|
|
11
11
|
import 'bitcoinjs-lib';
|
|
12
12
|
import '../BitcoinNetwork-TnABML0T.cjs';
|
|
13
13
|
import '@scure/bip32';
|
|
14
|
+
import '@buildonspark/lrc20-sdk/lrc/types';
|
|
14
15
|
import '@bufbuild/protobuf/wire';
|
|
15
16
|
import 'nice-grpc-common';
|
|
16
17
|
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import * as btc from '@scure/btc-signer';
|
|
2
2
|
import { Transaction } from '@scure/btc-signer';
|
|
3
3
|
import { TransactionOutput, TransactionInput } from '@scure/btc-signer/psbt';
|
|
4
|
-
import { N as Network } from '../network-
|
|
5
|
-
export { L as LRC_WALLET_NETWORK, c as LRC_WALLET_NETWORK_TYPE, b as NetworkToProto, a as NetworkType, g as getNetwork, d as getNetworkFromAddress, e as getNetworkFromString } from '../network-
|
|
6
|
-
import { i as SigningNonce, h as SigningCommitment } from '../signer-
|
|
7
|
-
export { V as VerifiableSecretShare, 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-
|
|
8
|
-
import { j as OutputWithPreviousTransactionData, l as TransferPackage, g as SparkServiceClient } from '../spark-
|
|
4
|
+
import { N as Network } from '../network-xkBSpaTn.js';
|
|
5
|
+
export { L as LRC_WALLET_NETWORK, c as LRC_WALLET_NETWORK_TYPE, b as NetworkToProto, a as NetworkType, g as getNetwork, d as getNetworkFromAddress, e as getNetworkFromString } from '../network-xkBSpaTn.js';
|
|
6
|
+
import { i as SigningNonce, h as SigningCommitment } from '../signer-wqesWifN.js';
|
|
7
|
+
export { V as VerifiableSecretShare, 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-wqesWifN.js';
|
|
8
|
+
import { j as OutputWithPreviousTransactionData, l as TransferPackage, g as SparkServiceClient } from '../spark-CDm4gqS6.js';
|
|
9
9
|
import { SparkAddressFormat } from '../address/index.js';
|
|
10
10
|
import '@buildonspark/lrc20-sdk';
|
|
11
11
|
import 'bitcoinjs-lib';
|
|
12
12
|
import '../BitcoinNetwork-TnABML0T.js';
|
|
13
13
|
import '@scure/bip32';
|
|
14
|
+
import '@buildonspark/lrc20-sdk/lrc/types';
|
|
14
15
|
import '@bufbuild/protobuf/wire';
|
|
15
16
|
import 'nice-grpc-common';
|
|
16
17
|
|
package/dist/utils/index.js
CHANGED
|
@@ -26,9 +26,16 @@ import {
|
|
|
26
26
|
isTxBroadcast,
|
|
27
27
|
maybeApplyFee,
|
|
28
28
|
proofOfPossessionMessageHashForDepositAddress
|
|
29
|
-
} from "../chunk-
|
|
29
|
+
} from "../chunk-IRW5TWMH.js";
|
|
30
|
+
import {
|
|
31
|
+
calculateAvailableTokenAmount,
|
|
32
|
+
checkIfSelectedOutputsAreAvailable,
|
|
33
|
+
collectResponses,
|
|
34
|
+
filterTokenBalanceForTokenPublicKey
|
|
35
|
+
} from "../chunk-6AFUC5M2.js";
|
|
30
36
|
import "../chunk-MIVX3GHD.js";
|
|
31
|
-
import "../chunk-
|
|
37
|
+
import "../chunk-TOSP3INR.js";
|
|
38
|
+
import "../chunk-O4RYNJNB.js";
|
|
32
39
|
import {
|
|
33
40
|
LRC_WALLET_NETWORK,
|
|
34
41
|
LRC_WALLET_NETWORK_TYPE,
|
|
@@ -37,8 +44,10 @@ import {
|
|
|
37
44
|
getNetwork,
|
|
38
45
|
getNetworkFromAddress,
|
|
39
46
|
getNetworkFromString
|
|
40
|
-
} from "../chunk-
|
|
41
|
-
import "../chunk-
|
|
47
|
+
} from "../chunk-Z5HIAYFT.js";
|
|
48
|
+
import "../chunk-DOA6QXYQ.js";
|
|
49
|
+
import "../chunk-HMLOC6TE.js";
|
|
50
|
+
import "../chunk-M6A4KFIG.js";
|
|
42
51
|
import {
|
|
43
52
|
addPrivateKeys,
|
|
44
53
|
addPublicKeys,
|
|
@@ -59,15 +68,7 @@ import {
|
|
|
59
68
|
subtractPublicKeys,
|
|
60
69
|
sumOfPrivateKeys,
|
|
61
70
|
validateOutboundAdaptorSignature
|
|
62
|
-
} from "../chunk-
|
|
63
|
-
import "../chunk-HMLOC6TE.js";
|
|
64
|
-
import {
|
|
65
|
-
calculateAvailableTokenAmount,
|
|
66
|
-
checkIfSelectedOutputsAreAvailable,
|
|
67
|
-
collectResponses,
|
|
68
|
-
filterTokenBalanceForTokenPublicKey
|
|
69
|
-
} from "../chunk-ATEHMLKP.js";
|
|
70
|
-
import "../chunk-TM4TOEOX.js";
|
|
71
|
+
} from "../chunk-NSJF5F5O.js";
|
|
71
72
|
import {
|
|
72
73
|
bigIntToPrivateKey,
|
|
73
74
|
computerLagrangeCoefficients,
|
|
@@ -80,10 +81,9 @@ import {
|
|
|
80
81
|
splitSecret,
|
|
81
82
|
splitSecretWithProofs,
|
|
82
83
|
validateShare
|
|
83
|
-
} from "../chunk-
|
|
84
|
+
} from "../chunk-QNNSEJ4P.js";
|
|
84
85
|
import "../chunk-VTUGIIWI.js";
|
|
85
|
-
import "../chunk-
|
|
86
|
-
import "../chunk-M6A4KFIG.js";
|
|
86
|
+
import "../chunk-GSI4OLXZ.js";
|
|
87
87
|
import "../chunk-MVRQ5US7.js";
|
|
88
88
|
export {
|
|
89
89
|
DEFAULT_FEE_SATS,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|