@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
@@ -1111,7 +1111,7 @@ function signFrost({
1111
1111
  adaptorPubKey
1112
1112
  }) {
1113
1113
  SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("signFrost", {
1114
- message: (0, import_utils13.bytesToHex)(message),
1114
+ message: (0, import_utils12.bytesToHex)(message),
1115
1115
  keyPackage,
1116
1116
  nonce,
1117
1117
  selfCommitment,
@@ -1138,15 +1138,15 @@ function aggregateFrost({
1138
1138
  adaptorPubKey
1139
1139
  }) {
1140
1140
  SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("aggregateFrost", {
1141
- message: (0, import_utils13.bytesToHex)(message),
1141
+ message: (0, import_utils12.bytesToHex)(message),
1142
1142
  statechainCommitments,
1143
1143
  selfCommitment,
1144
1144
  statechainSignatures,
1145
- selfSignature: (0, import_utils13.bytesToHex)(selfSignature),
1145
+ selfSignature: (0, import_utils12.bytesToHex)(selfSignature),
1146
1146
  statechainPublicKeys,
1147
- selfPublicKey: (0, import_utils13.bytesToHex)(selfPublicKey),
1148
- verifyingKey: (0, import_utils13.bytesToHex)(verifyingKey),
1149
- adaptorPubKey: adaptorPubKey ? (0, import_utils13.bytesToHex)(adaptorPubKey) : void 0
1147
+ selfPublicKey: (0, import_utils12.bytesToHex)(selfPublicKey),
1148
+ verifyingKey: (0, import_utils12.bytesToHex)(verifyingKey),
1149
+ adaptorPubKey: adaptorPubKey ? (0, import_utils12.bytesToHex)(adaptorPubKey) : void 0
1150
1150
  });
1151
1151
  return wasm_aggregate_frost(
1152
1152
  message,
@@ -1178,12 +1178,12 @@ function decryptEcies({
1178
1178
  }) {
1179
1179
  return decrypt_ecies(encryptedMsg, privateKey);
1180
1180
  }
1181
- var import_utils13;
1181
+ var import_utils12;
1182
1182
  var init_wasm = __esm({
1183
1183
  "src/spark_bindings/wasm/index.ts"() {
1184
1184
  "use strict";
1185
1185
  init_buffer();
1186
- import_utils13 = require("@noble/curves/utils");
1186
+ import_utils12 = require("@noble/curves/utils");
1187
1187
  init_spark_bindings();
1188
1188
  init_logging();
1189
1189
  }
@@ -1507,8 +1507,8 @@ init_buffer();
1507
1507
  // src/utils/address.ts
1508
1508
  init_buffer();
1509
1509
  var import_wire5 = require("@bufbuild/protobuf/wire");
1510
- var import_utils2 = require("@noble/curves/abstract/utils");
1511
1510
  var import_secp256k1 = require("@noble/curves/secp256k1");
1511
+ var import_utils2 = require("@noble/curves/utils");
1512
1512
  var import_utils3 = require("@noble/hashes/utils");
1513
1513
  var import_base2 = require("@scure/base");
1514
1514
  var import_uuidv7 = require("uuidv7");
@@ -2042,6 +2042,41 @@ function utxoSwapRequestTypeToJSON(object) {
2042
2042
  return "UNRECOGNIZED";
2043
2043
  }
2044
2044
  }
2045
+ function invoiceStatusFromJSON(object) {
2046
+ switch (object) {
2047
+ case 0:
2048
+ case "NOT_FOUND":
2049
+ return 0 /* NOT_FOUND */;
2050
+ case 1:
2051
+ case "PENDING":
2052
+ return 1 /* PENDING */;
2053
+ case 2:
2054
+ case "FINALIZED":
2055
+ return 2 /* FINALIZED */;
2056
+ case 3:
2057
+ case "EXPIRED":
2058
+ return 3 /* EXPIRED */;
2059
+ case -1:
2060
+ case "UNRECOGNIZED":
2061
+ default:
2062
+ return -1 /* UNRECOGNIZED */;
2063
+ }
2064
+ }
2065
+ function invoiceStatusToJSON(object) {
2066
+ switch (object) {
2067
+ case 0 /* NOT_FOUND */:
2068
+ return "NOT_FOUND";
2069
+ case 1 /* PENDING */:
2070
+ return "PENDING";
2071
+ case 2 /* FINALIZED */:
2072
+ return "FINALIZED";
2073
+ case 3 /* EXPIRED */:
2074
+ return "EXPIRED";
2075
+ case -1 /* UNRECOGNIZED */:
2076
+ default:
2077
+ return "UNRECOGNIZED";
2078
+ }
2079
+ }
2045
2080
  function initiatePreimageSwapRequest_ReasonFromJSON(object) {
2046
2081
  switch (object) {
2047
2082
  case 0:
@@ -2781,6 +2816,140 @@ var GenerateDepositAddressResponse = {
2781
2816
  return message;
2782
2817
  }
2783
2818
  };
2819
+ function createBaseGenerateStaticDepositAddressRequest() {
2820
+ return { signingPublicKey: new Uint8Array(0), identityPublicKey: new Uint8Array(0), network: 0 };
2821
+ }
2822
+ var GenerateStaticDepositAddressRequest = {
2823
+ encode(message, writer = new import_wire4.BinaryWriter()) {
2824
+ if (message.signingPublicKey.length !== 0) {
2825
+ writer.uint32(10).bytes(message.signingPublicKey);
2826
+ }
2827
+ if (message.identityPublicKey.length !== 0) {
2828
+ writer.uint32(18).bytes(message.identityPublicKey);
2829
+ }
2830
+ if (message.network !== 0) {
2831
+ writer.uint32(24).int32(message.network);
2832
+ }
2833
+ return writer;
2834
+ },
2835
+ decode(input, length) {
2836
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
2837
+ const end = length === void 0 ? reader.len : reader.pos + length;
2838
+ const message = createBaseGenerateStaticDepositAddressRequest();
2839
+ while (reader.pos < end) {
2840
+ const tag = reader.uint32();
2841
+ switch (tag >>> 3) {
2842
+ case 1: {
2843
+ if (tag !== 10) {
2844
+ break;
2845
+ }
2846
+ message.signingPublicKey = reader.bytes();
2847
+ continue;
2848
+ }
2849
+ case 2: {
2850
+ if (tag !== 18) {
2851
+ break;
2852
+ }
2853
+ message.identityPublicKey = reader.bytes();
2854
+ continue;
2855
+ }
2856
+ case 3: {
2857
+ if (tag !== 24) {
2858
+ break;
2859
+ }
2860
+ message.network = reader.int32();
2861
+ continue;
2862
+ }
2863
+ }
2864
+ if ((tag & 7) === 4 || tag === 0) {
2865
+ break;
2866
+ }
2867
+ reader.skip(tag & 7);
2868
+ }
2869
+ return message;
2870
+ },
2871
+ fromJSON(object) {
2872
+ return {
2873
+ signingPublicKey: isSet3(object.signingPublicKey) ? bytesFromBase642(object.signingPublicKey) : new Uint8Array(0),
2874
+ identityPublicKey: isSet3(object.identityPublicKey) ? bytesFromBase642(object.identityPublicKey) : new Uint8Array(0),
2875
+ network: isSet3(object.network) ? networkFromJSON(object.network) : 0
2876
+ };
2877
+ },
2878
+ toJSON(message) {
2879
+ const obj = {};
2880
+ if (message.signingPublicKey.length !== 0) {
2881
+ obj.signingPublicKey = base64FromBytes2(message.signingPublicKey);
2882
+ }
2883
+ if (message.identityPublicKey.length !== 0) {
2884
+ obj.identityPublicKey = base64FromBytes2(message.identityPublicKey);
2885
+ }
2886
+ if (message.network !== 0) {
2887
+ obj.network = networkToJSON(message.network);
2888
+ }
2889
+ return obj;
2890
+ },
2891
+ create(base) {
2892
+ return GenerateStaticDepositAddressRequest.fromPartial(base ?? {});
2893
+ },
2894
+ fromPartial(object) {
2895
+ const message = createBaseGenerateStaticDepositAddressRequest();
2896
+ message.signingPublicKey = object.signingPublicKey ?? new Uint8Array(0);
2897
+ message.identityPublicKey = object.identityPublicKey ?? new Uint8Array(0);
2898
+ message.network = object.network ?? 0;
2899
+ return message;
2900
+ }
2901
+ };
2902
+ function createBaseGenerateStaticDepositAddressResponse() {
2903
+ return { depositAddress: void 0 };
2904
+ }
2905
+ var GenerateStaticDepositAddressResponse = {
2906
+ encode(message, writer = new import_wire4.BinaryWriter()) {
2907
+ if (message.depositAddress !== void 0) {
2908
+ Address.encode(message.depositAddress, writer.uint32(10).fork()).join();
2909
+ }
2910
+ return writer;
2911
+ },
2912
+ decode(input, length) {
2913
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
2914
+ const end = length === void 0 ? reader.len : reader.pos + length;
2915
+ const message = createBaseGenerateStaticDepositAddressResponse();
2916
+ while (reader.pos < end) {
2917
+ const tag = reader.uint32();
2918
+ switch (tag >>> 3) {
2919
+ case 1: {
2920
+ if (tag !== 10) {
2921
+ break;
2922
+ }
2923
+ message.depositAddress = Address.decode(reader, reader.uint32());
2924
+ continue;
2925
+ }
2926
+ }
2927
+ if ((tag & 7) === 4 || tag === 0) {
2928
+ break;
2929
+ }
2930
+ reader.skip(tag & 7);
2931
+ }
2932
+ return message;
2933
+ },
2934
+ fromJSON(object) {
2935
+ return { depositAddress: isSet3(object.depositAddress) ? Address.fromJSON(object.depositAddress) : void 0 };
2936
+ },
2937
+ toJSON(message) {
2938
+ const obj = {};
2939
+ if (message.depositAddress !== void 0) {
2940
+ obj.depositAddress = Address.toJSON(message.depositAddress);
2941
+ }
2942
+ return obj;
2943
+ },
2944
+ create(base) {
2945
+ return GenerateStaticDepositAddressResponse.fromPartial(base ?? {});
2946
+ },
2947
+ fromPartial(object) {
2948
+ const message = createBaseGenerateStaticDepositAddressResponse();
2949
+ message.depositAddress = object.depositAddress !== void 0 && object.depositAddress !== null ? Address.fromPartial(object.depositAddress) : void 0;
2950
+ return message;
2951
+ }
2952
+ };
2784
2953
  function createBaseUTXO() {
2785
2954
  return { rawTx: new Uint8Array(0), vout: 0, network: 0, txid: new Uint8Array(0) };
2786
2955
  }
@@ -8841,7 +9010,8 @@ function createBaseTransferLeaf() {
8841
9010
  signature: new Uint8Array(0),
8842
9011
  intermediateRefundTx: new Uint8Array(0),
8843
9012
  intermediateDirectRefundTx: new Uint8Array(0),
8844
- intermediateDirectFromCpfpRefundTx: new Uint8Array(0)
9013
+ intermediateDirectFromCpfpRefundTx: new Uint8Array(0),
9014
+ pendingKeyTweakPublicKey: new Uint8Array(0)
8845
9015
  };
8846
9016
  }
8847
9017
  var TransferLeaf = {
@@ -8864,6 +9034,9 @@ var TransferLeaf = {
8864
9034
  if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
8865
9035
  writer.uint32(50).bytes(message.intermediateDirectFromCpfpRefundTx);
8866
9036
  }
9037
+ if (message.pendingKeyTweakPublicKey.length !== 0) {
9038
+ writer.uint32(58).bytes(message.pendingKeyTweakPublicKey);
9039
+ }
8867
9040
  return writer;
8868
9041
  },
8869
9042
  decode(input, length) {
@@ -8915,6 +9088,13 @@ var TransferLeaf = {
8915
9088
  message.intermediateDirectFromCpfpRefundTx = reader.bytes();
8916
9089
  continue;
8917
9090
  }
9091
+ case 7: {
9092
+ if (tag !== 58) {
9093
+ break;
9094
+ }
9095
+ message.pendingKeyTweakPublicKey = reader.bytes();
9096
+ continue;
9097
+ }
8918
9098
  }
8919
9099
  if ((tag & 7) === 4 || tag === 0) {
8920
9100
  break;
@@ -8930,7 +9110,8 @@ var TransferLeaf = {
8930
9110
  signature: isSet3(object.signature) ? bytesFromBase642(object.signature) : new Uint8Array(0),
8931
9111
  intermediateRefundTx: isSet3(object.intermediateRefundTx) ? bytesFromBase642(object.intermediateRefundTx) : new Uint8Array(0),
8932
9112
  intermediateDirectRefundTx: isSet3(object.intermediateDirectRefundTx) ? bytesFromBase642(object.intermediateDirectRefundTx) : new Uint8Array(0),
8933
- intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0)
9113
+ intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0),
9114
+ pendingKeyTweakPublicKey: isSet3(object.pendingKeyTweakPublicKey) ? bytesFromBase642(object.pendingKeyTweakPublicKey) : new Uint8Array(0)
8934
9115
  };
8935
9116
  },
8936
9117
  toJSON(message) {
@@ -8953,6 +9134,9 @@ var TransferLeaf = {
8953
9134
  if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
8954
9135
  obj.intermediateDirectFromCpfpRefundTx = base64FromBytes2(message.intermediateDirectFromCpfpRefundTx);
8955
9136
  }
9137
+ if (message.pendingKeyTweakPublicKey.length !== 0) {
9138
+ obj.pendingKeyTweakPublicKey = base64FromBytes2(message.pendingKeyTweakPublicKey);
9139
+ }
8956
9140
  return obj;
8957
9141
  },
8958
9142
  create(base) {
@@ -8966,6 +9150,7 @@ var TransferLeaf = {
8966
9150
  message.intermediateRefundTx = object.intermediateRefundTx ?? new Uint8Array(0);
8967
9151
  message.intermediateDirectRefundTx = object.intermediateDirectRefundTx ?? new Uint8Array(0);
8968
9152
  message.intermediateDirectFromCpfpRefundTx = object.intermediateDirectFromCpfpRefundTx ?? new Uint8Array(0);
9153
+ message.pendingKeyTweakPublicKey = object.pendingKeyTweakPublicKey ?? new Uint8Array(0);
8969
9154
  return message;
8970
9155
  }
8971
9156
  };
@@ -11863,13 +12048,16 @@ var QueryUserSignedRefundsRequest = {
11863
12048
  }
11864
12049
  };
11865
12050
  function createBaseQueryUserSignedRefundsResponse() {
11866
- return { userSignedRefunds: [] };
12051
+ return { userSignedRefunds: [], transfer: void 0 };
11867
12052
  }
11868
12053
  var QueryUserSignedRefundsResponse = {
11869
12054
  encode(message, writer = new import_wire4.BinaryWriter()) {
11870
12055
  for (const v of message.userSignedRefunds) {
11871
12056
  UserSignedRefund.encode(v, writer.uint32(10).fork()).join();
11872
12057
  }
12058
+ if (message.transfer !== void 0) {
12059
+ Transfer.encode(message.transfer, writer.uint32(26).fork()).join();
12060
+ }
11873
12061
  return writer;
11874
12062
  },
11875
12063
  decode(input, length) {
@@ -11886,6 +12074,13 @@ var QueryUserSignedRefundsResponse = {
11886
12074
  message.userSignedRefunds.push(UserSignedRefund.decode(reader, reader.uint32()));
11887
12075
  continue;
11888
12076
  }
12077
+ case 3: {
12078
+ if (tag !== 26) {
12079
+ break;
12080
+ }
12081
+ message.transfer = Transfer.decode(reader, reader.uint32());
12082
+ continue;
12083
+ }
11889
12084
  }
11890
12085
  if ((tag & 7) === 4 || tag === 0) {
11891
12086
  break;
@@ -11896,7 +12091,8 @@ var QueryUserSignedRefundsResponse = {
11896
12091
  },
11897
12092
  fromJSON(object) {
11898
12093
  return {
11899
- userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : []
12094
+ userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : [],
12095
+ transfer: isSet3(object.transfer) ? Transfer.fromJSON(object.transfer) : void 0
11900
12096
  };
11901
12097
  },
11902
12098
  toJSON(message) {
@@ -11904,6 +12100,9 @@ var QueryUserSignedRefundsResponse = {
11904
12100
  if (message.userSignedRefunds?.length) {
11905
12101
  obj.userSignedRefunds = message.userSignedRefunds.map((e) => UserSignedRefund.toJSON(e));
11906
12102
  }
12103
+ if (message.transfer !== void 0) {
12104
+ obj.transfer = Transfer.toJSON(message.transfer);
12105
+ }
11907
12106
  return obj;
11908
12107
  },
11909
12108
  create(base) {
@@ -11912,6 +12111,7 @@ var QueryUserSignedRefundsResponse = {
11912
12111
  fromPartial(object) {
11913
12112
  const message = createBaseQueryUserSignedRefundsResponse();
11914
12113
  message.userSignedRefunds = object.userSignedRefunds?.map((e) => UserSignedRefund.fromPartial(e)) || [];
12114
+ message.transfer = object.transfer !== void 0 && object.transfer !== null ? Transfer.fromPartial(object.transfer) : void 0;
11915
12115
  return message;
11916
12116
  }
11917
12117
  };
@@ -12798,7 +12998,8 @@ function createBaseDepositAddressQueryResult() {
12798
12998
  depositAddress: "",
12799
12999
  userSigningPublicKey: new Uint8Array(0),
12800
13000
  verifyingPublicKey: new Uint8Array(0),
12801
- leafId: void 0
13001
+ leafId: void 0,
13002
+ proofOfPossession: void 0
12802
13003
  };
12803
13004
  }
12804
13005
  var DepositAddressQueryResult = {
@@ -12815,6 +13016,9 @@ var DepositAddressQueryResult = {
12815
13016
  if (message.leafId !== void 0) {
12816
13017
  writer.uint32(34).string(message.leafId);
12817
13018
  }
13019
+ if (message.proofOfPossession !== void 0) {
13020
+ DepositAddressProof.encode(message.proofOfPossession, writer.uint32(42).fork()).join();
13021
+ }
12818
13022
  return writer;
12819
13023
  },
12820
13024
  decode(input, length) {
@@ -12852,6 +13056,13 @@ var DepositAddressQueryResult = {
12852
13056
  message.leafId = reader.string();
12853
13057
  continue;
12854
13058
  }
13059
+ case 5: {
13060
+ if (tag !== 42) {
13061
+ break;
13062
+ }
13063
+ message.proofOfPossession = DepositAddressProof.decode(reader, reader.uint32());
13064
+ continue;
13065
+ }
12855
13066
  }
12856
13067
  if ((tag & 7) === 4 || tag === 0) {
12857
13068
  break;
@@ -12865,7 +13076,8 @@ var DepositAddressQueryResult = {
12865
13076
  depositAddress: isSet3(object.depositAddress) ? globalThis.String(object.depositAddress) : "",
12866
13077
  userSigningPublicKey: isSet3(object.userSigningPublicKey) ? bytesFromBase642(object.userSigningPublicKey) : new Uint8Array(0),
12867
13078
  verifyingPublicKey: isSet3(object.verifyingPublicKey) ? bytesFromBase642(object.verifyingPublicKey) : new Uint8Array(0),
12868
- leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0
13079
+ leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0,
13080
+ proofOfPossession: isSet3(object.proofOfPossession) ? DepositAddressProof.fromJSON(object.proofOfPossession) : void 0
12869
13081
  };
12870
13082
  },
12871
13083
  toJSON(message) {
@@ -12882,6 +13094,9 @@ var DepositAddressQueryResult = {
12882
13094
  if (message.leafId !== void 0) {
12883
13095
  obj.leafId = message.leafId;
12884
13096
  }
13097
+ if (message.proofOfPossession !== void 0) {
13098
+ obj.proofOfPossession = DepositAddressProof.toJSON(message.proofOfPossession);
13099
+ }
12885
13100
  return obj;
12886
13101
  },
12887
13102
  create(base) {
@@ -12893,6 +13108,7 @@ var DepositAddressQueryResult = {
12893
13108
  message.userSigningPublicKey = object.userSigningPublicKey ?? new Uint8Array(0);
12894
13109
  message.verifyingPublicKey = object.verifyingPublicKey ?? new Uint8Array(0);
12895
13110
  message.leafId = object.leafId ?? void 0;
13111
+ message.proofOfPossession = object.proofOfPossession !== void 0 && object.proofOfPossession !== null ? DepositAddressProof.fromPartial(object.proofOfPossession) : void 0;
12896
13112
  return message;
12897
13113
  }
12898
13114
  };
@@ -14484,7 +14700,7 @@ var QueryNodesByValueResponse_NodesEntry = {
14484
14700
  }
14485
14701
  };
14486
14702
  function createBaseGetUtxosForAddressRequest() {
14487
- return { address: "", offset: 0, limit: 0, network: 0 };
14703
+ return { address: "", offset: 0, limit: 0, network: 0, excludeClaimed: false };
14488
14704
  }
14489
14705
  var GetUtxosForAddressRequest = {
14490
14706
  encode(message, writer = new import_wire4.BinaryWriter()) {
@@ -14500,6 +14716,9 @@ var GetUtxosForAddressRequest = {
14500
14716
  if (message.network !== 0) {
14501
14717
  writer.uint32(32).int32(message.network);
14502
14718
  }
14719
+ if (message.excludeClaimed !== false) {
14720
+ writer.uint32(40).bool(message.excludeClaimed);
14721
+ }
14503
14722
  return writer;
14504
14723
  },
14505
14724
  decode(input, length) {
@@ -14537,6 +14756,13 @@ var GetUtxosForAddressRequest = {
14537
14756
  message.network = reader.int32();
14538
14757
  continue;
14539
14758
  }
14759
+ case 5: {
14760
+ if (tag !== 40) {
14761
+ break;
14762
+ }
14763
+ message.excludeClaimed = reader.bool();
14764
+ continue;
14765
+ }
14540
14766
  }
14541
14767
  if ((tag & 7) === 4 || tag === 0) {
14542
14768
  break;
@@ -14550,7 +14776,8 @@ var GetUtxosForAddressRequest = {
14550
14776
  address: isSet3(object.address) ? globalThis.String(object.address) : "",
14551
14777
  offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
14552
14778
  limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
14553
- network: isSet3(object.network) ? networkFromJSON(object.network) : 0
14779
+ network: isSet3(object.network) ? networkFromJSON(object.network) : 0,
14780
+ excludeClaimed: isSet3(object.excludeClaimed) ? globalThis.Boolean(object.excludeClaimed) : false
14554
14781
  };
14555
14782
  },
14556
14783
  toJSON(message) {
@@ -14567,6 +14794,9 @@ var GetUtxosForAddressRequest = {
14567
14794
  if (message.network !== 0) {
14568
14795
  obj.network = networkToJSON(message.network);
14569
14796
  }
14797
+ if (message.excludeClaimed !== false) {
14798
+ obj.excludeClaimed = message.excludeClaimed;
14799
+ }
14570
14800
  return obj;
14571
14801
  },
14572
14802
  create(base) {
@@ -14578,6 +14808,7 @@ var GetUtxosForAddressRequest = {
14578
14808
  message.offset = object.offset ?? 0;
14579
14809
  message.limit = object.limit ?? 0;
14580
14810
  message.network = object.network ?? 0;
14811
+ message.excludeClaimed = object.excludeClaimed ?? false;
14581
14812
  return message;
14582
14813
  }
14583
14814
  };
@@ -14649,6 +14880,225 @@ var GetUtxosForAddressResponse = {
14649
14880
  return message;
14650
14881
  }
14651
14882
  };
14883
+ function createBaseQuerySparkInvoicesRequest() {
14884
+ return { limit: 0, offset: 0, invoice: [] };
14885
+ }
14886
+ var QuerySparkInvoicesRequest = {
14887
+ encode(message, writer = new import_wire4.BinaryWriter()) {
14888
+ if (message.limit !== 0) {
14889
+ writer.uint32(8).int64(message.limit);
14890
+ }
14891
+ if (message.offset !== 0) {
14892
+ writer.uint32(16).int64(message.offset);
14893
+ }
14894
+ for (const v of message.invoice) {
14895
+ writer.uint32(26).string(v);
14896
+ }
14897
+ return writer;
14898
+ },
14899
+ decode(input, length) {
14900
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
14901
+ const end = length === void 0 ? reader.len : reader.pos + length;
14902
+ const message = createBaseQuerySparkInvoicesRequest();
14903
+ while (reader.pos < end) {
14904
+ const tag = reader.uint32();
14905
+ switch (tag >>> 3) {
14906
+ case 1: {
14907
+ if (tag !== 8) {
14908
+ break;
14909
+ }
14910
+ message.limit = longToNumber2(reader.int64());
14911
+ continue;
14912
+ }
14913
+ case 2: {
14914
+ if (tag !== 16) {
14915
+ break;
14916
+ }
14917
+ message.offset = longToNumber2(reader.int64());
14918
+ continue;
14919
+ }
14920
+ case 3: {
14921
+ if (tag !== 26) {
14922
+ break;
14923
+ }
14924
+ message.invoice.push(reader.string());
14925
+ continue;
14926
+ }
14927
+ }
14928
+ if ((tag & 7) === 4 || tag === 0) {
14929
+ break;
14930
+ }
14931
+ reader.skip(tag & 7);
14932
+ }
14933
+ return message;
14934
+ },
14935
+ fromJSON(object) {
14936
+ return {
14937
+ limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
14938
+ offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
14939
+ invoice: globalThis.Array.isArray(object?.invoice) ? object.invoice.map((e) => globalThis.String(e)) : []
14940
+ };
14941
+ },
14942
+ toJSON(message) {
14943
+ const obj = {};
14944
+ if (message.limit !== 0) {
14945
+ obj.limit = Math.round(message.limit);
14946
+ }
14947
+ if (message.offset !== 0) {
14948
+ obj.offset = Math.round(message.offset);
14949
+ }
14950
+ if (message.invoice?.length) {
14951
+ obj.invoice = message.invoice;
14952
+ }
14953
+ return obj;
14954
+ },
14955
+ create(base) {
14956
+ return QuerySparkInvoicesRequest.fromPartial(base ?? {});
14957
+ },
14958
+ fromPartial(object) {
14959
+ const message = createBaseQuerySparkInvoicesRequest();
14960
+ message.limit = object.limit ?? 0;
14961
+ message.offset = object.offset ?? 0;
14962
+ message.invoice = object.invoice?.map((e) => e) || [];
14963
+ return message;
14964
+ }
14965
+ };
14966
+ function createBaseQuerySparkInvoicesResponse() {
14967
+ return { offset: 0, invoiceStatuses: [] };
14968
+ }
14969
+ var QuerySparkInvoicesResponse = {
14970
+ encode(message, writer = new import_wire4.BinaryWriter()) {
14971
+ if (message.offset !== 0) {
14972
+ writer.uint32(8).int64(message.offset);
14973
+ }
14974
+ for (const v of message.invoiceStatuses) {
14975
+ InvoiceResponse.encode(v, writer.uint32(18).fork()).join();
14976
+ }
14977
+ return writer;
14978
+ },
14979
+ decode(input, length) {
14980
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
14981
+ const end = length === void 0 ? reader.len : reader.pos + length;
14982
+ const message = createBaseQuerySparkInvoicesResponse();
14983
+ while (reader.pos < end) {
14984
+ const tag = reader.uint32();
14985
+ switch (tag >>> 3) {
14986
+ case 1: {
14987
+ if (tag !== 8) {
14988
+ break;
14989
+ }
14990
+ message.offset = longToNumber2(reader.int64());
14991
+ continue;
14992
+ }
14993
+ case 2: {
14994
+ if (tag !== 18) {
14995
+ break;
14996
+ }
14997
+ message.invoiceStatuses.push(InvoiceResponse.decode(reader, reader.uint32()));
14998
+ continue;
14999
+ }
15000
+ }
15001
+ if ((tag & 7) === 4 || tag === 0) {
15002
+ break;
15003
+ }
15004
+ reader.skip(tag & 7);
15005
+ }
15006
+ return message;
15007
+ },
15008
+ fromJSON(object) {
15009
+ return {
15010
+ offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
15011
+ invoiceStatuses: globalThis.Array.isArray(object?.invoiceStatuses) ? object.invoiceStatuses.map((e) => InvoiceResponse.fromJSON(e)) : []
15012
+ };
15013
+ },
15014
+ toJSON(message) {
15015
+ const obj = {};
15016
+ if (message.offset !== 0) {
15017
+ obj.offset = Math.round(message.offset);
15018
+ }
15019
+ if (message.invoiceStatuses?.length) {
15020
+ obj.invoiceStatuses = message.invoiceStatuses.map((e) => InvoiceResponse.toJSON(e));
15021
+ }
15022
+ return obj;
15023
+ },
15024
+ create(base) {
15025
+ return QuerySparkInvoicesResponse.fromPartial(base ?? {});
15026
+ },
15027
+ fromPartial(object) {
15028
+ const message = createBaseQuerySparkInvoicesResponse();
15029
+ message.offset = object.offset ?? 0;
15030
+ message.invoiceStatuses = object.invoiceStatuses?.map((e) => InvoiceResponse.fromPartial(e)) || [];
15031
+ return message;
15032
+ }
15033
+ };
15034
+ function createBaseInvoiceResponse() {
15035
+ return { invoice: "", status: 0 };
15036
+ }
15037
+ var InvoiceResponse = {
15038
+ encode(message, writer = new import_wire4.BinaryWriter()) {
15039
+ if (message.invoice !== "") {
15040
+ writer.uint32(10).string(message.invoice);
15041
+ }
15042
+ if (message.status !== 0) {
15043
+ writer.uint32(16).int32(message.status);
15044
+ }
15045
+ return writer;
15046
+ },
15047
+ decode(input, length) {
15048
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
15049
+ const end = length === void 0 ? reader.len : reader.pos + length;
15050
+ const message = createBaseInvoiceResponse();
15051
+ while (reader.pos < end) {
15052
+ const tag = reader.uint32();
15053
+ switch (tag >>> 3) {
15054
+ case 1: {
15055
+ if (tag !== 10) {
15056
+ break;
15057
+ }
15058
+ message.invoice = reader.string();
15059
+ continue;
15060
+ }
15061
+ case 2: {
15062
+ if (tag !== 16) {
15063
+ break;
15064
+ }
15065
+ message.status = reader.int32();
15066
+ continue;
15067
+ }
15068
+ }
15069
+ if ((tag & 7) === 4 || tag === 0) {
15070
+ break;
15071
+ }
15072
+ reader.skip(tag & 7);
15073
+ }
15074
+ return message;
15075
+ },
15076
+ fromJSON(object) {
15077
+ return {
15078
+ invoice: isSet3(object.invoice) ? globalThis.String(object.invoice) : "",
15079
+ status: isSet3(object.status) ? invoiceStatusFromJSON(object.status) : 0
15080
+ };
15081
+ },
15082
+ toJSON(message) {
15083
+ const obj = {};
15084
+ if (message.invoice !== "") {
15085
+ obj.invoice = message.invoice;
15086
+ }
15087
+ if (message.status !== 0) {
15088
+ obj.status = invoiceStatusToJSON(message.status);
15089
+ }
15090
+ return obj;
15091
+ },
15092
+ create(base) {
15093
+ return InvoiceResponse.fromPartial(base ?? {});
15094
+ },
15095
+ fromPartial(object) {
15096
+ const message = createBaseInvoiceResponse();
15097
+ message.invoice = object.invoice ?? "";
15098
+ message.status = object.status ?? 0;
15099
+ return message;
15100
+ }
15101
+ };
14652
15102
  var SparkServiceDefinition = {
14653
15103
  name: "SparkService",
14654
15104
  fullName: "spark.SparkService",
@@ -14661,6 +15111,15 @@ var SparkServiceDefinition = {
14661
15111
  responseStream: false,
14662
15112
  options: {}
14663
15113
  },
15114
+ /** Generates a new static deposit address of the user or returns the existing one for the specified network. */
15115
+ generate_static_deposit_address: {
15116
+ name: "generate_static_deposit_address",
15117
+ requestType: GenerateStaticDepositAddressRequest,
15118
+ requestStream: false,
15119
+ responseType: GenerateStaticDepositAddressResponse,
15120
+ responseStream: false,
15121
+ options: {}
15122
+ },
14664
15123
  start_deposit_tree_creation: {
14665
15124
  name: "start_deposit_tree_creation",
14666
15125
  requestType: StartDepositTreeCreationRequest,
@@ -15102,6 +15561,14 @@ var SparkServiceDefinition = {
15102
15561
  responseType: GetUtxosForAddressResponse,
15103
15562
  responseStream: false,
15104
15563
  options: {}
15564
+ },
15565
+ query_spark_invoices: {
15566
+ name: "query_spark_invoices",
15567
+ requestType: QuerySparkInvoicesRequest,
15568
+ requestStream: false,
15569
+ responseType: QuerySparkInvoicesResponse,
15570
+ responseStream: false,
15571
+ options: {}
15105
15572
  }
15106
15573
  }
15107
15574
  };
@@ -15171,13 +15638,13 @@ var import_sha2 = require("@noble/hashes/sha2");
15171
15638
  // src/utils/adaptor-signature.ts
15172
15639
  init_buffer();
15173
15640
  var import_modular = require("@noble/curves/abstract/modular");
15174
- var import_utils4 = require("@noble/curves/abstract/utils");
15175
15641
  var import_secp256k12 = require("@noble/curves/secp256k1");
15642
+ var import_utils4 = require("@noble/curves/utils");
15176
15643
 
15177
15644
  // src/utils/bitcoin.ts
15178
15645
  init_buffer();
15179
- var import_utils5 = require("@noble/curves/abstract/utils");
15180
15646
  var import_secp256k13 = require("@noble/curves/secp256k1");
15647
+ var import_utils5 = require("@noble/curves/utils");
15181
15648
  var import_sha22 = require("@noble/hashes/sha2");
15182
15649
  var btc2 = __toESM(require("@scure/btc-signer"), 1);
15183
15650
 
@@ -15294,8 +15761,8 @@ function getTxId(tx) {
15294
15761
 
15295
15762
  // src/utils/keys.ts
15296
15763
  init_buffer();
15297
- var import_utils6 = require("@noble/curves/abstract/utils");
15298
15764
  var import_secp256k14 = require("@noble/curves/secp256k1");
15765
+ var import_utils6 = require("@noble/curves/utils");
15299
15766
  function subtractPublicKeys(a, b) {
15300
15767
  if (a.length !== 33 || b.length !== 33) {
15301
15768
  throw new ValidationError("Public keys must be 33 bytes", {
@@ -16111,7 +16578,7 @@ fragment UserRequestFragment on UserRequest {
16111
16578
 
16112
16579
  // src/types/sdk-types.ts
16113
16580
  init_buffer();
16114
- var import_utils7 = require("@noble/curves/abstract/utils");
16581
+ var import_utils7 = require("@noble/curves/utils");
16115
16582
 
16116
16583
  // src/utils/fetch.ts
16117
16584
  init_buffer();
@@ -16154,8 +16621,8 @@ init_buffer();
16154
16621
 
16155
16622
  // src/utils/secret-sharing.ts
16156
16623
  init_buffer();
16157
- var import_utils8 = require("@noble/curves/abstract/utils");
16158
16624
  var import_secp256k15 = require("@noble/curves/secp256k1");
16625
+ var import_utils8 = require("@noble/curves/utils");
16159
16626
  function getRandomBigInt(max) {
16160
16627
  const byteLength = max.toString(2).length + 7 >> 3;
16161
16628
  const maxBigInt = max;
@@ -16257,12 +16724,11 @@ var import_base3 = require("@scure/base");
16257
16724
 
16258
16725
  // src/utils/token-transactions.ts
16259
16726
  init_buffer();
16260
- var import_utils9 = require("@noble/curves/abstract/utils");
16261
- var import_utils10 = require("@scure/btc-signer/utils");
16727
+ var import_utils9 = require("@noble/curves/utils");
16262
16728
 
16263
16729
  // src/utils/transfer_package.ts
16264
16730
  init_buffer();
16265
- var import_utils11 = require("@noble/curves/abstract/utils");
16731
+ var import_utils10 = require("@noble/curves/utils");
16266
16732
  var import_sha24 = require("@noble/hashes/sha2");
16267
16733
 
16268
16734
  // src/utils/transaction.ts
@@ -16394,7 +16860,7 @@ function getEphemeralAnchorOutput() {
16394
16860
 
16395
16861
  // src/utils/unilateral-exit.ts
16396
16862
  init_buffer();
16397
- var import_utils12 = require("@noble/curves/abstract/utils");
16863
+ var import_utils11 = require("@noble/curves/utils");
16398
16864
  var import_legacy = require("@noble/hashes/legacy");
16399
16865
  var import_sha25 = require("@noble/hashes/sha2");
16400
16866
  var btc3 = __toESM(require("@scure/btc-signer"), 1);
@@ -16417,13 +16883,13 @@ init_logging();
16417
16883
  // src/signer/signer.ts
16418
16884
  init_buffer();
16419
16885
  var import_secp256k17 = require("@bitcoinerlab/secp256k1");
16420
- var import_utils14 = require("@noble/curves/abstract/utils");
16421
16886
  var import_secp256k18 = require("@noble/curves/secp256k1");
16887
+ var import_utils13 = require("@noble/curves/utils");
16422
16888
  var import_sha26 = require("@noble/hashes/sha2");
16423
16889
  var import_bip32 = require("@scure/bip32");
16424
16890
  var import_bip39 = require("@scure/bip39");
16425
16891
  var import_english = require("@scure/bip39/wordlists/english");
16426
- var import_utils15 = require("@scure/btc-signer/utils");
16892
+ var import_utils14 = require("@scure/btc-signer/utils");
16427
16893
  var ecies = __toESM(require("eciesjs"), 1);
16428
16894
 
16429
16895
  // src/constants.ts
@@ -16431,7 +16897,7 @@ init_buffer();
16431
16897
  var import_core9 = require("@lightsparkdev/core");
16432
16898
  var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
16433
16899
  var isBun = globalThis.Bun !== void 0;
16434
- var packageVersion = true ? "0.2.11" : "unknown";
16900
+ var packageVersion = true ? "0.2.13" : "unknown";
16435
16901
  var baseEnvStr = "unknown";
16436
16902
  if (isBun) {
16437
16903
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
@@ -16542,7 +17008,7 @@ var DefaultSparkSigner = class {
16542
17008
  });
16543
17009
  }
16544
17010
  const receiverEciesPrivKey = ecies.PrivateKey.fromHex(
16545
- (0, import_utils14.bytesToHex)(this.identityKey.privateKey)
17011
+ (0, import_utils13.bytesToHex)(this.identityKey.privateKey)
16546
17012
  );
16547
17013
  const privateKey = ecies.decrypt(receiverEciesPrivKey.toHex(), ciphertext);
16548
17014
  return privateKey;
@@ -16676,7 +17142,7 @@ var DefaultSparkSigner = class {
16676
17142
  threshold,
16677
17143
  numShares
16678
17144
  }) {
16679
- const secretAsInt = (0, import_utils14.bytesToNumberBE)(secret);
17145
+ const secretAsInt = (0, import_utils13.bytesToNumberBE)(secret);
16680
17146
  return splitSecretWithProofs(secretAsInt, curveOrder, threshold, numShares);
16681
17147
  }
16682
17148
  async signFrost({
@@ -16712,7 +17178,7 @@ var DefaultSparkSigner = class {
16712
17178
  publicKey,
16713
17179
  verifyingKey
16714
17180
  };
16715
- const logMessage = (0, import_utils14.bytesToHex)(message);
17181
+ const logMessage = (0, import_utils13.bytesToHex)(message);
16716
17182
  const result = await SparkFrost.signFrost({
16717
17183
  message,
16718
17184
  keyPackage,
@@ -16754,7 +17220,7 @@ var DefaultSparkSigner = class {
16754
17220
  }
16755
17221
  async createSparkWalletFromSeed(seed, accountNumber) {
16756
17222
  if (typeof seed === "string") {
16757
- seed = (0, import_utils14.hexToBytes)(seed);
17223
+ seed = (0, import_utils13.hexToBytes)(seed);
16758
17224
  }
16759
17225
  const {
16760
17226
  identityKey,
@@ -16766,7 +17232,7 @@ var DefaultSparkSigner = class {
16766
17232
  this.depositKey = depositKey;
16767
17233
  this.signingKey = signingKey.hdKey;
16768
17234
  this.staticDepositKey = staticDepositKey.hdKey;
16769
- return (0, import_utils14.bytesToHex)(identityKey.publicKey);
17235
+ return (0, import_utils13.bytesToHex)(identityKey.publicKey);
16770
17236
  }
16771
17237
  async signMessageWithIdentityKey(message, compact) {
16772
17238
  if (!this.identityKey?.privateKey) {
@@ -16787,7 +17253,7 @@ var DefaultSparkSigner = class {
16787
17253
  });
16788
17254
  }
16789
17255
  const receiverEciesPrivKey = ecies.PrivateKey.fromHex(
16790
- (0, import_utils14.bytesToHex)(this.identityKey.privateKey)
17256
+ (0, import_utils13.bytesToHex)(this.identityKey.privateKey)
16791
17257
  );
16792
17258
  const privateKey = ecies.decrypt(receiverEciesPrivKey.toHex(), ciphertext);
16793
17259
  const publicKey = import_secp256k18.secp256k1.getPublicKey(privateKey);
@@ -16811,15 +17277,15 @@ var DefaultSparkSigner = class {
16811
17277
  }
16812
17278
  signTransactionIndex(tx, index, publicKey) {
16813
17279
  let privateKey;
16814
- if ((0, import_utils14.equalBytes)(publicKey, this.identityKey?.publicKey ?? new Uint8Array())) {
17280
+ if ((0, import_utils13.equalBytes)(publicKey, this.identityKey?.publicKey ?? new Uint8Array())) {
16815
17281
  privateKey = this.identityKey?.privateKey;
16816
- } else if ((0, import_utils14.equalBytes)(publicKey, this.depositKey?.publicKey ?? new Uint8Array())) {
17282
+ } else if ((0, import_utils13.equalBytes)(publicKey, this.depositKey?.publicKey ?? new Uint8Array())) {
16817
17283
  privateKey = this.depositKey?.privateKey;
16818
17284
  }
16819
17285
  if (!privateKey) {
16820
17286
  throw new ValidationError("Private key not found for public key", {
16821
17287
  field: "privateKey",
16822
- value: (0, import_utils14.bytesToHex)(publicKey)
17288
+ value: (0, import_utils13.bytesToHex)(publicKey)
16823
17289
  });
16824
17290
  }
16825
17291
  tx.signIdx(privateKey, index);
@@ -16890,8 +17356,8 @@ init_buffer();
16890
17356
  // src/spark-wallet/spark-wallet.ts
16891
17357
  init_buffer();
16892
17358
  var import_core13 = require("@lightsparkdev/core");
16893
- var import_utils25 = require("@noble/curves/abstract/utils");
16894
17359
  var import_secp256k115 = require("@noble/curves/secp256k1");
17360
+ var import_utils24 = require("@noble/curves/utils");
16895
17361
  var import_bip392 = require("@scure/bip39");
16896
17362
  var import_english2 = require("@scure/bip39/wordlists/english");
16897
17363
  var import_btc_signer6 = require("@scure/btc-signer");
@@ -21668,8 +22134,8 @@ var import_uuidv73 = require("uuidv7");
21668
22134
 
21669
22135
  // src/services/transfer.ts
21670
22136
  init_buffer();
21671
- var import_utils16 = require("@noble/curves/abstract/utils");
21672
22137
  var import_secp256k19 = require("@noble/curves/secp256k1");
22138
+ var import_utils15 = require("@noble/curves/utils");
21673
22139
  var import_sha29 = require("@noble/hashes/sha2");
21674
22140
  var import_btc_signer2 = require("@scure/btc-signer");
21675
22141
  var ecies2 = __toESM(require("eciesjs"), 1);
@@ -21680,9 +22146,9 @@ var DEFAULT_EXPIRY_TIME = 10 * 60 * 1e3;
21680
22146
  init_buffer();
21681
22147
  var import_secp256k110 = require("@noble/curves/secp256k1");
21682
22148
  var import_sha210 = require("@noble/hashes/sha2");
21683
- var import_utils17 = require("@noble/hashes/utils");
22149
+ var import_utils16 = require("@noble/hashes/utils");
21684
22150
  var import_btc_signer4 = require("@scure/btc-signer");
21685
- var import_utils18 = require("@scure/btc-signer/utils");
22151
+ var import_utils17 = require("@scure/btc-signer/utils");
21686
22152
  var DepositService = class {
21687
22153
  config;
21688
22154
  connectionManager;
@@ -21692,7 +22158,8 @@ var DepositService = class {
21692
22158
  }
21693
22159
  async validateDepositAddress({
21694
22160
  address: address2,
21695
- userPubkey
22161
+ userPubkey,
22162
+ verifyCoordinatorProof = false
21696
22163
  }) {
21697
22164
  if (!address2.depositAddressProof || !address2.depositAddressProof.proofOfPossessionSignature || !address2.depositAddressProof.addressSignatures) {
21698
22165
  throw new ValidationError(
@@ -21730,10 +22197,10 @@ var DepositService = class {
21730
22197
  }
21731
22198
  const addrHash = (0, import_sha210.sha256)(address2.address);
21732
22199
  for (const operator of Object.values(this.config.getSigningOperators())) {
21733
- if (operator.identifier === this.config.getCoordinatorIdentifier()) {
22200
+ if (operator.identifier === this.config.getCoordinatorIdentifier() && !verifyCoordinatorProof) {
21734
22201
  continue;
21735
22202
  }
21736
- const operatorPubkey2 = (0, import_utils17.hexToBytes)(operator.identityPublicKey);
22203
+ const operatorPubkey2 = (0, import_utils16.hexToBytes)(operator.identityPublicKey);
21737
22204
  const operatorSig = address2.depositAddressProof.addressSignatures[operator.identifier];
21738
22205
  if (!operatorSig) {
21739
22206
  throw new ValidationError("Operator signature not found", {
@@ -21755,6 +22222,46 @@ var DepositService = class {
21755
22222
  }
21756
22223
  }
21757
22224
  }
22225
+ async generateStaticDepositAddress({
22226
+ signingPubkey
22227
+ }) {
22228
+ const sparkClient = await this.connectionManager.createSparkClient(
22229
+ this.config.getCoordinatorAddress()
22230
+ );
22231
+ let depositResp;
22232
+ try {
22233
+ depositResp = await sparkClient.generate_static_deposit_address({
22234
+ signingPublicKey: signingPubkey,
22235
+ identityPublicKey: await this.config.signer.getIdentityPublicKey(),
22236
+ network: this.config.getNetworkProto()
22237
+ });
22238
+ } catch (error) {
22239
+ throw new NetworkError(
22240
+ "Failed to generate static deposit address",
22241
+ {
22242
+ operation: "generate_static_deposit_address",
22243
+ errorCount: 1,
22244
+ errors: error instanceof Error ? error.message : String(error)
22245
+ },
22246
+ error
22247
+ );
22248
+ }
22249
+ if (!depositResp.depositAddress) {
22250
+ throw new ValidationError(
22251
+ "No static deposit address response from coordinator",
22252
+ {
22253
+ field: "depositAddress",
22254
+ value: depositResp
22255
+ }
22256
+ );
22257
+ }
22258
+ await this.validateDepositAddress({
22259
+ address: depositResp.depositAddress,
22260
+ userPubkey: signingPubkey,
22261
+ verifyCoordinatorProof: true
22262
+ });
22263
+ return depositResp;
22264
+ }
21758
22265
  async generateDepositAddress({
21759
22266
  signingPubkey,
21760
22267
  leafId,
@@ -21822,7 +22329,7 @@ var DepositService = class {
21822
22329
  });
21823
22330
  }
21824
22331
  const depositOutPoint = {
21825
- txid: (0, import_utils17.hexToBytes)(getTxId(depositTx)),
22332
+ txid: (0, import_utils16.hexToBytes)(getTxId(depositTx)),
21826
22333
  index: vout
21827
22334
  };
21828
22335
  const depositTxOut = {
@@ -21841,8 +22348,8 @@ var DepositService = class {
21841
22348
  const { cpfpRefundTx, directRefundTx, directFromCpfpRefundTx } = createRefundTxs({
21842
22349
  sequence: INITIAL_SEQUENCE,
21843
22350
  directSequence: INITIAL_DIRECT_SEQUENCE,
21844
- input: { txid: (0, import_utils17.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
21845
- directInput: { txid: (0, import_utils17.hexToBytes)(getTxId(directRootTx)), index: 0 },
22351
+ input: { txid: (0, import_utils16.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
22352
+ directInput: { txid: (0, import_utils16.hexToBytes)(getTxId(directRootTx)), index: 0 },
21846
22353
  amountSats: amount,
21847
22354
  receivingPubkey: signingPubKey,
21848
22355
  network: this.config.getNetwork()
@@ -21972,7 +22479,7 @@ var DepositService = class {
21972
22479
  }
21973
22480
  );
21974
22481
  }
21975
- if (!(0, import_utils18.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
22482
+ if (!(0, import_utils17.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
21976
22483
  throw new ValidationError("Verifying key mismatch", {
21977
22484
  field: "verifyingKey",
21978
22485
  value: treeResp.rootNodeSignatureShares.verifyingKey,
@@ -22136,7 +22643,7 @@ var DepositService = class {
22136
22643
  });
22137
22644
  }
22138
22645
  const depositOutPoint = {
22139
- txid: (0, import_utils17.hexToBytes)(getTxId(depositTx)),
22646
+ txid: (0, import_utils16.hexToBytes)(getTxId(depositTx)),
22140
22647
  index: vout
22141
22648
  };
22142
22649
  const depositTxOut = {
@@ -22149,7 +22656,7 @@ var DepositService = class {
22149
22656
  const signingPubKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
22150
22657
  const { cpfpRefundTx } = createRefundTxs({
22151
22658
  sequence: INITIAL_SEQUENCE,
22152
- input: { txid: (0, import_utils17.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
22659
+ input: { txid: (0, import_utils16.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
22153
22660
  amountSats: amount,
22154
22661
  receivingPubkey: signingPubKey,
22155
22662
  network: this.config.getNetwork()
@@ -22219,7 +22726,7 @@ var DepositService = class {
22219
22726
  }
22220
22727
  );
22221
22728
  }
22222
- if (!(0, import_utils18.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
22729
+ if (!(0, import_utils17.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
22223
22730
  throw new ValidationError("Verifying key mismatch", {
22224
22731
  field: "verifyingKey",
22225
22732
  value: treeResp.rootNodeSignatureShares.verifyingKey,
@@ -22295,8 +22802,8 @@ var DepositService = class {
22295
22802
 
22296
22803
  // src/services/lightning.ts
22297
22804
  init_buffer();
22298
- var import_utils19 = require("@noble/curves/abstract/utils");
22299
22805
  var import_secp256k111 = require("@noble/curves/secp256k1");
22806
+ var import_utils18 = require("@noble/curves/utils");
22300
22807
  var import_sha211 = require("@noble/hashes/sha2");
22301
22808
  var import_uuidv74 = require("uuidv7");
22302
22809
 
@@ -22306,9 +22813,9 @@ var import_light_bolt11_decoder = require("light-bolt11-decoder");
22306
22813
 
22307
22814
  // src/services/token-transactions.ts
22308
22815
  init_buffer();
22309
- var import_utils20 = require("@noble/curves/abstract/utils");
22310
22816
  var import_secp256k113 = require("@noble/curves/secp256k1");
22311
- var import_utils21 = require("@noble/hashes/utils");
22817
+ var import_utils19 = require("@noble/curves/utils");
22818
+ var import_utils20 = require("@noble/hashes/utils");
22312
22819
 
22313
22820
  // src/utils/token-hashing.ts
22314
22821
  init_buffer();
@@ -22331,19 +22838,19 @@ var import_nice_grpc_common3 = require("nice-grpc-common");
22331
22838
 
22332
22839
  // src/services/signing.ts
22333
22840
  init_buffer();
22334
- var import_utils22 = require("@noble/curves/abstract/utils");
22841
+ var import_utils21 = require("@noble/curves/utils");
22335
22842
 
22336
22843
  // src/tests/utils/test-faucet.ts
22337
22844
  init_buffer();
22338
- var import_utils23 = require("@noble/curves/abstract/utils");
22339
22845
  var import_secp256k114 = require("@noble/curves/secp256k1");
22846
+ var import_utils22 = require("@noble/curves/utils");
22340
22847
  var btc5 = __toESM(require("@scure/btc-signer"), 1);
22341
22848
  var import_btc_signer5 = require("@scure/btc-signer");
22342
- var import_utils24 = require("@scure/btc-signer/utils");
22343
- var STATIC_FAUCET_KEY = (0, import_utils23.hexToBytes)(
22849
+ var import_utils23 = require("@scure/btc-signer/utils");
22850
+ var STATIC_FAUCET_KEY = (0, import_utils22.hexToBytes)(
22344
22851
  "deadbeef1337cafe4242424242424242deadbeef1337cafe4242424242424242"
22345
22852
  );
22346
- var STATIC_MINING_KEY = (0, import_utils23.hexToBytes)(
22853
+ var STATIC_MINING_KEY = (0, import_utils22.hexToBytes)(
22347
22854
  "1337cafe4242deadbeef4242424242421337cafe4242deadbeef424242424242"
22348
22855
  );
22349
22856
  var SATS_PER_BTC = 1e8;
@@ -22406,7 +22913,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
22406
22913
  if (!scanResult.success || scanResult.unspents.length === 0) {
22407
22914
  const blockHash = await this.generateToAddress(1, address2);
22408
22915
  const block = await this.getBlock(blockHash[0]);
22409
- const fundingTx = import_btc_signer5.Transaction.fromRaw((0, import_utils23.hexToBytes)(block.tx[0].hex), {
22916
+ const fundingTx = import_btc_signer5.Transaction.fromRaw((0, import_utils22.hexToBytes)(block.tx[0].hex), {
22410
22917
  allowUnknownOutputs: true
22411
22918
  });
22412
22919
  await this.generateToAddress(100, this.miningAddress);
@@ -22468,13 +22975,13 @@ var BitcoinFaucet = class _BitcoinFaucet {
22468
22975
  },
22469
22976
  STATIC_MINING_KEY
22470
22977
  );
22471
- await this.broadcastTx((0, import_utils23.bytesToHex)(signedSplitTx.extract()));
22978
+ await this.broadcastTx((0, import_utils22.bytesToHex)(signedSplitTx.extract()));
22472
22979
  const splitTxId = signedSplitTx.id;
22473
22980
  for (let i = 0; i < numCoinsToCreate; i++) {
22474
22981
  this.coins.push({
22475
22982
  key: STATIC_FAUCET_KEY,
22476
22983
  outpoint: {
22477
- txid: (0, import_utils23.hexToBytes)(splitTxId),
22984
+ txid: (0, import_utils22.hexToBytes)(splitTxId),
22478
22985
  index: i
22479
22986
  },
22480
22987
  txout: signedSplitTx.getOutput(i)
@@ -22502,7 +23009,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
22502
23009
  coinToSend.txout,
22503
23010
  coinToSend.key
22504
23011
  );
22505
- await this.broadcastTx((0, import_utils23.bytesToHex)(signedTx.extract()));
23012
+ await this.broadcastTx((0, import_utils22.bytesToHex)(signedTx.extract()));
22506
23013
  }
22507
23014
  async signFaucetCoin(unsignedTx, fundingTxOut, key) {
22508
23015
  const pubKey = import_secp256k114.secp256k1.getPublicKey(key);
@@ -22522,7 +23029,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
22522
23029
  new Array(unsignedTx.inputsLength).fill(fundingTxOut.amount)
22523
23030
  );
22524
23031
  const merkleRoot = new Uint8Array();
22525
- const tweakedKey = (0, import_utils24.taprootTweakPrivKey)(key, merkleRoot);
23032
+ const tweakedKey = (0, import_utils23.taprootTweakPrivKey)(key, merkleRoot);
22526
23033
  if (!tweakedKey)
22527
23034
  throw new Error("Invalid private key for taproot tweaking");
22528
23035
  const signature = import_secp256k114.schnorr.sign(sighash, tweakedKey);
@@ -22622,7 +23129,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
22622
23129
  });
22623
23130
  }
22624
23131
  const signedTx = await this.signFaucetCoin(tx, coin.txout, coin.key);
22625
- const txHex = (0, import_utils23.bytesToHex)(signedTx.extract());
23132
+ const txHex = (0, import_utils22.bytesToHex)(signedTx.extract());
22626
23133
  await this.broadcastTx(txHex);
22627
23134
  const randomKey = import_secp256k114.secp256k1.utils.randomPrivateKey();
22628
23135
  const randomPubKey = import_secp256k114.secp256k1.getPublicKey(randomKey);