@buildonspark/spark-sdk 0.2.11 → 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 (94) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/bare/index.cjs +703 -206
  3. package/dist/bare/index.d.cts +47 -3
  4. package/dist/bare/index.d.ts +47 -3
  5. package/dist/bare/index.js +626 -133
  6. package/dist/{chunk-A5M55UR3.js → chunk-5VWGOHED.js} +499 -8
  7. package/dist/{chunk-3WBPICWC.js → chunk-NQMQVXR5.js} +1 -1
  8. package/dist/{chunk-QNYJGFPD.js → chunk-OEK3R57K.js} +149 -123
  9. package/dist/{chunk-76SYPHOC.js → chunk-TB7DG5CU.js} +2 -2
  10. package/dist/{chunk-6CMNEDBK.js → chunk-XXTWWW6L.js} +1 -1
  11. package/dist/{client-Dd3QnxQu.d.ts → client-D7KDa4Ih.d.ts} +1 -1
  12. package/dist/{client-B9CAWKWz.d.cts → client-DVuA5-7M.d.cts} +1 -1
  13. package/dist/debug.cjs +703 -206
  14. package/dist/debug.d.cts +4 -4
  15. package/dist/debug.d.ts +4 -4
  16. package/dist/debug.js +4 -4
  17. package/dist/graphql/objects/index.d.cts +3 -3
  18. package/dist/graphql/objects/index.d.ts +3 -3
  19. package/dist/index.cjs +725 -228
  20. package/dist/index.d.cts +6 -6
  21. package/dist/index.d.ts +6 -6
  22. package/dist/index.js +5 -5
  23. package/dist/index.node.cjs +725 -228
  24. package/dist/index.node.d.cts +6 -6
  25. package/dist/index.node.d.ts +6 -6
  26. package/dist/index.node.js +4 -4
  27. package/dist/{logging-Bt_WdZbu.d.ts → logging-ClNhGzus.d.ts} +3 -3
  28. package/dist/{logging-BOAzMqpM.d.cts → logging-D3kvES69.d.cts} +3 -3
  29. package/dist/native/index.cjs +724 -227
  30. package/dist/native/index.d.cts +47 -3
  31. package/dist/native/index.d.ts +47 -3
  32. package/dist/native/index.js +628 -135
  33. package/dist/proto/spark.cjs +499 -8
  34. package/dist/proto/spark.d.cts +1 -1
  35. package/dist/proto/spark.d.ts +1 -1
  36. package/dist/proto/spark.js +17 -1
  37. package/dist/proto/spark_token.d.cts +1 -1
  38. package/dist/proto/spark_token.d.ts +1 -1
  39. package/dist/proto/spark_token.js +2 -2
  40. package/dist/{spark-CtGJPkx4.d.cts → spark-C7OG9mGJ.d.cts} +79 -2
  41. package/dist/{spark-CtGJPkx4.d.ts → spark-C7OG9mGJ.d.ts} +79 -2
  42. package/dist/{spark-wallet-yc2KhsVY.d.cts → spark-wallet-Dg5IRQe2.d.cts} +3 -5
  43. package/dist/{spark-wallet-Cp3yv6cK.d.ts → spark-wallet-DiHSU-pz.d.ts} +3 -5
  44. package/dist/{spark-wallet.node-D4IovOHu.d.ts → spark-wallet.node-BZrxwomN.d.ts} +1 -1
  45. package/dist/{spark-wallet.node-D0Qw5Wb4.d.cts → spark-wallet.node-DSWb18zh.d.cts} +1 -1
  46. package/dist/tests/test-utils.cjs +573 -66
  47. package/dist/tests/test-utils.d.cts +4 -4
  48. package/dist/tests/test-utils.d.ts +4 -4
  49. package/dist/tests/test-utils.js +5 -5
  50. package/dist/{token-transactions-CwhlOgIP.d.cts → token-transactions-B-WqFYpW.d.cts} +2 -2
  51. package/dist/{token-transactions-0nmR9mQO.d.ts → token-transactions-DovxHIxV.d.ts} +2 -2
  52. package/dist/types/index.cjs +492 -9
  53. package/dist/types/index.d.cts +2 -2
  54. package/dist/types/index.d.ts +2 -2
  55. package/dist/types/index.js +2 -2
  56. package/package.json +1 -1
  57. package/src/proto/common.ts +1 -1
  58. package/src/proto/google/protobuf/descriptor.ts +4 -10
  59. package/src/proto/google/protobuf/duration.ts +1 -1
  60. package/src/proto/google/protobuf/empty.ts +1 -1
  61. package/src/proto/google/protobuf/timestamp.ts +1 -1
  62. package/src/proto/mock.ts +1 -1
  63. package/src/proto/spark.ts +593 -3
  64. package/src/proto/spark_authn.ts +1 -1
  65. package/src/proto/spark_token.ts +1 -1
  66. package/src/proto/validate/validate.ts +27 -79
  67. package/src/services/deposit.ts +55 -3
  68. package/src/services/lightning.ts +2 -2
  69. package/src/services/signing.ts +1 -1
  70. package/src/services/token-transactions.ts +2 -5
  71. package/src/services/transfer.ts +2 -2
  72. package/src/signer/signer.ts +2 -2
  73. package/src/spark-wallet/spark-wallet.ts +25 -33
  74. package/src/tests/address.test.ts +10 -10
  75. package/src/tests/bitcoin.test.ts +2 -2
  76. package/src/tests/integration/coop-exit.test.ts +1 -1
  77. package/src/tests/integration/lightning.test.ts +1 -1
  78. package/src/tests/integration/ssp/static_deposit.test.ts +122 -1
  79. package/src/tests/integration/swap.test.ts +1 -1
  80. package/src/tests/integration/transfer.test.ts +1 -5
  81. package/src/tests/integration/wallet.test.ts +7 -7
  82. package/src/tests/integration/watchtower.test.ts +1 -1
  83. package/src/tests/token-hashing.test.ts +3 -6
  84. package/src/tests/token-outputs.test.ts +3 -3
  85. package/src/tests/utils/test-faucet.ts +2 -2
  86. package/src/types/sdk-types.ts +1 -1
  87. package/src/utils/adaptor-signature.ts +1 -1
  88. package/src/utils/address.ts +1 -1
  89. package/src/utils/bitcoin.ts +1 -5
  90. package/src/utils/keys.ts +1 -1
  91. package/src/utils/secret-sharing.ts +1 -1
  92. package/src/utils/token-transactions.ts +1 -2
  93. package/src/utils/transfer_package.ts +1 -1
  94. package/src/utils/unilateral-exit.ts +1 -1
