@buildonspark/spark-sdk 0.2.10 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -1
- package/dist/bare/chunk-P6AVV7VD.js +34 -0
- package/dist/bare/index.cjs +729 -166
- package/dist/bare/index.d.cts +62 -5
- package/dist/bare/index.d.ts +62 -5
- package/dist/bare/index.js +675 -173
- package/dist/bare/{wasm-OPXXYRN5.js → wasm-F5QFVBNZ.js} +26 -0
- package/dist/bare/{xhr-transport-6GYJAFWU.js → xhr-transport-EEEC7FYA.js} +2 -2
- package/dist/{chunk-A5M55UR3.js → chunk-5VWGOHED.js} +499 -8
- package/dist/{chunk-MWBK6QBF.js → chunk-NQMQVXR5.js} +1 -1
- package/dist/chunk-NX5KPN5F.js +34 -0
- package/dist/{chunk-JXLWOQK5.js → chunk-OEK3R57K.js} +196 -162
- 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 +725 -163
- package/dist/debug.d.cts +8 -5
- package/dist/debug.d.ts +8 -5
- package/dist/debug.js +5 -4
- package/dist/graphql/objects/index.d.cts +3 -3
- package/dist/graphql/objects/index.d.ts +3 -3
- package/dist/index.cjs +810 -246
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +11 -5
- package/dist/index.node.cjs +810 -246
- package/dist/index.node.d.cts +6 -6
- package/dist/index.node.d.ts +6 -6
- package/dist/index.node.js +10 -4
- package/dist/{xchain-address-BPwpnmuY.d.ts → logging-ClNhGzus.d.ts} +18 -4
- package/dist/{xchain-address-CNQEwLjR.d.cts → logging-D3kvES69.d.cts} +18 -4
- package/dist/native/chunk-D3SZRO65.js +36 -0
- package/dist/native/index.cjs +808 -244
- package/dist/native/index.d.cts +62 -5
- package/dist/native/index.d.ts +62 -5
- package/dist/native/index.js +769 -268
- package/dist/native/{wasm-2KV6XFEP.js → wasm-3YAXKQ7F.js} +25 -0
- package/dist/native/{xhr-transport-WHMS3FGG.js → xhr-transport-TNCG4HTW.js} +2 -2
- 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-yc2KhsVY.d.cts → spark-wallet-Dg5IRQe2.d.cts} +3 -5
- package/dist/{spark-wallet-Cp3yv6cK.d.ts → spark-wallet-DiHSU-pz.d.ts} +3 -5
- package/dist/{spark-wallet.node-D4IovOHu.d.ts → spark-wallet.node-BZrxwomN.d.ts} +1 -1
- package/dist/{spark-wallet.node-D0Qw5Wb4.d.cts → spark-wallet.node-DSWb18zh.d.cts} +1 -1
- package/dist/spark_bindings/wasm/index.cjs +51 -0
- package/dist/spark_bindings/wasm/index.js +25 -0
- package/dist/tests/test-utils.cjs +725 -155
- package/dist/tests/test-utils.d.cts +4 -4
- package/dist/tests/test-utils.d.ts +4 -4
- package/dist/tests/test-utils.js +6 -5
- package/dist/{token-transactions-CwhlOgIP.d.cts → token-transactions-B-WqFYpW.d.cts} +2 -2
- package/dist/{token-transactions-0nmR9mQO.d.ts → token-transactions-DovxHIxV.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/dist/{xhr-transport-RH6LDRXS.js → xhr-transport-IWJPYF7F.js} +2 -2
- package/package.json +1 -1
- 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 +60 -4
- 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 -2
- package/src/services/xhr-transport.ts +2 -2
- package/src/signer/signer.ts +2 -2
- package/src/spark-wallet/spark-wallet.ts +25 -33
- package/src/spark_bindings/wasm/index.ts +21 -0
- package/src/tests/address.test.ts +10 -10
- package/src/tests/bitcoin.test.ts +2 -2
- package/src/tests/integration/coop-exit.test.ts +1 -1
- package/src/tests/integration/lightning.test.ts +1 -1
- package/src/tests/integration/ssp/coop-exit-validation.test.ts +2 -2
- package/src/tests/integration/ssp/static_deposit.test.ts +122 -33
- package/src/tests/integration/swap.test.ts +1 -1
- package/src/tests/integration/transfer.test.ts +1 -5
- package/src/tests/integration/wallet.test.ts +7 -7
- package/src/tests/integration/watchtower.test.ts +3 -3
- 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 +12 -13
- package/src/utils/address.ts +10 -10
- package/src/utils/bitcoin.ts +7 -11
- package/src/utils/index.ts +1 -0
- package/src/utils/keys.ts +10 -10
- package/src/utils/logging.ts +40 -0
- package/src/utils/secret-sharing.ts +10 -12
- 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
|
|
|
@@ -121,7 +128,11 @@ export class DepositService {
|
|
|
121
128
|
}
|
|
122
129
|
const sig = secp256k1.Signature.fromDER(operatorSig);
|
|
123
130
|
|
|
124
|
-
const isVerified = secp256k1.verify(
|
|
131
|
+
const isVerified = secp256k1.verify(
|
|
132
|
+
sig.toCompactRawBytes(),
|
|
133
|
+
addrHash,
|
|
134
|
+
operatorPubkey,
|
|
135
|
+
);
|
|
125
136
|
if (!isVerified) {
|
|
126
137
|
throw new ValidationError("Operator signature verification failed", {
|
|
127
138
|
field: "operatorSignature",
|
|
@@ -131,6 +142,51 @@ export class DepositService {
|
|
|
131
142
|
}
|
|
132
143
|
}
|
|
133
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
|
+
|
|
134
190
|
async generateDepositAddress({
|
|
135
191
|
signingPubkey,
|
|
136
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";
|
|
@@ -100,7 +100,7 @@ export function XHRTransport(config?: XHRTransportConfig): Transport {
|
|
|
100
100
|
break;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
requestBody = bodyBuffer
|
|
103
|
+
requestBody = bodyBuffer!.slice();
|
|
104
104
|
} else {
|
|
105
105
|
let iterator: AsyncIterator<Uint8Array> | undefined;
|
|
106
106
|
|
|
@@ -117,7 +117,7 @@ export function XHRTransport(config?: XHRTransportConfig): Transport {
|
|
|
117
117
|
if (done) {
|
|
118
118
|
controller.close();
|
|
119
119
|
} else {
|
|
120
|
-
controller.enqueue(value);
|
|
120
|
+
controller.enqueue(value.slice());
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
async cancel() {
|
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";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isNode, isObject, mapCurrencyAmount } from "@lightsparkdev/core";
|
|
2
|
+
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
2
3
|
import {
|
|
3
4
|
bytesToHex,
|
|
4
5
|
bytesToNumberBE,
|
|
5
6
|
equalBytes,
|
|
6
7
|
hexToBytes,
|
|
7
8
|
numberToVarBytesBE,
|
|
8
|
-
} from "@noble/curves/
|
|
9
|
-
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
9
|
+
} from "@noble/curves/utils";
|
|
10
10
|
import { validateMnemonic } from "@scure/bip39";
|
|
11
11
|
import { wordlist } from "@scure/bip39/wordlists/english";
|
|
12
12
|
import { Address, OutScript, Transaction } from "@scure/btc-signer";
|
|
@@ -100,7 +100,6 @@ import { EventEmitter } from "eventemitter3";
|
|
|
100
100
|
import { ClientError, Status } from "nice-grpc-common";
|
|
101
101
|
import { isReactNative } from "../constants.js";
|
|
102
102
|
import { Network as NetworkProto, networkToJSON } from "../proto/spark.js";
|
|
103
|
-
import { TokenTransactionWithStatus } from "../proto/spark_token.js";
|
|
104
103
|
import {
|
|
105
104
|
decodeInvoice,
|
|
106
105
|
getNetworkFromInvoice,
|
|
@@ -126,6 +125,7 @@ import {
|
|
|
126
125
|
} from "../utils/address.js";
|
|
127
126
|
import { chunkArray } from "../utils/chunkArray.js";
|
|
128
127
|
import { getFetch } from "../utils/fetch.js";
|
|
128
|
+
import { HashSparkInvoice } from "../utils/invoice-hashing.js";
|
|
129
129
|
import { addPublicKeys } from "../utils/keys.js";
|
|
130
130
|
import { RetryContext, withRetry } from "../utils/retry.js";
|
|
131
131
|
import {
|
|
@@ -145,7 +145,6 @@ import type {
|
|
|
145
145
|
TransferParams,
|
|
146
146
|
UserTokenMetadata,
|
|
147
147
|
} from "./types.js";
|
|
148
|
-
import { HashSparkInvoice } from "../utils/invoice-hashing.js";
|
|
149
148
|
|
|
150
149
|
/**
|
|
151
150
|
* The SparkWallet class is the primary interface for interacting with the Spark network.
|
|
@@ -1628,7 +1627,7 @@ export class SparkWallet extends EventEmitter {
|
|
|
1628
1627
|
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
1629
1628
|
*/
|
|
1630
1629
|
public async getSingleUseDepositAddress(): Promise<string> {
|
|
1631
|
-
return await this.generateDepositAddress(
|
|
1630
|
+
return await this.generateDepositAddress();
|
|
1632
1631
|
}
|
|
1633
1632
|
|
|
1634
1633
|
/**
|
|
@@ -1638,47 +1637,38 @@ export class SparkWallet extends EventEmitter {
|
|
|
1638
1637
|
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
1639
1638
|
*/
|
|
1640
1639
|
public async getStaticDepositAddress(): Promise<string> {
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
} else {
|
|
1653
|
-
throw error;
|
|
1654
|
-
}
|
|
1640
|
+
const signingPubkey =
|
|
1641
|
+
await this.config.signer.getStaticDepositSigningKey(0);
|
|
1642
|
+
|
|
1643
|
+
const address = await this.depositService!.generateStaticDepositAddress({
|
|
1644
|
+
signingPubkey,
|
|
1645
|
+
});
|
|
1646
|
+
if (!address.depositAddress) {
|
|
1647
|
+
throw new RPCError("Failed to generate static deposit address", {
|
|
1648
|
+
method: "generateStaticDepositAddress",
|
|
1649
|
+
params: { signingPubkey },
|
|
1650
|
+
});
|
|
1655
1651
|
}
|
|
1652
|
+
|
|
1653
|
+
return address.depositAddress.address;
|
|
1656
1654
|
}
|
|
1657
1655
|
|
|
1658
1656
|
/**
|
|
1659
1657
|
* Generates a deposit address for receiving funds.
|
|
1660
|
-
*
|
|
1661
|
-
* @param {boolean} static - Whether the address is static or single use
|
|
1662
1658
|
* @returns {Promise<string>} A deposit address
|
|
1663
1659
|
* @private
|
|
1664
1660
|
*/
|
|
1665
|
-
private async generateDepositAddress(
|
|
1661
|
+
private async generateDepositAddress(): Promise<string> {
|
|
1666
1662
|
const leafId = uuidv7();
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
}
|
|
1672
|
-
signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
|
|
1673
|
-
type: KeyDerivationType.LEAF,
|
|
1674
|
-
path: leafId,
|
|
1675
|
-
});
|
|
1676
|
-
}
|
|
1663
|
+
|
|
1664
|
+
const signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
|
|
1665
|
+
type: KeyDerivationType.LEAF,
|
|
1666
|
+
path: leafId,
|
|
1667
|
+
});
|
|
1677
1668
|
|
|
1678
1669
|
const address = await this.depositService!.generateDepositAddress({
|
|
1679
1670
|
signingPubkey,
|
|
1680
1671
|
leafId,
|
|
1681
|
-
isStatic,
|
|
1682
1672
|
});
|
|
1683
1673
|
if (!address.depositAddress) {
|
|
1684
1674
|
throw new RPCError("Failed to generate deposit address", {
|
|
@@ -1713,6 +1703,7 @@ export class SparkWallet extends EventEmitter {
|
|
|
1713
1703
|
depositAddress: string,
|
|
1714
1704
|
limit: number = 100,
|
|
1715
1705
|
offset: number = 0,
|
|
1706
|
+
excludeClaimed: boolean = false,
|
|
1716
1707
|
): Promise<{ txid: string; vout: number }[]> {
|
|
1717
1708
|
if (!depositAddress) {
|
|
1718
1709
|
throw new ValidationError("Deposit address cannot be empty", {
|
|
@@ -1730,6 +1721,7 @@ export class SparkWallet extends EventEmitter {
|
|
|
1730
1721
|
network: NetworkToProto[this.config.getNetwork()],
|
|
1731
1722
|
limit,
|
|
1732
1723
|
offset,
|
|
1724
|
+
excludeClaimed,
|
|
1733
1725
|
});
|
|
1734
1726
|
|
|
1735
1727
|
return (
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { bytesToHex } from "@noble/curves/utils";
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
create_dummy_tx,
|
|
3
5
|
decrypt_ecies,
|
|
@@ -16,6 +18,7 @@ import {
|
|
|
16
18
|
ISigningNonce,
|
|
17
19
|
SignFrostParams,
|
|
18
20
|
} from "../types.js";
|
|
21
|
+
import { SparkSdkLogger, LOGGER_NAMES } from "../../utils/logging.js";
|
|
19
22
|
|
|
20
23
|
function createKeyPackage(params: IKeyPackage): KeyPackage {
|
|
21
24
|
return new KeyPackage(
|
|
@@ -43,6 +46,13 @@ export function signFrost({
|
|
|
43
46
|
statechainCommitments,
|
|
44
47
|
adaptorPubKey,
|
|
45
48
|
}: SignFrostParams): Uint8Array {
|
|
49
|
+
SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("signFrost", {
|
|
50
|
+
message: bytesToHex(message),
|
|
51
|
+
keyPackage: keyPackage,
|
|
52
|
+
nonce: nonce,
|
|
53
|
+
selfCommitment: selfCommitment,
|
|
54
|
+
statechainCommitments: statechainCommitments,
|
|
55
|
+
});
|
|
46
56
|
return wasm_sign_frost(
|
|
47
57
|
message,
|
|
48
58
|
createKeyPackage(keyPackage),
|
|
@@ -64,6 +74,17 @@ export function aggregateFrost({
|
|
|
64
74
|
verifyingKey,
|
|
65
75
|
adaptorPubKey,
|
|
66
76
|
}: AggregateFrostParams): Uint8Array {
|
|
77
|
+
SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("aggregateFrost", {
|
|
78
|
+
message: bytesToHex(message),
|
|
79
|
+
statechainCommitments: statechainCommitments,
|
|
80
|
+
selfCommitment: selfCommitment,
|
|
81
|
+
statechainSignatures: statechainSignatures,
|
|
82
|
+
selfSignature: bytesToHex(selfSignature),
|
|
83
|
+
statechainPublicKeys: statechainPublicKeys,
|
|
84
|
+
selfPublicKey: bytesToHex(selfPublicKey),
|
|
85
|
+
verifyingKey: bytesToHex(verifyingKey),
|
|
86
|
+
adaptorPubKey: adaptorPubKey ? bytesToHex(adaptorPubKey) : undefined,
|
|
87
|
+
});
|
|
67
88
|
return wasm_aggregate_frost(
|
|
68
89
|
message,
|
|
69
90
|
statechainCommitments,
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { uuidv7obj } from "uuidv7";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
Bech32mTokenIdentifier,
|
|
5
|
-
decodeBech32mTokenIdentifier,
|
|
6
|
-
} from "../utils/token-identifier.js";
|
|
7
3
|
import {
|
|
8
4
|
bytesToHex,
|
|
9
5
|
bytesToNumberBE,
|
|
10
6
|
hexToBytes,
|
|
11
7
|
numberToVarBytesBE,
|
|
12
|
-
} from "@noble/curves/
|
|
8
|
+
} from "@noble/curves/utils";
|
|
9
|
+
import { bech32m } from "@scure/base";
|
|
10
|
+
import { SparkAddress } from "../proto/spark.js";
|
|
13
11
|
import {
|
|
14
|
-
|
|
12
|
+
bech32mDecode,
|
|
15
13
|
decodeSparkAddress,
|
|
16
|
-
|
|
14
|
+
encodeSparkAddress,
|
|
17
15
|
encodeSparkAddressWithSignature,
|
|
16
|
+
getNetworkFromSparkAddress,
|
|
18
17
|
SparkAddressData,
|
|
19
|
-
bech32mDecode,
|
|
20
18
|
SparkAddressFormat,
|
|
21
19
|
} from "../utils/address.js";
|
|
22
|
-
import {
|
|
23
|
-
|
|
20
|
+
import {
|
|
21
|
+
Bech32mTokenIdentifier,
|
|
22
|
+
decodeBech32mTokenIdentifier,
|
|
23
|
+
} from "../utils/token-identifier.js";
|
|
24
24
|
|
|
25
25
|
describe("Spark Invoice Encode/Decode", () => {
|
|
26
26
|
const testCases = [
|