@buildonspark/spark-sdk 0.2.11 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/bare/index.cjs +761 -243
  3. package/dist/bare/index.d.cts +70 -11
  4. package/dist/bare/index.d.ts +70 -11
  5. package/dist/bare/index.js +684 -170
  6. package/dist/{chunk-A5M55UR3.js → chunk-5VWGOHED.js} +499 -8
  7. package/dist/{chunk-3WBPICWC.js → chunk-CKHJFQUA.js} +1 -1
  8. package/dist/{chunk-QNYJGFPD.js → chunk-LX45BCZW.js} +207 -160
  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 +761 -243
  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 +783 -265
  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 +783 -265
  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-BOAzMqpM.d.cts → logging-BfTyKwqb.d.cts} +3 -3
  28. package/dist/{logging-Bt_WdZbu.d.ts → logging-CaNpBgiE.d.ts} +3 -3
  29. package/dist/native/index.cjs +782 -264
  30. package/dist/native/index.d.cts +70 -11
  31. package/dist/native/index.d.ts +70 -11
  32. package/dist/native/index.js +686 -172
  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-Cp3yv6cK.d.ts → spark-wallet-D0Df_P_x.d.ts} +26 -13
  43. package/dist/{spark-wallet-yc2KhsVY.d.cts → spark-wallet-Dvh1BLP6.d.cts} +26 -13
  44. package/dist/{spark-wallet.node-D0Qw5Wb4.d.cts → spark-wallet.node-B3V8_fgw.d.cts} +1 -1
  45. package/dist/{spark-wallet.node-D4IovOHu.d.ts → spark-wallet.node-bGmy8-T8.d.ts} +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-D1ta-sHH.d.cts} +2 -2
  51. package/dist/{token-transactions-0nmR9mQO.d.ts → token-transactions-DINiKBzd.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 +3 -3
  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 -28
  72. package/src/signer/signer.ts +2 -2
  73. package/src/spark-wallet/proto-descriptors.ts +22 -0
  74. package/src/spark-wallet/proto-hash.ts +743 -0
  75. package/src/spark-wallet/proto-reflection.ts +193 -0
  76. package/src/spark-wallet/spark-wallet.ts +95 -57
  77. package/src/spark_descriptors.pb +0 -0
  78. package/src/tests/address.test.ts +10 -10
  79. package/src/tests/bitcoin.test.ts +2 -2
  80. package/src/tests/bufbuild-reflection.test.ts +151 -0
  81. package/src/tests/cross-language-hash.test.ts +79 -0
  82. package/src/tests/integration/address.test.ts +3 -12
  83. package/src/tests/integration/coop-exit.test.ts +1 -1
  84. package/src/tests/integration/lightning.test.ts +1 -1
  85. package/src/tests/integration/ssp/static_deposit.test.ts +128 -1
  86. package/src/tests/integration/static_deposit.test.ts +26 -0
  87. package/src/tests/integration/swap.test.ts +1 -1
  88. package/src/tests/integration/transfer.test.ts +1 -129
  89. package/src/tests/integration/wallet.test.ts +7 -7
  90. package/src/tests/integration/watchtower.test.ts +1 -1
  91. package/src/tests/token-hashing.test.ts +3 -6
  92. package/src/tests/token-outputs.test.ts +3 -3
  93. package/src/tests/utils/test-faucet.ts +2 -2
  94. package/src/types/sdk-types.ts +1 -1
  95. package/src/utils/adaptor-signature.ts +1 -1
  96. package/src/utils/address.ts +1 -1
  97. package/src/utils/bitcoin.ts +1 -5
  98. package/src/utils/keys.ts +1 -1
  99. package/src/utils/secret-sharing.ts +1 -1
  100. package/src/utils/token-transactions.ts +1 -2
  101. package/src/utils/transfer_package.ts +1 -1
  102. 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.13" : "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)
@@ -26309,24 +26775,6 @@ var TransferService = class extends BaseTransferService {
26309
26775
  throw new Error(`Error finalizing node signatures in transfer: ${error}`);
26310
26776
  }
26311
26777
  }
26312
- async cancelTransfer(transfer, operatorAddress) {
26313
- const sparkClient = await this.connectionManager.createSparkClient(operatorAddress);
26314
- try {
26315
- const response = await sparkClient.cancel_transfer({
26316
- transferId: transfer.id,
26317
- senderIdentityPublicKey: await this.config.signer.getIdentityPublicKey()
26318
- });
26319
- return response.transfer;
26320
- } catch (error) {
26321
- throw new NetworkError(
26322
- "Failed to cancel transfer",
26323
- {
26324
- method: "POST"
26325
- },
26326
- error
26327
- );
26328
- }
26329
- }
26330
26778
  async queryPendingTransfersBySender(operatorAddress) {
26331
26779
  const sparkClient = await this.connectionManager.createSparkClient(operatorAddress);
26332
26780
  try {
@@ -26416,13 +26864,13 @@ var TransferService = class extends BaseTransferService {
26416
26864
  });
26417
26865
  }
26418
26866
  const newCpfpRefundOutPoint = {
26419
- txid: (0, import_utils16.hexToBytes)(getTxId(cpfpNodeTx)),
26867
+ txid: (0, import_utils15.hexToBytes)(getTxId(cpfpNodeTx)),
26420
26868
  index: 0
26421
26869
  };
26422
26870
  let newDirectRefundOutPoint;
26423
26871
  if (newDirectNodeTx) {
26424
26872
  newDirectRefundOutPoint = {
26425
- txid: (0, import_utils16.hexToBytes)(getTxId(newDirectNodeTx)),
26873
+ txid: (0, import_utils15.hexToBytes)(getTxId(newDirectNodeTx)),
26426
26874
  index: 0
26427
26875
  };
26428
26876
  }
@@ -26550,7 +26998,7 @@ var TransferService = class extends BaseTransferService {
26550
26998
  const refundTx = getTxFromRawTxBytes(node.refundTx);
26551
26999
  const refundSequence = refundTx.getInput(0).sequence || 0;
26552
27000
  const newNodeOutPoint = {
26553
- txid: (0, import_utils16.hexToBytes)(getTxId(nodeTx)),
27001
+ txid: (0, import_utils15.hexToBytes)(getTxId(nodeTx)),
26554
27002
  index: 0
26555
27003
  };
26556
27004
  const {
@@ -26587,13 +27035,13 @@ var TransferService = class extends BaseTransferService {
26587
27035
  });
26588
27036
  }
26589
27037
  const newCpfpRefundOutPoint = {
26590
- txid: (0, import_utils16.hexToBytes)(getTxId(newNodeTx)),
27038
+ txid: (0, import_utils15.hexToBytes)(getTxId(newNodeTx)),
26591
27039
  index: 0
26592
27040
  };
26593
27041
  let newDirectRefundOutPoint;
26594
27042
  if (newDirectNodeTx) {
26595
27043
  newDirectRefundOutPoint = {
26596
- txid: (0, import_utils16.hexToBytes)(getTxId(newDirectNodeTx)),
27044
+ txid: (0, import_utils15.hexToBytes)(getTxId(newDirectNodeTx)),
26597
27045
  index: 0
26598
27046
  };
26599
27047
  }
@@ -26827,13 +27275,13 @@ var TransferService = class extends BaseTransferService {
26827
27275
  };
26828
27276
  const signingPublicKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
26829
27277
  const cpfpRefundOutPoint = {
26830
- txid: (0, import_utils16.hexToBytes)(getTxId(nodeTx)),
27278
+ txid: (0, import_utils15.hexToBytes)(getTxId(nodeTx)),
26831
27279
  index: 0
26832
27280
  };
26833
27281
  let directRefundOutPoint;
26834
27282
  if (directNodeTx) {
26835
27283
  directRefundOutPoint = {
26836
- txid: (0, import_utils16.hexToBytes)(getTxId(directNodeTx)),
27284
+ txid: (0, import_utils15.hexToBytes)(getTxId(directNodeTx)),
26837
27285
  index: 0
26838
27286
  };
26839
27287
  }
