@buildonspark/spark-sdk 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/bare/index.cjs +703 -206
- package/dist/bare/index.d.cts +47 -3
- package/dist/bare/index.d.ts +47 -3
- package/dist/bare/index.js +626 -133
- package/dist/{chunk-A5M55UR3.js → chunk-5VWGOHED.js} +499 -8
- package/dist/{chunk-3WBPICWC.js → chunk-NQMQVXR5.js} +1 -1
- package/dist/{chunk-QNYJGFPD.js → chunk-OEK3R57K.js} +149 -123
- 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 +703 -206
- package/dist/debug.d.cts +4 -4
- package/dist/debug.d.ts +4 -4
- package/dist/debug.js +4 -4
- package/dist/graphql/objects/index.d.cts +3 -3
- package/dist/graphql/objects/index.d.ts +3 -3
- package/dist/index.cjs +725 -228
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +5 -5
- package/dist/index.node.cjs +725 -228
- package/dist/index.node.d.cts +6 -6
- package/dist/index.node.d.ts +6 -6
- package/dist/index.node.js +4 -4
- package/dist/{logging-Bt_WdZbu.d.ts → logging-ClNhGzus.d.ts} +3 -3
- package/dist/{logging-BOAzMqpM.d.cts → logging-D3kvES69.d.cts} +3 -3
- package/dist/native/index.cjs +724 -227
- package/dist/native/index.d.cts +47 -3
- package/dist/native/index.d.ts +47 -3
- package/dist/native/index.js +628 -135
- 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/tests/test-utils.cjs +573 -66
- package/dist/tests/test-utils.d.cts +4 -4
- package/dist/tests/test-utils.d.ts +4 -4
- package/dist/tests/test-utils.js +5 -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/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 +55 -3
- 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/signer/signer.ts +2 -2
- package/src/spark-wallet/spark-wallet.ts +25 -33
- 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/static_deposit.test.ts +122 -1
- 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 +1 -1
- 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 +1 -1
- package/src/utils/address.ts +1 -1
- package/src/utils/bitcoin.ts +1 -5
- package/src/utils/keys.ts +1 -1
- package/src/utils/secret-sharing.ts +1 -1
- 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/index.cjs
CHANGED
|
@@ -1111,7 +1111,7 @@ function signFrost({
|
|
|
1111
1111
|
adaptorPubKey
|
|
1112
1112
|
}) {
|
|
1113
1113
|
SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("signFrost", {
|
|
1114
|
-
message: (0,
|
|
1114
|
+
message: (0, import_utils12.bytesToHex)(message),
|
|
1115
1115
|
keyPackage,
|
|
1116
1116
|
nonce,
|
|
1117
1117
|
selfCommitment,
|
|
@@ -1138,15 +1138,15 @@ function aggregateFrost({
|
|
|
1138
1138
|
adaptorPubKey
|
|
1139
1139
|
}) {
|
|
1140
1140
|
SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("aggregateFrost", {
|
|
1141
|
-
message: (0,
|
|
1141
|
+
message: (0, import_utils12.bytesToHex)(message),
|
|
1142
1142
|
statechainCommitments,
|
|
1143
1143
|
selfCommitment,
|
|
1144
1144
|
statechainSignatures,
|
|
1145
|
-
selfSignature: (0,
|
|
1145
|
+
selfSignature: (0, import_utils12.bytesToHex)(selfSignature),
|
|
1146
1146
|
statechainPublicKeys,
|
|
1147
|
-
selfPublicKey: (0,
|
|
1148
|
-
verifyingKey: (0,
|
|
1149
|
-
adaptorPubKey: adaptorPubKey ? (0,
|
|
1147
|
+
selfPublicKey: (0, import_utils12.bytesToHex)(selfPublicKey),
|
|
1148
|
+
verifyingKey: (0, import_utils12.bytesToHex)(verifyingKey),
|
|
1149
|
+
adaptorPubKey: adaptorPubKey ? (0, import_utils12.bytesToHex)(adaptorPubKey) : void 0
|
|
1150
1150
|
});
|
|
1151
1151
|
return wasm_aggregate_frost(
|
|
1152
1152
|
message,
|
|
@@ -1178,12 +1178,12 @@ function decryptEcies({
|
|
|
1178
1178
|
}) {
|
|
1179
1179
|
return decrypt_ecies(encryptedMsg, privateKey);
|
|
1180
1180
|
}
|
|
1181
|
-
var
|
|
1181
|
+
var import_utils12;
|
|
1182
1182
|
var init_wasm = __esm({
|
|
1183
1183
|
"src/spark_bindings/wasm/index.ts"() {
|
|
1184
1184
|
"use strict";
|
|
1185
1185
|
init_buffer();
|
|
1186
|
-
|
|
1186
|
+
import_utils12 = require("@noble/curves/utils");
|
|
1187
1187
|
init_spark_bindings();
|
|
1188
1188
|
init_logging();
|
|
1189
1189
|
}
|
|
@@ -1617,8 +1617,8 @@ init_buffer();
|
|
|
1617
1617
|
// src/utils/address.ts
|
|
1618
1618
|
init_buffer();
|
|
1619
1619
|
var import_wire5 = require("@bufbuild/protobuf/wire");
|
|
1620
|
-
var import_utils2 = require("@noble/curves/abstract/utils");
|
|
1621
1620
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
|
1621
|
+
var import_utils2 = require("@noble/curves/utils");
|
|
1622
1622
|
var import_utils3 = require("@noble/hashes/utils");
|
|
1623
1623
|
var import_base2 = require("@scure/base");
|
|
1624
1624
|
var import_uuidv7 = require("uuidv7");
|
|
@@ -2186,6 +2186,41 @@ function utxoSwapRequestTypeToJSON(object) {
|
|
|
2186
2186
|
return "UNRECOGNIZED";
|
|
2187
2187
|
}
|
|
2188
2188
|
}
|
|
2189
|
+
function invoiceStatusFromJSON(object) {
|
|
2190
|
+
switch (object) {
|
|
2191
|
+
case 0:
|
|
2192
|
+
case "NOT_FOUND":
|
|
2193
|
+
return 0 /* NOT_FOUND */;
|
|
2194
|
+
case 1:
|
|
2195
|
+
case "PENDING":
|
|
2196
|
+
return 1 /* PENDING */;
|
|
2197
|
+
case 2:
|
|
2198
|
+
case "FINALIZED":
|
|
2199
|
+
return 2 /* FINALIZED */;
|
|
2200
|
+
case 3:
|
|
2201
|
+
case "EXPIRED":
|
|
2202
|
+
return 3 /* EXPIRED */;
|
|
2203
|
+
case -1:
|
|
2204
|
+
case "UNRECOGNIZED":
|
|
2205
|
+
default:
|
|
2206
|
+
return -1 /* UNRECOGNIZED */;
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
function invoiceStatusToJSON(object) {
|
|
2210
|
+
switch (object) {
|
|
2211
|
+
case 0 /* NOT_FOUND */:
|
|
2212
|
+
return "NOT_FOUND";
|
|
2213
|
+
case 1 /* PENDING */:
|
|
2214
|
+
return "PENDING";
|
|
2215
|
+
case 2 /* FINALIZED */:
|
|
2216
|
+
return "FINALIZED";
|
|
2217
|
+
case 3 /* EXPIRED */:
|
|
2218
|
+
return "EXPIRED";
|
|
2219
|
+
case -1 /* UNRECOGNIZED */:
|
|
2220
|
+
default:
|
|
2221
|
+
return "UNRECOGNIZED";
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2189
2224
|
function initiatePreimageSwapRequest_ReasonFromJSON(object) {
|
|
2190
2225
|
switch (object) {
|
|
2191
2226
|
case 0:
|
|
@@ -2925,6 +2960,140 @@ var GenerateDepositAddressResponse = {
|
|
|
2925
2960
|
return message;
|
|
2926
2961
|
}
|
|
2927
2962
|
};
|
|
2963
|
+
function createBaseGenerateStaticDepositAddressRequest() {
|
|
2964
|
+
return { signingPublicKey: new Uint8Array(0), identityPublicKey: new Uint8Array(0), network: 0 };
|
|
2965
|
+
}
|
|
2966
|
+
var GenerateStaticDepositAddressRequest = {
|
|
2967
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
2968
|
+
if (message.signingPublicKey.length !== 0) {
|
|
2969
|
+
writer.uint32(10).bytes(message.signingPublicKey);
|
|
2970
|
+
}
|
|
2971
|
+
if (message.identityPublicKey.length !== 0) {
|
|
2972
|
+
writer.uint32(18).bytes(message.identityPublicKey);
|
|
2973
|
+
}
|
|
2974
|
+
if (message.network !== 0) {
|
|
2975
|
+
writer.uint32(24).int32(message.network);
|
|
2976
|
+
}
|
|
2977
|
+
return writer;
|
|
2978
|
+
},
|
|
2979
|
+
decode(input, length) {
|
|
2980
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
2981
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
2982
|
+
const message = createBaseGenerateStaticDepositAddressRequest();
|
|
2983
|
+
while (reader.pos < end) {
|
|
2984
|
+
const tag = reader.uint32();
|
|
2985
|
+
switch (tag >>> 3) {
|
|
2986
|
+
case 1: {
|
|
2987
|
+
if (tag !== 10) {
|
|
2988
|
+
break;
|
|
2989
|
+
}
|
|
2990
|
+
message.signingPublicKey = reader.bytes();
|
|
2991
|
+
continue;
|
|
2992
|
+
}
|
|
2993
|
+
case 2: {
|
|
2994
|
+
if (tag !== 18) {
|
|
2995
|
+
break;
|
|
2996
|
+
}
|
|
2997
|
+
message.identityPublicKey = reader.bytes();
|
|
2998
|
+
continue;
|
|
2999
|
+
}
|
|
3000
|
+
case 3: {
|
|
3001
|
+
if (tag !== 24) {
|
|
3002
|
+
break;
|
|
3003
|
+
}
|
|
3004
|
+
message.network = reader.int32();
|
|
3005
|
+
continue;
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
3009
|
+
break;
|
|
3010
|
+
}
|
|
3011
|
+
reader.skip(tag & 7);
|
|
3012
|
+
}
|
|
3013
|
+
return message;
|
|
3014
|
+
},
|
|
3015
|
+
fromJSON(object) {
|
|
3016
|
+
return {
|
|
3017
|
+
signingPublicKey: isSet3(object.signingPublicKey) ? bytesFromBase642(object.signingPublicKey) : new Uint8Array(0),
|
|
3018
|
+
identityPublicKey: isSet3(object.identityPublicKey) ? bytesFromBase642(object.identityPublicKey) : new Uint8Array(0),
|
|
3019
|
+
network: isSet3(object.network) ? networkFromJSON(object.network) : 0
|
|
3020
|
+
};
|
|
3021
|
+
},
|
|
3022
|
+
toJSON(message) {
|
|
3023
|
+
const obj = {};
|
|
3024
|
+
if (message.signingPublicKey.length !== 0) {
|
|
3025
|
+
obj.signingPublicKey = base64FromBytes2(message.signingPublicKey);
|
|
3026
|
+
}
|
|
3027
|
+
if (message.identityPublicKey.length !== 0) {
|
|
3028
|
+
obj.identityPublicKey = base64FromBytes2(message.identityPublicKey);
|
|
3029
|
+
}
|
|
3030
|
+
if (message.network !== 0) {
|
|
3031
|
+
obj.network = networkToJSON(message.network);
|
|
3032
|
+
}
|
|
3033
|
+
return obj;
|
|
3034
|
+
},
|
|
3035
|
+
create(base) {
|
|
3036
|
+
return GenerateStaticDepositAddressRequest.fromPartial(base ?? {});
|
|
3037
|
+
},
|
|
3038
|
+
fromPartial(object) {
|
|
3039
|
+
const message = createBaseGenerateStaticDepositAddressRequest();
|
|
3040
|
+
message.signingPublicKey = object.signingPublicKey ?? new Uint8Array(0);
|
|
3041
|
+
message.identityPublicKey = object.identityPublicKey ?? new Uint8Array(0);
|
|
3042
|
+
message.network = object.network ?? 0;
|
|
3043
|
+
return message;
|
|
3044
|
+
}
|
|
3045
|
+
};
|
|
3046
|
+
function createBaseGenerateStaticDepositAddressResponse() {
|
|
3047
|
+
return { depositAddress: void 0 };
|
|
3048
|
+
}
|
|
3049
|
+
var GenerateStaticDepositAddressResponse = {
|
|
3050
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
3051
|
+
if (message.depositAddress !== void 0) {
|
|
3052
|
+
Address.encode(message.depositAddress, writer.uint32(10).fork()).join();
|
|
3053
|
+
}
|
|
3054
|
+
return writer;
|
|
3055
|
+
},
|
|
3056
|
+
decode(input, length) {
|
|
3057
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
3058
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
3059
|
+
const message = createBaseGenerateStaticDepositAddressResponse();
|
|
3060
|
+
while (reader.pos < end) {
|
|
3061
|
+
const tag = reader.uint32();
|
|
3062
|
+
switch (tag >>> 3) {
|
|
3063
|
+
case 1: {
|
|
3064
|
+
if (tag !== 10) {
|
|
3065
|
+
break;
|
|
3066
|
+
}
|
|
3067
|
+
message.depositAddress = Address.decode(reader, reader.uint32());
|
|
3068
|
+
continue;
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
3072
|
+
break;
|
|
3073
|
+
}
|
|
3074
|
+
reader.skip(tag & 7);
|
|
3075
|
+
}
|
|
3076
|
+
return message;
|
|
3077
|
+
},
|
|
3078
|
+
fromJSON(object) {
|
|
3079
|
+
return { depositAddress: isSet3(object.depositAddress) ? Address.fromJSON(object.depositAddress) : void 0 };
|
|
3080
|
+
},
|
|
3081
|
+
toJSON(message) {
|
|
3082
|
+
const obj = {};
|
|
3083
|
+
if (message.depositAddress !== void 0) {
|
|
3084
|
+
obj.depositAddress = Address.toJSON(message.depositAddress);
|
|
3085
|
+
}
|
|
3086
|
+
return obj;
|
|
3087
|
+
},
|
|
3088
|
+
create(base) {
|
|
3089
|
+
return GenerateStaticDepositAddressResponse.fromPartial(base ?? {});
|
|
3090
|
+
},
|
|
3091
|
+
fromPartial(object) {
|
|
3092
|
+
const message = createBaseGenerateStaticDepositAddressResponse();
|
|
3093
|
+
message.depositAddress = object.depositAddress !== void 0 && object.depositAddress !== null ? Address.fromPartial(object.depositAddress) : void 0;
|
|
3094
|
+
return message;
|
|
3095
|
+
}
|
|
3096
|
+
};
|
|
2928
3097
|
function createBaseUTXO() {
|
|
2929
3098
|
return { rawTx: new Uint8Array(0), vout: 0, network: 0, txid: new Uint8Array(0) };
|
|
2930
3099
|
}
|
|
@@ -9038,7 +9207,8 @@ function createBaseTransferLeaf() {
|
|
|
9038
9207
|
signature: new Uint8Array(0),
|
|
9039
9208
|
intermediateRefundTx: new Uint8Array(0),
|
|
9040
9209
|
intermediateDirectRefundTx: new Uint8Array(0),
|
|
9041
|
-
intermediateDirectFromCpfpRefundTx: new Uint8Array(0)
|
|
9210
|
+
intermediateDirectFromCpfpRefundTx: new Uint8Array(0),
|
|
9211
|
+
pendingKeyTweakPublicKey: new Uint8Array(0)
|
|
9042
9212
|
};
|
|
9043
9213
|
}
|
|
9044
9214
|
var TransferLeaf = {
|
|
@@ -9061,6 +9231,9 @@ var TransferLeaf = {
|
|
|
9061
9231
|
if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
|
|
9062
9232
|
writer.uint32(50).bytes(message.intermediateDirectFromCpfpRefundTx);
|
|
9063
9233
|
}
|
|
9234
|
+
if (message.pendingKeyTweakPublicKey.length !== 0) {
|
|
9235
|
+
writer.uint32(58).bytes(message.pendingKeyTweakPublicKey);
|
|
9236
|
+
}
|
|
9064
9237
|
return writer;
|
|
9065
9238
|
},
|
|
9066
9239
|
decode(input, length) {
|
|
@@ -9112,6 +9285,13 @@ var TransferLeaf = {
|
|
|
9112
9285
|
message.intermediateDirectFromCpfpRefundTx = reader.bytes();
|
|
9113
9286
|
continue;
|
|
9114
9287
|
}
|
|
9288
|
+
case 7: {
|
|
9289
|
+
if (tag !== 58) {
|
|
9290
|
+
break;
|
|
9291
|
+
}
|
|
9292
|
+
message.pendingKeyTweakPublicKey = reader.bytes();
|
|
9293
|
+
continue;
|
|
9294
|
+
}
|
|
9115
9295
|
}
|
|
9116
9296
|
if ((tag & 7) === 4 || tag === 0) {
|
|
9117
9297
|
break;
|
|
@@ -9127,7 +9307,8 @@ var TransferLeaf = {
|
|
|
9127
9307
|
signature: isSet3(object.signature) ? bytesFromBase642(object.signature) : new Uint8Array(0),
|
|
9128
9308
|
intermediateRefundTx: isSet3(object.intermediateRefundTx) ? bytesFromBase642(object.intermediateRefundTx) : new Uint8Array(0),
|
|
9129
9309
|
intermediateDirectRefundTx: isSet3(object.intermediateDirectRefundTx) ? bytesFromBase642(object.intermediateDirectRefundTx) : new Uint8Array(0),
|
|
9130
|
-
intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0)
|
|
9310
|
+
intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0),
|
|
9311
|
+
pendingKeyTweakPublicKey: isSet3(object.pendingKeyTweakPublicKey) ? bytesFromBase642(object.pendingKeyTweakPublicKey) : new Uint8Array(0)
|
|
9131
9312
|
};
|
|
9132
9313
|
},
|
|
9133
9314
|
toJSON(message) {
|
|
@@ -9150,6 +9331,9 @@ var TransferLeaf = {
|
|
|
9150
9331
|
if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
|
|
9151
9332
|
obj.intermediateDirectFromCpfpRefundTx = base64FromBytes2(message.intermediateDirectFromCpfpRefundTx);
|
|
9152
9333
|
}
|
|
9334
|
+
if (message.pendingKeyTweakPublicKey.length !== 0) {
|
|
9335
|
+
obj.pendingKeyTweakPublicKey = base64FromBytes2(message.pendingKeyTweakPublicKey);
|
|
9336
|
+
}
|
|
9153
9337
|
return obj;
|
|
9154
9338
|
},
|
|
9155
9339
|
create(base) {
|
|
@@ -9163,6 +9347,7 @@ var TransferLeaf = {
|
|
|
9163
9347
|
message.intermediateRefundTx = object.intermediateRefundTx ?? new Uint8Array(0);
|
|
9164
9348
|
message.intermediateDirectRefundTx = object.intermediateDirectRefundTx ?? new Uint8Array(0);
|
|
9165
9349
|
message.intermediateDirectFromCpfpRefundTx = object.intermediateDirectFromCpfpRefundTx ?? new Uint8Array(0);
|
|
9350
|
+
message.pendingKeyTweakPublicKey = object.pendingKeyTweakPublicKey ?? new Uint8Array(0);
|
|
9166
9351
|
return message;
|
|
9167
9352
|
}
|
|
9168
9353
|
};
|
|
@@ -12060,13 +12245,16 @@ var QueryUserSignedRefundsRequest = {
|
|
|
12060
12245
|
}
|
|
12061
12246
|
};
|
|
12062
12247
|
function createBaseQueryUserSignedRefundsResponse() {
|
|
12063
|
-
return { userSignedRefunds: [] };
|
|
12248
|
+
return { userSignedRefunds: [], transfer: void 0 };
|
|
12064
12249
|
}
|
|
12065
12250
|
var QueryUserSignedRefundsResponse = {
|
|
12066
12251
|
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
12067
12252
|
for (const v of message.userSignedRefunds) {
|
|
12068
12253
|
UserSignedRefund.encode(v, writer.uint32(10).fork()).join();
|
|
12069
12254
|
}
|
|
12255
|
+
if (message.transfer !== void 0) {
|
|
12256
|
+
Transfer.encode(message.transfer, writer.uint32(26).fork()).join();
|
|
12257
|
+
}
|
|
12070
12258
|
return writer;
|
|
12071
12259
|
},
|
|
12072
12260
|
decode(input, length) {
|
|
@@ -12083,6 +12271,13 @@ var QueryUserSignedRefundsResponse = {
|
|
|
12083
12271
|
message.userSignedRefunds.push(UserSignedRefund.decode(reader, reader.uint32()));
|
|
12084
12272
|
continue;
|
|
12085
12273
|
}
|
|
12274
|
+
case 3: {
|
|
12275
|
+
if (tag !== 26) {
|
|
12276
|
+
break;
|
|
12277
|
+
}
|
|
12278
|
+
message.transfer = Transfer.decode(reader, reader.uint32());
|
|
12279
|
+
continue;
|
|
12280
|
+
}
|
|
12086
12281
|
}
|
|
12087
12282
|
if ((tag & 7) === 4 || tag === 0) {
|
|
12088
12283
|
break;
|
|
@@ -12093,7 +12288,8 @@ var QueryUserSignedRefundsResponse = {
|
|
|
12093
12288
|
},
|
|
12094
12289
|
fromJSON(object) {
|
|
12095
12290
|
return {
|
|
12096
|
-
userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : []
|
|
12291
|
+
userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : [],
|
|
12292
|
+
transfer: isSet3(object.transfer) ? Transfer.fromJSON(object.transfer) : void 0
|
|
12097
12293
|
};
|
|
12098
12294
|
},
|
|
12099
12295
|
toJSON(message) {
|
|
@@ -12101,6 +12297,9 @@ var QueryUserSignedRefundsResponse = {
|
|
|
12101
12297
|
if (message.userSignedRefunds?.length) {
|
|
12102
12298
|
obj.userSignedRefunds = message.userSignedRefunds.map((e) => UserSignedRefund.toJSON(e));
|
|
12103
12299
|
}
|
|
12300
|
+
if (message.transfer !== void 0) {
|
|
12301
|
+
obj.transfer = Transfer.toJSON(message.transfer);
|
|
12302
|
+
}
|
|
12104
12303
|
return obj;
|
|
12105
12304
|
},
|
|
12106
12305
|
create(base) {
|
|
@@ -12109,6 +12308,7 @@ var QueryUserSignedRefundsResponse = {
|
|
|
12109
12308
|
fromPartial(object) {
|
|
12110
12309
|
const message = createBaseQueryUserSignedRefundsResponse();
|
|
12111
12310
|
message.userSignedRefunds = object.userSignedRefunds?.map((e) => UserSignedRefund.fromPartial(e)) || [];
|
|
12311
|
+
message.transfer = object.transfer !== void 0 && object.transfer !== null ? Transfer.fromPartial(object.transfer) : void 0;
|
|
12112
12312
|
return message;
|
|
12113
12313
|
}
|
|
12114
12314
|
};
|
|
@@ -12995,7 +13195,8 @@ function createBaseDepositAddressQueryResult() {
|
|
|
12995
13195
|
depositAddress: "",
|
|
12996
13196
|
userSigningPublicKey: new Uint8Array(0),
|
|
12997
13197
|
verifyingPublicKey: new Uint8Array(0),
|
|
12998
|
-
leafId: void 0
|
|
13198
|
+
leafId: void 0,
|
|
13199
|
+
proofOfPossession: void 0
|
|
12999
13200
|
};
|
|
13000
13201
|
}
|
|
13001
13202
|
var DepositAddressQueryResult = {
|
|
@@ -13012,6 +13213,9 @@ var DepositAddressQueryResult = {
|
|
|
13012
13213
|
if (message.leafId !== void 0) {
|
|
13013
13214
|
writer.uint32(34).string(message.leafId);
|
|
13014
13215
|
}
|
|
13216
|
+
if (message.proofOfPossession !== void 0) {
|
|
13217
|
+
DepositAddressProof.encode(message.proofOfPossession, writer.uint32(42).fork()).join();
|
|
13218
|
+
}
|
|
13015
13219
|
return writer;
|
|
13016
13220
|
},
|
|
13017
13221
|
decode(input, length) {
|
|
@@ -13049,6 +13253,13 @@ var DepositAddressQueryResult = {
|
|
|
13049
13253
|
message.leafId = reader.string();
|
|
13050
13254
|
continue;
|
|
13051
13255
|
}
|
|
13256
|
+
case 5: {
|
|
13257
|
+
if (tag !== 42) {
|
|
13258
|
+
break;
|
|
13259
|
+
}
|
|
13260
|
+
message.proofOfPossession = DepositAddressProof.decode(reader, reader.uint32());
|
|
13261
|
+
continue;
|
|
13262
|
+
}
|
|
13052
13263
|
}
|
|
13053
13264
|
if ((tag & 7) === 4 || tag === 0) {
|
|
13054
13265
|
break;
|
|
@@ -13062,7 +13273,8 @@ var DepositAddressQueryResult = {
|
|
|
13062
13273
|
depositAddress: isSet3(object.depositAddress) ? globalThis.String(object.depositAddress) : "",
|
|
13063
13274
|
userSigningPublicKey: isSet3(object.userSigningPublicKey) ? bytesFromBase642(object.userSigningPublicKey) : new Uint8Array(0),
|
|
13064
13275
|
verifyingPublicKey: isSet3(object.verifyingPublicKey) ? bytesFromBase642(object.verifyingPublicKey) : new Uint8Array(0),
|
|
13065
|
-
leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0
|
|
13276
|
+
leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0,
|
|
13277
|
+
proofOfPossession: isSet3(object.proofOfPossession) ? DepositAddressProof.fromJSON(object.proofOfPossession) : void 0
|
|
13066
13278
|
};
|
|
13067
13279
|
},
|
|
13068
13280
|
toJSON(message) {
|
|
@@ -13079,6 +13291,9 @@ var DepositAddressQueryResult = {
|
|
|
13079
13291
|
if (message.leafId !== void 0) {
|
|
13080
13292
|
obj.leafId = message.leafId;
|
|
13081
13293
|
}
|
|
13294
|
+
if (message.proofOfPossession !== void 0) {
|
|
13295
|
+
obj.proofOfPossession = DepositAddressProof.toJSON(message.proofOfPossession);
|
|
13296
|
+
}
|
|
13082
13297
|
return obj;
|
|
13083
13298
|
},
|
|
13084
13299
|
create(base) {
|
|
@@ -13090,6 +13305,7 @@ var DepositAddressQueryResult = {
|
|
|
13090
13305
|
message.userSigningPublicKey = object.userSigningPublicKey ?? new Uint8Array(0);
|
|
13091
13306
|
message.verifyingPublicKey = object.verifyingPublicKey ?? new Uint8Array(0);
|
|
13092
13307
|
message.leafId = object.leafId ?? void 0;
|
|
13308
|
+
message.proofOfPossession = object.proofOfPossession !== void 0 && object.proofOfPossession !== null ? DepositAddressProof.fromPartial(object.proofOfPossession) : void 0;
|
|
13093
13309
|
return message;
|
|
13094
13310
|
}
|
|
13095
13311
|
};
|
|
@@ -15054,7 +15270,7 @@ var QueryNodesByValueResponse_NodesEntry = {
|
|
|
15054
15270
|
}
|
|
15055
15271
|
};
|
|
15056
15272
|
function createBaseGetUtxosForAddressRequest() {
|
|
15057
|
-
return { address: "", offset: 0, limit: 0, network: 0 };
|
|
15273
|
+
return { address: "", offset: 0, limit: 0, network: 0, excludeClaimed: false };
|
|
15058
15274
|
}
|
|
15059
15275
|
var GetUtxosForAddressRequest = {
|
|
15060
15276
|
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
@@ -15070,6 +15286,9 @@ var GetUtxosForAddressRequest = {
|
|
|
15070
15286
|
if (message.network !== 0) {
|
|
15071
15287
|
writer.uint32(32).int32(message.network);
|
|
15072
15288
|
}
|
|
15289
|
+
if (message.excludeClaimed !== false) {
|
|
15290
|
+
writer.uint32(40).bool(message.excludeClaimed);
|
|
15291
|
+
}
|
|
15073
15292
|
return writer;
|
|
15074
15293
|
},
|
|
15075
15294
|
decode(input, length) {
|
|
@@ -15107,6 +15326,13 @@ var GetUtxosForAddressRequest = {
|
|
|
15107
15326
|
message.network = reader.int32();
|
|
15108
15327
|
continue;
|
|
15109
15328
|
}
|
|
15329
|
+
case 5: {
|
|
15330
|
+
if (tag !== 40) {
|
|
15331
|
+
break;
|
|
15332
|
+
}
|
|
15333
|
+
message.excludeClaimed = reader.bool();
|
|
15334
|
+
continue;
|
|
15335
|
+
}
|
|
15110
15336
|
}
|
|
15111
15337
|
if ((tag & 7) === 4 || tag === 0) {
|
|
15112
15338
|
break;
|
|
@@ -15120,7 +15346,8 @@ var GetUtxosForAddressRequest = {
|
|
|
15120
15346
|
address: isSet3(object.address) ? globalThis.String(object.address) : "",
|
|
15121
15347
|
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
15122
15348
|
limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
|
|
15123
|
-
network: isSet3(object.network) ? networkFromJSON(object.network) : 0
|
|
15349
|
+
network: isSet3(object.network) ? networkFromJSON(object.network) : 0,
|
|
15350
|
+
excludeClaimed: isSet3(object.excludeClaimed) ? globalThis.Boolean(object.excludeClaimed) : false
|
|
15124
15351
|
};
|
|
15125
15352
|
},
|
|
15126
15353
|
toJSON(message) {
|
|
@@ -15137,6 +15364,9 @@ var GetUtxosForAddressRequest = {
|
|
|
15137
15364
|
if (message.network !== 0) {
|
|
15138
15365
|
obj.network = networkToJSON(message.network);
|
|
15139
15366
|
}
|
|
15367
|
+
if (message.excludeClaimed !== false) {
|
|
15368
|
+
obj.excludeClaimed = message.excludeClaimed;
|
|
15369
|
+
}
|
|
15140
15370
|
return obj;
|
|
15141
15371
|
},
|
|
15142
15372
|
create(base) {
|
|
@@ -15148,6 +15378,7 @@ var GetUtxosForAddressRequest = {
|
|
|
15148
15378
|
message.offset = object.offset ?? 0;
|
|
15149
15379
|
message.limit = object.limit ?? 0;
|
|
15150
15380
|
message.network = object.network ?? 0;
|
|
15381
|
+
message.excludeClaimed = object.excludeClaimed ?? false;
|
|
15151
15382
|
return message;
|
|
15152
15383
|
}
|
|
15153
15384
|
};
|
|
@@ -15219,6 +15450,225 @@ var GetUtxosForAddressResponse = {
|
|
|
15219
15450
|
return message;
|
|
15220
15451
|
}
|
|
15221
15452
|
};
|
|
15453
|
+
function createBaseQuerySparkInvoicesRequest() {
|
|
15454
|
+
return { limit: 0, offset: 0, invoice: [] };
|
|
15455
|
+
}
|
|
15456
|
+
var QuerySparkInvoicesRequest = {
|
|
15457
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
15458
|
+
if (message.limit !== 0) {
|
|
15459
|
+
writer.uint32(8).int64(message.limit);
|
|
15460
|
+
}
|
|
15461
|
+
if (message.offset !== 0) {
|
|
15462
|
+
writer.uint32(16).int64(message.offset);
|
|
15463
|
+
}
|
|
15464
|
+
for (const v of message.invoice) {
|
|
15465
|
+
writer.uint32(26).string(v);
|
|
15466
|
+
}
|
|
15467
|
+
return writer;
|
|
15468
|
+
},
|
|
15469
|
+
decode(input, length) {
|
|
15470
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
15471
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15472
|
+
const message = createBaseQuerySparkInvoicesRequest();
|
|
15473
|
+
while (reader.pos < end) {
|
|
15474
|
+
const tag = reader.uint32();
|
|
15475
|
+
switch (tag >>> 3) {
|
|
15476
|
+
case 1: {
|
|
15477
|
+
if (tag !== 8) {
|
|
15478
|
+
break;
|
|
15479
|
+
}
|
|
15480
|
+
message.limit = longToNumber2(reader.int64());
|
|
15481
|
+
continue;
|
|
15482
|
+
}
|
|
15483
|
+
case 2: {
|
|
15484
|
+
if (tag !== 16) {
|
|
15485
|
+
break;
|
|
15486
|
+
}
|
|
15487
|
+
message.offset = longToNumber2(reader.int64());
|
|
15488
|
+
continue;
|
|
15489
|
+
}
|
|
15490
|
+
case 3: {
|
|
15491
|
+
if (tag !== 26) {
|
|
15492
|
+
break;
|
|
15493
|
+
}
|
|
15494
|
+
message.invoice.push(reader.string());
|
|
15495
|
+
continue;
|
|
15496
|
+
}
|
|
15497
|
+
}
|
|
15498
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
15499
|
+
break;
|
|
15500
|
+
}
|
|
15501
|
+
reader.skip(tag & 7);
|
|
15502
|
+
}
|
|
15503
|
+
return message;
|
|
15504
|
+
},
|
|
15505
|
+
fromJSON(object) {
|
|
15506
|
+
return {
|
|
15507
|
+
limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
|
|
15508
|
+
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
15509
|
+
invoice: globalThis.Array.isArray(object?.invoice) ? object.invoice.map((e) => globalThis.String(e)) : []
|
|
15510
|
+
};
|
|
15511
|
+
},
|
|
15512
|
+
toJSON(message) {
|
|
15513
|
+
const obj = {};
|
|
15514
|
+
if (message.limit !== 0) {
|
|
15515
|
+
obj.limit = Math.round(message.limit);
|
|
15516
|
+
}
|
|
15517
|
+
if (message.offset !== 0) {
|
|
15518
|
+
obj.offset = Math.round(message.offset);
|
|
15519
|
+
}
|
|
15520
|
+
if (message.invoice?.length) {
|
|
15521
|
+
obj.invoice = message.invoice;
|
|
15522
|
+
}
|
|
15523
|
+
return obj;
|
|
15524
|
+
},
|
|
15525
|
+
create(base) {
|
|
15526
|
+
return QuerySparkInvoicesRequest.fromPartial(base ?? {});
|
|
15527
|
+
},
|
|
15528
|
+
fromPartial(object) {
|
|
15529
|
+
const message = createBaseQuerySparkInvoicesRequest();
|
|
15530
|
+
message.limit = object.limit ?? 0;
|
|
15531
|
+
message.offset = object.offset ?? 0;
|
|
15532
|
+
message.invoice = object.invoice?.map((e) => e) || [];
|
|
15533
|
+
return message;
|
|
15534
|
+
}
|
|
15535
|
+
};
|
|
15536
|
+
function createBaseQuerySparkInvoicesResponse() {
|
|
15537
|
+
return { offset: 0, invoiceStatuses: [] };
|
|
15538
|
+
}
|
|
15539
|
+
var QuerySparkInvoicesResponse = {
|
|
15540
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
15541
|
+
if (message.offset !== 0) {
|
|
15542
|
+
writer.uint32(8).int64(message.offset);
|
|
15543
|
+
}
|
|
15544
|
+
for (const v of message.invoiceStatuses) {
|
|
15545
|
+
InvoiceResponse.encode(v, writer.uint32(18).fork()).join();
|
|
15546
|
+
}
|
|
15547
|
+
return writer;
|
|
15548
|
+
},
|
|
15549
|
+
decode(input, length) {
|
|
15550
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
15551
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15552
|
+
const message = createBaseQuerySparkInvoicesResponse();
|
|
15553
|
+
while (reader.pos < end) {
|
|
15554
|
+
const tag = reader.uint32();
|
|
15555
|
+
switch (tag >>> 3) {
|
|
15556
|
+
case 1: {
|
|
15557
|
+
if (tag !== 8) {
|
|
15558
|
+
break;
|
|
15559
|
+
}
|
|
15560
|
+
message.offset = longToNumber2(reader.int64());
|
|
15561
|
+
continue;
|
|
15562
|
+
}
|
|
15563
|
+
case 2: {
|
|
15564
|
+
if (tag !== 18) {
|
|
15565
|
+
break;
|
|
15566
|
+
}
|
|
15567
|
+
message.invoiceStatuses.push(InvoiceResponse.decode(reader, reader.uint32()));
|
|
15568
|
+
continue;
|
|
15569
|
+
}
|
|
15570
|
+
}
|
|
15571
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
15572
|
+
break;
|
|
15573
|
+
}
|
|
15574
|
+
reader.skip(tag & 7);
|
|
15575
|
+
}
|
|
15576
|
+
return message;
|
|
15577
|
+
},
|
|
15578
|
+
fromJSON(object) {
|
|
15579
|
+
return {
|
|
15580
|
+
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
15581
|
+
invoiceStatuses: globalThis.Array.isArray(object?.invoiceStatuses) ? object.invoiceStatuses.map((e) => InvoiceResponse.fromJSON(e)) : []
|
|
15582
|
+
};
|
|
15583
|
+
},
|
|
15584
|
+
toJSON(message) {
|
|
15585
|
+
const obj = {};
|
|
15586
|
+
if (message.offset !== 0) {
|
|
15587
|
+
obj.offset = Math.round(message.offset);
|
|
15588
|
+
}
|
|
15589
|
+
if (message.invoiceStatuses?.length) {
|
|
15590
|
+
obj.invoiceStatuses = message.invoiceStatuses.map((e) => InvoiceResponse.toJSON(e));
|
|
15591
|
+
}
|
|
15592
|
+
return obj;
|
|
15593
|
+
},
|
|
15594
|
+
create(base) {
|
|
15595
|
+
return QuerySparkInvoicesResponse.fromPartial(base ?? {});
|
|
15596
|
+
},
|
|
15597
|
+
fromPartial(object) {
|
|
15598
|
+
const message = createBaseQuerySparkInvoicesResponse();
|
|
15599
|
+
message.offset = object.offset ?? 0;
|
|
15600
|
+
message.invoiceStatuses = object.invoiceStatuses?.map((e) => InvoiceResponse.fromPartial(e)) || [];
|
|
15601
|
+
return message;
|
|
15602
|
+
}
|
|
15603
|
+
};
|
|
15604
|
+
function createBaseInvoiceResponse() {
|
|
15605
|
+
return { invoice: "", status: 0 };
|
|
15606
|
+
}
|
|
15607
|
+
var InvoiceResponse = {
|
|
15608
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
15609
|
+
if (message.invoice !== "") {
|
|
15610
|
+
writer.uint32(10).string(message.invoice);
|
|
15611
|
+
}
|
|
15612
|
+
if (message.status !== 0) {
|
|
15613
|
+
writer.uint32(16).int32(message.status);
|
|
15614
|
+
}
|
|
15615
|
+
return writer;
|
|
15616
|
+
},
|
|
15617
|
+
decode(input, length) {
|
|
15618
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
15619
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15620
|
+
const message = createBaseInvoiceResponse();
|
|
15621
|
+
while (reader.pos < end) {
|
|
15622
|
+
const tag = reader.uint32();
|
|
15623
|
+
switch (tag >>> 3) {
|
|
15624
|
+
case 1: {
|
|
15625
|
+
if (tag !== 10) {
|
|
15626
|
+
break;
|
|
15627
|
+
}
|
|
15628
|
+
message.invoice = reader.string();
|
|
15629
|
+
continue;
|
|
15630
|
+
}
|
|
15631
|
+
case 2: {
|
|
15632
|
+
if (tag !== 16) {
|
|
15633
|
+
break;
|
|
15634
|
+
}
|
|
15635
|
+
message.status = reader.int32();
|
|
15636
|
+
continue;
|
|
15637
|
+
}
|
|
15638
|
+
}
|
|
15639
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
15640
|
+
break;
|
|
15641
|
+
}
|
|
15642
|
+
reader.skip(tag & 7);
|
|
15643
|
+
}
|
|
15644
|
+
return message;
|
|
15645
|
+
},
|
|
15646
|
+
fromJSON(object) {
|
|
15647
|
+
return {
|
|
15648
|
+
invoice: isSet3(object.invoice) ? globalThis.String(object.invoice) : "",
|
|
15649
|
+
status: isSet3(object.status) ? invoiceStatusFromJSON(object.status) : 0
|
|
15650
|
+
};
|
|
15651
|
+
},
|
|
15652
|
+
toJSON(message) {
|
|
15653
|
+
const obj = {};
|
|
15654
|
+
if (message.invoice !== "") {
|
|
15655
|
+
obj.invoice = message.invoice;
|
|
15656
|
+
}
|
|
15657
|
+
if (message.status !== 0) {
|
|
15658
|
+
obj.status = invoiceStatusToJSON(message.status);
|
|
15659
|
+
}
|
|
15660
|
+
return obj;
|
|
15661
|
+
},
|
|
15662
|
+
create(base) {
|
|
15663
|
+
return InvoiceResponse.fromPartial(base ?? {});
|
|
15664
|
+
},
|
|
15665
|
+
fromPartial(object) {
|
|
15666
|
+
const message = createBaseInvoiceResponse();
|
|
15667
|
+
message.invoice = object.invoice ?? "";
|
|
15668
|
+
message.status = object.status ?? 0;
|
|
15669
|
+
return message;
|
|
15670
|
+
}
|
|
15671
|
+
};
|
|
15222
15672
|
var SparkServiceDefinition = {
|
|
15223
15673
|
name: "SparkService",
|
|
15224
15674
|
fullName: "spark.SparkService",
|
|
@@ -15231,6 +15681,15 @@ var SparkServiceDefinition = {
|
|
|
15231
15681
|
responseStream: false,
|
|
15232
15682
|
options: {}
|
|
15233
15683
|
},
|
|
15684
|
+
/** Generates a new static deposit address of the user or returns the existing one for the specified network. */
|
|
15685
|
+
generate_static_deposit_address: {
|
|
15686
|
+
name: "generate_static_deposit_address",
|
|
15687
|
+
requestType: GenerateStaticDepositAddressRequest,
|
|
15688
|
+
requestStream: false,
|
|
15689
|
+
responseType: GenerateStaticDepositAddressResponse,
|
|
15690
|
+
responseStream: false,
|
|
15691
|
+
options: {}
|
|
15692
|
+
},
|
|
15234
15693
|
start_deposit_tree_creation: {
|
|
15235
15694
|
name: "start_deposit_tree_creation",
|
|
15236
15695
|
requestType: StartDepositTreeCreationRequest,
|
|
@@ -15672,6 +16131,14 @@ var SparkServiceDefinition = {
|
|
|
15672
16131
|
responseType: GetUtxosForAddressResponse,
|
|
15673
16132
|
responseStream: false,
|
|
15674
16133
|
options: {}
|
|
16134
|
+
},
|
|
16135
|
+
query_spark_invoices: {
|
|
16136
|
+
name: "query_spark_invoices",
|
|
16137
|
+
requestType: QuerySparkInvoicesRequest,
|
|
16138
|
+
requestStream: false,
|
|
16139
|
+
responseType: QuerySparkInvoicesResponse,
|
|
16140
|
+
responseStream: false,
|
|
16141
|
+
options: {}
|
|
15675
16142
|
}
|
|
15676
16143
|
}
|
|
15677
16144
|
};
|
|
@@ -16261,8 +16728,8 @@ function encodeSparkInvoiceFieldsV1Canonical(f) {
|
|
|
16261
16728
|
// src/utils/adaptor-signature.ts
|
|
16262
16729
|
init_buffer();
|
|
16263
16730
|
var import_modular = require("@noble/curves/abstract/modular");
|
|
16264
|
-
var import_utils4 = require("@noble/curves/abstract/utils");
|
|
16265
16731
|
var import_secp256k12 = require("@noble/curves/secp256k1");
|
|
16732
|
+
var import_utils4 = require("@noble/curves/utils");
|
|
16266
16733
|
function generateSignatureFromExistingAdaptor(signature, adaptorPrivateKeyBytes) {
|
|
16267
16734
|
const { r, s } = parseSignature(signature);
|
|
16268
16735
|
const sBigInt = (0, import_utils4.bytesToNumberBE)(s);
|
|
@@ -16391,8 +16858,8 @@ function parseSignature(signature) {
|
|
|
16391
16858
|
|
|
16392
16859
|
// src/utils/bitcoin.ts
|
|
16393
16860
|
init_buffer();
|
|
16394
|
-
var import_utils5 = require("@noble/curves/abstract/utils");
|
|
16395
16861
|
var import_secp256k13 = require("@noble/curves/secp256k1");
|
|
16862
|
+
var import_utils5 = require("@noble/curves/utils");
|
|
16396
16863
|
var import_sha22 = require("@noble/hashes/sha2");
|
|
16397
16864
|
var btc2 = __toESM(require("@scure/btc-signer"), 1);
|
|
16398
16865
|
|
|
@@ -16637,8 +17104,8 @@ function getTxEstimatedVbytesSizeByNumberOfInputsOutputs(numInputs, numOutputs)
|
|
|
16637
17104
|
|
|
16638
17105
|
// src/utils/keys.ts
|
|
16639
17106
|
init_buffer();
|
|
16640
|
-
var import_utils6 = require("@noble/curves/abstract/utils");
|
|
16641
17107
|
var import_secp256k14 = require("@noble/curves/secp256k1");
|
|
17108
|
+
var import_utils6 = require("@noble/curves/utils");
|
|
16642
17109
|
function addPublicKeys(a, b) {
|
|
16643
17110
|
if (a.length !== 33 || b.length !== 33) {
|
|
16644
17111
|
throw new ValidationError("Public keys must be 33 bytes", {
|
|
@@ -17895,7 +18362,7 @@ fragment UserRequestFragment on UserRequest {
|
|
|
17895
18362
|
|
|
17896
18363
|
// src/types/sdk-types.ts
|
|
17897
18364
|
init_buffer();
|
|
17898
|
-
var import_utils7 = require("@noble/curves/
|
|
18365
|
+
var import_utils7 = require("@noble/curves/utils");
|
|
17899
18366
|
function mapTreeNodeToWalletLeaf(proto) {
|
|
17900
18367
|
return {
|
|
17901
18368
|
id: proto.id,
|
|
@@ -18046,8 +18513,8 @@ function collectResponses(responses) {
|
|
|
18046
18513
|
|
|
18047
18514
|
// src/utils/secret-sharing.ts
|
|
18048
18515
|
init_buffer();
|
|
18049
|
-
var import_utils8 = require("@noble/curves/abstract/utils");
|
|
18050
18516
|
var import_secp256k15 = require("@noble/curves/secp256k1");
|
|
18517
|
+
var import_utils8 = require("@noble/curves/utils");
|
|
18051
18518
|
function getRandomBigInt(max) {
|
|
18052
18519
|
const byteLength = max.toString(2).length + 7 >> 3;
|
|
18053
18520
|
const maxBigInt = max;
|
|
@@ -18432,8 +18899,7 @@ function getNetworkFromBech32mTokenIdentifier(bech32mTokenIdentifier) {
|
|
|
18432
18899
|
|
|
18433
18900
|
// src/utils/token-transactions.ts
|
|
18434
18901
|
init_buffer();
|
|
18435
|
-
var import_utils9 = require("@noble/curves/
|
|
18436
|
-
var import_utils10 = require("@scure/btc-signer/utils");
|
|
18902
|
+
var import_utils9 = require("@noble/curves/utils");
|
|
18437
18903
|
function sumAvailableTokens(outputs) {
|
|
18438
18904
|
try {
|
|
18439
18905
|
return outputs.reduce(
|
|
@@ -18468,7 +18934,7 @@ function filterTokenBalanceForTokenIdentifier(tokenBalances, tokenIdentifier) {
|
|
|
18468
18934
|
}
|
|
18469
18935
|
const tokenIdentifierBytes = decodeBech32mTokenIdentifier(tokenIdentifier).tokenIdentifier;
|
|
18470
18936
|
const tokenBalance = [...tokenBalances.entries()].find(
|
|
18471
|
-
([, info]) => (0,
|
|
18937
|
+
([, info]) => (0, import_utils9.equalBytes)(info.tokenMetadata.rawTokenIdentifier, tokenIdentifierBytes)
|
|
18472
18938
|
);
|
|
18473
18939
|
if (!tokenBalance) {
|
|
18474
18940
|
return {
|
|
@@ -18482,7 +18948,7 @@ function filterTokenBalanceForTokenIdentifier(tokenBalances, tokenIdentifier) {
|
|
|
18482
18948
|
|
|
18483
18949
|
// src/utils/transfer_package.ts
|
|
18484
18950
|
init_buffer();
|
|
18485
|
-
var
|
|
18951
|
+
var import_utils10 = require("@noble/curves/utils");
|
|
18486
18952
|
var import_sha24 = require("@noble/hashes/sha2");
|
|
18487
18953
|
function getTransferPackageSigningPayload(transferID, transferPackage) {
|
|
18488
18954
|
const encryptedPayload = transferPackage.keyTweakPackage;
|
|
@@ -18491,7 +18957,7 @@ function getTransferPackageSigningPayload(transferID, transferPackage) {
|
|
|
18491
18957
|
).map(([key, value]) => ({ key, value }));
|
|
18492
18958
|
pairs.sort((a, b) => a.key.localeCompare(b.key));
|
|
18493
18959
|
const encoder = new TextEncoder();
|
|
18494
|
-
let message = (0,
|
|
18960
|
+
let message = (0, import_utils10.hexToBytes)(transferID.replaceAll("-", ""));
|
|
18495
18961
|
for (const pair of pairs) {
|
|
18496
18962
|
const keyPart = encoder.encode(pair.key + ":");
|
|
18497
18963
|
const separator = encoder.encode(";");
|
|
@@ -18844,7 +19310,7 @@ function getEphemeralAnchorOutput() {
|
|
|
18844
19310
|
|
|
18845
19311
|
// src/utils/unilateral-exit.ts
|
|
18846
19312
|
init_buffer();
|
|
18847
|
-
var
|
|
19313
|
+
var import_utils11 = require("@noble/curves/utils");
|
|
18848
19314
|
var import_legacy = require("@noble/hashes/legacy");
|
|
18849
19315
|
var import_sha25 = require("@noble/hashes/sha2");
|
|
18850
19316
|
var btc3 = __toESM(require("@scure/btc-signer"), 1);
|
|
@@ -18859,7 +19325,7 @@ function isEphemeralAnchorOutput(script, amount) {
|
|
|
18859
19325
|
}
|
|
18860
19326
|
async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network) {
|
|
18861
19327
|
const result = [];
|
|
18862
|
-
const nodes = nodeHexStrings.map((hex) => TreeNode.decode((0,
|
|
19328
|
+
const nodes = nodeHexStrings.map((hex) => TreeNode.decode((0, import_utils11.hexToBytes)(hex)));
|
|
18863
19329
|
const nodeMap = /* @__PURE__ */ new Map();
|
|
18864
19330
|
for (const node of nodes) {
|
|
18865
19331
|
nodeMap.set(node.id, node);
|
|
@@ -18915,10 +19381,10 @@ async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network)
|
|
|
18915
19381
|
}
|
|
18916
19382
|
}
|
|
18917
19383
|
for (const chainNode of chain) {
|
|
18918
|
-
const nodeTx = (0,
|
|
19384
|
+
const nodeTx = (0, import_utils11.bytesToHex)(chainNode.nodeTx);
|
|
18919
19385
|
transactions.push(nodeTx);
|
|
18920
19386
|
if (chainNode.id === node.id) {
|
|
18921
|
-
const refundTx = (0,
|
|
19387
|
+
const refundTx = (0, import_utils11.bytesToHex)(chainNode.refundTx);
|
|
18922
19388
|
transactions.push(refundTx);
|
|
18923
19389
|
}
|
|
18924
19390
|
}
|
|
@@ -18948,7 +19414,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
18948
19414
|
`Node hex string at index ${i} appears to be a raw transaction hex, not a TreeNode protobuf. Use 'leafidtohex' command to convert node IDs to proper hex strings.`
|
|
18949
19415
|
);
|
|
18950
19416
|
}
|
|
18951
|
-
const nodeBytes = (0,
|
|
19417
|
+
const nodeBytes = (0, import_utils11.hexToBytes)(hex);
|
|
18952
19418
|
const node = TreeNode.decode(nodeBytes);
|
|
18953
19419
|
if (!node.id) {
|
|
18954
19420
|
throw new Error(
|
|
@@ -19024,7 +19490,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
19024
19490
|
}
|
|
19025
19491
|
}
|
|
19026
19492
|
for (const chainNode of chain) {
|
|
19027
|
-
let nodeTxHex = (0,
|
|
19493
|
+
let nodeTxHex = (0, import_utils11.bytesToHex)(chainNode.nodeTx);
|
|
19028
19494
|
try {
|
|
19029
19495
|
const txObj = getTxFromRawTxHex(nodeTxHex);
|
|
19030
19496
|
const txid = getTxId(txObj);
|
|
@@ -19041,7 +19507,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
19041
19507
|
for (let i = txObj.outputsLength - 1; i >= 0; i--) {
|
|
19042
19508
|
const output = txObj.getOutput(i);
|
|
19043
19509
|
if (output?.amount === 0n && output.script) {
|
|
19044
|
-
anchorOutputScriptHex = (0,
|
|
19510
|
+
anchorOutputScriptHex = (0, import_utils11.bytesToHex)(output.script);
|
|
19045
19511
|
break;
|
|
19046
19512
|
}
|
|
19047
19513
|
}
|
|
@@ -19062,11 +19528,11 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
19062
19528
|
usedUtxos,
|
|
19063
19529
|
correctedParentTx
|
|
19064
19530
|
} = constructFeeBumpTx(nodeTxHex, availableUtxos, feeRate, void 0);
|
|
19065
|
-
const feeBumpTx = btc3.Transaction.fromPSBT((0,
|
|
19531
|
+
const feeBumpTx = btc3.Transaction.fromPSBT((0, import_utils11.hexToBytes)(nodeFeeBumpPsbt));
|
|
19066
19532
|
var feeBumpOut = feeBumpTx.outputsLength === 1 ? feeBumpTx.getOutput(0) : null;
|
|
19067
19533
|
var feeBumpOutPubKey = null;
|
|
19068
19534
|
for (const usedUtxo of usedUtxos) {
|
|
19069
|
-
if (feeBumpOut && (0,
|
|
19535
|
+
if (feeBumpOut && (0, import_utils11.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
|
|
19070
19536
|
feeBumpOutPubKey = usedUtxo.publicKey;
|
|
19071
19537
|
}
|
|
19072
19538
|
const index = availableUtxos.findIndex(
|
|
@@ -19081,20 +19547,20 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
19081
19547
|
txid: getTxId(feeBumpTx),
|
|
19082
19548
|
vout: 0,
|
|
19083
19549
|
value: feeBumpOut.amount,
|
|
19084
|
-
script: (0,
|
|
19550
|
+
script: (0, import_utils11.bytesToHex)(feeBumpOut.script),
|
|
19085
19551
|
publicKey: feeBumpOutPubKey
|
|
19086
19552
|
});
|
|
19087
19553
|
const finalNodeTx = correctedParentTx || nodeTxHex;
|
|
19088
19554
|
txPackages.push({ tx: finalNodeTx, feeBumpPsbt: nodeFeeBumpPsbt });
|
|
19089
19555
|
if (chainNode.id === node.id) {
|
|
19090
|
-
let refundTxHex = (0,
|
|
19556
|
+
let refundTxHex = (0, import_utils11.bytesToHex)(chainNode.refundTx);
|
|
19091
19557
|
try {
|
|
19092
19558
|
const txObj = getTxFromRawTxHex(refundTxHex);
|
|
19093
19559
|
let anchorOutputScriptHex;
|
|
19094
19560
|
for (let i = txObj.outputsLength - 1; i >= 0; i--) {
|
|
19095
19561
|
const output = txObj.getOutput(i);
|
|
19096
19562
|
if (output?.amount === 0n && output.script) {
|
|
19097
|
-
anchorOutputScriptHex = (0,
|
|
19563
|
+
anchorOutputScriptHex = (0, import_utils11.bytesToHex)(output.script);
|
|
19098
19564
|
break;
|
|
19099
19565
|
}
|
|
19100
19566
|
}
|
|
@@ -19117,12 +19583,12 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
19117
19583
|
void 0
|
|
19118
19584
|
);
|
|
19119
19585
|
const feeBumpTx2 = btc3.Transaction.fromPSBT(
|
|
19120
|
-
(0,
|
|
19586
|
+
(0, import_utils11.hexToBytes)(refundFeeBump.feeBumpPsbt)
|
|
19121
19587
|
);
|
|
19122
19588
|
var feeBumpOut = feeBumpTx2.outputsLength === 1 ? feeBumpTx2.getOutput(0) : null;
|
|
19123
19589
|
var feeBumpOutPubKey = null;
|
|
19124
19590
|
for (const usedUtxo of usedUtxos) {
|
|
19125
|
-
if (feeBumpOut && (0,
|
|
19591
|
+
if (feeBumpOut && (0, import_utils11.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
|
|
19126
19592
|
feeBumpOutPubKey = usedUtxo.publicKey;
|
|
19127
19593
|
}
|
|
19128
19594
|
const index = availableUtxos.findIndex(
|
|
@@ -19137,7 +19603,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
19137
19603
|
txid: getTxId(feeBumpTx2),
|
|
19138
19604
|
vout: 0,
|
|
19139
19605
|
value: feeBumpOut.amount,
|
|
19140
|
-
script: (0,
|
|
19606
|
+
script: (0, import_utils11.bytesToHex)(feeBumpOut.script),
|
|
19141
19607
|
publicKey: feeBumpOutPubKey
|
|
19142
19608
|
});
|
|
19143
19609
|
txPackages.push({
|
|
@@ -19232,10 +19698,10 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
|
|
|
19232
19698
|
if (!fundingUtxo) {
|
|
19233
19699
|
throw new Error(`UTXO at index ${i} is undefined`);
|
|
19234
19700
|
}
|
|
19235
|
-
const pubKeyHash = hash160((0,
|
|
19701
|
+
const pubKeyHash = hash160((0, import_utils11.hexToBytes)(fundingUtxo.publicKey));
|
|
19236
19702
|
const scriptToUse = new Uint8Array([0, 20, ...pubKeyHash]);
|
|
19237
|
-
const providedScript = (0,
|
|
19238
|
-
if ((0,
|
|
19703
|
+
const providedScript = (0, import_utils11.hexToBytes)(fundingUtxo.script);
|
|
19704
|
+
if ((0, import_utils11.bytesToHex)(scriptToUse) !== (0, import_utils11.bytesToHex)(providedScript)) {
|
|
19239
19705
|
throw new Error(
|
|
19240
19706
|
`\u274C Derived script doesn't match provided script for UTXO ${i + 1}.`
|
|
19241
19707
|
);
|
|
@@ -19300,7 +19766,7 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
|
|
|
19300
19766
|
}
|
|
19301
19767
|
let psbtHex;
|
|
19302
19768
|
try {
|
|
19303
|
-
psbtHex = (0,
|
|
19769
|
+
psbtHex = (0, import_utils11.bytesToHex)(builder.toPSBT());
|
|
19304
19770
|
} catch (error) {
|
|
19305
19771
|
throw new Error(`Failed to extract transaction: ${error}`);
|
|
19306
19772
|
}
|
|
@@ -19348,13 +19814,13 @@ init_logging();
|
|
|
19348
19814
|
// src/signer/signer.ts
|
|
19349
19815
|
init_buffer();
|
|
19350
19816
|
var import_secp256k17 = require("@bitcoinerlab/secp256k1");
|
|
19351
|
-
var import_utils14 = require("@noble/curves/abstract/utils");
|
|
19352
19817
|
var import_secp256k18 = require("@noble/curves/secp256k1");
|
|
19818
|
+
var import_utils13 = require("@noble/curves/utils");
|
|
19353
19819
|
var import_sha26 = require("@noble/hashes/sha2");
|
|
19354
19820
|
var import_bip32 = require("@scure/bip32");
|
|
19355
19821
|
var import_bip39 = require("@scure/bip39");
|
|
19356
19822
|
var import_english = require("@scure/bip39/wordlists/english");
|
|
19357
|
-
var
|
|
19823
|
+
var import_utils14 = require("@scure/btc-signer/utils");
|
|
19358
19824
|
var ecies = __toESM(require("eciesjs"), 1);
|
|
19359
19825
|
|
|
19360
19826
|
// src/constants.ts
|
|
@@ -19362,7 +19828,7 @@ init_buffer();
|
|
|
19362
19828
|
var import_core9 = require("@lightsparkdev/core");
|
|
19363
19829
|
var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
19364
19830
|
var isBun = globalThis.Bun !== void 0;
|
|
19365
|
-
var packageVersion = true ? "0.2.
|
|
19831
|
+
var packageVersion = true ? "0.2.12" : "unknown";
|
|
19366
19832
|
var baseEnvStr = "unknown";
|
|
19367
19833
|
if (isBun) {
|
|
19368
19834
|
const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
|
|
@@ -19460,7 +19926,7 @@ var TaprootOutputKeysGenerator = class {
|
|
|
19460
19926
|
}
|
|
19461
19927
|
const derivationPath = this.useAddressIndex ? `m/86'/0'/0'/0/${accountNumber}` : `m/86'/0'/${accountNumber}'/0/0`;
|
|
19462
19928
|
const taprootInternalKey = hdkey.derive(derivationPath);
|
|
19463
|
-
let tweakedPrivateKey = (0,
|
|
19929
|
+
let tweakedPrivateKey = (0, import_utils14.taprootTweakPrivKey)(taprootInternalKey.privateKey);
|
|
19464
19930
|
let tweakedPublicKey = import_secp256k18.secp256k1.getPublicKey(tweakedPrivateKey);
|
|
19465
19931
|
if (tweakedPublicKey[0] === 3) {
|
|
19466
19932
|
tweakedPrivateKey = (0, import_secp256k17.privateNegate)(tweakedPrivateKey);
|
|
@@ -19538,7 +20004,7 @@ var DefaultSparkSigner = class {
|
|
|
19538
20004
|
});
|
|
19539
20005
|
}
|
|
19540
20006
|
const receiverEciesPrivKey = ecies.PrivateKey.fromHex(
|
|
19541
|
-
(0,
|
|
20007
|
+
(0, import_utils13.bytesToHex)(this.identityKey.privateKey)
|
|
19542
20008
|
);
|
|
19543
20009
|
const privateKey = ecies.decrypt(receiverEciesPrivKey.toHex(), ciphertext);
|
|
19544
20010
|
return privateKey;
|
|
@@ -19672,7 +20138,7 @@ var DefaultSparkSigner = class {
|
|
|
19672
20138
|
threshold,
|
|
19673
20139
|
numShares
|
|
19674
20140
|
}) {
|
|
19675
|
-
const secretAsInt = (0,
|
|
20141
|
+
const secretAsInt = (0, import_utils13.bytesToNumberBE)(secret);
|
|
19676
20142
|
return splitSecretWithProofs(secretAsInt, curveOrder, threshold, numShares);
|
|
19677
20143
|
}
|
|
19678
20144
|
async signFrost({
|
|
@@ -19708,7 +20174,7 @@ var DefaultSparkSigner = class {
|
|
|
19708
20174
|
publicKey,
|
|
19709
20175
|
verifyingKey
|
|
19710
20176
|
};
|
|
19711
|
-
const logMessage = (0,
|
|
20177
|
+
const logMessage = (0, import_utils13.bytesToHex)(message);
|
|
19712
20178
|
const result = await SparkFrost.signFrost({
|
|
19713
20179
|
message,
|
|
19714
20180
|
keyPackage,
|
|
@@ -19750,7 +20216,7 @@ var DefaultSparkSigner = class {
|
|
|
19750
20216
|
}
|
|
19751
20217
|
async createSparkWalletFromSeed(seed, accountNumber) {
|
|
19752
20218
|
if (typeof seed === "string") {
|
|
19753
|
-
seed = (0,
|
|
20219
|
+
seed = (0, import_utils13.hexToBytes)(seed);
|
|
19754
20220
|
}
|
|
19755
20221
|
const {
|
|
19756
20222
|
identityKey,
|
|
@@ -19762,7 +20228,7 @@ var DefaultSparkSigner = class {
|
|
|
19762
20228
|
this.depositKey = depositKey;
|
|
19763
20229
|
this.signingKey = signingKey.hdKey;
|
|
19764
20230
|
this.staticDepositKey = staticDepositKey.hdKey;
|
|
19765
|
-
return (0,
|
|
20231
|
+
return (0, import_utils13.bytesToHex)(identityKey.publicKey);
|
|
19766
20232
|
}
|
|
19767
20233
|
async signMessageWithIdentityKey(message, compact) {
|
|
19768
20234
|
if (!this.identityKey?.privateKey) {
|
|
@@ -19783,7 +20249,7 @@ var DefaultSparkSigner = class {
|
|
|
19783
20249
|
});
|
|
19784
20250
|
}
|
|
19785
20251
|
const receiverEciesPrivKey = ecies.PrivateKey.fromHex(
|
|
19786
|
-
(0,
|
|
20252
|
+
(0, import_utils13.bytesToHex)(this.identityKey.privateKey)
|
|
19787
20253
|
);
|
|
19788
20254
|
const privateKey = ecies.decrypt(receiverEciesPrivKey.toHex(), ciphertext);
|
|
19789
20255
|
const publicKey = import_secp256k18.secp256k1.getPublicKey(privateKey);
|
|
@@ -19807,15 +20273,15 @@ var DefaultSparkSigner = class {
|
|
|
19807
20273
|
}
|
|
19808
20274
|
signTransactionIndex(tx, index, publicKey) {
|
|
19809
20275
|
let privateKey;
|
|
19810
|
-
if ((0,
|
|
20276
|
+
if ((0, import_utils13.equalBytes)(publicKey, this.identityKey?.publicKey ?? new Uint8Array())) {
|
|
19811
20277
|
privateKey = this.identityKey?.privateKey;
|
|
19812
|
-
} else if ((0,
|
|
20278
|
+
} else if ((0, import_utils13.equalBytes)(publicKey, this.depositKey?.publicKey ?? new Uint8Array())) {
|
|
19813
20279
|
privateKey = this.depositKey?.privateKey;
|
|
19814
20280
|
}
|
|
19815
20281
|
if (!privateKey) {
|
|
19816
20282
|
throw new ValidationError("Private key not found for public key", {
|
|
19817
20283
|
field: "privateKey",
|
|
19818
|
-
value: (0,
|
|
20284
|
+
value: (0, import_utils13.bytesToHex)(publicKey)
|
|
19819
20285
|
});
|
|
19820
20286
|
}
|
|
19821
20287
|
tx.signIdx(privateKey, index);
|
|
@@ -19893,8 +20359,8 @@ init_buffer();
|
|
|
19893
20359
|
// src/spark-wallet/spark-wallet.ts
|
|
19894
20360
|
init_buffer();
|
|
19895
20361
|
var import_core13 = require("@lightsparkdev/core");
|
|
19896
|
-
var import_utils25 = require("@noble/curves/abstract/utils");
|
|
19897
20362
|
var import_secp256k115 = require("@noble/curves/secp256k1");
|
|
20363
|
+
var import_utils24 = require("@noble/curves/utils");
|
|
19898
20364
|
var import_bip392 = require("@scure/bip39");
|
|
19899
20365
|
var import_english2 = require("@scure/bip39/wordlists/english");
|
|
19900
20366
|
var import_btc_signer6 = require("@scure/btc-signer");
|
|
@@ -25260,8 +25726,8 @@ var import_uuidv73 = require("uuidv7");
|
|
|
25260
25726
|
|
|
25261
25727
|
// src/services/transfer.ts
|
|
25262
25728
|
init_buffer();
|
|
25263
|
-
var import_utils16 = require("@noble/curves/abstract/utils");
|
|
25264
25729
|
var import_secp256k19 = require("@noble/curves/secp256k1");
|
|
25730
|
+
var import_utils15 = require("@noble/curves/utils");
|
|
25265
25731
|
var import_sha29 = require("@noble/hashes/sha2");
|
|
25266
25732
|
var import_btc_signer2 = require("@scure/btc-signer");
|
|
25267
25733
|
var ecies2 = __toESM(require("eciesjs"), 1);
|
|
@@ -25631,7 +26097,7 @@ var BaseTransferService = class {
|
|
|
25631
26097
|
}
|
|
25632
26098
|
async prepareSendTransferKeyTweaks(transferID, receiverIdentityPubkey, leaves, cpfpRefundSignatureMap, directRefundSignatureMap, directFromCpfpRefundSignatureMap) {
|
|
25633
26099
|
const receiverEciesPubKey = ecies2.PublicKey.fromHex(
|
|
25634
|
-
(0,
|
|
26100
|
+
(0, import_utils15.bytesToHex)(receiverIdentityPubkey)
|
|
25635
26101
|
);
|
|
25636
26102
|
const leavesTweaksMap = /* @__PURE__ */ new Map();
|
|
25637
26103
|
for (const leaf of leaves) {
|
|
@@ -25672,7 +26138,7 @@ var BaseTransferService = class {
|
|
|
25672
26138
|
throw new Error(`Share not found for operator ${operator.id}`);
|
|
25673
26139
|
}
|
|
25674
26140
|
const pubkeyTweak = import_secp256k19.secp256k1.getPublicKey(
|
|
25675
|
-
(0,
|
|
26141
|
+
(0, import_utils15.numberToBytesBE)(share.share, 32),
|
|
25676
26142
|
true
|
|
25677
26143
|
);
|
|
25678
26144
|
pubkeySharesTweak.set(identifier, pubkeyTweak);
|
|
@@ -25697,7 +26163,7 @@ var BaseTransferService = class {
|
|
|
25697
26163
|
leafTweaksMap.set(identifier, {
|
|
25698
26164
|
leafId: leaf.leaf.id,
|
|
25699
26165
|
secretShareTweak: {
|
|
25700
|
-
secretShare: (0,
|
|
26166
|
+
secretShare: (0, import_utils15.numberToBytesBE)(share.share, 32),
|
|
25701
26167
|
proofs: share.proofs
|
|
25702
26168
|
},
|
|
25703
26169
|
pubkeySharesTweak: Object.fromEntries(pubkeySharesTweak),
|
|
@@ -25720,7 +26186,7 @@ var BaseTransferService = class {
|
|
|
25720
26186
|
return void 0;
|
|
25721
26187
|
}
|
|
25722
26188
|
compareTransfers(transfer1, transfer2) {
|
|
25723
|
-
return transfer1.id === transfer2.id && (0,
|
|
26189
|
+
return transfer1.id === transfer2.id && (0, import_utils15.equalBytes)(
|
|
25724
26190
|
transfer1.senderIdentityPublicKey,
|
|
25725
26191
|
transfer2.senderIdentityPublicKey
|
|
25726
26192
|
) && transfer1.status === transfer2.status && transfer1.totalValue === transfer2.totalValue && transfer1.expiryTime?.getTime() === transfer2.expiryTime?.getTime() && transfer1.leaves.length === transfer2.leaves.length;
|
|
@@ -26019,7 +26485,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
26019
26485
|
}
|
|
26020
26486
|
const nodeTx = getTxFromRawTxBytes(leaf.leaf.nodeTx);
|
|
26021
26487
|
const cpfpNodeOutPoint = {
|
|
26022
|
-
txid: (0,
|
|
26488
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(nodeTx)),
|
|
26023
26489
|
index: 0
|
|
26024
26490
|
};
|
|
26025
26491
|
let directNodeTx;
|
|
@@ -26027,7 +26493,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
26027
26493
|
if (leaf.leaf.directTx.length > 0) {
|
|
26028
26494
|
directNodeTx = getTxFromRawTxBytes(leaf.leaf.directTx);
|
|
26029
26495
|
directNodeOutPoint = {
|
|
26030
|
-
txid: (0,
|
|
26496
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(directNodeTx)),
|
|
26031
26497
|
index: 0
|
|
26032
26498
|
};
|
|
26033
26499
|
}
|
|
@@ -26161,7 +26627,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
26161
26627
|
throw new Error(`Share not found for operator ${operator.id}`);
|
|
26162
26628
|
}
|
|
26163
26629
|
const pubkeyTweak = import_secp256k19.secp256k1.getPublicKey(
|
|
26164
|
-
(0,
|
|
26630
|
+
(0, import_utils15.numberToBytesBE)(share.share, 32)
|
|
26165
26631
|
);
|
|
26166
26632
|
pubkeySharesTweak.set(identifier, pubkeyTweak);
|
|
26167
26633
|
}
|
|
@@ -26174,7 +26640,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
26174
26640
|
leafTweaksMap.set(identifier, {
|
|
26175
26641
|
leafId: leaf.leaf.id,
|
|
26176
26642
|
secretShareTweak: {
|
|
26177
|
-
secretShare: (0,
|
|
26643
|
+
secretShare: (0, import_utils15.numberToBytesBE)(share.share, 32),
|
|
26178
26644
|
proofs: share.proofs
|
|
26179
26645
|
},
|
|
26180
26646
|
pubkeySharesTweak: Object.fromEntries(pubkeySharesTweak)
|
|
@@ -26360,13 +26826,13 @@ var TransferService = class extends BaseTransferService {
|
|
|
26360
26826
|
});
|
|
26361
26827
|
}
|
|
26362
26828
|
const newCpfpRefundOutPoint = {
|
|
26363
|
-
txid: (0,
|
|
26829
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(cpfpNodeTx)),
|
|
26364
26830
|
index: 0
|
|
26365
26831
|
};
|
|
26366
26832
|
let newDirectRefundOutPoint;
|
|
26367
26833
|
if (newDirectNodeTx) {
|
|
26368
26834
|
newDirectRefundOutPoint = {
|
|
26369
|
-
txid: (0,
|
|
26835
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(newDirectNodeTx)),
|
|
26370
26836
|
index: 0
|
|
26371
26837
|
};
|
|
26372
26838
|
}
|
|
@@ -26494,7 +26960,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
26494
26960
|
const refundTx = getTxFromRawTxBytes(node.refundTx);
|
|
26495
26961
|
const refundSequence = refundTx.getInput(0).sequence || 0;
|
|
26496
26962
|
const newNodeOutPoint = {
|
|
26497
|
-
txid: (0,
|
|
26963
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(nodeTx)),
|
|
26498
26964
|
index: 0
|
|
26499
26965
|
};
|
|
26500
26966
|
const {
|
|
@@ -26531,13 +26997,13 @@ var TransferService = class extends BaseTransferService {
|
|
|
26531
26997
|
});
|
|
26532
26998
|
}
|
|
26533
26999
|
const newCpfpRefundOutPoint = {
|
|
26534
|
-
txid: (0,
|
|
27000
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(newNodeTx)),
|
|
26535
27001
|
index: 0
|
|
26536
27002
|
};
|
|
26537
27003
|
let newDirectRefundOutPoint;
|
|
26538
27004
|
if (newDirectNodeTx) {
|
|
26539
27005
|
newDirectRefundOutPoint = {
|
|
26540
|
-
txid: (0,
|
|
27006
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(newDirectNodeTx)),
|
|
26541
27007
|
index: 0
|
|
26542
27008
|
};
|
|
26543
27009
|
}
|
|
@@ -26771,13 +27237,13 @@ var TransferService = class extends BaseTransferService {
|
|
|
26771
27237
|
};
|
|
26772
27238
|
const signingPublicKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
|
|
26773
27239
|
const cpfpRefundOutPoint = {
|
|
26774
|
-
txid: (0,
|
|
27240
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(nodeTx)),
|
|
26775
27241
|
index: 0
|
|
26776
27242
|
};
|
|
26777
27243
|
let directRefundOutPoint;
|
|
26778
27244
|
if (directNodeTx) {
|
|
26779
27245
|
directRefundOutPoint = {
|
|
26780
|
-
txid: (0,
|
|
27246
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(directNodeTx)),
|
|
26781
27247
|
index: 0
|
|
26782
27248
|
};
|
|
26783
27249
|
}
|
|
@@ -27153,9 +27619,9 @@ var CoopExitService = class extends BaseTransferService {
|
|
|
27153
27619
|
init_buffer();
|
|
27154
27620
|
var import_secp256k110 = require("@noble/curves/secp256k1");
|
|
27155
27621
|
var import_sha210 = require("@noble/hashes/sha2");
|
|
27156
|
-
var
|
|
27622
|
+
var import_utils16 = require("@noble/hashes/utils");
|
|
27157
27623
|
var import_btc_signer4 = require("@scure/btc-signer");
|
|
27158
|
-
var
|
|
27624
|
+
var import_utils17 = require("@scure/btc-signer/utils");
|
|
27159
27625
|
var DepositService = class {
|
|
27160
27626
|
config;
|
|
27161
27627
|
connectionManager;
|
|
@@ -27165,7 +27631,8 @@ var DepositService = class {
|
|
|
27165
27631
|
}
|
|
27166
27632
|
async validateDepositAddress({
|
|
27167
27633
|
address: address2,
|
|
27168
|
-
userPubkey
|
|
27634
|
+
userPubkey,
|
|
27635
|
+
verifyCoordinatorProof = false
|
|
27169
27636
|
}) {
|
|
27170
27637
|
if (!address2.depositAddressProof || !address2.depositAddressProof.proofOfPossessionSignature || !address2.depositAddressProof.addressSignatures) {
|
|
27171
27638
|
throw new ValidationError(
|
|
@@ -27203,10 +27670,10 @@ var DepositService = class {
|
|
|
27203
27670
|
}
|
|
27204
27671
|
const addrHash = (0, import_sha210.sha256)(address2.address);
|
|
27205
27672
|
for (const operator of Object.values(this.config.getSigningOperators())) {
|
|
27206
|
-
if (operator.identifier === this.config.getCoordinatorIdentifier()) {
|
|
27673
|
+
if (operator.identifier === this.config.getCoordinatorIdentifier() && !verifyCoordinatorProof) {
|
|
27207
27674
|
continue;
|
|
27208
27675
|
}
|
|
27209
|
-
const operatorPubkey2 = (0,
|
|
27676
|
+
const operatorPubkey2 = (0, import_utils16.hexToBytes)(operator.identityPublicKey);
|
|
27210
27677
|
const operatorSig = address2.depositAddressProof.addressSignatures[operator.identifier];
|
|
27211
27678
|
if (!operatorSig) {
|
|
27212
27679
|
throw new ValidationError("Operator signature not found", {
|
|
@@ -27228,6 +27695,46 @@ var DepositService = class {
|
|
|
27228
27695
|
}
|
|
27229
27696
|
}
|
|
27230
27697
|
}
|
|
27698
|
+
async generateStaticDepositAddress({
|
|
27699
|
+
signingPubkey
|
|
27700
|
+
}) {
|
|
27701
|
+
const sparkClient = await this.connectionManager.createSparkClient(
|
|
27702
|
+
this.config.getCoordinatorAddress()
|
|
27703
|
+
);
|
|
27704
|
+
let depositResp;
|
|
27705
|
+
try {
|
|
27706
|
+
depositResp = await sparkClient.generate_static_deposit_address({
|
|
27707
|
+
signingPublicKey: signingPubkey,
|
|
27708
|
+
identityPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
27709
|
+
network: this.config.getNetworkProto()
|
|
27710
|
+
});
|
|
27711
|
+
} catch (error) {
|
|
27712
|
+
throw new NetworkError(
|
|
27713
|
+
"Failed to generate static deposit address",
|
|
27714
|
+
{
|
|
27715
|
+
operation: "generate_static_deposit_address",
|
|
27716
|
+
errorCount: 1,
|
|
27717
|
+
errors: error instanceof Error ? error.message : String(error)
|
|
27718
|
+
},
|
|
27719
|
+
error
|
|
27720
|
+
);
|
|
27721
|
+
}
|
|
27722
|
+
if (!depositResp.depositAddress) {
|
|
27723
|
+
throw new ValidationError(
|
|
27724
|
+
"No static deposit address response from coordinator",
|
|
27725
|
+
{
|
|
27726
|
+
field: "depositAddress",
|
|
27727
|
+
value: depositResp
|
|
27728
|
+
}
|
|
27729
|
+
);
|
|
27730
|
+
}
|
|
27731
|
+
await this.validateDepositAddress({
|
|
27732
|
+
address: depositResp.depositAddress,
|
|
27733
|
+
userPubkey: signingPubkey,
|
|
27734
|
+
verifyCoordinatorProof: true
|
|
27735
|
+
});
|
|
27736
|
+
return depositResp;
|
|
27737
|
+
}
|
|
27231
27738
|
async generateDepositAddress({
|
|
27232
27739
|
signingPubkey,
|
|
27233
27740
|
leafId,
|
|
@@ -27295,7 +27802,7 @@ var DepositService = class {
|
|
|
27295
27802
|
});
|
|
27296
27803
|
}
|
|
27297
27804
|
const depositOutPoint = {
|
|
27298
|
-
txid: (0,
|
|
27805
|
+
txid: (0, import_utils16.hexToBytes)(getTxId(depositTx)),
|
|
27299
27806
|
index: vout
|
|
27300
27807
|
};
|
|
27301
27808
|
const depositTxOut = {
|
|
@@ -27314,8 +27821,8 @@ var DepositService = class {
|
|
|
27314
27821
|
const { cpfpRefundTx, directRefundTx, directFromCpfpRefundTx } = createRefundTxs({
|
|
27315
27822
|
sequence: INITIAL_SEQUENCE,
|
|
27316
27823
|
directSequence: INITIAL_DIRECT_SEQUENCE,
|
|
27317
|
-
input: { txid: (0,
|
|
27318
|
-
directInput: { txid: (0,
|
|
27824
|
+
input: { txid: (0, import_utils16.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
|
|
27825
|
+
directInput: { txid: (0, import_utils16.hexToBytes)(getTxId(directRootTx)), index: 0 },
|
|
27319
27826
|
amountSats: amount,
|
|
27320
27827
|
receivingPubkey: signingPubKey,
|
|
27321
27828
|
network: this.config.getNetwork()
|
|
@@ -27445,7 +27952,7 @@ var DepositService = class {
|
|
|
27445
27952
|
}
|
|
27446
27953
|
);
|
|
27447
27954
|
}
|
|
27448
|
-
if (!(0,
|
|
27955
|
+
if (!(0, import_utils17.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
|
|
27449
27956
|
throw new ValidationError("Verifying key mismatch", {
|
|
27450
27957
|
field: "verifyingKey",
|
|
27451
27958
|
value: treeResp.rootNodeSignatureShares.verifyingKey,
|
|
@@ -27609,7 +28116,7 @@ var DepositService = class {
|
|
|
27609
28116
|
});
|
|
27610
28117
|
}
|
|
27611
28118
|
const depositOutPoint = {
|
|
27612
|
-
txid: (0,
|
|
28119
|
+
txid: (0, import_utils16.hexToBytes)(getTxId(depositTx)),
|
|
27613
28120
|
index: vout
|
|
27614
28121
|
};
|
|
27615
28122
|
const depositTxOut = {
|
|
@@ -27622,7 +28129,7 @@ var DepositService = class {
|
|
|
27622
28129
|
const signingPubKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
|
|
27623
28130
|
const { cpfpRefundTx } = createRefundTxs({
|
|
27624
28131
|
sequence: INITIAL_SEQUENCE,
|
|
27625
|
-
input: { txid: (0,
|
|
28132
|
+
input: { txid: (0, import_utils16.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
|
|
27626
28133
|
amountSats: amount,
|
|
27627
28134
|
receivingPubkey: signingPubKey,
|
|
27628
28135
|
network: this.config.getNetwork()
|
|
@@ -27692,7 +28199,7 @@ var DepositService = class {
|
|
|
27692
28199
|
}
|
|
27693
28200
|
);
|
|
27694
28201
|
}
|
|
27695
|
-
if (!(0,
|
|
28202
|
+
if (!(0, import_utils17.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
|
|
27696
28203
|
throw new ValidationError("Verifying key mismatch", {
|
|
27697
28204
|
field: "verifyingKey",
|
|
27698
28205
|
value: treeResp.rootNodeSignatureShares.verifyingKey,
|
|
@@ -27768,8 +28275,8 @@ var DepositService = class {
|
|
|
27768
28275
|
|
|
27769
28276
|
// src/services/lightning.ts
|
|
27770
28277
|
init_buffer();
|
|
27771
|
-
var import_utils19 = require("@noble/curves/abstract/utils");
|
|
27772
28278
|
var import_secp256k111 = require("@noble/curves/secp256k1");
|
|
28279
|
+
var import_utils18 = require("@noble/curves/utils");
|
|
27773
28280
|
var import_sha211 = require("@noble/hashes/sha2");
|
|
27774
28281
|
var import_uuidv74 = require("uuidv7");
|
|
27775
28282
|
|
|
@@ -27855,8 +28362,8 @@ var LightningService = class {
|
|
|
27855
28362
|
}) {
|
|
27856
28363
|
const crypto = getCrypto();
|
|
27857
28364
|
const randBytes = crypto.getRandomValues(new Uint8Array(32));
|
|
27858
|
-
const preimage = (0,
|
|
27859
|
-
(0,
|
|
28365
|
+
const preimage = (0, import_utils18.numberToBytesBE)(
|
|
28366
|
+
(0, import_utils18.bytesToNumberBE)(randBytes) % import_secp256k111.secp256k1.CURVE.n,
|
|
27860
28367
|
32
|
|
27861
28368
|
);
|
|
27862
28369
|
return await this.createLightningInvoiceWithPreImage({
|
|
@@ -27911,12 +28418,12 @@ var LightningService = class {
|
|
|
27911
28418
|
const sparkClient = await this.connectionManager.createSparkClient(
|
|
27912
28419
|
operator.address
|
|
27913
28420
|
);
|
|
27914
|
-
const userIdentityPublicKey = receiverIdentityPubkey ? (0,
|
|
28421
|
+
const userIdentityPublicKey = receiverIdentityPubkey ? (0, import_utils18.hexToBytes)(receiverIdentityPubkey) : await this.config.signer.getIdentityPublicKey();
|
|
27915
28422
|
try {
|
|
27916
28423
|
await sparkClient.store_preimage_share({
|
|
27917
28424
|
paymentHash,
|
|
27918
28425
|
preimageShare: {
|
|
27919
|
-
secretShare: (0,
|
|
28426
|
+
secretShare: (0, import_utils18.numberToBytesBE)(share.share, 32),
|
|
27920
28427
|
proofs: share.proofs
|
|
27921
28428
|
},
|
|
27922
28429
|
threshold: this.config.getThreshold(),
|
|
@@ -28117,9 +28624,9 @@ var LightningService = class {
|
|
|
28117
28624
|
|
|
28118
28625
|
// src/services/token-transactions.ts
|
|
28119
28626
|
init_buffer();
|
|
28120
|
-
var import_utils20 = require("@noble/curves/abstract/utils");
|
|
28121
28627
|
var import_secp256k113 = require("@noble/curves/secp256k1");
|
|
28122
|
-
var
|
|
28628
|
+
var import_utils19 = require("@noble/curves/utils");
|
|
28629
|
+
var import_utils20 = require("@noble/hashes/utils");
|
|
28123
28630
|
|
|
28124
28631
|
// src/utils/token-hashing.ts
|
|
28125
28632
|
init_buffer();
|
|
@@ -30053,14 +30560,14 @@ var TokenTransactionService = class {
|
|
|
30053
30560
|
}
|
|
30054
30561
|
if (this.config.getTokenTransactionVersion() !== "V0" && receiverAddress.sparkInvoiceFields) {
|
|
30055
30562
|
return {
|
|
30056
|
-
receiverPublicKey: (0,
|
|
30563
|
+
receiverPublicKey: (0, import_utils20.hexToBytes)(receiverAddress.identityPublicKey),
|
|
30057
30564
|
rawTokenIdentifier,
|
|
30058
30565
|
tokenAmount: transfer.tokenAmount,
|
|
30059
30566
|
sparkInvoice: transfer.receiverSparkAddress
|
|
30060
30567
|
};
|
|
30061
30568
|
}
|
|
30062
30569
|
return {
|
|
30063
|
-
receiverPublicKey: (0,
|
|
30570
|
+
receiverPublicKey: (0, import_utils20.hexToBytes)(receiverAddress.identityPublicKey),
|
|
30064
30571
|
rawTokenIdentifier,
|
|
30065
30572
|
tokenPublicKey,
|
|
30066
30573
|
// Remove for full v0 deprecation
|
|
@@ -30099,7 +30606,7 @@ var TokenTransactionService = class {
|
|
|
30099
30606
|
const tokenOutputs = tokenOutputData.map((output) => ({
|
|
30100
30607
|
ownerPublicKey: output.receiverPublicKey,
|
|
30101
30608
|
tokenPublicKey: output.tokenPublicKey,
|
|
30102
|
-
tokenAmount: (0,
|
|
30609
|
+
tokenAmount: (0, import_utils19.numberToBytesBE)(output.tokenAmount, 16)
|
|
30103
30610
|
}));
|
|
30104
30611
|
if (availableTokenAmount > totalRequestedAmount) {
|
|
30105
30612
|
const changeAmount = availableTokenAmount - totalRequestedAmount;
|
|
@@ -30107,7 +30614,7 @@ var TokenTransactionService = class {
|
|
|
30107
30614
|
tokenOutputs.push({
|
|
30108
30615
|
ownerPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
30109
30616
|
tokenPublicKey: firstTokenPublicKey,
|
|
30110
|
-
tokenAmount: (0,
|
|
30617
|
+
tokenAmount: (0, import_utils19.numberToBytesBE)(changeAmount, 16)
|
|
30111
30618
|
});
|
|
30112
30619
|
}
|
|
30113
30620
|
return {
|
|
@@ -30138,7 +30645,7 @@ var TokenTransactionService = class {
|
|
|
30138
30645
|
(output) => ({
|
|
30139
30646
|
ownerPublicKey: output.receiverPublicKey,
|
|
30140
30647
|
tokenIdentifier: output.rawTokenIdentifier,
|
|
30141
|
-
tokenAmount: (0,
|
|
30648
|
+
tokenAmount: (0, import_utils19.numberToBytesBE)(output.tokenAmount, 16)
|
|
30142
30649
|
})
|
|
30143
30650
|
);
|
|
30144
30651
|
if (availableTokenAmount > totalRequestedAmount) {
|
|
@@ -30147,7 +30654,7 @@ var TokenTransactionService = class {
|
|
|
30147
30654
|
tokenOutputs.push({
|
|
30148
30655
|
ownerPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
30149
30656
|
tokenIdentifier: firstTokenIdentifierBytes,
|
|
30150
|
-
tokenAmount: (0,
|
|
30657
|
+
tokenAmount: (0, import_utils19.numberToBytesBE)(changeAmount, 16)
|
|
30151
30658
|
});
|
|
30152
30659
|
}
|
|
30153
30660
|
return {
|
|
@@ -30174,7 +30681,7 @@ var TokenTransactionService = class {
|
|
|
30174
30681
|
for (const [_, operator] of Object.entries(
|
|
30175
30682
|
this.config.getSigningOperators()
|
|
30176
30683
|
)) {
|
|
30177
|
-
operatorKeys.push((0,
|
|
30684
|
+
operatorKeys.push((0, import_utils20.hexToBytes)(operator.identityPublicKey));
|
|
30178
30685
|
}
|
|
30179
30686
|
return operatorKeys;
|
|
30180
30687
|
}
|
|
@@ -30258,7 +30765,7 @@ var TokenTransactionService = class {
|
|
|
30258
30765
|
{
|
|
30259
30766
|
field: "revocationCommitment",
|
|
30260
30767
|
value: derivedRevocationCommitment,
|
|
30261
|
-
expected: (0,
|
|
30768
|
+
expected: (0, import_utils19.bytesToHex)(outputsToSpendCommitments[outputIndex]),
|
|
30262
30769
|
outputIndex
|
|
30263
30770
|
}
|
|
30264
30771
|
)
|
|
@@ -30284,7 +30791,7 @@ var TokenTransactionService = class {
|
|
|
30284
30791
|
threshold
|
|
30285
30792
|
);
|
|
30286
30793
|
}
|
|
30287
|
-
return (0,
|
|
30794
|
+
return (0, import_utils19.bytesToHex)(finalTokenTransactionHash);
|
|
30288
30795
|
}
|
|
30289
30796
|
async broadcastTokenTransactionV1(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
|
|
30290
30797
|
const { finalTokenTransaction, finalTokenTransactionHash, threshold } = await this.startTokenTransaction(
|
|
@@ -30298,7 +30805,7 @@ var TokenTransactionService = class {
|
|
|
30298
30805
|
finalTokenTransactionHash,
|
|
30299
30806
|
signingOperators
|
|
30300
30807
|
);
|
|
30301
|
-
return (0,
|
|
30808
|
+
return (0, import_utils19.bytesToHex)(finalTokenTransactionHash);
|
|
30302
30809
|
}
|
|
30303
30810
|
async startTokenTransactionV0(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
|
|
30304
30811
|
const sparkClient = await this.connectionManager.createSparkClient(
|
|
@@ -30522,7 +31029,7 @@ var TokenTransactionService = class {
|
|
|
30522
31029
|
const identityPublicKey = await this.config.signer.getIdentityPublicKey();
|
|
30523
31030
|
const payload = {
|
|
30524
31031
|
finalTokenTransactionHash,
|
|
30525
|
-
operatorIdentityPublicKey: (0,
|
|
31032
|
+
operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
|
|
30526
31033
|
};
|
|
30527
31034
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
30528
31035
|
let operatorSpecificSignatures = [];
|
|
@@ -30737,8 +31244,8 @@ var TokenTransactionService = class {
|
|
|
30737
31244
|
this.config.getCoordinatorAddress()
|
|
30738
31245
|
);
|
|
30739
31246
|
let queryParams = {
|
|
30740
|
-
tokenPublicKeys: issuerPublicKeys?.map(
|
|
30741
|
-
ownerPublicKeys: ownerPublicKeys?.map(
|
|
31247
|
+
tokenPublicKeys: issuerPublicKeys?.map(import_utils20.hexToBytes),
|
|
31248
|
+
ownerPublicKeys: ownerPublicKeys?.map(import_utils20.hexToBytes),
|
|
30742
31249
|
tokenIdentifiers: tokenIdentifiers?.map((identifier) => {
|
|
30743
31250
|
const { tokenIdentifier } = decodeBech32mTokenIdentifier(
|
|
30744
31251
|
identifier,
|
|
@@ -30746,7 +31253,7 @@ var TokenTransactionService = class {
|
|
|
30746
31253
|
);
|
|
30747
31254
|
return tokenIdentifier;
|
|
30748
31255
|
}),
|
|
30749
|
-
tokenTransactionHashes: tokenTransactionHashes?.map(
|
|
31256
|
+
tokenTransactionHashes: tokenTransactionHashes?.map(import_utils20.hexToBytes),
|
|
30750
31257
|
outputIds: outputIds || [],
|
|
30751
31258
|
limit: pageSize,
|
|
30752
31259
|
offset
|
|
@@ -30805,8 +31312,8 @@ var TokenTransactionService = class {
|
|
|
30805
31312
|
this.config.getCoordinatorAddress()
|
|
30806
31313
|
);
|
|
30807
31314
|
let queryParams = {
|
|
30808
|
-
issuerPublicKeys: issuerPublicKeys?.map(
|
|
30809
|
-
ownerPublicKeys: ownerPublicKeys?.map(
|
|
31315
|
+
issuerPublicKeys: issuerPublicKeys?.map(import_utils20.hexToBytes),
|
|
31316
|
+
ownerPublicKeys: ownerPublicKeys?.map(import_utils20.hexToBytes),
|
|
30810
31317
|
tokenIdentifiers: tokenIdentifiers?.map((identifier) => {
|
|
30811
31318
|
const { tokenIdentifier } = decodeBech32mTokenIdentifier(
|
|
30812
31319
|
identifier,
|
|
@@ -30814,7 +31321,7 @@ var TokenTransactionService = class {
|
|
|
30814
31321
|
);
|
|
30815
31322
|
return tokenIdentifier;
|
|
30816
31323
|
}),
|
|
30817
|
-
tokenTransactionHashes: tokenTransactionHashes?.map(
|
|
31324
|
+
tokenTransactionHashes: tokenTransactionHashes?.map(import_utils20.hexToBytes),
|
|
30818
31325
|
outputIds: outputIds || [],
|
|
30819
31326
|
limit: pageSize,
|
|
30820
31327
|
offset
|
|
@@ -30849,7 +31356,7 @@ var TokenTransactionService = class {
|
|
|
30849
31356
|
});
|
|
30850
31357
|
}
|
|
30851
31358
|
const exactMatch = tokenOutputs.find(
|
|
30852
|
-
(item) => (0,
|
|
31359
|
+
(item) => (0, import_utils19.bytesToNumberBE)(item.output.tokenAmount) === tokenAmount
|
|
30853
31360
|
);
|
|
30854
31361
|
if (exactMatch) {
|
|
30855
31362
|
return [exactMatch];
|
|
@@ -30860,7 +31367,7 @@ var TokenTransactionService = class {
|
|
|
30860
31367
|
for (const outputWithPreviousTransactionData of tokenOutputs) {
|
|
30861
31368
|
if (remainingAmount <= 0n) break;
|
|
30862
31369
|
selectedOutputs.push(outputWithPreviousTransactionData);
|
|
30863
|
-
remainingAmount -= (0,
|
|
31370
|
+
remainingAmount -= (0, import_utils19.bytesToNumberBE)(
|
|
30864
31371
|
outputWithPreviousTransactionData.output.tokenAmount
|
|
30865
31372
|
);
|
|
30866
31373
|
}
|
|
@@ -30876,13 +31383,13 @@ var TokenTransactionService = class {
|
|
|
30876
31383
|
if (strategy === "SMALL_FIRST") {
|
|
30877
31384
|
tokenOutputs.sort((a, b) => {
|
|
30878
31385
|
return Number(
|
|
30879
|
-
(0,
|
|
31386
|
+
(0, import_utils19.bytesToNumberBE)(a.output.tokenAmount) - (0, import_utils19.bytesToNumberBE)(b.output.tokenAmount)
|
|
30880
31387
|
);
|
|
30881
31388
|
});
|
|
30882
31389
|
} else {
|
|
30883
31390
|
tokenOutputs.sort((a, b) => {
|
|
30884
31391
|
return Number(
|
|
30885
|
-
(0,
|
|
31392
|
+
(0, import_utils19.bytesToNumberBE)(b.output.tokenAmount) - (0, import_utils19.bytesToNumberBE)(a.output.tokenAmount)
|
|
30886
31393
|
);
|
|
30887
31394
|
});
|
|
30888
31395
|
}
|
|
@@ -30890,7 +31397,7 @@ var TokenTransactionService = class {
|
|
|
30890
31397
|
// Helper function for deciding if the signer public key is the identity public key
|
|
30891
31398
|
async signMessageWithKey(message, publicKey) {
|
|
30892
31399
|
const tokenSignatures = this.config.getTokenSignatures();
|
|
30893
|
-
if ((0,
|
|
31400
|
+
if ((0, import_utils19.bytesToHex)(publicKey) === (0, import_utils19.bytesToHex)(await this.config.signer.getIdentityPublicKey())) {
|
|
30894
31401
|
if (tokenSignatures === "SCHNORR") {
|
|
30895
31402
|
return await this.config.signer.signSchnorrWithIdentityKey(message);
|
|
30896
31403
|
} else {
|
|
@@ -30899,8 +31406,8 @@ var TokenTransactionService = class {
|
|
|
30899
31406
|
} else {
|
|
30900
31407
|
throw new ValidationError("Invalid public key", {
|
|
30901
31408
|
field: "publicKey",
|
|
30902
|
-
value: (0,
|
|
30903
|
-
expected: (0,
|
|
31409
|
+
value: (0, import_utils19.bytesToHex)(publicKey),
|
|
31410
|
+
expected: (0, import_utils19.bytesToHex)(await this.config.signer.getIdentityPublicKey())
|
|
30904
31411
|
});
|
|
30905
31412
|
}
|
|
30906
31413
|
}
|
|
@@ -30963,7 +31470,7 @@ var TokenTransactionService = class {
|
|
|
30963
31470
|
}
|
|
30964
31471
|
const payload = {
|
|
30965
31472
|
finalTokenTransactionHash,
|
|
30966
|
-
operatorIdentityPublicKey: (0,
|
|
31473
|
+
operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
|
|
30967
31474
|
};
|
|
30968
31475
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
30969
31476
|
const ownerSignature = await this.signMessageWithKey(
|
|
@@ -30985,7 +31492,7 @@ var TokenTransactionService = class {
|
|
|
30985
31492
|
}
|
|
30986
31493
|
const payload = {
|
|
30987
31494
|
finalTokenTransactionHash,
|
|
30988
|
-
operatorIdentityPublicKey: (0,
|
|
31495
|
+
operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
|
|
30989
31496
|
};
|
|
30990
31497
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
30991
31498
|
const ownerSignature = await this.signMessageWithKey(
|
|
@@ -31001,7 +31508,7 @@ var TokenTransactionService = class {
|
|
|
31001
31508
|
for (let i = 0; i < transferInput.outputsToSpend.length; i++) {
|
|
31002
31509
|
const payload = {
|
|
31003
31510
|
finalTokenTransactionHash,
|
|
31004
|
-
operatorIdentityPublicKey: (0,
|
|
31511
|
+
operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
|
|
31005
31512
|
};
|
|
31006
31513
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
31007
31514
|
let ownerSignature;
|
|
@@ -31018,7 +31525,7 @@ var TokenTransactionService = class {
|
|
|
31018
31525
|
}
|
|
31019
31526
|
inputTtxoSignaturesPerOperator.push({
|
|
31020
31527
|
ttxoSignatures,
|
|
31021
|
-
operatorIdentityPublicKey: (0,
|
|
31528
|
+
operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
|
|
31022
31529
|
});
|
|
31023
31530
|
}
|
|
31024
31531
|
return inputTtxoSignaturesPerOperator;
|
|
@@ -31037,7 +31544,7 @@ var import_nice_grpc_common3 = require("nice-grpc-common");
|
|
|
31037
31544
|
|
|
31038
31545
|
// src/services/signing.ts
|
|
31039
31546
|
init_buffer();
|
|
31040
|
-
var
|
|
31547
|
+
var import_utils21 = require("@noble/curves/utils");
|
|
31041
31548
|
var SigningService = class {
|
|
31042
31549
|
config;
|
|
31043
31550
|
constructor(config) {
|
|
@@ -31093,7 +31600,7 @@ var SigningService = class {
|
|
|
31093
31600
|
}
|
|
31094
31601
|
const nodeTx = getTxFromRawTxBytes(leaf.leaf.nodeTx);
|
|
31095
31602
|
const cpfpNodeOutPoint = {
|
|
31096
|
-
txid: (0,
|
|
31603
|
+
txid: (0, import_utils21.hexToBytes)(getTxId(nodeTx)),
|
|
31097
31604
|
index: 0
|
|
31098
31605
|
};
|
|
31099
31606
|
const currRefundTx = getTxFromRawTxBytes(leaf.leaf.refundTx);
|
|
@@ -31119,7 +31626,7 @@ var SigningService = class {
|
|
|
31119
31626
|
if (leaf.leaf.directTx.length > 0) {
|
|
31120
31627
|
directNodeTx = getTxFromRawTxBytes(leaf.leaf.directTx);
|
|
31121
31628
|
directNodeOutPoint = {
|
|
31122
|
-
txid: (0,
|
|
31629
|
+
txid: (0, import_utils21.hexToBytes)(getTxId(directNodeTx)),
|
|
31123
31630
|
index: 0
|
|
31124
31631
|
};
|
|
31125
31632
|
}
|
|
@@ -31203,15 +31710,15 @@ var SigningService = class {
|
|
|
31203
31710
|
|
|
31204
31711
|
// src/tests/utils/test-faucet.ts
|
|
31205
31712
|
init_buffer();
|
|
31206
|
-
var import_utils23 = require("@noble/curves/abstract/utils");
|
|
31207
31713
|
var import_secp256k114 = require("@noble/curves/secp256k1");
|
|
31714
|
+
var import_utils22 = require("@noble/curves/utils");
|
|
31208
31715
|
var btc5 = __toESM(require("@scure/btc-signer"), 1);
|
|
31209
31716
|
var import_btc_signer5 = require("@scure/btc-signer");
|
|
31210
|
-
var
|
|
31211
|
-
var STATIC_FAUCET_KEY = (0,
|
|
31717
|
+
var import_utils23 = require("@scure/btc-signer/utils");
|
|
31718
|
+
var STATIC_FAUCET_KEY = (0, import_utils22.hexToBytes)(
|
|
31212
31719
|
"deadbeef1337cafe4242424242424242deadbeef1337cafe4242424242424242"
|
|
31213
31720
|
);
|
|
31214
|
-
var STATIC_MINING_KEY = (0,
|
|
31721
|
+
var STATIC_MINING_KEY = (0, import_utils22.hexToBytes)(
|
|
31215
31722
|
"1337cafe4242deadbeef4242424242421337cafe4242deadbeef424242424242"
|
|
31216
31723
|
);
|
|
31217
31724
|
var SATS_PER_BTC = 1e8;
|
|
@@ -31274,7 +31781,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
31274
31781
|
if (!scanResult.success || scanResult.unspents.length === 0) {
|
|
31275
31782
|
const blockHash = await this.generateToAddress(1, address2);
|
|
31276
31783
|
const block = await this.getBlock(blockHash[0]);
|
|
31277
|
-
const fundingTx = import_btc_signer5.Transaction.fromRaw((0,
|
|
31784
|
+
const fundingTx = import_btc_signer5.Transaction.fromRaw((0, import_utils22.hexToBytes)(block.tx[0].hex), {
|
|
31278
31785
|
allowUnknownOutputs: true
|
|
31279
31786
|
});
|
|
31280
31787
|
await this.generateToAddress(100, this.miningAddress);
|
|
@@ -31336,13 +31843,13 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
31336
31843
|
},
|
|
31337
31844
|
STATIC_MINING_KEY
|
|
31338
31845
|
);
|
|
31339
|
-
await this.broadcastTx((0,
|
|
31846
|
+
await this.broadcastTx((0, import_utils22.bytesToHex)(signedSplitTx.extract()));
|
|
31340
31847
|
const splitTxId = signedSplitTx.id;
|
|
31341
31848
|
for (let i = 0; i < numCoinsToCreate; i++) {
|
|
31342
31849
|
this.coins.push({
|
|
31343
31850
|
key: STATIC_FAUCET_KEY,
|
|
31344
31851
|
outpoint: {
|
|
31345
|
-
txid: (0,
|
|
31852
|
+
txid: (0, import_utils22.hexToBytes)(splitTxId),
|
|
31346
31853
|
index: i
|
|
31347
31854
|
},
|
|
31348
31855
|
txout: signedSplitTx.getOutput(i)
|
|
@@ -31370,7 +31877,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
31370
31877
|
coinToSend.txout,
|
|
31371
31878
|
coinToSend.key
|
|
31372
31879
|
);
|
|
31373
|
-
await this.broadcastTx((0,
|
|
31880
|
+
await this.broadcastTx((0, import_utils22.bytesToHex)(signedTx.extract()));
|
|
31374
31881
|
}
|
|
31375
31882
|
async signFaucetCoin(unsignedTx, fundingTxOut, key) {
|
|
31376
31883
|
const pubKey = import_secp256k114.secp256k1.getPublicKey(key);
|
|
@@ -31390,7 +31897,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
31390
31897
|
new Array(unsignedTx.inputsLength).fill(fundingTxOut.amount)
|
|
31391
31898
|
);
|
|
31392
31899
|
const merkleRoot = new Uint8Array();
|
|
31393
|
-
const tweakedKey = (0,
|
|
31900
|
+
const tweakedKey = (0, import_utils23.taprootTweakPrivKey)(key, merkleRoot);
|
|
31394
31901
|
if (!tweakedKey)
|
|
31395
31902
|
throw new Error("Invalid private key for taproot tweaking");
|
|
31396
31903
|
const signature = import_secp256k114.schnorr.sign(sighash, tweakedKey);
|
|
@@ -31490,7 +31997,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
31490
31997
|
});
|
|
31491
31998
|
}
|
|
31492
31999
|
const signedTx = await this.signFaucetCoin(tx, coin.txout, coin.key);
|
|
31493
|
-
const txHex = (0,
|
|
32000
|
+
const txHex = (0, import_utils22.bytesToHex)(signedTx.extract());
|
|
31494
32001
|
await this.broadcastTx(txHex);
|
|
31495
32002
|
const randomKey = import_secp256k114.secp256k1.utils.randomPrivateKey();
|
|
31496
32003
|
const randomPubKey = import_secp256k114.secp256k1.getPublicKey(randomKey);
|
|
@@ -31681,7 +32188,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31681
32188
|
try {
|
|
31682
32189
|
if (event?.$case === "transfer" && event.transfer.transfer && event.transfer.transfer.type !== 40 /* COUNTER_SWAP */) {
|
|
31683
32190
|
const { senderIdentityPublicKey, receiverIdentityPublicKey } = event.transfer.transfer;
|
|
31684
|
-
if (event.transfer.transfer && !(0,
|
|
32191
|
+
if (event.transfer.transfer && !(0, import_utils24.equalBytes)(senderIdentityPublicKey, receiverIdentityPublicKey)) {
|
|
31685
32192
|
await this.claimTransfer({
|
|
31686
32193
|
transfer: event.transfer.transfer,
|
|
31687
32194
|
emit: true,
|
|
@@ -31846,10 +32353,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31846
32353
|
leavesToIgnore.add(nodeId);
|
|
31847
32354
|
continue;
|
|
31848
32355
|
}
|
|
31849
|
-
if (leaf.status !== operatorLeaf.status || !leaf.signingKeyshare || !operatorLeaf.signingKeyshare || !(0,
|
|
32356
|
+
if (leaf.status !== operatorLeaf.status || !leaf.signingKeyshare || !operatorLeaf.signingKeyshare || !(0, import_utils24.equalBytes)(
|
|
31850
32357
|
leaf.signingKeyshare.publicKey,
|
|
31851
32358
|
operatorLeaf.signingKeyshare.publicKey
|
|
31852
|
-
) || !(0,
|
|
32359
|
+
) || !(0, import_utils24.equalBytes)(leaf.nodeTx, operatorLeaf.nodeTx)) {
|
|
31853
32360
|
leavesToIgnore.add(nodeId);
|
|
31854
32361
|
}
|
|
31855
32362
|
}
|
|
@@ -31900,7 +32407,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31900
32407
|
});
|
|
31901
32408
|
}
|
|
31902
32409
|
verifyKey(pubkey1, pubkey2, verifyingKey) {
|
|
31903
|
-
return (0,
|
|
32410
|
+
return (0, import_utils24.equalBytes)(addPublicKeys(pubkey1, pubkey2), verifyingKey);
|
|
31904
32411
|
}
|
|
31905
32412
|
async selectLeaves(targetAmounts) {
|
|
31906
32413
|
if (targetAmounts.length === 0) {
|
|
@@ -32058,7 +32565,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32058
32565
|
* @returns {Promise<string>} The identity public key as a hex string.
|
|
32059
32566
|
*/
|
|
32060
32567
|
async getIdentityPublicKey() {
|
|
32061
|
-
return (0,
|
|
32568
|
+
return (0, import_utils24.bytesToHex)(await this.config.signer.getIdentityPublicKey());
|
|
32062
32569
|
}
|
|
32063
32570
|
/**
|
|
32064
32571
|
* Gets the Spark address of the wallet.
|
|
@@ -32068,7 +32575,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32068
32575
|
async getSparkAddress() {
|
|
32069
32576
|
if (!this.sparkAddress) {
|
|
32070
32577
|
this.sparkAddress = encodeSparkAddress({
|
|
32071
|
-
identityPublicKey: (0,
|
|
32578
|
+
identityPublicKey: (0, import_utils24.bytesToHex)(
|
|
32072
32579
|
await this.config.signer.getIdentityPublicKey()
|
|
32073
32580
|
),
|
|
32074
32581
|
network: this.config.getNetworkType()
|
|
@@ -32131,7 +32638,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32131
32638
|
$case: "tokensPayment",
|
|
32132
32639
|
tokensPayment: {
|
|
32133
32640
|
tokenIdentifier: decodedTokenIdentifier ?? void 0,
|
|
32134
|
-
amount: amount ? (0,
|
|
32641
|
+
amount: amount ? (0, import_utils24.numberToVarBytesBE)(amount) : void 0
|
|
32135
32642
|
}
|
|
32136
32643
|
};
|
|
32137
32644
|
const invoiceFields = {
|
|
@@ -32139,7 +32646,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32139
32646
|
id: (0, import_uuidv75.uuidv7obj)().bytes,
|
|
32140
32647
|
paymentType: protoPayment,
|
|
32141
32648
|
memo: memo ?? void 0,
|
|
32142
|
-
senderPublicKey: senderPublicKey ? (0,
|
|
32649
|
+
senderPublicKey: senderPublicKey ? (0, import_utils24.hexToBytes)(senderPublicKey) : void 0,
|
|
32143
32650
|
expiryTime: expiryTime ?? void 0
|
|
32144
32651
|
};
|
|
32145
32652
|
validateSparkInvoiceFields(invoiceFields);
|
|
@@ -32152,7 +32659,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32152
32659
|
const signature = await this.config.signer.signSchnorrWithIdentityKey(hash);
|
|
32153
32660
|
return encodeSparkAddressWithSignature(
|
|
32154
32661
|
{
|
|
32155
|
-
identityPublicKey: (0,
|
|
32662
|
+
identityPublicKey: (0, import_utils24.bytesToHex)(identityPublicKey),
|
|
32156
32663
|
network: this.config.getNetworkType(),
|
|
32157
32664
|
sparkInvoiceFields: invoiceFields
|
|
32158
32665
|
},
|
|
@@ -32198,7 +32705,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32198
32705
|
mnemonic = mnemonicOrSeed;
|
|
32199
32706
|
seed = await this.config.signer.mnemonicToSeed(mnemonicOrSeed);
|
|
32200
32707
|
} else {
|
|
32201
|
-
seed = (0,
|
|
32708
|
+
seed = (0, import_utils24.hexToBytes)(mnemonicOrSeed);
|
|
32202
32709
|
}
|
|
32203
32710
|
}
|
|
32204
32711
|
await this.initWalletFromSeed(seed, accountNumber);
|
|
@@ -32220,7 +32727,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32220
32727
|
});
|
|
32221
32728
|
}
|
|
32222
32729
|
this.sparkAddress = encodeSparkAddress({
|
|
32223
|
-
identityPublicKey: (0,
|
|
32730
|
+
identityPublicKey: (0, import_utils24.bytesToHex)(identityPublicKey),
|
|
32224
32731
|
network: this.config.getNetworkType()
|
|
32225
32732
|
});
|
|
32226
32733
|
return this.sparkAddress;
|
|
@@ -32340,7 +32847,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32340
32847
|
directFromCpfpSignatureMap
|
|
32341
32848
|
} = await this.transferService.startSwapSignRefund(
|
|
32342
32849
|
leafKeyTweaks,
|
|
32343
|
-
(0,
|
|
32850
|
+
(0, import_utils24.hexToBytes)(this.config.getSspIdentityPublicKey()),
|
|
32344
32851
|
new Date(Date.now() + 2 * 60 * 1e3)
|
|
32345
32852
|
);
|
|
32346
32853
|
try {
|
|
@@ -32400,18 +32907,18 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32400
32907
|
const userLeaves = [];
|
|
32401
32908
|
userLeaves.push({
|
|
32402
32909
|
leaf_id: transfer.leaves[0].leaf.id,
|
|
32403
|
-
raw_unsigned_refund_transaction: (0,
|
|
32910
|
+
raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
|
|
32404
32911
|
transfer.leaves[0].intermediateRefundTx
|
|
32405
32912
|
),
|
|
32406
|
-
direct_raw_unsigned_refund_transaction: (0,
|
|
32913
|
+
direct_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
|
|
32407
32914
|
transfer.leaves[0].intermediateDirectRefundTx
|
|
32408
32915
|
),
|
|
32409
|
-
direct_from_cpfp_raw_unsigned_refund_transaction: (0,
|
|
32916
|
+
direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
|
|
32410
32917
|
transfer.leaves[0].intermediateDirectFromCpfpRefundTx
|
|
32411
32918
|
),
|
|
32412
|
-
adaptor_added_signature: (0,
|
|
32413
|
-
direct_adaptor_added_signature: (0,
|
|
32414
|
-
direct_from_cpfp_adaptor_added_signature: (0,
|
|
32919
|
+
adaptor_added_signature: (0, import_utils24.bytesToHex)(cpfpAdaptorSignature),
|
|
32920
|
+
direct_adaptor_added_signature: (0, import_utils24.bytesToHex)(directAdaptorSignature),
|
|
32921
|
+
direct_from_cpfp_adaptor_added_signature: (0, import_utils24.bytesToHex)(
|
|
32415
32922
|
directFromCpfpAdaptorSignature
|
|
32416
32923
|
)
|
|
32417
32924
|
});
|
|
@@ -32464,24 +32971,24 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32464
32971
|
}
|
|
32465
32972
|
userLeaves.push({
|
|
32466
32973
|
leaf_id: leaf.leaf.id,
|
|
32467
|
-
raw_unsigned_refund_transaction: (0,
|
|
32974
|
+
raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
|
|
32468
32975
|
leaf.intermediateRefundTx
|
|
32469
32976
|
),
|
|
32470
|
-
direct_raw_unsigned_refund_transaction: (0,
|
|
32977
|
+
direct_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
|
|
32471
32978
|
leaf.intermediateDirectRefundTx
|
|
32472
32979
|
),
|
|
32473
|
-
direct_from_cpfp_raw_unsigned_refund_transaction: (0,
|
|
32980
|
+
direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
|
|
32474
32981
|
leaf.intermediateDirectFromCpfpRefundTx
|
|
32475
32982
|
),
|
|
32476
|
-
adaptor_added_signature: (0,
|
|
32477
|
-
direct_adaptor_added_signature: (0,
|
|
32478
|
-
direct_from_cpfp_adaptor_added_signature: (0,
|
|
32983
|
+
adaptor_added_signature: (0, import_utils24.bytesToHex)(cpfpSignature),
|
|
32984
|
+
direct_adaptor_added_signature: (0, import_utils24.bytesToHex)(directSignature),
|
|
32985
|
+
direct_from_cpfp_adaptor_added_signature: (0, import_utils24.bytesToHex)(
|
|
32479
32986
|
directFromCpfpSignature
|
|
32480
32987
|
)
|
|
32481
32988
|
});
|
|
32482
32989
|
}
|
|
32483
32990
|
const sspClient = this.getSspClient();
|
|
32484
|
-
const cpfpAdaptorPubkey = (0,
|
|
32991
|
+
const cpfpAdaptorPubkey = (0, import_utils24.bytesToHex)(
|
|
32485
32992
|
import_secp256k115.secp256k1.getPublicKey(cpfpAdaptorPrivateKey)
|
|
32486
32993
|
);
|
|
32487
32994
|
if (!cpfpAdaptorPubkey) {
|
|
@@ -32489,13 +32996,13 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32489
32996
|
}
|
|
32490
32997
|
let directAdaptorPubkey;
|
|
32491
32998
|
if (directAdaptorPrivateKey.length > 0) {
|
|
32492
|
-
directAdaptorPubkey = (0,
|
|
32999
|
+
directAdaptorPubkey = (0, import_utils24.bytesToHex)(
|
|
32493
33000
|
import_secp256k115.secp256k1.getPublicKey(directAdaptorPrivateKey)
|
|
32494
33001
|
);
|
|
32495
33002
|
}
|
|
32496
33003
|
let directFromCpfpAdaptorPubkey;
|
|
32497
33004
|
if (directFromCpfpAdaptorPrivateKey.length > 0) {
|
|
32498
|
-
directFromCpfpAdaptorPubkey = (0,
|
|
33005
|
+
directFromCpfpAdaptorPubkey = (0, import_utils24.bytesToHex)(
|
|
32499
33006
|
import_secp256k115.secp256k1.getPublicKey(directFromCpfpAdaptorPrivateKey)
|
|
32500
33007
|
);
|
|
32501
33008
|
}
|
|
@@ -32555,7 +33062,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32555
33062
|
throw new Error(`Leaf not found for node ${nodeId}`);
|
|
32556
33063
|
}
|
|
32557
33064
|
const cpfpNodeTx = getTxFromRawTxBytes(node.nodeTx);
|
|
32558
|
-
const cpfpRefundTxBytes = (0,
|
|
33065
|
+
const cpfpRefundTxBytes = (0, import_utils24.hexToBytes)(leaf.rawUnsignedRefundTransaction);
|
|
32559
33066
|
const cpfpRefundTx = getTxFromRawTxBytes(cpfpRefundTxBytes);
|
|
32560
33067
|
const cpfpSighash = getSigHashFromTx(
|
|
32561
33068
|
cpfpRefundTx,
|
|
@@ -32564,7 +33071,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32564
33071
|
);
|
|
32565
33072
|
const nodePublicKey = node.verifyingPublicKey;
|
|
32566
33073
|
const taprootKey = computeTaprootKeyNoScript(nodePublicKey.slice(1));
|
|
32567
|
-
const cpfpAdaptorSignatureBytes = (0,
|
|
33074
|
+
const cpfpAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
|
|
32568
33075
|
leaf.adaptorSignedSignature
|
|
32569
33076
|
);
|
|
32570
33077
|
applyAdaptorToSignature(
|
|
@@ -32575,7 +33082,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32575
33082
|
);
|
|
32576
33083
|
if (leaf.directRawUnsignedRefundTransaction) {
|
|
32577
33084
|
const directNodeTx = getTxFromRawTxBytes(node.directTx);
|
|
32578
|
-
const directRefundTxBytes = (0,
|
|
33085
|
+
const directRefundTxBytes = (0, import_utils24.hexToBytes)(
|
|
32579
33086
|
leaf.directRawUnsignedRefundTransaction
|
|
32580
33087
|
);
|
|
32581
33088
|
const directRefundTx = getTxFromRawTxBytes(directRefundTxBytes);
|
|
@@ -32589,7 +33096,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32589
33096
|
`Direct adaptor signed signature missing for node ${nodeId}`
|
|
32590
33097
|
);
|
|
32591
33098
|
}
|
|
32592
|
-
const directAdaptorSignatureBytes = (0,
|
|
33099
|
+
const directAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
|
|
32593
33100
|
leaf.directAdaptorSignedSignature
|
|
32594
33101
|
);
|
|
32595
33102
|
applyAdaptorToSignature(
|
|
@@ -32600,7 +33107,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32600
33107
|
);
|
|
32601
33108
|
}
|
|
32602
33109
|
if (leaf.directFromCpfpRawUnsignedRefundTransaction) {
|
|
32603
|
-
const directFromCpfpRefundTxBytes = (0,
|
|
33110
|
+
const directFromCpfpRefundTxBytes = (0, import_utils24.hexToBytes)(
|
|
32604
33111
|
leaf.directFromCpfpRawUnsignedRefundTransaction
|
|
32605
33112
|
);
|
|
32606
33113
|
const directFromCpfpRefundTx = getTxFromRawTxBytes(
|
|
@@ -32616,7 +33123,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32616
33123
|
`Direct adaptor signed signature missing for node ${nodeId}`
|
|
32617
33124
|
);
|
|
32618
33125
|
}
|
|
32619
|
-
const directFromCpfpAdaptorSignatureBytes = (0,
|
|
33126
|
+
const directFromCpfpAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
|
|
32620
33127
|
leaf.directFromCpfpAdaptorSignedSignature
|
|
32621
33128
|
);
|
|
32622
33129
|
applyAdaptorToSignature(
|
|
@@ -32635,9 +33142,9 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32635
33142
|
directFromCpfpSignatureMap
|
|
32636
33143
|
);
|
|
32637
33144
|
const completeResponse = await sspClient.completeLeaveSwap({
|
|
32638
|
-
adaptorSecretKey: (0,
|
|
32639
|
-
directAdaptorSecretKey: (0,
|
|
32640
|
-
directFromCpfpAdaptorSecretKey: (0,
|
|
33145
|
+
adaptorSecretKey: (0, import_utils24.bytesToHex)(cpfpAdaptorPrivateKey),
|
|
33146
|
+
directAdaptorSecretKey: (0, import_utils24.bytesToHex)(directAdaptorPrivateKey),
|
|
33147
|
+
directFromCpfpAdaptorSecretKey: (0, import_utils24.bytesToHex)(
|
|
32641
33148
|
directFromCpfpAdaptorPrivateKey
|
|
32642
33149
|
),
|
|
32643
33150
|
userOutboundTransferExternalId: transfer.id,
|
|
@@ -32732,12 +33239,12 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32732
33239
|
let tokenMetadataMap = /* @__PURE__ */ new Map();
|
|
32733
33240
|
for (const [tokenIdentifier, metadata] of this.tokenMetadata) {
|
|
32734
33241
|
tokenMetadataMap.set(tokenIdentifier, {
|
|
32735
|
-
tokenPublicKey: (0,
|
|
33242
|
+
tokenPublicKey: (0, import_utils24.bytesToHex)(metadata.issuerPublicKey),
|
|
32736
33243
|
rawTokenIdentifier: metadata.tokenIdentifier,
|
|
32737
33244
|
tokenName: metadata.tokenName,
|
|
32738
33245
|
tokenTicker: metadata.tokenTicker,
|
|
32739
33246
|
decimals: metadata.decimals,
|
|
32740
|
-
maxSupply: (0,
|
|
33247
|
+
maxSupply: (0, import_utils24.bytesToNumberBE)(metadata.maxSupply)
|
|
32741
33248
|
});
|
|
32742
33249
|
}
|
|
32743
33250
|
return tokenMetadataMap;
|
|
@@ -32772,7 +33279,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32772
33279
|
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
32773
33280
|
*/
|
|
32774
33281
|
async getSingleUseDepositAddress() {
|
|
32775
|
-
return await this.generateDepositAddress(
|
|
33282
|
+
return await this.generateDepositAddress();
|
|
32776
33283
|
}
|
|
32777
33284
|
/**
|
|
32778
33285
|
* Generates a new static deposit address for receiving bitcoin funds.
|
|
@@ -32781,43 +33288,32 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32781
33288
|
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
32782
33289
|
*/
|
|
32783
33290
|
async getStaticDepositAddress() {
|
|
32784
|
-
|
|
32785
|
-
|
|
32786
|
-
|
|
32787
|
-
|
|
32788
|
-
|
|
32789
|
-
|
|
32790
|
-
|
|
32791
|
-
|
|
32792
|
-
|
|
32793
|
-
}
|
|
32794
|
-
} else {
|
|
32795
|
-
throw error;
|
|
32796
|
-
}
|
|
33291
|
+
const signingPubkey = await this.config.signer.getStaticDepositSigningKey(0);
|
|
33292
|
+
const address2 = await this.depositService.generateStaticDepositAddress({
|
|
33293
|
+
signingPubkey
|
|
33294
|
+
});
|
|
33295
|
+
if (!address2.depositAddress) {
|
|
33296
|
+
throw new RPCError("Failed to generate static deposit address", {
|
|
33297
|
+
method: "generateStaticDepositAddress",
|
|
33298
|
+
params: { signingPubkey }
|
|
33299
|
+
});
|
|
32797
33300
|
}
|
|
33301
|
+
return address2.depositAddress.address;
|
|
32798
33302
|
}
|
|
32799
33303
|
/**
|
|
32800
33304
|
* Generates a deposit address for receiving funds.
|
|
32801
|
-
*
|
|
32802
|
-
* @param {boolean} static - Whether the address is static or single use
|
|
32803
33305
|
* @returns {Promise<string>} A deposit address
|
|
32804
33306
|
* @private
|
|
32805
33307
|
*/
|
|
32806
|
-
async generateDepositAddress(
|
|
33308
|
+
async generateDepositAddress() {
|
|
32807
33309
|
const leafId = (0, import_uuidv75.uuidv7)();
|
|
32808
|
-
|
|
32809
|
-
|
|
32810
|
-
|
|
32811
|
-
}
|
|
32812
|
-
signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
|
|
32813
|
-
type: "leaf" /* LEAF */,
|
|
32814
|
-
path: leafId
|
|
32815
|
-
});
|
|
32816
|
-
}
|
|
33310
|
+
const signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
|
|
33311
|
+
type: "leaf" /* LEAF */,
|
|
33312
|
+
path: leafId
|
|
33313
|
+
});
|
|
32817
33314
|
const address2 = await this.depositService.generateDepositAddress({
|
|
32818
33315
|
signingPubkey,
|
|
32819
|
-
leafId
|
|
32820
|
-
isStatic
|
|
33316
|
+
leafId
|
|
32821
33317
|
});
|
|
32822
33318
|
if (!address2.depositAddress) {
|
|
32823
33319
|
throw new RPCError("Failed to generate deposit address", {
|
|
@@ -32844,7 +33340,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32844
33340
|
* @param offset - Pagination offset (default 0).
|
|
32845
33341
|
* @returns {Promise<{ txid: string, vout: number }[]>} List of confirmed UTXOs.
|
|
32846
33342
|
*/
|
|
32847
|
-
async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0) {
|
|
33343
|
+
async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0, excludeClaimed = false) {
|
|
32848
33344
|
if (!depositAddress) {
|
|
32849
33345
|
throw new ValidationError("Deposit address cannot be empty", {
|
|
32850
33346
|
field: "depositAddress"
|
|
@@ -32858,10 +33354,11 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32858
33354
|
address: depositAddress,
|
|
32859
33355
|
network: NetworkToProto[this.config.getNetwork()],
|
|
32860
33356
|
limit,
|
|
32861
|
-
offset
|
|
33357
|
+
offset,
|
|
33358
|
+
excludeClaimed
|
|
32862
33359
|
});
|
|
32863
33360
|
return response.utxos.map((utxo) => ({
|
|
32864
|
-
txid: (0,
|
|
33361
|
+
txid: (0, import_utils24.bytesToHex)(utxo.txid),
|
|
32865
33362
|
vout: utxo.vout
|
|
32866
33363
|
})) ?? [];
|
|
32867
33364
|
} catch (error) {
|
|
@@ -32931,7 +33428,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32931
33428
|
if (network === BitcoinNetwork_default.FUTURE_VALUE) {
|
|
32932
33429
|
network = BitcoinNetwork_default.REGTEST;
|
|
32933
33430
|
}
|
|
32934
|
-
const depositSecretKey = (0,
|
|
33431
|
+
const depositSecretKey = (0, import_utils24.bytesToHex)(
|
|
32935
33432
|
await this.config.signer.getStaticDepositSecretKey(0)
|
|
32936
33433
|
);
|
|
32937
33434
|
const message = await this.getStaticDepositSigningPayload(
|
|
@@ -32944,7 +33441,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32944
33441
|
);
|
|
32945
33442
|
const hashBuffer = (0, import_sha213.sha256)(message);
|
|
32946
33443
|
const signatureBytes = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
|
|
32947
|
-
const signature = (0,
|
|
33444
|
+
const signature = (0, import_utils24.bytesToHex)(signatureBytes);
|
|
32948
33445
|
const response = await this.sspClient.claimStaticDeposit({
|
|
32949
33446
|
transactionId,
|
|
32950
33447
|
outputIndex,
|
|
@@ -33096,7 +33593,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33096
33593
|
networkJSON.toLowerCase(),
|
|
33097
33594
|
2 /* Refund */,
|
|
33098
33595
|
creditAmountSats,
|
|
33099
|
-
(0,
|
|
33596
|
+
(0, import_utils24.bytesToHex)(spendTxSighash)
|
|
33100
33597
|
);
|
|
33101
33598
|
const hashBuffer = (0, import_sha213.sha256)(message);
|
|
33102
33599
|
const swapResponseUserSignature = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
|
|
@@ -33105,7 +33602,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33105
33602
|
);
|
|
33106
33603
|
const swapResponse = await sparkClient.initiate_static_deposit_utxo_refund({
|
|
33107
33604
|
onChainUtxo: {
|
|
33108
|
-
txid: (0,
|
|
33605
|
+
txid: (0, import_utils24.hexToBytes)(depositTransactionId),
|
|
33109
33606
|
vout: outputIndex,
|
|
33110
33607
|
network: networkType
|
|
33111
33608
|
},
|
|
@@ -33174,7 +33671,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33174
33671
|
creditAmountView.setUint32(0, lowerHalf, true);
|
|
33175
33672
|
creditAmountView.setUint32(4, upperHalf, true);
|
|
33176
33673
|
parts.push(new Uint8Array(creditAmountBuffer));
|
|
33177
|
-
parts.push((0,
|
|
33674
|
+
parts.push((0, import_utils24.hexToBytes)(sspSignature));
|
|
33178
33675
|
const totalLength = parts.reduce((sum, part) => sum + part.length, 0);
|
|
33179
33676
|
const payload = new Uint8Array(totalLength);
|
|
33180
33677
|
let offset = 0;
|
|
@@ -33579,9 +34076,9 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33579
34076
|
});
|
|
33580
34077
|
}
|
|
33581
34078
|
const signerIdentityPublicKey = await this.config.signer.getIdentityPublicKey();
|
|
33582
|
-
const isSelfTransfer = (0,
|
|
34079
|
+
const isSelfTransfer = (0, import_utils24.equalBytes)(
|
|
33583
34080
|
signerIdentityPublicKey,
|
|
33584
|
-
(0,
|
|
34081
|
+
(0, import_utils24.hexToBytes)(receiverAddress.identityPublicKey)
|
|
33585
34082
|
);
|
|
33586
34083
|
return await this.withLeaves(async () => {
|
|
33587
34084
|
let leavesToSend = (await this.selectLeaves([amountSats])).get(
|
|
@@ -33603,7 +34100,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33603
34100
|
);
|
|
33604
34101
|
const transfer = await this.transferService.sendTransferWithKeyTweaks(
|
|
33605
34102
|
leafKeyTweaks,
|
|
33606
|
-
(0,
|
|
34103
|
+
(0, import_utils24.hexToBytes)(receiverAddress.identityPublicKey)
|
|
33607
34104
|
);
|
|
33608
34105
|
const leavesToRemove = new Set(leavesToSend.map((leaf) => leaf.id));
|
|
33609
34106
|
this.leaves = this.leaves.filter((leaf) => !leavesToRemove.has(leaf.id));
|
|
@@ -33619,7 +34116,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33619
34116
|
}
|
|
33620
34117
|
return mapTransferToWalletTransfer(
|
|
33621
34118
|
transfer,
|
|
33622
|
-
(0,
|
|
34119
|
+
(0, import_utils24.bytesToHex)(await this.config.signer.getIdentityPublicKey())
|
|
33623
34120
|
);
|
|
33624
34121
|
});
|
|
33625
34122
|
}
|
|
@@ -33975,7 +34472,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33975
34472
|
const invoice2 = await sspClient.requestLightningReceive({
|
|
33976
34473
|
amountSats: amountSats2,
|
|
33977
34474
|
network: bitcoinNetwork,
|
|
33978
|
-
paymentHash: (0,
|
|
34475
|
+
paymentHash: (0, import_utils24.bytesToHex)(paymentHash),
|
|
33979
34476
|
expirySecs: expirySeconds,
|
|
33980
34477
|
memo: memo2,
|
|
33981
34478
|
includeSparkAddress,
|
|
@@ -34084,7 +34581,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34084
34581
|
const sparkFallbackAddress = decodedInvoice.fallbackAddress;
|
|
34085
34582
|
const paymentHash = decodedInvoice.paymentHash;
|
|
34086
34583
|
if (preferSpark) {
|
|
34087
|
-
if (sparkFallbackAddress === void 0 || isValidSparkFallback((0,
|
|
34584
|
+
if (sparkFallbackAddress === void 0 || isValidSparkFallback((0, import_utils24.hexToBytes)(sparkFallbackAddress)) === false) {
|
|
34088
34585
|
console.warn(
|
|
34089
34586
|
"No valid spark address found in invoice. Defaulting to lightning."
|
|
34090
34587
|
);
|
|
@@ -34138,10 +34635,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34138
34635
|
);
|
|
34139
34636
|
const swapResponse = await this.lightningService.swapNodesForPreimage({
|
|
34140
34637
|
leaves: leavesToSend,
|
|
34141
|
-
receiverIdentityPubkey: (0,
|
|
34638
|
+
receiverIdentityPubkey: (0, import_utils24.hexToBytes)(
|
|
34142
34639
|
this.config.getSspIdentityPublicKey()
|
|
34143
34640
|
),
|
|
34144
|
-
paymentHash: (0,
|
|
34641
|
+
paymentHash: (0, import_utils24.hexToBytes)(paymentHash),
|
|
34145
34642
|
isInboundPayment: false,
|
|
34146
34643
|
invoiceString: invoice,
|
|
34147
34644
|
feeSats: feeEstimate,
|
|
@@ -34259,7 +34756,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34259
34756
|
});
|
|
34260
34757
|
await this.syncTokenOutputs();
|
|
34261
34758
|
const bech32mTokenIdentifier = encodeBech32mTokenIdentifier({
|
|
34262
|
-
tokenIdentifier: (0,
|
|
34759
|
+
tokenIdentifier: (0, import_utils24.hexToBytes)(firstTokenIdentifierHexSeen),
|
|
34263
34760
|
network: this.config.getNetworkType()
|
|
34264
34761
|
});
|
|
34265
34762
|
const receiverOutputs = decoded.map((d) => ({
|
|
@@ -34447,11 +34944,11 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34447
34944
|
const connectorOutputs = [];
|
|
34448
34945
|
for (let i = 0; i < connectorTx.outputsLength - 1; i++) {
|
|
34449
34946
|
connectorOutputs.push({
|
|
34450
|
-
txid: (0,
|
|
34947
|
+
txid: (0, import_utils24.hexToBytes)(connectorTxId),
|
|
34451
34948
|
index: i
|
|
34452
34949
|
});
|
|
34453
34950
|
}
|
|
34454
|
-
const sspPubIdentityKey = (0,
|
|
34951
|
+
const sspPubIdentityKey = (0, import_utils24.hexToBytes)(this.config.getSspIdentityPublicKey());
|
|
34455
34952
|
const transfer = await this.coopExitService.getConnectorRefundSignatures({
|
|
34456
34953
|
leaves: leafKeyTweaks,
|
|
34457
34954
|
exitTxId: coopExitTxId,
|
|
@@ -34505,7 +35002,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34505
35002
|
return transfers?.[0];
|
|
34506
35003
|
}
|
|
34507
35004
|
async constructTransfersWithUserRequest(transfers) {
|
|
34508
|
-
const identityPublicKey = (0,
|
|
35005
|
+
const identityPublicKey = (0, import_utils24.bytesToHex)(
|
|
34509
35006
|
await this.config.signer.getIdentityPublicKey()
|
|
34510
35007
|
);
|
|
34511
35008
|
const userRequests = await this.sspClient?.getTransfers(
|
|
@@ -34749,7 +35246,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34749
35246
|
hash,
|
|
34750
35247
|
compact
|
|
34751
35248
|
);
|
|
34752
|
-
return (0,
|
|
35249
|
+
return (0, import_utils24.bytesToHex)(signature);
|
|
34753
35250
|
}
|
|
34754
35251
|
/**
|
|
34755
35252
|
* Validates a message with the identity key.
|
|
@@ -34761,7 +35258,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34761
35258
|
async validateMessageWithIdentityKey(message, signature) {
|
|
34762
35259
|
const hash = (0, import_sha213.sha256)(message);
|
|
34763
35260
|
if (typeof signature === "string") {
|
|
34764
|
-
signature = (0,
|
|
35261
|
+
signature = (0, import_utils24.hexToBytes)(signature);
|
|
34765
35262
|
}
|
|
34766
35263
|
return this.config.signer.validateMessageWithIdentityKey(hash, signature);
|
|
34767
35264
|
}
|
|
@@ -34774,7 +35271,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34774
35271
|
*/
|
|
34775
35272
|
async signTransaction(txHex, keyType = "auto-detect") {
|
|
34776
35273
|
try {
|
|
34777
|
-
const tx = import_btc_signer6.Transaction.fromRaw((0,
|
|
35274
|
+
const tx = import_btc_signer6.Transaction.fromRaw((0, import_utils24.hexToBytes)(txHex));
|
|
34778
35275
|
let publicKey;
|
|
34779
35276
|
switch (keyType.toLowerCase()) {
|
|
34780
35277
|
case "identity":
|
|
@@ -34807,7 +35304,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34807
35304
|
publicKey,
|
|
34808
35305
|
this.config.getNetwork()
|
|
34809
35306
|
);
|
|
34810
|
-
if ((0,
|
|
35307
|
+
if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(identityScript)) {
|
|
34811
35308
|
try {
|
|
34812
35309
|
this.config.signer.signTransactionIndex(tx, i, publicKey);
|
|
34813
35310
|
inputsSigned++;
|
|
@@ -34851,13 +35348,13 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34851
35348
|
depositPubKey,
|
|
34852
35349
|
this.config.getNetwork()
|
|
34853
35350
|
);
|
|
34854
|
-
if ((0,
|
|
35351
|
+
if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(identityScript)) {
|
|
34855
35352
|
return {
|
|
34856
35353
|
publicKey: identityPubKey,
|
|
34857
35354
|
keyType: "identity"
|
|
34858
35355
|
};
|
|
34859
35356
|
}
|
|
34860
|
-
if ((0,
|
|
35357
|
+
if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(depositScript)) {
|
|
34861
35358
|
return {
|
|
34862
35359
|
publicKey: depositPubKey,
|
|
34863
35360
|
keyType: "deposit"
|