@@ -1112,7 +1112,7 @@ function signFrost({
1112
1112
  adaptorPubKey
1113
1113
  }) {
1114
1114
  SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("signFrost", {
1115
- message: (0, import_utils13.bytesToHex)(message),
1115
+ message: (0, import_utils12.bytesToHex)(message),
1116
1116
  keyPackage,
1117
1117
  nonce,
1118
1118
  selfCommitment,
@@ -1139,15 +1139,15 @@ function aggregateFrost({
1139
1139
  adaptorPubKey
1140
1140
  }) {
1141
1141
  SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("aggregateFrost", {
1142
- message: (0, import_utils13.bytesToHex)(message),
1142
+ message: (0, import_utils12.bytesToHex)(message),
1143
1143
  statechainCommitments,
1144
1144
  selfCommitment,
1145
1145
  statechainSignatures,
1146
- selfSignature: (0, import_utils13.bytesToHex)(selfSignature),
1146
+ selfSignature: (0, import_utils12.bytesToHex)(selfSignature),
1147
1147
  statechainPublicKeys,
1148
- selfPublicKey: (0, import_utils13.bytesToHex)(selfPublicKey),
1149
- verifyingKey: (0, import_utils13.bytesToHex)(verifyingKey),
1150
- adaptorPubKey: adaptorPubKey ? (0, import_utils13.bytesToHex)(adaptorPubKey) : void 0
1148
+ selfPublicKey: (0, import_utils12.bytesToHex)(selfPublicKey),
1149
+ verifyingKey: (0, import_utils12.bytesToHex)(verifyingKey),
1150
+ adaptorPubKey: adaptorPubKey ? (0, import_utils12.bytesToHex)(adaptorPubKey) : void 0
1151
1151
  });
1152
1152
  return wasm_aggregate_frost(
1153
1153
  message,
@@ -1179,12 +1179,12 @@ function decryptEcies({
1179
1179
  }) {
1180
1180
  return decrypt_ecies(encryptedMsg, privateKey);
1181
1181
  }
1182
- var import_utils13;
1182
+ var import_utils12;
1183
1183
  var init_wasm = __esm({
1184
1184
  "src/spark_bindings/wasm/index.ts"() {
1185
1185
  "use strict";
1186
1186
  init_buffer();
1187
- import_utils13 = require("@noble/curves/utils");
1187
+ import_utils12 = require("@noble/curves/utils");
1188
1188
  init_spark_bindings();
1189
1189
  init_logging();
1190
1190
  }
@@ -1614,8 +1614,8 @@ init_buffer();
1614
1614
  // src/utils/address.ts
1615
1615
  init_buffer();
1616
1616
  var import_wire5 = require("@bufbuild/protobuf/wire");
1617
- var import_utils2 = require("@noble/curves/abstract/utils");
1618
1617
  var import_secp256k1 = require("@noble/curves/secp256k1");
1618
+ var import_utils2 = require("@noble/curves/utils");
1619
1619
  var import_utils3 = require("@noble/hashes/utils");
1620
1620
  var import_base2 = require("@scure/base");
1621
1621
  var import_uuidv7 = require("uuidv7");
@@ -2183,6 +2183,41 @@ function utxoSwapRequestTypeToJSON(object) {
2183
2183
  return "UNRECOGNIZED";
2184
2184
  }
2185
2185
  }
2186
+ function invoiceStatusFromJSON(object) {
2187
+ switch (object) {
2188
+ case 0:
2189
+ case "NOT_FOUND":
2190
+ return 0 /* NOT_FOUND */;
2191
+ case 1:
2192
+ case "PENDING":
2193
+ return 1 /* PENDING */;
2194
+ case 2:
2195
+ case "FINALIZED":
2196
+ return 2 /* FINALIZED */;
2197
+ case 3:
2198
+ case "EXPIRED":
2199
+ return 3 /* EXPIRED */;
2200
+ case -1:
2201
+ case "UNRECOGNIZED":
2202
+ default:
2203
+ return -1 /* UNRECOGNIZED */;
2204
+ }
2205
+ }
2206
+ function invoiceStatusToJSON(object) {
2207
+ switch (object) {
2208
+ case 0 /* NOT_FOUND */:
2209
+ return "NOT_FOUND";
2210
+ case 1 /* PENDING */:
2211
+ return "PENDING";
2212
+ case 2 /* FINALIZED */:
2213
+ return "FINALIZED";
2214
+ case 3 /* EXPIRED */:
2215
+ return "EXPIRED";
2216
+ case -1 /* UNRECOGNIZED */:
2217
+ default:
2218
+ return "UNRECOGNIZED";
2219
+ }
2220
+ }
2186
2221
  function initiatePreimageSwapRequest_ReasonFromJSON(object) {
2187
2222
  switch (object) {
2188
2223
  case 0:
@@ -2922,6 +2957,140 @@ var GenerateDepositAddressResponse = {
2922
2957
  return message;
2923
2958
  }
2924
2959
  };
2960
+ function createBaseGenerateStaticDepositAddressRequest() {
2961
+ return { signingPublicKey: new Uint8Array(0), identityPublicKey: new Uint8Array(0), network: 0 };
2962
+ }
2963
+ var GenerateStaticDepositAddressRequest = {
2964
+ encode(message, writer = new import_wire4.BinaryWriter()) {
2965
+ if (message.signingPublicKey.length !== 0) {
2966
+ writer.uint32(10).bytes(message.signingPublicKey);
2967
+ }
2968
+ if (message.identityPublicKey.length !== 0) {
2969
+ writer.uint32(18).bytes(message.identityPublicKey);
2970
+ }
2971
+ if (message.network !== 0) {
2972
+ writer.uint32(24).int32(message.network);
2973
+ }
2974
+ return writer;
2975
+ },
2976
+ decode(input, length) {
2977
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
2978
+ const end = length === void 0 ? reader.len : reader.pos + length;
2979
+ const message = createBaseGenerateStaticDepositAddressRequest();
2980
+ while (reader.pos < end) {
2981
+ const tag = reader.uint32();
2982
+ switch (tag >>> 3) {
2983
+ case 1: {
2984
+ if (tag !== 10) {
2985
+ break;
2986
+ }
2987
+ message.signingPublicKey = reader.bytes();
2988
+ continue;
2989
+ }
2990
+ case 2: {
2991
+ if (tag !== 18) {
2992
+ break;
2993
+ }
2994
+ message.identityPublicKey = reader.bytes();
2995
+ continue;
2996
+ }
2997
+ case 3: {
2998
+ if (tag !== 24) {
2999
+ break;
3000
+ }
3001
+ message.network = reader.int32();
3002
+ continue;
3003
+ }
3004
+ }
3005
+ if ((tag & 7) === 4 || tag === 0) {
3006
+ break;
3007
+ }
3008
+ reader.skip(tag & 7);
3009
+ }
3010
+ return message;
3011
+ },
3012
+ fromJSON(object) {
3013
+ return {
3014
+ signingPublicKey: isSet3(object.signingPublicKey) ? bytesFromBase642(object.signingPublicKey) : new Uint8Array(0),
3015
+ identityPublicKey: isSet3(object.identityPublicKey) ? bytesFromBase642(object.identityPublicKey) : new Uint8Array(0),
3016
+ network: isSet3(object.network) ? networkFromJSON(object.network) : 0
3017
+ };
3018
+ },
3019
+ toJSON(message) {
3020
+ const obj = {};
3021
+ if (message.signingPublicKey.length !== 0) {
3022
+ obj.signingPublicKey = base64FromBytes2(message.signingPublicKey);
3023
+ }
3024
+ if (message.identityPublicKey.length !== 0) {
3025
+ obj.identityPublicKey = base64FromBytes2(message.identityPublicKey);
3026
+ }
3027
+ if (message.network !== 0) {
3028
+ obj.network = networkToJSON(message.network);
3029
+ }
3030
+ return obj;
3031
+ },
3032
+ create(base) {
3033
+ return GenerateStaticDepositAddressRequest.fromPartial(base ?? {});
3034
+ },
3035
+ fromPartial(object) {
3036
+ const message = createBaseGenerateStaticDepositAddressRequest();
3037
+ message.signingPublicKey = object.signingPublicKey ?? new Uint8Array(0);
3038
+ message.identityPublicKey = object.identityPublicKey ?? new Uint8Array(0);
3039
+ message.network = object.network ?? 0;
3040
+ return message;
3041
+ }
3042
+ };
3043
+ function createBaseGenerateStaticDepositAddressResponse() {
3044
+ return { depositAddress: void 0 };
3045
+ }
3046
+ var GenerateStaticDepositAddressResponse = {
3047
+ encode(message, writer = new import_wire4.BinaryWriter()) {
3048
+ if (message.depositAddress !== void 0) {
3049
+ Address.encode(message.depositAddress, writer.uint32(10).fork()).join();
3050
+ }
3051
+ return writer;
3052
+ },
3053
+ decode(input, length) {
3054
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
3055
+ const end = length === void 0 ? reader.len : reader.pos + length;
3056
+ const message = createBaseGenerateStaticDepositAddressResponse();
3057
+ while (reader.pos < end) {
3058
+ const tag = reader.uint32();
3059
+ switch (tag >>> 3) {
3060
+ case 1: {
3061
+ if (tag !== 10) {
3062
+ break;
3063
+ }
3064
+ message.depositAddress = Address.decode(reader, reader.uint32());
3065
+ continue;
3066
+ }
3067
+ }
3068
+ if ((tag & 7) === 4 || tag === 0) {
3069
+ break;
3070
+ }
3071
+ reader.skip(tag & 7);
3072
+ }
3073
+ return message;
3074
+ },
3075
+ fromJSON(object) {
3076
+ return { depositAddress: isSet3(object.depositAddress) ? Address.fromJSON(object.depositAddress) : void 0 };
3077
+ },
3078
+ toJSON(message) {
3079
+ const obj = {};
3080
+ if (message.depositAddress !== void 0) {
3081
+ obj.depositAddress = Address.toJSON(message.depositAddress);
3082
+ }
3083
+ return obj;
3084
+ },
3085
+ create(base) {
3086
+ return GenerateStaticDepositAddressResponse.fromPartial(base ?? {});
3087
+ },
3088
+ fromPartial(object) {
3089
+ const message = createBaseGenerateStaticDepositAddressResponse();
3090
+ message.depositAddress = object.depositAddress !== void 0 && object.depositAddress !== null ? Address.fromPartial(object.depositAddress) : void 0;
3091
+ return message;
3092
+ }
3093
+ };
2925
3094
  function createBaseUTXO() {
2926
3095
  return { rawTx: new Uint8Array(0), vout: 0, network: 0, txid: new Uint8Array(0) };
2927
3096
  }
@@ -9035,7 +9204,8 @@ function createBaseTransferLeaf() {
9035
9204
  signature: new Uint8Array(0),
9036
9205
  intermediateRefundTx: new Uint8Array(0),
9037
9206
  intermediateDirectRefundTx: new Uint8Array(0),
9038
- intermediateDirectFromCpfpRefundTx: new Uint8Array(0)
9207
+ intermediateDirectFromCpfpRefundTx: new Uint8Array(0),
9208
+ pendingKeyTweakPublicKey: new Uint8Array(0)
9039
9209
  };
9040
9210
  }
9041
9211
  var TransferLeaf = {
@@ -9058,6 +9228,9 @@ var TransferLeaf = {
9058
9228
  if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
9059
9229
  writer.uint32(50).bytes(message.intermediateDirectFromCpfpRefundTx);
9060
9230
  }
9231
+ if (message.pendingKeyTweakPublicKey.length !== 0) {
9232
+ writer.uint32(58).bytes(message.pendingKeyTweakPublicKey);
9233
+ }
9061
9234
  return writer;
9062
9235
  },
9063
9236
  decode(input, length) {
@@ -9109,6 +9282,13 @@ var TransferLeaf = {
9109
9282
  message.intermediateDirectFromCpfpRefundTx = reader.bytes();
9110
9283
  continue;
9111
9284
  }
9285
+ case 7: {
9286
+ if (tag !== 58) {
9287
+ break;
9288
+ }
9289
+ message.pendingKeyTweakPublicKey = reader.bytes();
9290
+ continue;
9291
+ }
9112
9292
  }
9113
9293
  if ((tag & 7) === 4 || tag === 0) {
9114
9294
  break;
@@ -9124,7 +9304,8 @@ var TransferLeaf = {
9124
9304
  signature: isSet3(object.signature) ? bytesFromBase642(object.signature) : new Uint8Array(0),
9125
9305
  intermediateRefundTx: isSet3(object.intermediateRefundTx) ? bytesFromBase642(object.intermediateRefundTx) : new Uint8Array(0),
9126
9306
  intermediateDirectRefundTx: isSet3(object.intermediateDirectRefundTx) ? bytesFromBase642(object.intermediateDirectRefundTx) : new Uint8Array(0),
9127
- intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0)
9307
+ intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0),
9308
+ pendingKeyTweakPublicKey: isSet3(object.pendingKeyTweakPublicKey) ? bytesFromBase642(object.pendingKeyTweakPublicKey) : new Uint8Array(0)
9128
9309
  };
9129
9310
  },
9130
9311
  toJSON(message) {
@@ -9147,6 +9328,9 @@ var TransferLeaf = {
9147
9328
  if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
9148
9329
  obj.intermediateDirectFromCpfpRefundTx = base64FromBytes2(message.intermediateDirectFromCpfpRefundTx);
9149
9330
  }
9331
+ if (message.pendingKeyTweakPublicKey.length !== 0) {
9332
+ obj.pendingKeyTweakPublicKey = base64FromBytes2(message.pendingKeyTweakPublicKey);
9333
+ }
9150
9334
  return obj;
9151
9335
  },
9152
9336
  create(base) {
@@ -9160,6 +9344,7 @@ var TransferLeaf = {
9160
9344
  message.intermediateRefundTx = object.intermediateRefundTx ?? new Uint8Array(0);
9161
9345
  message.intermediateDirectRefundTx = object.intermediateDirectRefundTx ?? new Uint8Array(0);
9162
9346
  message.intermediateDirectFromCpfpRefundTx = object.intermediateDirectFromCpfpRefundTx ?? new Uint8Array(0);
9347
+ message.pendingKeyTweakPublicKey = object.pendingKeyTweakPublicKey ?? new Uint8Array(0);
9163
9348
  return message;
9164
9349
  }
9165
9350
  };
@@ -12057,13 +12242,16 @@ var QueryUserSignedRefundsRequest = {
12057
12242
  }
12058
12243
  };
12059
12244
  function createBaseQueryUserSignedRefundsResponse() {
12060
- return { userSignedRefunds: [] };
12245
+ return { userSignedRefunds: [], transfer: void 0 };
12061
12246
  }
12062
12247
  var QueryUserSignedRefundsResponse = {
12063
12248
  encode(message, writer = new import_wire4.BinaryWriter()) {
12064
12249
  for (const v of message.userSignedRefunds) {
12065
12250
  UserSignedRefund.encode(v, writer.uint32(10).fork()).join();
12066
12251
  }
12252
+ if (message.transfer !== void 0) {
12253
+ Transfer.encode(message.transfer, writer.uint32(26).fork()).join();
12254
+ }
12067
12255
  return writer;
12068
12256
  },
12069
12257
  decode(input, length) {
@@ -12080,6 +12268,13 @@ var QueryUserSignedRefundsResponse = {
12080
12268
  message.userSignedRefunds.push(UserSignedRefund.decode(reader, reader.uint32()));
12081
12269
  continue;
12082
12270
  }
12271
+ case 3: {
12272
+ if (tag !== 26) {
12273
+ break;
12274
+ }
12275
+ message.transfer = Transfer.decode(reader, reader.uint32());
12276
+ continue;
12277
+ }
12083
12278
  }
12084
12279
  if ((tag & 7) === 4 || tag === 0) {
12085
12280
  break;
@@ -12090,7 +12285,8 @@ var QueryUserSignedRefundsResponse = {
12090
12285
  },
12091
12286
  fromJSON(object) {
12092
12287
  return {
12093
- userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : []
12288
+ userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : [],
12289
+ transfer: isSet3(object.transfer) ? Transfer.fromJSON(object.transfer) : void 0
12094
12290
  };
12095
12291
  },
12096
12292
  toJSON(message) {
@@ -12098,6 +12294,9 @@ var QueryUserSignedRefundsResponse = {
12098
12294
  if (message.userSignedRefunds?.length) {
12099
12295
  obj.userSignedRefunds = message.userSignedRefunds.map((e) => UserSignedRefund.toJSON(e));
12100
12296
  }
12297
+ if (message.transfer !== void 0) {
12298
+ obj.transfer = Transfer.toJSON(message.transfer);
12299
+ }
12101
12300
  return obj;
12102
12301
  },
12103
12302
  create(base) {
@@ -12106,6 +12305,7 @@ var QueryUserSignedRefundsResponse = {
12106
12305
  fromPartial(object) {
12107
12306
  const message = createBaseQueryUserSignedRefundsResponse();
12108
12307
  message.userSignedRefunds = object.userSignedRefunds?.map((e) => UserSignedRefund.fromPartial(e)) || [];
12308
+ message.transfer = object.transfer !== void 0 && object.transfer !== null ? Transfer.fromPartial(object.transfer) : void 0;
12109
12309
  return message;
12110
12310
  }
12111
12311
  };
@@ -12992,7 +13192,8 @@ function createBaseDepositAddressQueryResult() {
12992
13192
  depositAddress: "",
12993
13193
  userSigningPublicKey: new Uint8Array(0),
12994
13194
  verifyingPublicKey: new Uint8Array(0),
12995
- leafId: void 0
13195
+ leafId: void 0,
13196
+ proofOfPossession: void 0
12996
13197
  };
12997
13198
  }
12998
13199
  var DepositAddressQueryResult = {
@@ -13009,6 +13210,9 @@ var DepositAddressQueryResult = {
13009
13210
  if (message.leafId !== void 0) {
13010
13211
  writer.uint32(34).string(message.leafId);
13011
13212
  }
13213
+ if (message.proofOfPossession !== void 0) {
13214
+ DepositAddressProof.encode(message.proofOfPossession, writer.uint32(42).fork()).join();
13215
+ }
13012
13216
  return writer;
13013
13217
  },
13014
13218
  decode(input, length) {
@@ -13046,6 +13250,13 @@ var DepositAddressQueryResult = {
13046
13250
  message.leafId = reader.string();
13047
13251
  continue;
13048
13252
  }
13253
+ case 5: {
13254
+ if (tag !== 42) {
13255
+ break;
13256
+ }
13257
+ message.proofOfPossession = DepositAddressProof.decode(reader, reader.uint32());
13258
+ continue;
13259
+ }
13049
13260
  }
13050
13261
  if ((tag & 7) === 4 || tag === 0) {
13051
13262
  break;
@@ -13059,7 +13270,8 @@ var DepositAddressQueryResult = {
13059
13270
  depositAddress: isSet3(object.depositAddress) ? globalThis.String(object.depositAddress) : "",
13060
13271
  userSigningPublicKey: isSet3(object.userSigningPublicKey) ? bytesFromBase642(object.userSigningPublicKey) : new Uint8Array(0),
13061
13272
  verifyingPublicKey: isSet3(object.verifyingPublicKey) ? bytesFromBase642(object.verifyingPublicKey) : new Uint8Array(0),
13062
- leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0
13273
+ leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0,
13274
+ proofOfPossession: isSet3(object.proofOfPossession) ? DepositAddressProof.fromJSON(object.proofOfPossession) : void 0
13063
13275
  };
13064
13276
  },
13065
13277
  toJSON(message) {
@@ -13076,6 +13288,9 @@ var DepositAddressQueryResult = {
13076
13288
  if (message.leafId !== void 0) {
13077
13289
  obj.leafId = message.leafId;
13078
13290
  }
13291
+ if (message.proofOfPossession !== void 0) {
13292
+ obj.proofOfPossession = DepositAddressProof.toJSON(message.proofOfPossession);
13293
+ }
13079
13294
  return obj;
13080
13295
  },
13081
13296
  create(base) {
@@ -13087,6 +13302,7 @@ var DepositAddressQueryResult = {
13087
13302
  message.userSigningPublicKey = object.userSigningPublicKey ?? new Uint8Array(0);
13088
13303
  message.verifyingPublicKey = object.verifyingPublicKey ?? new Uint8Array(0);
13089
13304
  message.leafId = object.leafId ?? void 0;
13305
+ message.proofOfPossession = object.proofOfPossession !== void 0 && object.proofOfPossession !== null ? DepositAddressProof.fromPartial(object.proofOfPossession) : void 0;
13090
13306
  return message;
13091
13307
  }
13092
13308
  };
@@ -15051,7 +15267,7 @@ var QueryNodesByValueResponse_NodesEntry = {
15051
15267
  }
15052
15268
  };
15053
15269
  function createBaseGetUtxosForAddressRequest() {
15054
- return { address: "", offset: 0, limit: 0, network: 0 };
15270
+ return { address: "", offset: 0, limit: 0, network: 0, excludeClaimed: false };
15055
15271
  }
15056
15272
  var GetUtxosForAddressRequest = {
15057
15273
  encode(message, writer = new import_wire4.BinaryWriter()) {
@@ -15067,6 +15283,9 @@ var GetUtxosForAddressRequest = {
15067
15283
  if (message.network !== 0) {
15068
15284
  writer.uint32(32).int32(message.network);
15069
15285
  }
15286
+ if (message.excludeClaimed !== false) {
15287
+ writer.uint32(40).bool(message.excludeClaimed);
15288
+ }
15070
15289
  return writer;
15071
15290
  },
15072
15291
  decode(input, length) {
@@ -15104,6 +15323,13 @@ var GetUtxosForAddressRequest = {
15104
15323
  message.network = reader.int32();
15105
15324
  continue;
15106
15325
  }
15326
+ case 5: {
15327
+ if (tag !== 40) {
15328
+ break;
15329
+ }
15330
+ message.excludeClaimed = reader.bool();
15331
+ continue;
15332
+ }
15107
15333
  }
15108
15334
  if ((tag & 7) === 4 || tag === 0) {
15109
15335
  break;
@@ -15117,7 +15343,8 @@ var GetUtxosForAddressRequest = {
15117
15343
  address: isSet3(object.address) ? globalThis.String(object.address) : "",
15118
15344
  offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
15119
15345
  limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
15120
- network: isSet3(object.network) ? networkFromJSON(object.network) : 0
15346
+ network: isSet3(object.network) ? networkFromJSON(object.network) : 0,
15347
+ excludeClaimed: isSet3(object.excludeClaimed) ? globalThis.Boolean(object.excludeClaimed) : false
15121
15348
  };
15122
15349
  },
15123
15350
  toJSON(message) {
@@ -15134,6 +15361,9 @@ var GetUtxosForAddressRequest = {
15134
15361
  if (message.network !== 0) {
15135
15362
  obj.network = networkToJSON(message.network);
15136
15363
  }
15364
+ if (message.excludeClaimed !== false) {
15365
+ obj.excludeClaimed = message.excludeClaimed;
15366
+ }
15137
15367
  return obj;
15138
15368
  },
15139
15369
  create(base) {
@@ -15145,6 +15375,7 @@ var GetUtxosForAddressRequest = {
15145
15375
  message.offset = object.offset ?? 0;
15146
15376
  message.limit = object.limit ?? 0;
15147
15377
  message.network = object.network ?? 0;
15378
+ message.excludeClaimed = object.excludeClaimed ?? false;
15148
15379
  return message;
15149
15380
  }
15150
15381
  };
@@ -15216,6 +15447,225 @@ var GetUtxosForAddressResponse = {
15216
15447
  return message;
15217
15448
  }
15218
15449
  };
15450
+ function createBaseQuerySparkInvoicesRequest() {
15451
+ return { limit: 0, offset: 0, invoice: [] };
15452
+ }
15453
+ var QuerySparkInvoicesRequest = {
15454
+ encode(message, writer = new import_wire4.BinaryWriter()) {
15455
+ if (message.limit !== 0) {
15456
+ writer.uint32(8).int64(message.limit);
15457
+ }
15458
+ if (message.offset !== 0) {
15459
+ writer.uint32(16).int64(message.offset);
15460
+ }
15461
+ for (const v of message.invoice) {
15462
+ writer.uint32(26).string(v);
15463
+ }
15464
+ return writer;
15465
+ },
15466
+ decode(input, length) {
15467
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
15468
+ const end = length === void 0 ? reader.len : reader.pos + length;
15469
+ const message = createBaseQuerySparkInvoicesRequest();
15470
+ while (reader.pos < end) {
15471
+ const tag = reader.uint32();
15472
+ switch (tag >>> 3) {
15473
+ case 1: {
15474
+ if (tag !== 8) {
15475
+ break;
15476
+ }
15477
+ message.limit = longToNumber2(reader.int64());
15478
+ continue;
15479
+ }
15480
+ case 2: {
15481
+ if (tag !== 16) {
15482
+ break;
15483
+ }
15484
+ message.offset = longToNumber2(reader.int64());
15485
+ continue;
15486
+ }
15487
+ case 3: {
15488
+ if (tag !== 26) {
15489
+ break;
15490
+ }
15491
+ message.invoice.push(reader.string());
15492
+ continue;
15493
+ }
15494
+ }
15495
+ if ((tag & 7) === 4 || tag === 0) {
15496
+ break;
15497
+ }
15498
+ reader.skip(tag & 7);
15499
+ }
15500
+ return message;
15501
+ },
15502
+ fromJSON(object) {
15503
+ return {
15504
+ limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
15505
+ offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
15506
+ invoice: globalThis.Array.isArray(object?.invoice) ? object.invoice.map((e) => globalThis.String(e)) : []
15507
+ };
15508
+ },
15509
+ toJSON(message) {
15510
+ const obj = {};
15511
+ if (message.limit !== 0) {
15512
+ obj.limit = Math.round(message.limit);
15513
+ }
15514
+ if (message.offset !== 0) {
15515
+ obj.offset = Math.round(message.offset);
15516
+ }
15517
+ if (message.invoice?.length) {
15518
+ obj.invoice = message.invoice;
15519
+ }
15520
+ return obj;
15521
+ },
15522
+ create(base) {
15523
+ return QuerySparkInvoicesRequest.fromPartial(base ?? {});
15524
+ },
15525
+ fromPartial(object) {
15526
+ const message = createBaseQuerySparkInvoicesRequest();
15527
+ message.limit = object.limit ?? 0;
15528
+ message.offset = object.offset ?? 0;
15529
+ message.invoice = object.invoice?.map((e) => e) || [];
15530
+ return message;
15531
+ }
15532
+ };
15533
+ function createBaseQuerySparkInvoicesResponse() {
15534
+ return { offset: 0, invoiceStatuses: [] };
15535
+ }
15536
+ var QuerySparkInvoicesResponse = {
15537
+ encode(message, writer = new import_wire4.BinaryWriter()) {
15538
+ if (message.offset !== 0) {
15539
+ writer.uint32(8).int64(message.offset);
15540
+ }
15541
+ for (const v of message.invoiceStatuses) {
15542
+ InvoiceResponse.encode(v, writer.uint32(18).fork()).join();
15543
+ }
15544
+ return writer;
15545
+ },
15546
+ decode(input, length) {
15547
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
15548
+ const end = length === void 0 ? reader.len : reader.pos + length;
15549
+ const message = createBaseQuerySparkInvoicesResponse();
15550
+ while (reader.pos < end) {
15551
+ const tag = reader.uint32();
15552
+ switch (tag >>> 3) {
15553
+ case 1: {
15554
+ if (tag !== 8) {
15555
+ break;
15556
+ }
15557
+ message.offset = longToNumber2(reader.int64());
15558
+ continue;
15559
+ }
15560
+ case 2: {
15561
+ if (tag !== 18) {
15562
+ break;
15563
+ }
15564
+ message.invoiceStatuses.push(InvoiceResponse.decode(reader, reader.uint32()));
15565
+ continue;
15566
+ }
15567
+ }
15568
+ if ((tag & 7) === 4 || tag === 0) {
15569
+ break;
15570
+ }
15571
+ reader.skip(tag & 7);
15572
+ }
15573
+ return message;
15574
+ },
15575
+ fromJSON(object) {
15576
+ return {
15577
+ offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
15578
+ invoiceStatuses: globalThis.Array.isArray(object?.invoiceStatuses) ? object.invoiceStatuses.map((e) => InvoiceResponse.fromJSON(e)) : []
15579
+ };
15580
+ },
15581
+ toJSON(message) {
15582
+ const obj = {};
15583
+ if (message.offset !== 0) {
15584
+ obj.offset = Math.round(message.offset);
15585
+ }
15586
+ if (message.invoiceStatuses?.length) {
15587
+ obj.invoiceStatuses = message.invoiceStatuses.map((e) => InvoiceResponse.toJSON(e));
15588
+ }
15589
+ return obj;
15590
+ },
15591
+ create(base) {
15592
+ return QuerySparkInvoicesResponse.fromPartial(base ?? {});
15593
+ },
15594
+ fromPartial(object) {
15595
+ const message = createBaseQuerySparkInvoicesResponse();
15596
+ message.offset = object.offset ?? 0;
15597
+ message.invoiceStatuses = object.invoiceStatuses?.map((e) => InvoiceResponse.fromPartial(e)) || [];
15598
+ return message;
15599
+ }
15600
+ };
15601
+ function createBaseInvoiceResponse() {
15602
+ return { invoice: "", status: 0 };
15603
+ }
15604
+ var InvoiceResponse = {
15605
+ encode(message, writer = new import_wire4.BinaryWriter()) {
15606
+ if (message.invoice !== "") {
15607
+ writer.uint32(10).string(message.invoice);
15608
+ }
15609
+ if (message.status !== 0) {
15610
+ writer.uint32(16).int32(message.status);
15611
+ }
15612
+ return writer;
15613
+ },
15614
+ decode(input, length) {
15615
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
15616
+ const end = length === void 0 ? reader.len : reader.pos + length;
15617
+ const message = createBaseInvoiceResponse();
15618
+ while (reader.pos < end) {
15619
+ const tag = reader.uint32();
15620
+ switch (tag >>> 3) {
15621
+ case 1: {
15622
+ if (tag !== 10) {
15623
+ break;
15624
+ }
15625
+ message.invoice = reader.string();
15626
+ continue;
15627
+ }
15628
+ case 2: {
15629
+ if (tag !== 16) {
15630
+ break;
15631
+ }
15632
+ message.status = reader.int32();
15633
+ continue;
15634
+ }
15635
+ }
15636
+ if ((tag & 7) === 4 || tag === 0) {
15637
+ break;
15638
+ }
15639
+ reader.skip(tag & 7);
15640
+ }
15641
+ return message;
15642
+ },
15643
+ fromJSON(object) {
15644
+ return {
15645
+ invoice: isSet3(object.invoice) ? globalThis.String(object.invoice) : "",
15646
+ status: isSet3(object.status) ? invoiceStatusFromJSON(object.status) : 0
15647
+ };
15648
+ },
15649
+ toJSON(message) {
15650
+ const obj = {};
15651
+ if (message.invoice !== "") {
15652
+ obj.invoice = message.invoice;
15653
+ }
15654
+ if (message.status !== 0) {
15655
+ obj.status = invoiceStatusToJSON(message.status);
15656
+ }
15657
+ return obj;
15658
+ },
15659
+ create(base) {
15660
+ return InvoiceResponse.fromPartial(base ?? {});
15661
+ },
15662
+ fromPartial(object) {
15663
+ const message = createBaseInvoiceResponse();
15664
+ message.invoice = object.invoice ?? "";
15665
+ message.status = object.status ?? 0;
15666
+ return message;
15667
+ }
15668
+ };
15219
15669
  var SparkServiceDefinition = {
15220
15670
  name: "SparkService",
15221
15671
  fullName: "spark.SparkService",
@@ -15228,6 +15678,15 @@ var SparkServiceDefinition = {
15228
15678
  responseStream: false,
15229
15679
  options: {}
15230
15680
  },
15681
+ /** Generates a new static deposit address of the user or returns the existing one for the specified network. */
15682
+ generate_static_deposit_address: {
15683
+ name: "generate_static_deposit_address",
15684
+ requestType: GenerateStaticDepositAddressRequest,
15685
+ requestStream: false,
15686
+ responseType: GenerateStaticDepositAddressResponse,
15687
+ responseStream: false,
15688
+ options: {}
15689
+ },
15231
15690
  start_deposit_tree_creation: {
15232
15691
  name: "start_deposit_tree_creation",
15233
15692
  requestType: StartDepositTreeCreationRequest,
@@ -15669,6 +16128,14 @@ var SparkServiceDefinition = {
15669
16128
  responseType: GetUtxosForAddressResponse,
15670
16129
  responseStream: false,
15671
16130
  options: {}
16131
+ },
16132
+ query_spark_invoices: {
16133
+ name: "query_spark_invoices",
16134
+ requestType: QuerySparkInvoicesRequest,
16135
+ requestStream: false,
16136
+ responseType: QuerySparkInvoicesResponse,
16137
+ responseStream: false,
16138
+ options: {}
15672
16139
  }
15673
16140
  }
15674
16141
  };
@@ -16258,8 +16725,8 @@ function encodeSparkInvoiceFieldsV1Canonical(f) {
16258
16725
  // src/utils/adaptor-signature.ts
16259
16726
  init_buffer();
16260
16727
  var import_modular = require("@noble/curves/abstract/modular");
16261
- var import_utils4 = require("@noble/curves/abstract/utils");
16262
16728
  var import_secp256k12 = require("@noble/curves/secp256k1");
16729
+ var import_utils4 = require("@noble/curves/utils");
16263
16730
  function generateSignatureFromExistingAdaptor(signature, adaptorPrivateKeyBytes) {
16264
16731
  const { r, s } = parseSignature(signature);
16265
16732
  const sBigInt = (0, import_utils4.bytesToNumberBE)(s);
@@ -16388,8 +16855,8 @@ function parseSignature(signature) {
16388
16855
 
16389
16856
  // src/utils/bitcoin.ts
16390
16857
  init_buffer();
16391
- var import_utils5 = require("@noble/curves/abstract/utils");
16392
16858
  var import_secp256k13 = require("@noble/curves/secp256k1");
16859
+ var import_utils5 = require("@noble/curves/utils");
16393
16860
  var import_sha22 = require("@noble/hashes/sha2");
16394
16861
  var btc2 = __toESM(require("@scure/btc-signer"), 1);
16395
16862
 
@@ -16634,8 +17101,8 @@ function getTxEstimatedVbytesSizeByNumberOfInputsOutputs(numInputs, numOutputs)
16634
17101
 
16635
17102
  // src/utils/keys.ts
16636
17103
  init_buffer();
16637
- var import_utils6 = require("@noble/curves/abstract/utils");
16638
17104
  var import_secp256k14 = require("@noble/curves/secp256k1");
17105
+ var import_utils6 = require("@noble/curves/utils");
16639
17106
  function addPublicKeys(a, b) {
16640
17107
  if (a.length !== 33 || b.length !== 33) {
16641
17108
  throw new ValidationError("Public keys must be 33 bytes", {
@@ -17892,7 +18359,7 @@ fragment UserRequestFragment on UserRequest {
17892
18359
 
17893
18360
  // src/types/sdk-types.ts
17894
18361
  init_buffer();
17895
- var import_utils7 = require("@noble/curves/abstract/utils");
18362
+ var import_utils7 = require("@noble/curves/utils");
17896
18363
  function mapTreeNodeToWalletLeaf(proto) {
17897
18364
  return {
17898
18365
  id: proto.id,
@@ -18043,8 +18510,8 @@ function collectResponses(responses) {
18043
18510
 
18044
18511
  // src/utils/secret-sharing.ts
18045
18512
  init_buffer();
18046
- var import_utils8 = require("@noble/curves/abstract/utils");
18047
18513
  var import_secp256k15 = require("@noble/curves/secp256k1");
18514
+ var import_utils8 = require("@noble/curves/utils");
18048
18515
  function getRandomBigInt(max) {
18049
18516
  const byteLength = max.toString(2).length + 7 >> 3;
18050
18517
  const maxBigInt = max;
@@ -18429,8 +18896,7 @@ function getNetworkFromBech32mTokenIdentifier(bech32mTokenIdentifier) {
18429
18896
 
18430
18897
  // src/utils/token-transactions.ts
18431
18898
  init_buffer();
18432
- var import_utils9 = require("@noble/curves/abstract/utils");
18433
- var import_utils10 = require("@scure/btc-signer/utils");
18899
+ var import_utils9 = require("@noble/curves/utils");
18434
18900
  function sumAvailableTokens(outputs) {
18435
18901
  try {
18436
18902
  return outputs.reduce(
@@ -18465,7 +18931,7 @@ function filterTokenBalanceForTokenIdentifier(tokenBalances, tokenIdentifier) {
18465
18931
  }
18466
18932
  const tokenIdentifierBytes = decodeBech32mTokenIdentifier(tokenIdentifier).tokenIdentifier;
18467
18933
  const tokenBalance = [...tokenBalances.entries()].find(
18468
- ([, info]) => (0, import_utils10.equalBytes)(info.tokenMetadata.rawTokenIdentifier, tokenIdentifierBytes)
18934
+ ([, info]) => (0, import_utils9.equalBytes)(info.tokenMetadata.rawTokenIdentifier, tokenIdentifierBytes)
18469
18935
  );
18470
18936
  if (!tokenBalance) {
18471
18937
  return {
@@ -18479,7 +18945,7 @@ function filterTokenBalanceForTokenIdentifier(tokenBalances, tokenIdentifier) {
18479
18945
 
18480
18946
  // src/utils/transfer_package.ts
18481
18947
  init_buffer();
18482
- var import_utils11 = require("@noble/curves/abstract/utils");
18948
+ var import_utils10 = require("@noble/curves/utils");
18483
18949
  var import_sha24 = require("@noble/hashes/sha2");
18484
18950
  function getTransferPackageSigningPayload(transferID, transferPackage) {
18485
18951
  const encryptedPayload = transferPackage.keyTweakPackage;
@@ -18488,7 +18954,7 @@ function getTransferPackageSigningPayload(transferID, transferPackage) {
18488
18954
  ).map(([key, value]) => ({ key, value }));
18489
18955
  pairs.sort((a, b) => a.key.localeCompare(b.key));
18490
18956
  const encoder = new TextEncoder();
18491
- let message = (0, import_utils11.hexToBytes)(transferID.replaceAll("-", ""));
18957
+ let message = (0, import_utils10.hexToBytes)(transferID.replaceAll("-", ""));
18492
18958
  for (const pair of pairs) {
18493
18959
  const keyPart = encoder.encode(pair.key + ":");
18494
18960
  const separator = encoder.encode(";");
@@ -18841,7 +19307,7 @@ function getEphemeralAnchorOutput() {
18841
19307
 
18842
19308
  // src/utils/unilateral-exit.ts
18843
19309
  init_buffer();
18844
- var import_utils12 = require("@noble/curves/abstract/utils");
19310
+ var import_utils11 = require("@noble/curves/utils");
18845
19311
  var import_legacy = require("@noble/hashes/legacy");
18846
19312
  var import_sha25 = require("@noble/hashes/sha2");
18847
19313
  var btc3 = __toESM(require("@scure/btc-signer"), 1);
@@ -18856,7 +19322,7 @@ function isEphemeralAnchorOutput(script, amount) {
18856
19322
  }
18857
19323
  async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network) {
18858
19324
  const result = [];
18859
- const nodes = nodeHexStrings.map((hex) => TreeNode.decode((0, import_utils12.hexToBytes)(hex)));
19325
+ const nodes = nodeHexStrings.map((hex) => TreeNode.decode((0, import_utils11.hexToBytes)(hex)));
18860
19326
  const nodeMap = /* @__PURE__ */ new Map();
18861
19327
  for (const node of nodes) {
18862
19328
  nodeMap.set(node.id, node);
@@ -18912,10 +19378,10 @@ async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network)
18912
19378
  }
18913
19379
  }
18914
19380
  for (const chainNode of chain) {
18915
- const nodeTx = (0, import_utils12.bytesToHex)(chainNode.nodeTx);
19381
+ const nodeTx = (0, import_utils11.bytesToHex)(chainNode.nodeTx);
18916
19382
  transactions.push(nodeTx);
18917
19383
  if (chainNode.id === node.id) {
18918
- const refundTx = (0, import_utils12.bytesToHex)(chainNode.refundTx);
19384
+ const refundTx = (0, import_utils11.bytesToHex)(chainNode.refundTx);
18919
19385
  transactions.push(refundTx);
18920
19386
  }
18921
19387
  }
@@ -18945,7 +19411,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
18945
19411
  `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.`
18946
19412
  );
18947
19413
  }
18948
- const nodeBytes = (0, import_utils12.hexToBytes)(hex);
19414
+ const nodeBytes = (0, import_utils11.hexToBytes)(hex);
18949
19415
  const node = TreeNode.decode(nodeBytes);
18950
19416
  if (!node.id) {
18951
19417
  throw new Error(
@@ -19021,7 +19487,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
19021
19487
  }
19022
19488
  }
19023
19489
  for (const chainNode of chain) {
19024
- let nodeTxHex = (0, import_utils12.bytesToHex)(chainNode.nodeTx);
19490
+ let nodeTxHex = (0, import_utils11.bytesToHex)(chainNode.nodeTx);
19025
19491
  try {
19026
19492
  const txObj = getTxFromRawTxHex(nodeTxHex);
19027
19493
  const txid = getTxId(txObj);
@@ -19038,7 +19504,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
19038
19504
  for (let i = txObj.outputsLength - 1; i >= 0; i--) {
19039
19505
  const output = txObj.getOutput(i);
19040
19506
  if (output?.amount === 0n && output.script) {
19041
- anchorOutputScriptHex = (0, import_utils12.bytesToHex)(output.script);
19507
+ anchorOutputScriptHex = (0, import_utils11.bytesToHex)(output.script);
19042
19508
  break;
19043
19509
  }
19044
19510
  }
@@ -19059,11 +19525,11 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
19059
19525
  usedUtxos,
19060
19526
  correctedParentTx
19061
19527
  } = constructFeeBumpTx(nodeTxHex, availableUtxos, feeRate, void 0);
19062
- const feeBumpTx = btc3.Transaction.fromPSBT((0, import_utils12.hexToBytes)(nodeFeeBumpPsbt));
19528
+ const feeBumpTx = btc3.Transaction.fromPSBT((0, import_utils11.hexToBytes)(nodeFeeBumpPsbt));
19063
19529
  var feeBumpOut = feeBumpTx.outputsLength === 1 ? feeBumpTx.getOutput(0) : null;
19064
19530
  var feeBumpOutPubKey = null;
19065
19531
  for (const usedUtxo of usedUtxos) {
19066
- if (feeBumpOut && (0, import_utils12.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
19532
+ if (feeBumpOut && (0, import_utils11.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
19067
19533
  feeBumpOutPubKey = usedUtxo.publicKey;
19068
19534
  }
19069
19535
  const index = availableUtxos.findIndex(
@@ -19078,20 +19544,20 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
19078
19544
  txid: getTxId(feeBumpTx),
19079
19545
  vout: 0,
19080
19546
  value: feeBumpOut.amount,
19081
- script: (0, import_utils12.bytesToHex)(feeBumpOut.script),
19547
+ script: (0, import_utils11.bytesToHex)(feeBumpOut.script),
19082
19548
  publicKey: feeBumpOutPubKey
19083
19549
  });
19084
19550
  const finalNodeTx = correctedParentTx || nodeTxHex;
19085
19551
  txPackages.push({ tx: finalNodeTx, feeBumpPsbt: nodeFeeBumpPsbt });
19086
19552
  if (chainNode.id === node.id) {
19087
- let refundTxHex = (0, import_utils12.bytesToHex)(chainNode.refundTx);
19553
+ let refundTxHex = (0, import_utils11.bytesToHex)(chainNode.refundTx);
19088
19554
  try {
19089
19555
  const txObj = getTxFromRawTxHex(refundTxHex);
19090
19556
  let anchorOutputScriptHex;
19091
19557
  for (let i = txObj.outputsLength - 1; i >= 0; i--) {
19092
19558
  const output = txObj.getOutput(i);
19093
19559
  if (output?.amount === 0n && output.script) {
19094
- anchorOutputScriptHex = (0, import_utils12.bytesToHex)(output.script);
19560
+ anchorOutputScriptHex = (0, import_utils11.bytesToHex)(output.script);
19095
19561
  break;
19096
19562
  }
19097
19563
  }
@@ -19114,12 +19580,12 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
19114
19580
  void 0
19115
19581
  );
19116
19582
  const feeBumpTx2 = btc3.Transaction.fromPSBT(
19117
- (0, import_utils12.hexToBytes)(refundFeeBump.feeBumpPsbt)
19583
+ (0, import_utils11.hexToBytes)(refundFeeBump.feeBumpPsbt)
19118
19584
  );
19119
19585
  var feeBumpOut = feeBumpTx2.outputsLength === 1 ? feeBumpTx2.getOutput(0) : null;
19120
19586
  var feeBumpOutPubKey = null;
19121
19587
  for (const usedUtxo of usedUtxos) {
19122
- if (feeBumpOut && (0, import_utils12.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
19588
+ if (feeBumpOut && (0, import_utils11.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
19123
19589
  feeBumpOutPubKey = usedUtxo.publicKey;
19124
19590
  }
19125
19591
  const index = availableUtxos.findIndex(
@@ -19134,7 +19600,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
19134
19600
  txid: getTxId(feeBumpTx2),
19135
19601
  vout: 0,
19136
19602
  value: feeBumpOut.amount,
19137
- script: (0, import_utils12.bytesToHex)(feeBumpOut.script),
19603
+ script: (0, import_utils11.bytesToHex)(feeBumpOut.script),
19138
19604
  publicKey: feeBumpOutPubKey
19139
19605
  });
19140
19606
  txPackages.push({
@@ -19229,10 +19695,10 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
19229
19695
  if (!fundingUtxo) {
19230
19696
  throw new Error(`UTXO at index ${i} is undefined`);
19231
19697
  }
19232
- const pubKeyHash = hash160((0, import_utils12.hexToBytes)(fundingUtxo.publicKey));
19698
+ const pubKeyHash = hash160((0, import_utils11.hexToBytes)(fundingUtxo.publicKey));
19233
19699
  const scriptToUse = new Uint8Array([0, 20, ...pubKeyHash]);
19234
- const providedScript = (0, import_utils12.hexToBytes)(fundingUtxo.script);
19235
- if ((0, import_utils12.bytesToHex)(scriptToUse) !== (0, import_utils12.bytesToHex)(providedScript)) {
19700
+ const providedScript = (0, import_utils11.hexToBytes)(fundingUtxo.script);
19701
+ if ((0, import_utils11.bytesToHex)(scriptToUse) !== (0, import_utils11.bytesToHex)(providedScript)) {
19236
19702
  throw new Error(
19237
19703
  `\u274C Derived script doesn't match provided script for UTXO ${i + 1}.`
19238
19704
  );
@@ -19297,7 +19763,7 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
19297
19763
  }
19298
19764
  let psbtHex;
19299
19765
  try {
19300
- psbtHex = (0, import_utils12.bytesToHex)(builder.toPSBT());
19766
+ psbtHex = (0, import_utils11.bytesToHex)(builder.toPSBT());
19301
19767
  } catch (error) {
19302
19768
  throw new Error(`Failed to extract transaction: ${error}`);
19303
19769
  }
@@ -19474,13 +19940,13 @@ var NativeSparkFrost = class {
19474
19940
  // src/signer/signer.ts
19475
19941
  init_buffer();
19476
19942
  var import_secp256k17 = require("@bitcoinerlab/secp256k1");
19477
- var import_utils14 = require("@noble/curves/abstract/utils");
19478
19943
  var import_secp256k18 = require("@noble/curves/secp256k1");
19944
+ var import_utils13 = require("@noble/curves/utils");
19479
19945
  var import_sha26 = require("@noble/hashes/sha2");
19480
19946
  var import_bip32 = require("@scure/bip32");
19481
19947
  var import_bip39 = require("@scure/bip39");
19482
19948
  var import_english = require("@scure/bip39/wordlists/english");
19483
- var import_utils15 = require("@scure/btc-signer/utils");
19949
+ var import_utils14 = require("@scure/btc-signer/utils");
19484
19950
  var ecies = __toESM(require("eciesjs"), 1);
19485
19951
 
19486
19952
  // src/constants.ts
@@ -19488,7 +19954,7 @@ init_buffer();
19488
19954
  var import_core9 = require("@lightsparkdev/core");
19489
19955
  var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
19490
19956
  var isBun = globalThis.Bun !== void 0;
19491
- var packageVersion = true ? "0.2.11" : "unknown";
19957
+ var packageVersion = true ? "0.2.12" : "unknown";
19492
19958
  var baseEnvStr = "unknown";
19493
19959
  if (isBun) {
19494
19960
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
@@ -19599,7 +20065,7 @@ var DefaultSparkSigner = class {
19599
20065
  });
19600
20066
  }
19601
20067
  const receiverEciesPrivKey = ecies.PrivateKey.fromHex(
19602
- (0, import_utils14.bytesToHex)(this.identityKey.privateKey)
20068
+ (0, import_utils13.bytesToHex)(this.identityKey.privateKey)
19603
20069
  );
19604
20070
  const privateKey = ecies.decrypt(receiverEciesPrivKey.toHex(), ciphertext);
19605
20071
  return privateKey;
@@ -19733,7 +20199,7 @@ var DefaultSparkSigner = class {
19733
20199
  threshold,
19734
20200
  numShares
19735
20201
  }) {
19736
- const secretAsInt = (0, import_utils14.bytesToNumberBE)(secret);
20202
+ const secretAsInt = (0, import_utils13.bytesToNumberBE)(secret);
19737
20203
  return splitSecretWithProofs(secretAsInt, curveOrder, threshold, numShares);
19738
20204
  }
19739
20205
  async signFrost({
@@ -19769,7 +20235,7 @@ var DefaultSparkSigner = class {
19769
20235
  publicKey,
19770
20236
  verifyingKey
19771
20237
  };
19772
- const logMessage = (0, import_utils14.bytesToHex)(message);
20238
+ const logMessage = (0, import_utils13.bytesToHex)(message);
19773
20239
  const result = await SparkFrost.signFrost({
19774
20240
  message,
19775
20241
  keyPackage,
@@ -19811,7 +20277,7 @@ var DefaultSparkSigner = class {
19811
20277
  }
19812
20278
  async createSparkWalletFromSeed(seed, accountNumber) {
19813
20279
  if (typeof seed === "string") {
19814
- seed = (0, import_utils14.hexToBytes)(seed);
20280
+ seed = (0, import_utils13.hexToBytes)(seed);
19815
20281
  }
19816
20282
  const {
19817
20283
  identityKey,
@@ -19823,7 +20289,7 @@ var DefaultSparkSigner = class {
19823
20289
  this.depositKey = depositKey;
19824
20290
  this.signingKey = signingKey.hdKey;
19825
20291
  this.staticDepositKey = staticDepositKey.hdKey;
19826
- return (0, import_utils14.bytesToHex)(identityKey.publicKey);
20292
+ return (0, import_utils13.bytesToHex)(identityKey.publicKey);
19827
20293
  }
19828
20294
  async signMessageWithIdentityKey(message, compact) {
19829
20295
  if (!this.identityKey?.privateKey) {
@@ -19844,7 +20310,7 @@ var DefaultSparkSigner = class {
19844
20310
  });
19845
20311
  }
19846
20312
  const receiverEciesPrivKey = ecies.PrivateKey.fromHex(
19847
- (0, import_utils14.bytesToHex)(this.identityKey.privateKey)
20313
+ (0, import_utils13.bytesToHex)(this.identityKey.privateKey)
19848
20314
  );
19849
20315
  const privateKey = ecies.decrypt(receiverEciesPrivKey.toHex(), ciphertext);
19850
20316
  const publicKey = import_secp256k18.secp256k1.getPublicKey(privateKey);
@@ -19868,15 +20334,15 @@ var DefaultSparkSigner = class {
19868
20334
  }
19869
20335
  signTransactionIndex(tx, index, publicKey) {
19870
20336
  let privateKey;
19871
- if ((0, import_utils14.equalBytes)(publicKey, this.identityKey?.publicKey ?? new Uint8Array())) {
20337
+ if ((0, import_utils13.equalBytes)(publicKey, this.identityKey?.publicKey ?? new Uint8Array())) {
19872
20338
  privateKey = this.identityKey?.privateKey;
19873
- } else if ((0, import_utils14.equalBytes)(publicKey, this.depositKey?.publicKey ?? new Uint8Array())) {
20339
+ } else if ((0, import_utils13.equalBytes)(publicKey, this.depositKey?.publicKey ?? new Uint8Array())) {
19874
20340
  privateKey = this.depositKey?.privateKey;
19875
20341
  }
19876
20342
  if (!privateKey) {
19877
20343
  throw new ValidationError("Private key not found for public key", {
19878
20344
  field: "privateKey",
19879
- value: (0, import_utils14.bytesToHex)(publicKey)
20345
+ value: (0, import_utils13.bytesToHex)(publicKey)
19880
20346
  });
19881
20347
  }
19882
20348
  tx.signIdx(privateKey, index);
@@ -19949,8 +20415,8 @@ var ReactNativeSparkSigner = class extends DefaultSparkSigner {
19949
20415
  // src/spark-wallet/spark-wallet.ts
19950
20416
  init_buffer();
19951
20417
  var import_core13 = require("@lightsparkdev/core");
19952
- var import_utils25 = require("@noble/curves/abstract/utils");
19953
20418
  var import_secp256k115 = require("@noble/curves/secp256k1");
20419
+ var import_utils24 = require("@noble/curves/utils");
19954
20420
  var import_bip392 = require("@scure/bip39");
19955
20421
  var import_english2 = require("@scure/bip39/wordlists/english");
19956
20422
  var import_btc_signer6 = require("@scure/btc-signer");
@@ -25316,8 +25782,8 @@ var import_uuidv73 = require("uuidv7");
25316
25782
 
25317
25783
  // src/services/transfer.ts
25318
25784
  init_buffer();
25319
- var import_utils16 = require("@noble/curves/abstract/utils");
25320
25785
  var import_secp256k19 = require("@noble/curves/secp256k1");
25786
+ var import_utils15 = require("@noble/curves/utils");
25321
25787
  var import_sha29 = require("@noble/hashes/sha2");
25322
25788
  var import_btc_signer2 = require("@scure/btc-signer");
25323
25789
  var ecies2 = __toESM(require("eciesjs"), 1);
@@ -25687,7 +26153,7 @@ var BaseTransferService = class {
25687
26153
  }
25688
26154
  async prepareSendTransferKeyTweaks(transferID, receiverIdentityPubkey, leaves, cpfpRefundSignatureMap, directRefundSignatureMap, directFromCpfpRefundSignatureMap) {
25689
26155
  const receiverEciesPubKey = ecies2.PublicKey.fromHex(
25690
- (0, import_utils16.bytesToHex)(receiverIdentityPubkey)
26156
+ (0, import_utils15.bytesToHex)(receiverIdentityPubkey)
25691
26157
  );
25692
26158
  const leavesTweaksMap = /* @__PURE__ */ new Map();
25693
26159
  for (const leaf of leaves) {
@@ -25728,7 +26194,7 @@ var BaseTransferService = class {
25728
26194
  throw new Error(`Share not found for operator ${operator.id}`);
25729
26195
  }
25730
26196
  const pubkeyTweak = import_secp256k19.secp256k1.getPublicKey(
25731
- (0, import_utils16.numberToBytesBE)(share.share, 32),
26197
+ (0, import_utils15.numberToBytesBE)(share.share, 32),
25732
26198
  true
25733
26199
  );
25734
26200
  pubkeySharesTweak.set(identifier, pubkeyTweak);
@@ -25753,7 +26219,7 @@ var BaseTransferService = class {
25753
26219
  leafTweaksMap.set(identifier, {
25754
26220
  leafId: leaf.leaf.id,
25755
26221
  secretShareTweak: {
25756
- secretShare: (0, import_utils16.numberToBytesBE)(share.share, 32),
26222
+ secretShare: (0, import_utils15.numberToBytesBE)(share.share, 32),
25757
26223
  proofs: share.proofs
25758
26224
  },
25759
26225
  pubkeySharesTweak: Object.fromEntries(pubkeySharesTweak),
@@ -25776,7 +26242,7 @@ var BaseTransferService = class {
25776
26242
  return void 0;
25777
26243
  }
25778
26244
  compareTransfers(transfer1, transfer2) {
25779
- return transfer1.id === transfer2.id && (0, import_utils16.equalBytes)(
26245
+ return transfer1.id === transfer2.id && (0, import_utils15.equalBytes)(
25780
26246
  transfer1.senderIdentityPublicKey,
25781
26247
  transfer2.senderIdentityPublicKey
25782
26248
  ) && transfer1.status === transfer2.status && transfer1.totalValue === transfer2.totalValue && transfer1.expiryTime?.getTime() === transfer2.expiryTime?.getTime() && transfer1.leaves.length === transfer2.leaves.length;
@@ -26075,7 +26541,7 @@ var TransferService = class extends BaseTransferService {
26075
26541
  }
26076
26542
  const nodeTx = getTxFromRawTxBytes(leaf.leaf.nodeTx);
26077
26543
  const cpfpNodeOutPoint = {
26078
- txid: (0, import_utils16.hexToBytes)(getTxId(nodeTx)),
26544
+ txid: (0, import_utils15.hexToBytes)(getTxId(nodeTx)),
26079
26545
  index: 0
26080
26546
  };
26081
26547
  let directNodeTx;
@@ -26083,7 +26549,7 @@ var TransferService = class extends BaseTransferService {
26083
26549
  if (leaf.leaf.directTx.length > 0) {
26084
26550
  directNodeTx = getTxFromRawTxBytes(leaf.leaf.directTx);
26085
26551
  directNodeOutPoint = {
26086
- txid: (0, import_utils16.hexToBytes)(getTxId(directNodeTx)),
26552
+ txid: (0, import_utils15.hexToBytes)(getTxId(directNodeTx)),
26087
26553
  index: 0
26088
26554
  };
26089
26555
  }
@@ -26217,7 +26683,7 @@ var TransferService = class extends BaseTransferService {
26217
26683
  throw new Error(`Share not found for operator ${operator.id}`);
26218
26684
  }
26219
26685
  const pubkeyTweak = import_secp256k19.secp256k1.getPublicKey(
26220
- (0, import_utils16.numberToBytesBE)(share.share, 32)
26686
+ (0, import_utils15.numberToBytesBE)(share.share, 32)
26221
26687
  );
26222
26688
  pubkeySharesTweak.set(identifier, pubkeyTweak);
26223
26689
  }
@@ -26230,7 +26696,7 @@ var TransferService = class extends BaseTransferService {
26230
26696
  leafTweaksMap.set(identifier, {
26231
26697
  leafId: leaf.leaf.id,
26232
26698
  secretShareTweak: {
26233
- secretShare: (0, import_utils16.numberToBytesBE)(share.share, 32),
26699
+ secretShare: (0, import_utils15.numberToBytesBE)(share.share, 32),
26234
26700
  proofs: share.proofs
26235
26701
  },
26236
26702
  pubkeySharesTweak: Object.fromEntries(pubkeySharesTweak)
@@ -26416,13 +26882,13 @@ var TransferService = class extends BaseTransferService {
26416
26882
  });
26417
26883
  }
26418
26884
  const newCpfpRefundOutPoint = {
26419
- txid: (0, import_utils16.hexToBytes)(getTxId(cpfpNodeTx)),
26885
+ txid: (0, import_utils15.hexToBytes)(getTxId(cpfpNodeTx)),
26420
26886
  index: 0
26421
26887
  };
26422
26888
  let newDirectRefundOutPoint;
26423
26889
  if (newDirectNodeTx) {
26424
26890
  newDirectRefundOutPoint = {
26425
- txid: (0, import_utils16.hexToBytes)(getTxId(newDirectNodeTx)),
26891
+ txid: (0, import_utils15.hexToBytes)(getTxId(newDirectNodeTx)),
26426
26892
  index: 0
26427
26893
  };
26428
26894
  }
@@ -26550,7 +27016,7 @@ var TransferService = class extends BaseTransferService {
26550
27016
  const refundTx = getTxFromRawTxBytes(node.refundTx);
26551
27017
  const refundSequence = refundTx.getInput(0).sequence || 0;
26552
27018
  const newNodeOutPoint = {
26553
- txid: (0, import_utils16.hexToBytes)(getTxId(nodeTx)),
27019
+ txid: (0, import_utils15.hexToBytes)(getTxId(nodeTx)),
26554
27020
  index: 0
26555
27021
  };
26556
27022
  const {
@@ -26587,13 +27053,13 @@ var TransferService = class extends BaseTransferService {
26587
27053
  });
26588
27054
  }
26589
27055
  const newCpfpRefundOutPoint = {
26590
- txid: (0, import_utils16.hexToBytes)(getTxId(newNodeTx)),
27056
+ txid: (0, import_utils15.hexToBytes)(getTxId(newNodeTx)),
26591
27057
  index: 0
26592
27058
  };
26593
27059
  let newDirectRefundOutPoint;
26594
27060
  if (newDirectNodeTx) {
26595
27061
  newDirectRefundOutPoint = {
26596
- txid: (0, import_utils16.hexToBytes)(getTxId(newDirectNodeTx)),
27062
+ txid: (0, import_utils15.hexToBytes)(getTxId(newDirectNodeTx)),
26597
27063
  index: 0
26598
27064
  };
26599
27065
  }
@@ -26827,13 +27293,13 @@ var TransferService = class extends BaseTransferService {
26827
27293
  };
26828
27294
  const signingPublicKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
26829
27295
  const cpfpRefundOutPoint = {
26830
- txid: (0, import_utils16.hexToBytes)(getTxId(nodeTx)),
27296
+ txid: (0, import_utils15.hexToBytes)(getTxId(nodeTx)),
26831
27297
  index: 0
26832
27298
  };
26833
27299
  let directRefundOutPoint;
26834
27300
  if (directNodeTx) {
26835
27301
  directRefundOutPoint = {
26836
- txid: (0, import_utils16.hexToBytes)(getTxId(directNodeTx)),
27302
+ txid: (0, import_utils15.hexToBytes)(getTxId(directNodeTx)),
26837
27303
  index: 0
26838
27304
  };
26839
27305
  }
@@ -27209,9 +27675,9 @@ var CoopExitService = class extends BaseTransferService {
27209
27675
  init_buffer();
27210
27676
  var import_secp256k110 = require("@noble/curves/secp256k1");
27211
27677
  var import_sha210 = require("@noble/hashes/sha2");
27212
- var import_utils17 = require("@noble/hashes/utils");
27678
+ var import_utils16 = require("@noble/hashes/utils");
27213
27679
  var import_btc_signer4 = require("@scure/btc-signer");
27214
- var import_utils18 = require("@scure/btc-signer/utils");
27680
+ var import_utils17 = require("@scure/btc-signer/utils");
27215
27681
  var DepositService = class {
27216
27682
  config;
27217
27683
  connectionManager;
@@ -27221,7 +27687,8 @@ var DepositService = class {
27221
27687
  }
27222
27688
  async validateDepositAddress({
27223
27689
  address: address2,
27224
- userPubkey
27690
+ userPubkey,
27691
+ verifyCoordinatorProof = false
27225
27692
  }) {
27226
27693
  if (!address2.depositAddressProof || !address2.depositAddressProof.proofOfPossessionSignature || !address2.depositAddressProof.addressSignatures) {
27227
27694
  throw new ValidationError(
@@ -27259,10 +27726,10 @@ var DepositService = class {
27259
27726
  }
27260
27727
  const addrHash = (0, import_sha210.sha256)(address2.address);
27261
27728
  for (const operator of Object.values(this.config.getSigningOperators())) {
27262
- if (operator.identifier === this.config.getCoordinatorIdentifier()) {
27729
+ if (operator.identifier === this.config.getCoordinatorIdentifier() && !verifyCoordinatorProof) {
27263
27730
  continue;
27264
27731
  }
27265
- const operatorPubkey2 = (0, import_utils17.hexToBytes)(operator.identityPublicKey);
27732
+ const operatorPubkey2 = (0, import_utils16.hexToBytes)(operator.identityPublicKey);
27266
27733
  const operatorSig = address2.depositAddressProof.addressSignatures[operator.identifier];
27267
27734
  if (!operatorSig) {
27268
27735
  throw new ValidationError("Operator signature not found", {
@@ -27284,6 +27751,46 @@ var DepositService = class {
27284
27751
  }
27285
27752
  }
27286
27753
  }
27754
+ async generateStaticDepositAddress({
27755
+ signingPubkey
27756
+ }) {
27757
+ const sparkClient = await this.connectionManager.createSparkClient(
27758
+ this.config.getCoordinatorAddress()
27759
+ );
27760
+ let depositResp;
27761
+ try {
27762
+ depositResp = await sparkClient.generate_static_deposit_address({
27763
+ signingPublicKey: signingPubkey,
27764
+ identityPublicKey: await this.config.signer.getIdentityPublicKey(),
27765
+ network: this.config.getNetworkProto()
27766
+ });
27767
+ } catch (error) {
27768
+ throw new NetworkError(
27769
+ "Failed to generate static deposit address",
27770
+ {
27771
+ operation: "generate_static_deposit_address",
27772
+ errorCount: 1,
27773
+ errors: error instanceof Error ? error.message : String(error)
27774
+ },
27775
+ error
27776
+ );
27777
+ }
27778
+ if (!depositResp.depositAddress) {
27779
+ throw new ValidationError(
27780
+ "No static deposit address response from coordinator",
27781
+ {
27782
+ field: "depositAddress",
27783
+ value: depositResp
27784
+ }
27785
+ );
27786
+ }
27787
+ await this.validateDepositAddress({
27788
+ address: depositResp.depositAddress,
27789
+ userPubkey: signingPubkey,
27790
+ verifyCoordinatorProof: true
27791
+ });
27792
+ return depositResp;
27793
+ }
27287
27794
  async generateDepositAddress({
27288
27795
  signingPubkey,
27289
27796
  leafId,
@@ -27351,7 +27858,7 @@ var DepositService = class {
27351
27858
  });
27352
27859
  }
27353
27860
  const depositOutPoint = {
27354
- txid: (0, import_utils17.hexToBytes)(getTxId(depositTx)),
27861
+ txid: (0, import_utils16.hexToBytes)(getTxId(depositTx)),
27355
27862
  index: vout
27356
27863
  };
27357
27864
  const depositTxOut = {
@@ -27370,8 +27877,8 @@ var DepositService = class {
27370
27877
  const { cpfpRefundTx, directRefundTx, directFromCpfpRefundTx } = createRefundTxs({
27371
27878
  sequence: INITIAL_SEQUENCE,
27372
27879
  directSequence: INITIAL_DIRECT_SEQUENCE,
27373
- input: { txid: (0, import_utils17.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
27374
- directInput: { txid: (0, import_utils17.hexToBytes)(getTxId(directRootTx)), index: 0 },
27880
+ input: { txid: (0, import_utils16.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
27881
+ directInput: { txid: (0, import_utils16.hexToBytes)(getTxId(directRootTx)), index: 0 },
27375
27882
  amountSats: amount,
27376
27883
  receivingPubkey: signingPubKey,
27377
27884
  network: this.config.getNetwork()
@@ -27501,7 +28008,7 @@ var DepositService = class {
27501
28008
  }
27502
28009
  );
27503
28010
  }
27504
- if (!(0, import_utils18.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
28011
+ if (!(0, import_utils17.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
27505
28012
  throw new ValidationError("Verifying key mismatch", {
27506
28013
  field: "verifyingKey",
27507
28014
  value: treeResp.rootNodeSignatureShares.verifyingKey,
@@ -27665,7 +28172,7 @@ var DepositService = class {
27665
28172
  });
27666
28173
  }
27667
28174
  const depositOutPoint = {
27668
- txid: (0, import_utils17.hexToBytes)(getTxId(depositTx)),
28175
+ txid: (0, import_utils16.hexToBytes)(getTxId(depositTx)),
27669
28176
  index: vout
27670
28177
  };
27671
28178
  const depositTxOut = {
@@ -27678,7 +28185,7 @@ var DepositService = class {
27678
28185
  const signingPubKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
27679
28186
  const { cpfpRefundTx } = createRefundTxs({
27680
28187
  sequence: INITIAL_SEQUENCE,
27681
- input: { txid: (0, import_utils17.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
28188
+ input: { txid: (0, import_utils16.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
27682
28189
  amountSats: amount,
27683
28190
  receivingPubkey: signingPubKey,
27684
28191
  network: this.config.getNetwork()
@@ -27748,7 +28255,7 @@ var DepositService = class {
27748
28255
  }
27749
28256
  );
27750
28257
  }
27751
- if (!(0, import_utils18.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
28258
+ if (!(0, import_utils17.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
27752
28259
  throw new ValidationError("Verifying key mismatch", {
27753
28260
  field: "verifyingKey",
27754
28261
  value: treeResp.rootNodeSignatureShares.verifyingKey,
@@ -27824,8 +28331,8 @@ var DepositService = class {
27824
28331
 
27825
28332
  // src/services/lightning.ts
27826
28333
  init_buffer();
27827
- var import_utils19 = require("@noble/curves/abstract/utils");
27828
28334
  var import_secp256k111 = require("@noble/curves/secp256k1");
28335
+ var import_utils18 = require("@noble/curves/utils");
27829
28336
  var import_sha211 = require("@noble/hashes/sha2");
27830
28337
  var import_uuidv74 = require("uuidv7");
27831
28338
 
@@ -27911,8 +28418,8 @@ var LightningService = class {
27911
28418
  }) {
27912
28419
  const crypto = getCrypto();
27913
28420
  const randBytes = crypto.getRandomValues(new Uint8Array(32));
27914
- const preimage = (0, import_utils19.numberToBytesBE)(
27915
- (0, import_utils19.bytesToNumberBE)(randBytes) % import_secp256k111.secp256k1.CURVE.n,
28421
+ const preimage = (0, import_utils18.numberToBytesBE)(
28422
+ (0, import_utils18.bytesToNumberBE)(randBytes) % import_secp256k111.secp256k1.CURVE.n,
27916
28423
  32
27917
28424
  );
27918
28425
  return await this.createLightningInvoiceWithPreImage({
@@ -27967,12 +28474,12 @@ var LightningService = class {
27967
28474
  const sparkClient = await this.connectionManager.createSparkClient(
27968
28475
  operator.address
27969
28476
  );
27970
- const userIdentityPublicKey = receiverIdentityPubkey ? (0, import_utils19.hexToBytes)(receiverIdentityPubkey) : await this.config.signer.getIdentityPublicKey();
28477
+ const userIdentityPublicKey = receiverIdentityPubkey ? (0, import_utils18.hexToBytes)(receiverIdentityPubkey) : await this.config.signer.getIdentityPublicKey();
27971
28478
  try {
27972
28479
  await sparkClient.store_preimage_share({
27973
28480
  paymentHash,
27974
28481
  preimageShare: {
27975
- secretShare: (0, import_utils19.numberToBytesBE)(share.share, 32),
28482
+ secretShare: (0, import_utils18.numberToBytesBE)(share.share, 32),
27976
28483
  proofs: share.proofs
27977
28484
  },
27978
28485
  threshold: this.config.getThreshold(),
@@ -28173,9 +28680,9 @@ var LightningService = class {
28173
28680
 
28174
28681
  // src/services/token-transactions.ts
28175
28682
  init_buffer();
28176
- var import_utils20 = require("@noble/curves/abstract/utils");
28177
28683
  var import_secp256k113 = require("@noble/curves/secp256k1");
28178
- var import_utils21 = require("@noble/hashes/utils");
28684
+ var import_utils19 = require("@noble/curves/utils");
28685
+ var import_utils20 = require("@noble/hashes/utils");
28179
28686
 
28180
28687
  // src/utils/token-hashing.ts
28181
28688
  init_buffer();
@@ -30109,14 +30616,14 @@ var TokenTransactionService = class {
30109
30616
  }
30110
30617
  if (this.config.getTokenTransactionVersion() !== "V0" && receiverAddress.sparkInvoiceFields) {
30111
30618
  return {
30112
- receiverPublicKey: (0, import_utils21.hexToBytes)(receiverAddress.identityPublicKey),
30619
+ receiverPublicKey: (0, import_utils20.hexToBytes)(receiverAddress.identityPublicKey),
30113
30620
  rawTokenIdentifier,
30114
30621
  tokenAmount: transfer.tokenAmount,
30115
30622
  sparkInvoice: transfer.receiverSparkAddress
30116
30623
  };
30117
30624
  }
30118
30625
  return {
30119
- receiverPublicKey: (0, import_utils21.hexToBytes)(receiverAddress.identityPublicKey),
30626
+ receiverPublicKey: (0, import_utils20.hexToBytes)(receiverAddress.identityPublicKey),
30120
30627
  rawTokenIdentifier,
30121
30628
  tokenPublicKey,
30122
30629
  // Remove for full v0 deprecation
@@ -30155,7 +30662,7 @@ var TokenTransactionService = class {
30155
30662
  const tokenOutputs = tokenOutputData.map((output) => ({
30156
30663
  ownerPublicKey: output.receiverPublicKey,
30157
30664
  tokenPublicKey: output.tokenPublicKey,
30158
- tokenAmount: (0, import_utils20.numberToBytesBE)(output.tokenAmount, 16)
30665
+ tokenAmount: (0, import_utils19.numberToBytesBE)(output.tokenAmount, 16)
30159
30666
  }));
30160
30667
  if (availableTokenAmount > totalRequestedAmount) {
30161
30668
  const changeAmount = availableTokenAmount - totalRequestedAmount;
@@ -30163,7 +30670,7 @@ var TokenTransactionService = class {
30163
30670
  tokenOutputs.push({
30164
30671
  ownerPublicKey: await this.config.signer.getIdentityPublicKey(),
30165
30672
  tokenPublicKey: firstTokenPublicKey,
30166
- tokenAmount: (0, import_utils20.numberToBytesBE)(changeAmount, 16)
30673
+ tokenAmount: (0, import_utils19.numberToBytesBE)(changeAmount, 16)
30167
30674
  });
30168
30675
  }
30169
30676
  return {
@@ -30194,7 +30701,7 @@ var TokenTransactionService = class {
30194
30701
  (output) => ({
30195
30702
  ownerPublicKey: output.receiverPublicKey,
30196
30703
  tokenIdentifier: output.rawTokenIdentifier,
30197
- tokenAmount: (0, import_utils20.numberToBytesBE)(output.tokenAmount, 16)
30704
+ tokenAmount: (0, import_utils19.numberToBytesBE)(output.tokenAmount, 16)
30198
30705
  })
30199
30706
  );
30200
30707
  if (availableTokenAmount > totalRequestedAmount) {
@@ -30203,7 +30710,7 @@ var TokenTransactionService = class {
30203
30710
  tokenOutputs.push({
30204
30711
  ownerPublicKey: await this.config.signer.getIdentityPublicKey(),
30205
30712
  tokenIdentifier: firstTokenIdentifierBytes,
30206
- tokenAmount: (0, import_utils20.numberToBytesBE)(changeAmount, 16)
30713
+ tokenAmount: (0, import_utils19.numberToBytesBE)(changeAmount, 16)
30207
30714
  });
30208
30715
  }
30209
30716
  return {
@@ -30230,7 +30737,7 @@ var TokenTransactionService = class {
30230
30737
  for (const [_, operator] of Object.entries(
30231
30738
  this.config.getSigningOperators()
30232
30739
  )) {
30233
- operatorKeys.push((0, import_utils21.hexToBytes)(operator.identityPublicKey));
30740
+ operatorKeys.push((0, import_utils20.hexToBytes)(operator.identityPublicKey));
30234
30741
  }
30235
30742
  return operatorKeys;
30236
30743
  }
@@ -30314,7 +30821,7 @@ var TokenTransactionService = class {
30314
30821
  {
30315
30822
  field: "revocationCommitment",
30316
30823
  value: derivedRevocationCommitment,
30317
- expected: (0, import_utils20.bytesToHex)(outputsToSpendCommitments[outputIndex]),
30824
+ expected: (0, import_utils19.bytesToHex)(outputsToSpendCommitments[outputIndex]),
30318
30825
  outputIndex
30319
30826
  }
30320
30827
  )
@@ -30340,7 +30847,7 @@ var TokenTransactionService = class {
30340
30847
  threshold
30341
30848
  );
30342
30849
  }
30343
- return (0, import_utils20.bytesToHex)(finalTokenTransactionHash);
30850
+ return (0, import_utils19.bytesToHex)(finalTokenTransactionHash);
30344
30851
  }
30345
30852
  async broadcastTokenTransactionV1(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
30346
30853
  const { finalTokenTransaction, finalTokenTransactionHash, threshold } = await this.startTokenTransaction(
@@ -30354,7 +30861,7 @@ var TokenTransactionService = class {
30354
30861
  finalTokenTransactionHash,
30355
30862
  signingOperators
30356
30863
  );
30357
- return (0, import_utils20.bytesToHex)(finalTokenTransactionHash);
30864
+ return (0, import_utils19.bytesToHex)(finalTokenTransactionHash);
30358
30865
  }
30359
30866
  async startTokenTransactionV0(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
30360
30867
  const sparkClient = await this.connectionManager.createSparkClient(
@@ -30578,7 +31085,7 @@ var TokenTransactionService = class {
30578
31085
  const identityPublicKey = await this.config.signer.getIdentityPublicKey();
30579
31086
  const payload = {
30580
31087
  finalTokenTransactionHash,
30581
- operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
31088
+ operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
30582
31089
  };
30583
31090
  const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
30584
31091
  let operatorSpecificSignatures = [];
@@ -30793,8 +31300,8 @@ var TokenTransactionService = class {
30793
31300
  this.config.getCoordinatorAddress()
30794
31301
  );
30795
31302
  let queryParams = {
30796
- tokenPublicKeys: issuerPublicKeys?.map(import_utils21.hexToBytes),
30797
- ownerPublicKeys: ownerPublicKeys?.map(import_utils21.hexToBytes),
31303
+ tokenPublicKeys: issuerPublicKeys?.map(import_utils20.hexToBytes),
31304
+ ownerPublicKeys: ownerPublicKeys?.map(import_utils20.hexToBytes),
30798
31305
  tokenIdentifiers: tokenIdentifiers?.map((identifier) => {
30799
31306
  const { tokenIdentifier } = decodeBech32mTokenIdentifier(
30800
31307
  identifier,
@@ -30802,7 +31309,7 @@ var TokenTransactionService = class {
30802
31309
  );
30803
31310
  return tokenIdentifier;
30804
31311
  }),
30805
- tokenTransactionHashes: tokenTransactionHashes?.map(import_utils21.hexToBytes),
31312
+ tokenTransactionHashes: tokenTransactionHashes?.map(import_utils20.hexToBytes),
30806
31313
  outputIds: outputIds || [],
30807
31314
  limit: pageSize,
30808
31315
  offset
@@ -30861,8 +31368,8 @@ var TokenTransactionService = class {
30861
31368
  this.config.getCoordinatorAddress()
30862
31369
  );
30863
31370
  let queryParams = {
30864
- issuerPublicKeys: issuerPublicKeys?.map(import_utils21.hexToBytes),
30865
- ownerPublicKeys: ownerPublicKeys?.map(import_utils21.hexToBytes),
31371
+ issuerPublicKeys: issuerPublicKeys?.map(import_utils20.hexToBytes),
31372
+ ownerPublicKeys: ownerPublicKeys?.map(import_utils20.hexToBytes),
30866
31373
  tokenIdentifiers: tokenIdentifiers?.map((identifier) => {
30867
31374
  const { tokenIdentifier } = decodeBech32mTokenIdentifier(
30868
31375
  identifier,
@@ -30870,7 +31377,7 @@ var TokenTransactionService = class {
30870
31377
  );
30871
31378
  return tokenIdentifier;
30872
31379
  }),
30873
- tokenTransactionHashes: tokenTransactionHashes?.map(import_utils21.hexToBytes),
31380
+ tokenTransactionHashes: tokenTransactionHashes?.map(import_utils20.hexToBytes),
30874
31381
  outputIds: outputIds || [],
30875
31382
  limit: pageSize,
30876
31383
  offset
@@ -30905,7 +31412,7 @@ var TokenTransactionService = class {
30905
31412
  });
30906
31413
  }
30907
31414
  const exactMatch = tokenOutputs.find(
30908
- (item) => (0, import_utils20.bytesToNumberBE)(item.output.tokenAmount) === tokenAmount
31415
+ (item) => (0, import_utils19.bytesToNumberBE)(item.output.tokenAmount) === tokenAmount
30909
31416
  );
30910
31417
  if (exactMatch) {
30911
31418
  return [exactMatch];
@@ -30916,7 +31423,7 @@ var TokenTransactionService = class {
30916
31423
  for (const outputWithPreviousTransactionData of tokenOutputs) {
30917
31424
  if (remainingAmount <= 0n) break;
30918
31425
  selectedOutputs.push(outputWithPreviousTransactionData);
30919
- remainingAmount -= (0, import_utils20.bytesToNumberBE)(
31426
+ remainingAmount -= (0, import_utils19.bytesToNumberBE)(
30920
31427
  outputWithPreviousTransactionData.output.tokenAmount
30921
31428
  );
30922
31429
  }
@@ -30932,13 +31439,13 @@ var TokenTransactionService = class {
30932
31439
  if (strategy === "SMALL_FIRST") {
30933
31440
  tokenOutputs.sort((a, b) => {
30934
31441
  return Number(
30935
- (0, import_utils20.bytesToNumberBE)(a.output.tokenAmount) - (0, import_utils20.bytesToNumberBE)(b.output.tokenAmount)
31442
+ (0, import_utils19.bytesToNumberBE)(a.output.tokenAmount) - (0, import_utils19.bytesToNumberBE)(b.output.tokenAmount)
30936
31443
  );
30937
31444
  });
30938
31445
  } else {
30939
31446
  tokenOutputs.sort((a, b) => {
30940
31447
  return Number(
30941
- (0, import_utils20.bytesToNumberBE)(b.output.tokenAmount) - (0, import_utils20.bytesToNumberBE)(a.output.tokenAmount)
31448
+ (0, import_utils19.bytesToNumberBE)(b.output.tokenAmount) - (0, import_utils19.bytesToNumberBE)(a.output.tokenAmount)
30942
31449
  );
30943
31450
  });
30944
31451
  }
@@ -30946,7 +31453,7 @@ var TokenTransactionService = class {
30946
31453
  // Helper function for deciding if the signer public key is the identity public key
30947
31454
  async signMessageWithKey(message, publicKey) {
30948
31455
  const tokenSignatures = this.config.getTokenSignatures();
30949
- if ((0, import_utils20.bytesToHex)(publicKey) === (0, import_utils20.bytesToHex)(await this.config.signer.getIdentityPublicKey())) {
31456
+ if ((0, import_utils19.bytesToHex)(publicKey) === (0, import_utils19.bytesToHex)(await this.config.signer.getIdentityPublicKey())) {
30950
31457
  if (tokenSignatures === "SCHNORR") {
30951
31458
  return await this.config.signer.signSchnorrWithIdentityKey(message);
30952
31459
  } else {
@@ -30955,8 +31462,8 @@ var TokenTransactionService = class {
30955
31462
  } else {
30956
31463
  throw new ValidationError("Invalid public key", {
30957
31464
  field: "publicKey",
30958
- value: (0, import_utils20.bytesToHex)(publicKey),
30959
- expected: (0, import_utils20.bytesToHex)(await this.config.signer.getIdentityPublicKey())
31465
+ value: (0, import_utils19.bytesToHex)(publicKey),
31466
+ expected: (0, import_utils19.bytesToHex)(await this.config.signer.getIdentityPublicKey())
30960
31467
  });
30961
31468
  }
30962
31469
  }
@@ -31019,7 +31526,7 @@ var TokenTransactionService = class {
31019
31526
  }
31020
31527
  const payload = {
31021
31528
  finalTokenTransactionHash,
31022
- operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
31529
+ operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
31023
31530
  };
31024
31531
  const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
31025
31532
  const ownerSignature = await this.signMessageWithKey(
@@ -31041,7 +31548,7 @@ var TokenTransactionService = class {
31041
31548
  }
31042
31549
  const payload = {
31043
31550
  finalTokenTransactionHash,
31044
- operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
31551
+ operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
31045
31552
  };
31046
31553
  const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
31047
31554
  const ownerSignature = await this.signMessageWithKey(
@@ -31057,7 +31564,7 @@ var TokenTransactionService = class {
31057
31564
  for (let i = 0; i < transferInput.outputsToSpend.length; i++) {
31058
31565
  const payload = {
31059
31566
  finalTokenTransactionHash,
31060
- operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
31567
+ operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
31061
31568
  };
31062
31569
  const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
31063
31570
  let ownerSignature;
@@ -31074,7 +31581,7 @@ var TokenTransactionService = class {
31074
31581
  }
31075
31582
  inputTtxoSignaturesPerOperator.push({
31076
31583
  ttxoSignatures,
31077
- operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
31584
+ operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
31078
31585
  });
31079
31586
  }
31080
31587
  return inputTtxoSignaturesPerOperator;
@@ -31093,7 +31600,7 @@ var import_nice_grpc_common3 = require("nice-grpc-common");
31093
31600
 
31094
31601
  // src/services/signing.ts
31095
31602
  init_buffer();
31096
- var import_utils22 = require("@noble/curves/abstract/utils");
31603
+ var import_utils21 = require("@noble/curves/utils");
31097
31604
  var SigningService = class {
31098
31605
  config;
31099
31606
  constructor(config) {
@@ -31149,7 +31656,7 @@ var SigningService = class {
31149
31656
  }
31150
31657
  const nodeTx = getTxFromRawTxBytes(leaf.leaf.nodeTx);
31151
31658
  const cpfpNodeOutPoint = {
31152
- txid: (0, import_utils22.hexToBytes)(getTxId(nodeTx)),
31659
+ txid: (0, import_utils21.hexToBytes)(getTxId(nodeTx)),
31153
31660
  index: 0
31154
31661
  };
31155
31662
  const currRefundTx = getTxFromRawTxBytes(leaf.leaf.refundTx);
@@ -31175,7 +31682,7 @@ var SigningService = class {
31175
31682
  if (leaf.leaf.directTx.length > 0) {
31176
31683
  directNodeTx = getTxFromRawTxBytes(leaf.leaf.directTx);
31177
31684
  directNodeOutPoint = {
31178
- txid: (0, import_utils22.hexToBytes)(getTxId(directNodeTx)),
31685
+ txid: (0, import_utils21.hexToBytes)(getTxId(directNodeTx)),
31179
31686
  index: 0
31180
31687
  };
31181
31688
  }
@@ -31259,15 +31766,15 @@ var SigningService = class {
31259
31766
 
31260
31767
  // src/tests/utils/test-faucet.ts
31261
31768
  init_buffer();
31262
- var import_utils23 = require("@noble/curves/abstract/utils");
31263
31769
  var import_secp256k114 = require("@noble/curves/secp256k1");
31770
+ var import_utils22 = require("@noble/curves/utils");
31264
31771
  var btc5 = __toESM(require("@scure/btc-signer"), 1);
31265
31772
  var import_btc_signer5 = require("@scure/btc-signer");
31266
- var import_utils24 = require("@scure/btc-signer/utils");
31267
- var STATIC_FAUCET_KEY = (0, import_utils23.hexToBytes)(
31773
+ var import_utils23 = require("@scure/btc-signer/utils");
31774
+ var STATIC_FAUCET_KEY = (0, import_utils22.hexToBytes)(
31268
31775
  "deadbeef1337cafe4242424242424242deadbeef1337cafe4242424242424242"
31269
31776
  );
31270
- var STATIC_MINING_KEY = (0, import_utils23.hexToBytes)(
31777
+ var STATIC_MINING_KEY = (0, import_utils22.hexToBytes)(
31271
31778
  "1337cafe4242deadbeef4242424242421337cafe4242deadbeef424242424242"
31272
31779
  );
31273
31780
  var SATS_PER_BTC = 1e8;
@@ -31330,7 +31837,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
31330
31837
  if (!scanResult.success || scanResult.unspents.length === 0) {
31331
31838
  const blockHash = await this.generateToAddress(1, address2);
31332
31839
  const block = await this.getBlock(blockHash[0]);
31333
- const fundingTx = import_btc_signer5.Transaction.fromRaw((0, import_utils23.hexToBytes)(block.tx[0].hex), {
31840
+ const fundingTx = import_btc_signer5.Transaction.fromRaw((0, import_utils22.hexToBytes)(block.tx[0].hex), {
31334
31841
  allowUnknownOutputs: true
31335
31842
  });
31336
31843
  await this.generateToAddress(100, this.miningAddress);
@@ -31392,13 +31899,13 @@ var BitcoinFaucet = class _BitcoinFaucet {
31392
31899
  },
31393
31900
  STATIC_MINING_KEY
31394
31901
  );
31395
- await this.broadcastTx((0, import_utils23.bytesToHex)(signedSplitTx.extract()));
31902
+ await this.broadcastTx((0, import_utils22.bytesToHex)(signedSplitTx.extract()));
31396
31903
  const splitTxId = signedSplitTx.id;
31397
31904
  for (let i = 0; i < numCoinsToCreate; i++) {
31398
31905
  this.coins.push({
31399
31906
  key: STATIC_FAUCET_KEY,
31400
31907
  outpoint: {
31401
- txid: (0, import_utils23.hexToBytes)(splitTxId),
31908
+ txid: (0, import_utils22.hexToBytes)(splitTxId),
31402
31909
  index: i
31403
31910
  },
31404
31911
  txout: signedSplitTx.getOutput(i)
@@ -31426,7 +31933,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
31426
31933
  coinToSend.txout,
31427
31934
  coinToSend.key
31428
31935
  );
31429
- await this.broadcastTx((0, import_utils23.bytesToHex)(signedTx.extract()));
31936
+ await this.broadcastTx((0, import_utils22.bytesToHex)(signedTx.extract()));
31430
31937
  }
31431
31938
  async signFaucetCoin(unsignedTx, fundingTxOut, key) {
31432
31939
  const pubKey = import_secp256k114.secp256k1.getPublicKey(key);
@@ -31446,7 +31953,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
31446
31953
  new Array(unsignedTx.inputsLength).fill(fundingTxOut.amount)
31447
31954
  );
31448
31955
  const merkleRoot = new Uint8Array();
31449
- const tweakedKey = (0, import_utils24.taprootTweakPrivKey)(key, merkleRoot);
31956
+ const tweakedKey = (0, import_utils23.taprootTweakPrivKey)(key, merkleRoot);
31450
31957
  if (!tweakedKey)
31451
31958
  throw new Error("Invalid private key for taproot tweaking");
31452
31959
  const signature = import_secp256k114.schnorr.sign(sighash, tweakedKey);
@@ -31546,7 +32053,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
31546
32053
  });
31547
32054
  }
31548
32055
  const signedTx = await this.signFaucetCoin(tx, coin.txout, coin.key);
31549
- const txHex = (0, import_utils23.bytesToHex)(signedTx.extract());
32056
+ const txHex = (0, import_utils22.bytesToHex)(signedTx.extract());
31550
32057
  await this.broadcastTx(txHex);
31551
32058
  const randomKey = import_secp256k114.secp256k1.utils.randomPrivateKey();
31552
32059
  const randomPubKey = import_secp256k114.secp256k1.getPublicKey(randomKey);
@@ -31737,7 +32244,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
31737
32244
  try {
31738
32245
  if (event?.$case === "transfer" && event.transfer.transfer && event.transfer.transfer.type !== 40 /* COUNTER_SWAP */) {
31739
32246
  const { senderIdentityPublicKey, receiverIdentityPublicKey } = event.transfer.transfer;
31740
- if (event.transfer.transfer && !(0, import_utils25.equalBytes)(senderIdentityPublicKey, receiverIdentityPublicKey)) {
32247
+ if (event.transfer.transfer && !(0, import_utils24.equalBytes)(senderIdentityPublicKey, receiverIdentityPublicKey)) {
31741
32248
  await this.claimTransfer({
31742
32249
  transfer: event.transfer.transfer,
31743
32250
  emit: true,
@@ -31902,10 +32409,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
31902
32409
  leavesToIgnore.add(nodeId);
31903
32410
  continue;
31904
32411
  }
31905
- if (leaf.status !== operatorLeaf.status || !leaf.signingKeyshare || !operatorLeaf.signingKeyshare || !(0, import_utils25.equalBytes)(
32412
+ if (leaf.status !== operatorLeaf.status || !leaf.signingKeyshare || !operatorLeaf.signingKeyshare || !(0, import_utils24.equalBytes)(
31906
32413
  leaf.signingKeyshare.publicKey,
31907
32414
  operatorLeaf.signingKeyshare.publicKey
31908
- ) || !(0, import_utils25.equalBytes)(leaf.nodeTx, operatorLeaf.nodeTx)) {
32415
+ ) || !(0, import_utils24.equalBytes)(leaf.nodeTx, operatorLeaf.nodeTx)) {
31909
32416
  leavesToIgnore.add(nodeId);
31910
32417
  }
31911
32418
  }
@@ -31956,7 +32463,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
31956
32463
  });
31957
32464
  }
31958
32465
  verifyKey(pubkey1, pubkey2, verifyingKey) {
31959
- return (0, import_utils25.equalBytes)(addPublicKeys(pubkey1, pubkey2), verifyingKey);
32466
+ return (0, import_utils24.equalBytes)(addPublicKeys(pubkey1, pubkey2), verifyingKey);
31960
32467
  }
31961
32468
  async selectLeaves(targetAmounts) {
31962
32469
  if (targetAmounts.length === 0) {
@@ -32114,7 +32621,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32114
32621
  * @returns {Promise<string>} The identity public key as a hex string.
32115
32622
  */
32116
32623
  async getIdentityPublicKey() {
32117
- return (0, import_utils25.bytesToHex)(await this.config.signer.getIdentityPublicKey());
32624
+ return (0, import_utils24.bytesToHex)(await this.config.signer.getIdentityPublicKey());
32118
32625
  }
32119
32626
  /**
32120
32627
  * Gets the Spark address of the wallet.
@@ -32124,7 +32631,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32124
32631
  async getSparkAddress() {
32125
32632
  if (!this.sparkAddress) {
32126
32633
  this.sparkAddress = encodeSparkAddress({
32127
- identityPublicKey: (0, import_utils25.bytesToHex)(
32634
+ identityPublicKey: (0, import_utils24.bytesToHex)(
32128
32635
  await this.config.signer.getIdentityPublicKey()
32129
32636
  ),
32130
32637
  network: this.config.getNetworkType()
@@ -32187,7 +32694,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32187
32694
  $case: "tokensPayment",
32188
32695
  tokensPayment: {
32189
32696
  tokenIdentifier: decodedTokenIdentifier ?? void 0,
32190
- amount: amount ? (0, import_utils25.numberToVarBytesBE)(amount) : void 0
32697
+ amount: amount ? (0, import_utils24.numberToVarBytesBE)(amount) : void 0
32191
32698
  }
32192
32699
  };
32193
32700
  const invoiceFields = {
@@ -32195,7 +32702,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32195
32702
  id: (0, import_uuidv75.uuidv7obj)().bytes,
32196
32703
  paymentType: protoPayment,
32197
32704
  memo: memo ?? void 0,
32198
- senderPublicKey: senderPublicKey ? (0, import_utils25.hexToBytes)(senderPublicKey) : void 0,
32705
+ senderPublicKey: senderPublicKey ? (0, import_utils24.hexToBytes)(senderPublicKey) : void 0,
32199
32706
  expiryTime: expiryTime ?? void 0
32200
32707
  };
32201
32708
  validateSparkInvoiceFields(invoiceFields);
@@ -32208,7 +32715,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32208
32715
  const signature = await this.config.signer.signSchnorrWithIdentityKey(hash);
32209
32716
  return encodeSparkAddressWithSignature(
32210
32717
  {
32211
- identityPublicKey: (0, import_utils25.bytesToHex)(identityPublicKey),
32718
+ identityPublicKey: (0, import_utils24.bytesToHex)(identityPublicKey),
32212
32719
  network: this.config.getNetworkType(),
32213
32720
  sparkInvoiceFields: invoiceFields
32214
32721
  },
@@ -32254,7 +32761,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32254
32761
  mnemonic = mnemonicOrSeed;
32255
32762
  seed = await this.config.signer.mnemonicToSeed(mnemonicOrSeed);
32256
32763
  } else {
32257
- seed = (0, import_utils25.hexToBytes)(mnemonicOrSeed);
32764
+ seed = (0, import_utils24.hexToBytes)(mnemonicOrSeed);
32258
32765
  }
32259
32766
  }
32260
32767
  await this.initWalletFromSeed(seed, accountNumber);
@@ -32276,7 +32783,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32276
32783
  });
32277
32784
  }
32278
32785
  this.sparkAddress = encodeSparkAddress({
32279
- identityPublicKey: (0, import_utils25.bytesToHex)(identityPublicKey),
32786
+ identityPublicKey: (0, import_utils24.bytesToHex)(identityPublicKey),
32280
32787
  network: this.config.getNetworkType()
32281
32788
  });
32282
32789
  return this.sparkAddress;
@@ -32396,7 +32903,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32396
32903
  directFromCpfpSignatureMap
32397
32904
  } = await this.transferService.startSwapSignRefund(
32398
32905
  leafKeyTweaks,
32399
- (0, import_utils25.hexToBytes)(this.config.getSspIdentityPublicKey()),
32906
+ (0, import_utils24.hexToBytes)(this.config.getSspIdentityPublicKey()),
32400
32907
  new Date(Date.now() + 2 * 60 * 1e3)
32401
32908
  );
32402
32909
  try {
@@ -32456,18 +32963,18 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32456
32963
  const userLeaves = [];
32457
32964
  userLeaves.push({
32458
32965
  leaf_id: transfer.leaves[0].leaf.id,
32459
- raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
32966
+ raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32460
32967
  transfer.leaves[0].intermediateRefundTx
32461
32968
  ),
32462
- direct_raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
32969
+ direct_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32463
32970
  transfer.leaves[0].intermediateDirectRefundTx
32464
32971
  ),
32465
- direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
32972
+ direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32466
32973
  transfer.leaves[0].intermediateDirectFromCpfpRefundTx
32467
32974
  ),
32468
- adaptor_added_signature: (0, import_utils25.bytesToHex)(cpfpAdaptorSignature),
32469
- direct_adaptor_added_signature: (0, import_utils25.bytesToHex)(directAdaptorSignature),
32470
- direct_from_cpfp_adaptor_added_signature: (0, import_utils25.bytesToHex)(
32975
+ adaptor_added_signature: (0, import_utils24.bytesToHex)(cpfpAdaptorSignature),
32976
+ direct_adaptor_added_signature: (0, import_utils24.bytesToHex)(directAdaptorSignature),
32977
+ direct_from_cpfp_adaptor_added_signature: (0, import_utils24.bytesToHex)(
32471
32978
  directFromCpfpAdaptorSignature
32472
32979
  )
32473
32980
  });
@@ -32520,24 +33027,24 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32520
33027
  }
32521
33028
  userLeaves.push({
32522
33029
  leaf_id: leaf.leaf.id,
32523
- raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
33030
+ raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32524
33031
  leaf.intermediateRefundTx
32525
33032
  ),
32526
- direct_raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
33033
+ direct_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32527
33034
  leaf.intermediateDirectRefundTx
32528
33035
  ),
32529
- direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
33036
+ direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32530
33037
  leaf.intermediateDirectFromCpfpRefundTx
32531
33038
  ),
32532
- adaptor_added_signature: (0, import_utils25.bytesToHex)(cpfpSignature),
32533
- direct_adaptor_added_signature: (0, import_utils25.bytesToHex)(directSignature),
32534
- direct_from_cpfp_adaptor_added_signature: (0, import_utils25.bytesToHex)(
33039
+ adaptor_added_signature: (0, import_utils24.bytesToHex)(cpfpSignature),
33040
+ direct_adaptor_added_signature: (0, import_utils24.bytesToHex)(directSignature),
33041
+ direct_from_cpfp_adaptor_added_signature: (0, import_utils24.bytesToHex)(
32535
33042
  directFromCpfpSignature
32536
33043
  )
32537
33044
  });
32538
33045
  }
32539
33046
  const sspClient = this.getSspClient();
32540
- const cpfpAdaptorPubkey = (0, import_utils25.bytesToHex)(
33047
+ const cpfpAdaptorPubkey = (0, import_utils24.bytesToHex)(
32541
33048
  import_secp256k115.secp256k1.getPublicKey(cpfpAdaptorPrivateKey)
32542
33049
  );
32543
33050
  if (!cpfpAdaptorPubkey) {
@@ -32545,13 +33052,13 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32545
33052
  }
32546
33053
  let directAdaptorPubkey;
32547
33054
  if (directAdaptorPrivateKey.length > 0) {
32548
- directAdaptorPubkey = (0, import_utils25.bytesToHex)(
33055
+ directAdaptorPubkey = (0, import_utils24.bytesToHex)(
32549
33056
  import_secp256k115.secp256k1.getPublicKey(directAdaptorPrivateKey)
32550
33057
  );
32551
33058
  }
32552
33059
  let directFromCpfpAdaptorPubkey;
32553
33060
  if (directFromCpfpAdaptorPrivateKey.length > 0) {
32554
- directFromCpfpAdaptorPubkey = (0, import_utils25.bytesToHex)(
33061
+ directFromCpfpAdaptorPubkey = (0, import_utils24.bytesToHex)(
32555
33062
  import_secp256k115.secp256k1.getPublicKey(directFromCpfpAdaptorPrivateKey)
32556
33063
  );
32557
33064
  }
@@ -32611,7 +33118,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32611
33118
  throw new Error(`Leaf not found for node ${nodeId}`);
32612
33119
  }
32613
33120
  const cpfpNodeTx = getTxFromRawTxBytes(node.nodeTx);
32614
- const cpfpRefundTxBytes = (0, import_utils25.hexToBytes)(leaf.rawUnsignedRefundTransaction);
33121
+ const cpfpRefundTxBytes = (0, import_utils24.hexToBytes)(leaf.rawUnsignedRefundTransaction);
32615
33122
  const cpfpRefundTx = getTxFromRawTxBytes(cpfpRefundTxBytes);
32616
33123
  const cpfpSighash = getSigHashFromTx(
32617
33124
  cpfpRefundTx,
@@ -32620,7 +33127,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32620
33127
  );
32621
33128
  const nodePublicKey = node.verifyingPublicKey;
32622
33129
  const taprootKey = computeTaprootKeyNoScript(nodePublicKey.slice(1));
32623
- const cpfpAdaptorSignatureBytes = (0, import_utils25.hexToBytes)(
33130
+ const cpfpAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
32624
33131
  leaf.adaptorSignedSignature
32625
33132
  );
32626
33133
  applyAdaptorToSignature(
@@ -32631,7 +33138,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32631
33138
  );
32632
33139
  if (leaf.directRawUnsignedRefundTransaction) {
32633
33140
  const directNodeTx = getTxFromRawTxBytes(node.directTx);
32634
- const directRefundTxBytes = (0, import_utils25.hexToBytes)(
33141
+ const directRefundTxBytes = (0, import_utils24.hexToBytes)(
32635
33142
  leaf.directRawUnsignedRefundTransaction
32636
33143
  );
32637
33144
  const directRefundTx = getTxFromRawTxBytes(directRefundTxBytes);
@@ -32645,7 +33152,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32645
33152
  `Direct adaptor signed signature missing for node ${nodeId}`
32646
33153
  );
32647
33154
  }
32648
- const directAdaptorSignatureBytes = (0, import_utils25.hexToBytes)(
33155
+ const directAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
32649
33156
  leaf.directAdaptorSignedSignature
32650
33157
  );
32651
33158
  applyAdaptorToSignature(
@@ -32656,7 +33163,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32656
33163
  );
32657
33164
  }
32658
33165
  if (leaf.directFromCpfpRawUnsignedRefundTransaction) {
32659
- const directFromCpfpRefundTxBytes = (0, import_utils25.hexToBytes)(
33166
+ const directFromCpfpRefundTxBytes = (0, import_utils24.hexToBytes)(
32660
33167
  leaf.directFromCpfpRawUnsignedRefundTransaction
32661
33168
  );
32662
33169
  const directFromCpfpRefundTx = getTxFromRawTxBytes(
@@ -32672,7 +33179,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32672
33179
  `Direct adaptor signed signature missing for node ${nodeId}`
32673
33180
  );
32674
33181
  }
32675
- const directFromCpfpAdaptorSignatureBytes = (0, import_utils25.hexToBytes)(
33182
+ const directFromCpfpAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
32676
33183
  leaf.directFromCpfpAdaptorSignedSignature
32677
33184
  );
32678
33185
  applyAdaptorToSignature(
@@ -32691,9 +33198,9 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32691
33198
  directFromCpfpSignatureMap
32692
33199
  );
32693
33200
  const completeResponse = await sspClient.completeLeaveSwap({
32694
- adaptorSecretKey: (0, import_utils25.bytesToHex)(cpfpAdaptorPrivateKey),
32695
- directAdaptorSecretKey: (0, import_utils25.bytesToHex)(directAdaptorPrivateKey),
32696
- directFromCpfpAdaptorSecretKey: (0, import_utils25.bytesToHex)(
33201
+ adaptorSecretKey: (0, import_utils24.bytesToHex)(cpfpAdaptorPrivateKey),
33202
+ directAdaptorSecretKey: (0, import_utils24.bytesToHex)(directAdaptorPrivateKey),
33203
+ directFromCpfpAdaptorSecretKey: (0, import_utils24.bytesToHex)(
32697
33204
  directFromCpfpAdaptorPrivateKey
32698
33205
  ),
32699
33206
  userOutboundTransferExternalId: transfer.id,
@@ -32788,12 +33295,12 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32788
33295
  let tokenMetadataMap = /* @__PURE__ */ new Map();
32789
33296
  for (const [tokenIdentifier, metadata] of this.tokenMetadata) {
32790
33297
  tokenMetadataMap.set(tokenIdentifier, {
32791
- tokenPublicKey: (0, import_utils25.bytesToHex)(metadata.issuerPublicKey),
33298
+ tokenPublicKey: (0, import_utils24.bytesToHex)(metadata.issuerPublicKey),
32792
33299
  rawTokenIdentifier: metadata.tokenIdentifier,
32793
33300
  tokenName: metadata.tokenName,
32794
33301
  tokenTicker: metadata.tokenTicker,
32795
33302
  decimals: metadata.decimals,
32796
- maxSupply: (0, import_utils25.bytesToNumberBE)(metadata.maxSupply)
33303
+ maxSupply: (0, import_utils24.bytesToNumberBE)(metadata.maxSupply)
32797
33304
  });
32798
33305
  }
32799
33306
  return tokenMetadataMap;
@@ -32828,7 +33335,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32828
33335
  * @returns {Promise<string>} A Bitcoin address for depositing funds
32829
33336
  */
32830
33337
  async getSingleUseDepositAddress() {
32831
- return await this.generateDepositAddress(false);
33338
+ return await this.generateDepositAddress();
32832
33339
  }
32833
33340
  /**
32834
33341
  * Generates a new static deposit address for receiving bitcoin funds.
@@ -32837,43 +33344,32 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32837
33344
  * @returns {Promise<string>} A Bitcoin address for depositing funds
32838
33345
  */
32839
33346
  async getStaticDepositAddress() {
32840
- try {
32841
- return await this.generateDepositAddress(true);
32842
- } catch (error) {
32843
- if (error.message?.includes("static deposit address already exists")) {
32844
- const existingAddresses = await this.queryStaticDepositAddresses();
32845
- if (existingAddresses.length > 0 && existingAddresses[0]) {
32846
- return existingAddresses[0];
32847
- } else {
32848
- throw error;
32849
- }
32850
- } else {
32851
- throw error;
32852
- }
33347
+ const signingPubkey = await this.config.signer.getStaticDepositSigningKey(0);
33348
+ const address2 = await this.depositService.generateStaticDepositAddress({
33349
+ signingPubkey
33350
+ });
33351
+ if (!address2.depositAddress) {
33352
+ throw new RPCError("Failed to generate static deposit address", {
33353
+ method: "generateStaticDepositAddress",
33354
+ params: { signingPubkey }
33355
+ });
32853
33356
  }
33357
+ return address2.depositAddress.address;
32854
33358
  }
32855
33359
  /**
32856
33360
  * Generates a deposit address for receiving funds.
32857
- *
32858
- * @param {boolean} static - Whether the address is static or single use
32859
33361
  * @returns {Promise<string>} A deposit address
32860
33362
  * @private
32861
33363
  */
32862
- async generateDepositAddress(isStatic) {
33364
+ async generateDepositAddress() {
32863
33365
  const leafId = (0, import_uuidv75.uuidv7)();
32864
- let signingPubkey;
32865
- if (isStatic) {
32866
- signingPubkey = await this.config.signer.getStaticDepositSigningKey(0);
32867
- } else {
32868
- signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
32869
- type: "leaf" /* LEAF */,
32870
- path: leafId
32871
- });
32872
- }
33366
+ const signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
33367
+ type: "leaf" /* LEAF */,
33368
+ path: leafId
33369
+ });
32873
33370
  const address2 = await this.depositService.generateDepositAddress({
32874
33371
  signingPubkey,
32875
- leafId,
32876
- isStatic
33372
+ leafId
32877
33373
  });
32878
33374
  if (!address2.depositAddress) {
32879
33375
  throw new RPCError("Failed to generate deposit address", {
@@ -32900,7 +33396,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32900
33396
  * @param offset - Pagination offset (default 0).
32901
33397
  * @returns {Promise<{ txid: string, vout: number }[]>} List of confirmed UTXOs.
32902
33398
  */
32903
- async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0) {
33399
+ async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0, excludeClaimed = false) {
32904
33400
  if (!depositAddress) {
32905
33401
  throw new ValidationError("Deposit address cannot be empty", {
32906
33402
  field: "depositAddress"
@@ -32914,10 +33410,11 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32914
33410
  address: depositAddress,
32915
33411
  network: NetworkToProto[this.config.getNetwork()],
32916
33412
  limit,
32917
- offset
33413
+ offset,
33414
+ excludeClaimed
32918
33415
  });
32919
33416
  return response.utxos.map((utxo) => ({
32920
- txid: (0, import_utils25.bytesToHex)(utxo.txid),
33417
+ txid: (0, import_utils24.bytesToHex)(utxo.txid),
32921
33418
  vout: utxo.vout
32922
33419
  })) ?? [];
32923
33420
  } catch (error) {
@@ -32987,7 +33484,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32987
33484
  if (network === BitcoinNetwork_default.FUTURE_VALUE) {
32988
33485
  network = BitcoinNetwork_default.REGTEST;
32989
33486
  }
32990
- const depositSecretKey = (0, import_utils25.bytesToHex)(
33487
+ const depositSecretKey = (0, import_utils24.bytesToHex)(
32991
33488
  await this.config.signer.getStaticDepositSecretKey(0)
32992
33489
  );
32993
33490
  const message = await this.getStaticDepositSigningPayload(
@@ -33000,7 +33497,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33000
33497
  );
33001
33498
  const hashBuffer = (0, import_sha213.sha256)(message);
33002
33499
  const signatureBytes = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
33003
- const signature = (0, import_utils25.bytesToHex)(signatureBytes);
33500
+ const signature = (0, import_utils24.bytesToHex)(signatureBytes);
33004
33501
  const response = await this.sspClient.claimStaticDeposit({
33005
33502
  transactionId,
33006
33503
  outputIndex,
@@ -33152,7 +33649,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33152
33649
  networkJSON.toLowerCase(),
33153
33650
  2 /* Refund */,
33154
33651
  creditAmountSats,
33155
- (0, import_utils25.bytesToHex)(spendTxSighash)
33652
+ (0, import_utils24.bytesToHex)(spendTxSighash)
33156
33653
  );
33157
33654
  const hashBuffer = (0, import_sha213.sha256)(message);
33158
33655
  const swapResponseUserSignature = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
@@ -33161,7 +33658,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33161
33658
  );
33162
33659
  const swapResponse = await sparkClient.initiate_static_deposit_utxo_refund({
33163
33660
  onChainUtxo: {
33164
- txid: (0, import_utils25.hexToBytes)(depositTransactionId),
33661
+ txid: (0, import_utils24.hexToBytes)(depositTransactionId),
33165
33662
  vout: outputIndex,
33166
33663
  network: networkType
33167
33664
  },
@@ -33230,7 +33727,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33230
33727
  creditAmountView.setUint32(0, lowerHalf, true);
33231
33728
  creditAmountView.setUint32(4, upperHalf, true);
33232
33729
  parts.push(new Uint8Array(creditAmountBuffer));
33233
- parts.push((0, import_utils25.hexToBytes)(sspSignature));
33730
+ parts.push((0, import_utils24.hexToBytes)(sspSignature));
33234
33731
  const totalLength = parts.reduce((sum, part) => sum + part.length, 0);
33235
33732
  const payload = new Uint8Array(totalLength);
33236
33733
  let offset = 0;
@@ -33635,9 +34132,9 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33635
34132
  });
33636
34133
  }
33637
34134
  const signerIdentityPublicKey = await this.config.signer.getIdentityPublicKey();
33638
- const isSelfTransfer = (0, import_utils25.equalBytes)(
34135
+ const isSelfTransfer = (0, import_utils24.equalBytes)(
33639
34136
  signerIdentityPublicKey,
33640
- (0, import_utils25.hexToBytes)(receiverAddress.identityPublicKey)
34137
+ (0, import_utils24.hexToBytes)(receiverAddress.identityPublicKey)
33641
34138
  );
33642
34139
  return await this.withLeaves(async () => {
33643
34140
  let leavesToSend = (await this.selectLeaves([amountSats])).get(
@@ -33659,7 +34156,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33659
34156
  );
33660
34157
  const transfer = await this.transferService.sendTransferWithKeyTweaks(
33661
34158
  leafKeyTweaks,
33662
- (0, import_utils25.hexToBytes)(receiverAddress.identityPublicKey)
34159
+ (0, import_utils24.hexToBytes)(receiverAddress.identityPublicKey)
33663
34160
  );
33664
34161
  const leavesToRemove = new Set(leavesToSend.map((leaf) => leaf.id));
33665
34162
  this.leaves = this.leaves.filter((leaf) => !leavesToRemove.has(leaf.id));
@@ -33675,7 +34172,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33675
34172
  }
33676
34173
  return mapTransferToWalletTransfer(
33677
34174
  transfer,
33678
- (0, import_utils25.bytesToHex)(await this.config.signer.getIdentityPublicKey())
34175
+ (0, import_utils24.bytesToHex)(await this.config.signer.getIdentityPublicKey())
33679
34176
  );
33680
34177
  });
33681
34178
  }
@@ -34031,7 +34528,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34031
34528
  const invoice2 = await sspClient.requestLightningReceive({
34032
34529
  amountSats: amountSats2,
34033
34530
  network: bitcoinNetwork,
34034
- paymentHash: (0, import_utils25.bytesToHex)(paymentHash),
34531
+ paymentHash: (0, import_utils24.bytesToHex)(paymentHash),
34035
34532
  expirySecs: expirySeconds,
34036
34533
  memo: memo2,
34037
34534
  includeSparkAddress,
@@ -34140,7 +34637,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34140
34637
  const sparkFallbackAddress = decodedInvoice.fallbackAddress;
34141
34638
  const paymentHash = decodedInvoice.paymentHash;
34142
34639
  if (preferSpark) {
34143
- if (sparkFallbackAddress === void 0 || isValidSparkFallback((0, import_utils25.hexToBytes)(sparkFallbackAddress)) === false) {
34640
+ if (sparkFallbackAddress === void 0 || isValidSparkFallback((0, import_utils24.hexToBytes)(sparkFallbackAddress)) === false) {
34144
34641
  console.warn(
34145
34642
  "No valid spark address found in invoice. Defaulting to lightning."
34146
34643
  );
@@ -34194,10 +34691,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34194
34691
  );
34195
34692
  const swapResponse = await this.lightningService.swapNodesForPreimage({
34196
34693
  leaves: leavesToSend,
34197
- receiverIdentityPubkey: (0, import_utils25.hexToBytes)(
34694
+ receiverIdentityPubkey: (0, import_utils24.hexToBytes)(
34198
34695
  this.config.getSspIdentityPublicKey()
34199
34696
  ),
34200
- paymentHash: (0, import_utils25.hexToBytes)(paymentHash),
34697
+ paymentHash: (0, import_utils24.hexToBytes)(paymentHash),
34201
34698
  isInboundPayment: false,
34202
34699
  invoiceString: invoice,
34203
34700
  feeSats: feeEstimate,
@@ -34315,7 +34812,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34315
34812
  });
34316
34813
  await this.syncTokenOutputs();
34317
34814
  const bech32mTokenIdentifier = encodeBech32mTokenIdentifier({
34318
- tokenIdentifier: (0, import_utils25.hexToBytes)(firstTokenIdentifierHexSeen),
34815
+ tokenIdentifier: (0, import_utils24.hexToBytes)(firstTokenIdentifierHexSeen),
34319
34816
  network: this.config.getNetworkType()
34320
34817
  });
34321
34818
  const receiverOutputs = decoded.map((d) => ({
@@ -34503,11 +35000,11 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34503
35000
  const connectorOutputs = [];
34504
35001
  for (let i = 0; i < connectorTx.outputsLength - 1; i++) {
34505
35002
  connectorOutputs.push({
34506
- txid: (0, import_utils25.hexToBytes)(connectorTxId),
35003
+ txid: (0, import_utils24.hexToBytes)(connectorTxId),
34507
35004
  index: i
34508
35005
  });
34509
35006
  }
34510
- const sspPubIdentityKey = (0, import_utils25.hexToBytes)(this.config.getSspIdentityPublicKey());
35007
+ const sspPubIdentityKey = (0, import_utils24.hexToBytes)(this.config.getSspIdentityPublicKey());
34511
35008
  const transfer = await this.coopExitService.getConnectorRefundSignatures({
34512
35009
  leaves: leafKeyTweaks,
34513
35010
  exitTxId: coopExitTxId,
@@ -34561,7 +35058,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34561
35058
  return transfers?.[0];
34562
35059
  }
34563
35060
  async constructTransfersWithUserRequest(transfers) {
34564
- const identityPublicKey = (0, import_utils25.bytesToHex)(
35061
+ const identityPublicKey = (0, import_utils24.bytesToHex)(
34565
35062
  await this.config.signer.getIdentityPublicKey()
34566
35063
  );
34567
35064
  const userRequests = await this.sspClient?.getTransfers(
@@ -34805,7 +35302,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34805
35302
  hash,
34806
35303
  compact
34807
35304
  );
34808
- return (0, import_utils25.bytesToHex)(signature);
35305
+ return (0, import_utils24.bytesToHex)(signature);
34809
35306
  }
34810
35307
  /**
34811
35308
  * Validates a message with the identity key.
@@ -34817,7 +35314,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34817
35314
  async validateMessageWithIdentityKey(message, signature) {
34818
35315
  const hash = (0, import_sha213.sha256)(message);
34819
35316
  if (typeof signature === "string") {
34820
- signature = (0, import_utils25.hexToBytes)(signature);
35317
+ signature = (0, import_utils24.hexToBytes)(signature);
34821
35318
  }
34822
35319
  return this.config.signer.validateMessageWithIdentityKey(hash, signature);
34823
35320
  }
@@ -34830,7 +35327,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34830
35327
  */
34831
35328
  async signTransaction(txHex, keyType = "auto-detect") {
34832
35329
  try {
34833
- const tx = import_btc_signer6.Transaction.fromRaw((0, import_utils25.hexToBytes)(txHex));
35330
+ const tx = import_btc_signer6.Transaction.fromRaw((0, import_utils24.hexToBytes)(txHex));
34834
35331
  let publicKey;
34835
35332
  switch (keyType.toLowerCase()) {
34836
35333
  case "identity":
@@ -34863,7 +35360,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34863
35360
  publicKey,
34864
35361
  this.config.getNetwork()
34865
35362
  );
34866
- if ((0, import_utils25.bytesToHex)(script) === (0, import_utils25.bytesToHex)(identityScript)) {
35363
+ if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(identityScript)) {
34867
35364
  try {
34868
35365
  this.config.signer.signTransactionIndex(tx, i, publicKey);
34869
35366
  inputsSigned++;
@@ -34907,13 +35404,13 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34907
35404
  depositPubKey,
34908
35405
  this.config.getNetwork()
34909
35406
  );
34910
- if ((0, import_utils25.bytesToHex)(script) === (0, import_utils25.bytesToHex)(identityScript)) {
35407
+ if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(identityScript)) {
34911
35408
  return {
34912
35409
  publicKey: identityPubKey,
34913
35410
  keyType: "identity"
34914
35411
  };
34915
35412
  }
34916
- if ((0, import_utils25.bytesToHex)(script) === (0, import_utils25.bytesToHex)(depositScript)) {
35413
+ if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(depositScript)) {
34917
35414
  return {
34918
35415
  publicKey: depositPubKey,
34919
35416
  keyType: "deposit"