@buildonspark/spark-sdk 0.2.10 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/dist/bare/chunk-P6AVV7VD.js +34 -0
  3. package/dist/bare/index.cjs +729 -166
  4. package/dist/bare/index.d.cts +62 -5
  5. package/dist/bare/index.d.ts +62 -5
  6. package/dist/bare/index.js +675 -173
  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-A5M55UR3.js → chunk-5VWGOHED.js} +499 -8
  10. package/dist/{chunk-MWBK6QBF.js → chunk-NQMQVXR5.js} +1 -1
  11. package/dist/chunk-NX5KPN5F.js +34 -0
  12. package/dist/{chunk-JXLWOQK5.js → chunk-OEK3R57K.js} +196 -162
  13. package/dist/{chunk-76SYPHOC.js → chunk-TB7DG5CU.js} +2 -2
  14. package/dist/{chunk-6CMNEDBK.js → chunk-XXTWWW6L.js} +1 -1
  15. package/dist/{client-Dd3QnxQu.d.ts → client-D7KDa4Ih.d.ts} +1 -1
  16. package/dist/{client-B9CAWKWz.d.cts → client-DVuA5-7M.d.cts} +1 -1
  17. package/dist/debug.cjs +725 -163
  18. package/dist/debug.d.cts +8 -5
  19. package/dist/debug.d.ts +8 -5
  20. package/dist/debug.js +5 -4
  21. package/dist/graphql/objects/index.d.cts +3 -3
  22. package/dist/graphql/objects/index.d.ts +3 -3
  23. package/dist/index.cjs +810 -246
  24. package/dist/index.d.cts +6 -6
  25. package/dist/index.d.ts +6 -6
  26. package/dist/index.js +11 -5
  27. package/dist/index.node.cjs +810 -246
  28. package/dist/index.node.d.cts +6 -6
  29. package/dist/index.node.d.ts +6 -6
  30. package/dist/index.node.js +10 -4
  31. package/dist/{xchain-address-BPwpnmuY.d.ts → logging-ClNhGzus.d.ts} +18 -4
  32. package/dist/{xchain-address-CNQEwLjR.d.cts → logging-D3kvES69.d.cts} +18 -4
  33. package/dist/native/chunk-D3SZRO65.js +36 -0
  34. package/dist/native/index.cjs +808 -244
  35. package/dist/native/index.d.cts +62 -5
  36. package/dist/native/index.d.ts +62 -5
  37. package/dist/native/index.js +769 -268
  38. package/dist/native/{wasm-2KV6XFEP.js → wasm-3YAXKQ7F.js} +25 -0
  39. package/dist/native/{xhr-transport-WHMS3FGG.js → xhr-transport-TNCG4HTW.js} +2 -2
  40. package/dist/proto/spark.cjs +499 -8
  41. package/dist/proto/spark.d.cts +1 -1
  42. package/dist/proto/spark.d.ts +1 -1
  43. package/dist/proto/spark.js +17 -1
  44. package/dist/proto/spark_token.d.cts +1 -1
  45. package/dist/proto/spark_token.d.ts +1 -1
  46. package/dist/proto/spark_token.js +2 -2
  47. package/dist/{spark-CtGJPkx4.d.cts → spark-C7OG9mGJ.d.cts} +79 -2
  48. package/dist/{spark-CtGJPkx4.d.ts → spark-C7OG9mGJ.d.ts} +79 -2
  49. package/dist/{spark-wallet-yc2KhsVY.d.cts → spark-wallet-Dg5IRQe2.d.cts} +3 -5
  50. package/dist/{spark-wallet-Cp3yv6cK.d.ts → spark-wallet-DiHSU-pz.d.ts} +3 -5
  51. package/dist/{spark-wallet.node-D4IovOHu.d.ts → spark-wallet.node-BZrxwomN.d.ts} +1 -1
  52. package/dist/{spark-wallet.node-D0Qw5Wb4.d.cts → spark-wallet.node-DSWb18zh.d.cts} +1 -1
  53. package/dist/spark_bindings/wasm/index.cjs +51 -0
  54. package/dist/spark_bindings/wasm/index.js +25 -0
  55. package/dist/tests/test-utils.cjs +725 -155
  56. package/dist/tests/test-utils.d.cts +4 -4
  57. package/dist/tests/test-utils.d.ts +4 -4
  58. package/dist/tests/test-utils.js +6 -5
  59. package/dist/{token-transactions-CwhlOgIP.d.cts → token-transactions-B-WqFYpW.d.cts} +2 -2
  60. package/dist/{token-transactions-0nmR9mQO.d.ts → token-transactions-DovxHIxV.d.ts} +2 -2
  61. package/dist/types/index.cjs +492 -9
  62. package/dist/types/index.d.cts +2 -2
  63. package/dist/types/index.d.ts +2 -2
  64. package/dist/types/index.js +2 -2
  65. package/dist/{xhr-transport-RH6LDRXS.js → xhr-transport-IWJPYF7F.js} +2 -2
  66. package/package.json +1 -1
  67. package/src/proto/common.ts +1 -1
  68. package/src/proto/google/protobuf/descriptor.ts +4 -10
  69. package/src/proto/google/protobuf/duration.ts +1 -1
  70. package/src/proto/google/protobuf/empty.ts +1 -1
  71. package/src/proto/google/protobuf/timestamp.ts +1 -1
  72. package/src/proto/mock.ts +1 -1
  73. package/src/proto/spark.ts +593 -3
  74. package/src/proto/spark_authn.ts +1 -1
  75. package/src/proto/spark_token.ts +1 -1
  76. package/src/proto/validate/validate.ts +27 -79
  77. package/src/services/deposit.ts +60 -4
  78. package/src/services/lightning.ts +2 -2
  79. package/src/services/signing.ts +1 -1
  80. package/src/services/token-transactions.ts +2 -5
  81. package/src/services/transfer.ts +2 -2
  82. package/src/services/xhr-transport.ts +2 -2
  83. package/src/signer/signer.ts +2 -2
  84. package/src/spark-wallet/spark-wallet.ts +25 -33
  85. package/src/spark_bindings/wasm/index.ts +21 -0
  86. package/src/tests/address.test.ts +10 -10
  87. package/src/tests/bitcoin.test.ts +2 -2
  88. package/src/tests/integration/coop-exit.test.ts +1 -1
  89. package/src/tests/integration/lightning.test.ts +1 -1
  90. package/src/tests/integration/ssp/coop-exit-validation.test.ts +2 -2
  91. package/src/tests/integration/ssp/static_deposit.test.ts +122 -33
  92. package/src/tests/integration/swap.test.ts +1 -1
  93. package/src/tests/integration/transfer.test.ts +1 -5
  94. package/src/tests/integration/wallet.test.ts +7 -7
  95. package/src/tests/integration/watchtower.test.ts +3 -3
  96. package/src/tests/token-hashing.test.ts +3 -6
  97. package/src/tests/token-outputs.test.ts +3 -3
  98. package/src/tests/utils/test-faucet.ts +2 -2
  99. package/src/types/sdk-types.ts +1 -1
  100. package/src/utils/adaptor-signature.ts +12 -13
  101. package/src/utils/address.ts +10 -10
  102. package/src/utils/bitcoin.ts +7 -11
  103. package/src/utils/index.ts +1 -0
  104. package/src/utils/keys.ts +10 -10
  105. package/src/utils/logging.ts +40 -0
  106. package/src/utils/secret-sharing.ts +10 -12
  107. package/src/utils/token-transactions.ts +1 -2
  108. package/src/utils/transfer_package.ts +1 -1
  109. package/src/utils/unilateral-exit.ts +1 -1
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_utils12.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_utils12.bytesToHex)(message),
1142
+ statechainCommitments,
1143
+ selfCommitment,
1144
+ statechainSignatures,
1145
+ selfSignature: (0, import_utils12.bytesToHex)(selfSignature),
1146
+ statechainPublicKeys,
1147
+ selfPublicKey: (0, import_utils12.bytesToHex)(selfPublicKey),
1148
+ verifyingKey: (0, import_utils12.bytesToHex)(verifyingKey),
1149
+ adaptorPubKey: adaptorPubKey ? (0, import_utils12.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_utils12;
1126
1182
  var init_wasm = __esm({
1127
1183
  "src/spark_bindings/wasm/index.ts"() {
1128
1184
  "use strict";
1129
1185
  init_buffer();
1186
+ import_utils12 = 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");
1559
1620
  var import_secp256k1 = require("@noble/curves/secp256k1");
1560
- var import_utils2 = require("@noble/hashes/utils");
1621
+ var import_utils2 = require("@noble/curves/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";
@@ -2123,6 +2186,41 @@ function utxoSwapRequestTypeToJSON(object) {
2123
2186
  return "UNRECOGNIZED";
2124
2187
  }
2125
2188
  }
2189
+ function invoiceStatusFromJSON(object) {
2190
+ switch (object) {
2191
+ case 0:
2192
+ case "NOT_FOUND":
2193
+ return 0 /* NOT_FOUND */;
2194
+ case 1:
2195
+ case "PENDING":
2196
+ return 1 /* PENDING */;
2197
+ case 2:
2198
+ case "FINALIZED":
2199
+ return 2 /* FINALIZED */;
2200
+ case 3:
2201
+ case "EXPIRED":
2202
+ return 3 /* EXPIRED */;
2203
+ case -1:
2204
+ case "UNRECOGNIZED":
2205
+ default:
2206
+ return -1 /* UNRECOGNIZED */;
2207
+ }
2208
+ }
2209
+ function invoiceStatusToJSON(object) {
2210
+ switch (object) {
2211
+ case 0 /* NOT_FOUND */:
2212
+ return "NOT_FOUND";
2213
+ case 1 /* PENDING */:
2214
+ return "PENDING";
2215
+ case 2 /* FINALIZED */:
2216
+ return "FINALIZED";
2217
+ case 3 /* EXPIRED */:
2218
+ return "EXPIRED";
2219
+ case -1 /* UNRECOGNIZED */:
2220
+ default:
2221
+ return "UNRECOGNIZED";
2222
+ }
2223
+ }
2126
2224
  function initiatePreimageSwapRequest_ReasonFromJSON(object) {
2127
2225
  switch (object) {
2128
2226
  case 0:
@@ -2862,6 +2960,140 @@ var GenerateDepositAddressResponse = {
2862
2960
  return message;
2863
2961
  }
2864
2962
  };
2963
+ function createBaseGenerateStaticDepositAddressRequest() {
2964
+ return { signingPublicKey: new Uint8Array(0), identityPublicKey: new Uint8Array(0), network: 0 };
2965
+ }
2966
+ var GenerateStaticDepositAddressRequest = {
2967
+ encode(message, writer = new import_wire4.BinaryWriter()) {
2968
+ if (message.signingPublicKey.length !== 0) {
2969
+ writer.uint32(10).bytes(message.signingPublicKey);
2970
+ }
2971
+ if (message.identityPublicKey.length !== 0) {
2972
+ writer.uint32(18).bytes(message.identityPublicKey);
2973
+ }
2974
+ if (message.network !== 0) {
2975
+ writer.uint32(24).int32(message.network);
2976
+ }
2977
+ return writer;
2978
+ },
2979
+ decode(input, length) {
2980
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
2981
+ const end = length === void 0 ? reader.len : reader.pos + length;
2982
+ const message = createBaseGenerateStaticDepositAddressRequest();
2983
+ while (reader.pos < end) {
2984
+ const tag = reader.uint32();
2985
+ switch (tag >>> 3) {
2986
+ case 1: {
2987
+ if (tag !== 10) {
2988
+ break;
2989
+ }
2990
+ message.signingPublicKey = reader.bytes();
2991
+ continue;
2992
+ }
2993
+ case 2: {
2994
+ if (tag !== 18) {
2995
+ break;
2996
+ }
2997
+ message.identityPublicKey = reader.bytes();
2998
+ continue;
2999
+ }
3000
+ case 3: {
3001
+ if (tag !== 24) {
3002
+ break;
3003
+ }
3004
+ message.network = reader.int32();
3005
+ continue;
3006
+ }
3007
+ }
3008
+ if ((tag & 7) === 4 || tag === 0) {
3009
+ break;
3010
+ }
3011
+ reader.skip(tag & 7);
3012
+ }
3013
+ return message;
3014
+ },
3015
+ fromJSON(object) {
3016
+ return {
3017
+ signingPublicKey: isSet3(object.signingPublicKey) ? bytesFromBase642(object.signingPublicKey) : new Uint8Array(0),
3018
+ identityPublicKey: isSet3(object.identityPublicKey) ? bytesFromBase642(object.identityPublicKey) : new Uint8Array(0),
3019
+ network: isSet3(object.network) ? networkFromJSON(object.network) : 0
3020
+ };
3021
+ },
3022
+ toJSON(message) {
3023
+ const obj = {};
3024
+ if (message.signingPublicKey.length !== 0) {
3025
+ obj.signingPublicKey = base64FromBytes2(message.signingPublicKey);
3026
+ }
3027
+ if (message.identityPublicKey.length !== 0) {
3028
+ obj.identityPublicKey = base64FromBytes2(message.identityPublicKey);
3029
+ }
3030
+ if (message.network !== 0) {
3031
+ obj.network = networkToJSON(message.network);
3032
+ }
3033
+ return obj;
3034
+ },
3035
+ create(base) {
3036
+ return GenerateStaticDepositAddressRequest.fromPartial(base ?? {});
3037
+ },
3038
+ fromPartial(object) {
3039
+ const message = createBaseGenerateStaticDepositAddressRequest();
3040
+ message.signingPublicKey = object.signingPublicKey ?? new Uint8Array(0);
3041
+ message.identityPublicKey = object.identityPublicKey ?? new Uint8Array(0);
3042
+ message.network = object.network ?? 0;
3043
+ return message;
3044
+ }
3045
+ };
3046
+ function createBaseGenerateStaticDepositAddressResponse() {
3047
+ return { depositAddress: void 0 };
3048
+ }
3049
+ var GenerateStaticDepositAddressResponse = {
3050
+ encode(message, writer = new import_wire4.BinaryWriter()) {
3051
+ if (message.depositAddress !== void 0) {
3052
+ Address.encode(message.depositAddress, writer.uint32(10).fork()).join();
3053
+ }
3054
+ return writer;
3055
+ },
3056
+ decode(input, length) {
3057
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
3058
+ const end = length === void 0 ? reader.len : reader.pos + length;
3059
+ const message = createBaseGenerateStaticDepositAddressResponse();
3060
+ while (reader.pos < end) {
3061
+ const tag = reader.uint32();
3062
+ switch (tag >>> 3) {
3063
+ case 1: {
3064
+ if (tag !== 10) {
3065
+ break;
3066
+ }
3067
+ message.depositAddress = Address.decode(reader, reader.uint32());
3068
+ continue;
3069
+ }
3070
+ }
3071
+ if ((tag & 7) === 4 || tag === 0) {
3072
+ break;
3073
+ }
3074
+ reader.skip(tag & 7);
3075
+ }
3076
+ return message;
3077
+ },
3078
+ fromJSON(object) {
3079
+ return { depositAddress: isSet3(object.depositAddress) ? Address.fromJSON(object.depositAddress) : void 0 };
3080
+ },
3081
+ toJSON(message) {
3082
+ const obj = {};
3083
+ if (message.depositAddress !== void 0) {
3084
+ obj.depositAddress = Address.toJSON(message.depositAddress);
3085
+ }
3086
+ return obj;
3087
+ },
3088
+ create(base) {
3089
+ return GenerateStaticDepositAddressResponse.fromPartial(base ?? {});
3090
+ },
3091
+ fromPartial(object) {
3092
+ const message = createBaseGenerateStaticDepositAddressResponse();
3093
+ message.depositAddress = object.depositAddress !== void 0 && object.depositAddress !== null ? Address.fromPartial(object.depositAddress) : void 0;
3094
+ return message;
3095
+ }
3096
+ };
2865
3097
  function createBaseUTXO() {
2866
3098
  return { rawTx: new Uint8Array(0), vout: 0, network: 0, txid: new Uint8Array(0) };
2867
3099
  }
@@ -8975,7 +9207,8 @@ function createBaseTransferLeaf() {
8975
9207
  signature: new Uint8Array(0),
8976
9208
  intermediateRefundTx: new Uint8Array(0),
8977
9209
  intermediateDirectRefundTx: new Uint8Array(0),
8978
- intermediateDirectFromCpfpRefundTx: new Uint8Array(0)
9210
+ intermediateDirectFromCpfpRefundTx: new Uint8Array(0),
9211
+ pendingKeyTweakPublicKey: new Uint8Array(0)
8979
9212
  };
8980
9213
  }
8981
9214
  var TransferLeaf = {
@@ -8998,6 +9231,9 @@ var TransferLeaf = {
8998
9231
  if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
8999
9232
  writer.uint32(50).bytes(message.intermediateDirectFromCpfpRefundTx);
9000
9233
  }
9234
+ if (message.pendingKeyTweakPublicKey.length !== 0) {
9235
+ writer.uint32(58).bytes(message.pendingKeyTweakPublicKey);
9236
+ }
9001
9237
  return writer;
9002
9238
  },
9003
9239
  decode(input, length) {
@@ -9049,6 +9285,13 @@ var TransferLeaf = {
9049
9285
  message.intermediateDirectFromCpfpRefundTx = reader.bytes();
9050
9286
  continue;
9051
9287
  }
9288
+ case 7: {
9289
+ if (tag !== 58) {
9290
+ break;
9291
+ }
9292
+ message.pendingKeyTweakPublicKey = reader.bytes();
9293
+ continue;
9294
+ }
9052
9295
  }
9053
9296
  if ((tag & 7) === 4 || tag === 0) {
9054
9297
  break;
@@ -9064,7 +9307,8 @@ var TransferLeaf = {
9064
9307
  signature: isSet3(object.signature) ? bytesFromBase642(object.signature) : new Uint8Array(0),
9065
9308
  intermediateRefundTx: isSet3(object.intermediateRefundTx) ? bytesFromBase642(object.intermediateRefundTx) : new Uint8Array(0),
9066
9309
  intermediateDirectRefundTx: isSet3(object.intermediateDirectRefundTx) ? bytesFromBase642(object.intermediateDirectRefundTx) : new Uint8Array(0),
9067
- intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0)
9310
+ intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0),
9311
+ pendingKeyTweakPublicKey: isSet3(object.pendingKeyTweakPublicKey) ? bytesFromBase642(object.pendingKeyTweakPublicKey) : new Uint8Array(0)
9068
9312
  };
9069
9313
  },
9070
9314
  toJSON(message) {
@@ -9087,6 +9331,9 @@ var TransferLeaf = {
9087
9331
  if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
9088
9332
  obj.intermediateDirectFromCpfpRefundTx = base64FromBytes2(message.intermediateDirectFromCpfpRefundTx);
9089
9333
  }
9334
+ if (message.pendingKeyTweakPublicKey.length !== 0) {
9335
+ obj.pendingKeyTweakPublicKey = base64FromBytes2(message.pendingKeyTweakPublicKey);
9336
+ }
9090
9337
  return obj;
9091
9338
  },
9092
9339
  create(base) {
@@ -9100,6 +9347,7 @@ var TransferLeaf = {
9100
9347
  message.intermediateRefundTx = object.intermediateRefundTx ?? new Uint8Array(0);
9101
9348
  message.intermediateDirectRefundTx = object.intermediateDirectRefundTx ?? new Uint8Array(0);
9102
9349
  message.intermediateDirectFromCpfpRefundTx = object.intermediateDirectFromCpfpRefundTx ?? new Uint8Array(0);
9350
+ message.pendingKeyTweakPublicKey = object.pendingKeyTweakPublicKey ?? new Uint8Array(0);
9103
9351
  return message;
9104
9352
  }
9105
9353
  };
@@ -11997,13 +12245,16 @@ var QueryUserSignedRefundsRequest = {
11997
12245
  }
11998
12246
  };
11999
12247
  function createBaseQueryUserSignedRefundsResponse() {
12000
- return { userSignedRefunds: [] };
12248
+ return { userSignedRefunds: [], transfer: void 0 };
12001
12249
  }
12002
12250
  var QueryUserSignedRefundsResponse = {
12003
12251
  encode(message, writer = new import_wire4.BinaryWriter()) {
12004
12252
  for (const v of message.userSignedRefunds) {
12005
12253
  UserSignedRefund.encode(v, writer.uint32(10).fork()).join();
12006
12254
  }
12255
+ if (message.transfer !== void 0) {
12256
+ Transfer.encode(message.transfer, writer.uint32(26).fork()).join();
12257
+ }
12007
12258
  return writer;
12008
12259
  },
12009
12260
  decode(input, length) {
@@ -12020,6 +12271,13 @@ var QueryUserSignedRefundsResponse = {
12020
12271
  message.userSignedRefunds.push(UserSignedRefund.decode(reader, reader.uint32()));
12021
12272
  continue;
12022
12273
  }
12274
+ case 3: {
12275
+ if (tag !== 26) {
12276
+ break;
12277
+ }
12278
+ message.transfer = Transfer.decode(reader, reader.uint32());
12279
+ continue;
12280
+ }
12023
12281
  }
12024
12282
  if ((tag & 7) === 4 || tag === 0) {
12025
12283
  break;
@@ -12030,7 +12288,8 @@ var QueryUserSignedRefundsResponse = {
12030
12288
  },
12031
12289
  fromJSON(object) {
12032
12290
  return {
12033
- userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : []
12291
+ userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : [],
12292
+ transfer: isSet3(object.transfer) ? Transfer.fromJSON(object.transfer) : void 0
12034
12293
  };
12035
12294
  },
12036
12295
  toJSON(message) {
@@ -12038,6 +12297,9 @@ var QueryUserSignedRefundsResponse = {
12038
12297
  if (message.userSignedRefunds?.length) {
12039
12298
  obj.userSignedRefunds = message.userSignedRefunds.map((e) => UserSignedRefund.toJSON(e));
12040
12299
  }
12300
+ if (message.transfer !== void 0) {
12301
+ obj.transfer = Transfer.toJSON(message.transfer);
12302
+ }
12041
12303
  return obj;
12042
12304
  },
12043
12305
  create(base) {
@@ -12046,6 +12308,7 @@ var QueryUserSignedRefundsResponse = {
12046
12308
  fromPartial(object) {
12047
12309
  const message = createBaseQueryUserSignedRefundsResponse();
12048
12310
  message.userSignedRefunds = object.userSignedRefunds?.map((e) => UserSignedRefund.fromPartial(e)) || [];
12311
+ message.transfer = object.transfer !== void 0 && object.transfer !== null ? Transfer.fromPartial(object.transfer) : void 0;
12049
12312
  return message;
12050
12313
  }
12051
12314
  };
@@ -12932,7 +13195,8 @@ function createBaseDepositAddressQueryResult() {
12932
13195
  depositAddress: "",
12933
13196
  userSigningPublicKey: new Uint8Array(0),
12934
13197
  verifyingPublicKey: new Uint8Array(0),
12935
- leafId: void 0
13198
+ leafId: void 0,
13199
+ proofOfPossession: void 0
12936
13200
  };
12937
13201
  }
12938
13202
  var DepositAddressQueryResult = {
@@ -12949,6 +13213,9 @@ var DepositAddressQueryResult = {
12949
13213
  if (message.leafId !== void 0) {
12950
13214
  writer.uint32(34).string(message.leafId);
12951
13215
  }
13216
+ if (message.proofOfPossession !== void 0) {
13217
+ DepositAddressProof.encode(message.proofOfPossession, writer.uint32(42).fork()).join();
13218
+ }
12952
13219
  return writer;
12953
13220
  },
12954
13221
  decode(input, length) {
@@ -12986,6 +13253,13 @@ var DepositAddressQueryResult = {
12986
13253
  message.leafId = reader.string();
12987
13254
  continue;
12988
13255
  }
13256
+ case 5: {
13257
+ if (tag !== 42) {
13258
+ break;
13259
+ }
13260
+ message.proofOfPossession = DepositAddressProof.decode(reader, reader.uint32());
13261
+ continue;
13262
+ }
12989
13263
  }
12990
13264
  if ((tag & 7) === 4 || tag === 0) {
12991
13265
  break;
@@ -12999,7 +13273,8 @@ var DepositAddressQueryResult = {
12999
13273
  depositAddress: isSet3(object.depositAddress) ? globalThis.String(object.depositAddress) : "",
13000
13274
  userSigningPublicKey: isSet3(object.userSigningPublicKey) ? bytesFromBase642(object.userSigningPublicKey) : new Uint8Array(0),
13001
13275
  verifyingPublicKey: isSet3(object.verifyingPublicKey) ? bytesFromBase642(object.verifyingPublicKey) : new Uint8Array(0),
13002
- leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0
13276
+ leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0,
13277
+ proofOfPossession: isSet3(object.proofOfPossession) ? DepositAddressProof.fromJSON(object.proofOfPossession) : void 0
13003
13278
  };
13004
13279
  },
13005
13280
  toJSON(message) {
@@ -13016,6 +13291,9 @@ var DepositAddressQueryResult = {
13016
13291
  if (message.leafId !== void 0) {
13017
13292
  obj.leafId = message.leafId;
13018
13293
  }
13294
+ if (message.proofOfPossession !== void 0) {
13295
+ obj.proofOfPossession = DepositAddressProof.toJSON(message.proofOfPossession);
13296
+ }
13019
13297
  return obj;
13020
13298
  },
13021
13299
  create(base) {
@@ -13027,6 +13305,7 @@ var DepositAddressQueryResult = {
13027
13305
  message.userSigningPublicKey = object.userSigningPublicKey ?? new Uint8Array(0);
13028
13306
  message.verifyingPublicKey = object.verifyingPublicKey ?? new Uint8Array(0);
13029
13307
  message.leafId = object.leafId ?? void 0;
13308
+ message.proofOfPossession = object.proofOfPossession !== void 0 && object.proofOfPossession !== null ? DepositAddressProof.fromPartial(object.proofOfPossession) : void 0;
13030
13309
  return message;
13031
13310
  }
13032
13311
  };
@@ -14991,7 +15270,7 @@ var QueryNodesByValueResponse_NodesEntry = {
14991
15270
  }
14992
15271
  };
14993
15272
  function createBaseGetUtxosForAddressRequest() {
14994
- return { address: "", offset: 0, limit: 0, network: 0 };
15273
+ return { address: "", offset: 0, limit: 0, network: 0, excludeClaimed: false };
14995
15274
  }
14996
15275
  var GetUtxosForAddressRequest = {
14997
15276
  encode(message, writer = new import_wire4.BinaryWriter()) {
@@ -15007,6 +15286,9 @@ var GetUtxosForAddressRequest = {
15007
15286
  if (message.network !== 0) {
15008
15287
  writer.uint32(32).int32(message.network);
15009
15288
  }
15289
+ if (message.excludeClaimed !== false) {
15290
+ writer.uint32(40).bool(message.excludeClaimed);
15291
+ }
15010
15292
  return writer;
15011
15293
  },
15012
15294
  decode(input, length) {
@@ -15044,6 +15326,13 @@ var GetUtxosForAddressRequest = {
15044
15326
  message.network = reader.int32();
15045
15327
  continue;
15046
15328
  }
15329
+ case 5: {
15330
+ if (tag !== 40) {
15331
+ break;
15332
+ }
15333
+ message.excludeClaimed = reader.bool();
15334
+ continue;
15335
+ }
15047
15336
  }
15048
15337
  if ((tag & 7) === 4 || tag === 0) {
15049
15338
  break;
@@ -15057,7 +15346,8 @@ var GetUtxosForAddressRequest = {
15057
15346
  address: isSet3(object.address) ? globalThis.String(object.address) : "",
15058
15347
  offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
15059
15348
  limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
15060
- network: isSet3(object.network) ? networkFromJSON(object.network) : 0
15349
+ network: isSet3(object.network) ? networkFromJSON(object.network) : 0,
15350
+ excludeClaimed: isSet3(object.excludeClaimed) ? globalThis.Boolean(object.excludeClaimed) : false
15061
15351
  };
15062
15352
  },
15063
15353
  toJSON(message) {
@@ -15074,6 +15364,9 @@ var GetUtxosForAddressRequest = {
15074
15364
  if (message.network !== 0) {
15075
15365
  obj.network = networkToJSON(message.network);
15076
15366
  }
15367
+ if (message.excludeClaimed !== false) {
15368
+ obj.excludeClaimed = message.excludeClaimed;
15369
+ }
15077
15370
  return obj;
15078
15371
  },
15079
15372
  create(base) {
@@ -15085,6 +15378,7 @@ var GetUtxosForAddressRequest = {
15085
15378
  message.offset = object.offset ?? 0;
15086
15379
  message.limit = object.limit ?? 0;
15087
15380
  message.network = object.network ?? 0;
15381
+ message.excludeClaimed = object.excludeClaimed ?? false;
15088
15382
  return message;
15089
15383
  }
15090
15384
  };
@@ -15156,6 +15450,225 @@ var GetUtxosForAddressResponse = {
15156
15450
  return message;
15157
15451
  }
15158
15452
  };
15453
+ function createBaseQuerySparkInvoicesRequest() {
15454
+ return { limit: 0, offset: 0, invoice: [] };
15455
+ }
15456
+ var QuerySparkInvoicesRequest = {
15457
+ encode(message, writer = new import_wire4.BinaryWriter()) {
15458
+ if (message.limit !== 0) {
15459
+ writer.uint32(8).int64(message.limit);
15460
+ }
15461
+ if (message.offset !== 0) {
15462
+ writer.uint32(16).int64(message.offset);
15463
+ }
15464
+ for (const v of message.invoice) {
15465
+ writer.uint32(26).string(v);
15466
+ }
15467
+ return writer;
15468
+ },
15469
+ decode(input, length) {
15470
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
15471
+ const end = length === void 0 ? reader.len : reader.pos + length;
15472
+ const message = createBaseQuerySparkInvoicesRequest();
15473
+ while (reader.pos < end) {
15474
+ const tag = reader.uint32();
15475
+ switch (tag >>> 3) {
15476
+ case 1: {
15477
+ if (tag !== 8) {
15478
+ break;
15479
+ }
15480
+ message.limit = longToNumber2(reader.int64());
15481
+ continue;
15482
+ }
15483
+ case 2: {
15484
+ if (tag !== 16) {
15485
+ break;
15486
+ }
15487
+ message.offset = longToNumber2(reader.int64());
15488
+ continue;
15489
+ }
15490
+ case 3: {
15491
+ if (tag !== 26) {
15492
+ break;
15493
+ }
15494
+ message.invoice.push(reader.string());
15495
+ continue;
15496
+ }
15497
+ }
15498
+ if ((tag & 7) === 4 || tag === 0) {
15499
+ break;
15500
+ }
15501
+ reader.skip(tag & 7);
15502
+ }
15503
+ return message;
15504
+ },
15505
+ fromJSON(object) {
15506
+ return {
15507
+ limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
15508
+ offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
15509
+ invoice: globalThis.Array.isArray(object?.invoice) ? object.invoice.map((e) => globalThis.String(e)) : []
15510
+ };
15511
+ },
15512
+ toJSON(message) {
15513
+ const obj = {};
15514
+ if (message.limit !== 0) {
15515
+ obj.limit = Math.round(message.limit);
15516
+ }
15517
+ if (message.offset !== 0) {
15518
+ obj.offset = Math.round(message.offset);
15519
+ }
15520
+ if (message.invoice?.length) {
15521
+ obj.invoice = message.invoice;
15522
+ }
15523
+ return obj;
15524
+ },
15525
+ create(base) {
15526
+ return QuerySparkInvoicesRequest.fromPartial(base ?? {});
15527
+ },
15528
+ fromPartial(object) {
15529
+ const message = createBaseQuerySparkInvoicesRequest();
15530
+ message.limit = object.limit ?? 0;
15531
+ message.offset = object.offset ?? 0;
15532
+ message.invoice = object.invoice?.map((e) => e) || [];
15533
+ return message;
15534
+ }
15535
+ };
15536
+ function createBaseQuerySparkInvoicesResponse() {
15537
+ return { offset: 0, invoiceStatuses: [] };
15538
+ }
15539
+ var QuerySparkInvoicesResponse = {
15540
+ encode(message, writer = new import_wire4.BinaryWriter()) {
15541
+ if (message.offset !== 0) {
15542
+ writer.uint32(8).int64(message.offset);
15543
+ }
15544
+ for (const v of message.invoiceStatuses) {
15545
+ InvoiceResponse.encode(v, writer.uint32(18).fork()).join();
15546
+ }
15547
+ return writer;
15548
+ },
15549
+ decode(input, length) {
15550
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
15551
+ const end = length === void 0 ? reader.len : reader.pos + length;
15552
+ const message = createBaseQuerySparkInvoicesResponse();
15553
+ while (reader.pos < end) {
15554
+ const tag = reader.uint32();
15555
+ switch (tag >>> 3) {
15556
+ case 1: {
15557
+ if (tag !== 8) {
15558
+ break;
15559
+ }
15560
+ message.offset = longToNumber2(reader.int64());
15561
+ continue;
15562
+ }
15563
+ case 2: {
15564
+ if (tag !== 18) {
15565
+ break;
15566
+ }
15567
+ message.invoiceStatuses.push(InvoiceResponse.decode(reader, reader.uint32()));
15568
+ continue;
15569
+ }
15570
+ }
15571
+ if ((tag & 7) === 4 || tag === 0) {
15572
+ break;
15573
+ }
15574
+ reader.skip(tag & 7);
15575
+ }
15576
+ return message;
15577
+ },
15578
+ fromJSON(object) {
15579
+ return {
15580
+ offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
15581
+ invoiceStatuses: globalThis.Array.isArray(object?.invoiceStatuses) ? object.invoiceStatuses.map((e) => InvoiceResponse.fromJSON(e)) : []
15582
+ };
15583
+ },
15584
+ toJSON(message) {
15585
+ const obj = {};
15586
+ if (message.offset !== 0) {
15587
+ obj.offset = Math.round(message.offset);
15588
+ }
15589
+ if (message.invoiceStatuses?.length) {
15590
+ obj.invoiceStatuses = message.invoiceStatuses.map((e) => InvoiceResponse.toJSON(e));
15591
+ }
15592
+ return obj;
15593
+ },
15594
+ create(base) {
15595
+ return QuerySparkInvoicesResponse.fromPartial(base ?? {});
15596
+ },
15597
+ fromPartial(object) {
15598
+ const message = createBaseQuerySparkInvoicesResponse();
15599
+ message.offset = object.offset ?? 0;
15600
+ message.invoiceStatuses = object.invoiceStatuses?.map((e) => InvoiceResponse.fromPartial(e)) || [];
15601
+ return message;
15602
+ }
15603
+ };
15604
+ function createBaseInvoiceResponse() {
15605
+ return { invoice: "", status: 0 };
15606
+ }
15607
+ var InvoiceResponse = {
15608
+ encode(message, writer = new import_wire4.BinaryWriter()) {
15609
+ if (message.invoice !== "") {
15610
+ writer.uint32(10).string(message.invoice);
15611
+ }
15612
+ if (message.status !== 0) {
15613
+ writer.uint32(16).int32(message.status);
15614
+ }
15615
+ return writer;
15616
+ },
15617
+ decode(input, length) {
15618
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
15619
+ const end = length === void 0 ? reader.len : reader.pos + length;
15620
+ const message = createBaseInvoiceResponse();
15621
+ while (reader.pos < end) {
15622
+ const tag = reader.uint32();
15623
+ switch (tag >>> 3) {
15624
+ case 1: {
15625
+ if (tag !== 10) {
15626
+ break;
15627
+ }
15628
+ message.invoice = reader.string();
15629
+ continue;
15630
+ }
15631
+ case 2: {
15632
+ if (tag !== 16) {
15633
+ break;
15634
+ }
15635
+ message.status = reader.int32();
15636
+ continue;
15637
+ }
15638
+ }
15639
+ if ((tag & 7) === 4 || tag === 0) {
15640
+ break;
15641
+ }
15642
+ reader.skip(tag & 7);
15643
+ }
15644
+ return message;
15645
+ },
15646
+ fromJSON(object) {
15647
+ return {
15648
+ invoice: isSet3(object.invoice) ? globalThis.String(object.invoice) : "",
15649
+ status: isSet3(object.status) ? invoiceStatusFromJSON(object.status) : 0
15650
+ };
15651
+ },
15652
+ toJSON(message) {
15653
+ const obj = {};
15654
+ if (message.invoice !== "") {
15655
+ obj.invoice = message.invoice;
15656
+ }
15657
+ if (message.status !== 0) {
15658
+ obj.status = invoiceStatusToJSON(message.status);
15659
+ }
15660
+ return obj;
15661
+ },
15662
+ create(base) {
15663
+ return InvoiceResponse.fromPartial(base ?? {});
15664
+ },
15665
+ fromPartial(object) {
15666
+ const message = createBaseInvoiceResponse();
15667
+ message.invoice = object.invoice ?? "";
15668
+ message.status = object.status ?? 0;
15669
+ return message;
15670
+ }
15671
+ };
15159
15672
  var SparkServiceDefinition = {
15160
15673
  name: "SparkService",
15161
15674
  fullName: "spark.SparkService",
@@ -15168,6 +15681,15 @@ var SparkServiceDefinition = {
15168
15681
  responseStream: false,
15169
15682
  options: {}
15170
15683
  },
15684
+ /** Generates a new static deposit address of the user or returns the existing one for the specified network. */
15685
+ generate_static_deposit_address: {
15686
+ name: "generate_static_deposit_address",
15687
+ requestType: GenerateStaticDepositAddressRequest,
15688
+ requestStream: false,
15689
+ responseType: GenerateStaticDepositAddressResponse,
15690
+ responseStream: false,
15691
+ options: {}
15692
+ },
15171
15693
  start_deposit_tree_creation: {
15172
15694
  name: "start_deposit_tree_creation",
15173
15695
  requestType: StartDepositTreeCreationRequest,
@@ -15609,6 +16131,14 @@ var SparkServiceDefinition = {
15609
16131
  responseType: GetUtxosForAddressResponse,
15610
16132
  responseStream: false,
15611
16133
  options: {}
16134
+ },
16135
+ query_spark_invoices: {
16136
+ name: "query_spark_invoices",
16137
+ requestType: QuerySparkInvoicesRequest,
16138
+ requestStream: false,
16139
+ responseType: QuerySparkInvoicesResponse,
16140
+ responseStream: false,
16141
+ options: {}
15612
16142
  }
15613
16143
  }
15614
16144
  };
@@ -15839,9 +16369,6 @@ function uint64be(value) {
15839
16369
  }
15840
16370
 
15841
16371
  // 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
16372
  var BECH32M_LIMIT = 1024;
15846
16373
  var AddressNetwork = {
15847
16374
  MAINNET: "sp",
@@ -15856,7 +16383,7 @@ function encodeSparkAddress(payload) {
15856
16383
  function encodeSparkAddressWithSignature(payload, signature) {
15857
16384
  try {
15858
16385
  isValidPublicKey(payload.identityPublicKey);
15859
- const identityPublicKey = (0, import_utils2.hexToBytes)(payload.identityPublicKey);
16386
+ const identityPublicKey = (0, import_utils3.hexToBytes)(payload.identityPublicKey);
15860
16387
  let sparkInvoiceFields;
15861
16388
  if (payload.sparkInvoiceFields) {
15862
16389
  validateSparkInvoiceFields(payload.sparkInvoiceFields);
@@ -15900,8 +16427,8 @@ function decodeSparkAddress(address2, network) {
15900
16427
  }
15901
16428
  const payload = SparkAddress.decode(import_base2.bech32m.fromWords(decoded.words));
15902
16429
  const { identityPublicKey, sparkInvoiceFields, signature } = payload;
15903
- const identityPubkeyHex = (0, import_utils2.bytesToHex)(identityPublicKey);
15904
- const signatureHex = signature ? (0, import_utils2.bytesToHex)(signature) : void 0;
16430
+ const identityPubkeyHex = (0, import_utils3.bytesToHex)(identityPublicKey);
16431
+ const signatureHex = signature ? (0, import_utils3.bytesToHex)(signature) : void 0;
15905
16432
  isValidPublicKey(identityPubkeyHex);
15906
16433
  return {
15907
16434
  identityPublicKey: identityPubkeyHex,
@@ -15911,10 +16438,10 @@ function decodeSparkAddress(address2, network) {
15911
16438
  id: import_uuidv7.UUID.ofInner(sparkInvoiceFields.id).toString(),
15912
16439
  paymentType: sparkInvoiceFields.paymentType ? sparkInvoiceFields.paymentType.$case === "tokensPayment" ? {
15913
16440
  type: "tokens",
15914
- tokenIdentifier: sparkInvoiceFields.paymentType.tokensPayment.tokenIdentifier ? (0, import_utils2.bytesToHex)(
16441
+ tokenIdentifier: sparkInvoiceFields.paymentType.tokensPayment.tokenIdentifier ? (0, import_utils3.bytesToHex)(
15915
16442
  sparkInvoiceFields.paymentType.tokensPayment.tokenIdentifier
15916
16443
  ) : void 0,
15917
- amount: sparkInvoiceFields.paymentType.tokensPayment.amount ? (0, import_utils3.bytesToNumberBE)(
16444
+ amount: sparkInvoiceFields.paymentType.tokensPayment.amount ? (0, import_utils2.bytesToNumberBE)(
15918
16445
  sparkInvoiceFields.paymentType.tokensPayment.amount
15919
16446
  ) : void 0
15920
16447
  } : sparkInvoiceFields.paymentType.$case === "satsPayment" ? {
@@ -15922,7 +16449,7 @@ function decodeSparkAddress(address2, network) {
15922
16449
  amount: sparkInvoiceFields.paymentType.satsPayment.amount
15923
16450
  } : void 0 : void 0,
15924
16451
  memo: sparkInvoiceFields.memo,
15925
- senderPublicKey: sparkInvoiceFields.senderPublicKey ? (0, import_utils2.bytesToHex)(sparkInvoiceFields.senderPublicKey) : void 0,
16452
+ senderPublicKey: sparkInvoiceFields.senderPublicKey ? (0, import_utils3.bytesToHex)(sparkInvoiceFields.senderPublicKey) : void 0,
15926
16453
  expiryTime: sparkInvoiceFields.expiryTime
15927
16454
  },
15928
16455
  signature: signatureHex
@@ -15971,7 +16498,7 @@ function isValidSparkAddress(address2) {
15971
16498
  }
15972
16499
  function isValidPublicKey(publicKey) {
15973
16500
  try {
15974
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex(publicKey);
16501
+ const point = import_secp256k1.secp256k1.Point.fromHex(publicKey);
15975
16502
  point.assertValidity();
15976
16503
  } catch (error) {
15977
16504
  throw new ValidationError(
@@ -16006,7 +16533,7 @@ function validateSparkInvoiceFields(sparkInvoiceFields) {
16006
16533
  }
16007
16534
  if (senderPublicKey) {
16008
16535
  try {
16009
- isValidPublicKey((0, import_utils2.bytesToHex)(senderPublicKey));
16536
+ isValidPublicKey((0, import_utils3.bytesToHex)(senderPublicKey));
16010
16537
  } catch (error) {
16011
16538
  throw new ValidationError(
16012
16539
  "Invalid sender public key",
@@ -16057,7 +16584,7 @@ function validateSparkInvoiceFields(sparkInvoiceFields) {
16057
16584
  value: tokensAmount
16058
16585
  });
16059
16586
  }
16060
- const tokensAmountBigInt = (0, import_utils3.bytesToNumberBE)(tokensAmount);
16587
+ const tokensAmountBigInt = (0, import_utils2.bytesToNumberBE)(tokensAmount);
16061
16588
  if (tokensAmountBigInt < 0 || tokensAmountBigInt > MAX_UINT128) {
16062
16589
  throw new ValidationError(
16063
16590
  "Asset amount must be between 0 and MAX_UINT128",
@@ -16201,8 +16728,8 @@ function encodeSparkInvoiceFieldsV1Canonical(f) {
16201
16728
  // src/utils/adaptor-signature.ts
16202
16729
  init_buffer();
16203
16730
  var import_modular = require("@noble/curves/abstract/modular");
16204
- var import_utils4 = require("@noble/curves/abstract/utils");
16205
16731
  var import_secp256k12 = require("@noble/curves/secp256k1");
16732
+ var import_utils4 = require("@noble/curves/utils");
16206
16733
  function generateSignatureFromExistingAdaptor(signature, adaptorPrivateKeyBytes) {
16207
16734
  const { r, s } = parseSignature(signature);
16208
16735
  const sBigInt = (0, import_utils4.bytesToNumberBE)(s);
@@ -16269,7 +16796,7 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
16269
16796
  const commitmenet = import_secp256k12.schnorr.utils.taggedHash(
16270
16797
  "BIP0340/challenge",
16271
16798
  r,
16272
- pubKey.toRawBytes().slice(1),
16799
+ pubKey.toBytes().slice(1),
16273
16800
  hash
16274
16801
  );
16275
16802
  if (commitmenet.length > 32) {
@@ -16277,22 +16804,20 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
16277
16804
  }
16278
16805
  const e = (0, import_modular.mod)((0, import_utils4.bytesToNumberBE)(commitmenet), import_secp256k12.secp256k1.CURVE.n);
16279
16806
  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");
16807
+ const sG = import_secp256k12.secp256k1.Point.BASE.multiplyUnsafe((0, import_utils4.bytesToNumberBE)(s));
16808
+ const eP = pubKey.multiplyUnsafe(negE);
16809
+ const R = sG.add(eP);
16810
+ if (R.is0()) {
16811
+ throw new Error("R is zero");
16287
16812
  }
16288
16813
  R.assertValidity();
16289
- const adaptorPoint = import_secp256k12.secp256k1.ProjectivePoint.fromHex(adaptorPubkey);
16814
+ const adaptorPoint = import_secp256k12.secp256k1.Point.fromHex(adaptorPubkey);
16290
16815
  const newR = R.add(adaptorPoint);
16291
- if (!inbound && newR.equals(import_secp256k12.secp256k1.ProjectivePoint.ZERO)) {
16816
+ if (!inbound && newR.equals(import_secp256k12.secp256k1.Point.ZERO)) {
16292
16817
  throw new Error("calculated R point is the point at infinity");
16293
16818
  }
16294
16819
  newR.assertValidity();
16295
- if (!newR.hasEvenY()) {
16820
+ if (newR.y % 2n !== 0n) {
16296
16821
  throw new Error("calculated R y-value is odd");
16297
16822
  }
16298
16823
  const rNum = (0, import_utils4.bytesToNumberBE)(r);
@@ -16333,8 +16858,8 @@ function parseSignature(signature) {
16333
16858
 
16334
16859
  // src/utils/bitcoin.ts
16335
16860
  init_buffer();
16336
- var import_utils5 = require("@noble/curves/abstract/utils");
16337
16861
  var import_secp256k13 = require("@noble/curves/secp256k1");
16862
+ var import_utils5 = require("@noble/curves/utils");
16338
16863
  var import_sha22 = require("@noble/hashes/sha2");
16339
16864
  var btc2 = __toESM(require("@scure/btc-signer"), 1);
16340
16865
 
@@ -16442,8 +16967,8 @@ function computeTaprootKeyNoScript(pubkey) {
16442
16967
  const taggedHash = import_secp256k13.schnorr.utils.taggedHash("TapTweak", pubkey);
16443
16968
  const tweak = (0, import_utils5.bytesToNumberBE)(taggedHash);
16444
16969
  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();
16970
+ const Q = P.add(import_secp256k13.secp256k1.Point.fromPrivateKey(tweak));
16971
+ return Q.toBytes();
16447
16972
  }
16448
16973
  function getP2TRScriptFromPublicKey(pubKey, network) {
16449
16974
  if (pubKey.length !== 33) {
@@ -16453,9 +16978,9 @@ function getP2TRScriptFromPublicKey(pubKey, network) {
16453
16978
  expected: 33
16454
16979
  });
16455
16980
  }
16456
- const internalKey = import_secp256k13.secp256k1.ProjectivePoint.fromHex(pubKey);
16981
+ const internalKey = import_secp256k13.secp256k1.Point.fromHex(pubKey);
16457
16982
  const script = btc2.p2tr(
16458
- internalKey.toRawBytes().slice(1, 33),
16983
+ internalKey.toBytes().slice(1, 33),
16459
16984
  void 0,
16460
16985
  getNetwork(network)
16461
16986
  ).script;
@@ -16475,9 +17000,9 @@ function getP2TRAddressFromPublicKey(pubKey, network) {
16475
17000
  expected: 33
16476
17001
  });
16477
17002
  }
16478
- const internalKey = import_secp256k13.secp256k1.ProjectivePoint.fromHex(pubKey);
17003
+ const internalKey = import_secp256k13.secp256k1.Point.fromHex(pubKey);
16479
17004
  const address2 = btc2.p2tr(
16480
- internalKey.toRawBytes().slice(1, 33),
17005
+ internalKey.toBytes().slice(1, 33),
16481
17006
  void 0,
16482
17007
  getNetwork(network)
16483
17008
  ).address;
@@ -16579,8 +17104,8 @@ function getTxEstimatedVbytesSizeByNumberOfInputsOutputs(numInputs, numOutputs)
16579
17104
 
16580
17105
  // src/utils/keys.ts
16581
17106
  init_buffer();
16582
- var import_utils6 = require("@noble/curves/abstract/utils");
16583
17107
  var import_secp256k14 = require("@noble/curves/secp256k1");
17108
+ var import_utils6 = require("@noble/curves/utils");
16584
17109
  function addPublicKeys(a, b) {
16585
17110
  if (a.length !== 33 || b.length !== 33) {
16586
17111
  throw new ValidationError("Public keys must be 33 bytes", {
@@ -16589,9 +17114,9 @@ function addPublicKeys(a, b) {
16589
17114
  expected: 33
16590
17115
  });
16591
17116
  }
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);
17117
+ const pubkeyA = import_secp256k14.secp256k1.Point.fromHex(a);
17118
+ const pubkeyB = import_secp256k14.secp256k1.Point.fromHex(b);
17119
+ return pubkeyA.add(pubkeyB).toBytes(true);
16595
17120
  }
16596
17121
  function applyAdditiveTweakToPublicKey(pubkey, tweak) {
16597
17122
  if (pubkey.length !== 33) {
@@ -16608,11 +17133,11 @@ function applyAdditiveTweakToPublicKey(pubkey, tweak) {
16608
17133
  expected: 32
16609
17134
  });
16610
17135
  }
16611
- const pubkeyPoint = import_secp256k14.secp256k1.ProjectivePoint.fromHex(pubkey);
17136
+ const pubkeyPoint = import_secp256k14.secp256k1.Point.fromHex(pubkey);
16612
17137
  const privTweek = import_secp256k14.secp256k1.utils.normPrivateKeyToScalar(tweak);
16613
17138
  const pubTweek = import_secp256k14.secp256k1.getPublicKey(privTweek, true);
16614
- const tweekPoint = import_secp256k14.secp256k1.ProjectivePoint.fromHex(pubTweek);
16615
- return pubkeyPoint.add(tweekPoint).toRawBytes(true);
17139
+ const tweekPoint = import_secp256k14.secp256k1.Point.fromHex(pubTweek);
17140
+ return pubkeyPoint.add(tweekPoint).toBytes(true);
16616
17141
  }
16617
17142
  function subtractPublicKeys(a, b) {
16618
17143
  if (a.length !== 33 || b.length !== 33) {
@@ -16622,9 +17147,9 @@ function subtractPublicKeys(a, b) {
16622
17147
  expected: 33
16623
17148
  });
16624
17149
  }
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);
17150
+ const pubkeyA = import_secp256k14.secp256k1.Point.fromHex(a);
17151
+ const pubkeyB = import_secp256k14.secp256k1.Point.fromHex(b);
17152
+ return pubkeyA.subtract(pubkeyB).toBytes(true);
16628
17153
  }
16629
17154
  function addPrivateKeys(a, b) {
16630
17155
  if (a.length !== 32 || b.length !== 32) {
@@ -17837,7 +18362,7 @@ fragment UserRequestFragment on UserRequest {
17837
18362
 
17838
18363
  // src/types/sdk-types.ts
17839
18364
  init_buffer();
17840
- var import_utils7 = require("@noble/curves/abstract/utils");
18365
+ var import_utils7 = require("@noble/curves/utils");
17841
18366
  function mapTreeNodeToWalletLeaf(proto) {
17842
18367
  return {
17843
18368
  id: proto.id,
@@ -17988,8 +18513,8 @@ function collectResponses(responses) {
17988
18513
 
17989
18514
  // src/utils/secret-sharing.ts
17990
18515
  init_buffer();
17991
- var import_utils8 = require("@noble/curves/abstract/utils");
17992
18516
  var import_secp256k15 = require("@noble/curves/secp256k1");
18517
+ var import_utils8 = require("@noble/curves/utils");
17993
18518
  function getRandomBigInt(max) {
17994
18519
  const byteLength = max.toString(2).length + 7 >> 3;
17995
18520
  const maxBigInt = max;
@@ -18075,11 +18600,11 @@ function generatePolynomialForSecretSharing(fieldModulus, secret, degree) {
18075
18600
  const coefficients = new Array(degree);
18076
18601
  const proofs = new Array(degree);
18077
18602
  coefficients[0] = secret;
18078
- proofs[0] = import_secp256k15.secp256k1.ProjectivePoint.fromPrivateKey(secret).toRawBytes(true);
18603
+ proofs[0] = import_secp256k15.secp256k1.Point.fromPrivateKey(secret).toBytes(true);
18079
18604
  for (let i = 1; i < degree; i++) {
18080
18605
  const coefficient = getRandomBigInt(fieldModulus);
18081
18606
  coefficients[i] = coefficient;
18082
- proofs[i] = import_secp256k15.secp256k1.ProjectivePoint.fromPrivateKey(coefficient).toRawBytes(true);
18607
+ proofs[i] = import_secp256k15.secp256k1.Point.fromPrivateKey(coefficient).toBytes(true);
18083
18608
  }
18084
18609
  return {
18085
18610
  fieldModulus,
@@ -18151,9 +18676,9 @@ function recoverSecret(shares) {
18151
18676
  return result;
18152
18677
  }
18153
18678
  function validateShare(share) {
18154
- const targetPubkey = import_secp256k15.secp256k1.ProjectivePoint.fromPrivateKey(
18155
- share.share
18156
- ).toRawBytes(true);
18679
+ const targetPubkey = import_secp256k15.secp256k1.Point.fromPrivateKey(share.share).toBytes(
18680
+ true
18681
+ );
18157
18682
  let resultPubkey = share.proofs[0];
18158
18683
  if (!resultPubkey) {
18159
18684
  throw new ValidationError("Result pubkey is not valid", {
@@ -18172,8 +18697,8 @@ function validateShare(share) {
18172
18697
  });
18173
18698
  }
18174
18699
  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);
18700
+ const scaledPoint = import_secp256k15.secp256k1.Point.fromHex(pubkey).multiply(value);
18701
+ resultPubkey = import_secp256k15.secp256k1.Point.fromHex(resultPubkey).add(scaledPoint).toBytes(true);
18177
18702
  }
18178
18703
  if (!(0, import_utils8.equalBytes)(resultPubkey, targetPubkey)) {
18179
18704
  throw new ValidationError("Share is not valid", {
@@ -18374,8 +18899,7 @@ function getNetworkFromBech32mTokenIdentifier(bech32mTokenIdentifier) {
18374
18899
 
18375
18900
  // src/utils/token-transactions.ts
18376
18901
  init_buffer();
18377
- var import_utils9 = require("@noble/curves/abstract/utils");
18378
- var import_utils10 = require("@scure/btc-signer/utils");
18902
+ var import_utils9 = require("@noble/curves/utils");
18379
18903
  function sumAvailableTokens(outputs) {
18380
18904
  try {
18381
18905
  return outputs.reduce(
@@ -18410,7 +18934,7 @@ function filterTokenBalanceForTokenIdentifier(tokenBalances, tokenIdentifier) {
18410
18934
  }
18411
18935
  const tokenIdentifierBytes = decodeBech32mTokenIdentifier(tokenIdentifier).tokenIdentifier;
18412
18936
  const tokenBalance = [...tokenBalances.entries()].find(
18413
- ([, info]) => (0, import_utils10.equalBytes)(info.tokenMetadata.rawTokenIdentifier, tokenIdentifierBytes)
18937
+ ([, info]) => (0, import_utils9.equalBytes)(info.tokenMetadata.rawTokenIdentifier, tokenIdentifierBytes)
18414
18938
  );
18415
18939
  if (!tokenBalance) {
18416
18940
  return {
@@ -18424,7 +18948,7 @@ function filterTokenBalanceForTokenIdentifier(tokenBalances, tokenIdentifier) {
18424
18948
 
18425
18949
  // src/utils/transfer_package.ts
18426
18950
  init_buffer();
18427
- var import_utils11 = require("@noble/curves/abstract/utils");
18951
+ var import_utils10 = require("@noble/curves/utils");
18428
18952
  var import_sha24 = require("@noble/hashes/sha2");
18429
18953
  function getTransferPackageSigningPayload(transferID, transferPackage) {
18430
18954
  const encryptedPayload = transferPackage.keyTweakPackage;
@@ -18433,7 +18957,7 @@ function getTransferPackageSigningPayload(transferID, transferPackage) {
18433
18957
  ).map(([key, value]) => ({ key, value }));
18434
18958
  pairs.sort((a, b) => a.key.localeCompare(b.key));
18435
18959
  const encoder = new TextEncoder();
18436
- let message = (0, import_utils11.hexToBytes)(transferID.replaceAll("-", ""));
18960
+ let message = (0, import_utils10.hexToBytes)(transferID.replaceAll("-", ""));
18437
18961
  for (const pair of pairs) {
18438
18962
  const keyPart = encoder.encode(pair.key + ":");
18439
18963
  const separator = encoder.encode(";");
@@ -18786,7 +19310,7 @@ function getEphemeralAnchorOutput() {
18786
19310
 
18787
19311
  // src/utils/unilateral-exit.ts
18788
19312
  init_buffer();
18789
- var import_utils12 = require("@noble/curves/abstract/utils");
19313
+ var import_utils11 = require("@noble/curves/utils");
18790
19314
  var import_legacy = require("@noble/hashes/legacy");
18791
19315
  var import_sha25 = require("@noble/hashes/sha2");
18792
19316
  var btc3 = __toESM(require("@scure/btc-signer"), 1);
@@ -18801,7 +19325,7 @@ function isEphemeralAnchorOutput(script, amount) {
18801
19325
  }
18802
19326
  async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network) {
18803
19327
  const result = [];
18804
- const nodes = nodeHexStrings.map((hex) => TreeNode.decode((0, import_utils12.hexToBytes)(hex)));
19328
+ const nodes = nodeHexStrings.map((hex) => TreeNode.decode((0, import_utils11.hexToBytes)(hex)));
18805
19329
  const nodeMap = /* @__PURE__ */ new Map();
18806
19330
  for (const node of nodes) {
18807
19331
  nodeMap.set(node.id, node);
@@ -18857,10 +19381,10 @@ async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network)
18857
19381
  }
18858
19382
  }
18859
19383
  for (const chainNode of chain) {
18860
- const nodeTx = (0, import_utils12.bytesToHex)(chainNode.nodeTx);
19384
+ const nodeTx = (0, import_utils11.bytesToHex)(chainNode.nodeTx);
18861
19385
  transactions.push(nodeTx);
18862
19386
  if (chainNode.id === node.id) {
18863
- const refundTx = (0, import_utils12.bytesToHex)(chainNode.refundTx);
19387
+ const refundTx = (0, import_utils11.bytesToHex)(chainNode.refundTx);
18864
19388
  transactions.push(refundTx);
18865
19389
  }
18866
19390
  }
@@ -18890,7 +19414,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
18890
19414
  `Node hex string at index ${i} appears to be a raw transaction hex, not a TreeNode protobuf. Use 'leafidtohex' command to convert node IDs to proper hex strings.`
18891
19415
  );
18892
19416
  }
18893
- const nodeBytes = (0, import_utils12.hexToBytes)(hex);
19417
+ const nodeBytes = (0, import_utils11.hexToBytes)(hex);
18894
19418
  const node = TreeNode.decode(nodeBytes);
18895
19419
  if (!node.id) {
18896
19420
  throw new Error(
@@ -18966,7 +19490,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
18966
19490
  }
18967
19491
  }
18968
19492
  for (const chainNode of chain) {
18969
- let nodeTxHex = (0, import_utils12.bytesToHex)(chainNode.nodeTx);
19493
+ let nodeTxHex = (0, import_utils11.bytesToHex)(chainNode.nodeTx);
18970
19494
  try {
18971
19495
  const txObj = getTxFromRawTxHex(nodeTxHex);
18972
19496
  const txid = getTxId(txObj);
@@ -18983,7 +19507,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
18983
19507
  for (let i = txObj.outputsLength - 1; i >= 0; i--) {
18984
19508
  const output = txObj.getOutput(i);
18985
19509
  if (output?.amount === 0n && output.script) {
18986
- anchorOutputScriptHex = (0, import_utils12.bytesToHex)(output.script);
19510
+ anchorOutputScriptHex = (0, import_utils11.bytesToHex)(output.script);
18987
19511
  break;
18988
19512
  }
18989
19513
  }
@@ -19004,11 +19528,11 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
19004
19528
  usedUtxos,
19005
19529
  correctedParentTx
19006
19530
  } = constructFeeBumpTx(nodeTxHex, availableUtxos, feeRate, void 0);
19007
- const feeBumpTx = btc3.Transaction.fromPSBT((0, import_utils12.hexToBytes)(nodeFeeBumpPsbt));
19531
+ const feeBumpTx = btc3.Transaction.fromPSBT((0, import_utils11.hexToBytes)(nodeFeeBumpPsbt));
19008
19532
  var feeBumpOut = feeBumpTx.outputsLength === 1 ? feeBumpTx.getOutput(0) : null;
19009
19533
  var feeBumpOutPubKey = null;
19010
19534
  for (const usedUtxo of usedUtxos) {
19011
- if (feeBumpOut && (0, import_utils12.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
19535
+ if (feeBumpOut && (0, import_utils11.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
19012
19536
  feeBumpOutPubKey = usedUtxo.publicKey;
19013
19537
  }
19014
19538
  const index = availableUtxos.findIndex(
@@ -19023,20 +19547,20 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
19023
19547
  txid: getTxId(feeBumpTx),
19024
19548
  vout: 0,
19025
19549
  value: feeBumpOut.amount,
19026
- script: (0, import_utils12.bytesToHex)(feeBumpOut.script),
19550
+ script: (0, import_utils11.bytesToHex)(feeBumpOut.script),
19027
19551
  publicKey: feeBumpOutPubKey
19028
19552
  });
19029
19553
  const finalNodeTx = correctedParentTx || nodeTxHex;
19030
19554
  txPackages.push({ tx: finalNodeTx, feeBumpPsbt: nodeFeeBumpPsbt });
19031
19555
  if (chainNode.id === node.id) {
19032
- let refundTxHex = (0, import_utils12.bytesToHex)(chainNode.refundTx);
19556
+ let refundTxHex = (0, import_utils11.bytesToHex)(chainNode.refundTx);
19033
19557
  try {
19034
19558
  const txObj = getTxFromRawTxHex(refundTxHex);
19035
19559
  let anchorOutputScriptHex;
19036
19560
  for (let i = txObj.outputsLength - 1; i >= 0; i--) {
19037
19561
  const output = txObj.getOutput(i);
19038
19562
  if (output?.amount === 0n && output.script) {
19039
- anchorOutputScriptHex = (0, import_utils12.bytesToHex)(output.script);
19563
+ anchorOutputScriptHex = (0, import_utils11.bytesToHex)(output.script);
19040
19564
  break;
19041
19565
  }
19042
19566
  }
@@ -19059,12 +19583,12 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
19059
19583
  void 0
19060
19584
  );
19061
19585
  const feeBumpTx2 = btc3.Transaction.fromPSBT(
19062
- (0, import_utils12.hexToBytes)(refundFeeBump.feeBumpPsbt)
19586
+ (0, import_utils11.hexToBytes)(refundFeeBump.feeBumpPsbt)
19063
19587
  );
19064
19588
  var feeBumpOut = feeBumpTx2.outputsLength === 1 ? feeBumpTx2.getOutput(0) : null;
19065
19589
  var feeBumpOutPubKey = null;
19066
19590
  for (const usedUtxo of usedUtxos) {
19067
- if (feeBumpOut && (0, import_utils12.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
19591
+ if (feeBumpOut && (0, import_utils11.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
19068
19592
  feeBumpOutPubKey = usedUtxo.publicKey;
19069
19593
  }
19070
19594
  const index = availableUtxos.findIndex(
@@ -19079,7 +19603,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
19079
19603
  txid: getTxId(feeBumpTx2),
19080
19604
  vout: 0,
19081
19605
  value: feeBumpOut.amount,
19082
- script: (0, import_utils12.bytesToHex)(feeBumpOut.script),
19606
+ script: (0, import_utils11.bytesToHex)(feeBumpOut.script),
19083
19607
  publicKey: feeBumpOutPubKey
19084
19608
  });
19085
19609
  txPackages.push({
@@ -19174,10 +19698,10 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
19174
19698
  if (!fundingUtxo) {
19175
19699
  throw new Error(`UTXO at index ${i} is undefined`);
19176
19700
  }
19177
- const pubKeyHash = hash160((0, import_utils12.hexToBytes)(fundingUtxo.publicKey));
19701
+ const pubKeyHash = hash160((0, import_utils11.hexToBytes)(fundingUtxo.publicKey));
19178
19702
  const scriptToUse = new Uint8Array([0, 20, ...pubKeyHash]);
19179
- const providedScript = (0, import_utils12.hexToBytes)(fundingUtxo.script);
19180
- if ((0, import_utils12.bytesToHex)(scriptToUse) !== (0, import_utils12.bytesToHex)(providedScript)) {
19703
+ const providedScript = (0, import_utils11.hexToBytes)(fundingUtxo.script);
19704
+ if ((0, import_utils11.bytesToHex)(scriptToUse) !== (0, import_utils11.bytesToHex)(providedScript)) {
19181
19705
  throw new Error(
19182
19706
  `\u274C Derived script doesn't match provided script for UTXO ${i + 1}.`
19183
19707
  );
@@ -19242,7 +19766,7 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
19242
19766
  }
19243
19767
  let psbtHex;
19244
19768
  try {
19245
- psbtHex = (0, import_utils12.bytesToHex)(builder.toPSBT());
19769
+ psbtHex = (0, import_utils11.bytesToHex)(builder.toPSBT());
19246
19770
  } catch (error) {
19247
19771
  throw new Error(`Failed to extract transaction: ${error}`);
19248
19772
  }
@@ -19284,11 +19808,14 @@ function getSparkAddressFromTaproot(taprootAddress) {
19284
19808
  throw new ValidationError("Invalid taproot address");
19285
19809
  }
19286
19810
 
19811
+ // src/utils/index.ts
19812
+ init_logging();
19813
+
19287
19814
  // src/signer/signer.ts
19288
19815
  init_buffer();
19289
19816
  var import_secp256k17 = require("@bitcoinerlab/secp256k1");
19290
- var import_utils13 = require("@noble/curves/abstract/utils");
19291
19817
  var import_secp256k18 = require("@noble/curves/secp256k1");
19818
+ var import_utils13 = require("@noble/curves/utils");
19292
19819
  var import_sha26 = require("@noble/hashes/sha2");
19293
19820
  var import_bip32 = require("@scure/bip32");
19294
19821
  var import_bip39 = require("@scure/bip39");
@@ -19298,19 +19825,19 @@ var ecies = __toESM(require("eciesjs"), 1);
19298
19825
 
19299
19826
  // src/constants.ts
19300
19827
  init_buffer();
19301
- var import_core8 = require("@lightsparkdev/core");
19828
+ var import_core9 = require("@lightsparkdev/core");
19302
19829
  var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
19303
19830
  var isBun = globalThis.Bun !== void 0;
19304
- var packageVersion = true ? "0.2.10" : "unknown";
19831
+ var packageVersion = true ? "0.2.12" : "unknown";
19305
19832
  var baseEnvStr = "unknown";
19306
19833
  if (isBun) {
19307
19834
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
19308
19835
  baseEnvStr = `bun/${bunVersion}`;
19309
- } else if (import_core8.isNode) {
19836
+ } else if (import_core9.isNode) {
19310
19837
  baseEnvStr = `node/${process.version}`;
19311
19838
  } else if (isReactNative) {
19312
19839
  baseEnvStr = "react-native";
19313
- } else if (import_core8.isBare) {
19840
+ } else if (import_core9.isBare) {
19314
19841
  const bareVersion = Bare.version;
19315
19842
  baseEnvStr = `bare/${bareVersion}`;
19316
19843
  } else {
@@ -19831,9 +20358,9 @@ init_buffer();
19831
20358
 
19832
20359
  // src/spark-wallet/spark-wallet.ts
19833
20360
  init_buffer();
19834
- var import_core12 = require("@lightsparkdev/core");
19835
- var import_utils24 = require("@noble/curves/abstract/utils");
20361
+ var import_core13 = require("@lightsparkdev/core");
19836
20362
  var import_secp256k115 = require("@noble/curves/secp256k1");
20363
+ var import_utils24 = require("@noble/curves/utils");
19837
20364
  var import_bip392 = require("@scure/bip39");
19838
20365
  var import_english2 = require("@scure/bip39/wordlists/english");
19839
20366
  var import_btc_signer6 = require("@scure/btc-signer");
@@ -19842,7 +20369,7 @@ var import_uuidv75 = require("uuidv7");
19842
20369
 
19843
20370
  // src/graphql/client.ts
19844
20371
  init_buffer();
19845
- var import_core10 = require("@lightsparkdev/core");
20372
+ var import_core11 = require("@lightsparkdev/core");
19846
20373
  var import_sha27 = require("@noble/hashes/sha2");
19847
20374
 
19848
20375
  // src/graphql/mutations/ClaimStaticDeposit.ts
@@ -19896,7 +20423,7 @@ init_buffer();
19896
20423
 
19897
20424
  // src/graphql/objects/CoopExitRequest.ts
19898
20425
  init_buffer();
19899
- var import_core9 = require("@lightsparkdev/core");
20426
+ var import_core10 = require("@lightsparkdev/core");
19900
20427
  var CoopExitRequestFromJson = (obj) => {
19901
20428
  return {
19902
20429
  id: obj["coop_exit_request_id"],
@@ -20477,13 +21004,13 @@ var SspClient = class {
20477
21004
  this.authProvider = new SparkAuthProvider();
20478
21005
  const { fetch } = getFetch();
20479
21006
  const options = config.sspClientOptions;
20480
- this.requester = new import_core10.Requester(
20481
- new import_core10.NodeKeyCache(import_core10.DefaultCrypto),
21007
+ this.requester = new import_core11.Requester(
21008
+ new import_core11.NodeKeyCache(import_core11.DefaultCrypto),
20482
21009
  options.schemaEndpoint || `graphql/spark/2025-03-19`,
20483
21010
  `spark-sdk/0.0.0`,
20484
21011
  this.authProvider,
20485
21012
  options.baseUrl,
20486
- import_core10.DefaultCrypto,
21013
+ import_core11.DefaultCrypto,
20487
21014
  void 0,
20488
21015
  fetch
20489
21016
  );
@@ -20858,7 +21385,7 @@ var SspClient = class {
20858
21385
  {
20859
21386
  queryPayload: GetChallenge,
20860
21387
  variables: {
20861
- public_key: (0, import_core10.bytesToHex)(await this.signer.getIdentityPublicKey())
21388
+ public_key: (0, import_core11.bytesToHex)(await this.signer.getIdentityPublicKey())
20862
21389
  },
20863
21390
  constructObject: (response) => {
20864
21391
  return GetChallengeOutputFromJson(response.get_challenge);
@@ -20874,7 +21401,7 @@ var SspClient = class {
20874
21401
  variables: {
20875
21402
  protected_challenge: protectedChallenge,
20876
21403
  signature,
20877
- identity_public_key: (0, import_core10.bytesToHex)(
21404
+ identity_public_key: (0, import_core11.bytesToHex)(
20878
21405
  await this.signer.getIdentityPublicKey()
20879
21406
  )
20880
21407
  },
@@ -20919,7 +21446,7 @@ var SspClient = class {
20919
21446
  );
20920
21447
  return;
20921
21448
  } catch (err) {
20922
- if ((0, import_core10.isError)(err) && err.message.toLowerCase().includes("challenge expired")) {
21449
+ if ((0, import_core11.isError)(err) && err.message.toLowerCase().includes("challenge expired")) {
20923
21450
  lastErr = err;
20924
21451
  continue;
20925
21452
  }
@@ -21086,7 +21613,7 @@ var WalletConfigService = class {
21086
21613
 
21087
21614
  // src/services/connection.ts
21088
21615
  init_buffer();
21089
- var import_core11 = require("@lightsparkdev/core");
21616
+ var import_core12 = require("@lightsparkdev/core");
21090
21617
  var import_sha28 = require("@noble/hashes/sha2");
21091
21618
  var import_nice_grpc_client_middleware_retry = require("nice-grpc-client-middleware-retry");
21092
21619
  var import_nice_grpc_common2 = require("nice-grpc-common");
@@ -24844,7 +25371,7 @@ var ConnectionManager = class {
24844
25371
  async createMockClient(address2) {
24845
25372
  const channel = await this.createChannelWithTLS(address2);
24846
25373
  const isNodeChannel = "close" in channel;
24847
- if (import_core11.isNode && isNodeChannel && !isBun) {
25374
+ if (import_core12.isNode && isNodeChannel && !isBun) {
24848
25375
  const grpcModule = await import("nice-grpc");
24849
25376
  const { createClient } = "default" in grpcModule ? grpcModule.default : grpcModule;
24850
25377
  const client = createClient(MockServiceDefinition, channel);
@@ -24861,7 +25388,7 @@ var ConnectionManager = class {
24861
25388
  }
24862
25389
  async createChannelWithTLS(address2, certPath) {
24863
25390
  try {
24864
- if (import_core11.isNode && !isBun) {
25391
+ if (import_core12.isNode && !isBun) {
24865
25392
  const grpcModule = await import("nice-grpc");
24866
25393
  const { ChannelCredentials, createChannel } = "default" in grpcModule ? grpcModule.default : grpcModule;
24867
25394
  if (certPath) {
@@ -24892,7 +25419,7 @@ var ConnectionManager = class {
24892
25419
  const { XHRTransport: XHRTransport2 } = await Promise.resolve().then(() => (init_xhr_transport(), xhr_transport_exports));
24893
25420
  return createChannel(
24894
25421
  address2,
24895
- import_core11.isBare ? (0, import_nice_grpc_web.NodeHttpTransport)() : isReactNative ? XHRTransport2() : FetchTransport()
25422
+ import_core12.isBare ? (0, import_nice_grpc_web.NodeHttpTransport)() : isReactNative ? XHRTransport2() : FetchTransport()
24896
25423
  );
24897
25424
  }
24898
25425
  } catch (error) {
@@ -24998,7 +25525,7 @@ var ConnectionManager = class {
24998
25525
  sparkAuthnClient.close?.();
24999
25526
  return verifyResp.sessionToken;
25000
25527
  } catch (error) {
25001
- if ((0, import_core11.isError)(error)) {
25528
+ if ((0, import_core12.isError)(error)) {
25002
25529
  sparkAuthnClient?.close?.();
25003
25530
  if (error.message.includes("challenge expired")) {
25004
25531
  console.warn(
@@ -25049,7 +25576,7 @@ var ConnectionManager = class {
25049
25576
  );
25050
25577
  }
25051
25578
  createAuthnMiddleware() {
25052
- if (import_core11.isNode) {
25579
+ if (import_core12.isNode) {
25053
25580
  return async function* (call, options) {
25054
25581
  const metadata = (0, import_nice_grpc_common2.Metadata)(options.metadata).set(
25055
25582
  "X-Client-Env",
@@ -25071,14 +25598,14 @@ var ConnectionManager = class {
25071
25598
  }
25072
25599
  }
25073
25600
  createMiddleware(address2, authToken) {
25074
- if (import_core11.isNode) {
25601
+ if (import_core12.isNode) {
25075
25602
  return this.createNodeMiddleware(address2, authToken);
25076
25603
  } else {
25077
25604
  return this.createBrowserMiddleware(address2, authToken);
25078
25605
  }
25079
25606
  }
25080
25607
  async *handleMiddlewareError(error, address2, call, metadata, options) {
25081
- if ((0, import_core11.isError)(error)) {
25608
+ if ((0, import_core12.isError)(error)) {
25082
25609
  if (error.message.includes("token has expired")) {
25083
25610
  const newAuthToken = await this.authenticate(address2);
25084
25611
  const clientData = this.clients.get(address2);
@@ -25149,7 +25676,7 @@ var ConnectionManager = class {
25149
25676
  };
25150
25677
  let options = {};
25151
25678
  const isNodeChannel = "close" in channel;
25152
- if (import_core11.isNode && isNodeChannel && !isBun) {
25679
+ if (import_core12.isNode && isNodeChannel && !isBun) {
25153
25680
  const grpcModule = await import("nice-grpc");
25154
25681
  const { openTelemetryClientMiddleware } = await import("nice-grpc-opentelemetry");
25155
25682
  const { createClientFactory } = "default" in grpcModule ? grpcModule.default : grpcModule;
@@ -25199,8 +25726,8 @@ var import_uuidv73 = require("uuidv7");
25199
25726
 
25200
25727
  // src/services/transfer.ts
25201
25728
  init_buffer();
25202
- var import_utils15 = require("@noble/curves/abstract/utils");
25203
25729
  var import_secp256k19 = require("@noble/curves/secp256k1");
25730
+ var import_utils15 = require("@noble/curves/utils");
25204
25731
  var import_sha29 = require("@noble/hashes/sha2");
25205
25732
  var import_btc_signer2 = require("@scure/btc-signer");
25206
25733
  var ecies2 = __toESM(require("eciesjs"), 1);
@@ -27104,7 +27631,8 @@ var DepositService = class {
27104
27631
  }
27105
27632
  async validateDepositAddress({
27106
27633
  address: address2,
27107
- userPubkey
27634
+ userPubkey,
27635
+ verifyCoordinatorProof = false
27108
27636
  }) {
27109
27637
  if (!address2.depositAddressProof || !address2.depositAddressProof.proofOfPossessionSignature || !address2.depositAddressProof.addressSignatures) {
27110
27638
  throw new ValidationError(
@@ -27142,7 +27670,7 @@ var DepositService = class {
27142
27670
  }
27143
27671
  const addrHash = (0, import_sha210.sha256)(address2.address);
27144
27672
  for (const operator of Object.values(this.config.getSigningOperators())) {
27145
- if (operator.identifier === this.config.getCoordinatorIdentifier()) {
27673
+ if (operator.identifier === this.config.getCoordinatorIdentifier() && !verifyCoordinatorProof) {
27146
27674
  continue;
27147
27675
  }
27148
27676
  const operatorPubkey2 = (0, import_utils16.hexToBytes)(operator.identityPublicKey);
@@ -27154,7 +27682,11 @@ var DepositService = class {
27154
27682
  });
27155
27683
  }
27156
27684
  const sig = import_secp256k110.secp256k1.Signature.fromDER(operatorSig);
27157
- const isVerified2 = import_secp256k110.secp256k1.verify(sig, addrHash, operatorPubkey2);
27685
+ const isVerified2 = import_secp256k110.secp256k1.verify(
27686
+ sig.toCompactRawBytes(),
27687
+ addrHash,
27688
+ operatorPubkey2
27689
+ );
27158
27690
  if (!isVerified2) {
27159
27691
  throw new ValidationError("Operator signature verification failed", {
27160
27692
  field: "operatorSignature",
@@ -27163,6 +27695,46 @@ var DepositService = class {
27163
27695
  }
27164
27696
  }
27165
27697
  }
27698
+ async generateStaticDepositAddress({
27699
+ signingPubkey
27700
+ }) {
27701
+ const sparkClient = await this.connectionManager.createSparkClient(
27702
+ this.config.getCoordinatorAddress()
27703
+ );
27704
+ let depositResp;
27705
+ try {
27706
+ depositResp = await sparkClient.generate_static_deposit_address({
27707
+ signingPublicKey: signingPubkey,
27708
+ identityPublicKey: await this.config.signer.getIdentityPublicKey(),
27709
+ network: this.config.getNetworkProto()
27710
+ });
27711
+ } catch (error) {
27712
+ throw new NetworkError(
27713
+ "Failed to generate static deposit address",
27714
+ {
27715
+ operation: "generate_static_deposit_address",
27716
+ errorCount: 1,
27717
+ errors: error instanceof Error ? error.message : String(error)
27718
+ },
27719
+ error
27720
+ );
27721
+ }
27722
+ if (!depositResp.depositAddress) {
27723
+ throw new ValidationError(
27724
+ "No static deposit address response from coordinator",
27725
+ {
27726
+ field: "depositAddress",
27727
+ value: depositResp
27728
+ }
27729
+ );
27730
+ }
27731
+ await this.validateDepositAddress({
27732
+ address: depositResp.depositAddress,
27733
+ userPubkey: signingPubkey,
27734
+ verifyCoordinatorProof: true
27735
+ });
27736
+ return depositResp;
27737
+ }
27166
27738
  async generateDepositAddress({
27167
27739
  signingPubkey,
27168
27740
  leafId,
@@ -27703,8 +28275,8 @@ var DepositService = class {
27703
28275
 
27704
28276
  // src/services/lightning.ts
27705
28277
  init_buffer();
27706
- var import_utils18 = require("@noble/curves/abstract/utils");
27707
28278
  var import_secp256k111 = require("@noble/curves/secp256k1");
28279
+ var import_utils18 = require("@noble/curves/utils");
27708
28280
  var import_sha211 = require("@noble/hashes/sha2");
27709
28281
  var import_uuidv74 = require("uuidv7");
27710
28282
 
@@ -28052,8 +28624,8 @@ var LightningService = class {
28052
28624
 
28053
28625
  // src/services/token-transactions.ts
28054
28626
  init_buffer();
28055
- var import_utils19 = require("@noble/curves/abstract/utils");
28056
28627
  var import_secp256k113 = require("@noble/curves/secp256k1");
28628
+ var import_utils19 = require("@noble/curves/utils");
28057
28629
  var import_utils20 = require("@noble/hashes/utils");
28058
28630
 
28059
28631
  // src/utils/token-hashing.ts
@@ -30972,7 +31544,7 @@ var import_nice_grpc_common3 = require("nice-grpc-common");
30972
31544
 
30973
31545
  // src/services/signing.ts
30974
31546
  init_buffer();
30975
- var import_utils21 = require("@noble/curves/abstract/utils");
31547
+ var import_utils21 = require("@noble/curves/utils");
30976
31548
  var SigningService = class {
30977
31549
  config;
30978
31550
  constructor(config) {
@@ -31138,8 +31710,8 @@ var SigningService = class {
31138
31710
 
31139
31711
  // src/tests/utils/test-faucet.ts
31140
31712
  init_buffer();
31141
- var import_utils22 = require("@noble/curves/abstract/utils");
31142
31713
  var import_secp256k114 = require("@noble/curves/secp256k1");
31714
+ var import_utils22 = require("@noble/curves/utils");
31143
31715
  var btc5 = __toESM(require("@scure/btc-signer"), 1);
31144
31716
  var import_btc_signer5 = require("@scure/btc-signer");
31145
31717
  var import_utils23 = require("@scure/btc-signer/utils");
@@ -31685,7 +32257,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
31685
32257
  setTimeout(maybeUnref, 100);
31686
32258
  }
31687
32259
  };
31688
- if (import_core12.isNode) {
32260
+ if (import_core13.isNode) {
31689
32261
  maybeUnref();
31690
32262
  }
31691
32263
  const claimedTransfersIds = await this.claimTransfers();
@@ -32707,7 +33279,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32707
33279
  * @returns {Promise<string>} A Bitcoin address for depositing funds
32708
33280
  */
32709
33281
  async getSingleUseDepositAddress() {
32710
- return await this.generateDepositAddress(false);
33282
+ return await this.generateDepositAddress();
32711
33283
  }
32712
33284
  /**
32713
33285
  * Generates a new static deposit address for receiving bitcoin funds.
@@ -32716,43 +33288,32 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32716
33288
  * @returns {Promise<string>} A Bitcoin address for depositing funds
32717
33289
  */
32718
33290
  async getStaticDepositAddress() {
32719
- try {
32720
- return await this.generateDepositAddress(true);
32721
- } catch (error) {
32722
- if (error.message?.includes("static deposit address already exists")) {
32723
- const existingAddresses = await this.queryStaticDepositAddresses();
32724
- if (existingAddresses.length > 0 && existingAddresses[0]) {
32725
- return existingAddresses[0];
32726
- } else {
32727
- throw error;
32728
- }
32729
- } else {
32730
- throw error;
32731
- }
33291
+ const signingPubkey = await this.config.signer.getStaticDepositSigningKey(0);
33292
+ const address2 = await this.depositService.generateStaticDepositAddress({
33293
+ signingPubkey
33294
+ });
33295
+ if (!address2.depositAddress) {
33296
+ throw new RPCError("Failed to generate static deposit address", {
33297
+ method: "generateStaticDepositAddress",
33298
+ params: { signingPubkey }
33299
+ });
32732
33300
  }
33301
+ return address2.depositAddress.address;
32733
33302
  }
32734
33303
  /**
32735
33304
  * Generates a deposit address for receiving funds.
32736
- *
32737
- * @param {boolean} static - Whether the address is static or single use
32738
33305
  * @returns {Promise<string>} A deposit address
32739
33306
  * @private
32740
33307
  */
32741
- async generateDepositAddress(isStatic) {
33308
+ async generateDepositAddress() {
32742
33309
  const leafId = (0, import_uuidv75.uuidv7)();
32743
- let signingPubkey;
32744
- if (isStatic) {
32745
- signingPubkey = await this.config.signer.getStaticDepositSigningKey(0);
32746
- } else {
32747
- signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
32748
- type: "leaf" /* LEAF */,
32749
- path: leafId
32750
- });
32751
- }
33310
+ const signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
33311
+ type: "leaf" /* LEAF */,
33312
+ path: leafId
33313
+ });
32752
33314
  const address2 = await this.depositService.generateDepositAddress({
32753
33315
  signingPubkey,
32754
- leafId,
32755
- isStatic
33316
+ leafId
32756
33317
  });
32757
33318
  if (!address2.depositAddress) {
32758
33319
  throw new RPCError("Failed to generate deposit address", {
@@ -32779,7 +33340,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32779
33340
  * @param offset - Pagination offset (default 0).
32780
33341
  * @returns {Promise<{ txid: string, vout: number }[]>} List of confirmed UTXOs.
32781
33342
  */
32782
- async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0) {
33343
+ async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0, excludeClaimed = false) {
32783
33344
  if (!depositAddress) {
32784
33345
  throw new ValidationError("Deposit address cannot be empty", {
32785
33346
  field: "depositAddress"
@@ -32793,7 +33354,8 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32793
33354
  address: depositAddress,
32794
33355
  network: NetworkToProto[this.config.getNetwork()],
32795
33356
  limit,
32796
- offset
33357
+ offset,
33358
+ excludeClaimed
32797
33359
  });
32798
33360
  return response.utxos.map((utxo) => ({
32799
33361
  txid: (0, import_utils24.bytesToHex)(utxo.txid),
@@ -34225,7 +34787,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34225
34787
  if (!feeEstimate) {
34226
34788
  throw new Error("Failed to get lightning send fee estimate");
34227
34789
  }
34228
- const satsFeeEstimate = (0, import_core12.mapCurrencyAmount)(feeEstimate.feeEstimate);
34790
+ const satsFeeEstimate = (0, import_core13.mapCurrencyAmount)(feeEstimate.feeEstimate);
34229
34791
  return Math.ceil(satsFeeEstimate.sats);
34230
34792
  }
34231
34793
  // ***** Cooperative Exit Flow *****
@@ -35135,7 +35697,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
35135
35697
  } catch (error) {
35136
35698
  if (error instanceof Error) {
35137
35699
  error.message += ` [traceId: ${traceId}]`;
35138
- } else if ((0, import_core12.isObject)(error)) {
35700
+ } else if ((0, import_core13.isObject)(error)) {
35139
35701
  error["traceId"] = traceId;
35140
35702
  }
35141
35703
  throw error;
@@ -35208,7 +35770,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
35208
35770
  var import_sdk_trace_web = require("@opentelemetry/sdk-trace-web");
35209
35771
  var import_instrumentation = require("@opentelemetry/instrumentation");
35210
35772
  var import_instrumentation_fetch = require("@opentelemetry/instrumentation-fetch");
35211
- var import_core13 = require("@opentelemetry/core");
35773
+ var import_core14 = require("@opentelemetry/core");
35212
35774
  var import_api2 = require("@opentelemetry/api");
35213
35775
  var SparkWalletBrowser = class _SparkWalletBrowser extends SparkWallet {
35214
35776
  static async initialize({
@@ -35244,7 +35806,7 @@ function initializeTracerEnvBrowser({
35244
35806
  }) {
35245
35807
  const provider = new import_sdk_trace_web.WebTracerProvider({ spanProcessors });
35246
35808
  provider.register();
35247
- import_api2.propagation.setGlobalPropagator(new import_core13.W3CTraceContextPropagator());
35809
+ import_api2.propagation.setGlobalPropagator(new import_core14.W3CTraceContextPropagator());
35248
35810
  (0, import_instrumentation.registerInstrumentations)({
35249
35811
  instrumentations: [
35250
35812
  new import_instrumentation_fetch.FetchInstrumentation({
@@ -35278,6 +35840,7 @@ setCrypto(cryptoImpl2);
35278
35840
  INITIAL_SEQUENCE,
35279
35841
  InternalValidationError,
35280
35842
  KeyDerivationType,
35843
+ LOGGER_NAMES,
35281
35844
  LRC_WALLET_NETWORK,
35282
35845
  Network,
35283
35846
  NetworkError,
@@ -35285,6 +35848,7 @@ setCrypto(cryptoImpl2);
35285
35848
  NotImplementedError,
35286
35849
  RPCError,
35287
35850
  SparkSDKError,
35851
+ SparkSdkLogger,
35288
35852
  SparkWallet,
35289
35853
  TEST_UNILATERAL_DIRECT_SEQUENCE,
35290
35854
  TEST_UNILATERAL_SEQUENCE,