@buildonspark/spark-sdk 0.2.9 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/bare/chunk-P6AVV7VD.js +34 -0
  3. package/dist/bare/index.cjs +341 -279
  4. package/dist/bare/index.d.cts +15 -2
  5. package/dist/bare/index.d.ts +15 -2
  6. package/dist/bare/index.js +55 -50
  7. package/dist/bare/{wasm-OPXXYRN5.js → wasm-F5QFVBNZ.js} +26 -0
  8. package/dist/bare/{xhr-transport-6GYJAFWU.js → xhr-transport-EEEC7FYA.js} +2 -2
  9. package/dist/{chunk-23BBEC25.js → chunk-3WBPICWC.js} +1 -1
  10. package/dist/chunk-NX5KPN5F.js +34 -0
  11. package/dist/{chunk-5Y7YILMA.js → chunk-QNYJGFPD.js} +53 -49
  12. package/dist/debug.cjs +337 -276
  13. package/dist/debug.d.cts +5 -2
  14. package/dist/debug.d.ts +5 -2
  15. package/dist/debug.js +2 -1
  16. package/dist/index.cjs +390 -327
  17. package/dist/index.d.cts +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +8 -2
  20. package/dist/index.node.cjs +390 -327
  21. package/dist/index.node.d.cts +1 -1
  22. package/dist/index.node.d.ts +1 -1
  23. package/dist/index.node.js +7 -1
  24. package/dist/{xchain-address-CNQEwLjR.d.cts → logging-BOAzMqpM.d.cts} +15 -1
  25. package/dist/{xchain-address-BPwpnmuY.d.ts → logging-Bt_WdZbu.d.ts} +15 -1
  26. package/dist/native/chunk-D3SZRO65.js +36 -0
  27. package/dist/native/index.cjs +387 -324
  28. package/dist/native/index.d.cts +15 -2
  29. package/dist/native/index.d.ts +15 -2
  30. package/dist/native/index.js +147 -143
  31. package/dist/native/{wasm-2KV6XFEP.js → wasm-3YAXKQ7F.js} +25 -0
  32. package/dist/native/{xhr-transport-WHMS3FGG.js → xhr-transport-TNCG4HTW.js} +2 -2
  33. package/dist/spark_bindings/wasm/index.cjs +51 -0
  34. package/dist/spark_bindings/wasm/index.js +25 -0
  35. package/dist/tests/test-utils.cjs +229 -166
  36. package/dist/tests/test-utils.js +3 -2
  37. package/dist/{xhr-transport-RH6LDRXS.js → xhr-transport-IWJPYF7F.js} +2 -2
  38. package/package.json +1 -1
  39. package/src/services/deposit.ts +5 -1
  40. package/src/services/xhr-transport.ts +2 -2
  41. package/src/spark-wallet/spark-wallet.ts +4 -9
  42. package/src/spark_bindings/wasm/index.ts +21 -0
  43. package/src/tests/integration/lightning.test.ts +2 -2
  44. package/src/tests/integration/ssp/coop-exit-validation.test.ts +2 -2
  45. package/src/tests/integration/ssp/static_deposit.test.ts +0 -32
  46. package/src/tests/integration/swap.test.ts +2 -2
  47. package/src/tests/integration/transfer.test.ts +20 -16
  48. package/src/tests/integration/watchtower.test.ts +2 -2
  49. package/src/utils/adaptor-signature.ts +11 -12
  50. package/src/utils/address.ts +10 -10
  51. package/src/utils/bitcoin.ts +6 -6
  52. package/src/utils/index.ts +1 -0
  53. package/src/utils/keys.ts +9 -9
  54. package/src/utils/logging.ts +40 -0
  55. package/src/utils/secret-sharing.ts +9 -11
package/dist/index.cjs CHANGED
@@ -50,6 +50,43 @@ var init_buffer = __esm({
50
50
  }
51
51
  });
52
52
 
53
+ // src/utils/logging.ts
54
+ var import_core8, LOGGER_NAMES, SparkSdkLogger;
55
+ var init_logging = __esm({
56
+ "src/utils/logging.ts"() {
57
+ "use strict";
58
+ init_buffer();
59
+ import_core8 = require("@lightsparkdev/core");
60
+ LOGGER_NAMES = {
61
+ wasm: "wasm"
62
+ };
63
+ SparkSdkLogger = class {
64
+ static loggers = /* @__PURE__ */ new Map();
65
+ static get(name) {
66
+ if (!this.loggers.has(name)) {
67
+ this.loggers.set(name, new import_core8.Logger(name));
68
+ }
69
+ return this.loggers.get(name);
70
+ }
71
+ static setLevel(name, level) {
72
+ this.get(name).setLevel(level);
73
+ }
74
+ static setAllLevels(level) {
75
+ this.loggers.forEach((logger) => logger.setLevel(level));
76
+ }
77
+ static setEnabled(name, enabled) {
78
+ this.get(name).setEnabled(enabled);
79
+ }
80
+ static setAllEnabled(enabled) {
81
+ this.loggers.forEach((logger) => logger.setEnabled(enabled));
82
+ }
83
+ static {
84
+ Object.values(LOGGER_NAMES).forEach((name) => this.get(name));
85
+ }
86
+ };
87
+ }
88
+ });
89
+
53
90
  // src/wasm/spark_bindings.js
