@buildonspark/spark-sdk 0.2.11 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/bare/index.cjs +761 -243
- package/dist/bare/index.d.cts +70 -11
- package/dist/bare/index.d.ts +70 -11
- package/dist/bare/index.js +684 -170
- package/dist/{chunk-A5M55UR3.js → chunk-5VWGOHED.js} +499 -8
- package/dist/{chunk-3WBPICWC.js → chunk-CKHJFQUA.js} +1 -1
- package/dist/{chunk-QNYJGFPD.js → chunk-LX45BCZW.js} +207 -160
- package/dist/{chunk-76SYPHOC.js → chunk-TB7DG5CU.js} +2 -2
- package/dist/{chunk-6CMNEDBK.js → chunk-XXTWWW6L.js} +1 -1
- package/dist/{client-Dd3QnxQu.d.ts → client-D7KDa4Ih.d.ts} +1 -1
- package/dist/{client-B9CAWKWz.d.cts → client-DVuA5-7M.d.cts} +1 -1
- package/dist/debug.cjs +761 -243
- package/dist/debug.d.cts +4 -4
- package/dist/debug.d.ts +4 -4
- package/dist/debug.js +4 -4
- package/dist/graphql/objects/index.d.cts +3 -3
- package/dist/graphql/objects/index.d.ts +3 -3
- package/dist/index.cjs +783 -265
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +5 -5
- package/dist/index.node.cjs +783 -265
- package/dist/index.node.d.cts +6 -6
- package/dist/index.node.d.ts +6 -6
- package/dist/index.node.js +4 -4
- package/dist/{logging-BOAzMqpM.d.cts → logging-BfTyKwqb.d.cts} +3 -3
- package/dist/{logging-Bt_WdZbu.d.ts → logging-CaNpBgiE.d.ts} +3 -3
- package/dist/native/index.cjs +782 -264
- package/dist/native/index.d.cts +70 -11
- package/dist/native/index.d.ts +70 -11
- package/dist/native/index.js +686 -172
- package/dist/proto/spark.cjs +499 -8
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark.js +17 -1
- package/dist/proto/spark_token.d.cts +1 -1
- package/dist/proto/spark_token.d.ts +1 -1
- package/dist/proto/spark_token.js +2 -2
- package/dist/{spark-CtGJPkx4.d.cts → spark-C7OG9mGJ.d.cts} +79 -2
- package/dist/{spark-CtGJPkx4.d.ts → spark-C7OG9mGJ.d.ts} +79 -2
- package/dist/{spark-wallet-Cp3yv6cK.d.ts → spark-wallet-D0Df_P_x.d.ts} +26 -13
- package/dist/{spark-wallet-yc2KhsVY.d.cts → spark-wallet-Dvh1BLP6.d.cts} +26 -13
- package/dist/{spark-wallet.node-D0Qw5Wb4.d.cts → spark-wallet.node-B3V8_fgw.d.cts} +1 -1
- package/dist/{spark-wallet.node-D4IovOHu.d.ts → spark-wallet.node-bGmy8-T8.d.ts} +1 -1
- package/dist/tests/test-utils.cjs +573 -66
- package/dist/tests/test-utils.d.cts +4 -4
- package/dist/tests/test-utils.d.ts +4 -4
- package/dist/tests/test-utils.js +5 -5
- package/dist/{token-transactions-CwhlOgIP.d.cts → token-transactions-D1ta-sHH.d.cts} +2 -2
- package/dist/{token-transactions-0nmR9mQO.d.ts → token-transactions-DINiKBzd.d.ts} +2 -2
- package/dist/types/index.cjs +492 -9
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +2 -2
- package/package.json +3 -3
- package/src/proto/common.ts +1 -1
- package/src/proto/google/protobuf/descriptor.ts +4 -10
- package/src/proto/google/protobuf/duration.ts +1 -1
- package/src/proto/google/protobuf/empty.ts +1 -1
- package/src/proto/google/protobuf/timestamp.ts +1 -1
- package/src/proto/mock.ts +1 -1
- package/src/proto/spark.ts +593 -3
- package/src/proto/spark_authn.ts +1 -1
- package/src/proto/spark_token.ts +1 -1
- package/src/proto/validate/validate.ts +27 -79
- package/src/services/deposit.ts +55 -3
- package/src/services/lightning.ts +2 -2
- package/src/services/signing.ts +1 -1
- package/src/services/token-transactions.ts +2 -5
- package/src/services/transfer.ts +2 -28
- package/src/signer/signer.ts +2 -2
- package/src/spark-wallet/proto-descriptors.ts +22 -0
- package/src/spark-wallet/proto-hash.ts +743 -0
- package/src/spark-wallet/proto-reflection.ts +193 -0
- package/src/spark-wallet/spark-wallet.ts +95 -57
- package/src/spark_descriptors.pb +0 -0
- package/src/tests/address.test.ts +10 -10
- package/src/tests/bitcoin.test.ts +2 -2
- package/src/tests/bufbuild-reflection.test.ts +151 -0
- package/src/tests/cross-language-hash.test.ts +79 -0
- package/src/tests/integration/address.test.ts +3 -12
- package/src/tests/integration/coop-exit.test.ts +1 -1
- package/src/tests/integration/lightning.test.ts +1 -1
- package/src/tests/integration/ssp/static_deposit.test.ts +128 -1
- package/src/tests/integration/static_deposit.test.ts +26 -0
- package/src/tests/integration/swap.test.ts +1 -1
- package/src/tests/integration/transfer.test.ts +1 -129
- package/src/tests/integration/wallet.test.ts +7 -7
- package/src/tests/integration/watchtower.test.ts +1 -1
- package/src/tests/token-hashing.test.ts +3 -6
- package/src/tests/token-outputs.test.ts +3 -3
- package/src/tests/utils/test-faucet.ts +2 -2
- package/src/types/sdk-types.ts +1 -1
- package/src/utils/adaptor-signature.ts +1 -1
- package/src/utils/address.ts +1 -1
- package/src/utils/bitcoin.ts +1 -5
- package/src/utils/keys.ts +1 -1
- package/src/utils/secret-sharing.ts +1 -1
- package/src/utils/token-transactions.ts +1 -2
- package/src/utils/transfer_package.ts +1 -1
- package/src/utils/unilateral-exit.ts +1 -1
package/src/proto/spark_authn.ts
CHANGED
package/src/proto/spark_token.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
2
|
// versions:
|
|
3
|
-
// protoc-gen-ts_proto v2.7.
|
|
3
|
+
// protoc-gen-ts_proto v2.7.7
|
|
4
4
|
// protoc v5.29.3
|
|
5
5
|
// source: validate/validate.proto
|
|
6
6
|
|
|
@@ -1788,16 +1788,12 @@ export const FloatRules: MessageFns<FloatRules> = {
|
|
|
1788
1788
|
if (message.gte !== undefined && message.gte !== 0) {
|
|
1789
1789
|
writer.uint32(45).float(message.gte);
|
|
1790
1790
|
}
|
|
1791
|
-
writer.uint32(50).fork();
|
|
1792
1791
|
for (const v of message.in) {
|
|
1793
|
-
writer.float(v);
|
|
1792
|
+
writer.uint32(53).float(v!);
|
|
1794
1793
|
}
|
|
1795
|
-
writer.join();
|
|
1796
|
-
writer.uint32(58).fork();
|
|
1797
1794
|
for (const v of message.notIn) {
|
|
1798
|
-
writer.float(v);
|
|
1795
|
+
writer.uint32(61).float(v!);
|
|
1799
1796
|
}
|
|
1800
|
-
writer.join();
|
|
1801
1797
|
if (message.ignoreEmpty !== undefined && message.ignoreEmpty !== false) {
|
|
1802
1798
|
writer.uint32(64).bool(message.ignoreEmpty);
|
|
1803
1799
|
}
|
|
@@ -1984,16 +1980,12 @@ export const DoubleRules: MessageFns<DoubleRules> = {
|
|
|
1984
1980
|
if (message.gte !== undefined && message.gte !== 0) {
|
|
1985
1981
|
writer.uint32(41).double(message.gte);
|
|
1986
1982
|
}
|
|
1987
|
-
writer.uint32(50).fork();
|
|
1988
1983
|
for (const v of message.in) {
|
|
1989
|
-
writer.double(v);
|
|
1984
|
+
writer.uint32(49).double(v!);
|
|
1990
1985
|
}
|
|
1991
|
-
writer.join();
|
|
1992
|
-
writer.uint32(58).fork();
|
|
1993
1986
|
for (const v of message.notIn) {
|
|
1994
|
-
writer.double(v);
|
|
1987
|
+
writer.uint32(57).double(v!);
|
|
1995
1988
|
}
|
|
1996
|
-
writer.join();
|
|
1997
1989
|
if (message.ignoreEmpty !== undefined && message.ignoreEmpty !== false) {
|
|
1998
1990
|
writer.uint32(64).bool(message.ignoreEmpty);
|
|
1999
1991
|
}
|
|
@@ -2180,16 +2172,12 @@ export const Int32Rules: MessageFns<Int32Rules> = {
|
|
|
2180
2172
|
if (message.gte !== undefined && message.gte !== 0) {
|
|
2181
2173
|
writer.uint32(40).int32(message.gte);
|
|
2182
2174
|
}
|
|
2183
|
-
writer.uint32(50).fork();
|
|
2184
2175
|
for (const v of message.in) {
|
|
2185
|
-
writer.int32(v);
|
|
2176
|
+
writer.uint32(48).int32(v!);
|
|
2186
2177
|
}
|
|
2187
|
-
writer.join();
|
|
2188
|
-
writer.uint32(58).fork();
|
|
2189
2178
|
for (const v of message.notIn) {
|
|
2190
|
-
writer.int32(v);
|
|
2179
|
+
writer.uint32(56).int32(v!);
|
|
2191
2180
|
}
|
|
2192
|
-
writer.join();
|
|
2193
2181
|
if (message.ignoreEmpty !== undefined && message.ignoreEmpty !== false) {
|
|
2194
2182
|
writer.uint32(64).bool(message.ignoreEmpty);
|
|
2195
2183
|
}
|
|
@@ -2376,16 +2364,12 @@ export const Int64Rules: MessageFns<Int64Rules> = {
|
|
|
2376
2364
|
if (message.gte !== undefined && message.gte !== 0) {
|
|
2377
2365
|
writer.uint32(40).int64(message.gte);
|
|
2378
2366
|
}
|
|
2379
|
-
writer.uint32(50).fork();
|
|
2380
2367
|
for (const v of message.in) {
|
|
2381
|
-
writer.int64(v);
|
|
2368
|
+
writer.uint32(48).int64(v!);
|
|
2382
2369
|
}
|
|
2383
|
-
writer.join();
|
|
2384
|
-
writer.uint32(58).fork();
|
|
2385
2370
|
for (const v of message.notIn) {
|
|
2386
|
-
writer.int64(v);
|
|
2371
|
+
writer.uint32(56).int64(v!);
|
|
2387
2372
|
}
|
|
2388
|
-
writer.join();
|
|
2389
2373
|
if (message.ignoreEmpty !== undefined && message.ignoreEmpty !== false) {
|
|
2390
2374
|
writer.uint32(64).bool(message.ignoreEmpty);
|
|
2391
2375
|
}
|
|
@@ -2572,16 +2556,12 @@ export const UInt32Rules: MessageFns<UInt32Rules> = {
|
|
|
2572
2556
|
if (message.gte !== undefined && message.gte !== 0) {
|
|
2573
2557
|
writer.uint32(40).uint32(message.gte);
|
|
2574
2558
|
}
|
|
2575
|
-
writer.uint32(50).fork();
|
|
2576
2559
|
for (const v of message.in) {
|
|
2577
|
-
writer.uint32(v);
|
|
2560
|
+
writer.uint32(48).uint32(v!);
|
|
2578
2561
|
}
|
|
2579
|
-
writer.join();
|
|
2580
|
-
writer.uint32(58).fork();
|
|
2581
2562
|
for (const v of message.notIn) {
|
|
2582
|
-
writer.uint32(v);
|
|
2563
|
+
writer.uint32(56).uint32(v!);
|
|
2583
2564
|
}
|
|
2584
|
-
writer.join();
|
|
2585
2565
|
if (message.ignoreEmpty !== undefined && message.ignoreEmpty !== false) {
|
|
2586
2566
|
writer.uint32(64).bool(message.ignoreEmpty);
|
|
2587
2567
|
}
|
|
@@ -2768,16 +2748,12 @@ export const UInt64Rules: MessageFns<UInt64Rules> = {
|
|
|
2768
2748
|
if (message.gte !== undefined && message.gte !== 0) {
|
|
2769
2749
|
writer.uint32(40).uint64(message.gte);
|
|
2770
2750
|
}
|
|
2771
|
-
writer.uint32(50).fork();
|
|
2772
2751
|
for (const v of message.in) {
|
|
2773
|
-
writer.uint64(v);
|
|
2752
|
+
writer.uint32(48).uint64(v!);
|
|
2774
2753
|
}
|
|
2775
|
-
writer.join();
|
|
2776
|
-
writer.uint32(58).fork();
|
|
2777
2754
|
for (const v of message.notIn) {
|
|
2778
|
-
writer.uint64(v);
|
|
2755
|
+
writer.uint32(56).uint64(v!);
|
|
2779
2756
|
}
|
|
2780
|
-
writer.join();
|
|
2781
2757
|
if (message.ignoreEmpty !== undefined && message.ignoreEmpty !== false) {
|
|
2782
2758
|
writer.uint32(64).bool(message.ignoreEmpty);
|
|
2783
2759
|
}
|
|
@@ -2964,16 +2940,12 @@ export const SInt32Rules: MessageFns<SInt32Rules> = {
|
|
|
2964
2940
|
if (message.gte !== undefined && message.gte !== 0) {
|
|
2965
2941
|
writer.uint32(40).sint32(message.gte);
|
|
2966
2942
|
}
|
|
2967
|
-
writer.uint32(50).fork();
|
|
2968
2943
|
for (const v of message.in) {
|
|
2969
|
-
writer.sint32(v);
|
|
2944
|
+
writer.uint32(48).sint32(v!);
|
|
2970
2945
|
}
|
|
2971
|
-
writer.join();
|
|
2972
|
-
writer.uint32(58).fork();
|
|
2973
2946
|
for (const v of message.notIn) {
|
|
2974
|
-
writer.sint32(v);
|
|
2947
|
+
writer.uint32(56).sint32(v!);
|
|
2975
2948
|
}
|
|
2976
|
-
writer.join();
|
|
2977
2949
|
if (message.ignoreEmpty !== undefined && message.ignoreEmpty !== false) {
|
|
2978
2950
|
writer.uint32(64).bool(message.ignoreEmpty);
|
|
2979
2951
|
}
|
|
@@ -3160,16 +3132,12 @@ export const SInt64Rules: MessageFns<SInt64Rules> = {
|
|
|
3160
3132
|
if (message.gte !== undefined && message.gte !== 0) {
|
|
3161
3133
|
writer.uint32(40).sint64(message.gte);
|
|
3162
3134
|
}
|
|
3163
|
-
writer.uint32(50).fork();
|
|
3164
3135
|
for (const v of message.in) {
|
|
3165
|
-
writer.sint64(v);
|
|
3136
|
+
writer.uint32(48).sint64(v!);
|
|
3166
3137
|
}
|
|
3167
|
-
writer.join();
|
|
3168
|
-
writer.uint32(58).fork();
|
|
3169
3138
|
for (const v of message.notIn) {
|
|
3170
|
-
writer.sint64(v);
|
|
3139
|
+
writer.uint32(56).sint64(v!);
|
|
3171
3140
|
}
|
|
3172
|
-
writer.join();
|
|
3173
3141
|
if (message.ignoreEmpty !== undefined && message.ignoreEmpty !== false) {
|
|
3174
3142
|
writer.uint32(64).bool(message.ignoreEmpty);
|
|
3175
3143
|
}
|
|
@@ -3356,16 +3324,12 @@ export const Fixed32Rules: MessageFns<Fixed32Rules> = {
|
|
|
3356
3324
|
if (message.gte !== undefined && message.gte !== 0) {
|
|
3357
3325
|
writer.uint32(45).fixed32(message.gte);
|
|
3358
3326
|
}
|
|
3359
|
-
writer.uint32(50).fork();
|
|
3360
3327
|
for (const v of message.in) {
|
|
3361
|
-
writer.fixed32(v);
|
|
3328
|
+
writer.uint32(53).fixed32(v!);
|
|
3362
3329
|
}
|
|
3363
|
-
writer.join();
|
|
3364
|
-
writer.uint32(58).fork();
|
|
3365
3330
|
for (const v of message.notIn) {
|
|
3366
|
-
writer.fixed32(v);
|
|
3331
|
+
writer.uint32(61).fixed32(v!);
|
|
3367
3332
|
}
|
|
3368
|
-
writer.join();
|
|
3369
3333
|
if (message.ignoreEmpty !== undefined && message.ignoreEmpty !== false) {
|
|
3370
3334
|
writer.uint32(64).bool(message.ignoreEmpty);
|
|
3371
3335
|
}
|
|
@@ -3552,16 +3516,12 @@ export const Fixed64Rules: MessageFns<Fixed64Rules> = {
|
|
|
3552
3516
|
if (message.gte !== undefined && message.gte !== 0) {
|
|
3553
3517
|
writer.uint32(41).fixed64(message.gte);
|
|
3554
3518
|
}
|
|
3555
|
-
writer.uint32(50).fork();
|
|
3556
3519
|
for (const v of message.in) {
|
|
3557
|
-
writer.fixed64(v);
|
|
3520
|
+
writer.uint32(49).fixed64(v!);
|
|
3558
3521
|
}
|
|
3559
|
-
writer.join();
|
|
3560
|
-
writer.uint32(58).fork();
|
|
3561
3522
|
for (const v of message.notIn) {
|
|
3562
|
-
writer.fixed64(v);
|
|
3523
|
+
writer.uint32(57).fixed64(v!);
|
|
3563
3524
|
}
|
|
3564
|
-
writer.join();
|
|
3565
3525
|
if (message.ignoreEmpty !== undefined && message.ignoreEmpty !== false) {
|
|
3566
3526
|
writer.uint32(64).bool(message.ignoreEmpty);
|
|
3567
3527
|
}
|
|
@@ -3748,16 +3708,12 @@ export const SFixed32Rules: MessageFns<SFixed32Rules> = {
|
|
|
3748
3708
|
if (message.gte !== undefined && message.gte !== 0) {
|
|
3749
3709
|
writer.uint32(45).sfixed32(message.gte);
|
|
3750
3710
|
}
|
|
3751
|
-
writer.uint32(50).fork();
|
|
3752
3711
|
for (const v of message.in) {
|
|
3753
|
-
writer.sfixed32(v);
|
|
3712
|
+
writer.uint32(53).sfixed32(v!);
|
|
3754
3713
|
}
|
|
3755
|
-
writer.join();
|
|
3756
|
-
writer.uint32(58).fork();
|
|
3757
3714
|
for (const v of message.notIn) {
|
|
3758
|
-
writer.sfixed32(v);
|
|
3715
|
+
writer.uint32(61).sfixed32(v!);
|
|
3759
3716
|
}
|
|
3760
|
-
writer.join();
|
|
3761
3717
|
if (message.ignoreEmpty !== undefined && message.ignoreEmpty !== false) {
|
|
3762
3718
|
writer.uint32(64).bool(message.ignoreEmpty);
|
|
3763
3719
|
}
|
|
@@ -3944,16 +3900,12 @@ export const SFixed64Rules: MessageFns<SFixed64Rules> = {
|
|
|
3944
3900
|
if (message.gte !== undefined && message.gte !== 0) {
|
|
3945
3901
|
writer.uint32(41).sfixed64(message.gte);
|
|
3946
3902
|
}
|
|
3947
|
-
writer.uint32(50).fork();
|
|
3948
3903
|
for (const v of message.in) {
|
|
3949
|
-
writer.sfixed64(v);
|
|
3904
|
+
writer.uint32(49).sfixed64(v!);
|
|
3950
3905
|
}
|
|
3951
|
-
writer.join();
|
|
3952
|
-
writer.uint32(58).fork();
|
|
3953
3906
|
for (const v of message.notIn) {
|
|
3954
|
-
writer.sfixed64(v);
|
|
3907
|
+
writer.uint32(57).sfixed64(v!);
|
|
3955
3908
|
}
|
|
3956
|
-
writer.join();
|
|
3957
3909
|
if (message.ignoreEmpty !== undefined && message.ignoreEmpty !== false) {
|
|
3958
3910
|
writer.uint32(64).bool(message.ignoreEmpty);
|
|
3959
3911
|
}
|
|
@@ -5025,16 +4977,12 @@ export const EnumRules: MessageFns<EnumRules> = {
|
|
|
5025
4977
|
if (message.definedOnly !== undefined && message.definedOnly !== false) {
|
|
5026
4978
|
writer.uint32(16).bool(message.definedOnly);
|
|
5027
4979
|
}
|
|
5028
|
-
writer.uint32(26).fork();
|
|
5029
4980
|
for (const v of message.in) {
|
|
5030
|
-
writer.int32(v);
|
|
4981
|
+
writer.uint32(24).int32(v!);
|
|
5031
4982
|
}
|
|
5032
|
-
writer.join();
|
|
5033
|
-
writer.uint32(34).fork();
|
|
5034
4983
|
for (const v of message.notIn) {
|
|
5035
|
-
writer.int32(v);
|
|
4984
|
+
writer.uint32(32).int32(v!);
|
|
5036
4985
|
}
|
|
5037
|
-
writer.join();
|
|
5038
4986
|
return writer;
|
|
5039
4987
|
},
|
|
5040
4988
|
|
package/src/services/deposit.ts
CHANGED
|
@@ -28,6 +28,11 @@ import { ConnectionManager } from "./connection.js";
|
|
|
28
28
|
type ValidateDepositAddressParams = {
|
|
29
29
|
address: Address;
|
|
30
30
|
userPubkey: Uint8Array;
|
|
31
|
+
verifyCoordinatorProof?: boolean;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type GenerateStaticDepositAddressParams = {
|
|
35
|
+
signingPubkey: Uint8Array;
|
|
31
36
|
};
|
|
32
37
|
|
|
33
38
|
export type GenerateDepositAddressParams = {
|
|
@@ -43,8 +48,6 @@ export type CreateTreeRootParams = {
|
|
|
43
48
|
vout: number;
|
|
44
49
|
};
|
|
45
50
|
|
|
46
|
-
const INITIAL_TIME_LOCK = 2000;
|
|
47
|
-
|
|
48
51
|
export class DepositService {
|
|
49
52
|
private readonly config: WalletConfigService;
|
|
50
53
|
private readonly connectionManager: ConnectionManager;
|
|
@@ -60,6 +63,7 @@ export class DepositService {
|
|
|
60
63
|
private async validateDepositAddress({
|
|
61
64
|
address,
|
|
62
65
|
userPubkey,
|
|
66
|
+
verifyCoordinatorProof = false,
|
|
63
67
|
}: ValidateDepositAddressParams) {
|
|
64
68
|
if (
|
|
65
69
|
!address.depositAddressProof ||
|
|
@@ -106,7 +110,10 @@ export class DepositService {
|
|
|
106
110
|
|
|
107
111
|
const addrHash = sha256(address.address);
|
|
108
112
|
for (const operator of Object.values(this.config.getSigningOperators())) {
|
|
109
|
-
if (
|
|
113
|
+
if (
|
|
114
|
+
operator.identifier === this.config.getCoordinatorIdentifier() &&
|
|
115
|
+
!verifyCoordinatorProof
|
|
116
|
+
) {
|
|
110
117
|
continue;
|
|
111
118
|
}
|
|
112
119
|
|
|
@@ -135,6 +142,51 @@ export class DepositService {
|
|
|
135
142
|
}
|
|
136
143
|
}
|
|
137
144
|
|
|
145
|
+
async generateStaticDepositAddress({
|
|
146
|
+
signingPubkey,
|
|
147
|
+
}: GenerateStaticDepositAddressParams): Promise<GenerateDepositAddressResponse> {
|
|
148
|
+
const sparkClient = await this.connectionManager.createSparkClient(
|
|
149
|
+
this.config.getCoordinatorAddress(),
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
let depositResp: GenerateDepositAddressResponse;
|
|
153
|
+
try {
|
|
154
|
+
depositResp = await sparkClient.generate_static_deposit_address({
|
|
155
|
+
signingPublicKey: signingPubkey,
|
|
156
|
+
identityPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
157
|
+
network: this.config.getNetworkProto(),
|
|
158
|
+
});
|
|
159
|
+
} catch (error) {
|
|
160
|
+
throw new NetworkError(
|
|
161
|
+
"Failed to generate static deposit address",
|
|
162
|
+
{
|
|
163
|
+
operation: "generate_static_deposit_address",
|
|
164
|
+
errorCount: 1,
|
|
165
|
+
errors: error instanceof Error ? error.message : String(error),
|
|
166
|
+
},
|
|
167
|
+
error as Error,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (!depositResp.depositAddress) {
|
|
172
|
+
throw new ValidationError(
|
|
173
|
+
"No static deposit address response from coordinator",
|
|
174
|
+
{
|
|
175
|
+
field: "depositAddress",
|
|
176
|
+
value: depositResp,
|
|
177
|
+
},
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
await this.validateDepositAddress({
|
|
182
|
+
address: depositResp.depositAddress,
|
|
183
|
+
userPubkey: signingPubkey,
|
|
184
|
+
verifyCoordinatorProof: true,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
return depositResp;
|
|
188
|
+
}
|
|
189
|
+
|
|
138
190
|
async generateDepositAddress({
|
|
139
191
|
signingPubkey,
|
|
140
192
|
leafId,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
1
2
|
import {
|
|
2
3
|
bytesToNumberBE,
|
|
3
4
|
hexToBytes,
|
|
4
5
|
numberToBytesBE,
|
|
5
|
-
} from "@noble/curves/
|
|
6
|
-
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
6
|
+
} from "@noble/curves/utils";
|
|
7
7
|
import { sha256 } from "@noble/hashes/sha2";
|
|
8
8
|
import { uuidv7 } from "uuidv7";
|
|
9
9
|
import { NetworkError, ValidationError } from "../errors/types.js";
|
package/src/services/signing.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hexToBytes } from "@noble/curves/
|
|
1
|
+
import { hexToBytes } from "@noble/curves/utils";
|
|
2
2
|
import { Transaction } from "@scure/btc-signer";
|
|
3
3
|
import { TransactionInput } from "@scure/btc-signer/psbt";
|
|
4
4
|
import { ValidationError } from "../errors/types.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
1
2
|
import {
|
|
2
3
|
bytesToHex,
|
|
3
4
|
bytesToNumberBE,
|
|
4
5
|
numberToBytesBE,
|
|
5
|
-
} from "@noble/curves/
|
|
6
|
-
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
6
|
+
} from "@noble/curves/utils";
|
|
7
7
|
import { hexToBytes } from "@noble/hashes/utils";
|
|
8
8
|
import {
|
|
9
9
|
InternalValidationError,
|
|
@@ -17,9 +17,7 @@ import {
|
|
|
17
17
|
QueryTokenTransactionsRequest as QueryTokenTransactionsRequestV0,
|
|
18
18
|
RevocationSecretWithIndex,
|
|
19
19
|
SignTokenTransactionResponse,
|
|
20
|
-
SparkInvoiceFields,
|
|
21
20
|
TokenTransaction as TokenTransactionV0,
|
|
22
|
-
TokenTransactionWithStatus as TokenTransactionWithStatusV0,
|
|
23
21
|
} from "../proto/spark.js";
|
|
24
22
|
import {
|
|
25
23
|
InputTtxoSignaturesPerOperator,
|
|
@@ -28,7 +26,6 @@ import {
|
|
|
28
26
|
SignatureWithIndex,
|
|
29
27
|
TokenOutput,
|
|
30
28
|
TokenTransaction,
|
|
31
|
-
TokenTransactionWithStatus as TokenTransactionWithStatusV1,
|
|
32
29
|
} from "../proto/spark_token.js";
|
|
33
30
|
import { TokenOutputsMap } from "../spark-wallet/types.js";
|
|
34
31
|
import { SparkCallOptions } from "../types/grpc.js";
|
package/src/services/transfer.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
1
2
|
import {
|
|
2
3
|
bytesToHex,
|
|
3
4
|
equalBytes,
|
|
4
5
|
hexToBytes,
|
|
5
6
|
numberToBytesBE,
|
|
6
|
-
} from "@noble/curves/
|
|
7
|
-
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
7
|
+
} from "@noble/curves/utils";
|
|
8
8
|
import { sha256 } from "@noble/hashes/sha2";
|
|
9
9
|
import { Transaction } from "@scure/btc-signer";
|
|
10
10
|
import { TransactionInput, TransactionOutput } from "@scure/btc-signer/psbt";
|
|
@@ -1452,32 +1452,6 @@ export class TransferService extends BaseTransferService {
|
|
|
1452
1452
|
}
|
|
1453
1453
|
}
|
|
1454
1454
|
|
|
1455
|
-
async cancelTransfer(
|
|
1456
|
-
transfer: Transfer,
|
|
1457
|
-
operatorAddress: string,
|
|
1458
|
-
): Promise<Transfer | undefined> {
|
|
1459
|
-
const sparkClient =
|
|
1460
|
-
await this.connectionManager.createSparkClient(operatorAddress);
|
|
1461
|
-
|
|
1462
|
-
try {
|
|
1463
|
-
const response = await sparkClient.cancel_transfer({
|
|
1464
|
-
transferId: transfer.id,
|
|
1465
|
-
senderIdentityPublicKey:
|
|
1466
|
-
await this.config.signer.getIdentityPublicKey(),
|
|
1467
|
-
});
|
|
1468
|
-
|
|
1469
|
-
return response.transfer;
|
|
1470
|
-
} catch (error) {
|
|
1471
|
-
throw new NetworkError(
|
|
1472
|
-
"Failed to cancel transfer",
|
|
1473
|
-
{
|
|
1474
|
-
method: "POST",
|
|
1475
|
-
},
|
|
1476
|
-
error as Error,
|
|
1477
|
-
);
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
1455
|
async queryPendingTransfersBySender(
|
|
1482
1456
|
operatorAddress: string,
|
|
1483
1457
|
): Promise<QueryTransfersResponse> {
|
package/src/signer/signer.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { privateNegate } from "@bitcoinerlab/secp256k1";
|
|
2
|
+
import { schnorr, secp256k1 } from "@noble/curves/secp256k1";
|
|
2
3
|
import {
|
|
3
4
|
bytesToHex,
|
|
4
5
|
bytesToNumberBE,
|
|
5
6
|
equalBytes,
|
|
6
7
|
hexToBytes,
|
|
7
|
-
} from "@noble/curves/
|
|
8
|
-
import { schnorr, secp256k1 } from "@noble/curves/secp256k1";
|
|
8
|
+
} from "@noble/curves/utils";
|
|
9
9
|
import { sha256 } from "@noble/hashes/sha2";
|
|
10
10
|
import { HDKey } from "@scure/bip32";
|
|
11
11
|
import { generateMnemonic, mnemonicToSeed } from "@scure/bip39";
|