@@ -27209,9 +27657,9 @@ var CoopExitService = class extends BaseTransferService {
27209
27657
  init_buffer();
27210
27658
  var import_secp256k110 = require("@noble/curves/secp256k1");
27211
27659
  var import_sha210 = require("@noble/hashes/sha2");
27212
- var import_utils17 = require("@noble/hashes/utils");
27660
+ var import_utils16 = require("@noble/hashes/utils");
27213
27661
  var import_btc_signer4 = require("@scure/btc-signer");
27214
- var import_utils18 = require("@scure/btc-signer/utils");
27662
+ var import_utils17 = require("@scure/btc-signer/utils");
27215
27663
  var DepositService = class {
27216
27664
  config;
27217
27665
  connectionManager;
@@ -27221,7 +27669,8 @@ var DepositService = class {
27221
27669
  }
27222
27670
  async validateDepositAddress({
27223
27671
  address: address2,
27224
- userPubkey
27672
+ userPubkey,
27673
+ verifyCoordinatorProof = false
27225
27674
  }) {
27226
27675
  if (!address2.depositAddressProof || !address2.depositAddressProof.proofOfPossessionSignature || !address2.depositAddressProof.addressSignatures) {
27227
27676
  throw new ValidationError(
@@ -27259,10 +27708,10 @@ var DepositService = class {
27259
27708
  }
27260
27709
  const addrHash = (0, import_sha210.sha256)(address2.address);
27261
27710
  for (const operator of Object.values(this.config.getSigningOperators())) {
27262
- if (operator.identifier === this.config.getCoordinatorIdentifier()) {
27711
+ if (operator.identifier === this.config.getCoordinatorIdentifier() && !verifyCoordinatorProof) {
27263
27712
  continue;
27264
27713
  }
27265
- const operatorPubkey2 = (0, import_utils17.hexToBytes)(operator.identityPublicKey);
27714
+ const operatorPubkey2 = (0, import_utils16.hexToBytes)(operator.identityPublicKey);
27266
27715
  const operatorSig = address2.depositAddressProof.addressSignatures[operator.identifier];
27267
27716
  if (!operatorSig) {
27268
27717
  throw new ValidationError("Operator signature not found", {
@@ -27284,6 +27733,46 @@ var DepositService = class {
27284
27733
  }
27285
27734
  }
27286
27735
  }
27736
+ async generateStaticDepositAddress({
27737
+ signingPubkey
27738
+ }) {
27739
+ const sparkClient = await this.connectionManager.createSparkClient(
27740
+ this.config.getCoordinatorAddress()
27741
+ );
27742
+ let depositResp;
27743
+ try {
27744
+ depositResp = await sparkClient.generate_static_deposit_address({
27745
+ signingPublicKey: signingPubkey,
27746
+ identityPublicKey: await this.config.signer.getIdentityPublicKey(),
27747
+ network: this.config.getNetworkProto()
27748
+ });
27749
+ } catch (error) {
27750
+ throw new NetworkError(
27751
+ "Failed to generate static deposit address",
27752
+ {
27753
+ operation: "generate_static_deposit_address",
27754
+ errorCount: 1,
27755
+ errors: error instanceof Error ? error.message : String(error)
27756
+ },
27757
+ error
27758
+ );
27759
+ }
27760
+ if (!depositResp.depositAddress) {
27761
+ throw new ValidationError(
27762
+ "No static deposit address response from coordinator",
27763
+ {
27764
+ field: "depositAddress",
27765
+ value: depositResp
27766
+ }
27767
+ );
27768
+ }
27769
+ await this.validateDepositAddress({
27770
+ address: depositResp.depositAddress,
27771
+ userPubkey: signingPubkey,
27772
+ verifyCoordinatorProof: true
27773
+ });
27774
+ return depositResp;
27775
+ }
27287
27776
  async generateDepositAddress({
27288
27777
  signingPubkey,
27289
27778
  leafId,
@@ -27351,7 +27840,7 @@ var DepositService = class {
27351
27840
  });
27352
27841
  }
27353
27842
  const depositOutPoint = {
27354
- txid: (0, import_utils17.hexToBytes)(getTxId(depositTx)),
27843
+ txid: (0, import_utils16.hexToBytes)(getTxId(depositTx)),
27355
27844
  index: vout
27356
27845
  };
27357
27846
  const depositTxOut = {
@@ -27370,8 +27859,8 @@ var DepositService = class {
27370
27859
  const { cpfpRefundTx, directRefundTx, directFromCpfpRefundTx } = createRefundTxs({
27371
27860
  sequence: INITIAL_SEQUENCE,
27372
27861
  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 },
27862
+ input: { txid: (0, import_utils16.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
27863
+ directInput: { txid: (0, import_utils16.hexToBytes)(getTxId(directRootTx)), index: 0 },
27375
27864
  amountSats: amount,
27376
27865
  receivingPubkey: signingPubKey,
27377
27866
  network: this.config.getNetwork()
@@ -27501,7 +27990,7 @@ var DepositService = class {
27501
27990
  }
27502
27991
  );
27503
27992
  }
27504
- if (!(0, import_utils18.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
27993
+ if (!(0, import_utils17.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
27505
27994
  throw new ValidationError("Verifying key mismatch", {
27506
27995
  field: "verifyingKey",
27507
27996
  value: treeResp.rootNodeSignatureShares.verifyingKey,
@@ -27665,7 +28154,7 @@ var DepositService = class {
27665
28154
  });
27666
28155
  }
27667
28156
  const depositOutPoint = {
27668
- txid: (0, import_utils17.hexToBytes)(getTxId(depositTx)),
28157
+ txid: (0, import_utils16.hexToBytes)(getTxId(depositTx)),
27669
28158
  index: vout
27670
28159
  };
27671
28160
  const depositTxOut = {
@@ -27678,7 +28167,7 @@ var DepositService = class {
27678
28167
  const signingPubKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
27679
28168
  const { cpfpRefundTx } = createRefundTxs({
27680
28169
  sequence: INITIAL_SEQUENCE,
27681
- input: { txid: (0, import_utils17.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
28170
+ input: { txid: (0, import_utils16.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
27682
28171
  amountSats: amount,
27683
28172
  receivingPubkey: signingPubKey,
27684
28173
  network: this.config.getNetwork()
@@ -27748,7 +28237,7 @@ var DepositService = class {
27748
28237
  }
27749
28238
  );
27750
28239
  }
27751
- if (!(0, import_utils18.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
28240
+ if (!(0, import_utils17.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
27752
28241
  throw new ValidationError("Verifying key mismatch", {
27753
28242
  field: "verifyingKey",
27754
28243
  value: treeResp.rootNodeSignatureShares.verifyingKey,
@@ -27824,8 +28313,8 @@ var DepositService = class {
27824
28313
 
27825
28314
  // src/services/lightning.ts
27826
28315
  init_buffer();
27827
- var import_utils19 = require("@noble/curves/abstract/utils");
27828
28316
  var import_secp256k111 = require("@noble/curves/secp256k1");
28317
+ var import_utils18 = require("@noble/curves/utils");
27829
28318
  var import_sha211 = require("@noble/hashes/sha2");
27830
28319
  var import_uuidv74 = require("uuidv7");
27831
28320
 
@@ -27911,8 +28400,8 @@ var LightningService = class {
27911
28400
  }) {
27912
28401
  const crypto = getCrypto();
27913
28402
  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,
28403
+ const preimage = (0, import_utils18.numberToBytesBE)(
28404
+ (0, import_utils18.bytesToNumberBE)(randBytes) % import_secp256k111.secp256k1.CURVE.n,
27916
28405
  32
27917
28406
  );
27918
28407
  return await this.createLightningInvoiceWithPreImage({
@@ -27967,12 +28456,12 @@ var LightningService = class {
27967
28456
  const sparkClient = await this.connectionManager.createSparkClient(
27968
28457
  operator.address
27969
28458
  );
27970
- const userIdentityPublicKey = receiverIdentityPubkey ? (0, import_utils19.hexToBytes)(receiverIdentityPubkey) : await this.config.signer.getIdentityPublicKey();
28459
+ const userIdentityPublicKey = receiverIdentityPubkey ? (0, import_utils18.hexToBytes)(receiverIdentityPubkey) : await this.config.signer.getIdentityPublicKey();
27971
28460
  try {
27972
28461
  await sparkClient.store_preimage_share({
27973
28462
  paymentHash,
27974
28463
  preimageShare: {
27975
- secretShare: (0, import_utils19.numberToBytesBE)(share.share, 32),
28464
+ secretShare: (0, import_utils18.numberToBytesBE)(share.share, 32),
27976
28465
  proofs: share.proofs
27977
28466
  },
27978
28467
  threshold: this.config.getThreshold(),
@@ -28173,9 +28662,9 @@ var LightningService = class {
28173
28662
 
28174
28663
  // src/services/token-transactions.ts
28175
28664
  init_buffer();
28176
- var import_utils20 = require("@noble/curves/abstract/utils");
28177
28665
  var import_secp256k113 = require("@noble/curves/secp256k1");
28178
- var import_utils21 = require("@noble/hashes/utils");
28666
+ var import_utils19 = require("@noble/curves/utils");
28667
+ var import_utils20 = require("@noble/hashes/utils");
28179
28668
 
28180
28669
  // src/utils/token-hashing.ts
28181
28670
  init_buffer();
@@ -30109,14 +30598,14 @@ var TokenTransactionService = class {
30109
30598
  }
30110
30599
  if (this.config.getTokenTransactionVersion() !== "V0" && receiverAddress.sparkInvoiceFields) {
30111
30600
  return {
30112
- receiverPublicKey: (0, import_utils21.hexToBytes)(receiverAddress.identityPublicKey),
30601
+ receiverPublicKey: (0, import_utils20.hexToBytes)(receiverAddress.identityPublicKey),
30113
30602
  rawTokenIdentifier,
30114
30603
  tokenAmount: transfer.tokenAmount,
30115
30604
  sparkInvoice: transfer.receiverSparkAddress
30116
30605
  };
30117
30606
  }
30118
30607
  return {
30119
- receiverPublicKey: (0, import_utils21.hexToBytes)(receiverAddress.identityPublicKey),
30608
+ receiverPublicKey: (0, import_utils20.hexToBytes)(receiverAddress.identityPublicKey),
30120
30609
  rawTokenIdentifier,
30121
30610
  tokenPublicKey,
30122
30611
  // Remove for full v0 deprecation
@@ -30155,7 +30644,7 @@ var TokenTransactionService = class {
30155
30644
  const tokenOutputs = tokenOutputData.map((output) => ({
30156
30645
  ownerPublicKey: output.receiverPublicKey,
30157
30646
  tokenPublicKey: output.tokenPublicKey,
30158
- tokenAmount: (0, import_utils20.numberToBytesBE)(output.tokenAmount, 16)
30647
+ tokenAmount: (0, import_utils19.numberToBytesBE)(output.tokenAmount, 16)
30159
30648
  }));
30160
30649
  if (availableTokenAmount > totalRequestedAmount) {
30161
30650
  const changeAmount = availableTokenAmount - totalRequestedAmount;
@@ -30163,7 +30652,7 @@ var TokenTransactionService = class {
30163
30652
  tokenOutputs.push({
30164
30653
  ownerPublicKey: await this.config.signer.getIdentityPublicKey(),
30165
30654
  tokenPublicKey: firstTokenPublicKey,
30166
- tokenAmount: (0, import_utils20.numberToBytesBE)(changeAmount, 16)
30655
+ tokenAmount: (0, import_utils19.numberToBytesBE)(changeAmount, 16)
30167
30656
  });
30168
30657
  }
30169
30658
  return {
@@ -30194,7 +30683,7 @@ var TokenTransactionService = class {
30194
30683
  (output) => ({
30195
30684
  ownerPublicKey: output.receiverPublicKey,
30196
30685
  tokenIdentifier: output.rawTokenIdentifier,
30197
- tokenAmount: (0, import_utils20.numberToBytesBE)(output.tokenAmount, 16)
30686
+ tokenAmount: (0, import_utils19.numberToBytesBE)(output.tokenAmount, 16)
30198
30687
  })
30199
30688
  );
30200
30689
  if (availableTokenAmount > totalRequestedAmount) {
@@ -30203,7 +30692,7 @@ var TokenTransactionService = class {
30203
30692
  tokenOutputs.push({
30204
30693
  ownerPublicKey: await this.config.signer.getIdentityPublicKey(),
30205
30694
  tokenIdentifier: firstTokenIdentifierBytes,
30206
- tokenAmount: (0, import_utils20.numberToBytesBE)(changeAmount, 16)
30695
+ tokenAmount: (0, import_utils19.numberToBytesBE)(changeAmount, 16)
30207
30696
  });
30208
30697
  }
30209
30698
  return {
@@ -30230,7 +30719,7 @@ var TokenTransactionService = class {
30230
30719
  for (const [_, operator] of Object.entries(
30231
30720
  this.config.getSigningOperators()
30232
30721
  )) {
30233
- operatorKeys.push((0, import_utils21.hexToBytes)(operator.identityPublicKey));
30722
+ operatorKeys.push((0, import_utils20.hexToBytes)(operator.identityPublicKey));
30234
30723
  }
30235
30724
  return operatorKeys;
30236
30725
  }
@@ -30314,7 +30803,7 @@ var TokenTransactionService = class {
30314
30803
  {
30315
30804
  field: "revocationCommitment",
30316
30805
  value: derivedRevocationCommitment,
30317
- expected: (0, import_utils20.bytesToHex)(outputsToSpendCommitments[outputIndex]),
30806
+ expected: (0, import_utils19.bytesToHex)(outputsToSpendCommitments[outputIndex]),
30318
30807
  outputIndex
30319
30808
  }
30320
30809
  )
@@ -30340,7 +30829,7 @@ var TokenTransactionService = class {
30340
30829
  threshold
30341
30830
  );
30342
30831
  }
30343
- return (0, import_utils20.bytesToHex)(finalTokenTransactionHash);
30832
+ return (0, import_utils19.bytesToHex)(finalTokenTransactionHash);
30344
30833
  }
30345
30834
  async broadcastTokenTransactionV1(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
30346
30835
  const { finalTokenTransaction, finalTokenTransactionHash, threshold } = await this.startTokenTransaction(
@@ -30354,7 +30843,7 @@ var TokenTransactionService = class {
30354
30843
  finalTokenTransactionHash,
30355
30844
  signingOperators
30356
30845
  );
30357
- return (0, import_utils20.bytesToHex)(finalTokenTransactionHash);
30846
+ return (0, import_utils19.bytesToHex)(finalTokenTransactionHash);
30358
30847
  }
30359
30848
  async startTokenTransactionV0(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
30360
30849
  const sparkClient = await this.connectionManager.createSparkClient(
@@ -30578,7 +31067,7 @@ var TokenTransactionService = class {
30578
31067
  const identityPublicKey = await this.config.signer.getIdentityPublicKey();
30579
31068
  const payload = {
30580
31069
  finalTokenTransactionHash,
30581
- operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
31070
+ operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
30582
31071
  };
30583
31072
  const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
30584
31073
  let operatorSpecificSignatures = [];
@@ -30793,8 +31282,8 @@ var TokenTransactionService = class {
30793
31282
  this.config.getCoordinatorAddress()
30794
31283
  );
30795
31284
  let queryParams = {
30796
- tokenPublicKeys: issuerPublicKeys?.map(import_utils21.hexToBytes),
30797
- ownerPublicKeys: ownerPublicKeys?.map(import_utils21.hexToBytes),
31285
+ tokenPublicKeys: issuerPublicKeys?.map(import_utils20.hexToBytes),
31286
+ ownerPublicKeys: ownerPublicKeys?.map(import_utils20.hexToBytes),
30798
31287
  tokenIdentifiers: tokenIdentifiers?.map((identifier) => {
30799
31288
  const { tokenIdentifier } = decodeBech32mTokenIdentifier(
30800
31289
  identifier,
@@ -30802,7 +31291,7 @@ var TokenTransactionService = class {
30802
31291
  );
30803
31292
  return tokenIdentifier;
30804
31293
  }),
30805
- tokenTransactionHashes: tokenTransactionHashes?.map(import_utils21.hexToBytes),
31294
+ tokenTransactionHashes: tokenTransactionHashes?.map(import_utils20.hexToBytes),
30806
31295
  outputIds: outputIds || [],
30807
31296
  limit: pageSize,
30808
31297
  offset
@@ -30861,8 +31350,8 @@ var TokenTransactionService = class {
30861
31350
  this.config.getCoordinatorAddress()
30862
31351
  );
30863
31352
  let queryParams = {
30864
- issuerPublicKeys: issuerPublicKeys?.map(import_utils21.hexToBytes),
30865
- ownerPublicKeys: ownerPublicKeys?.map(import_utils21.hexToBytes),
31353
+ issuerPublicKeys: issuerPublicKeys?.map(import_utils20.hexToBytes),
31354
+ ownerPublicKeys: ownerPublicKeys?.map(import_utils20.hexToBytes),
30866
31355
  tokenIdentifiers: tokenIdentifiers?.map((identifier) => {
30867
31356
  const { tokenIdentifier } = decodeBech32mTokenIdentifier(
30868
31357
  identifier,
@@ -30870,7 +31359,7 @@ var TokenTransactionService = class {
30870
31359
  );
30871
31360
  return tokenIdentifier;
30872
31361
  }),
30873
- tokenTransactionHashes: tokenTransactionHashes?.map(import_utils21.hexToBytes),
31362
+ tokenTransactionHashes: tokenTransactionHashes?.map(import_utils20.hexToBytes),
30874
31363
  outputIds: outputIds || [],
30875
31364
  limit: pageSize,
30876
31365
  offset
@@ -30905,7 +31394,7 @@ var TokenTransactionService = class {
30905
31394
  });
30906
31395
  }
30907
31396
  const exactMatch = tokenOutputs.find(
30908
- (item) => (0, import_utils20.bytesToNumberBE)(item.output.tokenAmount) === tokenAmount
31397
+ (item) => (0, import_utils19.bytesToNumberBE)(item.output.tokenAmount) === tokenAmount
30909
31398
  );
30910
31399
  if (exactMatch) {
30911
31400
  return [exactMatch];
@@ -30916,7 +31405,7 @@ var TokenTransactionService = class {
30916
31405
  for (const outputWithPreviousTransactionData of tokenOutputs) {
30917
31406
  if (remainingAmount <= 0n) break;
30918
31407
  selectedOutputs.push(outputWithPreviousTransactionData);
30919
- remainingAmount -= (0, import_utils20.bytesToNumberBE)(
31408
+ remainingAmount -= (0, import_utils19.bytesToNumberBE)(
30920
31409
  outputWithPreviousTransactionData.output.tokenAmount
30921
31410
  );
30922
31411
  }
@@ -30932,13 +31421,13 @@ var TokenTransactionService = class {
30932
31421
  if (strategy === "SMALL_FIRST") {
30933
31422
  tokenOutputs.sort((a, b) => {
30934
31423
  return Number(
30935
- (0, import_utils20.bytesToNumberBE)(a.output.tokenAmount) - (0, import_utils20.bytesToNumberBE)(b.output.tokenAmount)
31424
+ (0, import_utils19.bytesToNumberBE)(a.output.tokenAmount) - (0, import_utils19.bytesToNumberBE)(b.output.tokenAmount)
30936
31425
  );
30937
31426
  });
30938
31427
  } else {
30939
31428
  tokenOutputs.sort((a, b) => {
30940
31429
  return Number(
30941
- (0, import_utils20.bytesToNumberBE)(b.output.tokenAmount) - (0, import_utils20.bytesToNumberBE)(a.output.tokenAmount)
31430
+ (0, import_utils19.bytesToNumberBE)(b.output.tokenAmount) - (0, import_utils19.bytesToNumberBE)(a.output.tokenAmount)
30942
31431
  );
30943
31432
  });
30944
31433
  }
@@ -30946,7 +31435,7 @@ var TokenTransactionService = class {
30946
31435
  // Helper function for deciding if the signer public key is the identity public key
30947
31436
  async signMessageWithKey(message, publicKey) {
30948
31437
  const tokenSignatures = this.config.getTokenSignatures();
30949
- if ((0, import_utils20.bytesToHex)(publicKey) === (0, import_utils20.bytesToHex)(await this.config.signer.getIdentityPublicKey())) {
31438
+ if ((0, import_utils19.bytesToHex)(publicKey) === (0, import_utils19.bytesToHex)(await this.config.signer.getIdentityPublicKey())) {
30950
31439
  if (tokenSignatures === "SCHNORR") {
30951
31440
  return await this.config.signer.signSchnorrWithIdentityKey(message);
30952
31441
  } else {
@@ -30955,8 +31444,8 @@ var TokenTransactionService = class {
30955
31444
  } else {
30956
31445
  throw new ValidationError("Invalid public key", {
30957
31446
  field: "publicKey",
30958
- value: (0, import_utils20.bytesToHex)(publicKey),
30959
- expected: (0, import_utils20.bytesToHex)(await this.config.signer.getIdentityPublicKey())
31447
+ value: (0, import_utils19.bytesToHex)(publicKey),
31448
+ expected: (0, import_utils19.bytesToHex)(await this.config.signer.getIdentityPublicKey())
30960
31449
  });
30961
31450
  }
30962
31451
  }
@@ -31019,7 +31508,7 @@ var TokenTransactionService = class {
31019
31508
  }
31020
31509
  const payload = {
31021
31510
  finalTokenTransactionHash,
31022
- operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
31511
+ operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
31023
31512
  };
31024
31513
  const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
31025
31514
  const ownerSignature = await this.signMessageWithKey(
@@ -31041,7 +31530,7 @@ var TokenTransactionService = class {
31041
31530
  }
31042
31531
  const payload = {
31043
31532
  finalTokenTransactionHash,
31044
- operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
31533
+ operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
31045
31534
  };
31046
31535
  const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
31047
31536
  const ownerSignature = await this.signMessageWithKey(
@@ -31057,7 +31546,7 @@ var TokenTransactionService = class {
31057
31546
  for (let i = 0; i < transferInput.outputsToSpend.length; i++) {
31058
31547
  const payload = {
31059
31548
  finalTokenTransactionHash,
31060
- operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
31549
+ operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
31061
31550
  };
31062
31551
  const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
31063
31552
  let ownerSignature;
@@ -31074,7 +31563,7 @@ var TokenTransactionService = class {
31074
31563
  }
31075
31564
  inputTtxoSignaturesPerOperator.push({
31076
31565
  ttxoSignatures,
31077
- operatorIdentityPublicKey: (0, import_utils21.hexToBytes)(operator.identityPublicKey)
31566
+ operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
31078
31567
  });
31079
31568
  }
31080
31569
  return inputTtxoSignaturesPerOperator;
@@ -31093,7 +31582,7 @@ var import_nice_grpc_common3 = require("nice-grpc-common");
31093
31582
 
31094
31583
  // src/services/signing.ts
31095
31584
  init_buffer();
31096
- var import_utils22 = require("@noble/curves/abstract/utils");
31585
+ var import_utils21 = require("@noble/curves/utils");
31097
31586
  var SigningService = class {
31098
31587
  config;
31099
31588
  constructor(config) {
@@ -31149,7 +31638,7 @@ var SigningService = class {
31149
31638
  }
31150
31639
  const nodeTx = getTxFromRawTxBytes(leaf.leaf.nodeTx);
31151
31640
  const cpfpNodeOutPoint = {
31152
- txid: (0, import_utils22.hexToBytes)(getTxId(nodeTx)),
31641
+ txid: (0, import_utils21.hexToBytes)(getTxId(nodeTx)),
31153
31642
  index: 0
31154
31643
  };
31155
31644
  const currRefundTx = getTxFromRawTxBytes(leaf.leaf.refundTx);
@@ -31175,7 +31664,7 @@ var SigningService = class {
31175
31664
  if (leaf.leaf.directTx.length > 0) {
31176
31665
  directNodeTx = getTxFromRawTxBytes(leaf.leaf.directTx);
31177
31666
  directNodeOutPoint = {
31178
- txid: (0, import_utils22.hexToBytes)(getTxId(directNodeTx)),
31667
+ txid: (0, import_utils21.hexToBytes)(getTxId(directNodeTx)),
31179
31668
  index: 0
31180
31669
  };
31181
31670
  }
@@ -31259,15 +31748,15 @@ var SigningService = class {
31259
31748
 
31260
31749
  // src/tests/utils/test-faucet.ts
31261
31750
  init_buffer();
31262
- var import_utils23 = require("@noble/curves/abstract/utils");
31263
31751
  var import_secp256k114 = require("@noble/curves/secp256k1");
31752
+ var import_utils22 = require("@noble/curves/utils");
31264
31753
  var btc5 = __toESM(require("@scure/btc-signer"), 1);
31265
31754
  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)(
31755
+ var import_utils23 = require("@scure/btc-signer/utils");
31756
+ var STATIC_FAUCET_KEY = (0, import_utils22.hexToBytes)(
31268
31757
  "deadbeef1337cafe4242424242424242deadbeef1337cafe4242424242424242"
31269
31758
  );
31270
- var STATIC_MINING_KEY = (0, import_utils23.hexToBytes)(
31759
+ var STATIC_MINING_KEY = (0, import_utils22.hexToBytes)(
31271
31760
  "1337cafe4242deadbeef4242424242421337cafe4242deadbeef424242424242"
31272
31761
  );
31273
31762
  var SATS_PER_BTC = 1e8;
@@ -31330,7 +31819,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
31330
31819
  if (!scanResult.success || scanResult.unspents.length === 0) {
31331
31820
  const blockHash = await this.generateToAddress(1, address2);
31332
31821
  const block = await this.getBlock(blockHash[0]);
31333
- const fundingTx = import_btc_signer5.Transaction.fromRaw((0, import_utils23.hexToBytes)(block.tx[0].hex), {
31822
+ const fundingTx = import_btc_signer5.Transaction.fromRaw((0, import_utils22.hexToBytes)(block.tx[0].hex), {
31334
31823
  allowUnknownOutputs: true
31335
31824
  });
31336
31825
  await this.generateToAddress(100, this.miningAddress);
@@ -31392,13 +31881,13 @@ var BitcoinFaucet = class _BitcoinFaucet {
31392
31881
  },
31393
31882
  STATIC_MINING_KEY
31394
31883
  );
31395
- await this.broadcastTx((0, import_utils23.bytesToHex)(signedSplitTx.extract()));
31884
+ await this.broadcastTx((0, import_utils22.bytesToHex)(signedSplitTx.extract()));
31396
31885
  const splitTxId = signedSplitTx.id;
31397
31886
  for (let i = 0; i < numCoinsToCreate; i++) {
31398
31887
  this.coins.push({
31399
31888
  key: STATIC_FAUCET_KEY,
31400
31889
  outpoint: {
31401
- txid: (0, import_utils23.hexToBytes)(splitTxId),
31890
+ txid: (0, import_utils22.hexToBytes)(splitTxId),
31402
31891
  index: i
31403
31892
  },
31404
31893
  txout: signedSplitTx.getOutput(i)
@@ -31426,7 +31915,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
31426
31915
  coinToSend.txout,
31427
31916
  coinToSend.key
31428
31917
  );
31429
- await this.broadcastTx((0, import_utils23.bytesToHex)(signedTx.extract()));
31918
+ await this.broadcastTx((0, import_utils22.bytesToHex)(signedTx.extract()));
31430
31919
  }
31431
31920
  async signFaucetCoin(unsignedTx, fundingTxOut, key) {
31432
31921
  const pubKey = import_secp256k114.secp256k1.getPublicKey(key);
@@ -31446,7 +31935,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
31446
31935
  new Array(unsignedTx.inputsLength).fill(fundingTxOut.amount)
31447
31936
  );
31448
31937
  const merkleRoot = new Uint8Array();
31449
- const tweakedKey = (0, import_utils24.taprootTweakPrivKey)(key, merkleRoot);
31938
+ const tweakedKey = (0, import_utils23.taprootTweakPrivKey)(key, merkleRoot);
31450
31939
  if (!tweakedKey)
31451
31940
  throw new Error("Invalid private key for taproot tweaking");
31452
31941
  const signature = import_secp256k114.schnorr.sign(sighash, tweakedKey);
@@ -31546,7 +32035,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
31546
32035
  });
31547
32036
  }
31548
32037
  const signedTx = await this.signFaucetCoin(tx, coin.txout, coin.key);
31549
- const txHex = (0, import_utils23.bytesToHex)(signedTx.extract());
32038
+ const txHex = (0, import_utils22.bytesToHex)(signedTx.extract());
31550
32039
  await this.broadcastTx(txHex);
31551
32040
  const randomKey = import_secp256k114.secp256k1.utils.randomPrivateKey();
31552
32041
  const randomPubKey = import_secp256k114.secp256k1.getPublicKey(randomKey);
@@ -31737,7 +32226,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
31737
32226
  try {
31738
32227
  if (event?.$case === "transfer" && event.transfer.transfer && event.transfer.transfer.type !== 40 /* COUNTER_SWAP */) {
31739
32228
  const { senderIdentityPublicKey, receiverIdentityPublicKey } = event.transfer.transfer;
31740
- if (event.transfer.transfer && !(0, import_utils25.equalBytes)(senderIdentityPublicKey, receiverIdentityPublicKey)) {
32229
+ if (event.transfer.transfer && !(0, import_utils24.equalBytes)(senderIdentityPublicKey, receiverIdentityPublicKey)) {
31741
32230
  await this.claimTransfer({
31742
32231
  transfer: event.transfer.transfer,
31743
32232
  emit: true,
@@ -31902,10 +32391,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
31902
32391
  leavesToIgnore.add(nodeId);
31903
32392
  continue;
31904
32393
  }
31905
- if (leaf.status !== operatorLeaf.status || !leaf.signingKeyshare || !operatorLeaf.signingKeyshare || !(0, import_utils25.equalBytes)(
32394
+ if (leaf.status !== operatorLeaf.status || !leaf.signingKeyshare || !operatorLeaf.signingKeyshare || !(0, import_utils24.equalBytes)(
31906
32395
  leaf.signingKeyshare.publicKey,
31907
32396
  operatorLeaf.signingKeyshare.publicKey
31908
- ) || !(0, import_utils25.equalBytes)(leaf.nodeTx, operatorLeaf.nodeTx)) {
32397
+ ) || !(0, import_utils24.equalBytes)(leaf.nodeTx, operatorLeaf.nodeTx)) {
31909
32398
  leavesToIgnore.add(nodeId);
31910
32399
  }
31911
32400
  }
@@ -31956,7 +32445,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
31956
32445
  });
31957
32446
  }
31958
32447
  verifyKey(pubkey1, pubkey2, verifyingKey) {
31959
- return (0, import_utils25.equalBytes)(addPublicKeys(pubkey1, pubkey2), verifyingKey);
32448
+ return (0, import_utils24.equalBytes)(addPublicKeys(pubkey1, pubkey2), verifyingKey);
31960
32449
  }
31961
32450
  async selectLeaves(targetAmounts) {
31962
32451
  if (targetAmounts.length === 0) {
@@ -32114,7 +32603,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32114
32603
  * @returns {Promise<string>} The identity public key as a hex string.
32115
32604
  */
32116
32605
  async getIdentityPublicKey() {
32117
- return (0, import_utils25.bytesToHex)(await this.config.signer.getIdentityPublicKey());
32606
+ return (0, import_utils24.bytesToHex)(await this.config.signer.getIdentityPublicKey());
32118
32607
  }
32119
32608
  /**
32120
32609
  * Gets the Spark address of the wallet.
@@ -32124,7 +32613,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32124
32613
  async getSparkAddress() {
32125
32614
  if (!this.sparkAddress) {
32126
32615
  this.sparkAddress = encodeSparkAddress({
32127
- identityPublicKey: (0, import_utils25.bytesToHex)(
32616
+ identityPublicKey: (0, import_utils24.bytesToHex)(
32128
32617
  await this.config.signer.getIdentityPublicKey()
32129
32618
  ),
32130
32619
  network: this.config.getNetworkType()
@@ -32187,7 +32676,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32187
32676
  $case: "tokensPayment",
32188
32677
  tokensPayment: {
32189
32678
  tokenIdentifier: decodedTokenIdentifier ?? void 0,
32190
- amount: amount ? (0, import_utils25.numberToVarBytesBE)(amount) : void 0
32679
+ amount: amount ? (0, import_utils24.numberToVarBytesBE)(amount) : void 0
32191
32680
  }
32192
32681
  };
32193
32682
  const invoiceFields = {
@@ -32195,7 +32684,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32195
32684
  id: (0, import_uuidv75.uuidv7obj)().bytes,
32196
32685
  paymentType: protoPayment,
32197
32686
  memo: memo ?? void 0,
32198
- senderPublicKey: senderPublicKey ? (0, import_utils25.hexToBytes)(senderPublicKey) : void 0,
32687
+ senderPublicKey: senderPublicKey ? (0, import_utils24.hexToBytes)(senderPublicKey) : void 0,
32199
32688
  expiryTime: expiryTime ?? void 0
32200
32689
  };
32201
32690
  validateSparkInvoiceFields(invoiceFields);
@@ -32208,7 +32697,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32208
32697
  const signature = await this.config.signer.signSchnorrWithIdentityKey(hash);
32209
32698
  return encodeSparkAddressWithSignature(
32210
32699
  {
32211
- identityPublicKey: (0, import_utils25.bytesToHex)(identityPublicKey),
32700
+ identityPublicKey: (0, import_utils24.bytesToHex)(identityPublicKey),
32212
32701
  network: this.config.getNetworkType(),
32213
32702
  sparkInvoiceFields: invoiceFields
32214
32703
  },
@@ -32254,7 +32743,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32254
32743
  mnemonic = mnemonicOrSeed;
32255
32744
  seed = await this.config.signer.mnemonicToSeed(mnemonicOrSeed);
32256
32745
  } else {
32257
- seed = (0, import_utils25.hexToBytes)(mnemonicOrSeed);
32746
+ seed = (0, import_utils24.hexToBytes)(mnemonicOrSeed);
32258
32747
  }
32259
32748
  }
32260
32749
  await this.initWalletFromSeed(seed, accountNumber);
@@ -32276,7 +32765,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32276
32765
  });
32277
32766
  }
32278
32767
  this.sparkAddress = encodeSparkAddress({
32279
- identityPublicKey: (0, import_utils25.bytesToHex)(identityPublicKey),
32768
+ identityPublicKey: (0, import_utils24.bytesToHex)(identityPublicKey),
32280
32769
  network: this.config.getNetworkType()
32281
32770
  });
32282
32771
  return this.sparkAddress;
@@ -32396,7 +32885,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32396
32885
  directFromCpfpSignatureMap
32397
32886
  } = await this.transferService.startSwapSignRefund(
32398
32887
  leafKeyTweaks,
32399
- (0, import_utils25.hexToBytes)(this.config.getSspIdentityPublicKey()),
32888
+ (0, import_utils24.hexToBytes)(this.config.getSspIdentityPublicKey()),
32400
32889
  new Date(Date.now() + 2 * 60 * 1e3)
32401
32890
  );
32402
32891
  try {
@@ -32456,18 +32945,18 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32456
32945
  const userLeaves = [];
32457
32946
  userLeaves.push({
32458
32947
  leaf_id: transfer.leaves[0].leaf.id,
32459
- raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
32948
+ raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32460
32949
  transfer.leaves[0].intermediateRefundTx
32461
32950
  ),
32462
- direct_raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
32951
+ direct_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32463
32952
  transfer.leaves[0].intermediateDirectRefundTx
32464
32953
  ),
32465
- direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
32954
+ direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32466
32955
  transfer.leaves[0].intermediateDirectFromCpfpRefundTx
32467
32956
  ),
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)(
32957
+ adaptor_added_signature: (0, import_utils24.bytesToHex)(cpfpAdaptorSignature),
32958
+ direct_adaptor_added_signature: (0, import_utils24.bytesToHex)(directAdaptorSignature),
32959
+ direct_from_cpfp_adaptor_added_signature: (0, import_utils24.bytesToHex)(
32471
32960
  directFromCpfpAdaptorSignature
32472
32961
  )
32473
32962
  });
@@ -32520,24 +33009,24 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32520
33009
  }
32521
33010
  userLeaves.push({
32522
33011
  leaf_id: leaf.leaf.id,
32523
- raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
33012
+ raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32524
33013
  leaf.intermediateRefundTx
32525
33014
  ),
32526
- direct_raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
33015
+ direct_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32527
33016
  leaf.intermediateDirectRefundTx
32528
33017
  ),
32529
- direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils25.bytesToHex)(
33018
+ direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
32530
33019
  leaf.intermediateDirectFromCpfpRefundTx
32531
33020
  ),
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)(
33021
+ adaptor_added_signature: (0, import_utils24.bytesToHex)(cpfpSignature),
33022
+ direct_adaptor_added_signature: (0, import_utils24.bytesToHex)(directSignature),
33023
+ direct_from_cpfp_adaptor_added_signature: (0, import_utils24.bytesToHex)(
32535
33024
  directFromCpfpSignature
32536
33025
  )
32537
33026
  });
32538
33027
  }
32539
33028
  const sspClient = this.getSspClient();
32540
- const cpfpAdaptorPubkey = (0, import_utils25.bytesToHex)(
33029
+ const cpfpAdaptorPubkey = (0, import_utils24.bytesToHex)(
32541
33030
  import_secp256k115.secp256k1.getPublicKey(cpfpAdaptorPrivateKey)
32542
33031
  );
32543
33032
  if (!cpfpAdaptorPubkey) {
@@ -32545,13 +33034,13 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32545
33034
  }
32546
33035
  let directAdaptorPubkey;
32547
33036
  if (directAdaptorPrivateKey.length > 0) {
32548
- directAdaptorPubkey = (0, import_utils25.bytesToHex)(
33037
+ directAdaptorPubkey = (0, import_utils24.bytesToHex)(
32549
33038
  import_secp256k115.secp256k1.getPublicKey(directAdaptorPrivateKey)
32550
33039
  );
32551
33040
  }
32552
33041
  let directFromCpfpAdaptorPubkey;
32553
33042
  if (directFromCpfpAdaptorPrivateKey.length > 0) {
32554
- directFromCpfpAdaptorPubkey = (0, import_utils25.bytesToHex)(
33043
+ directFromCpfpAdaptorPubkey = (0, import_utils24.bytesToHex)(
32555
33044
  import_secp256k115.secp256k1.getPublicKey(directFromCpfpAdaptorPrivateKey)
32556
33045
  );
32557
33046
  }
@@ -32611,7 +33100,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32611
33100
  throw new Error(`Leaf not found for node ${nodeId}`);
32612
33101
  }
32613
33102
  const cpfpNodeTx = getTxFromRawTxBytes(node.nodeTx);
32614
- const cpfpRefundTxBytes = (0, import_utils25.hexToBytes)(leaf.rawUnsignedRefundTransaction);
33103
+ const cpfpRefundTxBytes = (0, import_utils24.hexToBytes)(leaf.rawUnsignedRefundTransaction);
32615
33104
  const cpfpRefundTx = getTxFromRawTxBytes(cpfpRefundTxBytes);
32616
33105
  const cpfpSighash = getSigHashFromTx(
32617
33106
  cpfpRefundTx,
@@ -32620,7 +33109,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32620
33109
  );
32621
33110
  const nodePublicKey = node.verifyingPublicKey;
32622
33111
  const taprootKey = computeTaprootKeyNoScript(nodePublicKey.slice(1));
32623
- const cpfpAdaptorSignatureBytes = (0, import_utils25.hexToBytes)(
33112
+ const cpfpAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
32624
33113
  leaf.adaptorSignedSignature
32625
33114
  );
32626
33115
  applyAdaptorToSignature(
@@ -32631,7 +33120,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32631
33120
  );
32632
33121
  if (leaf.directRawUnsignedRefundTransaction) {
32633
33122
  const directNodeTx = getTxFromRawTxBytes(node.directTx);
32634
- const directRefundTxBytes = (0, import_utils25.hexToBytes)(
33123
+ const directRefundTxBytes = (0, import_utils24.hexToBytes)(
32635
33124
  leaf.directRawUnsignedRefundTransaction
32636
33125
  );
32637
33126
  const directRefundTx = getTxFromRawTxBytes(directRefundTxBytes);
@@ -32645,7 +33134,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32645
33134
  `Direct adaptor signed signature missing for node ${nodeId}`
32646
33135
  );
32647
33136
  }
32648
- const directAdaptorSignatureBytes = (0, import_utils25.hexToBytes)(
33137
+ const directAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
32649
33138
  leaf.directAdaptorSignedSignature
32650
33139
  );
32651
33140
  applyAdaptorToSignature(
@@ -32656,7 +33145,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32656
33145
  );
32657
33146
  }
32658
33147
  if (leaf.directFromCpfpRawUnsignedRefundTransaction) {
32659
- const directFromCpfpRefundTxBytes = (0, import_utils25.hexToBytes)(
33148
+ const directFromCpfpRefundTxBytes = (0, import_utils24.hexToBytes)(
32660
33149
  leaf.directFromCpfpRawUnsignedRefundTransaction
32661
33150
  );
32662
33151
  const directFromCpfpRefundTx = getTxFromRawTxBytes(
@@ -32672,7 +33161,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32672
33161
  `Direct adaptor signed signature missing for node ${nodeId}`
32673
33162
  );
32674
33163
  }
32675
- const directFromCpfpAdaptorSignatureBytes = (0, import_utils25.hexToBytes)(
33164
+ const directFromCpfpAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
32676
33165
  leaf.directFromCpfpAdaptorSignedSignature
32677
33166
  );
32678
33167
  applyAdaptorToSignature(
@@ -32691,9 +33180,9 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32691
33180
  directFromCpfpSignatureMap
32692
33181
  );
32693
33182
  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)(
33183
+ adaptorSecretKey: (0, import_utils24.bytesToHex)(cpfpAdaptorPrivateKey),
33184
+ directAdaptorSecretKey: (0, import_utils24.bytesToHex)(directAdaptorPrivateKey),
33185
+ directFromCpfpAdaptorSecretKey: (0, import_utils24.bytesToHex)(
32697
33186
  directFromCpfpAdaptorPrivateKey
32698
33187
  ),
32699
33188
  userOutboundTransferExternalId: transfer.id,
@@ -32724,7 +33213,6 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32724
33213
  message: e.message,
32725
33214
  stack: e.stack
32726
33215
  });
32727
- await this.cancelAllSenderInitiatedTransfers();
32728
33216
  throw new Error(`Failed to request leaves swap: ${e}`);
32729
33217
  }
32730
33218
  }
@@ -32788,12 +33276,12 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32788
33276
  let tokenMetadataMap = /* @__PURE__ */ new Map();
32789
33277
  for (const [tokenIdentifier, metadata] of this.tokenMetadata) {
32790
33278
  tokenMetadataMap.set(tokenIdentifier, {
32791
- tokenPublicKey: (0, import_utils25.bytesToHex)(metadata.issuerPublicKey),
33279
+ tokenPublicKey: (0, import_utils24.bytesToHex)(metadata.issuerPublicKey),
32792
33280
  rawTokenIdentifier: metadata.tokenIdentifier,
32793
33281
  tokenName: metadata.tokenName,
32794
33282
  tokenTicker: metadata.tokenTicker,
32795
33283
  decimals: metadata.decimals,
32796
- maxSupply: (0, import_utils25.bytesToNumberBE)(metadata.maxSupply)
33284
+ maxSupply: (0, import_utils24.bytesToNumberBE)(metadata.maxSupply)
32797
33285
  });
32798
33286
  }
32799
33287
  return tokenMetadataMap;
@@ -32828,7 +33316,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32828
33316
  * @returns {Promise<string>} A Bitcoin address for depositing funds
32829
33317
  */
32830
33318
  async getSingleUseDepositAddress() {
32831
- return await this.generateDepositAddress(false);
33319
+ return await this.generateDepositAddress();
32832
33320
  }
32833
33321
  /**
32834
33322
  * Generates a new static deposit address for receiving bitcoin funds.
@@ -32837,43 +33325,32 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32837
33325
  * @returns {Promise<string>} A Bitcoin address for depositing funds
32838
33326
  */
32839
33327
  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
- }
33328
+ const signingPubkey = await this.config.signer.getStaticDepositSigningKey(0);
33329
+ const address2 = await this.depositService.generateStaticDepositAddress({
33330
+ signingPubkey
33331
+ });
33332
+ if (!address2.depositAddress) {
33333
+ throw new RPCError("Failed to generate static deposit address", {
33334
+ method: "generateStaticDepositAddress",
33335
+ params: { signingPubkey }
33336
+ });
32853
33337
  }
33338
+ return address2.depositAddress.address;
32854
33339
  }
32855
33340
  /**
32856
33341
  * Generates a deposit address for receiving funds.
32857
- *
32858
- * @param {boolean} static - Whether the address is static or single use
32859
33342
  * @returns {Promise<string>} A deposit address
32860
33343
  * @private
32861
33344
  */
32862
- async generateDepositAddress(isStatic) {
33345
+ async generateDepositAddress() {
32863
33346
  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
- }
33347
+ const signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
33348
+ type: "leaf" /* LEAF */,
33349
+ path: leafId
33350
+ });
32873
33351
  const address2 = await this.depositService.generateDepositAddress({
32874
33352
  signingPubkey,
32875
- leafId,
32876
- isStatic
33353
+ leafId
32877
33354
  });
32878
33355
  if (!address2.depositAddress) {
32879
33356
  throw new RPCError("Failed to generate deposit address", {
@@ -32900,7 +33377,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32900
33377
  * @param offset - Pagination offset (default 0).
32901
33378
  * @returns {Promise<{ txid: string, vout: number }[]>} List of confirmed UTXOs.
32902
33379
  */
32903
- async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0) {
33380
+ async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0, excludeClaimed = false) {
32904
33381
  if (!depositAddress) {
32905
33382
  throw new ValidationError("Deposit address cannot be empty", {
32906
33383
  field: "depositAddress"
@@ -32914,10 +33391,11 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32914
33391
  address: depositAddress,
32915
33392
  network: NetworkToProto[this.config.getNetwork()],
32916
33393
  limit,
32917
- offset
33394
+ offset,
33395
+ excludeClaimed
32918
33396
  });
32919
33397
  return response.utxos.map((utxo) => ({
32920
- txid: (0, import_utils25.bytesToHex)(utxo.txid),
33398
+ txid: (0, import_utils24.bytesToHex)(utxo.txid),
32921
33399
  vout: utxo.vout
32922
33400
  })) ?? [];
32923
33401
  } catch (error) {
@@ -32987,7 +33465,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
32987
33465
  if (network === BitcoinNetwork_default.FUTURE_VALUE) {
32988
33466
  network = BitcoinNetwork_default.REGTEST;
32989
33467
  }
32990
- const depositSecretKey = (0, import_utils25.bytesToHex)(
33468
+ const depositSecretKey = (0, import_utils24.bytesToHex)(
32991
33469
  await this.config.signer.getStaticDepositSecretKey(0)
32992
33470
  );
32993
33471
  const message = await this.getStaticDepositSigningPayload(
@@ -33000,7 +33478,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33000
33478
  );
33001
33479
  const hashBuffer = (0, import_sha213.sha256)(message);
33002
33480
  const signatureBytes = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
33003
- const signature = (0, import_utils25.bytesToHex)(signatureBytes);
33481
+ const signature = (0, import_utils24.bytesToHex)(signatureBytes);
33004
33482
  const response = await this.sspClient.claimStaticDeposit({
33005
33483
  transactionId,
33006
33484
  outputIndex,
@@ -33152,7 +33630,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33152
33630
  networkJSON.toLowerCase(),
33153
33631
  2 /* Refund */,
33154
33632
  creditAmountSats,
33155
- (0, import_utils25.bytesToHex)(spendTxSighash)
33633
+ (0, import_utils24.bytesToHex)(spendTxSighash)
33156
33634
  );
33157
33635
  const hashBuffer = (0, import_sha213.sha256)(message);
33158
33636
  const swapResponseUserSignature = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
@@ -33161,7 +33639,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33161
33639
  );
33162
33640
  const swapResponse = await sparkClient.initiate_static_deposit_utxo_refund({
33163
33641
  onChainUtxo: {
33164
- txid: (0, import_utils25.hexToBytes)(depositTransactionId),
33642
+ txid: (0, import_utils24.hexToBytes)(depositTransactionId),
33165
33643
  vout: outputIndex,
33166
33644
  network: networkType
33167
33645
  },
@@ -33197,6 +33675,64 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33197
33675
  });
33198
33676
  return tx.hex;
33199
33677
  }
33678
+ /**
33679
+ * Refunds a static deposit and broadcasts the transaction to the network.
33680
+ *
33681
+ * @param {Object} params - The refund parameters
33682
+ * @param {string} params.depositTransactionId - The ID of the transaction
33683
+ * @param {number} [params.outputIndex] - The index of the output
33684
+ * @param {string} params.destinationAddress - The destination address
33685
+ * @param {number} [params.satsPerVbyteFee] - The fee per vbyte to refund
33686
+ * @returns {Promise<string>} The transaction ID
33687
+ */
33688
+ async refundAndBroadcastStaticDeposit({
33689
+ depositTransactionId,
33690
+ outputIndex,
33691
+ destinationAddress,
33692
+ satsPerVbyteFee
33693
+ }) {
33694
+ const txHex = await this.refundStaticDeposit({
33695
+ depositTransactionId,
33696
+ outputIndex,
33697
+ destinationAddress,
33698
+ satsPerVbyteFee
33699
+ });
33700
+ return await this.broadcastTx(txHex);
33701
+ }
33702
+ /**
33703
+ * Broadcasts a transaction to the network.
33704
+ *
33705
+ * @param {string} txHex - The hex of the transaction
33706
+ * @returns {Promise<string>} The transaction ID
33707
+ */
33708
+ async broadcastTx(txHex) {
33709
+ if (!txHex) {
33710
+ throw new ValidationError("Transaction hex cannot be empty", {
33711
+ field: "txHex"
33712
+ });
33713
+ }
33714
+ const { fetch, Headers: Headers2 } = getFetch();
33715
+ const baseUrl = this.config.getElectrsUrl();
33716
+ const headers = new Headers2();
33717
+ if (this.config.getNetwork() === 4 /* LOCAL */) {
33718
+ const localFaucet = BitcoinFaucet.getInstance();
33719
+ const response = await localFaucet.broadcastTx(txHex);
33720
+ return response;
33721
+ } else {
33722
+ if (this.config.getNetwork() === 3 /* REGTEST */) {
33723
+ const auth = btoa(
33724
+ `${ELECTRS_CREDENTIALS.username}:${ELECTRS_CREDENTIALS.password}`
33725
+ );
33726
+ headers.set("Authorization", `Basic ${auth}`);
33727
+ }
33728
+ const response = await fetch(`${baseUrl}/tx`, {
33729
+ method: "POST",
33730
+ body: txHex,
33731
+ headers
33732
+ });
33733
+ return response.text();
33734
+ }
33735
+ }
33200
33736
  async getStaticDepositSigningPayload(transactionID, outputIndex, network, requestType, creditAmountSats, sspSignature) {
33201
33737
  const encoder = new TextEncoder();
33202
33738
  const parts = [];
@@ -33230,7 +33766,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33230
33766
  creditAmountView.setUint32(0, lowerHalf, true);
33231
33767
  creditAmountView.setUint32(4, upperHalf, true);
33232
33768
  parts.push(new Uint8Array(creditAmountBuffer));
33233
- parts.push((0, import_utils25.hexToBytes)(sspSignature));
33769
+ parts.push((0, import_utils24.hexToBytes)(sspSignature));
33234
33770
  const totalLength = parts.reduce((sum, part) => sum + part.length, 0);
33235
33771
  const payload = new Uint8Array(totalLength);
33236
33772
  let offset = 0;
@@ -33635,9 +34171,9 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33635
34171
  });
33636
34172
  }
33637
34173
  const signerIdentityPublicKey = await this.config.signer.getIdentityPublicKey();
33638
- const isSelfTransfer = (0, import_utils25.equalBytes)(
34174
+ const isSelfTransfer = (0, import_utils24.equalBytes)(
33639
34175
  signerIdentityPublicKey,
33640
- (0, import_utils25.hexToBytes)(receiverAddress.identityPublicKey)
34176
+ (0, import_utils24.hexToBytes)(receiverAddress.identityPublicKey)
33641
34177
  );
33642
34178
  return await this.withLeaves(async () => {
33643
34179
  let leavesToSend = (await this.selectLeaves([amountSats])).get(
@@ -33659,7 +34195,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33659
34195
  );
33660
34196
  const transfer = await this.transferService.sendTransferWithKeyTweaks(
33661
34197
  leafKeyTweaks,
33662
- (0, import_utils25.hexToBytes)(receiverAddress.identityPublicKey)
34198
+ (0, import_utils24.hexToBytes)(receiverAddress.identityPublicKey)
33663
34199
  );
33664
34200
  const leavesToRemove = new Set(leavesToSend.map((leaf) => leaf.id));
33665
34201
  this.leaves = this.leaves.filter((leaf) => !leavesToRemove.has(leaf.id));
@@ -33675,7 +34211,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33675
34211
  }
33676
34212
  return mapTransferToWalletTransfer(
33677
34213
  transfer,
33678
- (0, import_utils25.bytesToHex)(await this.config.signer.getIdentityPublicKey())
34214
+ (0, import_utils24.bytesToHex)(await this.config.signer.getIdentityPublicKey())
33679
34215
  );
33680
34216
  });
33681
34217
  }
@@ -33935,24 +34471,6 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33935
34471
  (result) => result.status === "fulfilled" && result.value !== null
33936
34472
  ).map((result) => result.value);
33937
34473
  }
33938
- /**
33939
- * Cancels all sender-initiated transfers.
33940
- *
33941
- * @returns {Promise<void>}
33942
- * @private
33943
- */
33944
- async cancelAllSenderInitiatedTransfers() {
33945
- for (const operator of Object.values(this.config.getSigningOperators())) {
33946
- const transfers = await this.transferService.queryPendingTransfersBySender(
33947
- operator.address
33948
- );
33949
- for (const transfer of transfers.transfers) {
33950
- if (transfer.status === 0 /* TRANSFER_STATUS_SENDER_INITIATED */) {
33951
- await this.transferService.cancelTransfer(transfer, operator.address);
33952
- }
33953
- }
33954
- }
33955
- }
33956
34474
  // ***** Lightning Flow *****
33957
34475
  /**
33958
34476
  * Creates a Lightning invoice for receiving payments.
@@ -34031,7 +34549,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34031
34549
  const invoice2 = await sspClient.requestLightningReceive({
34032
34550
  amountSats: amountSats2,
34033
34551
  network: bitcoinNetwork,
34034
- paymentHash: (0, import_utils25.bytesToHex)(paymentHash),
34552
+ paymentHash: (0, import_utils24.bytesToHex)(paymentHash),
34035
34553
  expirySecs: expirySeconds,
34036
34554
  memo: memo2,
34037
34555
  includeSparkAddress,
@@ -34140,7 +34658,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34140
34658
  const sparkFallbackAddress = decodedInvoice.fallbackAddress;
34141
34659
  const paymentHash = decodedInvoice.paymentHash;
34142
34660
  if (preferSpark) {
34143
- if (sparkFallbackAddress === void 0 || isValidSparkFallback((0, import_utils25.hexToBytes)(sparkFallbackAddress)) === false) {
34661
+ if (sparkFallbackAddress === void 0 || isValidSparkFallback((0, import_utils24.hexToBytes)(sparkFallbackAddress)) === false) {
34144
34662
  console.warn(
34145
34663
  "No valid spark address found in invoice. Defaulting to lightning."
34146
34664
  );
@@ -34194,10 +34712,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34194
34712
  );
34195
34713
  const swapResponse = await this.lightningService.swapNodesForPreimage({
34196
34714
  leaves: leavesToSend,
34197
- receiverIdentityPubkey: (0, import_utils25.hexToBytes)(
34715
+ receiverIdentityPubkey: (0, import_utils24.hexToBytes)(
34198
34716
  this.config.getSspIdentityPublicKey()
34199
34717
  ),
34200
- paymentHash: (0, import_utils25.hexToBytes)(paymentHash),
34718
+ paymentHash: (0, import_utils24.hexToBytes)(paymentHash),
34201
34719
  isInboundPayment: false,
34202
34720
  invoiceString: invoice,
34203
34721
  feeSats: feeEstimate,
@@ -34315,7 +34833,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34315
34833
  });
34316
34834
  await this.syncTokenOutputs();
34317
34835
  const bech32mTokenIdentifier = encodeBech32mTokenIdentifier({
34318
- tokenIdentifier: (0, import_utils25.hexToBytes)(firstTokenIdentifierHexSeen),
34836
+ tokenIdentifier: (0, import_utils24.hexToBytes)(firstTokenIdentifierHexSeen),
34319
34837
  network: this.config.getNetworkType()
34320
34838
  });
34321
34839
  const receiverOutputs = decoded.map((d) => ({
@@ -34503,11 +35021,11 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34503
35021
  const connectorOutputs = [];
34504
35022
  for (let i = 0; i < connectorTx.outputsLength - 1; i++) {
34505
35023
  connectorOutputs.push({
34506
- txid: (0, import_utils25.hexToBytes)(connectorTxId),
35024
+ txid: (0, import_utils24.hexToBytes)(connectorTxId),
34507
35025
  index: i
34508
35026
  });
34509
35027
  }
34510
- const sspPubIdentityKey = (0, import_utils25.hexToBytes)(this.config.getSspIdentityPublicKey());
35028
+ const sspPubIdentityKey = (0, import_utils24.hexToBytes)(this.config.getSspIdentityPublicKey());
34511
35029
  const transfer = await this.coopExitService.getConnectorRefundSignatures({
34512
35030
  leaves: leafKeyTweaks,
34513
35031
  exitTxId: coopExitTxId,
@@ -34561,7 +35079,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34561
35079
  return transfers?.[0];
34562
35080
  }
34563
35081
  async constructTransfersWithUserRequest(transfers) {
34564
- const identityPublicKey = (0, import_utils25.bytesToHex)(
35082
+ const identityPublicKey = (0, import_utils24.bytesToHex)(
34565
35083
  await this.config.signer.getIdentityPublicKey()
34566
35084
  );
34567
35085
  const userRequests = await this.sspClient?.getTransfers(
@@ -34805,7 +35323,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34805
35323
  hash,
34806
35324
  compact
34807
35325
  );
34808
- return (0, import_utils25.bytesToHex)(signature);
35326
+ return (0, import_utils24.bytesToHex)(signature);
34809
35327
  }
34810
35328
  /**
34811
35329
  * Validates a message with the identity key.
@@ -34817,7 +35335,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34817
35335
  async validateMessageWithIdentityKey(message, signature) {
34818
35336
  const hash = (0, import_sha213.sha256)(message);
34819
35337
  if (typeof signature === "string") {
34820
- signature = (0, import_utils25.hexToBytes)(signature);
35338
+ signature = (0, import_utils24.hexToBytes)(signature);
34821
35339
  }
34822
35340
  return this.config.signer.validateMessageWithIdentityKey(hash, signature);
34823
35341
  }
@@ -34830,7 +35348,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34830
35348
  */
34831
35349
  async signTransaction(txHex, keyType = "auto-detect") {
34832
35350
  try {
34833
- const tx = import_btc_signer6.Transaction.fromRaw((0, import_utils25.hexToBytes)(txHex));
35351
+ const tx = import_btc_signer6.Transaction.fromRaw((0, import_utils24.hexToBytes)(txHex));
34834
35352
  let publicKey;
34835
35353
  switch (keyType.toLowerCase()) {
34836
35354
  case "identity":
@@ -34863,7 +35381,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34863
35381
  publicKey,
34864
35382
  this.config.getNetwork()
34865
35383
  );
34866
- if ((0, import_utils25.bytesToHex)(script) === (0, import_utils25.bytesToHex)(identityScript)) {
35384
+ if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(identityScript)) {
34867
35385
  try {
34868
35386
  this.config.signer.signTransactionIndex(tx, i, publicKey);
34869
35387
  inputsSigned++;
@@ -34907,13 +35425,13 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34907
35425
  depositPubKey,
34908
35426
  this.config.getNetwork()
34909
35427
  );
34910
- if ((0, import_utils25.bytesToHex)(script) === (0, import_utils25.bytesToHex)(identityScript)) {
35428
+ if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(identityScript)) {
34911
35429
  return {
34912
35430
  publicKey: identityPubKey,
34913
35431
  keyType: "identity"
34914
35432
  };
34915
35433
  }
34916
- if ((0, import_utils25.bytesToHex)(script) === (0, import_utils25.bytesToHex)(depositScript)) {
35434
+ if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(depositScript)) {
34917
35435
  return {
34918
35436
  publicKey: depositPubKey,
34919
35437
  keyType: "deposit"