54
91
  function getUint8ArrayMemory0() {
55
92
  if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
@@ -1073,6 +1110,13 @@ function signFrost({
1073
1110
  statechainCommitments,
1074
1111
  adaptorPubKey
1075
1112
  }) {
1113
+ SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("signFrost", {
1114
+ message: (0, import_utils13.bytesToHex)(message),
1115
+ keyPackage,
1116
+ nonce,
1117
+ selfCommitment,
1118
+ statechainCommitments
1119
+ });
1076
1120
  return wasm_sign_frost(
1077
1121
  message,
1078
1122
  createKeyPackage(keyPackage),
@@ -1093,6 +1137,17 @@ function aggregateFrost({
1093
1137
  verifyingKey,
1094
1138
  adaptorPubKey
1095
1139
  }) {
1140
+ SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("aggregateFrost", {
1141
+ message: (0, import_utils13.bytesToHex)(message),
1142
+ statechainCommitments,
1143
+ selfCommitment,
1144
+ statechainSignatures,
1145
+ selfSignature: (0, import_utils13.bytesToHex)(selfSignature),
1146
+ statechainPublicKeys,
1147
+ selfPublicKey: (0, import_utils13.bytesToHex)(selfPublicKey),
1148
+ verifyingKey: (0, import_utils13.bytesToHex)(verifyingKey),
1149
+ adaptorPubKey: adaptorPubKey ? (0, import_utils13.bytesToHex)(adaptorPubKey) : void 0
1150
+ });
1096
1151
  return wasm_aggregate_frost(
1097
1152
  message,
1098
1153
  statechainCommitments,
@@ -1123,11 +1178,14 @@ function decryptEcies({
1123
1178
  }) {
1124
1179
  return decrypt_ecies(encryptedMsg, privateKey);
1125
1180
  }
1181
+ var import_utils13;
1126
1182
  var init_wasm = __esm({
1127
1183
  "src/spark_bindings/wasm/index.ts"() {
1128
1184
  "use strict";
1129
1185
  init_buffer();
1186
+ import_utils13 = require("@noble/curves/utils");
1130
1187
  init_spark_bindings();
1188
+ init_logging();
1131
1189
  }
1132
1190
  });
1133
1191
 
@@ -1201,7 +1259,7 @@ function XHRTransport(config) {
1201
1259
  bodyBuffer = chunk;
1202
1260
  break;
1203
1261
  }
1204
- requestBody = bodyBuffer;
1262
+ requestBody = bodyBuffer.slice();
1205
1263
  } else {
1206
1264
  let iterator;
1207
1265
  requestBody = new ReadableStream({
@@ -1215,7 +1273,7 @@ function XHRTransport(config) {
1215
1273
  if (done) {
1216
1274
  controller.close();
1217
1275
  } else {
1218
- controller.enqueue(value);
1276
+ controller.enqueue(value.slice());
1219
1277
  }
1220
1278
  },
1221
1279
  async cancel() {
@@ -1317,6 +1375,7 @@ __export(index_exports, {
1317
1375
  INITIAL_SEQUENCE: () => INITIAL_SEQUENCE,
1318
1376
  InternalValidationError: () => InternalValidationError,
1319
1377
  KeyDerivationType: () => KeyDerivationType,
1378
+ LOGGER_NAMES: () => LOGGER_NAMES,
1320
1379
  LRC_WALLET_NETWORK: () => LRC_WALLET_NETWORK,
1321
1380
  Network: () => Network2,
1322
1381
  NetworkError: () => NetworkError,
@@ -1324,6 +1383,7 @@ __export(index_exports, {
1324
1383
  NotImplementedError: () => NotImplementedError,
1325
1384
  RPCError: () => RPCError,
1326
1385
  SparkSDKError: () => SparkSDKError,
1386
+ SparkSdkLogger: () => SparkSdkLogger,
1327
1387
  SparkWallet: () => SparkWalletBrowser,
1328
1388
  TEST_UNILATERAL_DIRECT_SEQUENCE: () => TEST_UNILATERAL_DIRECT_SEQUENCE,
1329
1389
  TEST_UNILATERAL_SEQUENCE: () => TEST_UNILATERAL_SEQUENCE,
@@ -1556,9 +1616,97 @@ init_buffer();
1556
1616
 
1557
1617
  // src/utils/address.ts
1558
1618
  init_buffer();
1619
+ var import_wire5 = require("@bufbuild/protobuf/wire");
1620
+ var import_utils2 = require("@noble/curves/abstract/utils");
1559
1621
  var import_secp256k1 = require("@noble/curves/secp256k1");
1560
- var import_utils2 = require("@noble/hashes/utils");
1622
+ var import_utils3 = require("@noble/hashes/utils");
1561
1623
  var import_base2 = require("@scure/base");
1624
+ var import_uuidv7 = require("uuidv7");
1625
+
1626
+ // src/proto/google/protobuf/timestamp.ts
1627
+ init_buffer();
1628
+ var import_wire = require("@bufbuild/protobuf/wire");
1629
+ function createBaseTimestamp() {
1630
+ return { seconds: 0, nanos: 0 };
1631
+ }
1632
+ var Timestamp = {
1633
+ encode(message, writer = new import_wire.BinaryWriter()) {
1634
+ if (message.seconds !== 0) {
1635
+ writer.uint32(8).int64(message.seconds);
1636
+ }
1637
+ if (message.nanos !== 0) {
1638
+ writer.uint32(16).int32(message.nanos);
1639
+ }
1640
+ return writer;
1641
+ },
1642
+ decode(input, length) {
1643
+ const reader = input instanceof import_wire.BinaryReader ? input : new import_wire.BinaryReader(input);
1644
+ const end = length === void 0 ? reader.len : reader.pos + length;
1645
+ const message = createBaseTimestamp();
1646
+ while (reader.pos < end) {
1647
+ const tag = reader.uint32();
1648
+ switch (tag >>> 3) {
1649
+ case 1: {
1650
+ if (tag !== 8) {
1651
+ break;
1652
+ }
1653
+ message.seconds = longToNumber(reader.int64());
1654
+ continue;
1655
+ }
1656
+ case 2: {
1657
+ if (tag !== 16) {
1658
+ break;
1659
+ }
1660
+ message.nanos = reader.int32();
1661
+ continue;
1662
+ }
1663
+ }
1664
+ if ((tag & 7) === 4 || tag === 0) {
1665
+ break;
1666
+ }
1667
+ reader.skip(tag & 7);
1668
+ }
1669
+ return message;
1670
+ },
1671
+ fromJSON(object) {
1672
+ return {
1673
+ seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0,
1674
+ nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0
1675
+ };
1676
+ },
1677
+ toJSON(message) {
1678
+ const obj = {};
1679
+ if (message.seconds !== 0) {
1680
+ obj.seconds = Math.round(message.seconds);
1681
+ }
1682
+ if (message.nanos !== 0) {
1683
+ obj.nanos = Math.round(message.nanos);
1684
+ }
1685
+ return obj;
1686
+ },
1687
+ create(base) {
1688
+ return Timestamp.fromPartial(base ?? {});
1689
+ },
1690
+ fromPartial(object) {
1691
+ const message = createBaseTimestamp();
1692
+ message.seconds = object.seconds ?? 0;
1693
+ message.nanos = object.nanos ?? 0;
1694
+ return message;
1695
+ }
1696
+ };
1697
+ function longToNumber(int64) {
1698
+ const num = globalThis.Number(int64.toString());
1699
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
1700
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
1701
+ }
1702
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
1703
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
1704
+ }
1705
+ return num;
1706
+ }
1707
+ function isSet(value) {
1708
+ return value !== null && value !== void 0;
1709
+ }
1562
1710
 
1563
1711
  // src/proto/spark.ts
1564
1712
  init_buffer();
@@ -1566,7 +1714,7 @@ var import_wire4 = require("@bufbuild/protobuf/wire");
1566
1714
 
1567
1715
  // src/proto/common.ts
1568
1716
  init_buffer();
1569
- var import_wire = require("@bufbuild/protobuf/wire");
1717
+ var import_wire2 = require("@bufbuild/protobuf/wire");
1570
1718
  function signatureIntentFromJSON(object) {
1571
1719
  switch (object) {
1572
1720
  case 0:
@@ -1611,7 +1759,7 @@ function createBaseSigningCommitment() {
1611
1759
  return { hiding: new Uint8Array(0), binding: new Uint8Array(0) };
1612
1760
  }
1613
1761
  var SigningCommitment = {
1614
- encode(message, writer = new import_wire.BinaryWriter()) {
1762
+ encode(message, writer = new import_wire2.BinaryWriter()) {
1615
1763
  if (message.hiding.length !== 0) {
1616
1764
  writer.uint32(10).bytes(message.hiding);
1617
1765
  }
@@ -1621,7 +1769,7 @@ var SigningCommitment = {
1621
1769
  return writer;
1622
1770
  },
1623
1771
  decode(input, length) {
1624
- const reader = input instanceof import_wire.BinaryReader ? input : new import_wire.BinaryReader(input);
1772
+ const reader = input instanceof import_wire2.BinaryReader ? input : new import_wire2.BinaryReader(input);
1625
1773
  const end = length === void 0 ? reader.len : reader.pos + length;
1626
1774
  const message = createBaseSigningCommitment();
1627
1775
  while (reader.pos < end) {
@@ -1651,8 +1799,8 @@ var SigningCommitment = {
1651
1799
  },
1652
1800
  fromJSON(object) {
1653
1801
  return {
1654
- hiding: isSet(object.hiding) ? bytesFromBase64(object.hiding) : new Uint8Array(0),
1655
- binding: isSet(object.binding) ? bytesFromBase64(object.binding) : new Uint8Array(0)
1802
+ hiding: isSet2(object.hiding) ? bytesFromBase64(object.hiding) : new Uint8Array(0),
1803
+ binding: isSet2(object.binding) ? bytesFromBase64(object.binding) : new Uint8Array(0)
1656
1804
  };
1657
1805
  },
1658
1806
  toJSON(message) {
@@ -1698,22 +1846,22 @@ function base64FromBytes(arr) {
1698
1846
  return globalThis.btoa(bin.join(""));
1699
1847
  }
1700
1848
  }
1701
- function isSet(value) {
1849
+ function isSet2(value) {
1702
1850
  return value !== null && value !== void 0;
1703
1851
  }
1704
1852
 
1705
1853
  // src/proto/google/protobuf/empty.ts
1706
1854
  init_buffer();
1707
- var import_wire2 = require("@bufbuild/protobuf/wire");
1855
+ var import_wire3 = require("@bufbuild/protobuf/wire");
1708
1856
  function createBaseEmpty() {
1709
1857
  return {};
1710
1858
  }
1711
1859
  var Empty = {
1712
- encode(_, writer = new import_wire2.BinaryWriter()) {
1860
+ encode(_, writer = new import_wire3.BinaryWriter()) {
1713
1861
  return writer;
1714
1862
  },
1715
1863
  decode(input, length) {
1716
- const reader = input instanceof import_wire2.BinaryReader ? input : new import_wire2.BinaryReader(input);
1864
+ const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
1717
1865
  const end = length === void 0 ? reader.len : reader.pos + length;
1718
1866
  const message = createBaseEmpty();
1719
1867
  while (reader.pos < end) {
@@ -1743,91 +1891,6 @@ var Empty = {
1743
1891
  }
1744
1892
  };
1745
1893
 
1746
- // src/proto/google/protobuf/timestamp.ts
1747
- init_buffer();
1748
- var import_wire3 = require("@bufbuild/protobuf/wire");
1749
- function createBaseTimestamp() {
1750
- return { seconds: 0, nanos: 0 };
1751
- }
1752
- var Timestamp = {
1753
- encode(message, writer = new import_wire3.BinaryWriter()) {
1754
- if (message.seconds !== 0) {
1755
- writer.uint32(8).int64(message.seconds);
1756
- }
1757
- if (message.nanos !== 0) {
1758
- writer.uint32(16).int32(message.nanos);
1759
- }
1760
- return writer;
1761
- },
1762
- decode(input, length) {
1763
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
1764
- const end = length === void 0 ? reader.len : reader.pos + length;
1765
- const message = createBaseTimestamp();
1766
- while (reader.pos < end) {
1767
- const tag = reader.uint32();
1768
- switch (tag >>> 3) {
1769
- case 1: {
1770
- if (tag !== 8) {
1771
- break;
1772
- }
1773
- message.seconds = longToNumber(reader.int64());
1774
- continue;
1775
- }
1776
- case 2: {
1777
- if (tag !== 16) {
1778
- break;
1779
- }
1780
- message.nanos = reader.int32();
1781
- continue;
1782
- }
1783
- }
1784
- if ((tag & 7) === 4 || tag === 0) {
1785
- break;
1786
- }
1787
- reader.skip(tag & 7);
1788
- }
1789
- return message;
1790
- },
1791
- fromJSON(object) {
1792
- return {
1793
- seconds: isSet2(object.seconds) ? globalThis.Number(object.seconds) : 0,
1794
- nanos: isSet2(object.nanos) ? globalThis.Number(object.nanos) : 0
1795
- };
1796
- },
1797
- toJSON(message) {
1798
- const obj = {};
1799
- if (message.seconds !== 0) {
1800
- obj.seconds = Math.round(message.seconds);
1801
- }
1802
- if (message.nanos !== 0) {
1803
- obj.nanos = Math.round(message.nanos);
1804
- }
1805
- return obj;
1806
- },
1807
- create(base) {
1808
- return Timestamp.fromPartial(base ?? {});
1809
- },
1810
- fromPartial(object) {
1811
- const message = createBaseTimestamp();
1812
- message.seconds = object.seconds ?? 0;
1813
- message.nanos = object.nanos ?? 0;
1814
- return message;
1815
- }
1816
- };
1817
- function longToNumber(int64) {
1818
- const num = globalThis.Number(int64.toString());
1819
- if (num > globalThis.Number.MAX_SAFE_INTEGER) {
1820
- throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
1821
- }
1822
- if (num < globalThis.Number.MIN_SAFE_INTEGER) {
1823
- throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
1824
- }
1825
- return num;
1826
- }
1827
- function isSet2(value) {
1828
- return value !== null && value !== void 0;
1829
- }
1830
-
1831
1894
  // src/proto/spark.ts
1832
1895
  var Network = /* @__PURE__ */ ((Network5) => {
1833
1896
  Network5[Network5["UNSPECIFIED"] = 0] = "UNSPECIFIED";
@@ -15839,9 +15902,6 @@ function uint64be(value) {
15839
15902
  }
15840
15903
 
15841
15904
  // src/utils/address.ts
15842
- var import_uuidv7 = require("uuidv7");
15843
- var import_utils3 = require("@noble/curves/abstract/utils");
15844
- var import_wire5 = require("@bufbuild/protobuf/wire");
15845
15905
  var BECH32M_LIMIT = 1024;
15846
15906
  var AddressNetwork = {
15847
15907
  MAINNET: "sp",
@@ -15856,7 +15916,7 @@ function encodeSparkAddress(payload) {
15856
15916
  function encodeSparkAddressWithSignature(payload, signature) {
15857
15917
  try {
15858
15918
  isValidPublicKey(payload.identityPublicKey);
15859
- const identityPublicKey = (0, import_utils2.hexToBytes)(payload.identityPublicKey);
15919
+ const identityPublicKey = (0, import_utils3.hexToBytes)(payload.identityPublicKey);
15860
15920
  let sparkInvoiceFields;
15861
15921
  if (payload.sparkInvoiceFields) {
15862
15922
  validateSparkInvoiceFields(payload.sparkInvoiceFields);
@@ -15900,8 +15960,8 @@ function decodeSparkAddress(address2, network) {
15900
15960
  }
15901
15961
  const payload = SparkAddress.decode(import_base2.bech32m.fromWords(decoded.words));
15902
15962
  const { identityPublicKey, sparkInvoiceFields, signature } = payload;
15903
- const identityPubkeyHex = (0, import_utils2.bytesToHex)(identityPublicKey);
15904
- const signatureHex = signature ? (0, import_utils2.bytesToHex)(signature) : void 0;
15963
+ const identityPubkeyHex = (0, import_utils3.bytesToHex)(identityPublicKey);
15964
+ const signatureHex = signature ? (0, import_utils3.bytesToHex)(signature) : void 0;
15905
15965
  isValidPublicKey(identityPubkeyHex);
15906
15966
  return {
15907
15967
  identityPublicKey: identityPubkeyHex,
@@ -15911,10 +15971,10 @@ function decodeSparkAddress(address2, network) {
15911
15971
  id: import_uuidv7.UUID.ofInner(sparkInvoiceFields.id).toString(),
15912
15972
  paymentType: sparkInvoiceFields.paymentType ? sparkInvoiceFields.paymentType.$case === "tokensPayment" ? {
15913
15973
  type: "tokens",
15914
- tokenIdentifier: sparkInvoiceFields.paymentType.tokensPayment.tokenIdentifier ? (0, import_utils2.bytesToHex)(
15974
+ tokenIdentifier: sparkInvoiceFields.paymentType.tokensPayment.tokenIdentifier ? (0, import_utils3.bytesToHex)(
15915
15975
  sparkInvoiceFields.paymentType.tokensPayment.tokenIdentifier
15916
15976
  ) : void 0,
15917
- amount: sparkInvoiceFields.paymentType.tokensPayment.amount ? (0, import_utils3.bytesToNumberBE)(
15977
+ amount: sparkInvoiceFields.paymentType.tokensPayment.amount ? (0, import_utils2.bytesToNumberBE)(
15918
15978
  sparkInvoiceFields.paymentType.tokensPayment.amount
15919
15979
  ) : void 0
15920
15980
  } : sparkInvoiceFields.paymentType.$case === "satsPayment" ? {
@@ -15922,7 +15982,7 @@ function decodeSparkAddress(address2, network) {
15922
15982
  amount: sparkInvoiceFields.paymentType.satsPayment.amount
15923
15983
  } : void 0 : void 0,
15924
15984
  memo: sparkInvoiceFields.memo,
15925
- senderPublicKey: sparkInvoiceFields.senderPublicKey ? (0, import_utils2.bytesToHex)(sparkInvoiceFields.senderPublicKey) : void 0,
15985
+ senderPublicKey: sparkInvoiceFields.senderPublicKey ? (0, import_utils3.bytesToHex)(sparkInvoiceFields.senderPublicKey) : void 0,
15926
15986
  expiryTime: sparkInvoiceFields.expiryTime
15927
15987
  },
15928
15988
  signature: signatureHex
@@ -15971,7 +16031,7 @@ function isValidSparkAddress(address2) {
15971
16031
  }
15972
16032
  function isValidPublicKey(publicKey) {
15973
16033
  try {
15974
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex(publicKey);
16034
+ const point = import_secp256k1.secp256k1.Point.fromHex(publicKey);
15975
16035
  point.assertValidity();
15976
16036
  } catch (error) {
15977
16037
  throw new ValidationError(
@@ -16006,7 +16066,7 @@ function validateSparkInvoiceFields(sparkInvoiceFields) {
16006
16066
  }
16007
16067
  if (senderPublicKey) {
16008
16068
  try {
16009
- isValidPublicKey((0, import_utils2.bytesToHex)(senderPublicKey));
16069
+ isValidPublicKey((0, import_utils3.bytesToHex)(senderPublicKey));
16010
16070
  } catch (error) {
16011
16071
  throw new ValidationError(
16012
16072
  "Invalid sender public key",
@@ -16057,7 +16117,7 @@ function validateSparkInvoiceFields(sparkInvoiceFields) {
16057
16117
  value: tokensAmount
16058
16118
  });
16059
16119
  }
16060
- const tokensAmountBigInt = (0, import_utils3.bytesToNumberBE)(tokensAmount);
16120
+ const tokensAmountBigInt = (0, import_utils2.bytesToNumberBE)(tokensAmount);
16061
16121
  if (tokensAmountBigInt < 0 || tokensAmountBigInt > MAX_UINT128) {
16062
16122
  throw new ValidationError(
16063
16123
  "Asset amount must be between 0 and MAX_UINT128",
@@ -16269,7 +16329,7 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
16269
16329
  const commitmenet = import_secp256k12.schnorr.utils.taggedHash(
16270
16330
  "BIP0340/challenge",
16271
16331
  r,
16272
- pubKey.toRawBytes().slice(1),
16332
+ pubKey.toBytes().slice(1),
16273
16333
  hash
16274
16334
  );
16275
16335
  if (commitmenet.length > 32) {
@@ -16277,22 +16337,20 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
16277
16337
  }
16278
16338
  const e = (0, import_modular.mod)((0, import_utils4.bytesToNumberBE)(commitmenet), import_secp256k12.secp256k1.CURVE.n);
16279
16339
  const negE = (0, import_modular.mod)(-e, import_secp256k12.secp256k1.CURVE.n);
16280
- const R = import_secp256k12.secp256k1.ProjectivePoint.BASE.multiplyAndAddUnsafe(
16281
- pubKey,
16282
- (0, import_utils4.bytesToNumberBE)(s),
16283
- negE
16284
- );
16285
- if (!R) {
16286
- throw new Error("R is undefined");
16340
+ const sG = import_secp256k12.secp256k1.Point.BASE.multiplyUnsafe((0, import_utils4.bytesToNumberBE)(s));
16341
+ const eP = pubKey.multiplyUnsafe(negE);
16342
+ const R = sG.add(eP);
16343
+ if (R.is0()) {
16344
+ throw new Error("R is zero");
16287
16345
  }
16288
16346
  R.assertValidity();
16289
- const adaptorPoint = import_secp256k12.secp256k1.ProjectivePoint.fromHex(adaptorPubkey);
16347
+ const adaptorPoint = import_secp256k12.secp256k1.Point.fromHex(adaptorPubkey);
16290
16348
  const newR = R.add(adaptorPoint);
16291
- if (!inbound && newR.equals(import_secp256k12.secp256k1.ProjectivePoint.ZERO)) {
16349
+ if (!inbound && newR.equals(import_secp256k12.secp256k1.Point.ZERO)) {
16292
16350
  throw new Error("calculated R point is the point at infinity");
16293
16351
  }
16294
16352
  newR.assertValidity();
16295
- if (!newR.hasEvenY()) {
16353
+ if (newR.y % 2n !== 0n) {
16296
16354
  throw new Error("calculated R y-value is odd");
16297
16355
  }
16298
16356
  const rNum = (0, import_utils4.bytesToNumberBE)(r);
@@ -16442,8 +16500,8 @@ function computeTaprootKeyNoScript(pubkey) {
16442
16500
  const taggedHash = import_secp256k13.schnorr.utils.taggedHash("TapTweak", pubkey);
16443
16501
  const tweak = (0, import_utils5.bytesToNumberBE)(taggedHash);
16444
16502
  const P = import_secp256k13.schnorr.utils.lift_x(import_secp256k13.schnorr.utils.bytesToNumberBE(pubkey));
16445
- const Q = P.add(import_secp256k13.secp256k1.ProjectivePoint.fromPrivateKey(tweak));
16446
- return Q.toRawBytes();
16503
+ const Q = P.add(import_secp256k13.secp256k1.Point.fromPrivateKey(tweak));
16504
+ return Q.toBytes();
16447
16505
  }
16448
16506
  function getP2TRScriptFromPublicKey(pubKey, network) {
16449
16507
  if (pubKey.length !== 33) {
@@ -16453,9 +16511,9 @@ function getP2TRScriptFromPublicKey(pubKey, network) {
16453
16511
  expected: 33
16454
16512
  });
16455
16513
  }
16456
- const internalKey = import_secp256k13.secp256k1.ProjectivePoint.fromHex(pubKey);
16514
+ const internalKey = import_secp256k13.secp256k1.Point.fromHex(pubKey);
16457
16515
  const script = btc2.p2tr(
16458
- internalKey.toRawBytes().slice(1, 33),
16516
+ internalKey.toBytes().slice(1, 33),
16459
16517
  void 0,
16460
16518
  getNetwork(network)
16461
16519
  ).script;
@@ -16475,9 +16533,9 @@ function getP2TRAddressFromPublicKey(pubKey, network) {
16475
16533
  expected: 33
16476
16534
  });
16477
16535
  }
16478
- const internalKey = import_secp256k13.secp256k1.ProjectivePoint.fromHex(pubKey);
16536
+ const internalKey = import_secp256k13.secp256k1.Point.fromHex(pubKey);
16479
16537
  const address2 = btc2.p2tr(
16480
- internalKey.toRawBytes().slice(1, 33),
16538
+ internalKey.toBytes().slice(1, 33),
16481
16539
  void 0,
16482
16540
  getNetwork(network)
16483
16541
  ).address;
@@ -16589,9 +16647,9 @@ function addPublicKeys(a, b) {
16589
16647
  expected: 33
16590
16648
  });
16591
16649
  }
16592
- const pubkeyA = import_secp256k14.secp256k1.ProjectivePoint.fromHex(a);
16593
- const pubkeyB = import_secp256k14.secp256k1.ProjectivePoint.fromHex(b);
16594
- return pubkeyA.add(pubkeyB).toRawBytes(true);
16650
+ const pubkeyA = import_secp256k14.secp256k1.Point.fromHex(a);
16651
+ const pubkeyB = import_secp256k14.secp256k1.Point.fromHex(b);
16652
+ return pubkeyA.add(pubkeyB).toBytes(true);
16595
16653
  }
16596
16654
  function applyAdditiveTweakToPublicKey(pubkey, tweak) {
16597
16655
  if (pubkey.length !== 33) {
@@ -16608,11 +16666,11 @@ function applyAdditiveTweakToPublicKey(pubkey, tweak) {
16608
16666
  expected: 32
16609
16667
  });
16610
16668
  }
16611
- const pubkeyPoint = import_secp256k14.secp256k1.ProjectivePoint.fromHex(pubkey);
16669
+ const pubkeyPoint = import_secp256k14.secp256k1.Point.fromHex(pubkey);
16612
16670
  const privTweek = import_secp256k14.secp256k1.utils.normPrivateKeyToScalar(tweak);
16613
16671
  const pubTweek = import_secp256k14.secp256k1.getPublicKey(privTweek, true);
16614
- const tweekPoint = import_secp256k14.secp256k1.ProjectivePoint.fromHex(pubTweek);
16615
- return pubkeyPoint.add(tweekPoint).toRawBytes(true);
16672
+ const tweekPoint = import_secp256k14.secp256k1.Point.fromHex(pubTweek);
16673
+ return pubkeyPoint.add(tweekPoint).toBytes(true);
16616
16674
  }
16617
16675
  function subtractPublicKeys(a, b) {
16618
16676
  if (a.length !== 33 || b.length !== 33) {
@@ -16622,9 +16680,9 @@ function subtractPublicKeys(a, b) {
16622
16680
  expected: 33
16623
16681
  });
16624
16682
  }
16625
- const pubkeyA = import_secp256k14.secp256k1.ProjectivePoint.fromHex(a);
16626
- const pubkeyB = import_secp256k14.secp256k1.ProjectivePoint.fromHex(b);
16627
- return pubkeyA.subtract(pubkeyB).toRawBytes(true);
16683
+ const pubkeyA = import_secp256k14.secp256k1.Point.fromHex(a);
16684
+ const pubkeyB = import_secp256k14.secp256k1.Point.fromHex(b);
16685
+ return pubkeyA.subtract(pubkeyB).toBytes(true);
16628
16686
  }
16629
16687
  function addPrivateKeys(a, b) {
16630
16688
  if (a.length !== 32 || b.length !== 32) {
@@ -18075,11 +18133,11 @@ function generatePolynomialForSecretSharing(fieldModulus, secret, degree) {
18075
18133
  const coefficients = new Array(degree);
18076
18134
  const proofs = new Array(degree);
18077
18135
  coefficients[0] = secret;
18078
- proofs[0] = import_secp256k15.secp256k1.ProjectivePoint.fromPrivateKey(secret).toRawBytes(true);
18136
+ proofs[0] = import_secp256k15.secp256k1.Point.fromPrivateKey(secret).toBytes(true);
18079
18137
  for (let i = 1; i < degree; i++) {
18080
18138
  const coefficient = getRandomBigInt(fieldModulus);
18081
18139
  coefficients[i] = coefficient;
18082
- proofs[i] = import_secp256k15.secp256k1.ProjectivePoint.fromPrivateKey(coefficient).toRawBytes(true);
18140
+ proofs[i] = import_secp256k15.secp256k1.Point.fromPrivateKey(coefficient).toBytes(true);
18083
18141
  }
18084
18142
  return {
18085
18143
  fieldModulus,
@@ -18151,9 +18209,9 @@ function recoverSecret(shares) {
18151
18209
  return result;
18152
18210
  }
18153
18211
  function validateShare(share) {
18154
- const targetPubkey = import_secp256k15.secp256k1.ProjectivePoint.fromPrivateKey(
18155
- share.share
18156
- ).toRawBytes(true);
18212
+ const targetPubkey = import_secp256k15.secp256k1.Point.fromPrivateKey(share.share).toBytes(
18213
+ true
18214
+ );
18157
18215
  let resultPubkey = share.proofs[0];
18158
18216
  if (!resultPubkey) {
18159
18217
  throw new ValidationError("Result pubkey is not valid", {
@@ -18172,8 +18230,8 @@ function validateShare(share) {
18172
18230
  });
18173
18231
  }
18174
18232
  const value = share.index ** BigInt(i) % share.fieldModulus;
18175
- const scaledPoint = import_secp256k15.secp256k1.ProjectivePoint.fromHex(pubkey).multiply(value);
18176
- resultPubkey = import_secp256k15.secp256k1.ProjectivePoint.fromHex(resultPubkey).add(scaledPoint).toRawBytes(true);
18233
+ const scaledPoint = import_secp256k15.secp256k1.Point.fromHex(pubkey).multiply(value);
18234
+ resultPubkey = import_secp256k15.secp256k1.Point.fromHex(resultPubkey).add(scaledPoint).toBytes(true);
18177
18235
  }
18178
18236
  if (!(0, import_utils8.equalBytes)(resultPubkey, targetPubkey)) {
18179
18237
  throw new ValidationError("Share is not valid", {
@@ -19284,33 +19342,36 @@ function getSparkAddressFromTaproot(taprootAddress) {
19284
19342
  throw new ValidationError("Invalid taproot address");
19285
19343
  }
19286
19344
 
19345
+ // src/utils/index.ts
19346
+ init_logging();
19347
+
19287
19348
  // src/signer/signer.ts
19288
19349
  init_buffer();
19289
19350
  var import_secp256k17 = require("@bitcoinerlab/secp256k1");
19290
- var import_utils13 = require("@noble/curves/abstract/utils");
19351
+ var import_utils14 = require("@noble/curves/abstract/utils");
19291
19352
  var import_secp256k18 = require("@noble/curves/secp256k1");
19292
19353
  var import_sha26 = require("@noble/hashes/sha2");
19293
19354
  var import_bip32 = require("@scure/bip32");
19294
19355
  var import_bip39 = require("@scure/bip39");
19295
19356
  var import_english = require("@scure/bip39/wordlists/english");
19296
- var import_utils14 = require("@scure/btc-signer/utils");
19357
+ var import_utils15 = require("@scure/btc-signer/utils");
19297
19358
  var ecies = __toESM(require("eciesjs"), 1);
19298
19359
 
19299
19360
  // src/constants.ts
19300
19361
  init_buffer();
19301
- var import_core8 = require("@lightsparkdev/core");
19362
+ var import_core9 = require("@lightsparkdev/core");
19302
19363
  var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
19303
19364
  var isBun = globalThis.Bun !== void 0;
19304
- var packageVersion = true ? "0.2.9" : "unknown";
19365
+ var packageVersion = true ? "0.2.11" : "unknown";
19305
19366
  var baseEnvStr = "unknown";
19306
19367
  if (isBun) {
19307
19368
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
19308
19369
  baseEnvStr = `bun/${bunVersion}`;
19309
- } else if (import_core8.isNode) {
19370
+ } else if (import_core9.isNode) {
19310
19371
  baseEnvStr = `node/${process.version}`;
19311
19372
  } else if (isReactNative) {
19312
19373
  baseEnvStr = "react-native";
19313
- } else if (import_core8.isBare) {
19374
+ } else if (import_core9.isBare) {
19314
19375
  const bareVersion = Bare.version;
19315
19376
  baseEnvStr = `bare/${bareVersion}`;
19316
19377
  } else {
@@ -19399,7 +19460,7 @@ var TaprootOutputKeysGenerator = class {
19399
19460
  }
19400
19461
  const derivationPath = this.useAddressIndex ? `m/86'/0'/0'/0/${accountNumber}` : `m/86'/0'/${accountNumber}'/0/0`;
19401
19462
  const taprootInternalKey = hdkey.derive(derivationPath);
19402
- let tweakedPrivateKey = (0, import_utils14.taprootTweakPrivKey)(taprootInternalKey.privateKey);
19463
+ let tweakedPrivateKey = (0, import_utils15.taprootTweakPrivKey)(taprootInternalKey.privateKey);
19403
19464
  let tweakedPublicKey = import_secp256k18.secp256k1.getPublicKey(tweakedPrivateKey);
19404
19465
  if (tweakedPublicKey[0] === 3) {
19405
19466
  tweakedPrivateKey = (0, import_secp256k17.privateNegate)(tweakedPrivateKey);
@@ -19477,7 +19538,7 @@ var DefaultSparkSigner = class {
19477
19538
  });
19478
19539
  }
19479
19540
  const receiverEciesPrivKey = ecies.PrivateKey.fromHex(
19480
- (0, import_utils13.bytesToHex)(this.identityKey.privateKey)
19541
+ (0, import_utils14.bytesToHex)(this.identityKey.privateKey)
19481
19542
  );
19482
19543
  const privateKey = ecies.decrypt(receiverEciesPrivKey.toHex(), ciphertext);
19483
19544
  return privateKey;
@@ -19611,7 +19672,7 @@ var DefaultSparkSigner = class {
19611
19672
  threshold,
19612
19673
  numShares
19613
19674
  }) {
19614
- const secretAsInt = (0, import_utils13.bytesToNumberBE)(secret);
19675
+ const secretAsInt = (0, import_utils14.bytesToNumberBE)(secret);
19615
19676
  return splitSecretWithProofs(secretAsInt, curveOrder, threshold, numShares);
19616
19677
  }
19617
19678
  async signFrost({
@@ -19647,7 +19708,7 @@ var DefaultSparkSigner = class {
19647
19708
  publicKey,
19648
19709
  verifyingKey
19649
19710
  };
19650
- const logMessage = (0, import_utils13.bytesToHex)(message);
19711
+ const logMessage = (0, import_utils14.bytesToHex)(message);
19651
19712
  const result = await SparkFrost.signFrost({
19652
19713
  message,
19653
19714
  keyPackage,
@@ -19689,7 +19750,7 @@ var DefaultSparkSigner = class {
19689
19750
  }
19690
19751
  async createSparkWalletFromSeed(seed, accountNumber) {
19691
19752
  if (typeof seed === "string") {
19692
- seed = (0, import_utils13.hexToBytes)(seed);
19753
+ seed = (0, import_utils14.hexToBytes)(seed);
19693
19754
  }
19694
19755
  const {
19695
19756
  identityKey,
@@ -19701,7 +19762,7 @@ var DefaultSparkSigner = class {
19701
19762
  this.depositKey = depositKey;
19702
19763
  this.signingKey = signingKey.hdKey;
19703
19764
  this.staticDepositKey = staticDepositKey.hdKey;
19704
- return (0, import_utils13.bytesToHex)(identityKey.publicKey);
19765
+ return (0, import_utils14.bytesToHex)(identityKey.publicKey);
19705
19766
  }
19706
19767
  async signMessageWithIdentityKey(message, compact) {
19707
19768
  if (!this.identityKey?.privateKey) {
@@ -19722,7 +19783,7 @@ var DefaultSparkSigner = class {
19722
19783
  });
19723
19784
  }
19724
19785
  const receiverEciesPrivKey = ecies.PrivateKey.fromHex(
19725
- (0, import_utils13.bytesToHex)(this.identityKey.privateKey)
19786
+ (0, import_utils14.bytesToHex)(this.identityKey.privateKey)
19726
19787
  );
19727
19788
  const privateKey = ecies.decrypt(receiverEciesPrivKey.toHex(), ciphertext);
19728
19789
  const publicKey = import_secp256k18.secp256k1.getPublicKey(privateKey);
@@ -19746,15 +19807,15 @@ var DefaultSparkSigner = class {
19746
19807
  }
19747
19808
  signTransactionIndex(tx, index, publicKey) {
19748
19809
  let privateKey;
19749
- if ((0, import_utils13.equalBytes)(publicKey, this.identityKey?.publicKey ?? new Uint8Array())) {
19810
+ if ((0, import_utils14.equalBytes)(publicKey, this.identityKey?.publicKey ?? new Uint8Array())) {
19750
19811
  privateKey = this.identityKey?.privateKey;
19751
- } else if ((0, import_utils13.equalBytes)(publicKey, this.depositKey?.publicKey ?? new Uint8Array())) {
19812
+ } else if ((0, import_utils14.equalBytes)(publicKey, this.depositKey?.publicKey ?? new Uint8Array())) {
19752
19813
  privateKey = this.depositKey?.privateKey;
19753
19814
  }
19754
19815
  if (!privateKey) {
19755
19816
  throw new ValidationError("Private key not found for public key", {
19756
19817
  field: "privateKey",
19757
- value: (0, import_utils13.bytesToHex)(publicKey)
19818
+ value: (0, import_utils14.bytesToHex)(publicKey)
19758
19819
  });
19759
19820
  }
19760
19821
  tx.signIdx(privateKey, index);
@@ -19831,8 +19892,8 @@ init_buffer();
19831
19892
 
19832
19893
  // src/spark-wallet/spark-wallet.ts
19833
19894
  init_buffer();
19834
- var import_core12 = require("@lightsparkdev/core");
19835
- var import_utils24 = require("@noble/curves/abstract/utils");
19895
+ var import_core13 = require("@lightsparkdev/core");
19896
+ var import_utils25 = require("@noble/curves/abstract/utils");
19836
19897
  var import_secp256k115 = require("@noble/curves/secp256k1");
19837
19898
  var import_bip392 = require("@scure/bip39");
19838
19899
  var import_english2 = require("@scure/bip39/wordlists/english");
@@ -19842,7 +19903,7 @@ var import_uuidv75 = require("uuidv7");
19842
19903
 
19843
19904
  // src/graphql/client.ts
19844
19905
  init_buffer();
19845
- var import_core10 = require("@lightsparkdev/core");
19906
+ var import_core11 = require("@lightsparkdev/core");
19846
19907
  var import_sha27 = require("@noble/hashes/sha2");
19847
19908
 
19848
19909
  // src/graphql/mutations/ClaimStaticDeposit.ts
@@ -19896,7 +19957,7 @@ init_buffer();
19896
19957
 
19897
19958
  // src/graphql/objects/CoopExitRequest.ts
19898
19959
  init_buffer();
19899
- var import_core9 = require("@lightsparkdev/core");
19960
+ var import_core10 = require("@lightsparkdev/core");
19900
19961
  var CoopExitRequestFromJson = (obj) => {
19901
19962
  return {
19902
19963
  id: obj["coop_exit_request_id"],
@@ -20477,13 +20538,13 @@ var SspClient = class {
20477
20538
  this.authProvider = new SparkAuthProvider();
20478
20539
  const { fetch } = getFetch();
20479
20540
  const options = config.sspClientOptions;
20480
- this.requester = new import_core10.Requester(
20481
- new import_core10.NodeKeyCache(import_core10.DefaultCrypto),
20541
+ this.requester = new import_core11.Requester(
20542
+ new import_core11.NodeKeyCache(import_core11.DefaultCrypto),
20482
20543
  options.schemaEndpoint || `graphql/spark/2025-03-19`,
20483
20544
  `spark-sdk/0.0.0`,
20484
20545
  this.authProvider,
20485
20546
  options.baseUrl,
20486
- import_core10.DefaultCrypto,
20547
+ import_core11.DefaultCrypto,
20487
20548
  void 0,
20488
20549
  fetch
20489
20550
  );
@@ -20858,7 +20919,7 @@ var SspClient = class {
20858
20919
  {
20859
20920
  queryPayload: GetChallenge,
20860
20921
  variables: {
20861
- public_key: (0, import_core10.bytesToHex)(await this.signer.getIdentityPublicKey())
20922
+ public_key: (0, import_core11.bytesToHex)(await this.signer.getIdentityPublicKey())
20862
20923
  },
20863
20924
  constructObject: (response) => {
20864
20925
  return GetChallengeOutputFromJson(response.get_challenge);
@@ -20874,7 +20935,7 @@ var SspClient = class {
20874
20935
  variables: {
20875
20936
  protected_challenge: protectedChallenge,
20876
20937
  signature,
20877
- identity_public_key: (0, import_core10.bytesToHex)(
20938
+ identity_public_key: (0, import_core11.bytesToHex)(
20878
20939
  await this.signer.getIdentityPublicKey()
20879
20940
  )
20880
20941
  },
@@ -20919,7 +20980,7 @@ var SspClient = class {
20919
20980
  );
20920
20981
  return;
20921
20982
  } catch (err) {
20922
- if ((0, import_core10.isError)(err) && err.message.toLowerCase().includes("challenge expired")) {
20983
+ if ((0, import_core11.isError)(err) && err.message.toLowerCase().includes("challenge expired")) {
20923
20984
  lastErr = err;
20924
20985
  continue;
20925
20986
  }
@@ -21086,7 +21147,7 @@ var WalletConfigService = class {
21086
21147
 
21087
21148
  // src/services/connection.ts
21088
21149
  init_buffer();
21089
- var import_core11 = require("@lightsparkdev/core");
21150
+ var import_core12 = require("@lightsparkdev/core");
21090
21151
  var import_sha28 = require("@noble/hashes/sha2");
21091
21152
  var import_nice_grpc_client_middleware_retry = require("nice-grpc-client-middleware-retry");
21092
21153
  var import_nice_grpc_common2 = require("nice-grpc-common");
@@ -24844,7 +24905,7 @@ var ConnectionManager = class {
24844
24905
  async createMockClient(address2) {
24845
24906
  const channel = await this.createChannelWithTLS(address2);
24846
24907
  const isNodeChannel = "close" in channel;
24847
- if (import_core11.isNode && isNodeChannel && !isBun) {
24908
+ if (import_core12.isNode && isNodeChannel && !isBun) {
24848
24909
  const grpcModule = await import("nice-grpc");
24849
24910
  const { createClient } = "default" in grpcModule ? grpcModule.default : grpcModule;
24850
24911
  const client = createClient(MockServiceDefinition, channel);
@@ -24861,7 +24922,7 @@ var ConnectionManager = class {
24861
24922
  }
24862
24923
  async createChannelWithTLS(address2, certPath) {
24863
24924
  try {
24864
- if (import_core11.isNode && !isBun) {
24925
+ if (import_core12.isNode && !isBun) {
24865
24926
  const grpcModule = await import("nice-grpc");
24866
24927
  const { ChannelCredentials, createChannel } = "default" in grpcModule ? grpcModule.default : grpcModule;
24867
24928
  if (certPath) {
@@ -24892,7 +24953,7 @@ var ConnectionManager = class {
24892
24953
  const { XHRTransport: XHRTransport2 } = await Promise.resolve().then(() => (init_xhr_transport(), xhr_transport_exports));
24893
24954
  return createChannel(
24894
24955
  address2,
24895
- import_core11.isBare ? (0, import_nice_grpc_web.NodeHttpTransport)() : isReactNative ? XHRTransport2() : FetchTransport()
24956
+ import_core12.isBare ? (0, import_nice_grpc_web.NodeHttpTransport)() : isReactNative ? XHRTransport2() : FetchTransport()
24896
24957
  );
24897
24958
  }
24898
24959
  } catch (error) {
@@ -24998,7 +25059,7 @@ var ConnectionManager = class {
24998
25059
  sparkAuthnClient.close?.();
24999
25060
  return verifyResp.sessionToken;
25000
25061
  } catch (error) {
25001
- if ((0, import_core11.isError)(error)) {
25062
+ if ((0, import_core12.isError)(error)) {
25002
25063
  sparkAuthnClient?.close?.();
25003
25064
  if (error.message.includes("challenge expired")) {
25004
25065
  console.warn(
@@ -25049,7 +25110,7 @@ var ConnectionManager = class {
25049
25110
  );
25050
25111
  }
25051
25112
  createAuthnMiddleware() {
25052
- if (import_core11.isNode) {
25113
+ if (import_core12.isNode) {
25053
25114
  return async function* (call, options) {
25054
25115
  const metadata = (0, import_nice_grpc_common2.Metadata)(options.metadata).set(
25055
25116
  "X-Client-Env",
@@ -25071,14 +25132,14 @@ var ConnectionManager = class {
25071
25132
  }
25072
25133
  }
25073
25134
  createMiddleware(address2, authToken) {
25074
- if (import_core11.isNode) {
25135
+ if (import_core12.isNode) {
25075
25136
  return this.createNodeMiddleware(address2, authToken);
25076
25137
  } else {
25077
25138
  return this.createBrowserMiddleware(address2, authToken);
25078
25139
  }
25079
25140
  }
25080
25141
  async *handleMiddlewareError(error, address2, call, metadata, options) {
25081
- if ((0, import_core11.isError)(error)) {
25142
+ if ((0, import_core12.isError)(error)) {
25082
25143
  if (error.message.includes("token has expired")) {
25083
25144
  const newAuthToken = await this.authenticate(address2);
25084
25145
  const clientData = this.clients.get(address2);
@@ -25149,7 +25210,7 @@ var ConnectionManager = class {
25149
25210
  };
25150
25211
  let options = {};
25151
25212
  const isNodeChannel = "close" in channel;
25152
- if (import_core11.isNode && isNodeChannel && !isBun) {
25213
+ if (import_core12.isNode && isNodeChannel && !isBun) {
25153
25214
  const grpcModule = await import("nice-grpc");
25154
25215
  const { openTelemetryClientMiddleware } = await import("nice-grpc-opentelemetry");
25155
25216
  const { createClientFactory } = "default" in grpcModule ? grpcModule.default : grpcModule;
@@ -25199,7 +25260,7 @@ var import_uuidv73 = require("uuidv7");
25199
25260
 
25200
25261
  // src/services/transfer.ts
25201
25262
  init_buffer();
25202
- var import_utils15 = require("@noble/curves/abstract/utils");
25263
+ var import_utils16 = require("@noble/curves/abstract/utils");
25203
25264
  var import_secp256k19 = require("@noble/curves/secp256k1");
25204
25265
  var import_sha29 = require("@noble/hashes/sha2");
25205
25266
  var import_btc_signer2 = require("@scure/btc-signer");
@@ -25570,7 +25631,7 @@ var BaseTransferService = class {
25570
25631
  }
25571
25632
  async prepareSendTransferKeyTweaks(transferID, receiverIdentityPubkey, leaves, cpfpRefundSignatureMap, directRefundSignatureMap, directFromCpfpRefundSignatureMap) {
25572
25633
  const receiverEciesPubKey = ecies2.PublicKey.fromHex(
25573
- (0, import_utils15.bytesToHex)(receiverIdentityPubkey)
25634
+ (0, import_utils16.bytesToHex)(receiverIdentityPubkey)
25574
25635
  );
25575
25636
  const leavesTweaksMap = /* @__PURE__ */ new Map();
25576
25637
  for (const leaf of leaves) {
@@ -25611,7 +25672,7 @@ var BaseTransferService = class {
25611
25672
  throw new Error(`Share not found for operator ${operator.id}`);
25612
25673
  }
25613
25674
  const pubkeyTweak = import_secp256k19.secp256k1.getPublicKey(
25614
- (0, import_utils15.numberToBytesBE)(share.share, 32),
25675
+ (0, import_utils16.numberToBytesBE)(share.share, 32),
25615
25676
  true
25616
25677
  );
25617
25678
  pubkeySharesTweak.set(identifier, pubkeyTweak);
@@ -25636,7 +25697,7 @@ var BaseTransferService = class {
25636
25697
  leafTweaksMap.set(identifier, {
25637
25698
  leafId: leaf.leaf.id,
25638
25699
  secretShareTweak: {
25639
- secretShare: (0, import_utils15.numberToBytesBE)(share.share, 32),
25700
+ secretShare: (0, import_utils16.numberToBytesBE)(share.share, 32),
25640
25701
  proofs: share.proofs
25641
25702
  },
25642
25703
  pubkeySharesTweak: Object.fromEntries(pubkeySharesTweak),
@@ -25659,7 +25720,7 @@ var BaseTransferService = class {
25659
25720
  return void 0;
25660
25721
  }
25661
25722
  compareTransfers(transfer1, transfer2) {
25662
- return transfer1.id === transfer2.id && (0, import_utils15.equalBytes)(
25723
+ return transfer1.id === transfer2.id && (0, import_utils16.equalBytes)(
25663
25724
  transfer1.senderIdentityPublicKey,
25664
25725
  transfer2.senderIdentityPublicKey
25665
25726
  ) && transfer1.status === transfer2.status && transfer1.totalValue === transfer2.totalValue && transfer1.expiryTime?.getTime() === transfer2.expiryTime?.getTime() && transfer1.leaves.length === transfer2.leaves.length;
@@ -25958,7 +26019,7 @@ var TransferService = class extends BaseTransferService {
25958
26019
  }
25959
26020
  const nodeTx = getTxFromRawTxBytes(leaf.leaf.nodeTx);
25960
26021
  const cpfpNodeOutPoint = {
25961
- txid: (0, import_utils15.hexToBytes)(getTxId(nodeTx)),
26022
+ txid: (0, import_utils16.hexToBytes)(getTxId(nodeTx)),
25962
26023
  index: 0
25963
26024
  };
25964
26025
  let directNodeTx;
@@ -25966,7 +26027,7 @@ var TransferService = class extends BaseTransferService {
25966
26027
  if (leaf.leaf.directTx.length > 0) {
25967
26028
  directNodeTx = getTxFromRawTxBytes(leaf.leaf.directTx);
25968
26029
  directNodeOutPoint = {
25969
- txid: (0, import_utils15.hexToBytes)(getTxId(directNodeTx)),
26030
+ txid: (0, import_utils16.hexToBytes)(getTxId(directNodeTx)),
25970
26031
  index: 0
25971
26032
  };
25972
26033
  }
@@ -26100,7 +26161,7 @@ var TransferService = class extends BaseTransferService {
26100
26161
  throw new Error(`Share not found for operator ${operator.id}`);
26101
26162
  }
26102
26163
  const pubkeyTweak = import_secp256k19.secp256k1.getPublicKey(
26103
- (0, import_utils15.numberToBytesBE)(share.share, 32)
26164
+ (0, import_utils16.numberToBytesBE)(share.share, 32)
26104
26165
  );
26105
26166
  pubkeySharesTweak.set(identifier, pubkeyTweak);
26106
26167
  }
@@ -26113,7 +26174,7 @@ var TransferService = class extends BaseTransferService {
26113
26174
  leafTweaksMap.set(identifier, {
26114
26175
  leafId: leaf.leaf.id,
26115
26176
  secretShareTweak: {
26116
- secretShare: (0, import_utils15.numberToBytesBE)(share.share, 32),
26177
+ secretShare: (0, import_utils16.numberToBytesBE)(share.share, 32),
26117
26178
  proofs: share.proofs
26118
26179
  },
26119
26180
  pubkeySharesTweak: Object.fromEntries(pubkeySharesTweak)
@@ -26299,13 +26360,13 @@ var TransferService = class extends BaseTransferService {
26299
26360
  });
26300
26361
  }
26301
26362
  const newCpfpRefundOutPoint = {
26302
- txid: (0, import_utils15.hexToBytes)(getTxId(cpfpNodeTx)),
26363
+ txid: (0, import_utils16.hexToBytes)(getTxId(cpfpNodeTx)),
26303
26364
  index: 0
26304
26365
  };
26305
26366
  let newDirectRefundOutPoint;
26306
26367
  if (newDirectNodeTx) {
26307
26368
  newDirectRefundOutPoint = {
26308
- txid: (0, import_utils15.hexToBytes)(getTxId(newDirectNodeTx)),
26369
+ txid: (0, import_utils16.hexToBytes)(getTxId(newDirectNodeTx)),
26309
26370
  index: 0
26310
26371
  };
26311
26372
  }
@@ -26433,7 +26494,7 @@ var TransferService = class extends BaseTransferService {
26433
26494
  const refundTx = getTxFromRawTxBytes(node.refundTx);
26434
26495
  const refundSequence = refundTx.getInput(0).sequence || 0;
26435
26496
  const newNodeOutPoint = {
26436
- txid: (0, import_utils15.hexToBytes)(getTxId(nodeTx)),
26497
+ txid: (0, import_utils16.hexToBytes)(getTxId(nodeTx)),
26437
26498
  index: 0
26438
26499
  };
26439
26500
  const {
@@ -26470,13 +26531,13 @@ var TransferService = class extends BaseTransferService {
26470
26531
  });
26471
26532
  }
26472
26533
  const newCpfpRefundOutPoint = {
26473
- txid: (0, import_utils15.hexToBytes)(getTxId(newNodeTx)),
26534
+ txid: (0, import_utils16.hexToBytes)(getTxId(newNodeTx)),
26474
26535
  index: 0
26475
26536
  };
26476
26537
  let newDirectRefundOutPoint;
26477
26538
  if (newDirectNodeTx) {
26478
26539
  newDirectRefundOutPoint = {
26479
- txid: (0, import_utils15.hexToBytes)(getTxId(newDirectNodeTx)),
26540
+ txid: (0, import_utils16.hexToBytes)(getTxId(newDirectNodeTx)),
26480
26541
  index: 0
26481
26542
  };
26482
26543
  }
@@ -26710,13 +26771,13 @@ var TransferService = class extends BaseTransferService {
26710
26771
  };
26711
26772
  const signingPublicKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
26712
26773
  const cpfpRefundOutPoint = {
26713
- txid: (0, import_utils15.hexToBytes)(getTxId(nodeTx)),
26774
+ txid: (0, import_utils16.hexToBytes)(getTxId(nodeTx)),
26714
26775
  index: 0
26715
26776
  };
26716
26777
  let directRefundOutPoint;
26717
26778
  if (directNodeTx) {
26718
26779
  directRefundOutPoint = {
26719
- txid: (0, import_utils15.hexToBytes)(getTxId(directNodeTx)),
26780
+ txid: (0, import_utils16.hexToBytes)(getTxId(directNodeTx)),
26720
26781
  index: 0
26721
26782
  };
26722
26783
  }
@@ -27092,9 +27153,9 @@ var CoopExitService = class extends BaseTransferService {
27092
27153
  init_buffer();
27093
27154
  var import_secp256k110 = require("@noble/curves/secp256k1");
27094
27155
  var import_sha210 = require("@noble/hashes/sha2");
27095
- var import_utils16 = require("@noble/hashes/utils");
27156
+ var import_utils17 = require("@noble/hashes/utils");
27096
27157
  var import_btc_signer4 = require("@scure/btc-signer");
27097
- var import_utils17 = require("@scure/btc-signer/utils");
27158
+ var import_utils18 = require("@scure/btc-signer/utils");
27098
27159
  var DepositService = class {
27099
27160
  config;
27100
27161
  connectionManager;
@@ -27145,7 +27206,7 @@ var DepositService = class {
27145
27206
  if (operator.identifier === this.config.getCoordinatorIdentifier()) {
27146
27207
  continue;
27147
27208
  }
27148
- const operatorPubkey2 = (0, import_utils16.hexToBytes)(operator.identityPublicKey);
27209
+ const operatorPubkey2 = (0, import_utils17.hexToBytes)(operator.identityPublicKey);
27149
27210
  const operatorSig = address2.depositAddressProof.addressSignatures[operator.identifier];
27150
27211
  if (!operatorSig) {
27151
27212
  throw new ValidationError("Operator signature not found", {
@@ -27154,7 +27215,11 @@ var DepositService = class {
27154
27215
  });
27155
27216
  }
27156
27217
  const sig = import_secp256k110.secp256k1.Signature.fromDER(operatorSig);
27157
- const isVerified2 = import_secp256k110.secp256k1.verify(sig, addrHash, operatorPubkey2);
27218
+ const isVerified2 = import_secp256k110.secp256k1.verify(
27219
+ sig.toCompactRawBytes(),
27220
+ addrHash,
27221
+ operatorPubkey2
27222
+ );
27158
27223
  if (!isVerified2) {
27159
27224
  throw new ValidationError("Operator signature verification failed", {
27160
27225
  field: "operatorSignature",
@@ -27230,7 +27295,7 @@ var DepositService = class {
27230
27295
  });
27231
27296
  }
27232
27297
  const depositOutPoint = {
27233
- txid: (0, import_utils16.hexToBytes)(getTxId(depositTx)),
27298
+ txid: (0, import_utils17.hexToBytes)(getTxId(depositTx)),
27234
27299
  index: vout
27235
27300
  };
27236
27301
  const depositTxOut = {
@@ -27249,8 +27314,8 @@ var DepositService = class {
27249
27314
  const { cpfpRefundTx, directRefundTx, directFromCpfpRefundTx } = createRefundTxs({
27250
27315
  sequence: INITIAL_SEQUENCE,
27251
27316
  directSequence: INITIAL_DIRECT_SEQUENCE,
27252
- input: { txid: (0, import_utils16.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
27253
- directInput: { txid: (0, import_utils16.hexToBytes)(getTxId(directRootTx)), index: 0 },
27317
+ input: { txid: (0, import_utils17.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
27318
+ directInput: { txid: (0, import_utils17.hexToBytes)(getTxId(directRootTx)), index: 0 },
27254
27319
  amountSats: amount,
27255
27320
  receivingPubkey: signingPubKey,
27256
27321
  network: this.config.getNetwork()
@@ -27380,7 +27445,7 @@ var DepositService = class {
27380
27445
  }
27381
27446
  );
27382
27447
  }
27383
- if (!(0, import_utils17.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
27448
+ if (!(0, import_utils18.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
27384
27449
  throw new ValidationError("Verifying key mismatch", {
27385
27450
  field: "verifyingKey",
27386
27451
  value: treeResp.rootNodeSignatureShares.verifyingKey,
@@ -27544,7 +27609,7 @@ var DepositService = class {
27544
27609
  });
27545
27610
  }
27546
27611
  const depositOutPoint = {
27547
- txid: (0, import_utils16.hexToBytes)(getTxId(depositTx)),
27612
+ txid: (0, import_utils17.hexToBytes)(getTxId(depositTx)),
27548
27613
  index: vout
27549
27614
  };
27550
27615
  const depositTxOut = {
@@ -27557,7 +27622,7 @@ var DepositService = class {
27557
27622
  const signingPubKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
27558
27623
  const { cpfpRefundTx } = createRefundTxs({
27559
27624
  sequence: INITIAL_SEQUENCE,
27560
- input: { txid: (0, import_utils16.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
27625
+ input: { txid: (0, import_utils17.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
27561
27626
  amountSats: amount,
27562
27627
  receivingPubkey: signingPubKey,
27563
27628
  network: this.config.getNetwork()
@@ -27627,7 +27692,7 @@ var DepositService = class {
27627
27692
  }
27628
27693
  );
27629
27694
  }
27630
- if (!(0, import_utils17.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
27695
+ if (!(0, import_utils18.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
27631
27696
  throw new ValidationError("Verifying key mismatch", {
27632
27697
  field: "verifyingKey",
27633
27698
  value: treeResp.rootNodeSignatureShares.verifyingKey,
@@ -27703,7 +27768,7 @@ var DepositService = class {
27703
27768
 
27704
27769
  // src/services/lightning.ts
27705
27770
  init_buffer();
27706
- var import_utils18 = require("@noble/curves/abstract/utils");
27771
+ var import_utils19 = require("@noble/curves/abstract/utils");
27707
27772
  var import_secp256k111 = require("@noble/curves/secp256k1");
27708
27773
  var import_sha211 = require("@noble/hashes/sha2");
27709
27774
  var import_uuidv74 = require("uuidv7");
@@ -27790,8 +27855,8 @@ var LightningService = class {
27790
27855
  }) {
27791
27856
  const crypto = getCrypto();
27792
27857
  const randBytes = crypto.getRandomValues(new Uint8Array(32));
27793
- const preimage = (0, import_utils18.numberToBytesBE)(
27794
- (0, import_utils18.bytesToNumberBE)(randBytes) % import_secp256k111.secp256k1.CURVE.n,
27858
+ const preimage = (0, import_utils19.numberToBytesBE)(
27859
+ (0, import_utils19.bytesToNumberBE)(randBytes) % import_secp256k111.secp256k1.CURVE.n,
27795
27860
  32
27796
27861
  );
27797
27862
  return await this.createLightningInvoiceWithPreImage({
@@ -27846,12 +27911,12 @@ var LightningService = class {
27846
27911
  const sparkClient = await this.connectionManager.createSparkClient(
27847
27912
  operator.address
27848
27913
  );
27849
- const userIdentityPublicKey = receiverIdentityPubkey ? (0, import_utils18.hexToBytes)(receiverIdentityPubkey) : await this.config.signer.getIdentityPublicKey();
27914
+ const userIdentityPublicKey = receiverIdentityPubkey ? (0, import_utils19.hexToBytes)(receiverIdentityPubkey) : await this.config.signer.getIdentityPublicKey();
27850
27915
  try {
27851
27916
  await sparkClient.store_preimage_share({
27852
27917
  paymentHash,
27853
27918
  preimageShare: {
27854
- secretShare: (0, import_utils18.numberToBytesBE)(share.share, 32),
27919
+ secretShare: (0, import_utils19.numberToBytesBE)(share.share, 32),
27855
27920
  proofs: share.proofs
27856
27921
  },
27857
27922
  threshold: this.config.getThreshold(),
@@ -28052,9 +28117,9 @@ var LightningService = class {
28052
28117
 
28053
28118
  // src/services/token-transactions.ts
28054
28119
  init_buffer();
28055
- var import_utils19 = require("@noble/curves/abstract/utils");
28120
+ var import_utils20 = require("@noble/curves/abstract/utils");
28056
28121
  var import_secp256k113 = require("@noble/curves/secp256k1");
28057
- var import_utils20 = require("@noble/hashes/utils");
28122
+ var import_utils21 = require("@noble/hashes/utils");
28058
28123
 
28059
28124
  // src/utils/token-hashing.ts
28060
28125
  init_buffer();
@@ -29988,14 +30053,14 @@ var TokenTransactionService = class {
29988
30053
  }
29989
30054
  if (this.config.getTokenTransactionVersion() !== "V0" && receiverAddress.sparkInvoiceFields) {
29990
30055
  return {
29991
- receiverPublicKey: (0, import_utils20.hexToBytes)(receiverAddress.identityPublicKey),
30056
+ receiverPublicKey: (0, import_utils21.hexToBytes)(receiverAddress.identityPublicKey),
29992
30057
  rawTokenIdentifier,
29993
30058
  tokenAmount: transfer.tokenAmount,
29994
30059
  sparkInvoice: transfer.receiverSparkAddress
29995
30060
  };
29996
30061
  }
29997
30062
  return {
29998
- receiverPublicKey: (0, import_utils20.hexToBytes)(receiverAddress.identityPublicKey),
30063
+ receiverPublicKey: (0, import_utils21.hexToBytes)(receiverAddress.identityPublicKey),
29999
30064
  rawTokenIdentifier,
30000
30065
  tokenPublicKey,
30001
30066
  // Remove for full v0 deprecation
@@ -30034,7 +30099,7 @@ var TokenTransactionService = class {
30034
30099
  const tokenOutputs = tokenOutputData.map((output) => ({
30035
30100
  ownerPublicKey: output.receiverPublicKey,
30036
30101
  tokenPublicKey: output.tokenPublicKey,
30037
- tokenAmount: (0, import_utils19.numberToBytesBE)(output.tokenAmount, 16)
30102
+ tokenAmount: (0, import_utils20.numberToBytesBE)(output.tokenAmount, 16)
30038
30103
  }));
30039
30104
  if (availableTokenAmount > totalRequestedAmount) {
30040
30105
  const changeAmount = availableTokenAmount - totalRequestedAmount;
@@ -30042,7 +30107,7 @@ var TokenTransactionService = class {
30042
30107
  tokenOutputs.push({
30043
30108
  ownerPublicKey: await this.config.signer.getIdentityPublicKey(),
30044
30109
  tokenPublicKey: firstTokenPublicKey,
30045
- tokenAmount: (0, import_utils19.numberToBytesBE)(changeAmount, 16)
30110
+ tokenAmount: (0, import_utils20.numberToBytesBE)(changeAmount, 16)
30046
30111
  });
30047
30112
  }
30048
30113
  return {
@@ -30073,7 +30138,7 @@ var TokenTransactionService = class {
30073
30138
  (output) => ({
30074
30139
  ownerPublicKey: output.receiverPublicKey,
30075
30140
  tokenIdentifier: output.rawTokenIdentifier,
30076
- tokenAmount: (0, import_utils19.numberToBytesBE)(output.tokenAmount, 16)
30141
+ tokenAmount: (0, import_utils20.numberToBytesBE)(output.tokenAmount, 16)
30077
30142
  })
30078
30143
  );
30079
30144
  if (availableTokenAmount > totalRequestedAmount) {
@@ -30082,7 +30147,7 @@ var TokenTransactionService = class {
30082
30147
  tokenOutputs.push({
30083
30148
  ownerPublicKey: await this.config.signer.getIdentityPublicKey(),
30084
30149
  tokenIdentifier: firstTokenIdentifierBytes,
30085
- tokenAmount: (0, import_utils19.numberToBytesBE)(changeAmount, 16)
30150
+ tokenAmount: (0, import_utils20.numberToBytesBE)(changeAmount, 16)
30086
30151
  });
30087
30152
  }
30088
30153
  return {
@@ -30109,7 +30174,7 @@ var TokenTransactionService = class {
30109
30174
  for (const [_, operator] of Object.entries(
30110
30175
  this.config.getSigningOperators()
30111
30176
  )) {
30112
- operatorKeys.push((0, import_utils20.hexToBytes)(operator.identityPublicKey));
30177
+ operatorKeys.push((0, import_utils21.hexToBytes)(operator.identityPublicKey));
30113
30178
  }
30114
30179
  return operatorKeys;
30115
30180
  }
@@ -30193,7 +30258,7 @@ var TokenTransactionService = class {
30193
30258
  {
30194
30259
  field: "revocationCommitment",
30195
30260
  value: derivedRevocationCommitment,
30196
- expected: (0, import_utils19.bytesToHex)(outputsToSpendCommitments[outputIndex]),
30261
+ expected: (0, import_utils20.bytesToHex)(outputsToSpendCommitments[outputIndex]),
30197
30262
  outputIndex
30198
30263
  }
30199
30264
  )
@@ -30219,7 +30284,7 @@ var TokenTransactionService = class {
30219
30284
  threshold
30220
30285
  );
30221
30286
  }
30222
- return (0, import_utils19.bytesToHex)(finalTokenTransactionHash);
30287
+ return (0, import_utils20.bytesToHex)(finalTokenTransactionHash);
30223
30288
  }
30224
30289
  async broadcastTokenTransactionV1(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
30225
30290
  const { finalTokenTransaction, finalTokenTransactionHash, threshold } = await this.startTokenTransaction(
@@ -30233,7 +30298,7 @@ var TokenTransactionService = class {
30233
30298
  finalTokenTransactionHash,
30234
30299
  signingOperators
30235
30300
  );
30236
- return (0, import_utils19.bytesToHex)(finalTokenTransactionHash);
30301
+ return (0, import_utils20.bytesToHex)(finalTokenTransactionHash);
30237
30302
  }
30238
30303
  async startTokenTransactionV0(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
30239
30304
  const sparkClient = await this.connectionManager.createSparkClient(
@@ -30457,7 +30522,7 @@ var TokenTransactionService = class {
30457
30522
  const identityPublicKey = await this.config.signer.getIdentityPublicKey();
30458
30523
  const payload = {
30459
30524
  finalTokenTransactionHash,
30460
- operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
30525
+ operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
30461
30526
  };
30462
30527
  const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
30463
30528
  let operatorSpecificSignatures = [];
@@ -30672,8 +30737,8 @@ var TokenTransactionService = class {
30672
30737
  this.config.getCoordinatorAddress()
30673
30738
  );
30674
30739
  let queryParams = {
30675
- tokenPublicKeys: issuerPublicKeys?.map(import_utils20.hexToBytes),
30676
- ownerPublicKeys: ownerPublicKeys?.map(import_utils20.hexToBytes),
30740
+ tokenPublicKeys: issuerPublicKeys?.map(import_utils21.hexToBytes),
30741
+ ownerPublicKeys: ownerPublicKeys?.map(import_utils21.hexToBytes),
30677
30742
  tokenIdentifiers: tokenIdentifiers?.map((identifier) => {
30678
30743
  const { tokenIdentifier } = decodeBech32mTokenIdentifier(
30679
30744
  identifier,
@@ -30681,7 +30746,7 @@ var TokenTransactionService = class {
30681
30746
  );
30682
30747
  return tokenIdentifier;
30683
30748
  }),
30684
- tokenTransactionHashes: tokenTransactionHashes?.map(import_utils20.hexToBytes),
30749
+ tokenTransactionHashes: tokenTransactionHashes?.map(import_utils21.hexToBytes),
30685
30750
  outputIds: outputIds || [],
30686
30751
  limit: pageSize,
30687
30752
  offset
@@ -30740,8 +30805,8 @@ var TokenTransactionService = class {
30740
30805
  this.config.getCoordinatorAddress()
30741
30806
  );
30742
30807
  let queryParams = {
30743
- issuerPublicKeys: issuerPublicKeys?.map(import_utils20.hexToBytes),
30744
- ownerPublicKeys: ownerPublicKeys?.map(import_utils20.hexToBytes),
30808
+ issuerPublicKeys: issuerPublicKeys?.map(import_utils21.hexToBytes),
30809
+ ownerPublicKeys: ownerPublicKeys?.map(import_utils21.hexToBytes),
30745
30810
  tokenIdentifiers: tokenIdentifiers?.map((identifier) => {
30746
30811
  const { tokenIdentifier } = decodeBech32mTokenIdentifier(
30747
30812
  identifier,
@@ -30749,7 +30814,7 @@ var TokenTransactionService = class {
30749
30814
  );
30750
30815
  return tokenIdentifier;
30751
30816
  }),
30752
- tokenTransactionHashes: tokenTransactionHashes?.map(import_utils20.hexToBytes),
30817
+ tokenTransactionHashes: tokenTransactionHashes?.map(import_utils21.hexToBytes),
30753
30818
  outputIds: outputIds || [],
30754
30819
  limit: pageSize,
30755
30820
  offset
@@ -30784,7 +30849,7 @@ var TokenTransactionService = class {
30784
30849
  });
30785
30850
  }
30786
30851
  const exactMatch = tokenOutputs.find(
30787
- (item) => (0, import_utils19.bytesToNumberBE)(item.output.tokenAmount) === tokenAmount
30852
+ (item) => (0, import_utils20.bytesToNumberBE)(item.output.tokenAmount) === tokenAmount
30788
30853
  );
30789
30854
  if (exactMatch) {
30790
30855
  return [exactMatch];
@@ -30795,7 +30860,7 @@ var TokenTransactionService = class {
30795
30860
  for (const outputWithPreviousTransactionData of tokenOutputs) {
30796
30861
  if (remainingAmount <= 0n) break;
30797
30862
  selectedOutputs.push(outputWithPreviousTransactionData);
30798
- remainingAmount -= (0, import_utils19.bytesToNumberBE)(
30863
+ remainingAmount -= (0, import_utils20.bytesToNumberBE)(
30799
30864
  outputWithPreviousTransactionData.output.tokenAmount
30800
30865
  );
30801
30866
  }
@@ -30811,13 +30876,13 @@ var TokenTransactionService = class {
30811
30876
  if (strategy === "SMALL_FIRST") {
30812
30877
  tokenOutputs.sort((a, b) => {
30813
30878
  return Number(
30814
- (0, import_utils19.bytesToNumberBE)(a.output.tokenAmount) - (0, import_utils19.bytesToNumberBE)(b.output.tokenAmount)
30879
+ (0, import_utils20.bytesToNumberBE)(a.output.tokenAmount) - (0, import_utils20.bytesToNumberBE)(b.output.tokenAmount)
30815
30880
  );
30816
30881
  });
30817
30882
  } else {
30818
30883
  tokenOutputs.sort((a, b) => {
30819
30884
  return Number(
30820
- (0, import_utils19.bytesToNumberBE)(b.output.tokenAmount) - (0, import_utils19.bytesToNumberBE)(a.output.tokenAmount)
30885
+ (0, import_utils20.bytesToNumberBE)(b.output.tokenAmount) - (0, import_utils20.bytesToNumberBE)(a.output.tokenAmount)
30821
30886
  );
30822
30887
  });
30823
30888
  }
@@ -30825,7 +30890,7 @@ var TokenTransactionService = class {
30825
30890
  // Helper function for deciding if the signer public key is the identity public key
30826
30891
  async signMessageWithKey(message, publicKey) {
30827
30892
  const tokenSignatures = this.config.getTokenSignatures();
30828
- if ((0, import_utils19.bytesToHex)(publicKey) === (0, import_utils19.bytesToHex)(await this.config.signer.getIdentityPublicKey())) {
30893
+ if ((0, import_utils20.bytesToHex)(publicKey) === (0, import_utils20.bytesToHex)(await this.config.signer.getIdentityPublicKey())) {
30829
30894
  if (tokenSignatures === "SCHNORR") {
30830
30895
  return await this.config.signer.signSchnorrWithIdentityKey(message);
30831
30896
  } else {
@@ -30834,8 +30899,8 @@ var TokenTransactionService = class {
30834
30899
  } else {
30835
30900
  throw new ValidationError("Invalid public key", {
30836
30901
  field: "publicKey",
30837
- value: (0, import_utils19.bytesToHex)(publicKey),
30838
- expected: (0, import_utils19.bytesToHex)(await this.config.signer.getIdentityPublicKey())
30902
+ value: (0, import_utils20.bytesToHex)(publicKey),
30903
+ expected: (0, import_utils20.bytesToHex)(await this.config.signer.getIdentityPublicKey())
30839
30904
  });
30840
30905
  }
30841
30906
  }
@@ -30898,7 +30963,7 @@ var TokenTransactionService = class {
30898
30963
  }
30899
30964
  const payload = {
30900
30965
  finalTokenTransactionHash,
30901
- operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
30966
+ operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
30902
30967
  };
30903
30968
  const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
30904
30969
  const ownerSignature = await this.signMessageWithKey(
@@ -30920,7 +30985,7 @@ var TokenTransactionService = class {
30920
30985
  }
30921
30986
  const payload = {
30922
30987
  finalTokenTransactionHash,
30923
- operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
30988
+ operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
30924
30989
  };
30925
30990
  const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
30926
30991
  const ownerSignature = await this.signMessageWithKey(
@@ -30936,7 +31001,7 @@ var TokenTransactionService = class {
30936
31001
  for (let i = 0; i < transferInput.outputsToSpend.length; i++) {
30937
31002
  const payload = {
30938
31003
  finalTokenTransactionHash,
30939
- operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
31004
+ operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
30940
31005
  };
30941
31006
  const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
30942
31007
  let ownerSignature;
@@ -30953,7 +31018,7 @@ var TokenTransactionService = class {
30953
31018
  }
30954
31019
  inputTtxoSignaturesPerOperator.push({
30955
31020
  ttxoSignatures,
30956
- operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
31021
+ operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
30957
31022
  });
30958
31023
  }
30959
31024
  return inputTtxoSignaturesPerOperator;
@@ -30972,7 +31037,7 @@ var import_nice_grpc_common3 = require("nice-grpc-common");
30972
31037
 
30973
31038
  // src/services/signing.ts
30974
31039
  init_buffer();
30975
- var import_utils21 = require("@noble/curves/abstract/utils");
31040
+ var import_utils22 = require("@noble/curves/abstract/utils");
30976
31041
  var SigningService = class {
30977
31042
  config;
30978
31043
  constructor(config) {
@@ -31028,7 +31093,7 @@ var SigningService = class {
31028
31093
  }
31029
31094
  const nodeTx = getTxFromRawTxBytes(leaf.leaf.nodeTx);
31030
31095
  const cpfpNodeOutPoint = {
31031
- txid: (0, import_utils21.hexToBytes)(getTxId(nodeTx)),
31096
+ txid: (0, import_utils22.hexToBytes)(getTxId(nodeTx)),
31032
31097
  index: 0
31033
31098
  };
31034
31099
  const currRefundTx = getTxFromRawTxBytes(leaf.leaf.refundTx);
@@ -31054,7 +31119,7 @@ var SigningService = class {
31054
31119
  if (leaf.leaf.directTx.length > 0) {
31055
31120
  directNodeTx = getTxFromRawTxBytes(leaf.leaf.directTx);
31056
31121
  directNodeOutPoint = {
31057
- txid: (0, import_utils21.hexToBytes)(getTxId(directNodeTx)),
31122
+ txid: (0, import_utils22.hexToBytes)(getTxId(directNodeTx)),
31058
31123
  index: 0
31059
31124
  };
31060
31125
  }
@@ -31138,15 +31203,15 @@ var SigningService = class {
31138
31203
 
31139
31204
  // src/tests/utils/test-faucet.ts
31140
31205
  init_buffer();
31141
- var import_utils22 = require("@noble/curves/abstract/utils");
31206
+ var import_utils23 = require("@noble/curves/abstract/utils");
31142
31207
  var import_secp256k114 = require("@noble/curves/secp256k1");
31143
31208
  var btc5 = __toESM(require("@scure/btc-signer"), 1);
31144
31209
  var import_btc_signer5 = require("@scure/btc-signer");
31145
- var import_utils23 = require("@scure/btc-signer/utils");
31146
- var STATIC_FAUCET_KEY = (0, import_utils22.hexToBytes)(
31210
+ var import_utils24 = require("@scure/btc-signer/utils");
31211
+ var STATIC_FAUCET_KEY = (0, import_utils23.hexToBytes)(
31147
31212
  "deadbeef1337cafe4242424242424242deadbeef1337cafe4242424242424242"
31148
31213
  );
31149
- var STATIC_MINING_KEY = (0, import_utils22.hexToBytes)(
31214
+ var STATIC_MINING_KEY = (0, import_utils23.hexToBytes)(
31150
31215
  "1337cafe4242deadbeef4242424242421337cafe4242deadbeef424242424242"
31151
31216
  );
31152
31217
  var SATS_PER_BTC = 1e8;
@@ -31209,7 +31274,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
31209
31274
  if (!scanResult.success || scanResult.unspents.length === 0) {
31210
31275
  const blockHash = await this.generateToAddress(1, address2);
31211
31276
  const block = await this.getBlock(blockHash[0]);
31212
- const fundingTx = import_btc_signer5.Transaction.fromRaw((0, import_utils22.hexToBytes)(block.tx[0].hex), {
31277
+ const fundingTx = import_btc_signer5.Transaction.fromRaw((0, import_utils23.hexToBytes)(block.tx[0].hex), {
31213
31278
  allowUnknownOutputs: true
31214
31279
  });
31215
31280
  await this.generateToAddress(100, this.miningAddress);
@@ -31271,13 +31336,13 @@ var BitcoinFaucet = class _BitcoinFaucet {
31271
31336
  },
31272
31337
  STATIC_MINING_KEY
31273
31338
  );
31274
- await this.broadcastTx((0, import_utils22.bytesToHex)(signedSplitTx.extract()));
31339
+ await this.broadcastTx((0, import_utils23.bytesToHex)(signedSplitTx.extract()));
31275
31340
  const splitTxId = signedSplitTx.id;
31276
31341
  for (let i = 0; i < numCoinsToCreate; i++) {
31277
31342
  this.coins.push({
31278
31343
  key: STATIC_FAUCET_KEY,
31279
31344
  outpoint: {
31280
- txid: (0, import_utils22.hexToBytes)(splitTxId),
31345
+ txid: (0, import_utils23.hexToBytes)(splitTxId),
31281
31346
  index: i
31282
31347
  },
31283
31348
  txout: signedSplitTx.getOutput(i)
@@ -31305,7 +31370,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
31305
31370
  coinToSend.txout,
31306
31371
  coinToSend.key
31307
31372
  );
31308
- await this.broadcastTx((0, import_utils22.bytesToHex)(signedTx.extract()));
31373
+ await this.broadcastTx((0, import_utils23.bytesToHex)(signedTx.extract()));
31309
31374
  }
31310
31375
  async signFaucetCoin(unsignedTx, fundingTxOut, key) {
31311
31376
  const pubKey = import_secp256k114.secp256k1.getPublicKey(key);
@@ -31325,7 +31390,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
31325
31390
  new Array(unsignedTx.inputsLength).fill(fundingTxOut.amount)
31326
31391
  );
31327
31392
  const merkleRoot = new Uint8Array();
31328
- const tweakedKey = (0, import_utils23.taprootTweakPrivKey)(key, merkleRoot);
31393
+ const tweakedKey = (0, import_utils24.taprootTweakPrivKey)(key, merkleRoot);
31329
31394
  if (!tweakedKey)
31330
31395
  throw new Error("Invalid private key for taproot tweaking");
31331
31396
  const signature = import_secp256k114.schnorr.sign(sighash, tweakedKey);
@@ -31425,7 +31490,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
31425
31490
  });
31426
31491
  }
31427
31492
  const signedTx = await this.signFaucetCoin(tx, coin.txout, coin.key);
31428
- const txHex = (0, import_utils22.bytesToHex)(signedTx.extract());
31493
+ const txHex = (0, import_utils23.bytesToHex)(signedTx.extract());
31429
31494
  await this.broadcastTx(txHex);
31430
31495
  const randomKey = import_secp256k114.secp256k1.utils.randomPrivateKey();
31431
31496
  const randomPubKey = import_secp256k114.secp256k1.getPublicKey(randomKey);
@@ -31616,7 +31681,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
31616
31681
  try {
31617
31682
  if (event?.$case === "transfer" && event.transfer.transfer && event.transfer.transfer.type !== 40 /* COUNTER_SWAP */) {
31618
31683
  const { senderIdentityPublicKey, receiverIdentityPublicKey } = event.transfer.transfer;
31619
- if (event.transfer.transfer && !(0, import_utils24.equalBytes)(senderIdentityPublicKey, receiverIdentityPublicKey)) {
31684
+ if (event.transfer.transfer && !(0, import_utils25.equalBytes)(senderIdentityPublicKey, receiverIdentityPublicKey)) {
31620
31685
  await this.claimTransfer({
31621
31686
  transfer: event.transfer.transfer,
31622
31687
  emit: true,
@@ -31685,7 +31750,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
31685
31750
  setTimeout(maybeUnref, 100);
31686
31751
  }
31687
31752
  };
31688
- if (import_core12.isNode) {
31753
+ if (import_core13.isNode) {
31689
31754
  maybeUnref();
31690
31755
  }
31691
31756
  const claimedTransfersIds = await this.claimTransfers();
@@ -31781,10 +31846,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
31781
31846
  leavesToIgnore.add(nodeId);
31782
31847
  continue;
31783
31848
  }
31784
- if (leaf.status !== operatorLeaf.status || !leaf.signingKeyshare || !operatorLeaf.signingKeyshare || !(0, import_utils24.equalBytes)(
31849
+ if (leaf.status !== operatorLeaf.status || !leaf.signingKeyshare || !operatorLeaf.signingKeyshare || !(0, import_utils25.equalBytes)(
31785
31850
  leaf.signingKeyshare.publicKey,
31786
31851
  operatorLeaf.signingKeyshare.publicKey
31787
- ) || !(0, import_utils24.equalBytes)(leaf.nodeTx, operatorLeaf.nodeTx)) {
31852
+ ) || !(0, import_utils25.equalBytes)(leaf.nodeTx, operatorLeaf.nodeTx)) {
31788
31853
  leavesToIgnore.add(nodeId);
31789
31854
  }
31790
31855
  }
@@ -31835,7 +31900,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
31835
31900
  });
31836
31901
  }
31837
31902
  verifyKey(pubkey1, pubkey2, verifyingKey) {
31838
- return (0, import_utils24.equalBytes)(addPublicKeys(pubkey1, pubkey2), verifyingKey);
31903
+ return (0, import_utils25.equalBytes)(addPublicKeys(pubkey1, pubkey2), verifyingKey);
31839
31904
  }
31840
31905
  async selectLeaves(targetAmounts) {
31841
31906
  if (targetAmounts.length === 0) {
@@ -31993,7 +32058,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
31993
32058
  * @returns {Promise<string>} The identity public key as a hex string.
31994
32059
  */
31995
32060
  async getIdentityPublicKey() {
31996
- return (0, import_utils24.bytesToHex)(await this.config.signer.getIdentityPublicKey());
32061
+ return (0, import_utils25.bytesToHex)(await this.config.signer.getIdentityPublicKey());
31997
32062
  }
31998
32063
  /**
31999
32064
  * Gets the Spark address of the wallet.
@@ -32003,7 +32068,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32003
32068
  async getSparkAddress() {
32004
32069
  if (!this.sparkAddress) {
32005
32070
  this.sparkAddress = encodeSparkAddress({
32006
- identityPublicKey: (0, import_utils24.bytesToHex)(
32071
+ identityPublicKey: (0, import_utils25.bytesToHex)(
32007
32072
  await this.config.signer.getIdentityPublicKey()
32008
32073
  ),
32009
32074
  network: this.config.getNetworkType()
@@ -32066,7 +32131,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32066
32131
  $case: "tokensPayment",
32067
32132
  tokensPayment: {
32068
32133
  tokenIdentifier: decodedTokenIdentifier ?? void 0,
32069
- amount: amount ? (0, import_utils24.numberToVarBytesBE)(amount) : void 0
32134
+ amount: amount ? (0, import_utils25.numberToVarBytesBE)(amount) : void 0
32070
32135
  }
32071
32136
  };
32072
32137
  const invoiceFields = {
@@ -32074,7 +32139,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32074
32139
  id: (0, import_uuidv75.uuidv7obj)().bytes,
32075
32140
  paymentType: protoPayment,
32076
32141
  memo: memo ?? void 0,
32077
- senderPublicKey: senderPublicKey ? (0, import_utils24.hexToBytes)(senderPublicKey) : void 0,
32142
+ senderPublicKey: senderPublicKey ? (0, import_utils25.hexToBytes)(senderPublicKey) : void 0,
32078
32143
  expiryTime: expiryTime ?? void 0
32079
32144
  };
32080
32145
  validateSparkInvoiceFields(invoiceFields);
@@ -32087,7 +32152,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32087
32152
  const signature = await this.config.signer.signSchnorrWithIdentityKey(hash);
32088
32153
  return encodeSparkAddressWithSignature(
32089
32154
  {
32090
- identityPublicKey: (0, import_utils24.bytesToHex)(identityPublicKey),
32155
+ identityPublicKey: (0, import_utils25.bytesToHex)(identityPublicKey),
32091
32156
  network: this.config.getNetworkType(),
32092
32157
  sparkInvoiceFields: invoiceFields
32093
32158
  },
@@ -32133,7 +32198,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32133
32198
  mnemonic = mnemonicOrSeed;
32134
32199
  seed = await this.config.signer.mnemonicToSeed(mnemonicOrSeed);
32135
32200
  } else {
32136
- seed = (0, import_utils24.hexToBytes)(mnemonicOrSeed);
32201
+ seed = (0, import_utils25.hexToBytes)(mnemonicOrSeed);
32137
32202
  }
32138
32203
  }
32139
32204
  await this.initWalletFromSeed(seed, accountNumber);
@@ -32155,7 +32220,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32155
32220
  });
32156
32221
  }
32157
32222
  this.sparkAddress = encodeSparkAddress({
32158
- identityPublicKey: (0, import_utils24.bytesToHex)(identityPublicKey),
32223
+ identityPublicKey: (0, import_utils25.bytesToHex)(identityPublicKey),
32159
32224
  network: this.config.getNetworkType()
32160
32225
  });
32161
32226
  return this.sparkAddress;
@@ -32244,7 +32309,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32244
32309
  throw new Error("targetAmount or leaves must be provided");
32245
32310
  }
32246
32311
  leavesToSwap.sort((a, b) => a.value - b.value);
32247
- const batches = chunkArray(leavesToSwap, 100);
32312
+ const batches = chunkArray(leavesToSwap, 64);
32248
32313
  const results = [];
32249
32314
  for (const batch of batches) {
32250
32315
  const result = await this.processSwapBatch(batch, targetAmounts);
@@ -32275,7 +32340,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32275
32340
  directFromCpfpSignatureMap
32276
32341
  } = await this.transferService.startSwapSignRefund(
32277
32342
  leafKeyTweaks,
32278
- (0, import_utils24.hexToBytes)(this.config.getSspIdentityPublicKey()),
32343
+ (0, import_utils25.hexToBytes)(this.config.getSspIdentityPublicKey()),
32279
32344
  new Date(Date.now() + 2 * 60 * 1e3)
32280
32345
  );
32281
32346
  try {
@@ -32335,18 +32400,18 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32335
32400
  const userLeaves = [];
32336
32401
  userLeaves.push({
32337
32402
  leaf_id: transfer.leaves[0].leaf.id,
32338
- raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32403
+ raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
32339
32404
  transfer.leaves[0].intermediateRefundTx
32340
32405
  ),
32341
- direct_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32406
+ direct_raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
32342
32407
  transfer.leaves[0].intermediateDirectRefundTx
32343
32408
  ),
32344
- direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32409
+ direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
32345
32410
  transfer.leaves[0].intermediateDirectFromCpfpRefundTx
32346
32411
  ),
32347
- adaptor_added_signature: (0, import_utils24.bytesToHex)(cpfpAdaptorSignature),
32348
- direct_adaptor_added_signature: (0, import_utils24.bytesToHex)(directAdaptorSignature),
32349
- direct_from_cpfp_adaptor_added_signature: (0, import_utils24.bytesToHex)(
32412
+ adaptor_added_signature: (0, import_utils25.bytesToHex)(cpfpAdaptorSignature),
32413
+ direct_adaptor_added_signature: (0, import_utils25.bytesToHex)(directAdaptorSignature),
32414
+ direct_from_cpfp_adaptor_added_signature: (0, import_utils25.bytesToHex)(
32350
32415
  directFromCpfpAdaptorSignature
32351
32416
  )
32352
32417
  });
@@ -32399,24 +32464,24 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32399
32464
  }
32400
32465
  userLeaves.push({
32401
32466
  leaf_id: leaf.leaf.id,
32402
- raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32467
+ raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
32403
32468
  leaf.intermediateRefundTx
32404
32469
  ),
32405
- direct_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32470
+ direct_raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
32406
32471
  leaf.intermediateDirectRefundTx
32407
32472
  ),
32408
- direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32473
+ direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
32409
32474
  leaf.intermediateDirectFromCpfpRefundTx
32410
32475
  ),
32411
- adaptor_added_signature: (0, import_utils24.bytesToHex)(cpfpSignature),
32412
- direct_adaptor_added_signature: (0, import_utils24.bytesToHex)(directSignature),
32413
- direct_from_cpfp_adaptor_added_signature: (0, import_utils24.bytesToHex)(
32476
+ adaptor_added_signature: (0, import_utils25.bytesToHex)(cpfpSignature),
32477
+ direct_adaptor_added_signature: (0, import_utils25.bytesToHex)(directSignature),
32478
+ direct_from_cpfp_adaptor_added_signature: (0, import_utils25.bytesToHex)(
32414
32479
  directFromCpfpSignature
32415
32480
  )
32416
32481
  });
32417
32482
  }
32418
32483
  const sspClient = this.getSspClient();
32419
- const cpfpAdaptorPubkey = (0, import_utils24.bytesToHex)(
32484
+ const cpfpAdaptorPubkey = (0, import_utils25.bytesToHex)(
32420
32485
  import_secp256k115.secp256k1.getPublicKey(cpfpAdaptorPrivateKey)
32421
32486
  );
32422
32487
  if (!cpfpAdaptorPubkey) {
@@ -32424,13 +32489,13 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32424
32489
  }
32425
32490
  let directAdaptorPubkey;
32426
32491
  if (directAdaptorPrivateKey.length > 0) {
32427
- directAdaptorPubkey = (0, import_utils24.bytesToHex)(
32492
+ directAdaptorPubkey = (0, import_utils25.bytesToHex)(
32428
32493
  import_secp256k115.secp256k1.getPublicKey(directAdaptorPrivateKey)
32429
32494
  );
32430
32495
  }
32431
32496
  let directFromCpfpAdaptorPubkey;
32432
32497
  if (directFromCpfpAdaptorPrivateKey.length > 0) {
32433
- directFromCpfpAdaptorPubkey = (0, import_utils24.bytesToHex)(
32498
+ directFromCpfpAdaptorPubkey = (0, import_utils25.bytesToHex)(
32434
32499
  import_secp256k115.secp256k1.getPublicKey(directFromCpfpAdaptorPrivateKey)
32435
32500
  );
32436
32501
  }
@@ -32490,7 +32555,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32490
32555
  throw new Error(`Leaf not found for node ${nodeId}`);
32491
32556
  }
32492
32557
  const cpfpNodeTx = getTxFromRawTxBytes(node.nodeTx);
32493
- const cpfpRefundTxBytes = (0, import_utils24.hexToBytes)(leaf.rawUnsignedRefundTransaction);
32558
+ const cpfpRefundTxBytes = (0, import_utils25.hexToBytes)(leaf.rawUnsignedRefundTransaction);
32494
32559
  const cpfpRefundTx = getTxFromRawTxBytes(cpfpRefundTxBytes);
32495
32560
  const cpfpSighash = getSigHashFromTx(
32496
32561
  cpfpRefundTx,
@@ -32499,7 +32564,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32499
32564
  );
32500
32565
  const nodePublicKey = node.verifyingPublicKey;
32501
32566
  const taprootKey = computeTaprootKeyNoScript(nodePublicKey.slice(1));
32502
- const cpfpAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
32567
+ const cpfpAdaptorSignatureBytes = (0, import_utils25.hexToBytes)(
32503
32568
  leaf.adaptorSignedSignature
32504
32569
  );
32505
32570
  applyAdaptorToSignature(
@@ -32510,7 +32575,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32510
32575
  );
32511
32576
  if (leaf.directRawUnsignedRefundTransaction) {
32512
32577
  const directNodeTx = getTxFromRawTxBytes(node.directTx);
32513
- const directRefundTxBytes = (0, import_utils24.hexToBytes)(
32578
+ const directRefundTxBytes = (0, import_utils25.hexToBytes)(
32514
32579
  leaf.directRawUnsignedRefundTransaction
32515
32580
  );
32516
32581
  const directRefundTx = getTxFromRawTxBytes(directRefundTxBytes);
@@ -32524,7 +32589,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32524
32589
  `Direct adaptor signed signature missing for node ${nodeId}`
32525
32590
  );
32526
32591
  }
32527
- const directAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
32592
+ const directAdaptorSignatureBytes = (0, import_utils25.hexToBytes)(
32528
32593
  leaf.directAdaptorSignedSignature
32529
32594
  );
32530
32595
  applyAdaptorToSignature(
@@ -32535,7 +32600,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32535
32600
  );
32536
32601
  }
32537
32602
  if (leaf.directFromCpfpRawUnsignedRefundTransaction) {
32538
- const directFromCpfpRefundTxBytes = (0, import_utils24.hexToBytes)(
32603
+ const directFromCpfpRefundTxBytes = (0, import_utils25.hexToBytes)(
32539
32604
  leaf.directFromCpfpRawUnsignedRefundTransaction
32540
32605
  );
32541
32606
  const directFromCpfpRefundTx = getTxFromRawTxBytes(
@@ -32551,7 +32616,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32551
32616
  `Direct adaptor signed signature missing for node ${nodeId}`
32552
32617
  );
32553
32618
  }
32554
- const directFromCpfpAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
32619
+ const directFromCpfpAdaptorSignatureBytes = (0, import_utils25.hexToBytes)(
32555
32620
  leaf.directFromCpfpAdaptorSignedSignature
32556
32621
  );
32557
32622
  applyAdaptorToSignature(
@@ -32570,9 +32635,9 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32570
32635
  directFromCpfpSignatureMap
32571
32636
  );
32572
32637
  const completeResponse = await sspClient.completeLeaveSwap({
32573
- adaptorSecretKey: (0, import_utils24.bytesToHex)(cpfpAdaptorPrivateKey),
32574
- directAdaptorSecretKey: (0, import_utils24.bytesToHex)(directAdaptorPrivateKey),
32575
- directFromCpfpAdaptorSecretKey: (0, import_utils24.bytesToHex)(
32638
+ adaptorSecretKey: (0, import_utils25.bytesToHex)(cpfpAdaptorPrivateKey),
32639
+ directAdaptorSecretKey: (0, import_utils25.bytesToHex)(directAdaptorPrivateKey),
32640
+ directFromCpfpAdaptorSecretKey: (0, import_utils25.bytesToHex)(
32576
32641
  directFromCpfpAdaptorPrivateKey
32577
32642
  ),
32578
32643
  userOutboundTransferExternalId: transfer.id,
@@ -32667,12 +32732,12 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32667
32732
  let tokenMetadataMap = /* @__PURE__ */ new Map();
32668
32733
  for (const [tokenIdentifier, metadata] of this.tokenMetadata) {
32669
32734
  tokenMetadataMap.set(tokenIdentifier, {
32670
- tokenPublicKey: (0, import_utils24.bytesToHex)(metadata.issuerPublicKey),
32735
+ tokenPublicKey: (0, import_utils25.bytesToHex)(metadata.issuerPublicKey),
32671
32736
  rawTokenIdentifier: metadata.tokenIdentifier,
32672
32737
  tokenName: metadata.tokenName,
32673
32738
  tokenTicker: metadata.tokenTicker,
32674
32739
  decimals: metadata.decimals,
32675
- maxSupply: (0, import_utils24.bytesToNumberBE)(metadata.maxSupply)
32740
+ maxSupply: (0, import_utils25.bytesToNumberBE)(metadata.maxSupply)
32676
32741
  });
32677
32742
  }
32678
32743
  return tokenMetadataMap;
@@ -32796,7 +32861,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32796
32861
  offset
32797
32862
  });
32798
32863
  return response.utxos.map((utxo) => ({
32799
- txid: (0, import_utils24.bytesToHex)(utxo.txid),
32864
+ txid: (0, import_utils25.bytesToHex)(utxo.txid),
32800
32865
  vout: utxo.vout
32801
32866
  })) ?? [];
32802
32867
  } catch (error) {
@@ -32866,7 +32931,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32866
32931
  if (network === BitcoinNetwork_default.FUTURE_VALUE) {
32867
32932
  network = BitcoinNetwork_default.REGTEST;
32868
32933
  }
32869
- const depositSecretKey = (0, import_utils24.bytesToHex)(
32934
+ const depositSecretKey = (0, import_utils25.bytesToHex)(
32870
32935
  await this.config.signer.getStaticDepositSecretKey(0)
32871
32936
  );
32872
32937
  const message = await this.getStaticDepositSigningPayload(
@@ -32879,7 +32944,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32879
32944
  );
32880
32945
  const hashBuffer = (0, import_sha213.sha256)(message);
32881
32946
  const signatureBytes = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
32882
- const signature = (0, import_utils24.bytesToHex)(signatureBytes);
32947
+ const signature = (0, import_utils25.bytesToHex)(signatureBytes);
32883
32948
  const response = await this.sspClient.claimStaticDeposit({
32884
32949
  transactionId,
32885
32950
  outputIndex,
@@ -33031,7 +33096,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33031
33096
  networkJSON.toLowerCase(),
33032
33097
  2 /* Refund */,
33033
33098
  creditAmountSats,
33034
- (0, import_utils24.bytesToHex)(spendTxSighash)
33099
+ (0, import_utils25.bytesToHex)(spendTxSighash)
33035
33100
  );
33036
33101
  const hashBuffer = (0, import_sha213.sha256)(message);
33037
33102
  const swapResponseUserSignature = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
@@ -33040,7 +33105,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33040
33105
  );
33041
33106
  const swapResponse = await sparkClient.initiate_static_deposit_utxo_refund({
33042
33107
  onChainUtxo: {
33043
- txid: (0, import_utils24.hexToBytes)(depositTransactionId),
33108
+ txid: (0, import_utils25.hexToBytes)(depositTransactionId),
33044
33109
  vout: outputIndex,
33045
33110
  network: networkType
33046
33111
  },
@@ -33109,7 +33174,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33109
33174
  creditAmountView.setUint32(0, lowerHalf, true);
33110
33175
  creditAmountView.setUint32(4, upperHalf, true);
33111
33176
  parts.push(new Uint8Array(creditAmountBuffer));
33112
- parts.push((0, import_utils24.hexToBytes)(sspSignature));
33177
+ parts.push((0, import_utils25.hexToBytes)(sspSignature));
33113
33178
  const totalLength = parts.reduce((sum, part) => sum + part.length, 0);
33114
33179
  const payload = new Uint8Array(totalLength);
33115
33180
  let offset = 0;
@@ -33487,11 +33552,11 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33487
33552
  field: "receiverSparkAddress"
33488
33553
  });
33489
33554
  }
33490
- const addressData = decodeSparkAddress(
33555
+ const receiverAddress = decodeSparkAddress(
33491
33556
  receiverSparkAddress,
33492
33557
  this.config.getNetworkType()
33493
33558
  );
33494
- if (addressData.sparkInvoiceFields) {
33559
+ if (receiverAddress.sparkInvoiceFields) {
33495
33560
  throw new ValidationError(
33496
33561
  "Spark address is a Spark invoice. Use fulfillSparkInvoice instead.",
33497
33562
  {
@@ -33513,14 +33578,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33513
33578
  value: amountSats
33514
33579
  });
33515
33580
  }
33516
- const receiverAddress = decodeSparkAddress(
33517
- receiverSparkAddress,
33518
- this.config.getNetworkType()
33519
- );
33520
33581
  const signerIdentityPublicKey = await this.config.signer.getIdentityPublicKey();
33521
- const isSelfTransfer = (0, import_utils24.equalBytes)(
33582
+ const isSelfTransfer = (0, import_utils25.equalBytes)(
33522
33583
  signerIdentityPublicKey,
33523
- (0, import_utils24.hexToBytes)(receiverAddress.identityPublicKey)
33584
+ (0, import_utils25.hexToBytes)(receiverAddress.identityPublicKey)
33524
33585
  );
33525
33586
  return await this.withLeaves(async () => {
33526
33587
  let leavesToSend = (await this.selectLeaves([amountSats])).get(
@@ -33542,7 +33603,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33542
33603
  );
33543
33604
  const transfer = await this.transferService.sendTransferWithKeyTweaks(
33544
33605
  leafKeyTweaks,
33545
- (0, import_utils24.hexToBytes)(receiverAddress.identityPublicKey)
33606
+ (0, import_utils25.hexToBytes)(receiverAddress.identityPublicKey)
33546
33607
  );
33547
33608
  const leavesToRemove = new Set(leavesToSend.map((leaf) => leaf.id));
33548
33609
  this.leaves = this.leaves.filter((leaf) => !leavesToRemove.has(leaf.id));
@@ -33558,7 +33619,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33558
33619
  }
33559
33620
  return mapTransferToWalletTransfer(
33560
33621
  transfer,
33561
- (0, import_utils24.bytesToHex)(await this.config.signer.getIdentityPublicKey())
33622
+ (0, import_utils25.bytesToHex)(await this.config.signer.getIdentityPublicKey())
33562
33623
  );
33563
33624
  });
33564
33625
  }
@@ -33914,7 +33975,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33914
33975
  const invoice2 = await sspClient.requestLightningReceive({
33915
33976
  amountSats: amountSats2,
33916
33977
  network: bitcoinNetwork,
33917
- paymentHash: (0, import_utils24.bytesToHex)(paymentHash),
33978
+ paymentHash: (0, import_utils25.bytesToHex)(paymentHash),
33918
33979
  expirySecs: expirySeconds,
33919
33980
  memo: memo2,
33920
33981
  includeSparkAddress,
@@ -34023,7 +34084,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34023
34084
  const sparkFallbackAddress = decodedInvoice.fallbackAddress;
34024
34085
  const paymentHash = decodedInvoice.paymentHash;
34025
34086
  if (preferSpark) {
34026
- if (sparkFallbackAddress === void 0 || isValidSparkFallback((0, import_utils24.hexToBytes)(sparkFallbackAddress)) === false) {
34087
+ if (sparkFallbackAddress === void 0 || isValidSparkFallback((0, import_utils25.hexToBytes)(sparkFallbackAddress)) === false) {
34027
34088
  console.warn(
34028
34089
  "No valid spark address found in invoice. Defaulting to lightning."
34029
34090
  );
@@ -34077,10 +34138,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34077
34138
  );
34078
34139
  const swapResponse = await this.lightningService.swapNodesForPreimage({
34079
34140
  leaves: leavesToSend,
34080
- receiverIdentityPubkey: (0, import_utils24.hexToBytes)(
34141
+ receiverIdentityPubkey: (0, import_utils25.hexToBytes)(
34081
34142
  this.config.getSspIdentityPublicKey()
34082
34143
  ),
34083
- paymentHash: (0, import_utils24.hexToBytes)(paymentHash),
34144
+ paymentHash: (0, import_utils25.hexToBytes)(paymentHash),
34084
34145
  isInboundPayment: false,
34085
34146
  invoiceString: invoice,
34086
34147
  feeSats: feeEstimate,
@@ -34198,7 +34259,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34198
34259
  });
34199
34260
  await this.syncTokenOutputs();
34200
34261
  const bech32mTokenIdentifier = encodeBech32mTokenIdentifier({
34201
- tokenIdentifier: (0, import_utils24.hexToBytes)(firstTokenIdentifierHexSeen),
34262
+ tokenIdentifier: (0, import_utils25.hexToBytes)(firstTokenIdentifierHexSeen),
34202
34263
  network: this.config.getNetworkType()
34203
34264
  });
34204
34265
  const receiverOutputs = decoded.map((d) => ({
@@ -34229,7 +34290,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34229
34290
  if (!feeEstimate) {
34230
34291
  throw new Error("Failed to get lightning send fee estimate");
34231
34292
  }
34232
- const satsFeeEstimate = (0, import_core12.mapCurrencyAmount)(feeEstimate.feeEstimate);
34293
+ const satsFeeEstimate = (0, import_core13.mapCurrencyAmount)(feeEstimate.feeEstimate);
34233
34294
  return Math.ceil(satsFeeEstimate.sats);
34234
34295
  }
34235
34296
  // ***** Cooperative Exit Flow *****
@@ -34386,11 +34447,11 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34386
34447
  const connectorOutputs = [];
34387
34448
  for (let i = 0; i < connectorTx.outputsLength - 1; i++) {
34388
34449
  connectorOutputs.push({
34389
- txid: (0, import_utils24.hexToBytes)(connectorTxId),
34450
+ txid: (0, import_utils25.hexToBytes)(connectorTxId),
34390
34451
  index: i
34391
34452
  });
34392
34453
  }
34393
- const sspPubIdentityKey = (0, import_utils24.hexToBytes)(this.config.getSspIdentityPublicKey());
34454
+ const sspPubIdentityKey = (0, import_utils25.hexToBytes)(this.config.getSspIdentityPublicKey());
34394
34455
  const transfer = await this.coopExitService.getConnectorRefundSignatures({
34395
34456
  leaves: leafKeyTweaks,
34396
34457
  exitTxId: coopExitTxId,
@@ -34444,7 +34505,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34444
34505
  return transfers?.[0];
34445
34506
  }
34446
34507
  async constructTransfersWithUserRequest(transfers) {
34447
- const identityPublicKey = (0, import_utils24.bytesToHex)(
34508
+ const identityPublicKey = (0, import_utils25.bytesToHex)(
34448
34509
  await this.config.signer.getIdentityPublicKey()
34449
34510
  );
34450
34511
  const userRequests = await this.sspClient?.getTransfers(
@@ -34688,7 +34749,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34688
34749
  hash,
34689
34750
  compact
34690
34751
  );
34691
- return (0, import_utils24.bytesToHex)(signature);
34752
+ return (0, import_utils25.bytesToHex)(signature);
34692
34753
  }
34693
34754
  /**
34694
34755
  * Validates a message with the identity key.
@@ -34700,7 +34761,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34700
34761
  async validateMessageWithIdentityKey(message, signature) {
34701
34762
  const hash = (0, import_sha213.sha256)(message);
34702
34763
  if (typeof signature === "string") {
34703
- signature = (0, import_utils24.hexToBytes)(signature);
34764
+ signature = (0, import_utils25.hexToBytes)(signature);
34704
34765
  }
34705
34766
  return this.config.signer.validateMessageWithIdentityKey(hash, signature);
34706
34767
  }
@@ -34713,7 +34774,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34713
34774
  */
34714
34775
  async signTransaction(txHex, keyType = "auto-detect") {
34715
34776
  try {
34716
- const tx = import_btc_signer6.Transaction.fromRaw((0, import_utils24.hexToBytes)(txHex));
34777
+ const tx = import_btc_signer6.Transaction.fromRaw((0, import_utils25.hexToBytes)(txHex));
34717
34778
  let publicKey;
34718
34779
  switch (keyType.toLowerCase()) {
34719
34780
  case "identity":
@@ -34746,7 +34807,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34746
34807
  publicKey,
34747
34808
  this.config.getNetwork()
34748
34809
  );
34749
- if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(identityScript)) {
34810
+ if ((0, import_utils25.bytesToHex)(script) === (0, import_utils25.bytesToHex)(identityScript)) {
34750
34811
  try {
34751
34812
  this.config.signer.signTransactionIndex(tx, i, publicKey);
34752
34813
  inputsSigned++;
@@ -34790,13 +34851,13 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34790
34851
  depositPubKey,
34791
34852
  this.config.getNetwork()
34792
34853
  );
34793
- if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(identityScript)) {
34854
+ if ((0, import_utils25.bytesToHex)(script) === (0, import_utils25.bytesToHex)(identityScript)) {
34794
34855
  return {
34795
34856
  publicKey: identityPubKey,
34796
34857
  keyType: "identity"
34797
34858
  };
34798
34859
  }
34799
- if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(depositScript)) {
34860
+ if ((0, import_utils25.bytesToHex)(script) === (0, import_utils25.bytesToHex)(depositScript)) {
34800
34861
  return {
34801
34862
  publicKey: depositPubKey,
34802
34863
  keyType: "deposit"
@@ -35090,7 +35151,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
35090
35151
  });
35091
35152
  Object.assign(aggregatedNodes, response.nodes ?? {});
35092
35153
  const received = Object.keys(response.nodes ?? {}).length;
35093
- if (received < pageSize) {
35154
+ if (received < pageSize || baseRequest.source?.$case === "nodeIds") {
35094
35155
  return {
35095
35156
  nodes: aggregatedNodes,
35096
35157
  offset: response.offset
@@ -35139,7 +35200,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
35139
35200
  } catch (error) {
35140
35201
  if (error instanceof Error) {
35141
35202
  error.message += ` [traceId: ${traceId}]`;
35142
- } else if ((0, import_core12.isObject)(error)) {
35203
+ } else if ((0, import_core13.isObject)(error)) {
35143
35204
  error["traceId"] = traceId;
35144
35205
  }
35145
35206
  throw error;
@@ -35212,7 +35273,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
35212
35273
  var import_sdk_trace_web = require("@opentelemetry/sdk-trace-web");
35213
35274
  var import_instrumentation = require("@opentelemetry/instrumentation");
35214
35275
  var import_instrumentation_fetch = require("@opentelemetry/instrumentation-fetch");
35215
- var import_core13 = require("@opentelemetry/core");
35276
+ var import_core14 = require("@opentelemetry/core");
35216
35277
  var import_api2 = require("@opentelemetry/api");
35217
35278
  var SparkWalletBrowser = class _SparkWalletBrowser extends SparkWallet {
35218
35279
  static async initialize({
@@ -35248,7 +35309,7 @@ function initializeTracerEnvBrowser({
35248
35309
  }) {
35249
35310
  const provider = new import_sdk_trace_web.WebTracerProvider({ spanProcessors });
35250
35311
  provider.register();
35251
- import_api2.propagation.setGlobalPropagator(new import_core13.W3CTraceContextPropagator());
35312
+ import_api2.propagation.setGlobalPropagator(new import_core14.W3CTraceContextPropagator());
35252
35313
  (0, import_instrumentation.registerInstrumentations)({
35253
35314
  instrumentations: [
35254
35315
  new import_instrumentation_fetch.FetchInstrumentation({
@@ -35282,6 +35343,7 @@ setCrypto(cryptoImpl2);
35282
35343
  INITIAL_SEQUENCE,
35283
35344
  InternalValidationError,
35284
35345
  KeyDerivationType,
35346
+ LOGGER_NAMES,
35285
35347
  LRC_WALLET_NETWORK,
35286
35348
  Network,
35287
35349
  NetworkError,
@@ -35289,6 +35351,7 @@ setCrypto(cryptoImpl2);
35289
35351
  NotImplementedError,
35290
35352
  RPCError,
35291
35353
  SparkSDKError,
35354
+ SparkSdkLogger,
35292
35355
  SparkWallet,
35293
35356
  TEST_UNILATERAL_DIRECT_SEQUENCE,
35294
35357
  TEST_UNILATERAL_SEQUENCE,