@buildonspark/spark-sdk 0.2.10 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -1
- package/dist/bare/chunk-P6AVV7VD.js +34 -0
- package/dist/bare/index.cjs +729 -166
- package/dist/bare/index.d.cts +62 -5
- package/dist/bare/index.d.ts +62 -5
- package/dist/bare/index.js +675 -173
- package/dist/bare/{wasm-OPXXYRN5.js → wasm-F5QFVBNZ.js} +26 -0
- package/dist/bare/{xhr-transport-6GYJAFWU.js → xhr-transport-EEEC7FYA.js} +2 -2
- package/dist/{chunk-A5M55UR3.js → chunk-5VWGOHED.js} +499 -8
- package/dist/{chunk-MWBK6QBF.js → chunk-NQMQVXR5.js} +1 -1
- package/dist/chunk-NX5KPN5F.js +34 -0
- package/dist/{chunk-JXLWOQK5.js → chunk-OEK3R57K.js} +196 -162
- package/dist/{chunk-76SYPHOC.js → chunk-TB7DG5CU.js} +2 -2
- package/dist/{chunk-6CMNEDBK.js → chunk-XXTWWW6L.js} +1 -1
- package/dist/{client-Dd3QnxQu.d.ts → client-D7KDa4Ih.d.ts} +1 -1
- package/dist/{client-B9CAWKWz.d.cts → client-DVuA5-7M.d.cts} +1 -1
- package/dist/debug.cjs +725 -163
- package/dist/debug.d.cts +8 -5
- package/dist/debug.d.ts +8 -5
- package/dist/debug.js +5 -4
- package/dist/graphql/objects/index.d.cts +3 -3
- package/dist/graphql/objects/index.d.ts +3 -3
- package/dist/index.cjs +810 -246
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +11 -5
- package/dist/index.node.cjs +810 -246
- package/dist/index.node.d.cts +6 -6
- package/dist/index.node.d.ts +6 -6
- package/dist/index.node.js +10 -4
- package/dist/{xchain-address-BPwpnmuY.d.ts → logging-ClNhGzus.d.ts} +18 -4
- package/dist/{xchain-address-CNQEwLjR.d.cts → logging-D3kvES69.d.cts} +18 -4
- package/dist/native/chunk-D3SZRO65.js +36 -0
- package/dist/native/index.cjs +808 -244
- package/dist/native/index.d.cts +62 -5
- package/dist/native/index.d.ts +62 -5
- package/dist/native/index.js +769 -268
- package/dist/native/{wasm-2KV6XFEP.js → wasm-3YAXKQ7F.js} +25 -0
- package/dist/native/{xhr-transport-WHMS3FGG.js → xhr-transport-TNCG4HTW.js} +2 -2
- package/dist/proto/spark.cjs +499 -8
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark.js +17 -1
- package/dist/proto/spark_token.d.cts +1 -1
- package/dist/proto/spark_token.d.ts +1 -1
- package/dist/proto/spark_token.js +2 -2
- package/dist/{spark-CtGJPkx4.d.cts → spark-C7OG9mGJ.d.cts} +79 -2
- package/dist/{spark-CtGJPkx4.d.ts → spark-C7OG9mGJ.d.ts} +79 -2
- package/dist/{spark-wallet-yc2KhsVY.d.cts → spark-wallet-Dg5IRQe2.d.cts} +3 -5
- package/dist/{spark-wallet-Cp3yv6cK.d.ts → spark-wallet-DiHSU-pz.d.ts} +3 -5
- package/dist/{spark-wallet.node-D4IovOHu.d.ts → spark-wallet.node-BZrxwomN.d.ts} +1 -1
- package/dist/{spark-wallet.node-D0Qw5Wb4.d.cts → spark-wallet.node-DSWb18zh.d.cts} +1 -1
- package/dist/spark_bindings/wasm/index.cjs +51 -0
- package/dist/spark_bindings/wasm/index.js +25 -0
- package/dist/tests/test-utils.cjs +725 -155
- package/dist/tests/test-utils.d.cts +4 -4
- package/dist/tests/test-utils.d.ts +4 -4
- package/dist/tests/test-utils.js +6 -5
- package/dist/{token-transactions-CwhlOgIP.d.cts → token-transactions-B-WqFYpW.d.cts} +2 -2
- package/dist/{token-transactions-0nmR9mQO.d.ts → token-transactions-DovxHIxV.d.ts} +2 -2
- package/dist/types/index.cjs +492 -9
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +2 -2
- package/dist/{xhr-transport-RH6LDRXS.js → xhr-transport-IWJPYF7F.js} +2 -2
- package/package.json +1 -1
- package/src/proto/common.ts +1 -1
- package/src/proto/google/protobuf/descriptor.ts +4 -10
- package/src/proto/google/protobuf/duration.ts +1 -1
- package/src/proto/google/protobuf/empty.ts +1 -1
- package/src/proto/google/protobuf/timestamp.ts +1 -1
- package/src/proto/mock.ts +1 -1
- package/src/proto/spark.ts +593 -3
- package/src/proto/spark_authn.ts +1 -1
- package/src/proto/spark_token.ts +1 -1
- package/src/proto/validate/validate.ts +27 -79
- package/src/services/deposit.ts +60 -4
- package/src/services/lightning.ts +2 -2
- package/src/services/signing.ts +1 -1
- package/src/services/token-transactions.ts +2 -5
- package/src/services/transfer.ts +2 -2
- package/src/services/xhr-transport.ts +2 -2
- package/src/signer/signer.ts +2 -2
- package/src/spark-wallet/spark-wallet.ts +25 -33
- package/src/spark_bindings/wasm/index.ts +21 -0
- package/src/tests/address.test.ts +10 -10
- package/src/tests/bitcoin.test.ts +2 -2
- package/src/tests/integration/coop-exit.test.ts +1 -1
- package/src/tests/integration/lightning.test.ts +1 -1
- package/src/tests/integration/ssp/coop-exit-validation.test.ts +2 -2
- package/src/tests/integration/ssp/static_deposit.test.ts +122 -33
- package/src/tests/integration/swap.test.ts +1 -1
- package/src/tests/integration/transfer.test.ts +1 -5
- package/src/tests/integration/wallet.test.ts +7 -7
- package/src/tests/integration/watchtower.test.ts +3 -3
- package/src/tests/token-hashing.test.ts +3 -6
- package/src/tests/token-outputs.test.ts +3 -3
- package/src/tests/utils/test-faucet.ts +2 -2
- package/src/types/sdk-types.ts +1 -1
- package/src/utils/adaptor-signature.ts +12 -13
- package/src/utils/address.ts +10 -10
- package/src/utils/bitcoin.ts +7 -11
- package/src/utils/index.ts +1 -0
- package/src/utils/keys.ts +10 -10
- package/src/utils/logging.ts +40 -0
- package/src/utils/secret-sharing.ts +10 -12
- package/src/utils/token-transactions.ts +1 -2
- package/src/utils/transfer_package.ts +1 -1
- package/src/utils/unilateral-exit.ts +1 -1
package/dist/bare/index.cjs
CHANGED
|
@@ -1022,6 +1022,42 @@ var init_spark_bindings = __esm({
|
|
|
1022
1022
|
}
|
|
1023
1023
|
});
|
|
1024
1024
|
|
|
1025
|
+
// src/utils/logging.ts
|
|
1026
|
+
var import_core11, LOGGER_NAMES, SparkSdkLogger;
|
|
1027
|
+
var init_logging = __esm({
|
|
1028
|
+
"src/utils/logging.ts"() {
|
|
1029
|
+
"use strict";
|
|
1030
|
+
import_core11 = require("@lightsparkdev/core");
|
|
1031
|
+
LOGGER_NAMES = {
|
|
1032
|
+
wasm: "wasm"
|
|
1033
|
+
};
|
|
1034
|
+
SparkSdkLogger = class {
|
|
1035
|
+
static loggers = /* @__PURE__ */ new Map();
|
|
1036
|
+
static get(name) {
|
|
1037
|
+
if (!this.loggers.has(name)) {
|
|
1038
|
+
this.loggers.set(name, new import_core11.Logger(name));
|
|
1039
|
+
}
|
|
1040
|
+
return this.loggers.get(name);
|
|
1041
|
+
}
|
|
1042
|
+
static setLevel(name, level) {
|
|
1043
|
+
this.get(name).setLevel(level);
|
|
1044
|
+
}
|
|
1045
|
+
static setAllLevels(level) {
|
|
1046
|
+
this.loggers.forEach((logger) => logger.setLevel(level));
|
|
1047
|
+
}
|
|
1048
|
+
static setEnabled(name, enabled) {
|
|
1049
|
+
this.get(name).setEnabled(enabled);
|
|
1050
|
+
}
|
|
1051
|
+
static setAllEnabled(enabled) {
|
|
1052
|
+
this.loggers.forEach((logger) => logger.setEnabled(enabled));
|
|
1053
|
+
}
|
|
1054
|
+
static {
|
|
1055
|
+
Object.values(LOGGER_NAMES).forEach((name) => this.get(name));
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
});
|
|
1060
|
+
|
|
1025
1061
|
// src/spark_bindings/wasm/index.ts
|
|
1026
1062
|
var wasm_exports = {};
|
|
1027
1063
|
__export(wasm_exports, {
|
|
@@ -1052,6 +1088,13 @@ function signFrost({
|
|
|
1052
1088
|
statechainCommitments,
|
|
1053
1089
|
adaptorPubKey
|
|
1054
1090
|
}) {
|
|
1091
|
+
SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("signFrost", {
|
|
1092
|
+
message: (0, import_utils4.bytesToHex)(message),
|
|
1093
|
+
keyPackage,
|
|
1094
|
+
nonce,
|
|
1095
|
+
selfCommitment,
|
|
1096
|
+
statechainCommitments
|
|
1097
|
+
});
|
|
1055
1098
|
return wasm_sign_frost(
|
|
1056
1099
|
message,
|
|
1057
1100
|
createKeyPackage(keyPackage),
|
|
@@ -1072,6 +1115,17 @@ function aggregateFrost({
|
|
|
1072
1115
|
verifyingKey,
|
|
1073
1116
|
adaptorPubKey
|
|
1074
1117
|
}) {
|
|
1118
|
+
SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("aggregateFrost", {
|
|
1119
|
+
message: (0, import_utils4.bytesToHex)(message),
|
|
1120
|
+
statechainCommitments,
|
|
1121
|
+
selfCommitment,
|
|
1122
|
+
statechainSignatures,
|
|
1123
|
+
selfSignature: (0, import_utils4.bytesToHex)(selfSignature),
|
|
1124
|
+
statechainPublicKeys,
|
|
1125
|
+
selfPublicKey: (0, import_utils4.bytesToHex)(selfPublicKey),
|
|
1126
|
+
verifyingKey: (0, import_utils4.bytesToHex)(verifyingKey),
|
|
1127
|
+
adaptorPubKey: adaptorPubKey ? (0, import_utils4.bytesToHex)(adaptorPubKey) : void 0
|
|
1128
|
+
});
|
|
1075
1129
|
return wasm_aggregate_frost(
|
|
1076
1130
|
message,
|
|
1077
1131
|
statechainCommitments,
|
|
@@ -1102,10 +1156,13 @@ function decryptEcies({
|
|
|
1102
1156
|
}) {
|
|
1103
1157
|
return decrypt_ecies(encryptedMsg, privateKey);
|
|
1104
1158
|
}
|
|
1159
|
+
var import_utils4;
|
|
1105
1160
|
var init_wasm = __esm({
|
|
1106
1161
|
"src/spark_bindings/wasm/index.ts"() {
|
|
1107
1162
|
"use strict";
|
|
1163
|
+
import_utils4 = require("@noble/curves/utils");
|
|
1108
1164
|
init_spark_bindings();
|
|
1165
|
+
init_logging();
|
|
1109
1166
|
}
|
|
1110
1167
|
});
|
|
1111
1168
|
|
|
@@ -1179,7 +1236,7 @@ function XHRTransport(config) {
|
|
|
1179
1236
|
bodyBuffer = chunk;
|
|
1180
1237
|
break;
|
|
1181
1238
|
}
|
|
1182
|
-
requestBody = bodyBuffer;
|
|
1239
|
+
requestBody = bodyBuffer.slice();
|
|
1183
1240
|
} else {
|
|
1184
1241
|
let iterator;
|
|
1185
1242
|
requestBody = new ReadableStream({
|
|
@@ -1193,7 +1250,7 @@ function XHRTransport(config) {
|
|
|
1193
1250
|
if (done) {
|
|
1194
1251
|
controller.close();
|
|
1195
1252
|
} else {
|
|
1196
|
-
controller.enqueue(value);
|
|
1253
|
+
controller.enqueue(value.slice());
|
|
1197
1254
|
}
|
|
1198
1255
|
},
|
|
1199
1256
|
async cancel() {
|
|
@@ -1293,6 +1350,7 @@ __export(index_exports, {
|
|
|
1293
1350
|
INITIAL_DIRECT_SEQUENCE: () => INITIAL_DIRECT_SEQUENCE,
|
|
1294
1351
|
INITIAL_SEQUENCE: () => INITIAL_SEQUENCE,
|
|
1295
1352
|
InternalValidationError: () => InternalValidationError,
|
|
1353
|
+
LOGGER_NAMES: () => LOGGER_NAMES,
|
|
1296
1354
|
LRC_WALLET_NETWORK: () => LRC_WALLET_NETWORK,
|
|
1297
1355
|
Network: () => Network2,
|
|
1298
1356
|
NetworkError: () => NetworkError,
|
|
@@ -1300,6 +1358,7 @@ __export(index_exports, {
|
|
|
1300
1358
|
NotImplementedError: () => NotImplementedError,
|
|
1301
1359
|
RPCError: () => RPCError,
|
|
1302
1360
|
SparkSDKError: () => SparkSDKError,
|
|
1361
|
+
SparkSdkLogger: () => SparkSdkLogger,
|
|
1303
1362
|
SparkWallet: () => SparkWalletBrowser,
|
|
1304
1363
|
TEST_UNILATERAL_DIRECT_SEQUENCE: () => TEST_UNILATERAL_DIRECT_SEQUENCE,
|
|
1305
1364
|
TEST_UNILATERAL_SEQUENCE: () => TEST_UNILATERAL_SEQUENCE,
|
|
@@ -1551,9 +1610,9 @@ var NotImplementedError = class extends SparkSDKError {
|
|
|
1551
1610
|
};
|
|
1552
1611
|
|
|
1553
1612
|
// src/spark-wallet/spark-wallet.ts
|
|
1554
|
-
var
|
|
1555
|
-
var import_utils23 = require("@noble/curves/abstract/utils");
|
|
1613
|
+
var import_core13 = require("@lightsparkdev/core");
|
|
1556
1614
|
var import_secp256k115 = require("@noble/curves/secp256k1");
|
|
1615
|
+
var import_utils23 = require("@noble/curves/utils");
|
|
1557
1616
|
var import_bip392 = require("@scure/bip39");
|
|
1558
1617
|
var import_english2 = require("@scure/bip39/wordlists/english");
|
|
1559
1618
|
var import_btc_signer6 = require("@scure/btc-signer");
|
|
@@ -4126,6 +4185,41 @@ function utxoSwapRequestTypeToJSON(object) {
|
|
|
4126
4185
|
return "UNRECOGNIZED";
|
|
4127
4186
|
}
|
|
4128
4187
|
}
|
|
4188
|
+
function invoiceStatusFromJSON(object) {
|
|
4189
|
+
switch (object) {
|
|
4190
|
+
case 0:
|
|
4191
|
+
case "NOT_FOUND":
|
|
4192
|
+
return 0 /* NOT_FOUND */;
|
|
4193
|
+
case 1:
|
|
4194
|
+
case "PENDING":
|
|
4195
|
+
return 1 /* PENDING */;
|
|
4196
|
+
case 2:
|
|
4197
|
+
case "FINALIZED":
|
|
4198
|
+
return 2 /* FINALIZED */;
|
|
4199
|
+
case 3:
|
|
4200
|
+
case "EXPIRED":
|
|
4201
|
+
return 3 /* EXPIRED */;
|
|
4202
|
+
case -1:
|
|
4203
|
+
case "UNRECOGNIZED":
|
|
4204
|
+
default:
|
|
4205
|
+
return -1 /* UNRECOGNIZED */;
|
|
4206
|
+
}
|
|
4207
|
+
}
|
|
4208
|
+
function invoiceStatusToJSON(object) {
|
|
4209
|
+
switch (object) {
|
|
4210
|
+
case 0 /* NOT_FOUND */:
|
|
4211
|
+
return "NOT_FOUND";
|
|
4212
|
+
case 1 /* PENDING */:
|
|
4213
|
+
return "PENDING";
|
|
4214
|
+
case 2 /* FINALIZED */:
|
|
4215
|
+
return "FINALIZED";
|
|
4216
|
+
case 3 /* EXPIRED */:
|
|
4217
|
+
return "EXPIRED";
|
|
4218
|
+
case -1 /* UNRECOGNIZED */:
|
|
4219
|
+
default:
|
|
4220
|
+
return "UNRECOGNIZED";
|
|
4221
|
+
}
|
|
4222
|
+
}
|
|
4129
4223
|
function initiatePreimageSwapRequest_ReasonFromJSON(object) {
|
|
4130
4224
|
switch (object) {
|
|
4131
4225
|
case 0:
|
|
@@ -4865,6 +4959,140 @@ var GenerateDepositAddressResponse = {
|
|
|
4865
4959
|
return message;
|
|
4866
4960
|
}
|
|
4867
4961
|
};
|
|
4962
|
+
function createBaseGenerateStaticDepositAddressRequest() {
|
|
4963
|
+
return { signingPublicKey: new Uint8Array(0), identityPublicKey: new Uint8Array(0), network: 0 };
|
|
4964
|
+
}
|
|
4965
|
+
var GenerateStaticDepositAddressRequest = {
|
|
4966
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
4967
|
+
if (message.signingPublicKey.length !== 0) {
|
|
4968
|
+
writer.uint32(10).bytes(message.signingPublicKey);
|
|
4969
|
+
}
|
|
4970
|
+
if (message.identityPublicKey.length !== 0) {
|
|
4971
|
+
writer.uint32(18).bytes(message.identityPublicKey);
|
|
4972
|
+
}
|
|
4973
|
+
if (message.network !== 0) {
|
|
4974
|
+
writer.uint32(24).int32(message.network);
|
|
4975
|
+
}
|
|
4976
|
+
return writer;
|
|
4977
|
+
},
|
|
4978
|
+
decode(input, length) {
|
|
4979
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
4980
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
4981
|
+
const message = createBaseGenerateStaticDepositAddressRequest();
|
|
4982
|
+
while (reader.pos < end) {
|
|
4983
|
+
const tag = reader.uint32();
|
|
4984
|
+
switch (tag >>> 3) {
|
|
4985
|
+
case 1: {
|
|
4986
|
+
if (tag !== 10) {
|
|
4987
|
+
break;
|
|
4988
|
+
}
|
|
4989
|
+
message.signingPublicKey = reader.bytes();
|
|
4990
|
+
continue;
|
|
4991
|
+
}
|
|
4992
|
+
case 2: {
|
|
4993
|
+
if (tag !== 18) {
|
|
4994
|
+
break;
|
|
4995
|
+
}
|
|
4996
|
+
message.identityPublicKey = reader.bytes();
|
|
4997
|
+
continue;
|
|
4998
|
+
}
|
|
4999
|
+
case 3: {
|
|
5000
|
+
if (tag !== 24) {
|
|
5001
|
+
break;
|
|
5002
|
+
}
|
|
5003
|
+
message.network = reader.int32();
|
|
5004
|
+
continue;
|
|
5005
|
+
}
|
|
5006
|
+
}
|
|
5007
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
5008
|
+
break;
|
|
5009
|
+
}
|
|
5010
|
+
reader.skip(tag & 7);
|
|
5011
|
+
}
|
|
5012
|
+
return message;
|
|
5013
|
+
},
|
|
5014
|
+
fromJSON(object) {
|
|
5015
|
+
return {
|
|
5016
|
+
signingPublicKey: isSet3(object.signingPublicKey) ? bytesFromBase642(object.signingPublicKey) : new Uint8Array(0),
|
|
5017
|
+
identityPublicKey: isSet3(object.identityPublicKey) ? bytesFromBase642(object.identityPublicKey) : new Uint8Array(0),
|
|
5018
|
+
network: isSet3(object.network) ? networkFromJSON(object.network) : 0
|
|
5019
|
+
};
|
|
5020
|
+
},
|
|
5021
|
+
toJSON(message) {
|
|
5022
|
+
const obj = {};
|
|
5023
|
+
if (message.signingPublicKey.length !== 0) {
|
|
5024
|
+
obj.signingPublicKey = base64FromBytes2(message.signingPublicKey);
|
|
5025
|
+
}
|
|
5026
|
+
if (message.identityPublicKey.length !== 0) {
|
|
5027
|
+
obj.identityPublicKey = base64FromBytes2(message.identityPublicKey);
|
|
5028
|
+
}
|
|
5029
|
+
if (message.network !== 0) {
|
|
5030
|
+
obj.network = networkToJSON(message.network);
|
|
5031
|
+
}
|
|
5032
|
+
return obj;
|
|
5033
|
+
},
|
|
5034
|
+
create(base) {
|
|
5035
|
+
return GenerateStaticDepositAddressRequest.fromPartial(base ?? {});
|
|
5036
|
+
},
|
|
5037
|
+
fromPartial(object) {
|
|
5038
|
+
const message = createBaseGenerateStaticDepositAddressRequest();
|
|
5039
|
+
message.signingPublicKey = object.signingPublicKey ?? new Uint8Array(0);
|
|
5040
|
+
message.identityPublicKey = object.identityPublicKey ?? new Uint8Array(0);
|
|
5041
|
+
message.network = object.network ?? 0;
|
|
5042
|
+
return message;
|
|
5043
|
+
}
|
|
5044
|
+
};
|
|
5045
|
+
function createBaseGenerateStaticDepositAddressResponse() {
|
|
5046
|
+
return { depositAddress: void 0 };
|
|
5047
|
+
}
|
|
5048
|
+
var GenerateStaticDepositAddressResponse = {
|
|
5049
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
5050
|
+
if (message.depositAddress !== void 0) {
|
|
5051
|
+
Address.encode(message.depositAddress, writer.uint32(10).fork()).join();
|
|
5052
|
+
}
|
|
5053
|
+
return writer;
|
|
5054
|
+
},
|
|
5055
|
+
decode(input, length) {
|
|
5056
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
5057
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
5058
|
+
const message = createBaseGenerateStaticDepositAddressResponse();
|
|
5059
|
+
while (reader.pos < end) {
|
|
5060
|
+
const tag = reader.uint32();
|
|
5061
|
+
switch (tag >>> 3) {
|
|
5062
|
+
case 1: {
|
|
5063
|
+
if (tag !== 10) {
|
|
5064
|
+
break;
|
|
5065
|
+
}
|
|
5066
|
+
message.depositAddress = Address.decode(reader, reader.uint32());
|
|
5067
|
+
continue;
|
|
5068
|
+
}
|
|
5069
|
+
}
|
|
5070
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
5071
|
+
break;
|
|
5072
|
+
}
|
|
5073
|
+
reader.skip(tag & 7);
|
|
5074
|
+
}
|
|
5075
|
+
return message;
|
|
5076
|
+
},
|
|
5077
|
+
fromJSON(object) {
|
|
5078
|
+
return { depositAddress: isSet3(object.depositAddress) ? Address.fromJSON(object.depositAddress) : void 0 };
|
|
5079
|
+
},
|
|
5080
|
+
toJSON(message) {
|
|
5081
|
+
const obj = {};
|
|
5082
|
+
if (message.depositAddress !== void 0) {
|
|
5083
|
+
obj.depositAddress = Address.toJSON(message.depositAddress);
|
|
5084
|
+
}
|
|
5085
|
+
return obj;
|
|
5086
|
+
},
|
|
5087
|
+
create(base) {
|
|
5088
|
+
return GenerateStaticDepositAddressResponse.fromPartial(base ?? {});
|
|
5089
|
+
},
|
|
5090
|
+
fromPartial(object) {
|
|
5091
|
+
const message = createBaseGenerateStaticDepositAddressResponse();
|
|
5092
|
+
message.depositAddress = object.depositAddress !== void 0 && object.depositAddress !== null ? Address.fromPartial(object.depositAddress) : void 0;
|
|
5093
|
+
return message;
|
|
5094
|
+
}
|
|
5095
|
+
};
|
|
4868
5096
|
function createBaseUTXO() {
|
|
4869
5097
|
return { rawTx: new Uint8Array(0), vout: 0, network: 0, txid: new Uint8Array(0) };
|
|
4870
5098
|
}
|
|
@@ -10978,7 +11206,8 @@ function createBaseTransferLeaf() {
|
|
|
10978
11206
|
signature: new Uint8Array(0),
|
|
10979
11207
|
intermediateRefundTx: new Uint8Array(0),
|
|
10980
11208
|
intermediateDirectRefundTx: new Uint8Array(0),
|
|
10981
|
-
intermediateDirectFromCpfpRefundTx: new Uint8Array(0)
|
|
11209
|
+
intermediateDirectFromCpfpRefundTx: new Uint8Array(0),
|
|
11210
|
+
pendingKeyTweakPublicKey: new Uint8Array(0)
|
|
10982
11211
|
};
|
|
10983
11212
|
}
|
|
10984
11213
|
var TransferLeaf = {
|
|
@@ -11001,6 +11230,9 @@ var TransferLeaf = {
|
|
|
11001
11230
|
if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
|
|
11002
11231
|
writer.uint32(50).bytes(message.intermediateDirectFromCpfpRefundTx);
|
|
11003
11232
|
}
|
|
11233
|
+
if (message.pendingKeyTweakPublicKey.length !== 0) {
|
|
11234
|
+
writer.uint32(58).bytes(message.pendingKeyTweakPublicKey);
|
|
11235
|
+
}
|
|
11004
11236
|
return writer;
|
|
11005
11237
|
},
|
|
11006
11238
|
decode(input, length) {
|
|
@@ -11052,6 +11284,13 @@ var TransferLeaf = {
|
|
|
11052
11284
|
message.intermediateDirectFromCpfpRefundTx = reader.bytes();
|
|
11053
11285
|
continue;
|
|
11054
11286
|
}
|
|
11287
|
+
case 7: {
|
|
11288
|
+
if (tag !== 58) {
|
|
11289
|
+
break;
|
|
11290
|
+
}
|
|
11291
|
+
message.pendingKeyTweakPublicKey = reader.bytes();
|
|
11292
|
+
continue;
|
|
11293
|
+
}
|
|
11055
11294
|
}
|
|
11056
11295
|
if ((tag & 7) === 4 || tag === 0) {
|
|
11057
11296
|
break;
|
|
@@ -11067,7 +11306,8 @@ var TransferLeaf = {
|
|
|
11067
11306
|
signature: isSet3(object.signature) ? bytesFromBase642(object.signature) : new Uint8Array(0),
|
|
11068
11307
|
intermediateRefundTx: isSet3(object.intermediateRefundTx) ? bytesFromBase642(object.intermediateRefundTx) : new Uint8Array(0),
|
|
11069
11308
|
intermediateDirectRefundTx: isSet3(object.intermediateDirectRefundTx) ? bytesFromBase642(object.intermediateDirectRefundTx) : new Uint8Array(0),
|
|
11070
|
-
intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0)
|
|
11309
|
+
intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0),
|
|
11310
|
+
pendingKeyTweakPublicKey: isSet3(object.pendingKeyTweakPublicKey) ? bytesFromBase642(object.pendingKeyTweakPublicKey) : new Uint8Array(0)
|
|
11071
11311
|
};
|
|
11072
11312
|
},
|
|
11073
11313
|
toJSON(message) {
|
|
@@ -11090,6 +11330,9 @@ var TransferLeaf = {
|
|
|
11090
11330
|
if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
|
|
11091
11331
|
obj.intermediateDirectFromCpfpRefundTx = base64FromBytes2(message.intermediateDirectFromCpfpRefundTx);
|
|
11092
11332
|
}
|
|
11333
|
+
if (message.pendingKeyTweakPublicKey.length !== 0) {
|
|
11334
|
+
obj.pendingKeyTweakPublicKey = base64FromBytes2(message.pendingKeyTweakPublicKey);
|
|
11335
|
+
}
|
|
11093
11336
|
return obj;
|
|
11094
11337
|
},
|
|
11095
11338
|
create(base) {
|
|
@@ -11103,6 +11346,7 @@ var TransferLeaf = {
|
|
|
11103
11346
|
message.intermediateRefundTx = object.intermediateRefundTx ?? new Uint8Array(0);
|
|
11104
11347
|
message.intermediateDirectRefundTx = object.intermediateDirectRefundTx ?? new Uint8Array(0);
|
|
11105
11348
|
message.intermediateDirectFromCpfpRefundTx = object.intermediateDirectFromCpfpRefundTx ?? new Uint8Array(0);
|
|
11349
|
+
message.pendingKeyTweakPublicKey = object.pendingKeyTweakPublicKey ?? new Uint8Array(0);
|
|
11106
11350
|
return message;
|
|
11107
11351
|
}
|
|
11108
11352
|
};
|
|
@@ -14000,13 +14244,16 @@ var QueryUserSignedRefundsRequest = {
|
|
|
14000
14244
|
}
|
|
14001
14245
|
};
|
|
14002
14246
|
function createBaseQueryUserSignedRefundsResponse() {
|
|
14003
|
-
return { userSignedRefunds: [] };
|
|
14247
|
+
return { userSignedRefunds: [], transfer: void 0 };
|
|
14004
14248
|
}
|
|
14005
14249
|
var QueryUserSignedRefundsResponse = {
|
|
14006
14250
|
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
14007
14251
|
for (const v of message.userSignedRefunds) {
|
|
14008
14252
|
UserSignedRefund.encode(v, writer.uint32(10).fork()).join();
|
|
14009
14253
|
}
|
|
14254
|
+
if (message.transfer !== void 0) {
|
|
14255
|
+
Transfer6.encode(message.transfer, writer.uint32(26).fork()).join();
|
|
14256
|
+
}
|
|
14010
14257
|
return writer;
|
|
14011
14258
|
},
|
|
14012
14259
|
decode(input, length) {
|
|
@@ -14023,6 +14270,13 @@ var QueryUserSignedRefundsResponse = {
|
|
|
14023
14270
|
message.userSignedRefunds.push(UserSignedRefund.decode(reader, reader.uint32()));
|
|
14024
14271
|
continue;
|
|
14025
14272
|
}
|
|
14273
|
+
case 3: {
|
|
14274
|
+
if (tag !== 26) {
|
|
14275
|
+
break;
|
|
14276
|
+
}
|
|
14277
|
+
message.transfer = Transfer6.decode(reader, reader.uint32());
|
|
14278
|
+
continue;
|
|
14279
|
+
}
|
|
14026
14280
|
}
|
|
14027
14281
|
if ((tag & 7) === 4 || tag === 0) {
|
|
14028
14282
|
break;
|
|
@@ -14033,7 +14287,8 @@ var QueryUserSignedRefundsResponse = {
|
|
|
14033
14287
|
},
|
|
14034
14288
|
fromJSON(object) {
|
|
14035
14289
|
return {
|
|
14036
|
-
userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : []
|
|
14290
|
+
userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : [],
|
|
14291
|
+
transfer: isSet3(object.transfer) ? Transfer6.fromJSON(object.transfer) : void 0
|
|
14037
14292
|
};
|
|
14038
14293
|
},
|
|
14039
14294
|
toJSON(message) {
|
|
@@ -14041,6 +14296,9 @@ var QueryUserSignedRefundsResponse = {
|
|
|
14041
14296
|
if (message.userSignedRefunds?.length) {
|
|
14042
14297
|
obj.userSignedRefunds = message.userSignedRefunds.map((e) => UserSignedRefund.toJSON(e));
|
|
14043
14298
|
}
|
|
14299
|
+
if (message.transfer !== void 0) {
|
|
14300
|
+
obj.transfer = Transfer6.toJSON(message.transfer);
|
|
14301
|
+
}
|
|
14044
14302
|
return obj;
|
|
14045
14303
|
},
|
|
14046
14304
|
create(base) {
|
|
@@ -14049,6 +14307,7 @@ var QueryUserSignedRefundsResponse = {
|
|
|
14049
14307
|
fromPartial(object) {
|
|
14050
14308
|
const message = createBaseQueryUserSignedRefundsResponse();
|
|
14051
14309
|
message.userSignedRefunds = object.userSignedRefunds?.map((e) => UserSignedRefund.fromPartial(e)) || [];
|
|
14310
|
+
message.transfer = object.transfer !== void 0 && object.transfer !== null ? Transfer6.fromPartial(object.transfer) : void 0;
|
|
14052
14311
|
return message;
|
|
14053
14312
|
}
|
|
14054
14313
|
};
|
|
@@ -14935,7 +15194,8 @@ function createBaseDepositAddressQueryResult() {
|
|
|
14935
15194
|
depositAddress: "",
|
|
14936
15195
|
userSigningPublicKey: new Uint8Array(0),
|
|
14937
15196
|
verifyingPublicKey: new Uint8Array(0),
|
|
14938
|
-
leafId: void 0
|
|
15197
|
+
leafId: void 0,
|
|
15198
|
+
proofOfPossession: void 0
|
|
14939
15199
|
};
|
|
14940
15200
|
}
|
|
14941
15201
|
var DepositAddressQueryResult = {
|
|
@@ -14952,6 +15212,9 @@ var DepositAddressQueryResult = {
|
|
|
14952
15212
|
if (message.leafId !== void 0) {
|
|
14953
15213
|
writer.uint32(34).string(message.leafId);
|
|
14954
15214
|
}
|
|
15215
|
+
if (message.proofOfPossession !== void 0) {
|
|
15216
|
+
DepositAddressProof.encode(message.proofOfPossession, writer.uint32(42).fork()).join();
|
|
15217
|
+
}
|
|
14955
15218
|
return writer;
|
|
14956
15219
|
},
|
|
14957
15220
|
decode(input, length) {
|
|
@@ -14989,6 +15252,13 @@ var DepositAddressQueryResult = {
|
|
|
14989
15252
|
message.leafId = reader.string();
|
|
14990
15253
|
continue;
|
|
14991
15254
|
}
|
|
15255
|
+
case 5: {
|
|
15256
|
+
if (tag !== 42) {
|
|
15257
|
+
break;
|
|
15258
|
+
}
|
|
15259
|
+
message.proofOfPossession = DepositAddressProof.decode(reader, reader.uint32());
|
|
15260
|
+
continue;
|
|
15261
|
+
}
|
|
14992
15262
|
}
|
|
14993
15263
|
if ((tag & 7) === 4 || tag === 0) {
|
|
14994
15264
|
break;
|
|
@@ -15002,7 +15272,8 @@ var DepositAddressQueryResult = {
|
|
|
15002
15272
|
depositAddress: isSet3(object.depositAddress) ? globalThis.String(object.depositAddress) : "",
|
|
15003
15273
|
userSigningPublicKey: isSet3(object.userSigningPublicKey) ? bytesFromBase642(object.userSigningPublicKey) : new Uint8Array(0),
|
|
15004
15274
|
verifyingPublicKey: isSet3(object.verifyingPublicKey) ? bytesFromBase642(object.verifyingPublicKey) : new Uint8Array(0),
|
|
15005
|
-
leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0
|
|
15275
|
+
leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0,
|
|
15276
|
+
proofOfPossession: isSet3(object.proofOfPossession) ? DepositAddressProof.fromJSON(object.proofOfPossession) : void 0
|
|
15006
15277
|
};
|
|
15007
15278
|
},
|
|
15008
15279
|
toJSON(message) {
|
|
@@ -15019,6 +15290,9 @@ var DepositAddressQueryResult = {
|
|
|
15019
15290
|
if (message.leafId !== void 0) {
|
|
15020
15291
|
obj.leafId = message.leafId;
|
|
15021
15292
|
}
|
|
15293
|
+
if (message.proofOfPossession !== void 0) {
|
|
15294
|
+
obj.proofOfPossession = DepositAddressProof.toJSON(message.proofOfPossession);
|
|
15295
|
+
}
|
|
15022
15296
|
return obj;
|
|
15023
15297
|
},
|
|
15024
15298
|
create(base) {
|
|
@@ -15030,6 +15304,7 @@ var DepositAddressQueryResult = {
|
|
|
15030
15304
|
message.userSigningPublicKey = object.userSigningPublicKey ?? new Uint8Array(0);
|
|
15031
15305
|
message.verifyingPublicKey = object.verifyingPublicKey ?? new Uint8Array(0);
|
|
15032
15306
|
message.leafId = object.leafId ?? void 0;
|
|
15307
|
+
message.proofOfPossession = object.proofOfPossession !== void 0 && object.proofOfPossession !== null ? DepositAddressProof.fromPartial(object.proofOfPossession) : void 0;
|
|
15033
15308
|
return message;
|
|
15034
15309
|
}
|
|
15035
15310
|
};
|
|
@@ -16994,7 +17269,7 @@ var QueryNodesByValueResponse_NodesEntry = {
|
|
|
16994
17269
|
}
|
|
16995
17270
|
};
|
|
16996
17271
|
function createBaseGetUtxosForAddressRequest() {
|
|
16997
|
-
return { address: "", offset: 0, limit: 0, network: 0 };
|
|
17272
|
+
return { address: "", offset: 0, limit: 0, network: 0, excludeClaimed: false };
|
|
16998
17273
|
}
|
|
16999
17274
|
var GetUtxosForAddressRequest = {
|
|
17000
17275
|
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
@@ -17010,6 +17285,9 @@ var GetUtxosForAddressRequest = {
|
|
|
17010
17285
|
if (message.network !== 0) {
|
|
17011
17286
|
writer.uint32(32).int32(message.network);
|
|
17012
17287
|
}
|
|
17288
|
+
if (message.excludeClaimed !== false) {
|
|
17289
|
+
writer.uint32(40).bool(message.excludeClaimed);
|
|
17290
|
+
}
|
|
17013
17291
|
return writer;
|
|
17014
17292
|
},
|
|
17015
17293
|
decode(input, length) {
|
|
@@ -17047,6 +17325,13 @@ var GetUtxosForAddressRequest = {
|
|
|
17047
17325
|
message.network = reader.int32();
|
|
17048
17326
|
continue;
|
|
17049
17327
|
}
|
|
17328
|
+
case 5: {
|
|
17329
|
+
if (tag !== 40) {
|
|
17330
|
+
break;
|
|
17331
|
+
}
|
|
17332
|
+
message.excludeClaimed = reader.bool();
|
|
17333
|
+
continue;
|
|
17334
|
+
}
|
|
17050
17335
|
}
|
|
17051
17336
|
if ((tag & 7) === 4 || tag === 0) {
|
|
17052
17337
|
break;
|
|
@@ -17060,7 +17345,8 @@ var GetUtxosForAddressRequest = {
|
|
|
17060
17345
|
address: isSet3(object.address) ? globalThis.String(object.address) : "",
|
|
17061
17346
|
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
17062
17347
|
limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
|
|
17063
|
-
network: isSet3(object.network) ? networkFromJSON(object.network) : 0
|
|
17348
|
+
network: isSet3(object.network) ? networkFromJSON(object.network) : 0,
|
|
17349
|
+
excludeClaimed: isSet3(object.excludeClaimed) ? globalThis.Boolean(object.excludeClaimed) : false
|
|
17064
17350
|
};
|
|
17065
17351
|
},
|
|
17066
17352
|
toJSON(message) {
|
|
@@ -17077,6 +17363,9 @@ var GetUtxosForAddressRequest = {
|
|
|
17077
17363
|
if (message.network !== 0) {
|
|
17078
17364
|
obj.network = networkToJSON(message.network);
|
|
17079
17365
|
}
|
|
17366
|
+
if (message.excludeClaimed !== false) {
|
|
17367
|
+
obj.excludeClaimed = message.excludeClaimed;
|
|
17368
|
+
}
|
|
17080
17369
|
return obj;
|
|
17081
17370
|
},
|
|
17082
17371
|
create(base) {
|
|
@@ -17088,6 +17377,7 @@ var GetUtxosForAddressRequest = {
|
|
|
17088
17377
|
message.offset = object.offset ?? 0;
|
|
17089
17378
|
message.limit = object.limit ?? 0;
|
|
17090
17379
|
message.network = object.network ?? 0;
|
|
17380
|
+
message.excludeClaimed = object.excludeClaimed ?? false;
|
|
17091
17381
|
return message;
|
|
17092
17382
|
}
|
|
17093
17383
|
};
|
|
@@ -17159,6 +17449,225 @@ var GetUtxosForAddressResponse = {
|
|
|
17159
17449
|
return message;
|
|
17160
17450
|
}
|
|
17161
17451
|
};
|
|
17452
|
+
function createBaseQuerySparkInvoicesRequest() {
|
|
17453
|
+
return { limit: 0, offset: 0, invoice: [] };
|
|
17454
|
+
}
|
|
17455
|
+
var QuerySparkInvoicesRequest = {
|
|
17456
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
17457
|
+
if (message.limit !== 0) {
|
|
17458
|
+
writer.uint32(8).int64(message.limit);
|
|
17459
|
+
}
|
|
17460
|
+
if (message.offset !== 0) {
|
|
17461
|
+
writer.uint32(16).int64(message.offset);
|
|
17462
|
+
}
|
|
17463
|
+
for (const v of message.invoice) {
|
|
17464
|
+
writer.uint32(26).string(v);
|
|
17465
|
+
}
|
|
17466
|
+
return writer;
|
|
17467
|
+
},
|
|
17468
|
+
decode(input, length) {
|
|
17469
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
17470
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
17471
|
+
const message = createBaseQuerySparkInvoicesRequest();
|
|
17472
|
+
while (reader.pos < end) {
|
|
17473
|
+
const tag = reader.uint32();
|
|
17474
|
+
switch (tag >>> 3) {
|
|
17475
|
+
case 1: {
|
|
17476
|
+
if (tag !== 8) {
|
|
17477
|
+
break;
|
|
17478
|
+
}
|
|
17479
|
+
message.limit = longToNumber2(reader.int64());
|
|
17480
|
+
continue;
|
|
17481
|
+
}
|
|
17482
|
+
case 2: {
|
|
17483
|
+
if (tag !== 16) {
|
|
17484
|
+
break;
|
|
17485
|
+
}
|
|
17486
|
+
message.offset = longToNumber2(reader.int64());
|
|
17487
|
+
continue;
|
|
17488
|
+
}
|
|
17489
|
+
case 3: {
|
|
17490
|
+
if (tag !== 26) {
|
|
17491
|
+
break;
|
|
17492
|
+
}
|
|
17493
|
+
message.invoice.push(reader.string());
|
|
17494
|
+
continue;
|
|
17495
|
+
}
|
|
17496
|
+
}
|
|
17497
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
17498
|
+
break;
|
|
17499
|
+
}
|
|
17500
|
+
reader.skip(tag & 7);
|
|
17501
|
+
}
|
|
17502
|
+
return message;
|
|
17503
|
+
},
|
|
17504
|
+
fromJSON(object) {
|
|
17505
|
+
return {
|
|
17506
|
+
limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
|
|
17507
|
+
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
17508
|
+
invoice: globalThis.Array.isArray(object?.invoice) ? object.invoice.map((e) => globalThis.String(e)) : []
|
|
17509
|
+
};
|
|
17510
|
+
},
|
|
17511
|
+
toJSON(message) {
|
|
17512
|
+
const obj = {};
|
|
17513
|
+
if (message.limit !== 0) {
|
|
17514
|
+
obj.limit = Math.round(message.limit);
|
|
17515
|
+
}
|
|
17516
|
+
if (message.offset !== 0) {
|
|
17517
|
+
obj.offset = Math.round(message.offset);
|
|
17518
|
+
}
|
|
17519
|
+
if (message.invoice?.length) {
|
|
17520
|
+
obj.invoice = message.invoice;
|
|
17521
|
+
}
|
|
17522
|
+
return obj;
|
|
17523
|
+
},
|
|
17524
|
+
create(base) {
|
|
17525
|
+
return QuerySparkInvoicesRequest.fromPartial(base ?? {});
|
|
17526
|
+
},
|
|
17527
|
+
fromPartial(object) {
|
|
17528
|
+
const message = createBaseQuerySparkInvoicesRequest();
|
|
17529
|
+
message.limit = object.limit ?? 0;
|
|
17530
|
+
message.offset = object.offset ?? 0;
|
|
17531
|
+
message.invoice = object.invoice?.map((e) => e) || [];
|
|
17532
|
+
return message;
|
|
17533
|
+
}
|
|
17534
|
+
};
|
|
17535
|
+
function createBaseQuerySparkInvoicesResponse() {
|
|
17536
|
+
return { offset: 0, invoiceStatuses: [] };
|
|
17537
|
+
}
|
|
17538
|
+
var QuerySparkInvoicesResponse = {
|
|
17539
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
17540
|
+
if (message.offset !== 0) {
|
|
17541
|
+
writer.uint32(8).int64(message.offset);
|
|
17542
|
+
}
|
|
17543
|
+
for (const v of message.invoiceStatuses) {
|
|
17544
|
+
InvoiceResponse.encode(v, writer.uint32(18).fork()).join();
|
|
17545
|
+
}
|
|
17546
|
+
return writer;
|
|
17547
|
+
},
|
|
17548
|
+
decode(input, length) {
|
|
17549
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
17550
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
17551
|
+
const message = createBaseQuerySparkInvoicesResponse();
|
|
17552
|
+
while (reader.pos < end) {
|
|
17553
|
+
const tag = reader.uint32();
|
|
17554
|
+
switch (tag >>> 3) {
|
|
17555
|
+
case 1: {
|
|
17556
|
+
if (tag !== 8) {
|
|
17557
|
+
break;
|
|
17558
|
+
}
|
|
17559
|
+
message.offset = longToNumber2(reader.int64());
|
|
17560
|
+
continue;
|
|
17561
|
+
}
|
|
17562
|
+
case 2: {
|
|
17563
|
+
if (tag !== 18) {
|
|
17564
|
+
break;
|
|
17565
|
+
}
|
|
17566
|
+
message.invoiceStatuses.push(InvoiceResponse.decode(reader, reader.uint32()));
|
|
17567
|
+
continue;
|
|
17568
|
+
}
|
|
17569
|
+
}
|
|
17570
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
17571
|
+
break;
|
|
17572
|
+
}
|
|
17573
|
+
reader.skip(tag & 7);
|
|
17574
|
+
}
|
|
17575
|
+
return message;
|
|
17576
|
+
},
|
|
17577
|
+
fromJSON(object) {
|
|
17578
|
+
return {
|
|
17579
|
+
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
17580
|
+
invoiceStatuses: globalThis.Array.isArray(object?.invoiceStatuses) ? object.invoiceStatuses.map((e) => InvoiceResponse.fromJSON(e)) : []
|
|
17581
|
+
};
|
|
17582
|
+
},
|
|
17583
|
+
toJSON(message) {
|
|
17584
|
+
const obj = {};
|
|
17585
|
+
if (message.offset !== 0) {
|
|
17586
|
+
obj.offset = Math.round(message.offset);
|
|
17587
|
+
}
|
|
17588
|
+
if (message.invoiceStatuses?.length) {
|
|
17589
|
+
obj.invoiceStatuses = message.invoiceStatuses.map((e) => InvoiceResponse.toJSON(e));
|
|
17590
|
+
}
|
|
17591
|
+
return obj;
|
|
17592
|
+
},
|
|
17593
|
+
create(base) {
|
|
17594
|
+
return QuerySparkInvoicesResponse.fromPartial(base ?? {});
|
|
17595
|
+
},
|
|
17596
|
+
fromPartial(object) {
|
|
17597
|
+
const message = createBaseQuerySparkInvoicesResponse();
|
|
17598
|
+
message.offset = object.offset ?? 0;
|
|
17599
|
+
message.invoiceStatuses = object.invoiceStatuses?.map((e) => InvoiceResponse.fromPartial(e)) || [];
|
|
17600
|
+
return message;
|
|
17601
|
+
}
|
|
17602
|
+
};
|
|
17603
|
+
function createBaseInvoiceResponse() {
|
|
17604
|
+
return { invoice: "", status: 0 };
|
|
17605
|
+
}
|
|
17606
|
+
var InvoiceResponse = {
|
|
17607
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
17608
|
+
if (message.invoice !== "") {
|
|
17609
|
+
writer.uint32(10).string(message.invoice);
|
|
17610
|
+
}
|
|
17611
|
+
if (message.status !== 0) {
|
|
17612
|
+
writer.uint32(16).int32(message.status);
|
|
17613
|
+
}
|
|
17614
|
+
return writer;
|
|
17615
|
+
},
|
|
17616
|
+
decode(input, length) {
|
|
17617
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
17618
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
17619
|
+
const message = createBaseInvoiceResponse();
|
|
17620
|
+
while (reader.pos < end) {
|
|
17621
|
+
const tag = reader.uint32();
|
|
17622
|
+
switch (tag >>> 3) {
|
|
17623
|
+
case 1: {
|
|
17624
|
+
if (tag !== 10) {
|
|
17625
|
+
break;
|
|
17626
|
+
}
|
|
17627
|
+
message.invoice = reader.string();
|
|
17628
|
+
continue;
|
|
17629
|
+
}
|
|
17630
|
+
case 2: {
|
|
17631
|
+
if (tag !== 16) {
|
|
17632
|
+
break;
|
|
17633
|
+
}
|
|
17634
|
+
message.status = reader.int32();
|
|
17635
|
+
continue;
|
|
17636
|
+
}
|
|
17637
|
+
}
|
|
17638
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
17639
|
+
break;
|
|
17640
|
+
}
|
|
17641
|
+
reader.skip(tag & 7);
|
|
17642
|
+
}
|
|
17643
|
+
return message;
|
|
17644
|
+
},
|
|
17645
|
+
fromJSON(object) {
|
|
17646
|
+
return {
|
|
17647
|
+
invoice: isSet3(object.invoice) ? globalThis.String(object.invoice) : "",
|
|
17648
|
+
status: isSet3(object.status) ? invoiceStatusFromJSON(object.status) : 0
|
|
17649
|
+
};
|
|
17650
|
+
},
|
|
17651
|
+
toJSON(message) {
|
|
17652
|
+
const obj = {};
|
|
17653
|
+
if (message.invoice !== "") {
|
|
17654
|
+
obj.invoice = message.invoice;
|
|
17655
|
+
}
|
|
17656
|
+
if (message.status !== 0) {
|
|
17657
|
+
obj.status = invoiceStatusToJSON(message.status);
|
|
17658
|
+
}
|
|
17659
|
+
return obj;
|
|
17660
|
+
},
|
|
17661
|
+
create(base) {
|
|
17662
|
+
return InvoiceResponse.fromPartial(base ?? {});
|
|
17663
|
+
},
|
|
17664
|
+
fromPartial(object) {
|
|
17665
|
+
const message = createBaseInvoiceResponse();
|
|
17666
|
+
message.invoice = object.invoice ?? "";
|
|
17667
|
+
message.status = object.status ?? 0;
|
|
17668
|
+
return message;
|
|
17669
|
+
}
|
|
17670
|
+
};
|
|
17162
17671
|
var SparkServiceDefinition = {
|
|
17163
17672
|
name: "SparkService",
|
|
17164
17673
|
fullName: "spark.SparkService",
|
|
@@ -17171,6 +17680,15 @@ var SparkServiceDefinition = {
|
|
|
17171
17680
|
responseStream: false,
|
|
17172
17681
|
options: {}
|
|
17173
17682
|
},
|
|
17683
|
+
/** Generates a new static deposit address of the user or returns the existing one for the specified network. */
|
|
17684
|
+
generate_static_deposit_address: {
|
|
17685
|
+
name: "generate_static_deposit_address",
|
|
17686
|
+
requestType: GenerateStaticDepositAddressRequest,
|
|
17687
|
+
requestStream: false,
|
|
17688
|
+
responseType: GenerateStaticDepositAddressResponse,
|
|
17689
|
+
responseStream: false,
|
|
17690
|
+
options: {}
|
|
17691
|
+
},
|
|
17174
17692
|
start_deposit_tree_creation: {
|
|
17175
17693
|
name: "start_deposit_tree_creation",
|
|
17176
17694
|
requestType: StartDepositTreeCreationRequest,
|
|
@@ -17612,6 +18130,14 @@ var SparkServiceDefinition = {
|
|
|
17612
18130
|
responseType: GetUtxosForAddressResponse,
|
|
17613
18131
|
responseStream: false,
|
|
17614
18132
|
options: {}
|
|
18133
|
+
},
|
|
18134
|
+
query_spark_invoices: {
|
|
18135
|
+
name: "query_spark_invoices",
|
|
18136
|
+
requestType: QuerySparkInvoicesRequest,
|
|
18137
|
+
requestStream: false,
|
|
18138
|
+
responseType: QuerySparkInvoicesResponse,
|
|
18139
|
+
responseStream: false,
|
|
18140
|
+
options: {}
|
|
17615
18141
|
}
|
|
17616
18142
|
}
|
|
17617
18143
|
};
|
|
@@ -17676,20 +18202,20 @@ function isSet3(value) {
|
|
|
17676
18202
|
|
|
17677
18203
|
// src/signer/signer.ts
|
|
17678
18204
|
var import_secp256k14 = require("@bitcoinerlab/secp256k1");
|
|
17679
|
-
var import_utils4 = require("@noble/curves/abstract/utils");
|
|
17680
18205
|
var import_secp256k15 = require("@noble/curves/secp256k1");
|
|
18206
|
+
var import_utils5 = require("@noble/curves/utils");
|
|
17681
18207
|
var import_sha22 = require("@noble/hashes/sha2");
|
|
17682
18208
|
var import_bip32 = require("@scure/bip32");
|
|
17683
18209
|
var import_bip39 = require("@scure/bip39");
|
|
17684
18210
|
var import_english = require("@scure/bip39/wordlists/english");
|
|
17685
|
-
var
|
|
18211
|
+
var import_utils6 = require("@scure/btc-signer/utils");
|
|
17686
18212
|
var ecies = __toESM(require("eciesjs"), 1);
|
|
17687
18213
|
|
|
17688
18214
|
// src/constants.ts
|
|
17689
18215
|
var import_core10 = require("@lightsparkdev/core");
|
|
17690
18216
|
var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
17691
18217
|
var isBun = globalThis.Bun !== void 0;
|
|
17692
|
-
var packageVersion = true ? "0.2.
|
|
18218
|
+
var packageVersion = true ? "0.2.12" : "unknown";
|
|
17693
18219
|
var baseEnvStr = "unknown";
|
|
17694
18220
|
if (isBun) {
|
|
17695
18221
|
const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
|
|
@@ -17708,8 +18234,8 @@ if (isBun) {
|
|
|
17708
18234
|
var clientEnv = `js-spark-sdk/${packageVersion} ${baseEnvStr}`;
|
|
17709
18235
|
|
|
17710
18236
|
// src/utils/keys.ts
|
|
17711
|
-
var import_utils2 = require("@noble/curves/abstract/utils");
|
|
17712
18237
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
|
18238
|
+
var import_utils2 = require("@noble/curves/utils");
|
|
17713
18239
|
function addPublicKeys(a, b) {
|
|
17714
18240
|
if (a.length !== 33 || b.length !== 33) {
|
|
17715
18241
|
throw new ValidationError("Public keys must be 33 bytes", {
|
|
@@ -17718,9 +18244,9 @@ function addPublicKeys(a, b) {
|
|
|
17718
18244
|
expected: 33
|
|
17719
18245
|
});
|
|
17720
18246
|
}
|
|
17721
|
-
const pubkeyA = import_secp256k1.secp256k1.
|
|
17722
|
-
const pubkeyB = import_secp256k1.secp256k1.
|
|
17723
|
-
return pubkeyA.add(pubkeyB).
|
|
18247
|
+
const pubkeyA = import_secp256k1.secp256k1.Point.fromHex(a);
|
|
18248
|
+
const pubkeyB = import_secp256k1.secp256k1.Point.fromHex(b);
|
|
18249
|
+
return pubkeyA.add(pubkeyB).toBytes(true);
|
|
17724
18250
|
}
|
|
17725
18251
|
function applyAdditiveTweakToPublicKey(pubkey, tweak) {
|
|
17726
18252
|
if (pubkey.length !== 33) {
|
|
@@ -17737,11 +18263,11 @@ function applyAdditiveTweakToPublicKey(pubkey, tweak) {
|
|
|
17737
18263
|
expected: 32
|
|
17738
18264
|
});
|
|
17739
18265
|
}
|
|
17740
|
-
const pubkeyPoint = import_secp256k1.secp256k1.
|
|
18266
|
+
const pubkeyPoint = import_secp256k1.secp256k1.Point.fromHex(pubkey);
|
|
17741
18267
|
const privTweek = import_secp256k1.secp256k1.utils.normPrivateKeyToScalar(tweak);
|
|
17742
18268
|
const pubTweek = import_secp256k1.secp256k1.getPublicKey(privTweek, true);
|
|
17743
|
-
const tweekPoint = import_secp256k1.secp256k1.
|
|
17744
|
-
return pubkeyPoint.add(tweekPoint).
|
|
18269
|
+
const tweekPoint = import_secp256k1.secp256k1.Point.fromHex(pubTweek);
|
|
18270
|
+
return pubkeyPoint.add(tweekPoint).toBytes(true);
|
|
17745
18271
|
}
|
|
17746
18272
|
function subtractPublicKeys(a, b) {
|
|
17747
18273
|
if (a.length !== 33 || b.length !== 33) {
|
|
@@ -17751,9 +18277,9 @@ function subtractPublicKeys(a, b) {
|
|
|
17751
18277
|
expected: 33
|
|
17752
18278
|
});
|
|
17753
18279
|
}
|
|
17754
|
-
const pubkeyA = import_secp256k1.secp256k1.
|
|
17755
|
-
const pubkeyB = import_secp256k1.secp256k1.
|
|
17756
|
-
return pubkeyA.subtract(pubkeyB).
|
|
18280
|
+
const pubkeyA = import_secp256k1.secp256k1.Point.fromHex(a);
|
|
18281
|
+
const pubkeyB = import_secp256k1.secp256k1.Point.fromHex(b);
|
|
18282
|
+
return pubkeyA.subtract(pubkeyB).toBytes(true);
|
|
17757
18283
|
}
|
|
17758
18284
|
function addPrivateKeys(a, b) {
|
|
17759
18285
|
if (a.length !== 32 || b.length !== 32) {
|
|
@@ -17806,8 +18332,8 @@ function lastKeyWithTarget(target, keys) {
|
|
|
17806
18332
|
}
|
|
17807
18333
|
|
|
17808
18334
|
// src/utils/secret-sharing.ts
|
|
17809
|
-
var import_utils3 = require("@noble/curves/abstract/utils");
|
|
17810
18335
|
var import_secp256k12 = require("@noble/curves/secp256k1");
|
|
18336
|
+
var import_utils3 = require("@noble/curves/utils");
|
|
17811
18337
|
function getRandomBigInt(max) {
|
|
17812
18338
|
const byteLength = max.toString(2).length + 7 >> 3;
|
|
17813
18339
|
const maxBigInt = max;
|
|
@@ -17893,11 +18419,11 @@ function generatePolynomialForSecretSharing(fieldModulus, secret, degree) {
|
|
|
17893
18419
|
const coefficients = new Array(degree);
|
|
17894
18420
|
const proofs = new Array(degree);
|
|
17895
18421
|
coefficients[0] = secret;
|
|
17896
|
-
proofs[0] = import_secp256k12.secp256k1.
|
|
18422
|
+
proofs[0] = import_secp256k12.secp256k1.Point.fromPrivateKey(secret).toBytes(true);
|
|
17897
18423
|
for (let i = 1; i < degree; i++) {
|
|
17898
18424
|
const coefficient = getRandomBigInt(fieldModulus);
|
|
17899
18425
|
coefficients[i] = coefficient;
|
|
17900
|
-
proofs[i] = import_secp256k12.secp256k1.
|
|
18426
|
+
proofs[i] = import_secp256k12.secp256k1.Point.fromPrivateKey(coefficient).toBytes(true);
|
|
17901
18427
|
}
|
|
17902
18428
|
return {
|
|
17903
18429
|
fieldModulus,
|
|
@@ -17969,9 +18495,9 @@ function recoverSecret(shares) {
|
|
|
17969
18495
|
return result;
|
|
17970
18496
|
}
|
|
17971
18497
|
function validateShare(share) {
|
|
17972
|
-
const targetPubkey = import_secp256k12.secp256k1.
|
|
17973
|
-
|
|
17974
|
-
)
|
|
18498
|
+
const targetPubkey = import_secp256k12.secp256k1.Point.fromPrivateKey(share.share).toBytes(
|
|
18499
|
+
true
|
|
18500
|
+
);
|
|
17975
18501
|
let resultPubkey = share.proofs[0];
|
|
17976
18502
|
if (!resultPubkey) {
|
|
17977
18503
|
throw new ValidationError("Result pubkey is not valid", {
|
|
@@ -17990,8 +18516,8 @@ function validateShare(share) {
|
|
|
17990
18516
|
});
|
|
17991
18517
|
}
|
|
17992
18518
|
const value = share.index ** BigInt(i) % share.fieldModulus;
|
|
17993
|
-
const scaledPoint = import_secp256k12.secp256k1.
|
|
17994
|
-
resultPubkey = import_secp256k12.secp256k1.
|
|
18519
|
+
const scaledPoint = import_secp256k12.secp256k1.Point.fromHex(pubkey).multiply(value);
|
|
18520
|
+
resultPubkey = import_secp256k12.secp256k1.Point.fromHex(resultPubkey).add(scaledPoint).toBytes(true);
|
|
17995
18521
|
}
|
|
17996
18522
|
if (!(0, import_utils3.equalBytes)(resultPubkey, targetPubkey)) {
|
|
17997
18523
|
throw new ValidationError("Share is not valid", {
|
|
@@ -18160,7 +18686,7 @@ var TaprootOutputKeysGenerator = class {
|
|
|
18160
18686
|
}
|
|
18161
18687
|
const derivationPath = this.useAddressIndex ? `m/86'/0'/0'/0/${accountNumber}` : `m/86'/0'/${accountNumber}'/0/0`;
|
|
18162
18688
|
const taprootInternalKey = hdkey.derive(derivationPath);
|
|
18163
|
-
let tweakedPrivateKey = (0,
|
|
18689
|
+
let tweakedPrivateKey = (0, import_utils6.taprootTweakPrivKey)(taprootInternalKey.privateKey);
|
|
18164
18690
|
let tweakedPublicKey = import_secp256k15.secp256k1.getPublicKey(tweakedPrivateKey);
|
|
18165
18691
|
if (tweakedPublicKey[0] === 3) {
|
|
18166
18692
|
tweakedPrivateKey = (0, import_secp256k14.privateNegate)(tweakedPrivateKey);
|
|
@@ -18238,7 +18764,7 @@ var DefaultSparkSigner = class {
|
|
|
18238
18764
|
});
|
|
18239
18765
|
}
|
|
18240
18766
|
const receiverEciesPrivKey = ecies.PrivateKey.fromHex(
|
|
18241
|
-
(0,
|
|
18767
|
+
(0, import_utils5.bytesToHex)(this.identityKey.privateKey)
|
|
18242
18768
|
);
|
|
18243
18769
|
const privateKey = ecies.decrypt(receiverEciesPrivKey.toHex(), ciphertext);
|
|
18244
18770
|
return privateKey;
|
|
@@ -18372,7 +18898,7 @@ var DefaultSparkSigner = class {
|
|
|
18372
18898
|
threshold,
|
|
18373
18899
|
numShares
|
|
18374
18900
|
}) {
|
|
18375
|
-
const secretAsInt = (0,
|
|
18901
|
+
const secretAsInt = (0, import_utils5.bytesToNumberBE)(secret);
|
|
18376
18902
|
return splitSecretWithProofs(secretAsInt, curveOrder, threshold, numShares);
|
|
18377
18903
|
}
|
|
18378
18904
|
async signFrost({
|
|
@@ -18408,7 +18934,7 @@ var DefaultSparkSigner = class {
|
|
|
18408
18934
|
publicKey,
|
|
18409
18935
|
verifyingKey
|
|
18410
18936
|
};
|
|
18411
|
-
const logMessage = (0,
|
|
18937
|
+
const logMessage = (0, import_utils5.bytesToHex)(message);
|
|
18412
18938
|
const result = await SparkFrost.signFrost({
|
|
18413
18939
|
message,
|
|
18414
18940
|
keyPackage,
|
|
@@ -18450,7 +18976,7 @@ var DefaultSparkSigner = class {
|
|
|
18450
18976
|
}
|
|
18451
18977
|
async createSparkWalletFromSeed(seed, accountNumber) {
|
|
18452
18978
|
if (typeof seed === "string") {
|
|
18453
|
-
seed = (0,
|
|
18979
|
+
seed = (0, import_utils5.hexToBytes)(seed);
|
|
18454
18980
|
}
|
|
18455
18981
|
const {
|
|
18456
18982
|
identityKey,
|
|
@@ -18462,7 +18988,7 @@ var DefaultSparkSigner = class {
|
|
|
18462
18988
|
this.depositKey = depositKey;
|
|
18463
18989
|
this.signingKey = signingKey.hdKey;
|
|
18464
18990
|
this.staticDepositKey = staticDepositKey.hdKey;
|
|
18465
|
-
return (0,
|
|
18991
|
+
return (0, import_utils5.bytesToHex)(identityKey.publicKey);
|
|
18466
18992
|
}
|
|
18467
18993
|
async signMessageWithIdentityKey(message, compact) {
|
|
18468
18994
|
if (!this.identityKey?.privateKey) {
|
|
@@ -18483,7 +19009,7 @@ var DefaultSparkSigner = class {
|
|
|
18483
19009
|
});
|
|
18484
19010
|
}
|
|
18485
19011
|
const receiverEciesPrivKey = ecies.PrivateKey.fromHex(
|
|
18486
|
-
(0,
|
|
19012
|
+
(0, import_utils5.bytesToHex)(this.identityKey.privateKey)
|
|
18487
19013
|
);
|
|
18488
19014
|
const privateKey = ecies.decrypt(receiverEciesPrivKey.toHex(), ciphertext);
|
|
18489
19015
|
const publicKey = import_secp256k15.secp256k1.getPublicKey(privateKey);
|
|
@@ -18507,15 +19033,15 @@ var DefaultSparkSigner = class {
|
|
|
18507
19033
|
}
|
|
18508
19034
|
signTransactionIndex(tx, index, publicKey) {
|
|
18509
19035
|
let privateKey;
|
|
18510
|
-
if ((0,
|
|
19036
|
+
if ((0, import_utils5.equalBytes)(publicKey, this.identityKey?.publicKey ?? new Uint8Array())) {
|
|
18511
19037
|
privateKey = this.identityKey?.privateKey;
|
|
18512
|
-
} else if ((0,
|
|
19038
|
+
} else if ((0, import_utils5.equalBytes)(publicKey, this.depositKey?.publicKey ?? new Uint8Array())) {
|
|
18513
19039
|
privateKey = this.depositKey?.privateKey;
|
|
18514
19040
|
}
|
|
18515
19041
|
if (!privateKey) {
|
|
18516
19042
|
throw new ValidationError("Private key not found for public key", {
|
|
18517
19043
|
field: "privateKey",
|
|
18518
|
-
value: (0,
|
|
19044
|
+
value: (0, import_utils5.bytesToHex)(publicKey)
|
|
18519
19045
|
});
|
|
18520
19046
|
}
|
|
18521
19047
|
tx.signIdx(privateKey, index);
|
|
@@ -18986,7 +19512,7 @@ var WalletConfigService = class {
|
|
|
18986
19512
|
};
|
|
18987
19513
|
|
|
18988
19514
|
// src/services/connection.ts
|
|
18989
|
-
var
|
|
19515
|
+
var import_core12 = require("@lightsparkdev/core");
|
|
18990
19516
|
var import_sha23 = require("@noble/hashes/sha2");
|
|
18991
19517
|
var import_nice_grpc_client_middleware_retry = require("nice-grpc-client-middleware-retry");
|
|
18992
19518
|
var import_nice_grpc_common2 = require("nice-grpc-common");
|
|
@@ -22741,7 +23267,7 @@ var ConnectionManager = class {
|
|
|
22741
23267
|
async createMockClient(address2) {
|
|
22742
23268
|
const channel = await this.createChannelWithTLS(address2);
|
|
22743
23269
|
const isNodeChannel = "close" in channel;
|
|
22744
|
-
if (
|
|
23270
|
+
if (import_core12.isNode && isNodeChannel && !isBun) {
|
|
22745
23271
|
const grpcModule = await import("nice-grpc");
|
|
22746
23272
|
const { createClient } = "default" in grpcModule ? grpcModule.default : grpcModule;
|
|
22747
23273
|
const client = createClient(MockServiceDefinition, channel);
|
|
@@ -22758,7 +23284,7 @@ var ConnectionManager = class {
|
|
|
22758
23284
|
}
|
|
22759
23285
|
async createChannelWithTLS(address2, certPath) {
|
|
22760
23286
|
try {
|
|
22761
|
-
if (
|
|
23287
|
+
if (import_core12.isNode && !isBun) {
|
|
22762
23288
|
const grpcModule = await import("nice-grpc");
|
|
22763
23289
|
const { ChannelCredentials, createChannel } = "default" in grpcModule ? grpcModule.default : grpcModule;
|
|
22764
23290
|
if (certPath) {
|
|
@@ -22789,7 +23315,7 @@ var ConnectionManager = class {
|
|
|
22789
23315
|
const { XHRTransport: XHRTransport2 } = await Promise.resolve().then(() => (init_xhr_transport(), xhr_transport_exports));
|
|
22790
23316
|
return createChannel(
|
|
22791
23317
|
address2,
|
|
22792
|
-
|
|
23318
|
+
import_core12.isBare ? (0, import_nice_grpc_web.NodeHttpTransport)() : isReactNative ? XHRTransport2() : FetchTransport()
|
|
22793
23319
|
);
|
|
22794
23320
|
}
|
|
22795
23321
|
} catch (error) {
|
|
@@ -22895,7 +23421,7 @@ var ConnectionManager = class {
|
|
|
22895
23421
|
sparkAuthnClient.close?.();
|
|
22896
23422
|
return verifyResp.sessionToken;
|
|
22897
23423
|
} catch (error) {
|
|
22898
|
-
if ((0,
|
|
23424
|
+
if ((0, import_core12.isError)(error)) {
|
|
22899
23425
|
sparkAuthnClient?.close?.();
|
|
22900
23426
|
if (error.message.includes("challenge expired")) {
|
|
22901
23427
|
console.warn(
|
|
@@ -22946,7 +23472,7 @@ var ConnectionManager = class {
|
|
|
22946
23472
|
);
|
|
22947
23473
|
}
|
|
22948
23474
|
createAuthnMiddleware() {
|
|
22949
|
-
if (
|
|
23475
|
+
if (import_core12.isNode) {
|
|
22950
23476
|
return async function* (call, options) {
|
|
22951
23477
|
const metadata = (0, import_nice_grpc_common2.Metadata)(options.metadata).set(
|
|
22952
23478
|
"X-Client-Env",
|
|
@@ -22968,14 +23494,14 @@ var ConnectionManager = class {
|
|
|
22968
23494
|
}
|
|
22969
23495
|
}
|
|
22970
23496
|
createMiddleware(address2, authToken) {
|
|
22971
|
-
if (
|
|
23497
|
+
if (import_core12.isNode) {
|
|
22972
23498
|
return this.createNodeMiddleware(address2, authToken);
|
|
22973
23499
|
} else {
|
|
22974
23500
|
return this.createBrowserMiddleware(address2, authToken);
|
|
22975
23501
|
}
|
|
22976
23502
|
}
|
|
22977
23503
|
async *handleMiddlewareError(error, address2, call, metadata, options) {
|
|
22978
|
-
if ((0,
|
|
23504
|
+
if ((0, import_core12.isError)(error)) {
|
|
22979
23505
|
if (error.message.includes("token has expired")) {
|
|
22980
23506
|
const newAuthToken = await this.authenticate(address2);
|
|
22981
23507
|
const clientData = this.clients.get(address2);
|
|
@@ -23046,7 +23572,7 @@ var ConnectionManager = class {
|
|
|
23046
23572
|
};
|
|
23047
23573
|
let options = {};
|
|
23048
23574
|
const isNodeChannel = "close" in channel;
|
|
23049
|
-
if (
|
|
23575
|
+
if (import_core12.isNode && isNodeChannel && !isBun) {
|
|
23050
23576
|
const grpcModule = await import("nice-grpc");
|
|
23051
23577
|
const { openTelemetryClientMiddleware } = await import("nice-grpc-opentelemetry");
|
|
23052
23578
|
const { createClientFactory } = "default" in grpcModule ? grpcModule.default : grpcModule;
|
|
@@ -23094,8 +23620,8 @@ var import_btc_signer3 = require("@scure/btc-signer");
|
|
|
23094
23620
|
var import_uuidv72 = require("uuidv7");
|
|
23095
23621
|
|
|
23096
23622
|
// src/utils/bitcoin.ts
|
|
23097
|
-
var import_utils6 = require("@noble/curves/abstract/utils");
|
|
23098
23623
|
var import_secp256k16 = require("@noble/curves/secp256k1");
|
|
23624
|
+
var import_utils7 = require("@noble/curves/utils");
|
|
23099
23625
|
var import_sha24 = require("@noble/hashes/sha2");
|
|
23100
23626
|
var btc2 = __toESM(require("@scure/btc-signer"), 1);
|
|
23101
23627
|
function computeTaprootKeyNoScript(pubkey) {
|
|
@@ -23107,10 +23633,10 @@ function computeTaprootKeyNoScript(pubkey) {
|
|
|
23107
23633
|
});
|
|
23108
23634
|
}
|
|
23109
23635
|
const taggedHash = import_secp256k16.schnorr.utils.taggedHash("TapTweak", pubkey);
|
|
23110
|
-
const tweak = (0,
|
|
23636
|
+
const tweak = (0, import_utils7.bytesToNumberBE)(taggedHash);
|
|
23111
23637
|
const P = import_secp256k16.schnorr.utils.lift_x(import_secp256k16.schnorr.utils.bytesToNumberBE(pubkey));
|
|
23112
|
-
const Q = P.add(import_secp256k16.secp256k1.
|
|
23113
|
-
return Q.
|
|
23638
|
+
const Q = P.add(import_secp256k16.secp256k1.Point.fromPrivateKey(tweak));
|
|
23639
|
+
return Q.toBytes();
|
|
23114
23640
|
}
|
|
23115
23641
|
function getP2TRScriptFromPublicKey(pubKey, network) {
|
|
23116
23642
|
if (pubKey.length !== 33) {
|
|
@@ -23120,9 +23646,9 @@ function getP2TRScriptFromPublicKey(pubKey, network) {
|
|
|
23120
23646
|
expected: 33
|
|
23121
23647
|
});
|
|
23122
23648
|
}
|
|
23123
|
-
const internalKey = import_secp256k16.secp256k1.
|
|
23649
|
+
const internalKey = import_secp256k16.secp256k1.Point.fromHex(pubKey);
|
|
23124
23650
|
const script = btc2.p2tr(
|
|
23125
|
-
internalKey.
|
|
23651
|
+
internalKey.toBytes().slice(1, 33),
|
|
23126
23652
|
void 0,
|
|
23127
23653
|
getNetwork(network)
|
|
23128
23654
|
).script;
|
|
@@ -23142,9 +23668,9 @@ function getP2TRAddressFromPublicKey(pubKey, network) {
|
|
|
23142
23668
|
expected: 33
|
|
23143
23669
|
});
|
|
23144
23670
|
}
|
|
23145
|
-
const internalKey = import_secp256k16.secp256k1.
|
|
23671
|
+
const internalKey = import_secp256k16.secp256k1.Point.fromHex(pubKey);
|
|
23146
23672
|
const address2 = btc2.p2tr(
|
|
23147
|
-
internalKey.
|
|
23673
|
+
internalKey.toBytes().slice(1, 33),
|
|
23148
23674
|
void 0,
|
|
23149
23675
|
getNetwork(network)
|
|
23150
23676
|
).address;
|
|
@@ -23160,7 +23686,7 @@ function getP2TRAddressFromPkScript(pkScript, network) {
|
|
|
23160
23686
|
if (pkScript.length !== 34 || pkScript[0] !== 81 || pkScript[1] !== 32) {
|
|
23161
23687
|
throw new ValidationError("Invalid pkscript", {
|
|
23162
23688
|
field: "pkScript",
|
|
23163
|
-
value: (0,
|
|
23689
|
+
value: (0, import_utils7.bytesToHex)(pkScript),
|
|
23164
23690
|
expected: "34 bytes starting with 0x51 0x20"
|
|
23165
23691
|
});
|
|
23166
23692
|
}
|
|
@@ -23185,7 +23711,7 @@ function getP2WPKHAddressFromPublicKey(pubKey, network) {
|
|
|
23185
23711
|
return address2;
|
|
23186
23712
|
}
|
|
23187
23713
|
function getTxFromRawTxHex(rawTxHex) {
|
|
23188
|
-
const txBytes = (0,
|
|
23714
|
+
const txBytes = (0, import_utils7.hexToBytes)(rawTxHex);
|
|
23189
23715
|
const tx = btc2.Transaction.fromRaw(txBytes, {
|
|
23190
23716
|
allowUnknownOutputs: true
|
|
23191
23717
|
});
|
|
@@ -23232,10 +23758,10 @@ function getSigHashFromTx(tx, inputIndex, prevOutput) {
|
|
|
23232
23758
|
);
|
|
23233
23759
|
}
|
|
23234
23760
|
function getTxId(tx) {
|
|
23235
|
-
return (0,
|
|
23761
|
+
return (0, import_utils7.bytesToHex)((0, import_sha24.sha256)((0, import_sha24.sha256)(tx.toBytes(true))).reverse());
|
|
23236
23762
|
}
|
|
23237
23763
|
function getTxIdNoReverse(tx) {
|
|
23238
|
-
return (0,
|
|
23764
|
+
return (0, import_utils7.bytesToHex)((0, import_sha24.sha256)((0, import_sha24.sha256)(tx.toBytes(true))));
|
|
23239
23765
|
}
|
|
23240
23766
|
function getTxEstimatedVbytesSizeByNumberOfInputsOutputs(numInputs, numOutputs) {
|
|
23241
23767
|
const TX_OVERHEAD = 10;
|
|
@@ -23581,15 +24107,15 @@ function getEphemeralAnchorOutput() {
|
|
|
23581
24107
|
}
|
|
23582
24108
|
|
|
23583
24109
|
// src/services/transfer.ts
|
|
23584
|
-
var import_utils8 = require("@noble/curves/abstract/utils");
|
|
23585
24110
|
var import_secp256k17 = require("@noble/curves/secp256k1");
|
|
24111
|
+
var import_utils9 = require("@noble/curves/utils");
|
|
23586
24112
|
var import_sha26 = require("@noble/hashes/sha2");
|
|
23587
24113
|
var import_btc_signer2 = require("@scure/btc-signer");
|
|
23588
24114
|
var ecies2 = __toESM(require("eciesjs"), 1);
|
|
23589
24115
|
var import_uuidv7 = require("uuidv7");
|
|
23590
24116
|
|
|
23591
24117
|
// src/utils/transfer_package.ts
|
|
23592
|
-
var
|
|
24118
|
+
var import_utils8 = require("@noble/curves/utils");
|
|
23593
24119
|
var import_sha25 = require("@noble/hashes/sha2");
|
|
23594
24120
|
function getTransferPackageSigningPayload(transferID, transferPackage) {
|
|
23595
24121
|
const encryptedPayload = transferPackage.keyTweakPackage;
|
|
@@ -23598,7 +24124,7 @@ function getTransferPackageSigningPayload(transferID, transferPackage) {
|
|
|
23598
24124
|
).map(([key, value]) => ({ key, value }));
|
|
23599
24125
|
pairs.sort((a, b) => a.key.localeCompare(b.key));
|
|
23600
24126
|
const encoder = new TextEncoder();
|
|
23601
|
-
let message = (0,
|
|
24127
|
+
let message = (0, import_utils8.hexToBytes)(transferID.replaceAll("-", ""));
|
|
23602
24128
|
for (const pair of pairs) {
|
|
23603
24129
|
const keyPart = encoder.encode(pair.key + ":");
|
|
23604
24130
|
const separator = encoder.encode(";");
|
|
@@ -23978,7 +24504,7 @@ var BaseTransferService = class {
|
|
|
23978
24504
|
}
|
|
23979
24505
|
async prepareSendTransferKeyTweaks(transferID, receiverIdentityPubkey, leaves, cpfpRefundSignatureMap, directRefundSignatureMap, directFromCpfpRefundSignatureMap) {
|
|
23980
24506
|
const receiverEciesPubKey = ecies2.PublicKey.fromHex(
|
|
23981
|
-
(0,
|
|
24507
|
+
(0, import_utils9.bytesToHex)(receiverIdentityPubkey)
|
|
23982
24508
|
);
|
|
23983
24509
|
const leavesTweaksMap = /* @__PURE__ */ new Map();
|
|
23984
24510
|
for (const leaf of leaves) {
|
|
@@ -24019,7 +24545,7 @@ var BaseTransferService = class {
|
|
|
24019
24545
|
throw new Error(`Share not found for operator ${operator.id}`);
|
|
24020
24546
|
}
|
|
24021
24547
|
const pubkeyTweak = import_secp256k17.secp256k1.getPublicKey(
|
|
24022
|
-
(0,
|
|
24548
|
+
(0, import_utils9.numberToBytesBE)(share.share, 32),
|
|
24023
24549
|
true
|
|
24024
24550
|
);
|
|
24025
24551
|
pubkeySharesTweak.set(identifier, pubkeyTweak);
|
|
@@ -24044,7 +24570,7 @@ var BaseTransferService = class {
|
|
|
24044
24570
|
leafTweaksMap.set(identifier, {
|
|
24045
24571
|
leafId: leaf.leaf.id,
|
|
24046
24572
|
secretShareTweak: {
|
|
24047
|
-
secretShare: (0,
|
|
24573
|
+
secretShare: (0, import_utils9.numberToBytesBE)(share.share, 32),
|
|
24048
24574
|
proofs: share.proofs
|
|
24049
24575
|
},
|
|
24050
24576
|
pubkeySharesTweak: Object.fromEntries(pubkeySharesTweak),
|
|
@@ -24067,7 +24593,7 @@ var BaseTransferService = class {
|
|
|
24067
24593
|
return void 0;
|
|
24068
24594
|
}
|
|
24069
24595
|
compareTransfers(transfer1, transfer2) {
|
|
24070
|
-
return transfer1.id === transfer2.id && (0,
|
|
24596
|
+
return transfer1.id === transfer2.id && (0, import_utils9.equalBytes)(
|
|
24071
24597
|
transfer1.senderIdentityPublicKey,
|
|
24072
24598
|
transfer2.senderIdentityPublicKey
|
|
24073
24599
|
) && transfer1.status === transfer2.status && transfer1.totalValue === transfer2.totalValue && transfer1.expiryTime?.getTime() === transfer2.expiryTime?.getTime() && transfer1.leaves.length === transfer2.leaves.length;
|
|
@@ -24366,7 +24892,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
24366
24892
|
}
|
|
24367
24893
|
const nodeTx = getTxFromRawTxBytes(leaf.leaf.nodeTx);
|
|
24368
24894
|
const cpfpNodeOutPoint = {
|
|
24369
|
-
txid: (0,
|
|
24895
|
+
txid: (0, import_utils9.hexToBytes)(getTxId(nodeTx)),
|
|
24370
24896
|
index: 0
|
|
24371
24897
|
};
|
|
24372
24898
|
let directNodeTx;
|
|
@@ -24374,7 +24900,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
24374
24900
|
if (leaf.leaf.directTx.length > 0) {
|
|
24375
24901
|
directNodeTx = getTxFromRawTxBytes(leaf.leaf.directTx);
|
|
24376
24902
|
directNodeOutPoint = {
|
|
24377
|
-
txid: (0,
|
|
24903
|
+
txid: (0, import_utils9.hexToBytes)(getTxId(directNodeTx)),
|
|
24378
24904
|
index: 0
|
|
24379
24905
|
};
|
|
24380
24906
|
}
|
|
@@ -24508,7 +25034,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
24508
25034
|
throw new Error(`Share not found for operator ${operator.id}`);
|
|
24509
25035
|
}
|
|
24510
25036
|
const pubkeyTweak = import_secp256k17.secp256k1.getPublicKey(
|
|
24511
|
-
(0,
|
|
25037
|
+
(0, import_utils9.numberToBytesBE)(share.share, 32)
|
|
24512
25038
|
);
|
|
24513
25039
|
pubkeySharesTweak.set(identifier, pubkeyTweak);
|
|
24514
25040
|
}
|
|
@@ -24521,7 +25047,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
24521
25047
|
leafTweaksMap.set(identifier, {
|
|
24522
25048
|
leafId: leaf.leaf.id,
|
|
24523
25049
|
secretShareTweak: {
|
|
24524
|
-
secretShare: (0,
|
|
25050
|
+
secretShare: (0, import_utils9.numberToBytesBE)(share.share, 32),
|
|
24525
25051
|
proofs: share.proofs
|
|
24526
25052
|
},
|
|
24527
25053
|
pubkeySharesTweak: Object.fromEntries(pubkeySharesTweak)
|
|
@@ -24707,13 +25233,13 @@ var TransferService = class extends BaseTransferService {
|
|
|
24707
25233
|
});
|
|
24708
25234
|
}
|
|
24709
25235
|
const newCpfpRefundOutPoint = {
|
|
24710
|
-
txid: (0,
|
|
25236
|
+
txid: (0, import_utils9.hexToBytes)(getTxId(cpfpNodeTx)),
|
|
24711
25237
|
index: 0
|
|
24712
25238
|
};
|
|
24713
25239
|
let newDirectRefundOutPoint;
|
|
24714
25240
|
if (newDirectNodeTx) {
|
|
24715
25241
|
newDirectRefundOutPoint = {
|
|
24716
|
-
txid: (0,
|
|
25242
|
+
txid: (0, import_utils9.hexToBytes)(getTxId(newDirectNodeTx)),
|
|
24717
25243
|
index: 0
|
|
24718
25244
|
};
|
|
24719
25245
|
}
|
|
@@ -24841,7 +25367,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
24841
25367
|
const refundTx = getTxFromRawTxBytes(node.refundTx);
|
|
24842
25368
|
const refundSequence = refundTx.getInput(0).sequence || 0;
|
|
24843
25369
|
const newNodeOutPoint = {
|
|
24844
|
-
txid: (0,
|
|
25370
|
+
txid: (0, import_utils9.hexToBytes)(getTxId(nodeTx)),
|
|
24845
25371
|
index: 0
|
|
24846
25372
|
};
|
|
24847
25373
|
const {
|
|
@@ -24878,13 +25404,13 @@ var TransferService = class extends BaseTransferService {
|
|
|
24878
25404
|
});
|
|
24879
25405
|
}
|
|
24880
25406
|
const newCpfpRefundOutPoint = {
|
|
24881
|
-
txid: (0,
|
|
25407
|
+
txid: (0, import_utils9.hexToBytes)(getTxId(newNodeTx)),
|
|
24882
25408
|
index: 0
|
|
24883
25409
|
};
|
|
24884
25410
|
let newDirectRefundOutPoint;
|
|
24885
25411
|
if (newDirectNodeTx) {
|
|
24886
25412
|
newDirectRefundOutPoint = {
|
|
24887
|
-
txid: (0,
|
|
25413
|
+
txid: (0, import_utils9.hexToBytes)(getTxId(newDirectNodeTx)),
|
|
24888
25414
|
index: 0
|
|
24889
25415
|
};
|
|
24890
25416
|
}
|
|
@@ -25118,13 +25644,13 @@ var TransferService = class extends BaseTransferService {
|
|
|
25118
25644
|
};
|
|
25119
25645
|
const signingPublicKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
|
|
25120
25646
|
const cpfpRefundOutPoint = {
|
|
25121
|
-
txid: (0,
|
|
25647
|
+
txid: (0, import_utils9.hexToBytes)(getTxId(nodeTx)),
|
|
25122
25648
|
index: 0
|
|
25123
25649
|
};
|
|
25124
25650
|
let directRefundOutPoint;
|
|
25125
25651
|
if (directNodeTx) {
|
|
25126
25652
|
directRefundOutPoint = {
|
|
25127
|
-
txid: (0,
|
|
25653
|
+
txid: (0, import_utils9.hexToBytes)(getTxId(directNodeTx)),
|
|
25128
25654
|
index: 0
|
|
25129
25655
|
};
|
|
25130
25656
|
}
|
|
@@ -25499,9 +26025,9 @@ var CoopExitService = class extends BaseTransferService {
|
|
|
25499
26025
|
// src/services/deposit.ts
|
|
25500
26026
|
var import_secp256k18 = require("@noble/curves/secp256k1");
|
|
25501
26027
|
var import_sha28 = require("@noble/hashes/sha2");
|
|
25502
|
-
var
|
|
26028
|
+
var import_utils10 = require("@noble/hashes/utils");
|
|
25503
26029
|
var import_btc_signer4 = require("@scure/btc-signer");
|
|
25504
|
-
var
|
|
26030
|
+
var import_utils11 = require("@scure/btc-signer/utils");
|
|
25505
26031
|
|
|
25506
26032
|
// src/utils/proof.ts
|
|
25507
26033
|
var import_sha27 = require("@noble/hashes/sha2");
|
|
@@ -25526,7 +26052,8 @@ var DepositService = class {
|
|
|
25526
26052
|
}
|
|
25527
26053
|
async validateDepositAddress({
|
|
25528
26054
|
address: address2,
|
|
25529
|
-
userPubkey
|
|
26055
|
+
userPubkey,
|
|
26056
|
+
verifyCoordinatorProof = false
|
|
25530
26057
|
}) {
|
|
25531
26058
|
if (!address2.depositAddressProof || !address2.depositAddressProof.proofOfPossessionSignature || !address2.depositAddressProof.addressSignatures) {
|
|
25532
26059
|
throw new ValidationError(
|
|
@@ -25564,10 +26091,10 @@ var DepositService = class {
|
|
|
25564
26091
|
}
|
|
25565
26092
|
const addrHash = (0, import_sha28.sha256)(address2.address);
|
|
25566
26093
|
for (const operator of Object.values(this.config.getSigningOperators())) {
|
|
25567
|
-
if (operator.identifier === this.config.getCoordinatorIdentifier()) {
|
|
26094
|
+
if (operator.identifier === this.config.getCoordinatorIdentifier() && !verifyCoordinatorProof) {
|
|
25568
26095
|
continue;
|
|
25569
26096
|
}
|
|
25570
|
-
const operatorPubkey2 = (0,
|
|
26097
|
+
const operatorPubkey2 = (0, import_utils10.hexToBytes)(operator.identityPublicKey);
|
|
25571
26098
|
const operatorSig = address2.depositAddressProof.addressSignatures[operator.identifier];
|
|
25572
26099
|
if (!operatorSig) {
|
|
25573
26100
|
throw new ValidationError("Operator signature not found", {
|
|
@@ -25576,7 +26103,11 @@ var DepositService = class {
|
|
|
25576
26103
|
});
|
|
25577
26104
|
}
|
|
25578
26105
|
const sig = import_secp256k18.secp256k1.Signature.fromDER(operatorSig);
|
|
25579
|
-
const isVerified2 = import_secp256k18.secp256k1.verify(
|
|
26106
|
+
const isVerified2 = import_secp256k18.secp256k1.verify(
|
|
26107
|
+
sig.toCompactRawBytes(),
|
|
26108
|
+
addrHash,
|
|
26109
|
+
operatorPubkey2
|
|
26110
|
+
);
|
|
25580
26111
|
if (!isVerified2) {
|
|
25581
26112
|
throw new ValidationError("Operator signature verification failed", {
|
|
25582
26113
|
field: "operatorSignature",
|
|
@@ -25585,6 +26116,46 @@ var DepositService = class {
|
|
|
25585
26116
|
}
|
|
25586
26117
|
}
|
|
25587
26118
|
}
|
|
26119
|
+
async generateStaticDepositAddress({
|
|
26120
|
+
signingPubkey
|
|
26121
|
+
}) {
|
|
26122
|
+
const sparkClient = await this.connectionManager.createSparkClient(
|
|
26123
|
+
this.config.getCoordinatorAddress()
|
|
26124
|
+
);
|
|
26125
|
+
let depositResp;
|
|
26126
|
+
try {
|
|
26127
|
+
depositResp = await sparkClient.generate_static_deposit_address({
|
|
26128
|
+
signingPublicKey: signingPubkey,
|
|
26129
|
+
identityPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
26130
|
+
network: this.config.getNetworkProto()
|
|
26131
|
+
});
|
|
26132
|
+
} catch (error) {
|
|
26133
|
+
throw new NetworkError(
|
|
26134
|
+
"Failed to generate static deposit address",
|
|
26135
|
+
{
|
|
26136
|
+
operation: "generate_static_deposit_address",
|
|
26137
|
+
errorCount: 1,
|
|
26138
|
+
errors: error instanceof Error ? error.message : String(error)
|
|
26139
|
+
},
|
|
26140
|
+
error
|
|
26141
|
+
);
|
|
26142
|
+
}
|
|
26143
|
+
if (!depositResp.depositAddress) {
|
|
26144
|
+
throw new ValidationError(
|
|
26145
|
+
"No static deposit address response from coordinator",
|
|
26146
|
+
{
|
|
26147
|
+
field: "depositAddress",
|
|
26148
|
+
value: depositResp
|
|
26149
|
+
}
|
|
26150
|
+
);
|
|
26151
|
+
}
|
|
26152
|
+
await this.validateDepositAddress({
|
|
26153
|
+
address: depositResp.depositAddress,
|
|
26154
|
+
userPubkey: signingPubkey,
|
|
26155
|
+
verifyCoordinatorProof: true
|
|
26156
|
+
});
|
|
26157
|
+
return depositResp;
|
|
26158
|
+
}
|
|
25588
26159
|
async generateDepositAddress({
|
|
25589
26160
|
signingPubkey,
|
|
25590
26161
|
leafId,
|
|
@@ -25652,7 +26223,7 @@ var DepositService = class {
|
|
|
25652
26223
|
});
|
|
25653
26224
|
}
|
|
25654
26225
|
const depositOutPoint = {
|
|
25655
|
-
txid: (0,
|
|
26226
|
+
txid: (0, import_utils10.hexToBytes)(getTxId(depositTx)),
|
|
25656
26227
|
index: vout
|
|
25657
26228
|
};
|
|
25658
26229
|
const depositTxOut = {
|
|
@@ -25671,8 +26242,8 @@ var DepositService = class {
|
|
|
25671
26242
|
const { cpfpRefundTx, directRefundTx, directFromCpfpRefundTx } = createRefundTxs({
|
|
25672
26243
|
sequence: INITIAL_SEQUENCE,
|
|
25673
26244
|
directSequence: INITIAL_DIRECT_SEQUENCE,
|
|
25674
|
-
input: { txid: (0,
|
|
25675
|
-
directInput: { txid: (0,
|
|
26245
|
+
input: { txid: (0, import_utils10.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
|
|
26246
|
+
directInput: { txid: (0, import_utils10.hexToBytes)(getTxId(directRootTx)), index: 0 },
|
|
25676
26247
|
amountSats: amount,
|
|
25677
26248
|
receivingPubkey: signingPubKey,
|
|
25678
26249
|
network: this.config.getNetwork()
|
|
@@ -25802,7 +26373,7 @@ var DepositService = class {
|
|
|
25802
26373
|
}
|
|
25803
26374
|
);
|
|
25804
26375
|
}
|
|
25805
|
-
if (!(0,
|
|
26376
|
+
if (!(0, import_utils11.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
|
|
25806
26377
|
throw new ValidationError("Verifying key mismatch", {
|
|
25807
26378
|
field: "verifyingKey",
|
|
25808
26379
|
value: treeResp.rootNodeSignatureShares.verifyingKey,
|
|
@@ -25966,7 +26537,7 @@ var DepositService = class {
|
|
|
25966
26537
|
});
|
|
25967
26538
|
}
|
|
25968
26539
|
const depositOutPoint = {
|
|
25969
|
-
txid: (0,
|
|
26540
|
+
txid: (0, import_utils10.hexToBytes)(getTxId(depositTx)),
|
|
25970
26541
|
index: vout
|
|
25971
26542
|
};
|
|
25972
26543
|
const depositTxOut = {
|
|
@@ -25979,7 +26550,7 @@ var DepositService = class {
|
|
|
25979
26550
|
const signingPubKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
|
|
25980
26551
|
const { cpfpRefundTx } = createRefundTxs({
|
|
25981
26552
|
sequence: INITIAL_SEQUENCE,
|
|
25982
|
-
input: { txid: (0,
|
|
26553
|
+
input: { txid: (0, import_utils10.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
|
|
25983
26554
|
amountSats: amount,
|
|
25984
26555
|
receivingPubkey: signingPubKey,
|
|
25985
26556
|
network: this.config.getNetwork()
|
|
@@ -26049,7 +26620,7 @@ var DepositService = class {
|
|
|
26049
26620
|
}
|
|
26050
26621
|
);
|
|
26051
26622
|
}
|
|
26052
|
-
if (!(0,
|
|
26623
|
+
if (!(0, import_utils11.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
|
|
26053
26624
|
throw new ValidationError("Verifying key mismatch", {
|
|
26054
26625
|
field: "verifyingKey",
|
|
26055
26626
|
value: treeResp.rootNodeSignatureShares.verifyingKey,
|
|
@@ -26124,8 +26695,8 @@ var DepositService = class {
|
|
|
26124
26695
|
};
|
|
26125
26696
|
|
|
26126
26697
|
// src/services/lightning.ts
|
|
26127
|
-
var import_utils11 = require("@noble/curves/abstract/utils");
|
|
26128
26698
|
var import_secp256k19 = require("@noble/curves/secp256k1");
|
|
26699
|
+
var import_utils12 = require("@noble/curves/utils");
|
|
26129
26700
|
var import_sha29 = require("@noble/hashes/sha2");
|
|
26130
26701
|
var import_uuidv73 = require("uuidv7");
|
|
26131
26702
|
|
|
@@ -26210,8 +26781,8 @@ var LightningService = class {
|
|
|
26210
26781
|
}) {
|
|
26211
26782
|
const crypto = getCrypto();
|
|
26212
26783
|
const randBytes = crypto.getRandomValues(new Uint8Array(32));
|
|
26213
|
-
const preimage = (0,
|
|
26214
|
-
(0,
|
|
26784
|
+
const preimage = (0, import_utils12.numberToBytesBE)(
|
|
26785
|
+
(0, import_utils12.bytesToNumberBE)(randBytes) % import_secp256k19.secp256k1.CURVE.n,
|
|
26215
26786
|
32
|
|
26216
26787
|
);
|
|
26217
26788
|
return await this.createLightningInvoiceWithPreImage({
|
|
@@ -26266,12 +26837,12 @@ var LightningService = class {
|
|
|
26266
26837
|
const sparkClient = await this.connectionManager.createSparkClient(
|
|
26267
26838
|
operator.address
|
|
26268
26839
|
);
|
|
26269
|
-
const userIdentityPublicKey = receiverIdentityPubkey ? (0,
|
|
26840
|
+
const userIdentityPublicKey = receiverIdentityPubkey ? (0, import_utils12.hexToBytes)(receiverIdentityPubkey) : await this.config.signer.getIdentityPublicKey();
|
|
26270
26841
|
try {
|
|
26271
26842
|
await sparkClient.store_preimage_share({
|
|
26272
26843
|
paymentHash,
|
|
26273
26844
|
preimageShare: {
|
|
26274
|
-
secretShare: (0,
|
|
26845
|
+
secretShare: (0, import_utils12.numberToBytesBE)(share.share, 32),
|
|
26275
26846
|
proofs: share.proofs
|
|
26276
26847
|
},
|
|
26277
26848
|
threshold: this.config.getThreshold(),
|
|
@@ -26471,14 +27042,17 @@ var LightningService = class {
|
|
|
26471
27042
|
};
|
|
26472
27043
|
|
|
26473
27044
|
// src/services/token-transactions.ts
|
|
26474
|
-
var import_utils16 = require("@noble/curves/abstract/utils");
|
|
26475
27045
|
var import_secp256k112 = require("@noble/curves/secp256k1");
|
|
27046
|
+
var import_utils16 = require("@noble/curves/utils");
|
|
26476
27047
|
var import_utils17 = require("@noble/hashes/utils");
|
|
26477
27048
|
|
|
26478
27049
|
// src/utils/address.ts
|
|
27050
|
+
var import_wire8 = require("@bufbuild/protobuf/wire");
|
|
26479
27051
|
var import_secp256k110 = require("@noble/curves/secp256k1");
|
|
26480
|
-
var
|
|
27052
|
+
var import_utils13 = require("@noble/curves/utils");
|
|
27053
|
+
var import_utils14 = require("@noble/hashes/utils");
|
|
26481
27054
|
var import_base2 = require("@scure/base");
|
|
27055
|
+
var import_uuidv74 = require("uuidv7");
|
|
26482
27056
|
|
|
26483
27057
|
// src/utils/invoice-hashing.ts
|
|
26484
27058
|
var import_sha210 = require("@noble/hashes/sha2");
|
|
@@ -26647,9 +27221,6 @@ function uint64be(value) {
|
|
|
26647
27221
|
}
|
|
26648
27222
|
|
|
26649
27223
|
// src/utils/address.ts
|
|
26650
|
-
var import_uuidv74 = require("uuidv7");
|
|
26651
|
-
var import_utils13 = require("@noble/curves/abstract/utils");
|
|
26652
|
-
var import_wire8 = require("@bufbuild/protobuf/wire");
|
|
26653
27224
|
var BECH32M_LIMIT = 1024;
|
|
26654
27225
|
var AddressNetwork = {
|
|
26655
27226
|
MAINNET: "sp",
|
|
@@ -26664,7 +27235,7 @@ function encodeSparkAddress(payload) {
|
|
|
26664
27235
|
function encodeSparkAddressWithSignature(payload, signature) {
|
|
26665
27236
|
try {
|
|
26666
27237
|
isValidPublicKey(payload.identityPublicKey);
|
|
26667
|
-
const identityPublicKey = (0,
|
|
27238
|
+
const identityPublicKey = (0, import_utils14.hexToBytes)(payload.identityPublicKey);
|
|
26668
27239
|
let sparkInvoiceFields;
|
|
26669
27240
|
if (payload.sparkInvoiceFields) {
|
|
26670
27241
|
validateSparkInvoiceFields(payload.sparkInvoiceFields);
|
|
@@ -26708,8 +27279,8 @@ function decodeSparkAddress(address2, network) {
|
|
|
26708
27279
|
}
|
|
26709
27280
|
const payload = SparkAddress.decode(import_base2.bech32m.fromWords(decoded.words));
|
|
26710
27281
|
const { identityPublicKey, sparkInvoiceFields, signature } = payload;
|
|
26711
|
-
const identityPubkeyHex = (0,
|
|
26712
|
-
const signatureHex = signature ? (0,
|
|
27282
|
+
const identityPubkeyHex = (0, import_utils14.bytesToHex)(identityPublicKey);
|
|
27283
|
+
const signatureHex = signature ? (0, import_utils14.bytesToHex)(signature) : void 0;
|
|
26713
27284
|
isValidPublicKey(identityPubkeyHex);
|
|
26714
27285
|
return {
|
|
26715
27286
|
identityPublicKey: identityPubkeyHex,
|
|
@@ -26719,7 +27290,7 @@ function decodeSparkAddress(address2, network) {
|
|
|
26719
27290
|
id: import_uuidv74.UUID.ofInner(sparkInvoiceFields.id).toString(),
|
|
26720
27291
|
paymentType: sparkInvoiceFields.paymentType ? sparkInvoiceFields.paymentType.$case === "tokensPayment" ? {
|
|
26721
27292
|
type: "tokens",
|
|
26722
|
-
tokenIdentifier: sparkInvoiceFields.paymentType.tokensPayment.tokenIdentifier ? (0,
|
|
27293
|
+
tokenIdentifier: sparkInvoiceFields.paymentType.tokensPayment.tokenIdentifier ? (0, import_utils14.bytesToHex)(
|
|
26723
27294
|
sparkInvoiceFields.paymentType.tokensPayment.tokenIdentifier
|
|
26724
27295
|
) : void 0,
|
|
26725
27296
|
amount: sparkInvoiceFields.paymentType.tokensPayment.amount ? (0, import_utils13.bytesToNumberBE)(
|
|
@@ -26730,7 +27301,7 @@ function decodeSparkAddress(address2, network) {
|
|
|
26730
27301
|
amount: sparkInvoiceFields.paymentType.satsPayment.amount
|
|
26731
27302
|
} : void 0 : void 0,
|
|
26732
27303
|
memo: sparkInvoiceFields.memo,
|
|
26733
|
-
senderPublicKey: sparkInvoiceFields.senderPublicKey ? (0,
|
|
27304
|
+
senderPublicKey: sparkInvoiceFields.senderPublicKey ? (0, import_utils14.bytesToHex)(sparkInvoiceFields.senderPublicKey) : void 0,
|
|
26734
27305
|
expiryTime: sparkInvoiceFields.expiryTime
|
|
26735
27306
|
},
|
|
26736
27307
|
signature: signatureHex
|
|
@@ -26779,7 +27350,7 @@ function isValidSparkAddress(address2) {
|
|
|
26779
27350
|
}
|
|
26780
27351
|
function isValidPublicKey(publicKey) {
|
|
26781
27352
|
try {
|
|
26782
|
-
const point = import_secp256k110.secp256k1.
|
|
27353
|
+
const point = import_secp256k110.secp256k1.Point.fromHex(publicKey);
|
|
26783
27354
|
point.assertValidity();
|
|
26784
27355
|
} catch (error) {
|
|
26785
27356
|
throw new ValidationError(
|
|
@@ -26814,7 +27385,7 @@ function validateSparkInvoiceFields(sparkInvoiceFields) {
|
|
|
26814
27385
|
}
|
|
26815
27386
|
if (senderPublicKey) {
|
|
26816
27387
|
try {
|
|
26817
|
-
isValidPublicKey((0,
|
|
27388
|
+
isValidPublicKey((0, import_utils14.bytesToHex)(senderPublicKey));
|
|
26818
27389
|
} catch (error) {
|
|
26819
27390
|
throw new ValidationError(
|
|
26820
27391
|
"Invalid sender public key",
|
|
@@ -28963,12 +29534,11 @@ function validateTokenTransaction(finalTokenTransaction, partialTokenTransaction
|
|
|
28963
29534
|
}
|
|
28964
29535
|
|
|
28965
29536
|
// src/utils/token-transactions.ts
|
|
28966
|
-
var
|
|
28967
|
-
var import_utils15 = require("@scure/btc-signer/utils");
|
|
29537
|
+
var import_utils15 = require("@noble/curves/utils");
|
|
28968
29538
|
function sumAvailableTokens(outputs) {
|
|
28969
29539
|
try {
|
|
28970
29540
|
return outputs.reduce(
|
|
28971
|
-
(sum, output) => sum + BigInt((0,
|
|
29541
|
+
(sum, output) => sum + BigInt((0, import_utils15.bytesToNumberBE)(output.output.tokenAmount)),
|
|
28972
29542
|
BigInt(0)
|
|
28973
29543
|
);
|
|
28974
29544
|
} catch (error) {
|
|
@@ -30079,8 +30649,8 @@ function isTokenTransaction(tokenTransaction) {
|
|
|
30079
30649
|
|
|
30080
30650
|
// src/utils/adaptor-signature.ts
|
|
30081
30651
|
var import_modular = require("@noble/curves/abstract/modular");
|
|
30082
|
-
var import_utils18 = require("@noble/curves/abstract/utils");
|
|
30083
30652
|
var import_secp256k113 = require("@noble/curves/secp256k1");
|
|
30653
|
+
var import_utils18 = require("@noble/curves/utils");
|
|
30084
30654
|
function generateSignatureFromExistingAdaptor(signature, adaptorPrivateKeyBytes) {
|
|
30085
30655
|
const { r, s } = parseSignature(signature);
|
|
30086
30656
|
const sBigInt = (0, import_utils18.bytesToNumberBE)(s);
|
|
@@ -30147,7 +30717,7 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
|
|
|
30147
30717
|
const commitmenet = import_secp256k113.schnorr.utils.taggedHash(
|
|
30148
30718
|
"BIP0340/challenge",
|
|
30149
30719
|
r,
|
|
30150
|
-
pubKey.
|
|
30720
|
+
pubKey.toBytes().slice(1),
|
|
30151
30721
|
hash
|
|
30152
30722
|
);
|
|
30153
30723
|
if (commitmenet.length > 32) {
|
|
@@ -30155,22 +30725,20 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
|
|
|
30155
30725
|
}
|
|
30156
30726
|
const e = (0, import_modular.mod)((0, import_utils18.bytesToNumberBE)(commitmenet), import_secp256k113.secp256k1.CURVE.n);
|
|
30157
30727
|
const negE = (0, import_modular.mod)(-e, import_secp256k113.secp256k1.CURVE.n);
|
|
30158
|
-
const
|
|
30159
|
-
|
|
30160
|
-
|
|
30161
|
-
|
|
30162
|
-
|
|
30163
|
-
if (!R) {
|
|
30164
|
-
throw new Error("R is undefined");
|
|
30728
|
+
const sG = import_secp256k113.secp256k1.Point.BASE.multiplyUnsafe((0, import_utils18.bytesToNumberBE)(s));
|
|
30729
|
+
const eP = pubKey.multiplyUnsafe(negE);
|
|
30730
|
+
const R = sG.add(eP);
|
|
30731
|
+
if (R.is0()) {
|
|
30732
|
+
throw new Error("R is zero");
|
|
30165
30733
|
}
|
|
30166
30734
|
R.assertValidity();
|
|
30167
|
-
const adaptorPoint = import_secp256k113.secp256k1.
|
|
30735
|
+
const adaptorPoint = import_secp256k113.secp256k1.Point.fromHex(adaptorPubkey);
|
|
30168
30736
|
const newR = R.add(adaptorPoint);
|
|
30169
|
-
if (!inbound && newR.equals(import_secp256k113.secp256k1.
|
|
30737
|
+
if (!inbound && newR.equals(import_secp256k113.secp256k1.Point.ZERO)) {
|
|
30170
30738
|
throw new Error("calculated R point is the point at infinity");
|
|
30171
30739
|
}
|
|
30172
30740
|
newR.assertValidity();
|
|
30173
|
-
if (
|
|
30741
|
+
if (newR.y % 2n !== 0n) {
|
|
30174
30742
|
throw new Error("calculated R y-value is odd");
|
|
30175
30743
|
}
|
|
30176
30744
|
const rNum = (0, import_utils18.bytesToNumberBE)(r);
|
|
@@ -30217,7 +30785,7 @@ var import_eventemitter3 = require("eventemitter3");
|
|
|
30217
30785
|
var import_nice_grpc_common3 = require("nice-grpc-common");
|
|
30218
30786
|
|
|
30219
30787
|
// src/services/signing.ts
|
|
30220
|
-
var import_utils19 = require("@noble/curves/
|
|
30788
|
+
var import_utils19 = require("@noble/curves/utils");
|
|
30221
30789
|
var SigningService = class {
|
|
30222
30790
|
config;
|
|
30223
30791
|
constructor(config) {
|
|
@@ -30382,8 +30950,8 @@ var SigningService = class {
|
|
|
30382
30950
|
};
|
|
30383
30951
|
|
|
30384
30952
|
// src/tests/utils/test-faucet.ts
|
|
30385
|
-
var import_utils20 = require("@noble/curves/abstract/utils");
|
|
30386
30953
|
var import_secp256k114 = require("@noble/curves/secp256k1");
|
|
30954
|
+
var import_utils20 = require("@noble/curves/utils");
|
|
30387
30955
|
var btc3 = __toESM(require("@scure/btc-signer"), 1);
|
|
30388
30956
|
var import_btc_signer5 = require("@scure/btc-signer");
|
|
30389
30957
|
var import_utils21 = require("@scure/btc-signer/utils");
|
|
@@ -30686,7 +31254,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
30686
31254
|
};
|
|
30687
31255
|
|
|
30688
31256
|
// src/types/sdk-types.ts
|
|
30689
|
-
var import_utils22 = require("@noble/curves/
|
|
31257
|
+
var import_utils22 = require("@noble/curves/utils");
|
|
30690
31258
|
function mapTreeNodeToWalletLeaf(proto) {
|
|
30691
31259
|
return {
|
|
30692
31260
|
id: proto.id,
|
|
@@ -30972,7 +31540,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
30972
31540
|
setTimeout(maybeUnref, 100);
|
|
30973
31541
|
}
|
|
30974
31542
|
};
|
|
30975
|
-
if (
|
|
31543
|
+
if (import_core13.isNode) {
|
|
30976
31544
|
maybeUnref();
|
|
30977
31545
|
}
|
|
30978
31546
|
const claimedTransfersIds = await this.claimTransfers();
|
|
@@ -31994,7 +32562,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31994
32562
|
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
31995
32563
|
*/
|
|
31996
32564
|
async getSingleUseDepositAddress() {
|
|
31997
|
-
return await this.generateDepositAddress(
|
|
32565
|
+
return await this.generateDepositAddress();
|
|
31998
32566
|
}
|
|
31999
32567
|
/**
|
|
32000
32568
|
* Generates a new static deposit address for receiving bitcoin funds.
|
|
@@ -32003,43 +32571,32 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32003
32571
|
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
32004
32572
|
*/
|
|
32005
32573
|
async getStaticDepositAddress() {
|
|
32006
|
-
|
|
32007
|
-
|
|
32008
|
-
|
|
32009
|
-
|
|
32010
|
-
|
|
32011
|
-
|
|
32012
|
-
|
|
32013
|
-
|
|
32014
|
-
|
|
32015
|
-
}
|
|
32016
|
-
} else {
|
|
32017
|
-
throw error;
|
|
32018
|
-
}
|
|
32574
|
+
const signingPubkey = await this.config.signer.getStaticDepositSigningKey(0);
|
|
32575
|
+
const address2 = await this.depositService.generateStaticDepositAddress({
|
|
32576
|
+
signingPubkey
|
|
32577
|
+
});
|
|
32578
|
+
if (!address2.depositAddress) {
|
|
32579
|
+
throw new RPCError("Failed to generate static deposit address", {
|
|
32580
|
+
method: "generateStaticDepositAddress",
|
|
32581
|
+
params: { signingPubkey }
|
|
32582
|
+
});
|
|
32019
32583
|
}
|
|
32584
|
+
return address2.depositAddress.address;
|
|
32020
32585
|
}
|
|
32021
32586
|
/**
|
|
32022
32587
|
* Generates a deposit address for receiving funds.
|
|
32023
|
-
*
|
|
32024
|
-
* @param {boolean} static - Whether the address is static or single use
|
|
32025
32588
|
* @returns {Promise<string>} A deposit address
|
|
32026
32589
|
* @private
|
|
32027
32590
|
*/
|
|
32028
|
-
async generateDepositAddress(
|
|
32591
|
+
async generateDepositAddress() {
|
|
32029
32592
|
const leafId = (0, import_uuidv75.uuidv7)();
|
|
32030
|
-
|
|
32031
|
-
|
|
32032
|
-
|
|
32033
|
-
}
|
|
32034
|
-
signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
|
|
32035
|
-
type: "leaf" /* LEAF */,
|
|
32036
|
-
path: leafId
|
|
32037
|
-
});
|
|
32038
|
-
}
|
|
32593
|
+
const signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
|
|
32594
|
+
type: "leaf" /* LEAF */,
|
|
32595
|
+
path: leafId
|
|
32596
|
+
});
|
|
32039
32597
|
const address2 = await this.depositService.generateDepositAddress({
|
|
32040
32598
|
signingPubkey,
|
|
32041
|
-
leafId
|
|
32042
|
-
isStatic
|
|
32599
|
+
leafId
|
|
32043
32600
|
});
|
|
32044
32601
|
if (!address2.depositAddress) {
|
|
32045
32602
|
throw new RPCError("Failed to generate deposit address", {
|
|
@@ -32066,7 +32623,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32066
32623
|
* @param offset - Pagination offset (default 0).
|
|
32067
32624
|
* @returns {Promise<{ txid: string, vout: number }[]>} List of confirmed UTXOs.
|
|
32068
32625
|
*/
|
|
32069
|
-
async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0) {
|
|
32626
|
+
async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0, excludeClaimed = false) {
|
|
32070
32627
|
if (!depositAddress) {
|
|
32071
32628
|
throw new ValidationError("Deposit address cannot be empty", {
|
|
32072
32629
|
field: "depositAddress"
|
|
@@ -32080,7 +32637,8 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32080
32637
|
address: depositAddress,
|
|
32081
32638
|
network: NetworkToProto[this.config.getNetwork()],
|
|
32082
32639
|
limit,
|
|
32083
|
-
offset
|
|
32640
|
+
offset,
|
|
32641
|
+
excludeClaimed
|
|
32084
32642
|
});
|
|
32085
32643
|
return response.utxos.map((utxo) => ({
|
|
32086
32644
|
txid: (0, import_utils23.bytesToHex)(utxo.txid),
|
|
@@ -33512,7 +34070,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33512
34070
|
if (!feeEstimate) {
|
|
33513
34071
|
throw new Error("Failed to get lightning send fee estimate");
|
|
33514
34072
|
}
|
|
33515
|
-
const satsFeeEstimate = (0,
|
|
34073
|
+
const satsFeeEstimate = (0, import_core13.mapCurrencyAmount)(feeEstimate.feeEstimate);
|
|
33516
34074
|
return Math.ceil(satsFeeEstimate.sats);
|
|
33517
34075
|
}
|
|
33518
34076
|
// ***** Cooperative Exit Flow *****
|
|
@@ -34422,7 +34980,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34422
34980
|
} catch (error) {
|
|
34423
34981
|
if (error instanceof Error) {
|
|
34424
34982
|
error.message += ` [traceId: ${traceId}]`;
|
|
34425
|
-
} else if ((0,
|
|
34983
|
+
} else if ((0, import_core13.isObject)(error)) {
|
|
34426
34984
|
error["traceId"] = traceId;
|
|
34427
34985
|
}
|
|
34428
34986
|
throw error;
|
|
@@ -34495,7 +35053,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34495
35053
|
var import_sdk_trace_web = require("@opentelemetry/sdk-trace-web");
|
|
34496
35054
|
var import_instrumentation = require("@opentelemetry/instrumentation");
|
|
34497
35055
|
var import_instrumentation_fetch = require("@opentelemetry/instrumentation-fetch");
|
|
34498
|
-
var
|
|
35056
|
+
var import_core14 = require("@opentelemetry/core");
|
|
34499
35057
|
var import_api2 = require("@opentelemetry/api");
|
|
34500
35058
|
var SparkWalletBrowser = class _SparkWalletBrowser extends SparkWallet {
|
|
34501
35059
|
static async initialize({
|
|
@@ -34531,7 +35089,7 @@ function initializeTracerEnvBrowser({
|
|
|
34531
35089
|
}) {
|
|
34532
35090
|
const provider = new import_sdk_trace_web.WebTracerProvider({ spanProcessors });
|
|
34533
35091
|
provider.register();
|
|
34534
|
-
import_api2.propagation.setGlobalPropagator(new
|
|
35092
|
+
import_api2.propagation.setGlobalPropagator(new import_core14.W3CTraceContextPropagator());
|
|
34535
35093
|
(0, import_instrumentation.registerInstrumentations)({
|
|
34536
35094
|
instrumentations: [
|
|
34537
35095
|
new import_instrumentation_fetch.FetchInstrumentation({
|
|
@@ -34596,7 +35154,7 @@ async function isTxBroadcast(txid, baseUrl, network) {
|
|
|
34596
35154
|
}
|
|
34597
35155
|
|
|
34598
35156
|
// src/utils/unilateral-exit.ts
|
|
34599
|
-
var import_utils24 = require("@noble/curves/
|
|
35157
|
+
var import_utils24 = require("@noble/curves/utils");
|
|
34600
35158
|
var import_legacy = require("@noble/hashes/legacy");
|
|
34601
35159
|
var import_sha213 = require("@noble/hashes/sha2");
|
|
34602
35160
|
var btc4 = __toESM(require("@scure/btc-signer"), 1);
|
|
@@ -35093,6 +35651,9 @@ function getSparkAddressFromTaproot(taprootAddress) {
|
|
|
35093
35651
|
throw new ValidationError("Invalid taproot address");
|
|
35094
35652
|
}
|
|
35095
35653
|
|
|
35654
|
+
// src/utils/index.ts
|
|
35655
|
+
init_logging();
|
|
35656
|
+
|
|
35096
35657
|
// src/bare/index.ts
|
|
35097
35658
|
globalThis.AbortController = import_cjs_ponyfill.AbortController;
|
|
35098
35659
|
var Headers2 = import_headers.default;
|
|
@@ -35116,6 +35677,7 @@ setFetch(sparkBareFetch, Headers2);
|
|
|
35116
35677
|
INITIAL_DIRECT_SEQUENCE,
|
|
35117
35678
|
INITIAL_SEQUENCE,
|
|
35118
35679
|
InternalValidationError,
|
|
35680
|
+
LOGGER_NAMES,
|
|
35119
35681
|
LRC_WALLET_NETWORK,
|
|
35120
35682
|
Network,
|
|
35121
35683
|
NetworkError,
|
|
@@ -35123,6 +35685,7 @@ setFetch(sparkBareFetch, Headers2);
|
|
|
35123
35685
|
NotImplementedError,
|
|
35124
35686
|
RPCError,
|
|
35125
35687
|
SparkSDKError,
|
|
35688
|
+
SparkSdkLogger,
|
|
35126
35689
|
SparkWallet,
|
|
35127
35690
|
TEST_UNILATERAL_DIRECT_SEQUENCE,
|
|
35128
35691
|
TEST_UNILATERAL_SEQUENCE,
|