@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/dist/native/index.js
CHANGED
|
@@ -130,8 +130,8 @@ var NotImplementedError = class extends SparkSDKError {
|
|
|
130
130
|
|
|
131
131
|
// src/utils/address.ts
|
|
132
132
|
import { BinaryWriter as BinaryWriter5 } from "@bufbuild/protobuf/wire";
|
|
133
|
-
import { bytesToNumberBE } from "@noble/curves/abstract/utils";
|
|
134
133
|
import { schnorr, secp256k1 } from "@noble/curves/secp256k1";
|
|
134
|
+
import { bytesToNumberBE } from "@noble/curves/utils";
|
|
135
135
|
import { bytesToHex as bytesToHex2, hexToBytes } from "@noble/hashes/utils";
|
|
136
136
|
import { bech32m } from "@scure/base";
|
|
137
137
|
import { UUID } from "uuidv7";
|
|
@@ -695,6 +695,41 @@ function utxoSwapRequestTypeToJSON(object) {
|
|
|
695
695
|
return "UNRECOGNIZED";
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
|
+
function invoiceStatusFromJSON(object) {
|
|
699
|
+
switch (object) {
|
|
700
|
+
case 0:
|
|
701
|
+
case "NOT_FOUND":
|
|
702
|
+
return 0 /* NOT_FOUND */;
|
|
703
|
+
case 1:
|
|
704
|
+
case "PENDING":
|
|
705
|
+
return 1 /* PENDING */;
|
|
706
|
+
case 2:
|
|
707
|
+
case "FINALIZED":
|
|
708
|
+
return 2 /* FINALIZED */;
|
|
709
|
+
case 3:
|
|
710
|
+
case "EXPIRED":
|
|
711
|
+
return 3 /* EXPIRED */;
|
|
712
|
+
case -1:
|
|
713
|
+
case "UNRECOGNIZED":
|
|
714
|
+
default:
|
|
715
|
+
return -1 /* UNRECOGNIZED */;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
function invoiceStatusToJSON(object) {
|
|
719
|
+
switch (object) {
|
|
720
|
+
case 0 /* NOT_FOUND */:
|
|
721
|
+
return "NOT_FOUND";
|
|
722
|
+
case 1 /* PENDING */:
|
|
723
|
+
return "PENDING";
|
|
724
|
+
case 2 /* FINALIZED */:
|
|
725
|
+
return "FINALIZED";
|
|
726
|
+
case 3 /* EXPIRED */:
|
|
727
|
+
return "EXPIRED";
|
|
728
|
+
case -1 /* UNRECOGNIZED */:
|
|
729
|
+
default:
|
|
730
|
+
return "UNRECOGNIZED";
|
|
731
|
+
}
|
|
732
|
+
}
|
|
698
733
|
function initiatePreimageSwapRequest_ReasonFromJSON(object) {
|
|
699
734
|
switch (object) {
|
|
700
735
|
case 0:
|
|
@@ -1434,6 +1469,140 @@ var GenerateDepositAddressResponse = {
|
|
|
1434
1469
|
return message;
|
|
1435
1470
|
}
|
|
1436
1471
|
};
|
|
1472
|
+
function createBaseGenerateStaticDepositAddressRequest() {
|
|
1473
|
+
return { signingPublicKey: new Uint8Array(0), identityPublicKey: new Uint8Array(0), network: 0 };
|
|
1474
|
+
}
|
|
1475
|
+
var GenerateStaticDepositAddressRequest = {
|
|
1476
|
+
encode(message, writer = new BinaryWriter4()) {
|
|
1477
|
+
if (message.signingPublicKey.length !== 0) {
|
|
1478
|
+
writer.uint32(10).bytes(message.signingPublicKey);
|
|
1479
|
+
}
|
|
1480
|
+
if (message.identityPublicKey.length !== 0) {
|
|
1481
|
+
writer.uint32(18).bytes(message.identityPublicKey);
|
|
1482
|
+
}
|
|
1483
|
+
if (message.network !== 0) {
|
|
1484
|
+
writer.uint32(24).int32(message.network);
|
|
1485
|
+
}
|
|
1486
|
+
return writer;
|
|
1487
|
+
},
|
|
1488
|
+
decode(input, length) {
|
|
1489
|
+
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
1490
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
1491
|
+
const message = createBaseGenerateStaticDepositAddressRequest();
|
|
1492
|
+
while (reader.pos < end) {
|
|
1493
|
+
const tag = reader.uint32();
|
|
1494
|
+
switch (tag >>> 3) {
|
|
1495
|
+
case 1: {
|
|
1496
|
+
if (tag !== 10) {
|
|
1497
|
+
break;
|
|
1498
|
+
}
|
|
1499
|
+
message.signingPublicKey = reader.bytes();
|
|
1500
|
+
continue;
|
|
1501
|
+
}
|
|
1502
|
+
case 2: {
|
|
1503
|
+
if (tag !== 18) {
|
|
1504
|
+
break;
|
|
1505
|
+
}
|
|
1506
|
+
message.identityPublicKey = reader.bytes();
|
|
1507
|
+
continue;
|
|
1508
|
+
}
|
|
1509
|
+
case 3: {
|
|
1510
|
+
if (tag !== 24) {
|
|
1511
|
+
break;
|
|
1512
|
+
}
|
|
1513
|
+
message.network = reader.int32();
|
|
1514
|
+
continue;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1518
|
+
break;
|
|
1519
|
+
}
|
|
1520
|
+
reader.skip(tag & 7);
|
|
1521
|
+
}
|
|
1522
|
+
return message;
|
|
1523
|
+
},
|
|
1524
|
+
fromJSON(object) {
|
|
1525
|
+
return {
|
|
1526
|
+
signingPublicKey: isSet3(object.signingPublicKey) ? bytesFromBase642(object.signingPublicKey) : new Uint8Array(0),
|
|
1527
|
+
identityPublicKey: isSet3(object.identityPublicKey) ? bytesFromBase642(object.identityPublicKey) : new Uint8Array(0),
|
|
1528
|
+
network: isSet3(object.network) ? networkFromJSON(object.network) : 0
|
|
1529
|
+
};
|
|
1530
|
+
},
|
|
1531
|
+
toJSON(message) {
|
|
1532
|
+
const obj = {};
|
|
1533
|
+
if (message.signingPublicKey.length !== 0) {
|
|
1534
|
+
obj.signingPublicKey = base64FromBytes2(message.signingPublicKey);
|
|
1535
|
+
}
|
|
1536
|
+
if (message.identityPublicKey.length !== 0) {
|
|
1537
|
+
obj.identityPublicKey = base64FromBytes2(message.identityPublicKey);
|
|
1538
|
+
}
|
|
1539
|
+
if (message.network !== 0) {
|
|
1540
|
+
obj.network = networkToJSON(message.network);
|
|
1541
|
+
}
|
|
1542
|
+
return obj;
|
|
1543
|
+
},
|
|
1544
|
+
create(base) {
|
|
1545
|
+
return GenerateStaticDepositAddressRequest.fromPartial(base ?? {});
|
|
1546
|
+
},
|
|
1547
|
+
fromPartial(object) {
|
|
1548
|
+
const message = createBaseGenerateStaticDepositAddressRequest();
|
|
1549
|
+
message.signingPublicKey = object.signingPublicKey ?? new Uint8Array(0);
|
|
1550
|
+
message.identityPublicKey = object.identityPublicKey ?? new Uint8Array(0);
|
|
1551
|
+
message.network = object.network ?? 0;
|
|
1552
|
+
return message;
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
function createBaseGenerateStaticDepositAddressResponse() {
|
|
1556
|
+
return { depositAddress: void 0 };
|
|
1557
|
+
}
|
|
1558
|
+
var GenerateStaticDepositAddressResponse = {
|
|
1559
|
+
encode(message, writer = new BinaryWriter4()) {
|
|
1560
|
+
if (message.depositAddress !== void 0) {
|
|
1561
|
+
Address.encode(message.depositAddress, writer.uint32(10).fork()).join();
|
|
1562
|
+
}
|
|
1563
|
+
return writer;
|
|
1564
|
+
},
|
|
1565
|
+
decode(input, length) {
|
|
1566
|
+
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
1567
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
1568
|
+
const message = createBaseGenerateStaticDepositAddressResponse();
|
|
1569
|
+
while (reader.pos < end) {
|
|
1570
|
+
const tag = reader.uint32();
|
|
1571
|
+
switch (tag >>> 3) {
|
|
1572
|
+
case 1: {
|
|
1573
|
+
if (tag !== 10) {
|
|
1574
|
+
break;
|
|
1575
|
+
}
|
|
1576
|
+
message.depositAddress = Address.decode(reader, reader.uint32());
|
|
1577
|
+
continue;
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1581
|
+
break;
|
|
1582
|
+
}
|
|
1583
|
+
reader.skip(tag & 7);
|
|
1584
|
+
}
|
|
1585
|
+
return message;
|
|
1586
|
+
},
|
|
1587
|
+
fromJSON(object) {
|
|
1588
|
+
return { depositAddress: isSet3(object.depositAddress) ? Address.fromJSON(object.depositAddress) : void 0 };
|
|
1589
|
+
},
|
|
1590
|
+
toJSON(message) {
|
|
1591
|
+
const obj = {};
|
|
1592
|
+
if (message.depositAddress !== void 0) {
|
|
1593
|
+
obj.depositAddress = Address.toJSON(message.depositAddress);
|
|
1594
|
+
}
|
|
1595
|
+
return obj;
|
|
1596
|
+
},
|
|
1597
|
+
create(base) {
|
|
1598
|
+
return GenerateStaticDepositAddressResponse.fromPartial(base ?? {});
|
|
1599
|
+
},
|
|
1600
|
+
fromPartial(object) {
|
|
1601
|
+
const message = createBaseGenerateStaticDepositAddressResponse();
|
|
1602
|
+
message.depositAddress = object.depositAddress !== void 0 && object.depositAddress !== null ? Address.fromPartial(object.depositAddress) : void 0;
|
|
1603
|
+
return message;
|
|
1604
|
+
}
|
|
1605
|
+
};
|
|
1437
1606
|
function createBaseUTXO() {
|
|
1438
1607
|
return { rawTx: new Uint8Array(0), vout: 0, network: 0, txid: new Uint8Array(0) };
|
|
1439
1608
|
}
|
|
@@ -7547,7 +7716,8 @@ function createBaseTransferLeaf() {
|
|
|
7547
7716
|
signature: new Uint8Array(0),
|
|
7548
7717
|
intermediateRefundTx: new Uint8Array(0),
|
|
7549
7718
|
intermediateDirectRefundTx: new Uint8Array(0),
|
|
7550
|
-
intermediateDirectFromCpfpRefundTx: new Uint8Array(0)
|
|
7719
|
+
intermediateDirectFromCpfpRefundTx: new Uint8Array(0),
|
|
7720
|
+
pendingKeyTweakPublicKey: new Uint8Array(0)
|
|
7551
7721
|
};
|
|
7552
7722
|
}
|
|
7553
7723
|
var TransferLeaf = {
|
|
@@ -7570,6 +7740,9 @@ var TransferLeaf = {
|
|
|
7570
7740
|
if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
|
|
7571
7741
|
writer.uint32(50).bytes(message.intermediateDirectFromCpfpRefundTx);
|
|
7572
7742
|
}
|
|
7743
|
+
if (message.pendingKeyTweakPublicKey.length !== 0) {
|
|
7744
|
+
writer.uint32(58).bytes(message.pendingKeyTweakPublicKey);
|
|
7745
|
+
}
|
|
7573
7746
|
return writer;
|
|
7574
7747
|
},
|
|
7575
7748
|
decode(input, length) {
|
|
@@ -7621,6 +7794,13 @@ var TransferLeaf = {
|
|
|
7621
7794
|
message.intermediateDirectFromCpfpRefundTx = reader.bytes();
|
|
7622
7795
|
continue;
|
|
7623
7796
|
}
|
|
7797
|
+
case 7: {
|
|
7798
|
+
if (tag !== 58) {
|
|
7799
|
+
break;
|
|
7800
|
+
}
|
|
7801
|
+
message.pendingKeyTweakPublicKey = reader.bytes();
|
|
7802
|
+
continue;
|
|
7803
|
+
}
|
|
7624
7804
|
}
|
|
7625
7805
|
if ((tag & 7) === 4 || tag === 0) {
|
|
7626
7806
|
break;
|
|
@@ -7636,7 +7816,8 @@ var TransferLeaf = {
|
|
|
7636
7816
|
signature: isSet3(object.signature) ? bytesFromBase642(object.signature) : new Uint8Array(0),
|
|
7637
7817
|
intermediateRefundTx: isSet3(object.intermediateRefundTx) ? bytesFromBase642(object.intermediateRefundTx) : new Uint8Array(0),
|
|
7638
7818
|
intermediateDirectRefundTx: isSet3(object.intermediateDirectRefundTx) ? bytesFromBase642(object.intermediateDirectRefundTx) : new Uint8Array(0),
|
|
7639
|
-
intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0)
|
|
7819
|
+
intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0),
|
|
7820
|
+
pendingKeyTweakPublicKey: isSet3(object.pendingKeyTweakPublicKey) ? bytesFromBase642(object.pendingKeyTweakPublicKey) : new Uint8Array(0)
|
|
7640
7821
|
};
|
|
7641
7822
|
},
|
|
7642
7823
|
toJSON(message) {
|
|
@@ -7659,6 +7840,9 @@ var TransferLeaf = {
|
|
|
7659
7840
|
if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
|
|
7660
7841
|
obj.intermediateDirectFromCpfpRefundTx = base64FromBytes2(message.intermediateDirectFromCpfpRefundTx);
|
|
7661
7842
|
}
|
|
7843
|
+
if (message.pendingKeyTweakPublicKey.length !== 0) {
|
|
7844
|
+
obj.pendingKeyTweakPublicKey = base64FromBytes2(message.pendingKeyTweakPublicKey);
|
|
7845
|
+
}
|
|
7662
7846
|
return obj;
|
|
7663
7847
|
},
|
|
7664
7848
|
create(base) {
|
|
@@ -7672,6 +7856,7 @@ var TransferLeaf = {
|
|
|
7672
7856
|
message.intermediateRefundTx = object.intermediateRefundTx ?? new Uint8Array(0);
|
|
7673
7857
|
message.intermediateDirectRefundTx = object.intermediateDirectRefundTx ?? new Uint8Array(0);
|
|
7674
7858
|
message.intermediateDirectFromCpfpRefundTx = object.intermediateDirectFromCpfpRefundTx ?? new Uint8Array(0);
|
|
7859
|
+
message.pendingKeyTweakPublicKey = object.pendingKeyTweakPublicKey ?? new Uint8Array(0);
|
|
7675
7860
|
return message;
|
|
7676
7861
|
}
|
|
7677
7862
|
};
|
|
@@ -10569,13 +10754,16 @@ var QueryUserSignedRefundsRequest = {
|
|
|
10569
10754
|
}
|
|
10570
10755
|
};
|
|
10571
10756
|
function createBaseQueryUserSignedRefundsResponse() {
|
|
10572
|
-
return { userSignedRefunds: [] };
|
|
10757
|
+
return { userSignedRefunds: [], transfer: void 0 };
|
|
10573
10758
|
}
|
|
10574
10759
|
var QueryUserSignedRefundsResponse = {
|
|
10575
10760
|
encode(message, writer = new BinaryWriter4()) {
|
|
10576
10761
|
for (const v of message.userSignedRefunds) {
|
|
10577
10762
|
UserSignedRefund.encode(v, writer.uint32(10).fork()).join();
|
|
10578
10763
|
}
|
|
10764
|
+
if (message.transfer !== void 0) {
|
|
10765
|
+
Transfer.encode(message.transfer, writer.uint32(26).fork()).join();
|
|
10766
|
+
}
|
|
10579
10767
|
return writer;
|
|
10580
10768
|
},
|
|
10581
10769
|
decode(input, length) {
|
|
@@ -10592,6 +10780,13 @@ var QueryUserSignedRefundsResponse = {
|
|
|
10592
10780
|
message.userSignedRefunds.push(UserSignedRefund.decode(reader, reader.uint32()));
|
|
10593
10781
|
continue;
|
|
10594
10782
|
}
|
|
10783
|
+
case 3: {
|
|
10784
|
+
if (tag !== 26) {
|
|
10785
|
+
break;
|
|
10786
|
+
}
|
|
10787
|
+
message.transfer = Transfer.decode(reader, reader.uint32());
|
|
10788
|
+
continue;
|
|
10789
|
+
}
|
|
10595
10790
|
}
|
|
10596
10791
|
if ((tag & 7) === 4 || tag === 0) {
|
|
10597
10792
|
break;
|
|
@@ -10602,7 +10797,8 @@ var QueryUserSignedRefundsResponse = {
|
|
|
10602
10797
|
},
|
|
10603
10798
|
fromJSON(object) {
|
|
10604
10799
|
return {
|
|
10605
|
-
userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : []
|
|
10800
|
+
userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : [],
|
|
10801
|
+
transfer: isSet3(object.transfer) ? Transfer.fromJSON(object.transfer) : void 0
|
|
10606
10802
|
};
|
|
10607
10803
|
},
|
|
10608
10804
|
toJSON(message) {
|
|
@@ -10610,6 +10806,9 @@ var QueryUserSignedRefundsResponse = {
|
|
|
10610
10806
|
if (message.userSignedRefunds?.length) {
|
|
10611
10807
|
obj.userSignedRefunds = message.userSignedRefunds.map((e) => UserSignedRefund.toJSON(e));
|
|
10612
10808
|
}
|
|
10809
|
+
if (message.transfer !== void 0) {
|
|
10810
|
+
obj.transfer = Transfer.toJSON(message.transfer);
|
|
10811
|
+
}
|
|
10613
10812
|
return obj;
|
|
10614
10813
|
},
|
|
10615
10814
|
create(base) {
|
|
@@ -10618,6 +10817,7 @@ var QueryUserSignedRefundsResponse = {
|
|
|
10618
10817
|
fromPartial(object) {
|
|
10619
10818
|
const message = createBaseQueryUserSignedRefundsResponse();
|
|
10620
10819
|
message.userSignedRefunds = object.userSignedRefunds?.map((e) => UserSignedRefund.fromPartial(e)) || [];
|
|
10820
|
+
message.transfer = object.transfer !== void 0 && object.transfer !== null ? Transfer.fromPartial(object.transfer) : void 0;
|
|
10621
10821
|
return message;
|
|
10622
10822
|
}
|
|
10623
10823
|
};
|
|
@@ -11504,7 +11704,8 @@ function createBaseDepositAddressQueryResult() {
|
|
|
11504
11704
|
depositAddress: "",
|
|
11505
11705
|
userSigningPublicKey: new Uint8Array(0),
|
|
11506
11706
|
verifyingPublicKey: new Uint8Array(0),
|
|
11507
|
-
leafId: void 0
|
|
11707
|
+
leafId: void 0,
|
|
11708
|
+
proofOfPossession: void 0
|
|
11508
11709
|
};
|
|
11509
11710
|
}
|
|
11510
11711
|
var DepositAddressQueryResult = {
|
|
@@ -11521,6 +11722,9 @@ var DepositAddressQueryResult = {
|
|
|
11521
11722
|
if (message.leafId !== void 0) {
|
|
11522
11723
|
writer.uint32(34).string(message.leafId);
|
|
11523
11724
|
}
|
|
11725
|
+
if (message.proofOfPossession !== void 0) {
|
|
11726
|
+
DepositAddressProof.encode(message.proofOfPossession, writer.uint32(42).fork()).join();
|
|
11727
|
+
}
|
|
11524
11728
|
return writer;
|
|
11525
11729
|
},
|
|
11526
11730
|
decode(input, length) {
|
|
@@ -11558,6 +11762,13 @@ var DepositAddressQueryResult = {
|
|
|
11558
11762
|
message.leafId = reader.string();
|
|
11559
11763
|
continue;
|
|
11560
11764
|
}
|
|
11765
|
+
case 5: {
|
|
11766
|
+
if (tag !== 42) {
|
|
11767
|
+
break;
|
|
11768
|
+
}
|
|
11769
|
+
message.proofOfPossession = DepositAddressProof.decode(reader, reader.uint32());
|
|
11770
|
+
continue;
|
|
11771
|
+
}
|
|
11561
11772
|
}
|
|
11562
11773
|
if ((tag & 7) === 4 || tag === 0) {
|
|
11563
11774
|
break;
|
|
@@ -11571,7 +11782,8 @@ var DepositAddressQueryResult = {
|
|
|
11571
11782
|
depositAddress: isSet3(object.depositAddress) ? globalThis.String(object.depositAddress) : "",
|
|
11572
11783
|
userSigningPublicKey: isSet3(object.userSigningPublicKey) ? bytesFromBase642(object.userSigningPublicKey) : new Uint8Array(0),
|
|
11573
11784
|
verifyingPublicKey: isSet3(object.verifyingPublicKey) ? bytesFromBase642(object.verifyingPublicKey) : new Uint8Array(0),
|
|
11574
|
-
leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0
|
|
11785
|
+
leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0,
|
|
11786
|
+
proofOfPossession: isSet3(object.proofOfPossession) ? DepositAddressProof.fromJSON(object.proofOfPossession) : void 0
|
|
11575
11787
|
};
|
|
11576
11788
|
},
|
|
11577
11789
|
toJSON(message) {
|
|
@@ -11588,6 +11800,9 @@ var DepositAddressQueryResult = {
|
|
|
11588
11800
|
if (message.leafId !== void 0) {
|
|
11589
11801
|
obj.leafId = message.leafId;
|
|
11590
11802
|
}
|
|
11803
|
+
if (message.proofOfPossession !== void 0) {
|
|
11804
|
+
obj.proofOfPossession = DepositAddressProof.toJSON(message.proofOfPossession);
|
|
11805
|
+
}
|
|
11591
11806
|
return obj;
|
|
11592
11807
|
},
|
|
11593
11808
|
create(base) {
|
|
@@ -11599,6 +11814,7 @@ var DepositAddressQueryResult = {
|
|
|
11599
11814
|
message.userSigningPublicKey = object.userSigningPublicKey ?? new Uint8Array(0);
|
|
11600
11815
|
message.verifyingPublicKey = object.verifyingPublicKey ?? new Uint8Array(0);
|
|
11601
11816
|
message.leafId = object.leafId ?? void 0;
|
|
11817
|
+
message.proofOfPossession = object.proofOfPossession !== void 0 && object.proofOfPossession !== null ? DepositAddressProof.fromPartial(object.proofOfPossession) : void 0;
|
|
11602
11818
|
return message;
|
|
11603
11819
|
}
|
|
11604
11820
|
};
|
|
@@ -13563,7 +13779,7 @@ var QueryNodesByValueResponse_NodesEntry = {
|
|
|
13563
13779
|
}
|
|
13564
13780
|
};
|
|
13565
13781
|
function createBaseGetUtxosForAddressRequest() {
|
|
13566
|
-
return { address: "", offset: 0, limit: 0, network: 0 };
|
|
13782
|
+
return { address: "", offset: 0, limit: 0, network: 0, excludeClaimed: false };
|
|
13567
13783
|
}
|
|
13568
13784
|
var GetUtxosForAddressRequest = {
|
|
13569
13785
|
encode(message, writer = new BinaryWriter4()) {
|
|
@@ -13579,6 +13795,9 @@ var GetUtxosForAddressRequest = {
|
|
|
13579
13795
|
if (message.network !== 0) {
|
|
13580
13796
|
writer.uint32(32).int32(message.network);
|
|
13581
13797
|
}
|
|
13798
|
+
if (message.excludeClaimed !== false) {
|
|
13799
|
+
writer.uint32(40).bool(message.excludeClaimed);
|
|
13800
|
+
}
|
|
13582
13801
|
return writer;
|
|
13583
13802
|
},
|
|
13584
13803
|
decode(input, length) {
|
|
@@ -13616,6 +13835,13 @@ var GetUtxosForAddressRequest = {
|
|
|
13616
13835
|
message.network = reader.int32();
|
|
13617
13836
|
continue;
|
|
13618
13837
|
}
|
|
13838
|
+
case 5: {
|
|
13839
|
+
if (tag !== 40) {
|
|
13840
|
+
break;
|
|
13841
|
+
}
|
|
13842
|
+
message.excludeClaimed = reader.bool();
|
|
13843
|
+
continue;
|
|
13844
|
+
}
|
|
13619
13845
|
}
|
|
13620
13846
|
if ((tag & 7) === 4 || tag === 0) {
|
|
13621
13847
|
break;
|
|
@@ -13629,7 +13855,8 @@ var GetUtxosForAddressRequest = {
|
|
|
13629
13855
|
address: isSet3(object.address) ? globalThis.String(object.address) : "",
|
|
13630
13856
|
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
13631
13857
|
limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
|
|
13632
|
-
network: isSet3(object.network) ? networkFromJSON(object.network) : 0
|
|
13858
|
+
network: isSet3(object.network) ? networkFromJSON(object.network) : 0,
|
|
13859
|
+
excludeClaimed: isSet3(object.excludeClaimed) ? globalThis.Boolean(object.excludeClaimed) : false
|
|
13633
13860
|
};
|
|
13634
13861
|
},
|
|
13635
13862
|
toJSON(message) {
|
|
@@ -13646,6 +13873,9 @@ var GetUtxosForAddressRequest = {
|
|
|
13646
13873
|
if (message.network !== 0) {
|
|
13647
13874
|
obj.network = networkToJSON(message.network);
|
|
13648
13875
|
}
|
|
13876
|
+
if (message.excludeClaimed !== false) {
|
|
13877
|
+
obj.excludeClaimed = message.excludeClaimed;
|
|
13878
|
+
}
|
|
13649
13879
|
return obj;
|
|
13650
13880
|
},
|
|
13651
13881
|
create(base) {
|
|
@@ -13657,6 +13887,7 @@ var GetUtxosForAddressRequest = {
|
|
|
13657
13887
|
message.offset = object.offset ?? 0;
|
|
13658
13888
|
message.limit = object.limit ?? 0;
|
|
13659
13889
|
message.network = object.network ?? 0;
|
|
13890
|
+
message.excludeClaimed = object.excludeClaimed ?? false;
|
|
13660
13891
|
return message;
|
|
13661
13892
|
}
|
|
13662
13893
|
};
|
|
@@ -13728,6 +13959,225 @@ var GetUtxosForAddressResponse = {
|
|
|
13728
13959
|
return message;
|
|
13729
13960
|
}
|
|
13730
13961
|
};
|
|
13962
|
+
function createBaseQuerySparkInvoicesRequest() {
|
|
13963
|
+
return { limit: 0, offset: 0, invoice: [] };
|
|
13964
|
+
}
|
|
13965
|
+
var QuerySparkInvoicesRequest = {
|
|
13966
|
+
encode(message, writer = new BinaryWriter4()) {
|
|
13967
|
+
if (message.limit !== 0) {
|
|
13968
|
+
writer.uint32(8).int64(message.limit);
|
|
13969
|
+
}
|
|
13970
|
+
if (message.offset !== 0) {
|
|
13971
|
+
writer.uint32(16).int64(message.offset);
|
|
13972
|
+
}
|
|
13973
|
+
for (const v of message.invoice) {
|
|
13974
|
+
writer.uint32(26).string(v);
|
|
13975
|
+
}
|
|
13976
|
+
return writer;
|
|
13977
|
+
},
|
|
13978
|
+
decode(input, length) {
|
|
13979
|
+
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
13980
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
13981
|
+
const message = createBaseQuerySparkInvoicesRequest();
|
|
13982
|
+
while (reader.pos < end) {
|
|
13983
|
+
const tag = reader.uint32();
|
|
13984
|
+
switch (tag >>> 3) {
|
|
13985
|
+
case 1: {
|
|
13986
|
+
if (tag !== 8) {
|
|
13987
|
+
break;
|
|
13988
|
+
}
|
|
13989
|
+
message.limit = longToNumber2(reader.int64());
|
|
13990
|
+
continue;
|
|
13991
|
+
}
|
|
13992
|
+
case 2: {
|
|
13993
|
+
if (tag !== 16) {
|
|
13994
|
+
break;
|
|
13995
|
+
}
|
|
13996
|
+
message.offset = longToNumber2(reader.int64());
|
|
13997
|
+
continue;
|
|
13998
|
+
}
|
|
13999
|
+
case 3: {
|
|
14000
|
+
if (tag !== 26) {
|
|
14001
|
+
break;
|
|
14002
|
+
}
|
|
14003
|
+
message.invoice.push(reader.string());
|
|
14004
|
+
continue;
|
|
14005
|
+
}
|
|
14006
|
+
}
|
|
14007
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
14008
|
+
break;
|
|
14009
|
+
}
|
|
14010
|
+
reader.skip(tag & 7);
|
|
14011
|
+
}
|
|
14012
|
+
return message;
|
|
14013
|
+
},
|
|
14014
|
+
fromJSON(object) {
|
|
14015
|
+
return {
|
|
14016
|
+
limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
|
|
14017
|
+
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
14018
|
+
invoice: globalThis.Array.isArray(object?.invoice) ? object.invoice.map((e) => globalThis.String(e)) : []
|
|
14019
|
+
};
|
|
14020
|
+
},
|
|
14021
|
+
toJSON(message) {
|
|
14022
|
+
const obj = {};
|
|
14023
|
+
if (message.limit !== 0) {
|
|
14024
|
+
obj.limit = Math.round(message.limit);
|
|
14025
|
+
}
|
|
14026
|
+
if (message.offset !== 0) {
|
|
14027
|
+
obj.offset = Math.round(message.offset);
|
|
14028
|
+
}
|
|
14029
|
+
if (message.invoice?.length) {
|
|
14030
|
+
obj.invoice = message.invoice;
|
|
14031
|
+
}
|
|
14032
|
+
return obj;
|
|
14033
|
+
},
|
|
14034
|
+
create(base) {
|
|
14035
|
+
return QuerySparkInvoicesRequest.fromPartial(base ?? {});
|
|
14036
|
+
},
|
|
14037
|
+
fromPartial(object) {
|
|
14038
|
+
const message = createBaseQuerySparkInvoicesRequest();
|
|
14039
|
+
message.limit = object.limit ?? 0;
|
|
14040
|
+
message.offset = object.offset ?? 0;
|
|
14041
|
+
message.invoice = object.invoice?.map((e) => e) || [];
|
|
14042
|
+
return message;
|
|
14043
|
+
}
|
|
14044
|
+
};
|
|
14045
|
+
function createBaseQuerySparkInvoicesResponse() {
|
|
14046
|
+
return { offset: 0, invoiceStatuses: [] };
|
|
14047
|
+
}
|
|
14048
|
+
var QuerySparkInvoicesResponse = {
|
|
14049
|
+
encode(message, writer = new BinaryWriter4()) {
|
|
14050
|
+
if (message.offset !== 0) {
|
|
14051
|
+
writer.uint32(8).int64(message.offset);
|
|
14052
|
+
}
|
|
14053
|
+
for (const v of message.invoiceStatuses) {
|
|
14054
|
+
InvoiceResponse.encode(v, writer.uint32(18).fork()).join();
|
|
14055
|
+
}
|
|
14056
|
+
return writer;
|
|
14057
|
+
},
|
|
14058
|
+
decode(input, length) {
|
|
14059
|
+
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
14060
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
14061
|
+
const message = createBaseQuerySparkInvoicesResponse();
|
|
14062
|
+
while (reader.pos < end) {
|
|
14063
|
+
const tag = reader.uint32();
|
|
14064
|
+
switch (tag >>> 3) {
|
|
14065
|
+
case 1: {
|
|
14066
|
+
if (tag !== 8) {
|
|
14067
|
+
break;
|
|
14068
|
+
}
|
|
14069
|
+
message.offset = longToNumber2(reader.int64());
|
|
14070
|
+
continue;
|
|
14071
|
+
}
|
|
14072
|
+
case 2: {
|
|
14073
|
+
if (tag !== 18) {
|
|
14074
|
+
break;
|
|
14075
|
+
}
|
|
14076
|
+
message.invoiceStatuses.push(InvoiceResponse.decode(reader, reader.uint32()));
|
|
14077
|
+
continue;
|
|
14078
|
+
}
|
|
14079
|
+
}
|
|
14080
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
14081
|
+
break;
|
|
14082
|
+
}
|
|
14083
|
+
reader.skip(tag & 7);
|
|
14084
|
+
}
|
|
14085
|
+
return message;
|
|
14086
|
+
},
|
|
14087
|
+
fromJSON(object) {
|
|
14088
|
+
return {
|
|
14089
|
+
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
14090
|
+
invoiceStatuses: globalThis.Array.isArray(object?.invoiceStatuses) ? object.invoiceStatuses.map((e) => InvoiceResponse.fromJSON(e)) : []
|
|
14091
|
+
};
|
|
14092
|
+
},
|
|
14093
|
+
toJSON(message) {
|
|
14094
|
+
const obj = {};
|
|
14095
|
+
if (message.offset !== 0) {
|
|
14096
|
+
obj.offset = Math.round(message.offset);
|
|
14097
|
+
}
|
|
14098
|
+
if (message.invoiceStatuses?.length) {
|
|
14099
|
+
obj.invoiceStatuses = message.invoiceStatuses.map((e) => InvoiceResponse.toJSON(e));
|
|
14100
|
+
}
|
|
14101
|
+
return obj;
|
|
14102
|
+
},
|
|
14103
|
+
create(base) {
|
|
14104
|
+
return QuerySparkInvoicesResponse.fromPartial(base ?? {});
|
|
14105
|
+
},
|
|
14106
|
+
fromPartial(object) {
|
|
14107
|
+
const message = createBaseQuerySparkInvoicesResponse();
|
|
14108
|
+
message.offset = object.offset ?? 0;
|
|
14109
|
+
message.invoiceStatuses = object.invoiceStatuses?.map((e) => InvoiceResponse.fromPartial(e)) || [];
|
|
14110
|
+
return message;
|
|
14111
|
+
}
|
|
14112
|
+
};
|
|
14113
|
+
function createBaseInvoiceResponse() {
|
|
14114
|
+
return { invoice: "", status: 0 };
|
|
14115
|
+
}
|
|
14116
|
+
var InvoiceResponse = {
|
|
14117
|
+
encode(message, writer = new BinaryWriter4()) {
|
|
14118
|
+
if (message.invoice !== "") {
|
|
14119
|
+
writer.uint32(10).string(message.invoice);
|
|
14120
|
+
}
|
|
14121
|
+
if (message.status !== 0) {
|
|
14122
|
+
writer.uint32(16).int32(message.status);
|
|
14123
|
+
}
|
|
14124
|
+
return writer;
|
|
14125
|
+
},
|
|
14126
|
+
decode(input, length) {
|
|
14127
|
+
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
14128
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
14129
|
+
const message = createBaseInvoiceResponse();
|
|
14130
|
+
while (reader.pos < end) {
|
|
14131
|
+
const tag = reader.uint32();
|
|
14132
|
+
switch (tag >>> 3) {
|
|
14133
|
+
case 1: {
|
|
14134
|
+
if (tag !== 10) {
|
|
14135
|
+
break;
|
|
14136
|
+
}
|
|
14137
|
+
message.invoice = reader.string();
|
|
14138
|
+
continue;
|
|
14139
|
+
}
|
|
14140
|
+
case 2: {
|
|
14141
|
+
if (tag !== 16) {
|
|
14142
|
+
break;
|
|
14143
|
+
}
|
|
14144
|
+
message.status = reader.int32();
|
|
14145
|
+
continue;
|
|
14146
|
+
}
|
|
14147
|
+
}
|
|
14148
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
14149
|
+
break;
|
|
14150
|
+
}
|
|
14151
|
+
reader.skip(tag & 7);
|
|
14152
|
+
}
|
|
14153
|
+
return message;
|
|
14154
|
+
},
|
|
14155
|
+
fromJSON(object) {
|
|
14156
|
+
return {
|
|
14157
|
+
invoice: isSet3(object.invoice) ? globalThis.String(object.invoice) : "",
|
|
14158
|
+
status: isSet3(object.status) ? invoiceStatusFromJSON(object.status) : 0
|
|
14159
|
+
};
|
|
14160
|
+
},
|
|
14161
|
+
toJSON(message) {
|
|
14162
|
+
const obj = {};
|
|
14163
|
+
if (message.invoice !== "") {
|
|
14164
|
+
obj.invoice = message.invoice;
|
|
14165
|
+
}
|
|
14166
|
+
if (message.status !== 0) {
|
|
14167
|
+
obj.status = invoiceStatusToJSON(message.status);
|
|
14168
|
+
}
|
|
14169
|
+
return obj;
|
|
14170
|
+
},
|
|
14171
|
+
create(base) {
|
|
14172
|
+
return InvoiceResponse.fromPartial(base ?? {});
|
|
14173
|
+
},
|
|
14174
|
+
fromPartial(object) {
|
|
14175
|
+
const message = createBaseInvoiceResponse();
|
|
14176
|
+
message.invoice = object.invoice ?? "";
|
|
14177
|
+
message.status = object.status ?? 0;
|
|
14178
|
+
return message;
|
|
14179
|
+
}
|
|
14180
|
+
};
|
|
13731
14181
|
var SparkServiceDefinition = {
|
|
13732
14182
|
name: "SparkService",
|
|
13733
14183
|
fullName: "spark.SparkService",
|
|
@@ -13740,6 +14190,15 @@ var SparkServiceDefinition = {
|
|
|
13740
14190
|
responseStream: false,
|
|
13741
14191
|
options: {}
|
|
13742
14192
|
},
|
|
14193
|
+
/** Generates a new static deposit address of the user or returns the existing one for the specified network. */
|
|
14194
|
+
generate_static_deposit_address: {
|
|
14195
|
+
name: "generate_static_deposit_address",
|
|
14196
|
+
requestType: GenerateStaticDepositAddressRequest,
|
|
14197
|
+
requestStream: false,
|
|
14198
|
+
responseType: GenerateStaticDepositAddressResponse,
|
|
14199
|
+
responseStream: false,
|
|
14200
|
+
options: {}
|
|
14201
|
+
},
|
|
13743
14202
|
start_deposit_tree_creation: {
|
|
13744
14203
|
name: "start_deposit_tree_creation",
|
|
13745
14204
|
requestType: StartDepositTreeCreationRequest,
|
|
@@ -14181,6 +14640,14 @@ var SparkServiceDefinition = {
|
|
|
14181
14640
|
responseType: GetUtxosForAddressResponse,
|
|
14182
14641
|
responseStream: false,
|
|
14183
14642
|
options: {}
|
|
14643
|
+
},
|
|
14644
|
+
query_spark_invoices: {
|
|
14645
|
+
name: "query_spark_invoices",
|
|
14646
|
+
requestType: QuerySparkInvoicesRequest,
|
|
14647
|
+
requestStream: false,
|
|
14648
|
+
responseType: QuerySparkInvoicesResponse,
|
|
14649
|
+
responseStream: false,
|
|
14650
|
+
options: {}
|
|
14184
14651
|
}
|
|
14185
14652
|
}
|
|
14186
14653
|
};
|
|
@@ -14768,8 +15235,8 @@ function encodeSparkInvoiceFieldsV1Canonical(f) {
|
|
|
14768
15235
|
|
|
14769
15236
|
// src/utils/adaptor-signature.ts
|
|
14770
15237
|
import { mod } from "@noble/curves/abstract/modular";
|
|
14771
|
-
import { bytesToNumberBE as bytesToNumberBE2, numberToBytesBE } from "@noble/curves/abstract/utils";
|
|
14772
15238
|
import { schnorr as schnorr2, secp256k1 as secp256k12 } from "@noble/curves/secp256k1";
|
|
15239
|
+
import { bytesToNumberBE as bytesToNumberBE2, numberToBytesBE } from "@noble/curves/utils";
|
|
14773
15240
|
function generateSignatureFromExistingAdaptor(signature, adaptorPrivateKeyBytes) {
|
|
14774
15241
|
const { r, s } = parseSignature(signature);
|
|
14775
15242
|
const sBigInt = bytesToNumberBE2(s);
|
|
@@ -14897,12 +15364,8 @@ function parseSignature(signature) {
|
|
|
14897
15364
|
}
|
|
14898
15365
|
|
|
14899
15366
|
// src/utils/bitcoin.ts
|
|
14900
|
-
import {
|
|
14901
|
-
bytesToHex as bytesToHex3,
|
|
14902
|
-
bytesToNumberBE as bytesToNumberBE3,
|
|
14903
|
-
hexToBytes as hexToBytes2
|
|
14904
|
-
} from "@noble/curves/abstract/utils";
|
|
14905
15367
|
import { schnorr as schnorr3, secp256k1 as secp256k13 } from "@noble/curves/secp256k1";
|
|
15368
|
+
import { bytesToHex as bytesToHex3, bytesToNumberBE as bytesToNumberBE3, hexToBytes as hexToBytes2 } from "@noble/curves/utils";
|
|
14906
15369
|
import { sha256 as sha2562 } from "@noble/hashes/sha2";
|
|
14907
15370
|
import * as btc2 from "@scure/btc-signer";
|
|
14908
15371
|
|
|
@@ -15144,8 +15607,8 @@ function getTxEstimatedVbytesSizeByNumberOfInputsOutputs(numInputs, numOutputs)
|
|
|
15144
15607
|
}
|
|
15145
15608
|
|
|
15146
15609
|
// src/utils/keys.ts
|
|
15147
|
-
import { numberToBytesBE as numberToBytesBE2 } from "@noble/curves/abstract/utils";
|
|
15148
15610
|
import { secp256k1 as secp256k14 } from "@noble/curves/secp256k1";
|
|
15611
|
+
import { numberToBytesBE as numberToBytesBE2 } from "@noble/curves/utils";
|
|
15149
15612
|
function addPublicKeys(a, b) {
|
|
15150
15613
|
if (a.length !== 33 || b.length !== 33) {
|
|
15151
15614
|
throw new ValidationError("Public keys must be 33 bytes", {
|
|
@@ -16350,7 +16813,7 @@ fragment UserRequestFragment on UserRequest {
|
|
|
16350
16813
|
}`;
|
|
16351
16814
|
|
|
16352
16815
|
// src/types/sdk-types.ts
|
|
16353
|
-
import { bytesToHex as bytesToHex4 } from "@noble/curves/
|
|
16816
|
+
import { bytesToHex as bytesToHex4 } from "@noble/curves/utils";
|
|
16354
16817
|
function mapTreeNodeToWalletLeaf(proto) {
|
|
16355
16818
|
return {
|
|
16356
16819
|
id: proto.id,
|
|
@@ -16497,8 +16960,8 @@ function collectResponses(responses) {
|
|
|
16497
16960
|
}
|
|
16498
16961
|
|
|
16499
16962
|
// src/utils/secret-sharing.ts
|
|
16500
|
-
import { bytesToHex as bytesToHex5, equalBytes } from "@noble/curves/abstract/utils";
|
|
16501
16963
|
import { secp256k1 as secp256k15 } from "@noble/curves/secp256k1";
|
|
16964
|
+
import { bytesToHex as bytesToHex5, equalBytes } from "@noble/curves/utils";
|
|
16502
16965
|
function getRandomBigInt(max) {
|
|
16503
16966
|
const byteLength = max.toString(2).length + 7 >> 3;
|
|
16504
16967
|
const maxBigInt = max;
|
|
@@ -16880,8 +17343,7 @@ function getNetworkFromBech32mTokenIdentifier(bech32mTokenIdentifier) {
|
|
|
16880
17343
|
}
|
|
16881
17344
|
|
|
16882
17345
|
// src/utils/token-transactions.ts
|
|
16883
|
-
import { bytesToNumberBE as bytesToNumberBE4 } from "@noble/curves/
|
|
16884
|
-
import { equalBytes as equalBytes2 } from "@scure/btc-signer/utils";
|
|
17346
|
+
import { bytesToNumberBE as bytesToNumberBE4, equalBytes as equalBytes2 } from "@noble/curves/utils";
|
|
16885
17347
|
function sumAvailableTokens(outputs) {
|
|
16886
17348
|
try {
|
|
16887
17349
|
return outputs.reduce(
|
|
@@ -16929,7 +17391,7 @@ function filterTokenBalanceForTokenIdentifier(tokenBalances, tokenIdentifier) {
|
|
|
16929
17391
|
}
|
|
16930
17392
|
|
|
16931
17393
|
// src/utils/transfer_package.ts
|
|
16932
|
-
import { hexToBytes as hexToBytes3 } from "@noble/curves/
|
|
17394
|
+
import { hexToBytes as hexToBytes3 } from "@noble/curves/utils";
|
|
16933
17395
|
import { sha256 as sha2564 } from "@noble/hashes/sha2";
|
|
16934
17396
|
function getTransferPackageSigningPayload(transferID, transferPackage) {
|
|
16935
17397
|
const encryptedPayload = transferPackage.keyTweakPackage;
|
|
@@ -17289,7 +17751,7 @@ function getEphemeralAnchorOutput() {
|
|
|
17289
17751
|
}
|
|
17290
17752
|
|
|
17291
17753
|
// src/utils/unilateral-exit.ts
|
|
17292
|
-
import { bytesToHex as
|
|
17754
|
+
import { bytesToHex as bytesToHex6, hexToBytes as hexToBytes4 } from "@noble/curves/utils";
|
|
17293
17755
|
import { ripemd160 } from "@noble/hashes/legacy";
|
|
17294
17756
|
import { sha256 as sha2565 } from "@noble/hashes/sha2";
|
|
17295
17757
|
import * as btc3 from "@scure/btc-signer";
|
|
@@ -17360,10 +17822,10 @@ async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network)
|
|
|
17360
17822
|
}
|
|
17361
17823
|
}
|
|
17362
17824
|
for (const chainNode of chain) {
|
|
17363
|
-
const nodeTx =
|
|
17825
|
+
const nodeTx = bytesToHex6(chainNode.nodeTx);
|
|
17364
17826
|
transactions.push(nodeTx);
|
|
17365
17827
|
if (chainNode.id === node.id) {
|
|
17366
|
-
const refundTx =
|
|
17828
|
+
const refundTx = bytesToHex6(chainNode.refundTx);
|
|
17367
17829
|
transactions.push(refundTx);
|
|
17368
17830
|
}
|
|
17369
17831
|
}
|
|
@@ -17469,7 +17931,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
17469
17931
|
}
|
|
17470
17932
|
}
|
|
17471
17933
|
for (const chainNode of chain) {
|
|
17472
|
-
let nodeTxHex =
|
|
17934
|
+
let nodeTxHex = bytesToHex6(chainNode.nodeTx);
|
|
17473
17935
|
try {
|
|
17474
17936
|
const txObj = getTxFromRawTxHex(nodeTxHex);
|
|
17475
17937
|
const txid = getTxId(txObj);
|
|
@@ -17486,7 +17948,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
17486
17948
|
for (let i = txObj.outputsLength - 1; i >= 0; i--) {
|
|
17487
17949
|
const output = txObj.getOutput(i);
|
|
17488
17950
|
if (output?.amount === 0n && output.script) {
|
|
17489
|
-
anchorOutputScriptHex =
|
|
17951
|
+
anchorOutputScriptHex = bytesToHex6(output.script);
|
|
17490
17952
|
break;
|
|
17491
17953
|
}
|
|
17492
17954
|
}
|
|
@@ -17511,7 +17973,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
17511
17973
|
var feeBumpOut = feeBumpTx.outputsLength === 1 ? feeBumpTx.getOutput(0) : null;
|
|
17512
17974
|
var feeBumpOutPubKey = null;
|
|
17513
17975
|
for (const usedUtxo of usedUtxos) {
|
|
17514
|
-
if (feeBumpOut &&
|
|
17976
|
+
if (feeBumpOut && bytesToHex6(feeBumpOut.script) == usedUtxo.script) {
|
|
17515
17977
|
feeBumpOutPubKey = usedUtxo.publicKey;
|
|
17516
17978
|
}
|
|
17517
17979
|
const index = availableUtxos.findIndex(
|
|
@@ -17526,20 +17988,20 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
17526
17988
|
txid: getTxId(feeBumpTx),
|
|
17527
17989
|
vout: 0,
|
|
17528
17990
|
value: feeBumpOut.amount,
|
|
17529
|
-
script:
|
|
17991
|
+
script: bytesToHex6(feeBumpOut.script),
|
|
17530
17992
|
publicKey: feeBumpOutPubKey
|
|
17531
17993
|
});
|
|
17532
17994
|
const finalNodeTx = correctedParentTx || nodeTxHex;
|
|
17533
17995
|
txPackages.push({ tx: finalNodeTx, feeBumpPsbt: nodeFeeBumpPsbt });
|
|
17534
17996
|
if (chainNode.id === node.id) {
|
|
17535
|
-
let refundTxHex =
|
|
17997
|
+
let refundTxHex = bytesToHex6(chainNode.refundTx);
|
|
17536
17998
|
try {
|
|
17537
17999
|
const txObj = getTxFromRawTxHex(refundTxHex);
|
|
17538
18000
|
let anchorOutputScriptHex;
|
|
17539
18001
|
for (let i = txObj.outputsLength - 1; i >= 0; i--) {
|
|
17540
18002
|
const output = txObj.getOutput(i);
|
|
17541
18003
|
if (output?.amount === 0n && output.script) {
|
|
17542
|
-
anchorOutputScriptHex =
|
|
18004
|
+
anchorOutputScriptHex = bytesToHex6(output.script);
|
|
17543
18005
|
break;
|
|
17544
18006
|
}
|
|
17545
18007
|
}
|
|
@@ -17567,7 +18029,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
17567
18029
|
var feeBumpOut = feeBumpTx2.outputsLength === 1 ? feeBumpTx2.getOutput(0) : null;
|
|
17568
18030
|
var feeBumpOutPubKey = null;
|
|
17569
18031
|
for (const usedUtxo of usedUtxos) {
|
|
17570
|
-
if (feeBumpOut &&
|
|
18032
|
+
if (feeBumpOut && bytesToHex6(feeBumpOut.script) == usedUtxo.script) {
|
|
17571
18033
|
feeBumpOutPubKey = usedUtxo.publicKey;
|
|
17572
18034
|
}
|
|
17573
18035
|
const index = availableUtxos.findIndex(
|
|
@@ -17582,7 +18044,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
17582
18044
|
txid: getTxId(feeBumpTx2),
|
|
17583
18045
|
vout: 0,
|
|
17584
18046
|
value: feeBumpOut.amount,
|
|
17585
|
-
script:
|
|
18047
|
+
script: bytesToHex6(feeBumpOut.script),
|
|
17586
18048
|
publicKey: feeBumpOutPubKey
|
|
17587
18049
|
});
|
|
17588
18050
|
txPackages.push({
|
|
@@ -17680,7 +18142,7 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
|
|
|
17680
18142
|
const pubKeyHash = hash160(hexToBytes4(fundingUtxo.publicKey));
|
|
17681
18143
|
const scriptToUse = new Uint8Array([0, 20, ...pubKeyHash]);
|
|
17682
18144
|
const providedScript = hexToBytes4(fundingUtxo.script);
|
|
17683
|
-
if (
|
|
18145
|
+
if (bytesToHex6(scriptToUse) !== bytesToHex6(providedScript)) {
|
|
17684
18146
|
throw new Error(
|
|
17685
18147
|
`\u274C Derived script doesn't match provided script for UTXO ${i + 1}.`
|
|
17686
18148
|
);
|
|
@@ -17745,7 +18207,7 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
|
|
|
17745
18207
|
}
|
|
17746
18208
|
let psbtHex;
|
|
17747
18209
|
try {
|
|
17748
|
-
psbtHex =
|
|
18210
|
+
psbtHex = bytesToHex6(builder.toPSBT());
|
|
17749
18211
|
} catch (error) {
|
|
17750
18212
|
throw new Error(`Failed to extract transaction: ${error}`);
|
|
17751
18213
|
}
|
|
@@ -17913,13 +18375,13 @@ var NativeSparkFrost = class {
|
|
|
17913
18375
|
|
|
17914
18376
|
// src/signer/signer.ts
|
|
17915
18377
|
import { privateNegate } from "@bitcoinerlab/secp256k1";
|
|
18378
|
+
import { schnorr as schnorr4, secp256k1 as secp256k17 } from "@noble/curves/secp256k1";
|
|
17916
18379
|
import {
|
|
17917
|
-
bytesToHex as
|
|
18380
|
+
bytesToHex as bytesToHex7,
|
|
17918
18381
|
bytesToNumberBE as bytesToNumberBE5,
|
|
17919
18382
|
equalBytes as equalBytes3,
|
|
17920
18383
|
hexToBytes as hexToBytes5
|
|
17921
|
-
} from "@noble/curves/
|
|
17922
|
-
import { schnorr as schnorr4, secp256k1 as secp256k17 } from "@noble/curves/secp256k1";
|
|
18384
|
+
} from "@noble/curves/utils";
|
|
17923
18385
|
import { sha256 as sha2566 } from "@noble/hashes/sha2";
|
|
17924
18386
|
import { HDKey } from "@scure/bip32";
|
|
17925
18387
|
import { generateMnemonic, mnemonicToSeed } from "@scure/bip39";
|
|
@@ -17931,7 +18393,7 @@ import * as ecies from "eciesjs";
|
|
|
17931
18393
|
import { isNode, isBare } from "@lightsparkdev/core";
|
|
17932
18394
|
var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
17933
18395
|
var isBun = globalThis.Bun !== void 0;
|
|
17934
|
-
var packageVersion = true ? "0.2.
|
|
18396
|
+
var packageVersion = true ? "0.2.13" : "unknown";
|
|
17935
18397
|
var baseEnvStr = "unknown";
|
|
17936
18398
|
if (isBun) {
|
|
17937
18399
|
const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
|
|
@@ -18039,7 +18501,7 @@ var DefaultSparkSigner = class {
|
|
|
18039
18501
|
});
|
|
18040
18502
|
}
|
|
18041
18503
|
const receiverEciesPrivKey = ecies.PrivateKey.fromHex(
|
|
18042
|
-
|
|
18504
|
+
bytesToHex7(this.identityKey.privateKey)
|
|
18043
18505
|
);
|
|
18044
18506
|
const privateKey = ecies.decrypt(receiverEciesPrivKey.toHex(), ciphertext);
|
|
18045
18507
|
return privateKey;
|
|
@@ -18209,7 +18671,7 @@ var DefaultSparkSigner = class {
|
|
|
18209
18671
|
publicKey,
|
|
18210
18672
|
verifyingKey
|
|
18211
18673
|
};
|
|
18212
|
-
const logMessage =
|
|
18674
|
+
const logMessage = bytesToHex7(message);
|
|
18213
18675
|
const result = await SparkFrost.signFrost({
|
|
18214
18676
|
message,
|
|
18215
18677
|
keyPackage,
|
|
@@ -18263,7 +18725,7 @@ var DefaultSparkSigner = class {
|
|
|
18263
18725
|
this.depositKey = depositKey;
|
|
18264
18726
|
this.signingKey = signingKey.hdKey;
|
|
18265
18727
|
this.staticDepositKey = staticDepositKey.hdKey;
|
|
18266
|
-
return
|
|
18728
|
+
return bytesToHex7(identityKey.publicKey);
|
|
18267
18729
|
}
|
|
18268
18730
|
async signMessageWithIdentityKey(message, compact) {
|
|
18269
18731
|
if (!this.identityKey?.privateKey) {
|
|
@@ -18284,7 +18746,7 @@ var DefaultSparkSigner = class {
|
|
|
18284
18746
|
});
|
|
18285
18747
|
}
|
|
18286
18748
|
const receiverEciesPrivKey = ecies.PrivateKey.fromHex(
|
|
18287
|
-
|
|
18749
|
+
bytesToHex7(this.identityKey.privateKey)
|
|
18288
18750
|
);
|
|
18289
18751
|
const privateKey = ecies.decrypt(receiverEciesPrivKey.toHex(), ciphertext);
|
|
18290
18752
|
const publicKey = secp256k17.getPublicKey(privateKey);
|
|
@@ -18316,7 +18778,7 @@ var DefaultSparkSigner = class {
|
|
|
18316
18778
|
if (!privateKey) {
|
|
18317
18779
|
throw new ValidationError("Private key not found for public key", {
|
|
18318
18780
|
field: "privateKey",
|
|
18319
|
-
value:
|
|
18781
|
+
value: bytesToHex7(publicKey)
|
|
18320
18782
|
});
|
|
18321
18783
|
}
|
|
18322
18784
|
tx.signIdx(privateKey, index);
|
|
@@ -18388,14 +18850,14 @@ var ReactNativeSparkSigner = class extends DefaultSparkSigner {
|
|
|
18388
18850
|
|
|
18389
18851
|
// src/spark-wallet/spark-wallet.ts
|
|
18390
18852
|
import { isNode as isNode3, isObject as isObject10, mapCurrencyAmount } from "@lightsparkdev/core";
|
|
18853
|
+
import { secp256k1 as secp256k114 } from "@noble/curves/secp256k1";
|
|
18391
18854
|
import {
|
|
18392
|
-
bytesToHex as
|
|
18855
|
+
bytesToHex as bytesToHex12,
|
|
18393
18856
|
bytesToNumberBE as bytesToNumberBE8,
|
|
18394
18857
|
equalBytes as equalBytes6,
|
|
18395
18858
|
hexToBytes as hexToBytes12,
|
|
18396
18859
|
numberToVarBytesBE
|
|
18397
|
-
} from "@noble/curves/
|
|
18398
|
-
import { secp256k1 as secp256k114 } from "@noble/curves/secp256k1";
|
|
18860
|
+
} from "@noble/curves/utils";
|
|
18399
18861
|
import { validateMnemonic } from "@scure/bip39";
|
|
18400
18862
|
import { wordlist as wordlist2 } from "@scure/bip39/wordlists/english";
|
|
18401
18863
|
import { Address as Address5, OutScript as OutScript3, Transaction as Transaction8 } from "@scure/btc-signer";
|
|
@@ -18404,7 +18866,7 @@ import { uuidv7 as uuidv74, uuidv7obj } from "uuidv7";
|
|
|
18404
18866
|
|
|
18405
18867
|
// src/graphql/client.ts
|
|
18406
18868
|
import {
|
|
18407
|
-
bytesToHex as
|
|
18869
|
+
bytesToHex as bytesToHex8,
|
|
18408
18870
|
DefaultCrypto,
|
|
18409
18871
|
NodeKeyCache,
|
|
18410
18872
|
Requester,
|
|
@@ -19390,7 +19852,7 @@ var SspClient = class {
|
|
|
19390
19852
|
{
|
|
19391
19853
|
queryPayload: GetChallenge,
|
|
19392
19854
|
variables: {
|
|
19393
|
-
public_key:
|
|
19855
|
+
public_key: bytesToHex8(await this.signer.getIdentityPublicKey())
|
|
19394
19856
|
},
|
|
19395
19857
|
constructObject: (response) => {
|
|
19396
19858
|
return GetChallengeOutputFromJson(response.get_challenge);
|
|
@@ -19406,7 +19868,7 @@ var SspClient = class {
|
|
|
19406
19868
|
variables: {
|
|
19407
19869
|
protected_challenge: protectedChallenge,
|
|
19408
19870
|
signature,
|
|
19409
|
-
identity_public_key:
|
|
19871
|
+
identity_public_key: bytesToHex8(
|
|
19410
19872
|
await this.signer.getIdentityPublicKey()
|
|
19411
19873
|
)
|
|
19412
19874
|
},
|
|
@@ -23726,13 +24188,13 @@ import { Transaction as Transaction5 } from "@scure/btc-signer";
|
|
|
23726
24188
|
import { uuidv7 as uuidv72 } from "uuidv7";
|
|
23727
24189
|
|
|
23728
24190
|
// src/services/transfer.ts
|
|
24191
|
+
import { secp256k1 as secp256k18 } from "@noble/curves/secp256k1";
|
|
23729
24192
|
import {
|
|
23730
|
-
bytesToHex as
|
|
24193
|
+
bytesToHex as bytesToHex9,
|
|
23731
24194
|
equalBytes as equalBytes4,
|
|
23732
24195
|
hexToBytes as hexToBytes6,
|
|
23733
24196
|
numberToBytesBE as numberToBytesBE3
|
|
23734
|
-
} from "@noble/curves/
|
|
23735
|
-
import { secp256k1 as secp256k18 } from "@noble/curves/secp256k1";
|
|
24197
|
+
} from "@noble/curves/utils";
|
|
23736
24198
|
import { sha256 as sha2569 } from "@noble/hashes/sha2";
|
|
23737
24199
|
import { Transaction as Transaction4 } from "@scure/btc-signer";
|
|
23738
24200
|
import * as ecies2 from "eciesjs";
|
|
@@ -24102,7 +24564,7 @@ var BaseTransferService = class {
|
|
|
24102
24564
|
}
|
|
24103
24565
|
async prepareSendTransferKeyTweaks(transferID, receiverIdentityPubkey, leaves, cpfpRefundSignatureMap, directRefundSignatureMap, directFromCpfpRefundSignatureMap) {
|
|
24104
24566
|
const receiverEciesPubKey = ecies2.PublicKey.fromHex(
|
|
24105
|
-
|
|
24567
|
+
bytesToHex9(receiverIdentityPubkey)
|
|
24106
24568
|
);
|
|
24107
24569
|
const leavesTweaksMap = /* @__PURE__ */ new Map();
|
|
24108
24570
|
for (const leaf of leaves) {
|
|
@@ -24724,24 +25186,6 @@ var TransferService = class extends BaseTransferService {
|
|
|
24724
25186
|
throw new Error(`Error finalizing node signatures in transfer: ${error}`);
|
|
24725
25187
|
}
|
|
24726
25188
|
}
|
|
24727
|
-
async cancelTransfer(transfer, operatorAddress) {
|
|
24728
|
-
const sparkClient = await this.connectionManager.createSparkClient(operatorAddress);
|
|
24729
|
-
try {
|
|
24730
|
-
const response = await sparkClient.cancel_transfer({
|
|
24731
|
-
transferId: transfer.id,
|
|
24732
|
-
senderIdentityPublicKey: await this.config.signer.getIdentityPublicKey()
|
|
24733
|
-
});
|
|
24734
|
-
return response.transfer;
|
|
24735
|
-
} catch (error) {
|
|
24736
|
-
throw new NetworkError(
|
|
24737
|
-
"Failed to cancel transfer",
|
|
24738
|
-
{
|
|
24739
|
-
method: "POST"
|
|
24740
|
-
},
|
|
24741
|
-
error
|
|
24742
|
-
);
|
|
24743
|
-
}
|
|
24744
|
-
}
|
|
24745
25189
|
async queryPendingTransfersBySender(operatorAddress) {
|
|
24746
25190
|
const sparkClient = await this.connectionManager.createSparkClient(operatorAddress);
|
|
24747
25191
|
try {
|
|
@@ -25635,7 +26079,8 @@ var DepositService = class {
|
|
|
25635
26079
|
}
|
|
25636
26080
|
async validateDepositAddress({
|
|
25637
26081
|
address: address2,
|
|
25638
|
-
userPubkey
|
|
26082
|
+
userPubkey,
|
|
26083
|
+
verifyCoordinatorProof = false
|
|
25639
26084
|
}) {
|
|
25640
26085
|
if (!address2.depositAddressProof || !address2.depositAddressProof.proofOfPossessionSignature || !address2.depositAddressProof.addressSignatures) {
|
|
25641
26086
|
throw new ValidationError(
|
|
@@ -25673,7 +26118,7 @@ var DepositService = class {
|
|
|
25673
26118
|
}
|
|
25674
26119
|
const addrHash = sha25610(address2.address);
|
|
25675
26120
|
for (const operator of Object.values(this.config.getSigningOperators())) {
|
|
25676
|
-
if (operator.identifier === this.config.getCoordinatorIdentifier()) {
|
|
26121
|
+
if (operator.identifier === this.config.getCoordinatorIdentifier() && !verifyCoordinatorProof) {
|
|
25677
26122
|
continue;
|
|
25678
26123
|
}
|
|
25679
26124
|
const operatorPubkey2 = hexToBytes7(operator.identityPublicKey);
|
|
@@ -25698,6 +26143,46 @@ var DepositService = class {
|
|
|
25698
26143
|
}
|
|
25699
26144
|
}
|
|
25700
26145
|
}
|
|
26146
|
+
async generateStaticDepositAddress({
|
|
26147
|
+
signingPubkey
|
|
26148
|
+
}) {
|
|
26149
|
+
const sparkClient = await this.connectionManager.createSparkClient(
|
|
26150
|
+
this.config.getCoordinatorAddress()
|
|
26151
|
+
);
|
|
26152
|
+
let depositResp;
|
|
26153
|
+
try {
|
|
26154
|
+
depositResp = await sparkClient.generate_static_deposit_address({
|
|
26155
|
+
signingPublicKey: signingPubkey,
|
|
26156
|
+
identityPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
26157
|
+
network: this.config.getNetworkProto()
|
|
26158
|
+
});
|
|
26159
|
+
} catch (error) {
|
|
26160
|
+
throw new NetworkError(
|
|
26161
|
+
"Failed to generate static deposit address",
|
|
26162
|
+
{
|
|
26163
|
+
operation: "generate_static_deposit_address",
|
|
26164
|
+
errorCount: 1,
|
|
26165
|
+
errors: error instanceof Error ? error.message : String(error)
|
|
26166
|
+
},
|
|
26167
|
+
error
|
|
26168
|
+
);
|
|
26169
|
+
}
|
|
26170
|
+
if (!depositResp.depositAddress) {
|
|
26171
|
+
throw new ValidationError(
|
|
26172
|
+
"No static deposit address response from coordinator",
|
|
26173
|
+
{
|
|
26174
|
+
field: "depositAddress",
|
|
26175
|
+
value: depositResp
|
|
26176
|
+
}
|
|
26177
|
+
);
|
|
26178
|
+
}
|
|
26179
|
+
await this.validateDepositAddress({
|
|
26180
|
+
address: depositResp.depositAddress,
|
|
26181
|
+
userPubkey: signingPubkey,
|
|
26182
|
+
verifyCoordinatorProof: true
|
|
26183
|
+
});
|
|
26184
|
+
return depositResp;
|
|
26185
|
+
}
|
|
25701
26186
|
async generateDepositAddress({
|
|
25702
26187
|
signingPubkey,
|
|
25703
26188
|
leafId,
|
|
@@ -26237,12 +26722,12 @@ var DepositService = class {
|
|
|
26237
26722
|
};
|
|
26238
26723
|
|
|
26239
26724
|
// src/services/lightning.ts
|
|
26725
|
+
import { secp256k1 as secp256k110 } from "@noble/curves/secp256k1";
|
|
26240
26726
|
import {
|
|
26241
26727
|
bytesToNumberBE as bytesToNumberBE6,
|
|
26242
26728
|
hexToBytes as hexToBytes8,
|
|
26243
26729
|
numberToBytesBE as numberToBytesBE4
|
|
26244
|
-
} from "@noble/curves/
|
|
26245
|
-
import { secp256k1 as secp256k110 } from "@noble/curves/secp256k1";
|
|
26730
|
+
} from "@noble/curves/utils";
|
|
26246
26731
|
import { sha256 as sha25611 } from "@noble/hashes/sha2";
|
|
26247
26732
|
import { uuidv7 as uuidv73 } from "uuidv7";
|
|
26248
26733
|
|
|
@@ -26588,12 +27073,12 @@ var LightningService = class {
|
|
|
26588
27073
|
};
|
|
26589
27074
|
|
|
26590
27075
|
// src/services/token-transactions.ts
|
|
27076
|
+
import { secp256k1 as secp256k112 } from "@noble/curves/secp256k1";
|
|
26591
27077
|
import {
|
|
26592
|
-
bytesToHex as
|
|
27078
|
+
bytesToHex as bytesToHex10,
|
|
26593
27079
|
bytesToNumberBE as bytesToNumberBE7,
|
|
26594
27080
|
numberToBytesBE as numberToBytesBE5
|
|
26595
|
-
} from "@noble/curves/
|
|
26596
|
-
import { secp256k1 as secp256k112 } from "@noble/curves/secp256k1";
|
|
27081
|
+
} from "@noble/curves/utils";
|
|
26597
27082
|
import { hexToBytes as hexToBytes9 } from "@noble/hashes/utils";
|
|
26598
27083
|
|
|
26599
27084
|
// src/utils/token-hashing.ts
|
|
@@ -28730,7 +29215,7 @@ var TokenTransactionService = class {
|
|
|
28730
29215
|
{
|
|
28731
29216
|
field: "revocationCommitment",
|
|
28732
29217
|
value: derivedRevocationCommitment,
|
|
28733
|
-
expected:
|
|
29218
|
+
expected: bytesToHex10(outputsToSpendCommitments[outputIndex]),
|
|
28734
29219
|
outputIndex
|
|
28735
29220
|
}
|
|
28736
29221
|
)
|
|
@@ -28756,7 +29241,7 @@ var TokenTransactionService = class {
|
|
|
28756
29241
|
threshold
|
|
28757
29242
|
);
|
|
28758
29243
|
}
|
|
28759
|
-
return
|
|
29244
|
+
return bytesToHex10(finalTokenTransactionHash);
|
|
28760
29245
|
}
|
|
28761
29246
|
async broadcastTokenTransactionV1(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
|
|
28762
29247
|
const { finalTokenTransaction, finalTokenTransactionHash, threshold } = await this.startTokenTransaction(
|
|
@@ -28770,7 +29255,7 @@ var TokenTransactionService = class {
|
|
|
28770
29255
|
finalTokenTransactionHash,
|
|
28771
29256
|
signingOperators
|
|
28772
29257
|
);
|
|
28773
|
-
return
|
|
29258
|
+
return bytesToHex10(finalTokenTransactionHash);
|
|
28774
29259
|
}
|
|
28775
29260
|
async startTokenTransactionV0(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
|
|
28776
29261
|
const sparkClient = await this.connectionManager.createSparkClient(
|
|
@@ -29362,7 +29847,7 @@ var TokenTransactionService = class {
|
|
|
29362
29847
|
// Helper function for deciding if the signer public key is the identity public key
|
|
29363
29848
|
async signMessageWithKey(message, publicKey) {
|
|
29364
29849
|
const tokenSignatures = this.config.getTokenSignatures();
|
|
29365
|
-
if (
|
|
29850
|
+
if (bytesToHex10(publicKey) === bytesToHex10(await this.config.signer.getIdentityPublicKey())) {
|
|
29366
29851
|
if (tokenSignatures === "SCHNORR") {
|
|
29367
29852
|
return await this.config.signer.signSchnorrWithIdentityKey(message);
|
|
29368
29853
|
} else {
|
|
@@ -29371,8 +29856,8 @@ var TokenTransactionService = class {
|
|
|
29371
29856
|
} else {
|
|
29372
29857
|
throw new ValidationError("Invalid public key", {
|
|
29373
29858
|
field: "publicKey",
|
|
29374
|
-
value:
|
|
29375
|
-
expected:
|
|
29859
|
+
value: bytesToHex10(publicKey),
|
|
29860
|
+
expected: bytesToHex10(await this.config.signer.getIdentityPublicKey())
|
|
29376
29861
|
});
|
|
29377
29862
|
}
|
|
29378
29863
|
}
|
|
@@ -29511,7 +29996,7 @@ import { EventEmitter } from "eventemitter3";
|
|
|
29511
29996
|
import { ClientError, Status } from "nice-grpc-common";
|
|
29512
29997
|
|
|
29513
29998
|
// src/services/signing.ts
|
|
29514
|
-
import { hexToBytes as hexToBytes10 } from "@noble/curves/
|
|
29999
|
+
import { hexToBytes as hexToBytes10 } from "@noble/curves/utils";
|
|
29515
30000
|
var SigningService = class {
|
|
29516
30001
|
config;
|
|
29517
30002
|
constructor(config) {
|
|
@@ -29676,8 +30161,8 @@ var SigningService = class {
|
|
|
29676
30161
|
};
|
|
29677
30162
|
|
|
29678
30163
|
// src/tests/utils/test-faucet.ts
|
|
29679
|
-
import { bytesToHex as bytesToHex12, hexToBytes as hexToBytes11 } from "@noble/curves/abstract/utils";
|
|
29680
30164
|
import { schnorr as schnorr6, secp256k1 as secp256k113 } from "@noble/curves/secp256k1";
|
|
30165
|
+
import { bytesToHex as bytesToHex11, hexToBytes as hexToBytes11 } from "@noble/curves/utils";
|
|
29681
30166
|
import * as btc5 from "@scure/btc-signer";
|
|
29682
30167
|
import { Address as Address4, OutScript as OutScript2, SigHash as SigHash2, Transaction as Transaction7 } from "@scure/btc-signer";
|
|
29683
30168
|
import { taprootTweakPrivKey as taprootTweakPrivKey2 } from "@scure/btc-signer/utils";
|
|
@@ -29809,7 +30294,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
29809
30294
|
},
|
|
29810
30295
|
STATIC_MINING_KEY
|
|
29811
30296
|
);
|
|
29812
|
-
await this.broadcastTx(
|
|
30297
|
+
await this.broadcastTx(bytesToHex11(signedSplitTx.extract()));
|
|
29813
30298
|
const splitTxId = signedSplitTx.id;
|
|
29814
30299
|
for (let i = 0; i < numCoinsToCreate; i++) {
|
|
29815
30300
|
this.coins.push({
|
|
@@ -29843,7 +30328,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
29843
30328
|
coinToSend.txout,
|
|
29844
30329
|
coinToSend.key
|
|
29845
30330
|
);
|
|
29846
|
-
await this.broadcastTx(
|
|
30331
|
+
await this.broadcastTx(bytesToHex11(signedTx.extract()));
|
|
29847
30332
|
}
|
|
29848
30333
|
async signFaucetCoin(unsignedTx, fundingTxOut, key) {
|
|
29849
30334
|
const pubKey = secp256k113.getPublicKey(key);
|
|
@@ -29963,7 +30448,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
29963
30448
|
});
|
|
29964
30449
|
}
|
|
29965
30450
|
const signedTx = await this.signFaucetCoin(tx, coin.txout, coin.key);
|
|
29966
|
-
const txHex =
|
|
30451
|
+
const txHex = bytesToHex11(signedTx.extract());
|
|
29967
30452
|
await this.broadcastTx(txHex);
|
|
29968
30453
|
const randomKey = secp256k113.utils.randomPrivateKey();
|
|
29969
30454
|
const randomPubKey = secp256k113.getPublicKey(randomKey);
|
|
@@ -30529,7 +31014,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
30529
31014
|
* @returns {Promise<string>} The identity public key as a hex string.
|
|
30530
31015
|
*/
|
|
30531
31016
|
async getIdentityPublicKey() {
|
|
30532
|
-
return
|
|
31017
|
+
return bytesToHex12(await this.config.signer.getIdentityPublicKey());
|
|
30533
31018
|
}
|
|
30534
31019
|
/**
|
|
30535
31020
|
* Gets the Spark address of the wallet.
|
|
@@ -30539,7 +31024,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
30539
31024
|
async getSparkAddress() {
|
|
30540
31025
|
if (!this.sparkAddress) {
|
|
30541
31026
|
this.sparkAddress = encodeSparkAddress({
|
|
30542
|
-
identityPublicKey:
|
|
31027
|
+
identityPublicKey: bytesToHex12(
|
|
30543
31028
|
await this.config.signer.getIdentityPublicKey()
|
|
30544
31029
|
),
|
|
30545
31030
|
network: this.config.getNetworkType()
|
|
@@ -30623,7 +31108,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
30623
31108
|
const signature = await this.config.signer.signSchnorrWithIdentityKey(hash);
|
|
30624
31109
|
return encodeSparkAddressWithSignature(
|
|
30625
31110
|
{
|
|
30626
|
-
identityPublicKey:
|
|
31111
|
+
identityPublicKey: bytesToHex12(identityPublicKey),
|
|
30627
31112
|
network: this.config.getNetworkType(),
|
|
30628
31113
|
sparkInvoiceFields: invoiceFields
|
|
30629
31114
|
},
|
|
@@ -30691,7 +31176,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
30691
31176
|
});
|
|
30692
31177
|
}
|
|
30693
31178
|
this.sparkAddress = encodeSparkAddress({
|
|
30694
|
-
identityPublicKey:
|
|
31179
|
+
identityPublicKey: bytesToHex12(identityPublicKey),
|
|
30695
31180
|
network: this.config.getNetworkType()
|
|
30696
31181
|
});
|
|
30697
31182
|
return this.sparkAddress;
|
|
@@ -30871,18 +31356,18 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
30871
31356
|
const userLeaves = [];
|
|
30872
31357
|
userLeaves.push({
|
|
30873
31358
|
leaf_id: transfer.leaves[0].leaf.id,
|
|
30874
|
-
raw_unsigned_refund_transaction:
|
|
31359
|
+
raw_unsigned_refund_transaction: bytesToHex12(
|
|
30875
31360
|
transfer.leaves[0].intermediateRefundTx
|
|
30876
31361
|
),
|
|
30877
|
-
direct_raw_unsigned_refund_transaction:
|
|
31362
|
+
direct_raw_unsigned_refund_transaction: bytesToHex12(
|
|
30878
31363
|
transfer.leaves[0].intermediateDirectRefundTx
|
|
30879
31364
|
),
|
|
30880
|
-
direct_from_cpfp_raw_unsigned_refund_transaction:
|
|
31365
|
+
direct_from_cpfp_raw_unsigned_refund_transaction: bytesToHex12(
|
|
30881
31366
|
transfer.leaves[0].intermediateDirectFromCpfpRefundTx
|
|
30882
31367
|
),
|
|
30883
|
-
adaptor_added_signature:
|
|
30884
|
-
direct_adaptor_added_signature:
|
|
30885
|
-
direct_from_cpfp_adaptor_added_signature:
|
|
31368
|
+
adaptor_added_signature: bytesToHex12(cpfpAdaptorSignature),
|
|
31369
|
+
direct_adaptor_added_signature: bytesToHex12(directAdaptorSignature),
|
|
31370
|
+
direct_from_cpfp_adaptor_added_signature: bytesToHex12(
|
|
30886
31371
|
directFromCpfpAdaptorSignature
|
|
30887
31372
|
)
|
|
30888
31373
|
});
|
|
@@ -30935,24 +31420,24 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
30935
31420
|
}
|
|
30936
31421
|
userLeaves.push({
|
|
30937
31422
|
leaf_id: leaf.leaf.id,
|
|
30938
|
-
raw_unsigned_refund_transaction:
|
|
31423
|
+
raw_unsigned_refund_transaction: bytesToHex12(
|
|
30939
31424
|
leaf.intermediateRefundTx
|
|
30940
31425
|
),
|
|
30941
|
-
direct_raw_unsigned_refund_transaction:
|
|
31426
|
+
direct_raw_unsigned_refund_transaction: bytesToHex12(
|
|
30942
31427
|
leaf.intermediateDirectRefundTx
|
|
30943
31428
|
),
|
|
30944
|
-
direct_from_cpfp_raw_unsigned_refund_transaction:
|
|
31429
|
+
direct_from_cpfp_raw_unsigned_refund_transaction: bytesToHex12(
|
|
30945
31430
|
leaf.intermediateDirectFromCpfpRefundTx
|
|
30946
31431
|
),
|
|
30947
|
-
adaptor_added_signature:
|
|
30948
|
-
direct_adaptor_added_signature:
|
|
30949
|
-
direct_from_cpfp_adaptor_added_signature:
|
|
31432
|
+
adaptor_added_signature: bytesToHex12(cpfpSignature),
|
|
31433
|
+
direct_adaptor_added_signature: bytesToHex12(directSignature),
|
|
31434
|
+
direct_from_cpfp_adaptor_added_signature: bytesToHex12(
|
|
30950
31435
|
directFromCpfpSignature
|
|
30951
31436
|
)
|
|
30952
31437
|
});
|
|
30953
31438
|
}
|
|
30954
31439
|
const sspClient = this.getSspClient();
|
|
30955
|
-
const cpfpAdaptorPubkey =
|
|
31440
|
+
const cpfpAdaptorPubkey = bytesToHex12(
|
|
30956
31441
|
secp256k114.getPublicKey(cpfpAdaptorPrivateKey)
|
|
30957
31442
|
);
|
|
30958
31443
|
if (!cpfpAdaptorPubkey) {
|
|
@@ -30960,13 +31445,13 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
30960
31445
|
}
|
|
30961
31446
|
let directAdaptorPubkey;
|
|
30962
31447
|
if (directAdaptorPrivateKey.length > 0) {
|
|
30963
|
-
directAdaptorPubkey =
|
|
31448
|
+
directAdaptorPubkey = bytesToHex12(
|
|
30964
31449
|
secp256k114.getPublicKey(directAdaptorPrivateKey)
|
|
30965
31450
|
);
|
|
30966
31451
|
}
|
|
30967
31452
|
let directFromCpfpAdaptorPubkey;
|
|
30968
31453
|
if (directFromCpfpAdaptorPrivateKey.length > 0) {
|
|
30969
|
-
directFromCpfpAdaptorPubkey =
|
|
31454
|
+
directFromCpfpAdaptorPubkey = bytesToHex12(
|
|
30970
31455
|
secp256k114.getPublicKey(directFromCpfpAdaptorPrivateKey)
|
|
30971
31456
|
);
|
|
30972
31457
|
}
|
|
@@ -31106,9 +31591,9 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
31106
31591
|
directFromCpfpSignatureMap
|
|
31107
31592
|
);
|
|
31108
31593
|
const completeResponse = await sspClient.completeLeaveSwap({
|
|
31109
|
-
adaptorSecretKey:
|
|
31110
|
-
directAdaptorSecretKey:
|
|
31111
|
-
directFromCpfpAdaptorSecretKey:
|
|
31594
|
+
adaptorSecretKey: bytesToHex12(cpfpAdaptorPrivateKey),
|
|
31595
|
+
directAdaptorSecretKey: bytesToHex12(directAdaptorPrivateKey),
|
|
31596
|
+
directFromCpfpAdaptorSecretKey: bytesToHex12(
|
|
31112
31597
|
directFromCpfpAdaptorPrivateKey
|
|
31113
31598
|
),
|
|
31114
31599
|
userOutboundTransferExternalId: transfer.id,
|
|
@@ -31139,7 +31624,6 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
31139
31624
|
message: e.message,
|
|
31140
31625
|
stack: e.stack
|
|
31141
31626
|
});
|
|
31142
|
-
await this.cancelAllSenderInitiatedTransfers();
|
|
31143
31627
|
throw new Error(`Failed to request leaves swap: ${e}`);
|
|
31144
31628
|
}
|
|
31145
31629
|
}
|
|
@@ -31203,7 +31687,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
31203
31687
|
let tokenMetadataMap = /* @__PURE__ */ new Map();
|
|
31204
31688
|
for (const [tokenIdentifier, metadata] of this.tokenMetadata) {
|
|
31205
31689
|
tokenMetadataMap.set(tokenIdentifier, {
|
|
31206
|
-
tokenPublicKey:
|
|
31690
|
+
tokenPublicKey: bytesToHex12(metadata.issuerPublicKey),
|
|
31207
31691
|
rawTokenIdentifier: metadata.tokenIdentifier,
|
|
31208
31692
|
tokenName: metadata.tokenName,
|
|
31209
31693
|
tokenTicker: metadata.tokenTicker,
|
|
@@ -31243,7 +31727,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
31243
31727
|
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
31244
31728
|
*/
|
|
31245
31729
|
async getSingleUseDepositAddress() {
|
|
31246
|
-
return await this.generateDepositAddress(
|
|
31730
|
+
return await this.generateDepositAddress();
|
|
31247
31731
|
}
|
|
31248
31732
|
/**
|
|
31249
31733
|
* Generates a new static deposit address for receiving bitcoin funds.
|
|
@@ -31252,43 +31736,32 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
31252
31736
|
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
31253
31737
|
*/
|
|
31254
31738
|
async getStaticDepositAddress() {
|
|
31255
|
-
|
|
31256
|
-
|
|
31257
|
-
|
|
31258
|
-
|
|
31259
|
-
|
|
31260
|
-
|
|
31261
|
-
|
|
31262
|
-
|
|
31263
|
-
|
|
31264
|
-
}
|
|
31265
|
-
} else {
|
|
31266
|
-
throw error;
|
|
31267
|
-
}
|
|
31739
|
+
const signingPubkey = await this.config.signer.getStaticDepositSigningKey(0);
|
|
31740
|
+
const address2 = await this.depositService.generateStaticDepositAddress({
|
|
31741
|
+
signingPubkey
|
|
31742
|
+
});
|
|
31743
|
+
if (!address2.depositAddress) {
|
|
31744
|
+
throw new RPCError("Failed to generate static deposit address", {
|
|
31745
|
+
method: "generateStaticDepositAddress",
|
|
31746
|
+
params: { signingPubkey }
|
|
31747
|
+
});
|
|
31268
31748
|
}
|
|
31749
|
+
return address2.depositAddress.address;
|
|
31269
31750
|
}
|
|
31270
31751
|
/**
|
|
31271
31752
|
* Generates a deposit address for receiving funds.
|
|
31272
|
-
*
|
|
31273
|
-
* @param {boolean} static - Whether the address is static or single use
|
|
31274
31753
|
* @returns {Promise<string>} A deposit address
|
|
31275
31754
|
* @private
|
|
31276
31755
|
*/
|
|
31277
|
-
async generateDepositAddress(
|
|
31756
|
+
async generateDepositAddress() {
|
|
31278
31757
|
const leafId = uuidv74();
|
|
31279
|
-
|
|
31280
|
-
|
|
31281
|
-
|
|
31282
|
-
}
|
|
31283
|
-
signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
|
|
31284
|
-
type: "leaf" /* LEAF */,
|
|
31285
|
-
path: leafId
|
|
31286
|
-
});
|
|
31287
|
-
}
|
|
31758
|
+
const signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
|
|
31759
|
+
type: "leaf" /* LEAF */,
|
|
31760
|
+
path: leafId
|
|
31761
|
+
});
|
|
31288
31762
|
const address2 = await this.depositService.generateDepositAddress({
|
|
31289
31763
|
signingPubkey,
|
|
31290
|
-
leafId
|
|
31291
|
-
isStatic
|
|
31764
|
+
leafId
|
|
31292
31765
|
});
|
|
31293
31766
|
if (!address2.depositAddress) {
|
|
31294
31767
|
throw new RPCError("Failed to generate deposit address", {
|
|
@@ -31315,7 +31788,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
31315
31788
|
* @param offset - Pagination offset (default 0).
|
|
31316
31789
|
* @returns {Promise<{ txid: string, vout: number }[]>} List of confirmed UTXOs.
|
|
31317
31790
|
*/
|
|
31318
|
-
async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0) {
|
|
31791
|
+
async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0, excludeClaimed = false) {
|
|
31319
31792
|
if (!depositAddress) {
|
|
31320
31793
|
throw new ValidationError("Deposit address cannot be empty", {
|
|
31321
31794
|
field: "depositAddress"
|
|
@@ -31329,10 +31802,11 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
31329
31802
|
address: depositAddress,
|
|
31330
31803
|
network: NetworkToProto[this.config.getNetwork()],
|
|
31331
31804
|
limit,
|
|
31332
|
-
offset
|
|
31805
|
+
offset,
|
|
31806
|
+
excludeClaimed
|
|
31333
31807
|
});
|
|
31334
31808
|
return response.utxos.map((utxo) => ({
|
|
31335
|
-
txid:
|
|
31809
|
+
txid: bytesToHex12(utxo.txid),
|
|
31336
31810
|
vout: utxo.vout
|
|
31337
31811
|
})) ?? [];
|
|
31338
31812
|
} catch (error) {
|
|
@@ -31402,7 +31876,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
31402
31876
|
if (network === BitcoinNetwork_default.FUTURE_VALUE) {
|
|
31403
31877
|
network = BitcoinNetwork_default.REGTEST;
|
|
31404
31878
|
}
|
|
31405
|
-
const depositSecretKey =
|
|
31879
|
+
const depositSecretKey = bytesToHex12(
|
|
31406
31880
|
await this.config.signer.getStaticDepositSecretKey(0)
|
|
31407
31881
|
);
|
|
31408
31882
|
const message = await this.getStaticDepositSigningPayload(
|
|
@@ -31415,7 +31889,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
31415
31889
|
);
|
|
31416
31890
|
const hashBuffer = sha25613(message);
|
|
31417
31891
|
const signatureBytes = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
|
|
31418
|
-
const signature =
|
|
31892
|
+
const signature = bytesToHex12(signatureBytes);
|
|
31419
31893
|
const response = await this.sspClient.claimStaticDeposit({
|
|
31420
31894
|
transactionId,
|
|
31421
31895
|
outputIndex,
|
|
@@ -31567,7 +32041,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
31567
32041
|
networkJSON.toLowerCase(),
|
|
31568
32042
|
2 /* Refund */,
|
|
31569
32043
|
creditAmountSats,
|
|
31570
|
-
|
|
32044
|
+
bytesToHex12(spendTxSighash)
|
|
31571
32045
|
);
|
|
31572
32046
|
const hashBuffer = sha25613(message);
|
|
31573
32047
|
const swapResponseUserSignature = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
|
|
@@ -31612,6 +32086,64 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
31612
32086
|
});
|
|
31613
32087
|
return tx.hex;
|
|
31614
32088
|
}
|
|
32089
|
+
/**
|
|
32090
|
+
* Refunds a static deposit and broadcasts the transaction to the network.
|
|
32091
|
+
*
|
|
32092
|
+
* @param {Object} params - The refund parameters
|
|
32093
|
+
* @param {string} params.depositTransactionId - The ID of the transaction
|
|
32094
|
+
* @param {number} [params.outputIndex] - The index of the output
|
|
32095
|
+
* @param {string} params.destinationAddress - The destination address
|
|
32096
|
+
* @param {number} [params.satsPerVbyteFee] - The fee per vbyte to refund
|
|
32097
|
+
* @returns {Promise<string>} The transaction ID
|
|
32098
|
+
*/
|
|
32099
|
+
async refundAndBroadcastStaticDeposit({
|
|
32100
|
+
depositTransactionId,
|
|
32101
|
+
outputIndex,
|
|
32102
|
+
destinationAddress,
|
|
32103
|
+
satsPerVbyteFee
|
|
32104
|
+
}) {
|
|
32105
|
+
const txHex = await this.refundStaticDeposit({
|
|
32106
|
+
depositTransactionId,
|
|
32107
|
+
outputIndex,
|
|
32108
|
+
destinationAddress,
|
|
32109
|
+
satsPerVbyteFee
|
|
32110
|
+
});
|
|
32111
|
+
return await this.broadcastTx(txHex);
|
|
32112
|
+
}
|
|
32113
|
+
/**
|
|
32114
|
+
* Broadcasts a transaction to the network.
|
|
32115
|
+
*
|
|
32116
|
+
* @param {string} txHex - The hex of the transaction
|
|
32117
|
+
* @returns {Promise<string>} The transaction ID
|
|
32118
|
+
*/
|
|
32119
|
+
async broadcastTx(txHex) {
|
|
32120
|
+
if (!txHex) {
|
|
32121
|
+
throw new ValidationError("Transaction hex cannot be empty", {
|
|
32122
|
+
field: "txHex"
|
|
32123
|
+
});
|
|
32124
|
+
}
|
|
32125
|
+
const { fetch, Headers: Headers2 } = getFetch();
|
|
32126
|
+
const baseUrl = this.config.getElectrsUrl();
|
|
32127
|
+
const headers = new Headers2();
|
|
32128
|
+
if (this.config.getNetwork() === 4 /* LOCAL */) {
|
|
32129
|
+
const localFaucet = BitcoinFaucet.getInstance();
|
|
32130
|
+
const response = await localFaucet.broadcastTx(txHex);
|
|
32131
|
+
return response;
|
|
32132
|
+
} else {
|
|
32133
|
+
if (this.config.getNetwork() === 3 /* REGTEST */) {
|
|
32134
|
+
const auth = btoa(
|
|
32135
|
+
`${ELECTRS_CREDENTIALS.username}:${ELECTRS_CREDENTIALS.password}`
|
|
32136
|
+
);
|
|
32137
|
+
headers.set("Authorization", `Basic ${auth}`);
|
|
32138
|
+
}
|
|
32139
|
+
const response = await fetch(`${baseUrl}/tx`, {
|
|
32140
|
+
method: "POST",
|
|
32141
|
+
body: txHex,
|
|
32142
|
+
headers
|
|
32143
|
+
});
|
|
32144
|
+
return response.text();
|
|
32145
|
+
}
|
|
32146
|
+
}
|
|
31615
32147
|
async getStaticDepositSigningPayload(transactionID, outputIndex, network, requestType, creditAmountSats, sspSignature) {
|
|
31616
32148
|
const encoder = new TextEncoder();
|
|
31617
32149
|
const parts = [];
|
|
@@ -32090,7 +32622,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
32090
32622
|
}
|
|
32091
32623
|
return mapTransferToWalletTransfer(
|
|
32092
32624
|
transfer,
|
|
32093
|
-
|
|
32625
|
+
bytesToHex12(await this.config.signer.getIdentityPublicKey())
|
|
32094
32626
|
);
|
|
32095
32627
|
});
|
|
32096
32628
|
}
|
|
@@ -32350,24 +32882,6 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
32350
32882
|
(result) => result.status === "fulfilled" && result.value !== null
|
|
32351
32883
|
).map((result) => result.value);
|
|
32352
32884
|
}
|
|
32353
|
-
/**
|
|
32354
|
-
* Cancels all sender-initiated transfers.
|
|
32355
|
-
*
|
|
32356
|
-
* @returns {Promise<void>}
|
|
32357
|
-
* @private
|
|
32358
|
-
*/
|
|
32359
|
-
async cancelAllSenderInitiatedTransfers() {
|
|
32360
|
-
for (const operator of Object.values(this.config.getSigningOperators())) {
|
|
32361
|
-
const transfers = await this.transferService.queryPendingTransfersBySender(
|
|
32362
|
-
operator.address
|
|
32363
|
-
);
|
|
32364
|
-
for (const transfer of transfers.transfers) {
|
|
32365
|
-
if (transfer.status === 0 /* TRANSFER_STATUS_SENDER_INITIATED */) {
|
|
32366
|
-
await this.transferService.cancelTransfer(transfer, operator.address);
|
|
32367
|
-
}
|
|
32368
|
-
}
|
|
32369
|
-
}
|
|
32370
|
-
}
|
|
32371
32885
|
// ***** Lightning Flow *****
|
|
32372
32886
|
/**
|
|
32373
32887
|
* Creates a Lightning invoice for receiving payments.
|
|
@@ -32446,7 +32960,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
32446
32960
|
const invoice2 = await sspClient.requestLightningReceive({
|
|
32447
32961
|
amountSats: amountSats2,
|
|
32448
32962
|
network: bitcoinNetwork,
|
|
32449
|
-
paymentHash:
|
|
32963
|
+
paymentHash: bytesToHex12(paymentHash),
|
|
32450
32964
|
expirySecs: expirySeconds,
|
|
32451
32965
|
memo: memo2,
|
|
32452
32966
|
includeSparkAddress,
|
|
@@ -32976,7 +33490,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
32976
33490
|
return transfers?.[0];
|
|
32977
33491
|
}
|
|
32978
33492
|
async constructTransfersWithUserRequest(transfers) {
|
|
32979
|
-
const identityPublicKey =
|
|
33493
|
+
const identityPublicKey = bytesToHex12(
|
|
32980
33494
|
await this.config.signer.getIdentityPublicKey()
|
|
32981
33495
|
);
|
|
32982
33496
|
const userRequests = await this.sspClient?.getTransfers(
|
|
@@ -33220,7 +33734,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
33220
33734
|
hash,
|
|
33221
33735
|
compact
|
|
33222
33736
|
);
|
|
33223
|
-
return
|
|
33737
|
+
return bytesToHex12(signature);
|
|
33224
33738
|
}
|
|
33225
33739
|
/**
|
|
33226
33740
|
* Validates a message with the identity key.
|
|
@@ -33278,7 +33792,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
33278
33792
|
publicKey,
|
|
33279
33793
|
this.config.getNetwork()
|
|
33280
33794
|
);
|
|
33281
|
-
if (
|
|
33795
|
+
if (bytesToHex12(script) === bytesToHex12(identityScript)) {
|
|
33282
33796
|
try {
|
|
33283
33797
|
this.config.signer.signTransactionIndex(tx, i, publicKey);
|
|
33284
33798
|
inputsSigned++;
|
|
@@ -33322,13 +33836,13 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
|
|
|
33322
33836
|
depositPubKey,
|
|
33323
33837
|
this.config.getNetwork()
|
|
33324
33838
|
);
|
|
33325
|
-
if (
|
|
33839
|
+
if (bytesToHex12(script) === bytesToHex12(identityScript)) {
|
|
33326
33840
|
return {
|
|
33327
33841
|
publicKey: identityPubKey,
|
|
33328
33842
|
keyType: "identity"
|
|
33329
33843
|
};
|
|
33330
33844
|
}
|
|
33331
|
-
if (
|
|
33845
|
+
if (bytesToHex12(script) === bytesToHex12(depositScript)) {
|
|
33332
33846
|
return {
|
|
33333
33847
|
publicKey: depositPubKey,
|
|
33334
33848
|
keyType: "deposit"
|