@buildonspark/spark-sdk 0.2.11 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/bare/index.cjs +761 -243
- package/dist/bare/index.d.cts +70 -11
- package/dist/bare/index.d.ts +70 -11
- package/dist/bare/index.js +684 -170
- package/dist/{chunk-A5M55UR3.js → chunk-5VWGOHED.js} +499 -8
- package/dist/{chunk-3WBPICWC.js → chunk-CKHJFQUA.js} +1 -1
- package/dist/{chunk-QNYJGFPD.js → chunk-LX45BCZW.js} +207 -160
- 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 +761 -243
- 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 +783 -265
- 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 +783 -265
- 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-BOAzMqpM.d.cts → logging-BfTyKwqb.d.cts} +3 -3
- package/dist/{logging-Bt_WdZbu.d.ts → logging-CaNpBgiE.d.ts} +3 -3
- package/dist/native/index.cjs +782 -264
- package/dist/native/index.d.cts +70 -11
- package/dist/native/index.d.ts +70 -11
- package/dist/native/index.js +686 -172
- 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-Cp3yv6cK.d.ts → spark-wallet-D0Df_P_x.d.ts} +26 -13
- package/dist/{spark-wallet-yc2KhsVY.d.cts → spark-wallet-Dvh1BLP6.d.cts} +26 -13
- package/dist/{spark-wallet.node-D0Qw5Wb4.d.cts → spark-wallet.node-B3V8_fgw.d.cts} +1 -1
- package/dist/{spark-wallet.node-D4IovOHu.d.ts → spark-wallet.node-bGmy8-T8.d.ts} +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-D1ta-sHH.d.cts} +2 -2
- package/dist/{token-transactions-0nmR9mQO.d.ts → token-transactions-DINiKBzd.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 +3 -3
- 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 -28
- package/src/signer/signer.ts +2 -2
- package/src/spark-wallet/proto-descriptors.ts +22 -0
- package/src/spark-wallet/proto-hash.ts +743 -0
- package/src/spark-wallet/proto-reflection.ts +193 -0
- package/src/spark-wallet/spark-wallet.ts +95 -57
- package/src/spark_descriptors.pb +0 -0
- package/src/tests/address.test.ts +10 -10
- package/src/tests/bitcoin.test.ts +2 -2
- package/src/tests/bufbuild-reflection.test.ts +151 -0
- package/src/tests/cross-language-hash.test.ts +79 -0
- package/src/tests/integration/address.test.ts +3 -12
- 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 +128 -1
- package/src/tests/integration/static_deposit.test.ts +26 -0
- package/src/tests/integration/swap.test.ts +1 -1
- package/src/tests/integration/transfer.test.ts +1 -129
- 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.node.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
|
}
|
|
@@ -1618,8 +1618,8 @@ init_buffer();
|
|
|
1618
1618
|
// src/utils/address.ts
|
|
1619
1619
|
init_buffer();
|
|
1620
1620
|
var import_wire5 = require("@bufbuild/protobuf/wire");
|
|
1621
|
-
var import_utils2 = require("@noble/curves/abstract/utils");
|
|
1622
1621
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
|
1622
|
+
var import_utils2 = require("@noble/curves/utils");
|
|
1623
1623
|
var import_utils3 = require("@noble/hashes/utils");
|
|
1624
1624
|
var import_base2 = require("@scure/base");
|
|
1625
1625
|
var import_uuidv7 = require("uuidv7");
|
|
@@ -2187,6 +2187,41 @@ function utxoSwapRequestTypeToJSON(object) {
|
|
|
2187
2187
|
return "UNRECOGNIZED";
|
|
2188
2188
|
}
|
|
2189
2189
|
}
|
|
2190
|
+
function invoiceStatusFromJSON(object) {
|
|
2191
|
+
switch (object) {
|
|
2192
|
+
case 0:
|
|
2193
|
+
case "NOT_FOUND":
|
|
2194
|
+
return 0 /* NOT_FOUND */;
|
|
2195
|
+
case 1:
|
|
2196
|
+
case "PENDING":
|
|
2197
|
+
return 1 /* PENDING */;
|
|
2198
|
+
case 2:
|
|
2199
|
+
case "FINALIZED":
|
|
2200
|
+
return 2 /* FINALIZED */;
|
|
2201
|
+
case 3:
|
|
2202
|
+
case "EXPIRED":
|
|
2203
|
+
return 3 /* EXPIRED */;
|
|
2204
|
+
case -1:
|
|
2205
|
+
case "UNRECOGNIZED":
|
|
2206
|
+
default:
|
|
2207
|
+
return -1 /* UNRECOGNIZED */;
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
function invoiceStatusToJSON(object) {
|
|
2211
|
+
switch (object) {
|
|
2212
|
+
case 0 /* NOT_FOUND */:
|
|
2213
|
+
return "NOT_FOUND";
|
|
2214
|
+
case 1 /* PENDING */:
|
|
2215
|
+
return "PENDING";
|
|
2216
|
+
case 2 /* FINALIZED */:
|
|
2217
|
+
return "FINALIZED";
|
|
2218
|
+
case 3 /* EXPIRED */:
|
|
2219
|
+
return "EXPIRED";
|
|
2220
|
+
case -1 /* UNRECOGNIZED */:
|
|
2221
|
+
default:
|
|
2222
|
+
return "UNRECOGNIZED";
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2190
2225
|
function initiatePreimageSwapRequest_ReasonFromJSON(object) {
|
|
2191
2226
|
switch (object) {
|
|
2192
2227
|
case 0:
|
|
@@ -2926,6 +2961,140 @@ var GenerateDepositAddressResponse = {
|
|
|
2926
2961
|
return message;
|
|
2927
2962
|
}
|
|
2928
2963
|
};
|
|
2964
|
+
function createBaseGenerateStaticDepositAddressRequest() {
|
|
2965
|
+
return { signingPublicKey: new Uint8Array(0), identityPublicKey: new Uint8Array(0), network: 0 };
|
|
2966
|
+
}
|
|
2967
|
+
var GenerateStaticDepositAddressRequest = {
|
|
2968
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
2969
|
+
if (message.signingPublicKey.length !== 0) {
|
|
2970
|
+
writer.uint32(10).bytes(message.signingPublicKey);
|
|
2971
|
+
}
|
|
2972
|
+
if (message.identityPublicKey.length !== 0) {
|
|
2973
|
+
writer.uint32(18).bytes(message.identityPublicKey);
|
|
2974
|
+
}
|
|
2975
|
+
if (message.network !== 0) {
|
|
2976
|
+
writer.uint32(24).int32(message.network);
|
|
2977
|
+
}
|
|
2978
|
+
return writer;
|
|
2979
|
+
},
|
|
2980
|
+
decode(input, length) {
|
|
2981
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
2982
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
2983
|
+
const message = createBaseGenerateStaticDepositAddressRequest();
|
|
2984
|
+
while (reader.pos < end) {
|
|
2985
|
+
const tag = reader.uint32();
|
|
2986
|
+
switch (tag >>> 3) {
|
|
2987
|
+
case 1: {
|
|
2988
|
+
if (tag !== 10) {
|
|
2989
|
+
break;
|
|
2990
|
+
}
|
|
2991
|
+
message.signingPublicKey = reader.bytes();
|
|
2992
|
+
continue;
|
|
2993
|
+
}
|
|
2994
|
+
case 2: {
|
|
2995
|
+
if (tag !== 18) {
|
|
2996
|
+
break;
|
|
2997
|
+
}
|
|
2998
|
+
message.identityPublicKey = reader.bytes();
|
|
2999
|
+
continue;
|
|
3000
|
+
}
|
|
3001
|
+
case 3: {
|
|
3002
|
+
if (tag !== 24) {
|
|
3003
|
+
break;
|
|
3004
|
+
}
|
|
3005
|
+
message.network = reader.int32();
|
|
3006
|
+
continue;
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
3009
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
3010
|
+
break;
|
|
3011
|
+
}
|
|
3012
|
+
reader.skip(tag & 7);
|
|
3013
|
+
}
|
|
3014
|
+
return message;
|
|
3015
|
+
},
|
|
3016
|
+
fromJSON(object) {
|
|
3017
|
+
return {
|
|
3018
|
+
signingPublicKey: isSet3(object.signingPublicKey) ? bytesFromBase642(object.signingPublicKey) : new Uint8Array(0),
|
|
3019
|
+
identityPublicKey: isSet3(object.identityPublicKey) ? bytesFromBase642(object.identityPublicKey) : new Uint8Array(0),
|
|
3020
|
+
network: isSet3(object.network) ? networkFromJSON(object.network) : 0
|
|
3021
|
+
};
|
|
3022
|
+
},
|
|
3023
|
+
toJSON(message) {
|
|
3024
|
+
const obj = {};
|
|
3025
|
+
if (message.signingPublicKey.length !== 0) {
|
|
3026
|
+
obj.signingPublicKey = base64FromBytes2(message.signingPublicKey);
|
|
3027
|
+
}
|
|
3028
|
+
if (message.identityPublicKey.length !== 0) {
|
|
3029
|
+
obj.identityPublicKey = base64FromBytes2(message.identityPublicKey);
|
|
3030
|
+
}
|
|
3031
|
+
if (message.network !== 0) {
|
|
3032
|
+
obj.network = networkToJSON(message.network);
|
|
3033
|
+
}
|
|
3034
|
+
return obj;
|
|
3035
|
+
},
|
|
3036
|
+
create(base) {
|
|
3037
|
+
return GenerateStaticDepositAddressRequest.fromPartial(base ?? {});
|
|
3038
|
+
},
|
|
3039
|
+
fromPartial(object) {
|
|
3040
|
+
const message = createBaseGenerateStaticDepositAddressRequest();
|
|
3041
|
+
message.signingPublicKey = object.signingPublicKey ?? new Uint8Array(0);
|
|
3042
|
+
message.identityPublicKey = object.identityPublicKey ?? new Uint8Array(0);
|
|
3043
|
+
message.network = object.network ?? 0;
|
|
3044
|
+
return message;
|
|
3045
|
+
}
|
|
3046
|
+
};
|
|
3047
|
+
function createBaseGenerateStaticDepositAddressResponse() {
|
|
3048
|
+
return { depositAddress: void 0 };
|
|
3049
|
+
}
|
|
3050
|
+
var GenerateStaticDepositAddressResponse = {
|
|
3051
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
3052
|
+
if (message.depositAddress !== void 0) {
|
|
3053
|
+
Address.encode(message.depositAddress, writer.uint32(10).fork()).join();
|
|
3054
|
+
}
|
|
3055
|
+
return writer;
|
|
3056
|
+
},
|
|
3057
|
+
decode(input, length) {
|
|
3058
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
3059
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
3060
|
+
const message = createBaseGenerateStaticDepositAddressResponse();
|
|
3061
|
+
while (reader.pos < end) {
|
|
3062
|
+
const tag = reader.uint32();
|
|
3063
|
+
switch (tag >>> 3) {
|
|
3064
|
+
case 1: {
|
|
3065
|
+
if (tag !== 10) {
|
|
3066
|
+
break;
|
|
3067
|
+
}
|
|
3068
|
+
message.depositAddress = Address.decode(reader, reader.uint32());
|
|
3069
|
+
continue;
|
|
3070
|
+
}
|
|
3071
|
+
}
|
|
3072
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
3073
|
+
break;
|
|
3074
|
+
}
|
|
3075
|
+
reader.skip(tag & 7);
|
|
3076
|
+
}
|
|
3077
|
+
return message;
|
|
3078
|
+
},
|
|
3079
|
+
fromJSON(object) {
|
|
3080
|
+
return { depositAddress: isSet3(object.depositAddress) ? Address.fromJSON(object.depositAddress) : void 0 };
|
|
3081
|
+
},
|
|
3082
|
+
toJSON(message) {
|
|
3083
|
+
const obj = {};
|
|
3084
|
+
if (message.depositAddress !== void 0) {
|
|
3085
|
+
obj.depositAddress = Address.toJSON(message.depositAddress);
|
|
3086
|
+
}
|
|
3087
|
+
return obj;
|
|
3088
|
+
},
|
|
3089
|
+
create(base) {
|
|
3090
|
+
return GenerateStaticDepositAddressResponse.fromPartial(base ?? {});
|
|
3091
|
+
},
|
|
3092
|
+
fromPartial(object) {
|
|
3093
|
+
const message = createBaseGenerateStaticDepositAddressResponse();
|
|
3094
|
+
message.depositAddress = object.depositAddress !== void 0 && object.depositAddress !== null ? Address.fromPartial(object.depositAddress) : void 0;
|
|
3095
|
+
return message;
|
|
3096
|
+
}
|
|
3097
|
+
};
|
|
2929
3098
|
function createBaseUTXO() {
|
|
2930
3099
|
return { rawTx: new Uint8Array(0), vout: 0, network: 0, txid: new Uint8Array(0) };
|
|
2931
3100
|
}
|
|
@@ -9039,7 +9208,8 @@ function createBaseTransferLeaf() {
|
|
|
9039
9208
|
signature: new Uint8Array(0),
|
|
9040
9209
|
intermediateRefundTx: new Uint8Array(0),
|
|
9041
9210
|
intermediateDirectRefundTx: new Uint8Array(0),
|
|
9042
|
-
intermediateDirectFromCpfpRefundTx: new Uint8Array(0)
|
|
9211
|
+
intermediateDirectFromCpfpRefundTx: new Uint8Array(0),
|
|
9212
|
+
pendingKeyTweakPublicKey: new Uint8Array(0)
|
|
9043
9213
|
};
|
|
9044
9214
|
}
|
|
9045
9215
|
var TransferLeaf = {
|
|
@@ -9062,6 +9232,9 @@ var TransferLeaf = {
|
|
|
9062
9232
|
if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
|
|
9063
9233
|
writer.uint32(50).bytes(message.intermediateDirectFromCpfpRefundTx);
|
|
9064
9234
|
}
|
|
9235
|
+
if (message.pendingKeyTweakPublicKey.length !== 0) {
|
|
9236
|
+
writer.uint32(58).bytes(message.pendingKeyTweakPublicKey);
|
|
9237
|
+
}
|
|
9065
9238
|
return writer;
|
|
9066
9239
|
},
|
|
9067
9240
|
decode(input, length) {
|
|
@@ -9113,6 +9286,13 @@ var TransferLeaf = {
|
|
|
9113
9286
|
message.intermediateDirectFromCpfpRefundTx = reader.bytes();
|
|
9114
9287
|
continue;
|
|
9115
9288
|
}
|
|
9289
|
+
case 7: {
|
|
9290
|
+
if (tag !== 58) {
|
|
9291
|
+
break;
|
|
9292
|
+
}
|
|
9293
|
+
message.pendingKeyTweakPublicKey = reader.bytes();
|
|
9294
|
+
continue;
|
|
9295
|
+
}
|
|
9116
9296
|
}
|
|
9117
9297
|
if ((tag & 7) === 4 || tag === 0) {
|
|
9118
9298
|
break;
|
|
@@ -9128,7 +9308,8 @@ var TransferLeaf = {
|
|
|
9128
9308
|
signature: isSet3(object.signature) ? bytesFromBase642(object.signature) : new Uint8Array(0),
|
|
9129
9309
|
intermediateRefundTx: isSet3(object.intermediateRefundTx) ? bytesFromBase642(object.intermediateRefundTx) : new Uint8Array(0),
|
|
9130
9310
|
intermediateDirectRefundTx: isSet3(object.intermediateDirectRefundTx) ? bytesFromBase642(object.intermediateDirectRefundTx) : new Uint8Array(0),
|
|
9131
|
-
intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0)
|
|
9311
|
+
intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0),
|
|
9312
|
+
pendingKeyTweakPublicKey: isSet3(object.pendingKeyTweakPublicKey) ? bytesFromBase642(object.pendingKeyTweakPublicKey) : new Uint8Array(0)
|
|
9132
9313
|
};
|
|
9133
9314
|
},
|
|
9134
9315
|
toJSON(message) {
|
|
@@ -9151,6 +9332,9 @@ var TransferLeaf = {
|
|
|
9151
9332
|
if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
|
|
9152
9333
|
obj.intermediateDirectFromCpfpRefundTx = base64FromBytes2(message.intermediateDirectFromCpfpRefundTx);
|
|
9153
9334
|
}
|
|
9335
|
+
if (message.pendingKeyTweakPublicKey.length !== 0) {
|
|
9336
|
+
obj.pendingKeyTweakPublicKey = base64FromBytes2(message.pendingKeyTweakPublicKey);
|
|
9337
|
+
}
|
|
9154
9338
|
return obj;
|
|
9155
9339
|
},
|
|
9156
9340
|
create(base) {
|
|
@@ -9164,6 +9348,7 @@ var TransferLeaf = {
|
|
|
9164
9348
|
message.intermediateRefundTx = object.intermediateRefundTx ?? new Uint8Array(0);
|
|
9165
9349
|
message.intermediateDirectRefundTx = object.intermediateDirectRefundTx ?? new Uint8Array(0);
|
|
9166
9350
|
message.intermediateDirectFromCpfpRefundTx = object.intermediateDirectFromCpfpRefundTx ?? new Uint8Array(0);
|
|
9351
|
+
message.pendingKeyTweakPublicKey = object.pendingKeyTweakPublicKey ?? new Uint8Array(0);
|
|
9167
9352
|
return message;
|
|
9168
9353
|
}
|
|
9169
9354
|
};
|
|
@@ -12061,13 +12246,16 @@ var QueryUserSignedRefundsRequest = {
|
|
|
12061
12246
|
}
|
|
12062
12247
|
};
|
|
12063
12248
|
function createBaseQueryUserSignedRefundsResponse() {
|
|
12064
|
-
return { userSignedRefunds: [] };
|
|
12249
|
+
return { userSignedRefunds: [], transfer: void 0 };
|
|
12065
12250
|
}
|
|
12066
12251
|
var QueryUserSignedRefundsResponse = {
|
|
12067
12252
|
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
12068
12253
|
for (const v of message.userSignedRefunds) {
|
|
12069
12254
|
UserSignedRefund.encode(v, writer.uint32(10).fork()).join();
|
|
12070
12255
|
}
|
|
12256
|
+
if (message.transfer !== void 0) {
|
|
12257
|
+
Transfer.encode(message.transfer, writer.uint32(26).fork()).join();
|
|
12258
|
+
}
|
|
12071
12259
|
return writer;
|
|
12072
12260
|
},
|
|
12073
12261
|
decode(input, length) {
|
|
@@ -12084,6 +12272,13 @@ var QueryUserSignedRefundsResponse = {
|
|
|
12084
12272
|
message.userSignedRefunds.push(UserSignedRefund.decode(reader, reader.uint32()));
|
|
12085
12273
|
continue;
|
|
12086
12274
|
}
|
|
12275
|
+
case 3: {
|
|
12276
|
+
if (tag !== 26) {
|
|
12277
|
+
break;
|
|
12278
|
+
}
|
|
12279
|
+
message.transfer = Transfer.decode(reader, reader.uint32());
|
|
12280
|
+
continue;
|
|
12281
|
+
}
|
|
12087
12282
|
}
|
|
12088
12283
|
if ((tag & 7) === 4 || tag === 0) {
|
|
12089
12284
|
break;
|
|
@@ -12094,7 +12289,8 @@ var QueryUserSignedRefundsResponse = {
|
|
|
12094
12289
|
},
|
|
12095
12290
|
fromJSON(object) {
|
|
12096
12291
|
return {
|
|
12097
|
-
userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : []
|
|
12292
|
+
userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : [],
|
|
12293
|
+
transfer: isSet3(object.transfer) ? Transfer.fromJSON(object.transfer) : void 0
|
|
12098
12294
|
};
|
|
12099
12295
|
},
|
|
12100
12296
|
toJSON(message) {
|
|
@@ -12102,6 +12298,9 @@ var QueryUserSignedRefundsResponse = {
|
|
|
12102
12298
|
if (message.userSignedRefunds?.length) {
|
|
12103
12299
|
obj.userSignedRefunds = message.userSignedRefunds.map((e) => UserSignedRefund.toJSON(e));
|
|
12104
12300
|
}
|
|
12301
|
+
if (message.transfer !== void 0) {
|
|
12302
|
+
obj.transfer = Transfer.toJSON(message.transfer);
|
|
12303
|
+
}
|
|
12105
12304
|
return obj;
|
|
12106
12305
|
},
|
|
12107
12306
|
create(base) {
|
|
@@ -12110,6 +12309,7 @@ var QueryUserSignedRefundsResponse = {
|
|
|
12110
12309
|
fromPartial(object) {
|
|
12111
12310
|
const message = createBaseQueryUserSignedRefundsResponse();
|
|
12112
12311
|
message.userSignedRefunds = object.userSignedRefunds?.map((e) => UserSignedRefund.fromPartial(e)) || [];
|
|
12312
|
+
message.transfer = object.transfer !== void 0 && object.transfer !== null ? Transfer.fromPartial(object.transfer) : void 0;
|
|
12113
12313
|
return message;
|
|
12114
12314
|
}
|
|
12115
12315
|
};
|
|
@@ -12996,7 +13196,8 @@ function createBaseDepositAddressQueryResult() {
|
|
|
12996
13196
|
depositAddress: "",
|
|
12997
13197
|
userSigningPublicKey: new Uint8Array(0),
|
|
12998
13198
|
verifyingPublicKey: new Uint8Array(0),
|
|
12999
|
-
leafId: void 0
|
|
13199
|
+
leafId: void 0,
|
|
13200
|
+
proofOfPossession: void 0
|
|
13000
13201
|
};
|
|
13001
13202
|
}
|
|
13002
13203
|
var DepositAddressQueryResult = {
|
|
@@ -13013,6 +13214,9 @@ var DepositAddressQueryResult = {
|
|
|
13013
13214
|
if (message.leafId !== void 0) {
|
|
13014
13215
|
writer.uint32(34).string(message.leafId);
|
|
13015
13216
|
}
|
|
13217
|
+
if (message.proofOfPossession !== void 0) {
|
|
13218
|
+
DepositAddressProof.encode(message.proofOfPossession, writer.uint32(42).fork()).join();
|
|
13219
|
+
}
|
|
13016
13220
|
return writer;
|
|
13017
13221
|
},
|
|
13018
13222
|
decode(input, length) {
|
|
@@ -13050,6 +13254,13 @@ var DepositAddressQueryResult = {
|
|
|
13050
13254
|
message.leafId = reader.string();
|
|
13051
13255
|
continue;
|
|
13052
13256
|
}
|
|
13257
|
+
case 5: {
|
|
13258
|
+
if (tag !== 42) {
|
|
13259
|
+
break;
|
|
13260
|
+
}
|
|
13261
|
+
message.proofOfPossession = DepositAddressProof.decode(reader, reader.uint32());
|
|
13262
|
+
continue;
|
|
13263
|
+
}
|
|
13053
13264
|
}
|
|
13054
13265
|
if ((tag & 7) === 4 || tag === 0) {
|
|
13055
13266
|
break;
|
|
@@ -13063,7 +13274,8 @@ var DepositAddressQueryResult = {
|
|
|
13063
13274
|
depositAddress: isSet3(object.depositAddress) ? globalThis.String(object.depositAddress) : "",
|
|
13064
13275
|
userSigningPublicKey: isSet3(object.userSigningPublicKey) ? bytesFromBase642(object.userSigningPublicKey) : new Uint8Array(0),
|
|
13065
13276
|
verifyingPublicKey: isSet3(object.verifyingPublicKey) ? bytesFromBase642(object.verifyingPublicKey) : new Uint8Array(0),
|
|
13066
|
-
leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0
|
|
13277
|
+
leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0,
|
|
13278
|
+
proofOfPossession: isSet3(object.proofOfPossession) ? DepositAddressProof.fromJSON(object.proofOfPossession) : void 0
|
|
13067
13279
|
};
|
|
13068
13280
|
},
|
|
13069
13281
|
toJSON(message) {
|
|
@@ -13080,6 +13292,9 @@ var DepositAddressQueryResult = {
|
|
|
13080
13292
|
if (message.leafId !== void 0) {
|
|
13081
13293
|
obj.leafId = message.leafId;
|
|
13082
13294
|
}
|
|
13295
|
+
if (message.proofOfPossession !== void 0) {
|
|
13296
|
+
obj.proofOfPossession = DepositAddressProof.toJSON(message.proofOfPossession);
|
|
13297
|
+
}
|
|
13083
13298
|
return obj;
|
|
13084
13299
|
},
|
|
13085
13300
|
create(base) {
|
|
@@ -13091,6 +13306,7 @@ var DepositAddressQueryResult = {
|
|
|
13091
13306
|
message.userSigningPublicKey = object.userSigningPublicKey ?? new Uint8Array(0);
|
|
13092
13307
|
message.verifyingPublicKey = object.verifyingPublicKey ?? new Uint8Array(0);
|
|
13093
13308
|
message.leafId = object.leafId ?? void 0;
|
|
13309
|
+
message.proofOfPossession = object.proofOfPossession !== void 0 && object.proofOfPossession !== null ? DepositAddressProof.fromPartial(object.proofOfPossession) : void 0;
|
|
13094
13310
|
return message;
|
|
13095
13311
|
}
|
|
13096
13312
|
};
|
|
@@ -15055,7 +15271,7 @@ var QueryNodesByValueResponse_NodesEntry = {
|
|
|
15055
15271
|
}
|
|
15056
15272
|
};
|
|
15057
15273
|
function createBaseGetUtxosForAddressRequest() {
|
|
15058
|
-
return { address: "", offset: 0, limit: 0, network: 0 };
|
|
15274
|
+
return { address: "", offset: 0, limit: 0, network: 0, excludeClaimed: false };
|
|
15059
15275
|
}
|
|
15060
15276
|
var GetUtxosForAddressRequest = {
|
|
15061
15277
|
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
@@ -15071,6 +15287,9 @@ var GetUtxosForAddressRequest = {
|
|
|
15071
15287
|
if (message.network !== 0) {
|
|
15072
15288
|
writer.uint32(32).int32(message.network);
|
|
15073
15289
|
}
|
|
15290
|
+
if (message.excludeClaimed !== false) {
|
|
15291
|
+
writer.uint32(40).bool(message.excludeClaimed);
|
|
15292
|
+
}
|
|
15074
15293
|
return writer;
|
|
15075
15294
|
},
|
|
15076
15295
|
decode(input, length) {
|
|
@@ -15108,6 +15327,13 @@ var GetUtxosForAddressRequest = {
|
|
|
15108
15327
|
message.network = reader.int32();
|
|
15109
15328
|
continue;
|
|
15110
15329
|
}
|
|
15330
|
+
case 5: {
|
|
15331
|
+
if (tag !== 40) {
|
|
15332
|
+
break;
|
|
15333
|
+
}
|
|
15334
|
+
message.excludeClaimed = reader.bool();
|
|
15335
|
+
continue;
|
|
15336
|
+
}
|
|
15111
15337
|
}
|
|
15112
15338
|
if ((tag & 7) === 4 || tag === 0) {
|
|
15113
15339
|
break;
|
|
@@ -15121,7 +15347,8 @@ var GetUtxosForAddressRequest = {
|
|
|
15121
15347
|
address: isSet3(object.address) ? globalThis.String(object.address) : "",
|
|
15122
15348
|
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
15123
15349
|
limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
|
|
15124
|
-
network: isSet3(object.network) ? networkFromJSON(object.network) : 0
|
|
15350
|
+
network: isSet3(object.network) ? networkFromJSON(object.network) : 0,
|
|
15351
|
+
excludeClaimed: isSet3(object.excludeClaimed) ? globalThis.Boolean(object.excludeClaimed) : false
|
|
15125
15352
|
};
|
|
15126
15353
|
},
|
|
15127
15354
|
toJSON(message) {
|
|
@@ -15138,6 +15365,9 @@ var GetUtxosForAddressRequest = {
|
|
|
15138
15365
|
if (message.network !== 0) {
|
|
15139
15366
|
obj.network = networkToJSON(message.network);
|
|
15140
15367
|
}
|
|
15368
|
+
if (message.excludeClaimed !== false) {
|
|
15369
|
+
obj.excludeClaimed = message.excludeClaimed;
|
|
15370
|
+
}
|
|
15141
15371
|
return obj;
|
|
15142
15372
|
},
|
|
15143
15373
|
create(base) {
|
|
@@ -15149,6 +15379,7 @@ var GetUtxosForAddressRequest = {
|
|
|
15149
15379
|
message.offset = object.offset ?? 0;
|
|
15150
15380
|
message.limit = object.limit ?? 0;
|
|
15151
15381
|
message.network = object.network ?? 0;
|
|
15382
|
+
message.excludeClaimed = object.excludeClaimed ?? false;
|
|
15152
15383
|
return message;
|
|
15153
15384
|
}
|
|
15154
15385
|
};
|
|
@@ -15220,6 +15451,225 @@ var GetUtxosForAddressResponse = {
|
|
|
15220
15451
|
return message;
|
|
15221
15452
|
}
|
|
15222
15453
|
};
|
|
15454
|
+
function createBaseQuerySparkInvoicesRequest() {
|
|
15455
|
+
return { limit: 0, offset: 0, invoice: [] };
|
|
15456
|
+
}
|
|
15457
|
+
var QuerySparkInvoicesRequest = {
|
|
15458
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
15459
|
+
if (message.limit !== 0) {
|
|
15460
|
+
writer.uint32(8).int64(message.limit);
|
|
15461
|
+
}
|
|
15462
|
+
if (message.offset !== 0) {
|
|
15463
|
+
writer.uint32(16).int64(message.offset);
|
|
15464
|
+
}
|
|
15465
|
+
for (const v of message.invoice) {
|
|
15466
|
+
writer.uint32(26).string(v);
|
|
15467
|
+
}
|
|
15468
|
+
return writer;
|
|
15469
|
+
},
|
|
15470
|
+
decode(input, length) {
|
|
15471
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
15472
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15473
|
+
const message = createBaseQuerySparkInvoicesRequest();
|
|
15474
|
+
while (reader.pos < end) {
|
|
15475
|
+
const tag = reader.uint32();
|
|
15476
|
+
switch (tag >>> 3) {
|
|
15477
|
+
case 1: {
|
|
15478
|
+
if (tag !== 8) {
|
|
15479
|
+
break;
|
|
15480
|
+
}
|
|
15481
|
+
message.limit = longToNumber2(reader.int64());
|
|
15482
|
+
continue;
|
|
15483
|
+
}
|
|
15484
|
+
case 2: {
|
|
15485
|
+
if (tag !== 16) {
|
|
15486
|
+
break;
|
|
15487
|
+
}
|
|
15488
|
+
message.offset = longToNumber2(reader.int64());
|
|
15489
|
+
continue;
|
|
15490
|
+
}
|
|
15491
|
+
case 3: {
|
|
15492
|
+
if (tag !== 26) {
|
|
15493
|
+
break;
|
|
15494
|
+
}
|
|
15495
|
+
message.invoice.push(reader.string());
|
|
15496
|
+
continue;
|
|
15497
|
+
}
|
|
15498
|
+
}
|
|
15499
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
15500
|
+
break;
|
|
15501
|
+
}
|
|
15502
|
+
reader.skip(tag & 7);
|
|
15503
|
+
}
|
|
15504
|
+
return message;
|
|
15505
|
+
},
|
|
15506
|
+
fromJSON(object) {
|
|
15507
|
+
return {
|
|
15508
|
+
limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
|
|
15509
|
+
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
15510
|
+
invoice: globalThis.Array.isArray(object?.invoice) ? object.invoice.map((e) => globalThis.String(e)) : []
|
|
15511
|
+
};
|
|
15512
|
+
},
|
|
15513
|
+
toJSON(message) {
|
|
15514
|
+
const obj = {};
|
|
15515
|
+
if (message.limit !== 0) {
|
|
15516
|
+
obj.limit = Math.round(message.limit);
|
|
15517
|
+
}
|
|
15518
|
+
if (message.offset !== 0) {
|
|
15519
|
+
obj.offset = Math.round(message.offset);
|
|
15520
|
+
}
|
|
15521
|
+
if (message.invoice?.length) {
|
|
15522
|
+
obj.invoice = message.invoice;
|
|
15523
|
+
}
|
|
15524
|
+
return obj;
|
|
15525
|
+
},
|
|
15526
|
+
create(base) {
|
|
15527
|
+
return QuerySparkInvoicesRequest.fromPartial(base ?? {});
|
|
15528
|
+
},
|
|
15529
|
+
fromPartial(object) {
|
|
15530
|
+
const message = createBaseQuerySparkInvoicesRequest();
|
|
15531
|
+
message.limit = object.limit ?? 0;
|
|
15532
|
+
message.offset = object.offset ?? 0;
|
|
15533
|
+
message.invoice = object.invoice?.map((e) => e) || [];
|
|
15534
|
+
return message;
|
|
15535
|
+
}
|
|
15536
|
+
};
|
|
15537
|
+
function createBaseQuerySparkInvoicesResponse() {
|
|
15538
|
+
return { offset: 0, invoiceStatuses: [] };
|
|
15539
|
+
}
|
|
15540
|
+
var QuerySparkInvoicesResponse = {
|
|
15541
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
15542
|
+
if (message.offset !== 0) {
|
|
15543
|
+
writer.uint32(8).int64(message.offset);
|
|
15544
|
+
}
|
|
15545
|
+
for (const v of message.invoiceStatuses) {
|
|
15546
|
+
InvoiceResponse.encode(v, writer.uint32(18).fork()).join();
|
|
15547
|
+
}
|
|
15548
|
+
return writer;
|
|
15549
|
+
},
|
|
15550
|
+
decode(input, length) {
|
|
15551
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
15552
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15553
|
+
const message = createBaseQuerySparkInvoicesResponse();
|
|
15554
|
+
while (reader.pos < end) {
|
|
15555
|
+
const tag = reader.uint32();
|
|
15556
|
+
switch (tag >>> 3) {
|
|
15557
|
+
case 1: {
|
|
15558
|
+
if (tag !== 8) {
|
|
15559
|
+
break;
|
|
15560
|
+
}
|
|
15561
|
+
message.offset = longToNumber2(reader.int64());
|
|
15562
|
+
continue;
|
|
15563
|
+
}
|
|
15564
|
+
case 2: {
|
|
15565
|
+
if (tag !== 18) {
|
|
15566
|
+
break;
|
|
15567
|
+
}
|
|
15568
|
+
message.invoiceStatuses.push(InvoiceResponse.decode(reader, reader.uint32()));
|
|
15569
|
+
continue;
|
|
15570
|
+
}
|
|
15571
|
+
}
|
|
15572
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
15573
|
+
break;
|
|
15574
|
+
}
|
|
15575
|
+
reader.skip(tag & 7);
|
|
15576
|
+
}
|
|
15577
|
+
return message;
|
|
15578
|
+
},
|
|
15579
|
+
fromJSON(object) {
|
|
15580
|
+
return {
|
|
15581
|
+
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
15582
|
+
invoiceStatuses: globalThis.Array.isArray(object?.invoiceStatuses) ? object.invoiceStatuses.map((e) => InvoiceResponse.fromJSON(e)) : []
|
|
15583
|
+
};
|
|
15584
|
+
},
|
|
15585
|
+
toJSON(message) {
|
|
15586
|
+
const obj = {};
|
|
15587
|
+
if (message.offset !== 0) {
|
|
15588
|
+
obj.offset = Math.round(message.offset);
|
|
15589
|
+
}
|
|
15590
|
+
if (message.invoiceStatuses?.length) {
|
|
15591
|
+
obj.invoiceStatuses = message.invoiceStatuses.map((e) => InvoiceResponse.toJSON(e));
|
|
15592
|
+
}
|
|
15593
|
+
return obj;
|
|
15594
|
+
},
|
|
15595
|
+
create(base) {
|
|
15596
|
+
return QuerySparkInvoicesResponse.fromPartial(base ?? {});
|
|
15597
|
+
},
|
|
15598
|
+
fromPartial(object) {
|
|
15599
|
+
const message = createBaseQuerySparkInvoicesResponse();
|
|
15600
|
+
message.offset = object.offset ?? 0;
|
|
15601
|
+
message.invoiceStatuses = object.invoiceStatuses?.map((e) => InvoiceResponse.fromPartial(e)) || [];
|
|
15602
|
+
return message;
|
|
15603
|
+
}
|
|
15604
|
+
};
|
|
15605
|
+
function createBaseInvoiceResponse() {
|
|
15606
|
+
return { invoice: "", status: 0 };
|
|
15607
|
+
}
|
|
15608
|
+
var InvoiceResponse = {
|
|
15609
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
15610
|
+
if (message.invoice !== "") {
|
|
15611
|
+
writer.uint32(10).string(message.invoice);
|
|
15612
|
+
}
|
|
15613
|
+
if (message.status !== 0) {
|
|
15614
|
+
writer.uint32(16).int32(message.status);
|
|
15615
|
+
}
|
|
15616
|
+
return writer;
|
|
15617
|
+
},
|
|
15618
|
+
decode(input, length) {
|
|
15619
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
15620
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15621
|
+
const message = createBaseInvoiceResponse();
|
|
15622
|
+
while (reader.pos < end) {
|
|
15623
|
+
const tag = reader.uint32();
|
|
15624
|
+
switch (tag >>> 3) {
|
|
15625
|
+
case 1: {
|
|
15626
|
+
if (tag !== 10) {
|
|
15627
|
+
break;
|
|
15628
|
+
}
|
|
15629
|
+
message.invoice = reader.string();
|
|
15630
|
+
continue;
|
|
15631
|
+
}
|
|
15632
|
+
case 2: {
|
|
15633
|
+
if (tag !== 16) {
|
|
15634
|
+
break;
|
|
15635
|
+
}
|
|
15636
|
+
message.status = reader.int32();
|
|
15637
|
+
continue;
|
|
15638
|
+
}
|
|
15639
|
+
}
|
|
15640
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
15641
|
+
break;
|
|
15642
|
+
}
|
|
15643
|
+
reader.skip(tag & 7);
|
|
15644
|
+
}
|
|
15645
|
+
return message;
|
|
15646
|
+
},
|
|
15647
|
+
fromJSON(object) {
|
|
15648
|
+
return {
|
|
15649
|
+
invoice: isSet3(object.invoice) ? globalThis.String(object.invoice) : "",
|
|
15650
|
+
status: isSet3(object.status) ? invoiceStatusFromJSON(object.status) : 0
|
|
15651
|
+
};
|
|
15652
|
+
},
|
|
15653
|
+
toJSON(message) {
|
|
15654
|
+
const obj = {};
|
|
15655
|
+
if (message.invoice !== "") {
|
|
15656
|
+
obj.invoice = message.invoice;
|
|
15657
|
+
}
|
|
15658
|
+
if (message.status !== 0) {
|
|
15659
|
+
obj.status = invoiceStatusToJSON(message.status);
|
|
15660
|
+
}
|
|
15661
|
+
return obj;
|
|
15662
|
+
},
|
|
15663
|
+
create(base) {
|
|
15664
|
+
return InvoiceResponse.fromPartial(base ?? {});
|
|
15665
|
+
},
|
|
15666
|
+
fromPartial(object) {
|
|
15667
|
+
const message = createBaseInvoiceResponse();
|
|
15668
|
+
message.invoice = object.invoice ?? "";
|
|
15669
|
+
message.status = object.status ?? 0;
|
|
15670
|
+
return message;
|
|
15671
|
+
}
|
|
15672
|
+
};
|
|
15223
15673
|
var SparkServiceDefinition = {
|
|
15224
15674
|
name: "SparkService",
|
|
15225
15675
|
fullName: "spark.SparkService",
|
|
@@ -15232,6 +15682,15 @@ var SparkServiceDefinition = {
|
|
|
15232
15682
|
responseStream: false,
|
|
15233
15683
|
options: {}
|
|
15234
15684
|
},
|
|
15685
|
+
/** Generates a new static deposit address of the user or returns the existing one for the specified network. */
|
|
15686
|
+
generate_static_deposit_address: {
|
|
15687
|
+
name: "generate_static_deposit_address",
|
|
15688
|
+
requestType: GenerateStaticDepositAddressRequest,
|
|
15689
|
+
requestStream: false,
|
|
15690
|
+
responseType: GenerateStaticDepositAddressResponse,
|
|
15691
|
+
responseStream: false,
|
|
15692
|
+
options: {}
|
|
15693
|
+
},
|
|
15235
15694
|
start_deposit_tree_creation: {
|
|
15236
15695
|
name: "start_deposit_tree_creation",
|
|
15237
15696
|
requestType: StartDepositTreeCreationRequest,
|
|
@@ -15673,6 +16132,14 @@ var SparkServiceDefinition = {
|
|
|
15673
16132
|
responseType: GetUtxosForAddressResponse,
|
|
15674
16133
|
responseStream: false,
|
|
15675
16134
|
options: {}
|
|
16135
|
+
},
|
|
16136
|
+
query_spark_invoices: {
|
|
16137
|
+
name: "query_spark_invoices",
|
|
16138
|
+
requestType: QuerySparkInvoicesRequest,
|
|
16139
|
+
requestStream: false,
|
|
16140
|
+
responseType: QuerySparkInvoicesResponse,
|
|
16141
|
+
responseStream: false,
|
|
16142
|
+
options: {}
|
|
15676
16143
|
}
|
|
15677
16144
|
}
|
|
15678
16145
|
};
|
|
@@ -16262,8 +16729,8 @@ function encodeSparkInvoiceFieldsV1Canonical(f) {
|
|
|
16262
16729
|
// src/utils/adaptor-signature.ts
|
|
16263
16730
|
init_buffer();
|
|
16264
16731
|
var import_modular = require("@noble/curves/abstract/modular");
|
|
16265
|
-
var import_utils4 = require("@noble/curves/abstract/utils");
|
|
16266
16732
|
var import_secp256k12 = require("@noble/curves/secp256k1");
|
|
16733
|
+
var import_utils4 = require("@noble/curves/utils");
|
|
16267
16734
|
function generateSignatureFromExistingAdaptor(signature, adaptorPrivateKeyBytes) {
|
|
16268
16735
|
const { r, s } = parseSignature(signature);
|
|
16269
16736
|
const sBigInt = (0, import_utils4.bytesToNumberBE)(s);
|
|
@@ -16392,8 +16859,8 @@ function parseSignature(signature) {
|
|
|
16392
16859
|
|
|
16393
16860
|
// src/utils/bitcoin.ts
|
|
16394
16861
|
init_buffer();
|
|
16395
|
-
var import_utils5 = require("@noble/curves/abstract/utils");
|
|
16396
16862
|
var import_secp256k13 = require("@noble/curves/secp256k1");
|
|
16863
|
+
var import_utils5 = require("@noble/curves/utils");
|
|
16397
16864
|
var import_sha22 = require("@noble/hashes/sha2");
|
|
16398
16865
|
var btc2 = __toESM(require("@scure/btc-signer"), 1);
|
|
16399
16866
|
|
|
@@ -16638,8 +17105,8 @@ function getTxEstimatedVbytesSizeByNumberOfInputsOutputs(numInputs, numOutputs)
|
|
|
16638
17105
|
|
|
16639
17106
|
// src/utils/keys.ts
|
|
16640
17107
|
init_buffer();
|
|
16641
|
-
var import_utils6 = require("@noble/curves/abstract/utils");
|
|
16642
17108
|
var import_secp256k14 = require("@noble/curves/secp256k1");
|
|
17109
|
+
var import_utils6 = require("@noble/curves/utils");
|
|
16643
17110
|
function addPublicKeys(a, b) {
|
|
16644
17111
|
if (a.length !== 33 || b.length !== 33) {
|
|
16645
17112
|
throw new ValidationError("Public keys must be 33 bytes", {
|
|
@@ -17896,7 +18363,7 @@ fragment UserRequestFragment on UserRequest {
|
|
|
17896
18363
|
|
|
17897
18364
|
// src/types/sdk-types.ts
|
|
17898
18365
|
init_buffer();
|
|
17899
|
-
var import_utils7 = require("@noble/curves/
|
|
18366
|
+
var import_utils7 = require("@noble/curves/utils");
|
|
17900
18367
|
function mapTreeNodeToWalletLeaf(proto) {
|
|
17901
18368
|
return {
|
|
17902
18369
|
id: proto.id,
|
|
@@ -18047,8 +18514,8 @@ function collectResponses(responses) {
|
|
|
18047
18514
|
|
|
18048
18515
|
// src/utils/secret-sharing.ts
|
|
18049
18516
|
init_buffer();
|
|
18050
|
-
var import_utils8 = require("@noble/curves/abstract/utils");
|
|
18051
18517
|
var import_secp256k15 = require("@noble/curves/secp256k1");
|
|
18518
|
+
var import_utils8 = require("@noble/curves/utils");
|
|
18052
18519
|
function getRandomBigInt(max) {
|
|
18053
18520
|
const byteLength = max.toString(2).length + 7 >> 3;
|
|
18054
18521
|
const maxBigInt = max;
|
|
@@ -18433,8 +18900,7 @@ function getNetworkFromBech32mTokenIdentifier(bech32mTokenIdentifier) {
|
|
|
18433
18900
|
|
|
18434
18901
|
// src/utils/token-transactions.ts
|
|
18435
18902
|
init_buffer();
|
|
18436
|
-
var import_utils9 = require("@noble/curves/
|
|
18437
|
-
var import_utils10 = require("@scure/btc-signer/utils");
|
|
18903
|
+
var import_utils9 = require("@noble/curves/utils");
|
|
18438
18904
|
function sumAvailableTokens(outputs) {
|
|
18439
18905
|
try {
|
|
18440
18906
|
return outputs.reduce(
|
|
@@ -18469,7 +18935,7 @@ function filterTokenBalanceForTokenIdentifier(tokenBalances, tokenIdentifier) {
|
|
|
18469
18935
|
}
|
|
18470
18936
|
const tokenIdentifierBytes = decodeBech32mTokenIdentifier(tokenIdentifier).tokenIdentifier;
|
|
18471
18937
|
const tokenBalance = [...tokenBalances.entries()].find(
|
|
18472
|
-
([, info]) => (0,
|
|
18938
|
+
([, info]) => (0, import_utils9.equalBytes)(info.tokenMetadata.rawTokenIdentifier, tokenIdentifierBytes)
|
|
18473
18939
|
);
|
|
18474
18940
|
if (!tokenBalance) {
|
|
18475
18941
|
return {
|
|
@@ -18483,7 +18949,7 @@ function filterTokenBalanceForTokenIdentifier(tokenBalances, tokenIdentifier) {
|
|
|
18483
18949
|
|
|
18484
18950
|
// src/utils/transfer_package.ts
|
|
18485
18951
|
init_buffer();
|
|
18486
|
-
var
|
|
18952
|
+
var import_utils10 = require("@noble/curves/utils");
|
|
18487
18953
|
var import_sha24 = require("@noble/hashes/sha2");
|
|
18488
18954
|
function getTransferPackageSigningPayload(transferID, transferPackage) {
|
|
18489
18955
|
const encryptedPayload = transferPackage.keyTweakPackage;
|
|
@@ -18492,7 +18958,7 @@ function getTransferPackageSigningPayload(transferID, transferPackage) {
|
|
|
18492
18958
|
).map(([key, value]) => ({ key, value }));
|
|
18493
18959
|
pairs.sort((a, b) => a.key.localeCompare(b.key));
|
|
18494
18960
|
const encoder = new TextEncoder();
|
|
18495
|
-
let message = (0,
|
|
18961
|
+
let message = (0, import_utils10.hexToBytes)(transferID.replaceAll("-", ""));
|
|
18496
18962
|
for (const pair of pairs) {
|
|
18497
18963
|
const keyPart = encoder.encode(pair.key + ":");
|
|
18498
18964
|
const separator = encoder.encode(";");
|
|
@@ -18845,7 +19311,7 @@ function getEphemeralAnchorOutput() {
|
|
|
18845
19311
|
|
|
18846
19312
|
// src/utils/unilateral-exit.ts
|
|
18847
19313
|
init_buffer();
|
|
18848
|
-
var
|
|
19314
|
+
var import_utils11 = require("@noble/curves/utils");
|
|
18849
19315
|
var import_legacy = require("@noble/hashes/legacy");
|
|
18850
19316
|
var import_sha25 = require("@noble/hashes/sha2");
|
|
18851
19317
|
var btc3 = __toESM(require("@scure/btc-signer"), 1);
|
|
@@ -18860,7 +19326,7 @@ function isEphemeralAnchorOutput(script, amount) {
|
|
|
18860
19326
|
}
|
|
18861
19327
|
async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network) {
|
|
18862
19328
|
const result = [];
|
|
18863
|
-
const nodes = nodeHexStrings.map((hex) => TreeNode.decode((0,
|
|
19329
|
+
const nodes = nodeHexStrings.map((hex) => TreeNode.decode((0, import_utils11.hexToBytes)(hex)));
|
|
18864
19330
|
const nodeMap = /* @__PURE__ */ new Map();
|
|
18865
19331
|
for (const node of nodes) {
|
|
18866
19332
|
nodeMap.set(node.id, node);
|
|
@@ -18916,10 +19382,10 @@ async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network)
|
|
|
18916
19382
|
}
|
|
18917
19383
|
}
|
|
18918
19384
|
for (const chainNode of chain) {
|
|
18919
|
-
const nodeTx = (0,
|
|
19385
|
+
const nodeTx = (0, import_utils11.bytesToHex)(chainNode.nodeTx);
|
|
18920
19386
|
transactions.push(nodeTx);
|
|
18921
19387
|
if (chainNode.id === node.id) {
|
|
18922
|
-
const refundTx = (0,
|
|
19388
|
+
const refundTx = (0, import_utils11.bytesToHex)(chainNode.refundTx);
|
|
18923
19389
|
transactions.push(refundTx);
|
|
18924
19390
|
}
|
|
18925
19391
|
}
|
|
@@ -18949,7 +19415,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
18949
19415
|
`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.`
|
|
18950
19416
|
);
|
|
18951
19417
|
}
|
|
18952
|
-
const nodeBytes = (0,
|
|
19418
|
+
const nodeBytes = (0, import_utils11.hexToBytes)(hex);
|
|
18953
19419
|
const node = TreeNode.decode(nodeBytes);
|
|
18954
19420
|
if (!node.id) {
|
|
18955
19421
|
throw new Error(
|
|
@@ -19025,7 +19491,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
19025
19491
|
}
|
|
19026
19492
|
}
|
|
19027
19493
|
for (const chainNode of chain) {
|
|
19028
|
-
let nodeTxHex = (0,
|
|
19494
|
+
let nodeTxHex = (0, import_utils11.bytesToHex)(chainNode.nodeTx);
|
|
19029
19495
|
try {
|
|
19030
19496
|
const txObj = getTxFromRawTxHex(nodeTxHex);
|
|
19031
19497
|
const txid = getTxId(txObj);
|
|
@@ -19042,7 +19508,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
19042
19508
|
for (let i = txObj.outputsLength - 1; i >= 0; i--) {
|
|
19043
19509
|
const output = txObj.getOutput(i);
|
|
19044
19510
|
if (output?.amount === 0n && output.script) {
|
|
19045
|
-
anchorOutputScriptHex = (0,
|
|
19511
|
+
anchorOutputScriptHex = (0, import_utils11.bytesToHex)(output.script);
|
|
19046
19512
|
break;
|
|
19047
19513
|
}
|
|
19048
19514
|
}
|
|
@@ -19063,11 +19529,11 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
19063
19529
|
usedUtxos,
|
|
19064
19530
|
correctedParentTx
|
|
19065
19531
|
} = constructFeeBumpTx(nodeTxHex, availableUtxos, feeRate, void 0);
|
|
19066
|
-
const feeBumpTx = btc3.Transaction.fromPSBT((0,
|
|
19532
|
+
const feeBumpTx = btc3.Transaction.fromPSBT((0, import_utils11.hexToBytes)(nodeFeeBumpPsbt));
|
|
19067
19533
|
var feeBumpOut = feeBumpTx.outputsLength === 1 ? feeBumpTx.getOutput(0) : null;
|
|
19068
19534
|
var feeBumpOutPubKey = null;
|
|
19069
19535
|
for (const usedUtxo of usedUtxos) {
|
|
19070
|
-
if (feeBumpOut && (0,
|
|
19536
|
+
if (feeBumpOut && (0, import_utils11.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
|
|
19071
19537
|
feeBumpOutPubKey = usedUtxo.publicKey;
|
|
19072
19538
|
}
|
|
19073
19539
|
const index = availableUtxos.findIndex(
|
|
@@ -19082,20 +19548,20 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
19082
19548
|
txid: getTxId(feeBumpTx),
|
|
19083
19549
|
vout: 0,
|
|
19084
19550
|
value: feeBumpOut.amount,
|
|
19085
|
-
script: (0,
|
|
19551
|
+
script: (0, import_utils11.bytesToHex)(feeBumpOut.script),
|
|
19086
19552
|
publicKey: feeBumpOutPubKey
|
|
19087
19553
|
});
|
|
19088
19554
|
const finalNodeTx = correctedParentTx || nodeTxHex;
|
|
19089
19555
|
txPackages.push({ tx: finalNodeTx, feeBumpPsbt: nodeFeeBumpPsbt });
|
|
19090
19556
|
if (chainNode.id === node.id) {
|
|
19091
|
-
let refundTxHex = (0,
|
|
19557
|
+
let refundTxHex = (0, import_utils11.bytesToHex)(chainNode.refundTx);
|
|
19092
19558
|
try {
|
|
19093
19559
|
const txObj = getTxFromRawTxHex(refundTxHex);
|
|
19094
19560
|
let anchorOutputScriptHex;
|
|
19095
19561
|
for (let i = txObj.outputsLength - 1; i >= 0; i--) {
|
|
19096
19562
|
const output = txObj.getOutput(i);
|
|
19097
19563
|
if (output?.amount === 0n && output.script) {
|
|
19098
|
-
anchorOutputScriptHex = (0,
|
|
19564
|
+
anchorOutputScriptHex = (0, import_utils11.bytesToHex)(output.script);
|
|
19099
19565
|
break;
|
|
19100
19566
|
}
|
|
19101
19567
|
}
|
|
@@ -19118,12 +19584,12 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
19118
19584
|
void 0
|
|
19119
19585
|
);
|
|
19120
19586
|
const feeBumpTx2 = btc3.Transaction.fromPSBT(
|
|
19121
|
-
(0,
|
|
19587
|
+
(0, import_utils11.hexToBytes)(refundFeeBump.feeBumpPsbt)
|
|
19122
19588
|
);
|
|
19123
19589
|
var feeBumpOut = feeBumpTx2.outputsLength === 1 ? feeBumpTx2.getOutput(0) : null;
|
|
19124
19590
|
var feeBumpOutPubKey = null;
|
|
19125
19591
|
for (const usedUtxo of usedUtxos) {
|
|
19126
|
-
if (feeBumpOut && (0,
|
|
19592
|
+
if (feeBumpOut && (0, import_utils11.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
|
|
19127
19593
|
feeBumpOutPubKey = usedUtxo.publicKey;
|
|
19128
19594
|
}
|
|
19129
19595
|
const index = availableUtxos.findIndex(
|
|
@@ -19138,7 +19604,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
19138
19604
|
txid: getTxId(feeBumpTx2),
|
|
19139
19605
|
vout: 0,
|
|
19140
19606
|
value: feeBumpOut.amount,
|
|
19141
|
-
script: (0,
|
|
19607
|
+
script: (0, import_utils11.bytesToHex)(feeBumpOut.script),
|
|
19142
19608
|
publicKey: feeBumpOutPubKey
|
|
19143
19609
|
});
|
|
19144
19610
|
txPackages.push({
|
|
@@ -19233,10 +19699,10 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
|
|
|
19233
19699
|
if (!fundingUtxo) {
|
|
19234
19700
|
throw new Error(`UTXO at index ${i} is undefined`);
|
|
19235
19701
|
}
|
|
19236
|
-
const pubKeyHash = hash160((0,
|
|
19702
|
+
const pubKeyHash = hash160((0, import_utils11.hexToBytes)(fundingUtxo.publicKey));
|
|
19237
19703
|
const scriptToUse = new Uint8Array([0, 20, ...pubKeyHash]);
|
|
19238
|
-
const providedScript = (0,
|
|
19239
|
-
if ((0,
|
|
19704
|
+
const providedScript = (0, import_utils11.hexToBytes)(fundingUtxo.script);
|
|
19705
|
+
if ((0, import_utils11.bytesToHex)(scriptToUse) !== (0, import_utils11.bytesToHex)(providedScript)) {
|
|
19240
19706
|
throw new Error(
|
|
19241
19707
|
`\u274C Derived script doesn't match provided script for UTXO ${i + 1}.`
|
|
19242
19708
|
);
|
|
@@ -19301,7 +19767,7 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
|
|
|
19301
19767
|
}
|
|
19302
19768
|
let psbtHex;
|
|
19303
19769
|
try {
|
|
19304
|
-
psbtHex = (0,
|
|
19770
|
+
psbtHex = (0, import_utils11.bytesToHex)(builder.toPSBT());
|
|
19305
19771
|
} catch (error) {
|
|
19306
19772
|
throw new Error(`Failed to extract transaction: ${error}`);
|
|
19307
19773
|
}
|
|
@@ -19349,13 +19815,13 @@ init_logging();
|
|
|
19349
19815
|
// src/signer/signer.ts
|
|
19350
19816
|
init_buffer();
|
|
19351
19817
|
var import_secp256k17 = require("@bitcoinerlab/secp256k1");
|
|
19352
|
-
var import_utils14 = require("@noble/curves/abstract/utils");
|
|
19353
19818
|
var import_secp256k18 = require("@noble/curves/secp256k1");
|
|
19819
|
+
var import_utils13 = require("@noble/curves/utils");
|
|
19354
19820
|
var import_sha26 = require("@noble/hashes/sha2");
|
|
19355
19821
|
var import_bip32 = require("@scure/bip32");
|
|
19356
19822
|
var import_bip39 = require("@scure/bip39");
|
|
19357
19823
|
var import_english = require("@scure/bip39/wordlists/english");
|
|
19358
|
-
var
|
|
19824
|
+
var import_utils14 = require("@scure/btc-signer/utils");
|
|
19359
19825
|
var ecies = __toESM(require("eciesjs"), 1);
|
|
19360
19826
|
|
|
19361
19827
|
// src/constants.ts
|
|
@@ -19363,7 +19829,7 @@ init_buffer();
|
|
|
19363
19829
|
var import_core9 = require("@lightsparkdev/core");
|
|
19364
19830
|
var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
19365
19831
|
var isBun = globalThis.Bun !== void 0;
|
|
19366
|
-
var packageVersion = true ? "0.2.
|
|
19832
|
+
var packageVersion = true ? "0.2.13" : "unknown";
|
|
19367
19833
|
var baseEnvStr = "unknown";
|
|
19368
19834
|
if (isBun) {
|
|
19369
19835
|
const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
|
|
@@ -19461,7 +19927,7 @@ var TaprootOutputKeysGenerator = class {
|
|
|
19461
19927
|
}
|
|
19462
19928
|
const derivationPath = this.useAddressIndex ? `m/86'/0'/0'/0/${accountNumber}` : `m/86'/0'/${accountNumber}'/0/0`;
|
|
19463
19929
|
const taprootInternalKey = hdkey.derive(derivationPath);
|
|
19464
|
-
let tweakedPrivateKey = (0,
|
|
19930
|
+
let tweakedPrivateKey = (0, import_utils14.taprootTweakPrivKey)(taprootInternalKey.privateKey);
|
|
19465
19931
|
let tweakedPublicKey = import_secp256k18.secp256k1.getPublicKey(tweakedPrivateKey);
|
|
19466
19932
|
if (tweakedPublicKey[0] === 3) {
|
|
19467
19933
|
tweakedPrivateKey = (0, import_secp256k17.privateNegate)(tweakedPrivateKey);
|
|
@@ -19539,7 +20005,7 @@ var DefaultSparkSigner = class {
|
|
|
19539
20005
|
});
|
|
19540
20006
|
}
|
|
19541
20007
|
const receiverEciesPrivKey = ecies.PrivateKey.fromHex(
|
|
19542
|
-
(0,
|
|
20008
|
+
(0, import_utils13.bytesToHex)(this.identityKey.privateKey)
|
|
19543
20009
|
);
|
|
19544
20010
|
const privateKey = ecies.decrypt(receiverEciesPrivKey.toHex(), ciphertext);
|
|
19545
20011
|
return privateKey;
|
|
@@ -19673,7 +20139,7 @@ var DefaultSparkSigner = class {
|
|
|
19673
20139
|
threshold,
|
|
19674
20140
|
numShares
|
|
19675
20141
|
}) {
|
|
19676
|
-
const secretAsInt = (0,
|
|
20142
|
+
const secretAsInt = (0, import_utils13.bytesToNumberBE)(secret);
|
|
19677
20143
|
return splitSecretWithProofs(secretAsInt, curveOrder, threshold, numShares);
|
|
19678
20144
|
}
|
|
19679
20145
|
async signFrost({
|
|
@@ -19709,7 +20175,7 @@ var DefaultSparkSigner = class {
|
|
|
19709
20175
|
publicKey,
|
|
19710
20176
|
verifyingKey
|
|
19711
20177
|
};
|
|
19712
|
-
const logMessage = (0,
|
|
20178
|
+
const logMessage = (0, import_utils13.bytesToHex)(message);
|
|
19713
20179
|
const result = await SparkFrost.signFrost({
|
|
19714
20180
|
message,
|
|
19715
20181
|
keyPackage,
|
|
@@ -19751,7 +20217,7 @@ var DefaultSparkSigner = class {
|
|
|
19751
20217
|
}
|
|
19752
20218
|
async createSparkWalletFromSeed(seed, accountNumber) {
|
|
19753
20219
|
if (typeof seed === "string") {
|
|
19754
|
-
seed = (0,
|
|
20220
|
+
seed = (0, import_utils13.hexToBytes)(seed);
|
|
19755
20221
|
}
|
|
19756
20222
|
const {
|
|
19757
20223
|
identityKey,
|
|
@@ -19763,7 +20229,7 @@ var DefaultSparkSigner = class {
|
|
|
19763
20229
|
this.depositKey = depositKey;
|
|
19764
20230
|
this.signingKey = signingKey.hdKey;
|
|
19765
20231
|
this.staticDepositKey = staticDepositKey.hdKey;
|
|
19766
|
-
return (0,
|
|
20232
|
+
return (0, import_utils13.bytesToHex)(identityKey.publicKey);
|
|
19767
20233
|
}
|
|
19768
20234
|
async signMessageWithIdentityKey(message, compact) {
|
|
19769
20235
|
if (!this.identityKey?.privateKey) {
|
|
@@ -19784,7 +20250,7 @@ var DefaultSparkSigner = class {
|
|
|
19784
20250
|
});
|
|
19785
20251
|
}
|
|
19786
20252
|
const receiverEciesPrivKey = ecies.PrivateKey.fromHex(
|
|
19787
|
-
(0,
|
|
20253
|
+
(0, import_utils13.bytesToHex)(this.identityKey.privateKey)
|
|
19788
20254
|
);
|
|
19789
20255
|
const privateKey = ecies.decrypt(receiverEciesPrivKey.toHex(), ciphertext);
|
|
19790
20256
|
const publicKey = import_secp256k18.secp256k1.getPublicKey(privateKey);
|
|
@@ -19808,15 +20274,15 @@ var DefaultSparkSigner = class {
|
|
|
19808
20274
|
}
|
|
19809
20275
|
signTransactionIndex(tx, index, publicKey) {
|
|
19810
20276
|
let privateKey;
|
|
19811
|
-
if ((0,
|
|
20277
|
+
if ((0, import_utils13.equalBytes)(publicKey, this.identityKey?.publicKey ?? new Uint8Array())) {
|
|
19812
20278
|
privateKey = this.identityKey?.privateKey;
|
|
19813
|
-
} else if ((0,
|
|
20279
|
+
} else if ((0, import_utils13.equalBytes)(publicKey, this.depositKey?.publicKey ?? new Uint8Array())) {
|
|
19814
20280
|
privateKey = this.depositKey?.privateKey;
|
|
19815
20281
|
}
|
|
19816
20282
|
if (!privateKey) {
|
|
19817
20283
|
throw new ValidationError("Private key not found for public key", {
|
|
19818
20284
|
field: "privateKey",
|
|
19819
|
-
value: (0,
|
|
20285
|
+
value: (0, import_utils13.bytesToHex)(publicKey)
|
|
19820
20286
|
});
|
|
19821
20287
|
}
|
|
19822
20288
|
tx.signIdx(privateKey, index);
|
|
@@ -19894,8 +20360,8 @@ init_buffer();
|
|
|
19894
20360
|
// src/spark-wallet/spark-wallet.ts
|
|
19895
20361
|
init_buffer();
|
|
19896
20362
|
var import_core13 = require("@lightsparkdev/core");
|
|
19897
|
-
var import_utils25 = require("@noble/curves/abstract/utils");
|
|
19898
20363
|
var import_secp256k115 = require("@noble/curves/secp256k1");
|
|
20364
|
+
var import_utils24 = require("@noble/curves/utils");
|
|
19899
20365
|
var import_bip392 = require("@scure/bip39");
|
|
19900
20366
|
var import_english2 = require("@scure/bip39/wordlists/english");
|
|
19901
20367
|
var import_btc_signer6 = require("@scure/btc-signer");
|
|
@@ -25261,8 +25727,8 @@ var import_uuidv73 = require("uuidv7");
|
|
|
25261
25727
|
|
|
25262
25728
|
// src/services/transfer.ts
|
|
25263
25729
|
init_buffer();
|
|
25264
|
-
var import_utils16 = require("@noble/curves/abstract/utils");
|
|
25265
25730
|
var import_secp256k19 = require("@noble/curves/secp256k1");
|
|
25731
|
+
var import_utils15 = require("@noble/curves/utils");
|
|
25266
25732
|
var import_sha29 = require("@noble/hashes/sha2");
|
|
25267
25733
|
var import_btc_signer2 = require("@scure/btc-signer");
|
|
25268
25734
|
var ecies2 = __toESM(require("eciesjs"), 1);
|
|
@@ -25632,7 +26098,7 @@ var BaseTransferService = class {
|
|
|
25632
26098
|
}
|
|
25633
26099
|
async prepareSendTransferKeyTweaks(transferID, receiverIdentityPubkey, leaves, cpfpRefundSignatureMap, directRefundSignatureMap, directFromCpfpRefundSignatureMap) {
|
|
25634
26100
|
const receiverEciesPubKey = ecies2.PublicKey.fromHex(
|
|
25635
|
-
(0,
|
|
26101
|
+
(0, import_utils15.bytesToHex)(receiverIdentityPubkey)
|
|
25636
26102
|
);
|
|
25637
26103
|
const leavesTweaksMap = /* @__PURE__ */ new Map();
|
|
25638
26104
|
for (const leaf of leaves) {
|
|
@@ -25673,7 +26139,7 @@ var BaseTransferService = class {
|
|
|
25673
26139
|
throw new Error(`Share not found for operator ${operator.id}`);
|
|
25674
26140
|
}
|
|
25675
26141
|
const pubkeyTweak = import_secp256k19.secp256k1.getPublicKey(
|
|
25676
|
-
(0,
|
|
26142
|
+
(0, import_utils15.numberToBytesBE)(share.share, 32),
|
|
25677
26143
|
true
|
|
25678
26144
|
);
|
|
25679
26145
|
pubkeySharesTweak.set(identifier, pubkeyTweak);
|
|
@@ -25698,7 +26164,7 @@ var BaseTransferService = class {
|
|
|
25698
26164
|
leafTweaksMap.set(identifier, {
|
|
25699
26165
|
leafId: leaf.leaf.id,
|
|
25700
26166
|
secretShareTweak: {
|
|
25701
|
-
secretShare: (0,
|
|
26167
|
+
secretShare: (0, import_utils15.numberToBytesBE)(share.share, 32),
|
|
25702
26168
|
proofs: share.proofs
|
|
25703
26169
|
},
|
|
25704
26170
|
pubkeySharesTweak: Object.fromEntries(pubkeySharesTweak),
|
|
@@ -25721,7 +26187,7 @@ var BaseTransferService = class {
|
|
|
25721
26187
|
return void 0;
|
|
25722
26188
|
}
|
|
25723
26189
|
compareTransfers(transfer1, transfer2) {
|
|
25724
|
-
return transfer1.id === transfer2.id && (0,
|
|
26190
|
+
return transfer1.id === transfer2.id && (0, import_utils15.equalBytes)(
|
|
25725
26191
|
transfer1.senderIdentityPublicKey,
|
|
25726
26192
|
transfer2.senderIdentityPublicKey
|
|
25727
26193
|
) && transfer1.status === transfer2.status && transfer1.totalValue === transfer2.totalValue && transfer1.expiryTime?.getTime() === transfer2.expiryTime?.getTime() && transfer1.leaves.length === transfer2.leaves.length;
|
|
@@ -26020,7 +26486,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
26020
26486
|
}
|
|
26021
26487
|
const nodeTx = getTxFromRawTxBytes(leaf.leaf.nodeTx);
|
|
26022
26488
|
const cpfpNodeOutPoint = {
|
|
26023
|
-
txid: (0,
|
|
26489
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(nodeTx)),
|
|
26024
26490
|
index: 0
|
|
26025
26491
|
};
|
|
26026
26492
|
let directNodeTx;
|
|
@@ -26028,7 +26494,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
26028
26494
|
if (leaf.leaf.directTx.length > 0) {
|
|
26029
26495
|
directNodeTx = getTxFromRawTxBytes(leaf.leaf.directTx);
|
|
26030
26496
|
directNodeOutPoint = {
|
|
26031
|
-
txid: (0,
|
|
26497
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(directNodeTx)),
|
|
26032
26498
|
index: 0
|
|
26033
26499
|
};
|
|
26034
26500
|
}
|
|
@@ -26162,7 +26628,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
26162
26628
|
throw new Error(`Share not found for operator ${operator.id}`);
|
|
26163
26629
|
}
|
|
26164
26630
|
const pubkeyTweak = import_secp256k19.secp256k1.getPublicKey(
|
|
26165
|
-
(0,
|
|
26631
|
+
(0, import_utils15.numberToBytesBE)(share.share, 32)
|
|
26166
26632
|
);
|
|
26167
26633
|
pubkeySharesTweak.set(identifier, pubkeyTweak);
|
|
26168
26634
|
}
|
|
@@ -26175,7 +26641,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
26175
26641
|
leafTweaksMap.set(identifier, {
|
|
26176
26642
|
leafId: leaf.leaf.id,
|
|
26177
26643
|
secretShareTweak: {
|
|
26178
|
-
secretShare: (0,
|
|
26644
|
+
secretShare: (0, import_utils15.numberToBytesBE)(share.share, 32),
|
|
26179
26645
|
proofs: share.proofs
|
|
26180
26646
|
},
|
|
26181
26647
|
pubkeySharesTweak: Object.fromEntries(pubkeySharesTweak)
|
|
@@ -26254,24 +26720,6 @@ var TransferService = class extends BaseTransferService {
|
|
|
26254
26720
|
throw new Error(`Error finalizing node signatures in transfer: ${error}`);
|
|
26255
26721
|
}
|
|
26256
26722
|
}
|
|
26257
|
-
async cancelTransfer(transfer, operatorAddress) {
|
|
26258
|
-
const sparkClient = await this.connectionManager.createSparkClient(operatorAddress);
|
|
26259
|
-
try {
|
|
26260
|
-
const response = await sparkClient.cancel_transfer({
|
|
26261
|
-
transferId: transfer.id,
|
|
26262
|
-
senderIdentityPublicKey: await this.config.signer.getIdentityPublicKey()
|
|
26263
|
-
});
|
|
26264
|
-
return response.transfer;
|
|
26265
|
-
} catch (error) {
|
|
26266
|
-
throw new NetworkError(
|
|
26267
|
-
"Failed to cancel transfer",
|
|
26268
|
-
{
|
|
26269
|
-
method: "POST"
|
|
26270
|
-
},
|
|
26271
|
-
error
|
|
26272
|
-
);
|
|
26273
|
-
}
|
|
26274
|
-
}
|
|
26275
26723
|
async queryPendingTransfersBySender(operatorAddress) {
|
|
26276
26724
|
const sparkClient = await this.connectionManager.createSparkClient(operatorAddress);
|
|
26277
26725
|
try {
|
|
@@ -26361,13 +26809,13 @@ var TransferService = class extends BaseTransferService {
|
|
|
26361
26809
|
});
|
|
26362
26810
|
}
|
|
26363
26811
|
const newCpfpRefundOutPoint = {
|
|
26364
|
-
txid: (0,
|
|
26812
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(cpfpNodeTx)),
|
|
26365
26813
|
index: 0
|
|
26366
26814
|
};
|
|
26367
26815
|
let newDirectRefundOutPoint;
|
|
26368
26816
|
if (newDirectNodeTx) {
|
|
26369
26817
|
newDirectRefundOutPoint = {
|
|
26370
|
-
txid: (0,
|
|
26818
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(newDirectNodeTx)),
|
|
26371
26819
|
index: 0
|
|
26372
26820
|
};
|
|
26373
26821
|
}
|
|
@@ -26495,7 +26943,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
26495
26943
|
const refundTx = getTxFromRawTxBytes(node.refundTx);
|
|
26496
26944
|
const refundSequence = refundTx.getInput(0).sequence || 0;
|
|
26497
26945
|
const newNodeOutPoint = {
|
|
26498
|
-
txid: (0,
|
|
26946
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(nodeTx)),
|
|
26499
26947
|
index: 0
|
|
26500
26948
|
};
|
|
26501
26949
|
const {
|
|
@@ -26532,13 +26980,13 @@ var TransferService = class extends BaseTransferService {
|
|
|
26532
26980
|
});
|
|
26533
26981
|
}
|
|
26534
26982
|
const newCpfpRefundOutPoint = {
|
|
26535
|
-
txid: (0,
|
|
26983
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(newNodeTx)),
|
|
26536
26984
|
index: 0
|
|
26537
26985
|
};
|
|
26538
26986
|
let newDirectRefundOutPoint;
|
|
26539
26987
|
if (newDirectNodeTx) {
|
|
26540
26988
|
newDirectRefundOutPoint = {
|
|
26541
|
-
txid: (0,
|
|
26989
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(newDirectNodeTx)),
|
|
26542
26990
|
index: 0
|
|
26543
26991
|
};
|
|
26544
26992
|
}
|
|
@@ -26772,13 +27220,13 @@ var TransferService = class extends BaseTransferService {
|
|
|
26772
27220
|
};
|
|
26773
27221
|
const signingPublicKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
|
|
26774
27222
|
const cpfpRefundOutPoint = {
|
|
26775
|
-
txid: (0,
|
|
27223
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(nodeTx)),
|
|
26776
27224
|
index: 0
|
|
26777
27225
|
};
|
|
26778
27226
|
let directRefundOutPoint;
|
|
26779
27227
|
if (directNodeTx) {
|
|
26780
27228
|
directRefundOutPoint = {
|
|
26781
|
-
txid: (0,
|
|
27229
|
+
txid: (0, import_utils15.hexToBytes)(getTxId(directNodeTx)),
|
|
26782
27230
|
index: 0
|
|
26783
27231
|
};
|
|
26784
27232
|
}
|
|
@@ -27154,9 +27602,9 @@ var CoopExitService = class extends BaseTransferService {
|
|
|
27154
27602
|
init_buffer();
|
|
27155
27603
|
var import_secp256k110 = require("@noble/curves/secp256k1");
|
|
27156
27604
|
var import_sha210 = require("@noble/hashes/sha2");
|
|
27157
|
-
var
|
|
27605
|
+
var import_utils16 = require("@noble/hashes/utils");
|
|
27158
27606
|
var import_btc_signer4 = require("@scure/btc-signer");
|
|
27159
|
-
var
|
|
27607
|
+
var import_utils17 = require("@scure/btc-signer/utils");
|
|
27160
27608
|
var DepositService = class {
|
|
27161
27609
|
config;
|
|
27162
27610
|
connectionManager;
|
|
@@ -27166,7 +27614,8 @@ var DepositService = class {
|
|
|
27166
27614
|
}
|
|
27167
27615
|
async validateDepositAddress({
|
|
27168
27616
|
address: address2,
|
|
27169
|
-
userPubkey
|
|
27617
|
+
userPubkey,
|
|
27618
|
+
verifyCoordinatorProof = false
|
|
27170
27619
|
}) {
|
|
27171
27620
|
if (!address2.depositAddressProof || !address2.depositAddressProof.proofOfPossessionSignature || !address2.depositAddressProof.addressSignatures) {
|
|
27172
27621
|
throw new ValidationError(
|
|
@@ -27204,10 +27653,10 @@ var DepositService = class {
|
|
|
27204
27653
|
}
|
|
27205
27654
|
const addrHash = (0, import_sha210.sha256)(address2.address);
|
|
27206
27655
|
for (const operator of Object.values(this.config.getSigningOperators())) {
|
|
27207
|
-
if (operator.identifier === this.config.getCoordinatorIdentifier()) {
|
|
27656
|
+
if (operator.identifier === this.config.getCoordinatorIdentifier() && !verifyCoordinatorProof) {
|
|
27208
27657
|
continue;
|
|
27209
27658
|
}
|
|
27210
|
-
const operatorPubkey2 = (0,
|
|
27659
|
+
const operatorPubkey2 = (0, import_utils16.hexToBytes)(operator.identityPublicKey);
|
|
27211
27660
|
const operatorSig = address2.depositAddressProof.addressSignatures[operator.identifier];
|
|
27212
27661
|
if (!operatorSig) {
|
|
27213
27662
|
throw new ValidationError("Operator signature not found", {
|
|
@@ -27229,6 +27678,46 @@ var DepositService = class {
|
|
|
27229
27678
|
}
|
|
27230
27679
|
}
|
|
27231
27680
|
}
|
|
27681
|
+
async generateStaticDepositAddress({
|
|
27682
|
+
signingPubkey
|
|
27683
|
+
}) {
|
|
27684
|
+
const sparkClient = await this.connectionManager.createSparkClient(
|
|
27685
|
+
this.config.getCoordinatorAddress()
|
|
27686
|
+
);
|
|
27687
|
+
let depositResp;
|
|
27688
|
+
try {
|
|
27689
|
+
depositResp = await sparkClient.generate_static_deposit_address({
|
|
27690
|
+
signingPublicKey: signingPubkey,
|
|
27691
|
+
identityPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
27692
|
+
network: this.config.getNetworkProto()
|
|
27693
|
+
});
|
|
27694
|
+
} catch (error) {
|
|
27695
|
+
throw new NetworkError(
|
|
27696
|
+
"Failed to generate static deposit address",
|
|
27697
|
+
{
|
|
27698
|
+
operation: "generate_static_deposit_address",
|
|
27699
|
+
errorCount: 1,
|
|
27700
|
+
errors: error instanceof Error ? error.message : String(error)
|
|
27701
|
+
},
|
|
27702
|
+
error
|
|
27703
|
+
);
|
|
27704
|
+
}
|
|
27705
|
+
if (!depositResp.depositAddress) {
|
|
27706
|
+
throw new ValidationError(
|
|
27707
|
+
"No static deposit address response from coordinator",
|
|
27708
|
+
{
|
|
27709
|
+
field: "depositAddress",
|
|
27710
|
+
value: depositResp
|
|
27711
|
+
}
|
|
27712
|
+
);
|
|
27713
|
+
}
|
|
27714
|
+
await this.validateDepositAddress({
|
|
27715
|
+
address: depositResp.depositAddress,
|
|
27716
|
+
userPubkey: signingPubkey,
|
|
27717
|
+
verifyCoordinatorProof: true
|
|
27718
|
+
});
|
|
27719
|
+
return depositResp;
|
|
27720
|
+
}
|
|
27232
27721
|
async generateDepositAddress({
|
|
27233
27722
|
signingPubkey,
|
|
27234
27723
|
leafId,
|
|
@@ -27296,7 +27785,7 @@ var DepositService = class {
|
|
|
27296
27785
|
});
|
|
27297
27786
|
}
|
|
27298
27787
|
const depositOutPoint = {
|
|
27299
|
-
txid: (0,
|
|
27788
|
+
txid: (0, import_utils16.hexToBytes)(getTxId(depositTx)),
|
|
27300
27789
|
index: vout
|
|
27301
27790
|
};
|
|
27302
27791
|
const depositTxOut = {
|
|
@@ -27315,8 +27804,8 @@ var DepositService = class {
|
|
|
27315
27804
|
const { cpfpRefundTx, directRefundTx, directFromCpfpRefundTx } = createRefundTxs({
|
|
27316
27805
|
sequence: INITIAL_SEQUENCE,
|
|
27317
27806
|
directSequence: INITIAL_DIRECT_SEQUENCE,
|
|
27318
|
-
input: { txid: (0,
|
|
27319
|
-
directInput: { txid: (0,
|
|
27807
|
+
input: { txid: (0, import_utils16.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
|
|
27808
|
+
directInput: { txid: (0, import_utils16.hexToBytes)(getTxId(directRootTx)), index: 0 },
|
|
27320
27809
|
amountSats: amount,
|
|
27321
27810
|
receivingPubkey: signingPubKey,
|
|
27322
27811
|
network: this.config.getNetwork()
|
|
@@ -27446,7 +27935,7 @@ var DepositService = class {
|
|
|
27446
27935
|
}
|
|
27447
27936
|
);
|
|
27448
27937
|
}
|
|
27449
|
-
if (!(0,
|
|
27938
|
+
if (!(0, import_utils17.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
|
|
27450
27939
|
throw new ValidationError("Verifying key mismatch", {
|
|
27451
27940
|
field: "verifyingKey",
|
|
27452
27941
|
value: treeResp.rootNodeSignatureShares.verifyingKey,
|
|
@@ -27610,7 +28099,7 @@ var DepositService = class {
|
|
|
27610
28099
|
});
|
|
27611
28100
|
}
|
|
27612
28101
|
const depositOutPoint = {
|
|
27613
|
-
txid: (0,
|
|
28102
|
+
txid: (0, import_utils16.hexToBytes)(getTxId(depositTx)),
|
|
27614
28103
|
index: vout
|
|
27615
28104
|
};
|
|
27616
28105
|
const depositTxOut = {
|
|
@@ -27623,7 +28112,7 @@ var DepositService = class {
|
|
|
27623
28112
|
const signingPubKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
|
|
27624
28113
|
const { cpfpRefundTx } = createRefundTxs({
|
|
27625
28114
|
sequence: INITIAL_SEQUENCE,
|
|
27626
|
-
input: { txid: (0,
|
|
28115
|
+
input: { txid: (0, import_utils16.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
|
|
27627
28116
|
amountSats: amount,
|
|
27628
28117
|
receivingPubkey: signingPubKey,
|
|
27629
28118
|
network: this.config.getNetwork()
|
|
@@ -27693,7 +28182,7 @@ var DepositService = class {
|
|
|
27693
28182
|
}
|
|
27694
28183
|
);
|
|
27695
28184
|
}
|
|
27696
|
-
if (!(0,
|
|
28185
|
+
if (!(0, import_utils17.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
|
|
27697
28186
|
throw new ValidationError("Verifying key mismatch", {
|
|
27698
28187
|
field: "verifyingKey",
|
|
27699
28188
|
value: treeResp.rootNodeSignatureShares.verifyingKey,
|
|
@@ -27769,8 +28258,8 @@ var DepositService = class {
|
|
|
27769
28258
|
|
|
27770
28259
|
// src/services/lightning.ts
|
|
27771
28260
|
init_buffer();
|
|
27772
|
-
var import_utils19 = require("@noble/curves/abstract/utils");
|
|
27773
28261
|
var import_secp256k111 = require("@noble/curves/secp256k1");
|
|
28262
|
+
var import_utils18 = require("@noble/curves/utils");
|
|
27774
28263
|
var import_sha211 = require("@noble/hashes/sha2");
|
|
27775
28264
|
var import_uuidv74 = require("uuidv7");
|
|
27776
28265
|
|
|
@@ -27856,8 +28345,8 @@ var LightningService = class {
|
|
|
27856
28345
|
}) {
|
|
27857
28346
|
const crypto = getCrypto();
|
|
27858
28347
|
const randBytes = crypto.getRandomValues(new Uint8Array(32));
|
|
27859
|
-
const preimage = (0,
|
|
27860
|
-
(0,
|
|
28348
|
+
const preimage = (0, import_utils18.numberToBytesBE)(
|
|
28349
|
+
(0, import_utils18.bytesToNumberBE)(randBytes) % import_secp256k111.secp256k1.CURVE.n,
|
|
27861
28350
|
32
|
|
27862
28351
|
);
|
|
27863
28352
|
return await this.createLightningInvoiceWithPreImage({
|
|
@@ -27912,12 +28401,12 @@ var LightningService = class {
|
|
|
27912
28401
|
const sparkClient = await this.connectionManager.createSparkClient(
|
|
27913
28402
|
operator.address
|
|
27914
28403
|
);
|
|
27915
|
-
const userIdentityPublicKey = receiverIdentityPubkey ? (0,
|
|
28404
|
+
const userIdentityPublicKey = receiverIdentityPubkey ? (0, import_utils18.hexToBytes)(receiverIdentityPubkey) : await this.config.signer.getIdentityPublicKey();
|
|
27916
28405
|
try {
|
|
27917
28406
|
await sparkClient.store_preimage_share({
|
|
27918
28407
|
paymentHash,
|
|
27919
28408
|
preimageShare: {
|
|
27920
|
-
secretShare: (0,
|
|
28409
|
+
secretShare: (0, import_utils18.numberToBytesBE)(share.share, 32),
|
|
27921
28410
|
proofs: share.proofs
|
|
27922
28411
|
},
|
|
27923
28412
|
threshold: this.config.getThreshold(),
|
|
@@ -28118,9 +28607,9 @@ var LightningService = class {
|
|
|
28118
28607
|
|
|
28119
28608
|
// src/services/token-transactions.ts
|
|
28120
28609
|
init_buffer();
|
|
28121
|
-
var import_utils20 = require("@noble/curves/abstract/utils");
|
|
28122
28610
|
var import_secp256k113 = require("@noble/curves/secp256k1");
|
|
28123
|
-
var
|
|
28611
|
+
var import_utils19 = require("@noble/curves/utils");
|
|
28612
|
+
var import_utils20 = require("@noble/hashes/utils");
|
|
28124
28613
|
|
|
28125
28614
|
// src/utils/token-hashing.ts
|
|
28126
28615
|
init_buffer();
|
|
@@ -30054,14 +30543,14 @@ var TokenTransactionService = class {
|
|
|
30054
30543
|
}
|
|
30055
30544
|
if (this.config.getTokenTransactionVersion() !== "V0" && receiverAddress.sparkInvoiceFields) {
|
|
30056
30545
|
return {
|
|
30057
|
-
receiverPublicKey: (0,
|
|
30546
|
+
receiverPublicKey: (0, import_utils20.hexToBytes)(receiverAddress.identityPublicKey),
|
|
30058
30547
|
rawTokenIdentifier,
|
|
30059
30548
|
tokenAmount: transfer.tokenAmount,
|
|
30060
30549
|
sparkInvoice: transfer.receiverSparkAddress
|
|
30061
30550
|
};
|
|
30062
30551
|
}
|
|
30063
30552
|
return {
|
|
30064
|
-
receiverPublicKey: (0,
|
|
30553
|
+
receiverPublicKey: (0, import_utils20.hexToBytes)(receiverAddress.identityPublicKey),
|
|
30065
30554
|
rawTokenIdentifier,
|
|
30066
30555
|
tokenPublicKey,
|
|
30067
30556
|
// Remove for full v0 deprecation
|
|
@@ -30100,7 +30589,7 @@ var TokenTransactionService = class {
|
|
|
30100
30589
|
const tokenOutputs = tokenOutputData.map((output) => ({
|
|
30101
30590
|
ownerPublicKey: output.receiverPublicKey,
|
|
30102
30591
|
tokenPublicKey: output.tokenPublicKey,
|
|
30103
|
-
tokenAmount: (0,
|
|
30592
|
+
tokenAmount: (0, import_utils19.numberToBytesBE)(output.tokenAmount, 16)
|
|
30104
30593
|
}));
|
|
30105
30594
|
if (availableTokenAmount > totalRequestedAmount) {
|
|
30106
30595
|
const changeAmount = availableTokenAmount - totalRequestedAmount;
|
|
@@ -30108,7 +30597,7 @@ var TokenTransactionService = class {
|
|
|
30108
30597
|
tokenOutputs.push({
|
|
30109
30598
|
ownerPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
30110
30599
|
tokenPublicKey: firstTokenPublicKey,
|
|
30111
|
-
tokenAmount: (0,
|
|
30600
|
+
tokenAmount: (0, import_utils19.numberToBytesBE)(changeAmount, 16)
|
|
30112
30601
|
});
|
|
30113
30602
|
}
|
|
30114
30603
|
return {
|
|
@@ -30139,7 +30628,7 @@ var TokenTransactionService = class {
|
|
|
30139
30628
|
(output) => ({
|
|
30140
30629
|
ownerPublicKey: output.receiverPublicKey,
|
|
30141
30630
|
tokenIdentifier: output.rawTokenIdentifier,
|
|
30142
|
-
tokenAmount: (0,
|
|
30631
|
+
tokenAmount: (0, import_utils19.numberToBytesBE)(output.tokenAmount, 16)
|
|
30143
30632
|
})
|
|
30144
30633
|
);
|
|
30145
30634
|
if (availableTokenAmount > totalRequestedAmount) {
|
|
@@ -30148,7 +30637,7 @@ var TokenTransactionService = class {
|
|
|
30148
30637
|
tokenOutputs.push({
|
|
30149
30638
|
ownerPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
30150
30639
|
tokenIdentifier: firstTokenIdentifierBytes,
|
|
30151
|
-
tokenAmount: (0,
|
|
30640
|
+
tokenAmount: (0, import_utils19.numberToBytesBE)(changeAmount, 16)
|
|
30152
30641
|
});
|
|
30153
30642
|
}
|
|
30154
30643
|
return {
|
|
@@ -30175,7 +30664,7 @@ var TokenTransactionService = class {
|
|
|
30175
30664
|
for (const [_, operator] of Object.entries(
|
|
30176
30665
|
this.config.getSigningOperators()
|
|
30177
30666
|
)) {
|
|
30178
|
-
operatorKeys.push((0,
|
|
30667
|
+
operatorKeys.push((0, import_utils20.hexToBytes)(operator.identityPublicKey));
|
|
30179
30668
|
}
|
|
30180
30669
|
return operatorKeys;
|
|
30181
30670
|
}
|
|
@@ -30259,7 +30748,7 @@ var TokenTransactionService = class {
|
|
|
30259
30748
|
{
|
|
30260
30749
|
field: "revocationCommitment",
|
|
30261
30750
|
value: derivedRevocationCommitment,
|
|
30262
|
-
expected: (0,
|
|
30751
|
+
expected: (0, import_utils19.bytesToHex)(outputsToSpendCommitments[outputIndex]),
|
|
30263
30752
|
outputIndex
|
|
30264
30753
|
}
|
|
30265
30754
|
)
|
|
@@ -30285,7 +30774,7 @@ var TokenTransactionService = class {
|
|
|
30285
30774
|
threshold
|
|
30286
30775
|
);
|
|
30287
30776
|
}
|
|
30288
|
-
return (0,
|
|
30777
|
+
return (0, import_utils19.bytesToHex)(finalTokenTransactionHash);
|
|
30289
30778
|
}
|
|
30290
30779
|
async broadcastTokenTransactionV1(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
|
|
30291
30780
|
const { finalTokenTransaction, finalTokenTransactionHash, threshold } = await this.startTokenTransaction(
|
|
@@ -30299,7 +30788,7 @@ var TokenTransactionService = class {
|
|
|
30299
30788
|
finalTokenTransactionHash,
|
|
30300
30789
|
signingOperators
|
|
30301
30790
|
);
|
|
30302
|
-
return (0,
|
|
30791
|
+
return (0, import_utils19.bytesToHex)(finalTokenTransactionHash);
|
|
30303
30792
|
}
|
|
30304
30793
|
async startTokenTransactionV0(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
|
|
30305
30794
|
const sparkClient = await this.connectionManager.createSparkClient(
|
|
@@ -30523,7 +31012,7 @@ var TokenTransactionService = class {
|
|
|
30523
31012
|
const identityPublicKey = await this.config.signer.getIdentityPublicKey();
|
|
30524
31013
|
const payload = {
|
|
30525
31014
|
finalTokenTransactionHash,
|
|
30526
|
-
operatorIdentityPublicKey: (0,
|
|
31015
|
+
operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
|
|
30527
31016
|
};
|
|
30528
31017
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
30529
31018
|
let operatorSpecificSignatures = [];
|
|
@@ -30738,8 +31227,8 @@ var TokenTransactionService = class {
|
|
|
30738
31227
|
this.config.getCoordinatorAddress()
|
|
30739
31228
|
);
|
|
30740
31229
|
let queryParams = {
|
|
30741
|
-
tokenPublicKeys: issuerPublicKeys?.map(
|
|
30742
|
-
ownerPublicKeys: ownerPublicKeys?.map(
|
|
31230
|
+
tokenPublicKeys: issuerPublicKeys?.map(import_utils20.hexToBytes),
|
|
31231
|
+
ownerPublicKeys: ownerPublicKeys?.map(import_utils20.hexToBytes),
|
|
30743
31232
|
tokenIdentifiers: tokenIdentifiers?.map((identifier) => {
|
|
30744
31233
|
const { tokenIdentifier } = decodeBech32mTokenIdentifier(
|
|
30745
31234
|
identifier,
|
|
@@ -30747,7 +31236,7 @@ var TokenTransactionService = class {
|
|
|
30747
31236
|
);
|
|
30748
31237
|
return tokenIdentifier;
|
|
30749
31238
|
}),
|
|
30750
|
-
tokenTransactionHashes: tokenTransactionHashes?.map(
|
|
31239
|
+
tokenTransactionHashes: tokenTransactionHashes?.map(import_utils20.hexToBytes),
|
|
30751
31240
|
outputIds: outputIds || [],
|
|
30752
31241
|
limit: pageSize,
|
|
30753
31242
|
offset
|
|
@@ -30806,8 +31295,8 @@ var TokenTransactionService = class {
|
|
|
30806
31295
|
this.config.getCoordinatorAddress()
|
|
30807
31296
|
);
|
|
30808
31297
|
let queryParams = {
|
|
30809
|
-
issuerPublicKeys: issuerPublicKeys?.map(
|
|
30810
|
-
ownerPublicKeys: ownerPublicKeys?.map(
|
|
31298
|
+
issuerPublicKeys: issuerPublicKeys?.map(import_utils20.hexToBytes),
|
|
31299
|
+
ownerPublicKeys: ownerPublicKeys?.map(import_utils20.hexToBytes),
|
|
30811
31300
|
tokenIdentifiers: tokenIdentifiers?.map((identifier) => {
|
|
30812
31301
|
const { tokenIdentifier } = decodeBech32mTokenIdentifier(
|
|
30813
31302
|
identifier,
|
|
@@ -30815,7 +31304,7 @@ var TokenTransactionService = class {
|
|
|
30815
31304
|
);
|
|
30816
31305
|
return tokenIdentifier;
|
|
30817
31306
|
}),
|
|
30818
|
-
tokenTransactionHashes: tokenTransactionHashes?.map(
|
|
31307
|
+
tokenTransactionHashes: tokenTransactionHashes?.map(import_utils20.hexToBytes),
|
|
30819
31308
|
outputIds: outputIds || [],
|
|
30820
31309
|
limit: pageSize,
|
|
30821
31310
|
offset
|
|
@@ -30850,7 +31339,7 @@ var TokenTransactionService = class {
|
|
|
30850
31339
|
});
|
|
30851
31340
|
}
|
|
30852
31341
|
const exactMatch = tokenOutputs.find(
|
|
30853
|
-
(item) => (0,
|
|
31342
|
+
(item) => (0, import_utils19.bytesToNumberBE)(item.output.tokenAmount) === tokenAmount
|
|
30854
31343
|
);
|
|
30855
31344
|
if (exactMatch) {
|
|
30856
31345
|
return [exactMatch];
|
|
@@ -30861,7 +31350,7 @@ var TokenTransactionService = class {
|
|
|
30861
31350
|
for (const outputWithPreviousTransactionData of tokenOutputs) {
|
|
30862
31351
|
if (remainingAmount <= 0n) break;
|
|
30863
31352
|
selectedOutputs.push(outputWithPreviousTransactionData);
|
|
30864
|
-
remainingAmount -= (0,
|
|
31353
|
+
remainingAmount -= (0, import_utils19.bytesToNumberBE)(
|
|
30865
31354
|
outputWithPreviousTransactionData.output.tokenAmount
|
|
30866
31355
|
);
|
|
30867
31356
|
}
|
|
@@ -30877,13 +31366,13 @@ var TokenTransactionService = class {
|
|
|
30877
31366
|
if (strategy === "SMALL_FIRST") {
|
|
30878
31367
|
tokenOutputs.sort((a, b) => {
|
|
30879
31368
|
return Number(
|
|
30880
|
-
(0,
|
|
31369
|
+
(0, import_utils19.bytesToNumberBE)(a.output.tokenAmount) - (0, import_utils19.bytesToNumberBE)(b.output.tokenAmount)
|
|
30881
31370
|
);
|
|
30882
31371
|
});
|
|
30883
31372
|
} else {
|
|
30884
31373
|
tokenOutputs.sort((a, b) => {
|
|
30885
31374
|
return Number(
|
|
30886
|
-
(0,
|
|
31375
|
+
(0, import_utils19.bytesToNumberBE)(b.output.tokenAmount) - (0, import_utils19.bytesToNumberBE)(a.output.tokenAmount)
|
|
30887
31376
|
);
|
|
30888
31377
|
});
|
|
30889
31378
|
}
|
|
@@ -30891,7 +31380,7 @@ var TokenTransactionService = class {
|
|
|
30891
31380
|
// Helper function for deciding if the signer public key is the identity public key
|
|
30892
31381
|
async signMessageWithKey(message, publicKey) {
|
|
30893
31382
|
const tokenSignatures = this.config.getTokenSignatures();
|
|
30894
|
-
if ((0,
|
|
31383
|
+
if ((0, import_utils19.bytesToHex)(publicKey) === (0, import_utils19.bytesToHex)(await this.config.signer.getIdentityPublicKey())) {
|
|
30895
31384
|
if (tokenSignatures === "SCHNORR") {
|
|
30896
31385
|
return await this.config.signer.signSchnorrWithIdentityKey(message);
|
|
30897
31386
|
} else {
|
|
@@ -30900,8 +31389,8 @@ var TokenTransactionService = class {
|
|
|
30900
31389
|
} else {
|
|
30901
31390
|
throw new ValidationError("Invalid public key", {
|
|
30902
31391
|
field: "publicKey",
|
|
30903
|
-
value: (0,
|
|
30904
|
-
expected: (0,
|
|
31392
|
+
value: (0, import_utils19.bytesToHex)(publicKey),
|
|
31393
|
+
expected: (0, import_utils19.bytesToHex)(await this.config.signer.getIdentityPublicKey())
|
|
30905
31394
|
});
|
|
30906
31395
|
}
|
|
30907
31396
|
}
|
|
@@ -30964,7 +31453,7 @@ var TokenTransactionService = class {
|
|
|
30964
31453
|
}
|
|
30965
31454
|
const payload = {
|
|
30966
31455
|
finalTokenTransactionHash,
|
|
30967
|
-
operatorIdentityPublicKey: (0,
|
|
31456
|
+
operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
|
|
30968
31457
|
};
|
|
30969
31458
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
30970
31459
|
const ownerSignature = await this.signMessageWithKey(
|
|
@@ -30986,7 +31475,7 @@ var TokenTransactionService = class {
|
|
|
30986
31475
|
}
|
|
30987
31476
|
const payload = {
|
|
30988
31477
|
finalTokenTransactionHash,
|
|
30989
|
-
operatorIdentityPublicKey: (0,
|
|
31478
|
+
operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
|
|
30990
31479
|
};
|
|
30991
31480
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
30992
31481
|
const ownerSignature = await this.signMessageWithKey(
|
|
@@ -31002,7 +31491,7 @@ var TokenTransactionService = class {
|
|
|
31002
31491
|
for (let i = 0; i < transferInput.outputsToSpend.length; i++) {
|
|
31003
31492
|
const payload = {
|
|
31004
31493
|
finalTokenTransactionHash,
|
|
31005
|
-
operatorIdentityPublicKey: (0,
|
|
31494
|
+
operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
|
|
31006
31495
|
};
|
|
31007
31496
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
31008
31497
|
let ownerSignature;
|
|
@@ -31019,7 +31508,7 @@ var TokenTransactionService = class {
|
|
|
31019
31508
|
}
|
|
31020
31509
|
inputTtxoSignaturesPerOperator.push({
|
|
31021
31510
|
ttxoSignatures,
|
|
31022
|
-
operatorIdentityPublicKey: (0,
|
|
31511
|
+
operatorIdentityPublicKey: (0, import_utils20.hexToBytes)(operator.identityPublicKey)
|
|
31023
31512
|
});
|
|
31024
31513
|
}
|
|
31025
31514
|
return inputTtxoSignaturesPerOperator;
|
|
@@ -31038,7 +31527,7 @@ var import_nice_grpc_common3 = require("nice-grpc-common");
|
|
|
31038
31527
|
|
|
31039
31528
|
// src/services/signing.ts
|
|
31040
31529
|
init_buffer();
|
|
31041
|
-
var
|
|
31530
|
+
var import_utils21 = require("@noble/curves/utils");
|
|
31042
31531
|
var SigningService = class {
|
|
31043
31532
|
config;
|
|
31044
31533
|
constructor(config) {
|
|
@@ -31094,7 +31583,7 @@ var SigningService = class {
|
|
|
31094
31583
|
}
|
|
31095
31584
|
const nodeTx = getTxFromRawTxBytes(leaf.leaf.nodeTx);
|
|
31096
31585
|
const cpfpNodeOutPoint = {
|
|
31097
|
-
txid: (0,
|
|
31586
|
+
txid: (0, import_utils21.hexToBytes)(getTxId(nodeTx)),
|
|
31098
31587
|
index: 0
|
|
31099
31588
|
};
|
|
31100
31589
|
const currRefundTx = getTxFromRawTxBytes(leaf.leaf.refundTx);
|
|
@@ -31120,7 +31609,7 @@ var SigningService = class {
|
|
|
31120
31609
|
if (leaf.leaf.directTx.length > 0) {
|
|
31121
31610
|
directNodeTx = getTxFromRawTxBytes(leaf.leaf.directTx);
|
|
31122
31611
|
directNodeOutPoint = {
|
|
31123
|
-
txid: (0,
|
|
31612
|
+
txid: (0, import_utils21.hexToBytes)(getTxId(directNodeTx)),
|
|
31124
31613
|
index: 0
|
|
31125
31614
|
};
|
|
31126
31615
|
}
|
|
@@ -31204,15 +31693,15 @@ var SigningService = class {
|
|
|
31204
31693
|
|
|
31205
31694
|
// src/tests/utils/test-faucet.ts
|
|
31206
31695
|
init_buffer();
|
|
31207
|
-
var import_utils23 = require("@noble/curves/abstract/utils");
|
|
31208
31696
|
var import_secp256k114 = require("@noble/curves/secp256k1");
|
|
31697
|
+
var import_utils22 = require("@noble/curves/utils");
|
|
31209
31698
|
var btc5 = __toESM(require("@scure/btc-signer"), 1);
|
|
31210
31699
|
var import_btc_signer5 = require("@scure/btc-signer");
|
|
31211
|
-
var
|
|
31212
|
-
var STATIC_FAUCET_KEY = (0,
|
|
31700
|
+
var import_utils23 = require("@scure/btc-signer/utils");
|
|
31701
|
+
var STATIC_FAUCET_KEY = (0, import_utils22.hexToBytes)(
|
|
31213
31702
|
"deadbeef1337cafe4242424242424242deadbeef1337cafe4242424242424242"
|
|
31214
31703
|
);
|
|
31215
|
-
var STATIC_MINING_KEY = (0,
|
|
31704
|
+
var STATIC_MINING_KEY = (0, import_utils22.hexToBytes)(
|
|
31216
31705
|
"1337cafe4242deadbeef4242424242421337cafe4242deadbeef424242424242"
|
|
31217
31706
|
);
|
|
31218
31707
|
var SATS_PER_BTC = 1e8;
|
|
@@ -31275,7 +31764,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
31275
31764
|
if (!scanResult.success || scanResult.unspents.length === 0) {
|
|
31276
31765
|
const blockHash = await this.generateToAddress(1, address2);
|
|
31277
31766
|
const block = await this.getBlock(blockHash[0]);
|
|
31278
|
-
const fundingTx = import_btc_signer5.Transaction.fromRaw((0,
|
|
31767
|
+
const fundingTx = import_btc_signer5.Transaction.fromRaw((0, import_utils22.hexToBytes)(block.tx[0].hex), {
|
|
31279
31768
|
allowUnknownOutputs: true
|
|
31280
31769
|
});
|
|
31281
31770
|
await this.generateToAddress(100, this.miningAddress);
|
|
@@ -31337,13 +31826,13 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
31337
31826
|
},
|
|
31338
31827
|
STATIC_MINING_KEY
|
|
31339
31828
|
);
|
|
31340
|
-
await this.broadcastTx((0,
|
|
31829
|
+
await this.broadcastTx((0, import_utils22.bytesToHex)(signedSplitTx.extract()));
|
|
31341
31830
|
const splitTxId = signedSplitTx.id;
|
|
31342
31831
|
for (let i = 0; i < numCoinsToCreate; i++) {
|
|
31343
31832
|
this.coins.push({
|
|
31344
31833
|
key: STATIC_FAUCET_KEY,
|
|
31345
31834
|
outpoint: {
|
|
31346
|
-
txid: (0,
|
|
31835
|
+
txid: (0, import_utils22.hexToBytes)(splitTxId),
|
|
31347
31836
|
index: i
|
|
31348
31837
|
},
|
|
31349
31838
|
txout: signedSplitTx.getOutput(i)
|
|
@@ -31371,7 +31860,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
31371
31860
|
coinToSend.txout,
|
|
31372
31861
|
coinToSend.key
|
|
31373
31862
|
);
|
|
31374
|
-
await this.broadcastTx((0,
|
|
31863
|
+
await this.broadcastTx((0, import_utils22.bytesToHex)(signedTx.extract()));
|
|
31375
31864
|
}
|
|
31376
31865
|
async signFaucetCoin(unsignedTx, fundingTxOut, key) {
|
|
31377
31866
|
const pubKey = import_secp256k114.secp256k1.getPublicKey(key);
|
|
@@ -31391,7 +31880,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
31391
31880
|
new Array(unsignedTx.inputsLength).fill(fundingTxOut.amount)
|
|
31392
31881
|
);
|
|
31393
31882
|
const merkleRoot = new Uint8Array();
|
|
31394
|
-
const tweakedKey = (0,
|
|
31883
|
+
const tweakedKey = (0, import_utils23.taprootTweakPrivKey)(key, merkleRoot);
|
|
31395
31884
|
if (!tweakedKey)
|
|
31396
31885
|
throw new Error("Invalid private key for taproot tweaking");
|
|
31397
31886
|
const signature = import_secp256k114.schnorr.sign(sighash, tweakedKey);
|
|
@@ -31491,7 +31980,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
31491
31980
|
});
|
|
31492
31981
|
}
|
|
31493
31982
|
const signedTx = await this.signFaucetCoin(tx, coin.txout, coin.key);
|
|
31494
|
-
const txHex = (0,
|
|
31983
|
+
const txHex = (0, import_utils22.bytesToHex)(signedTx.extract());
|
|
31495
31984
|
await this.broadcastTx(txHex);
|
|
31496
31985
|
const randomKey = import_secp256k114.secp256k1.utils.randomPrivateKey();
|
|
31497
31986
|
const randomPubKey = import_secp256k114.secp256k1.getPublicKey(randomKey);
|
|
@@ -31682,7 +32171,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31682
32171
|
try {
|
|
31683
32172
|
if (event?.$case === "transfer" && event.transfer.transfer && event.transfer.transfer.type !== 40 /* COUNTER_SWAP */) {
|
|
31684
32173
|
const { senderIdentityPublicKey, receiverIdentityPublicKey } = event.transfer.transfer;
|
|
31685
|
-
if (event.transfer.transfer && !(0,
|
|
32174
|
+
if (event.transfer.transfer && !(0, import_utils24.equalBytes)(senderIdentityPublicKey, receiverIdentityPublicKey)) {
|
|
31686
32175
|
await this.claimTransfer({
|
|
31687
32176
|
transfer: event.transfer.transfer,
|
|
31688
32177
|
emit: true,
|
|
@@ -31847,10 +32336,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31847
32336
|
leavesToIgnore.add(nodeId);
|
|
31848
32337
|
continue;
|
|
31849
32338
|
}
|
|
31850
|
-
if (leaf.status !== operatorLeaf.status || !leaf.signingKeyshare || !operatorLeaf.signingKeyshare || !(0,
|
|
32339
|
+
if (leaf.status !== operatorLeaf.status || !leaf.signingKeyshare || !operatorLeaf.signingKeyshare || !(0, import_utils24.equalBytes)(
|
|
31851
32340
|
leaf.signingKeyshare.publicKey,
|
|
31852
32341
|
operatorLeaf.signingKeyshare.publicKey
|
|
31853
|
-
) || !(0,
|
|
32342
|
+
) || !(0, import_utils24.equalBytes)(leaf.nodeTx, operatorLeaf.nodeTx)) {
|
|
31854
32343
|
leavesToIgnore.add(nodeId);
|
|
31855
32344
|
}
|
|
31856
32345
|
}
|
|
@@ -31901,7 +32390,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31901
32390
|
});
|
|
31902
32391
|
}
|
|
31903
32392
|
verifyKey(pubkey1, pubkey2, verifyingKey) {
|
|
31904
|
-
return (0,
|
|
32393
|
+
return (0, import_utils24.equalBytes)(addPublicKeys(pubkey1, pubkey2), verifyingKey);
|
|
31905
32394
|
}
|
|
31906
32395
|
async selectLeaves(targetAmounts) {
|
|
31907
32396
|
if (targetAmounts.length === 0) {
|
|
@@ -32059,7 +32548,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32059
32548
|
* @returns {Promise<string>} The identity public key as a hex string.
|
|
32060
32549
|
*/
|
|
32061
32550
|
async getIdentityPublicKey() {
|
|
32062
|
-
return (0,
|
|
32551
|
+
return (0, import_utils24.bytesToHex)(await this.config.signer.getIdentityPublicKey());
|
|
32063
32552
|
}
|
|
32064
32553
|
/**
|
|
32065
32554
|
* Gets the Spark address of the wallet.
|
|
@@ -32069,7 +32558,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32069
32558
|
async getSparkAddress() {
|
|
32070
32559
|
if (!this.sparkAddress) {
|
|
32071
32560
|
this.sparkAddress = encodeSparkAddress({
|
|
32072
|
-
identityPublicKey: (0,
|
|
32561
|
+
identityPublicKey: (0, import_utils24.bytesToHex)(
|
|
32073
32562
|
await this.config.signer.getIdentityPublicKey()
|
|
32074
32563
|
),
|
|
32075
32564
|
network: this.config.getNetworkType()
|
|
@@ -32132,7 +32621,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32132
32621
|
$case: "tokensPayment",
|
|
32133
32622
|
tokensPayment: {
|
|
32134
32623
|
tokenIdentifier: decodedTokenIdentifier ?? void 0,
|
|
32135
|
-
amount: amount ? (0,
|
|
32624
|
+
amount: amount ? (0, import_utils24.numberToVarBytesBE)(amount) : void 0
|
|
32136
32625
|
}
|
|
32137
32626
|
};
|
|
32138
32627
|
const invoiceFields = {
|
|
@@ -32140,7 +32629,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32140
32629
|
id: (0, import_uuidv75.uuidv7obj)().bytes,
|
|
32141
32630
|
paymentType: protoPayment,
|
|
32142
32631
|
memo: memo ?? void 0,
|
|
32143
|
-
senderPublicKey: senderPublicKey ? (0,
|
|
32632
|
+
senderPublicKey: senderPublicKey ? (0, import_utils24.hexToBytes)(senderPublicKey) : void 0,
|
|
32144
32633
|
expiryTime: expiryTime ?? void 0
|
|
32145
32634
|
};
|
|
32146
32635
|
validateSparkInvoiceFields(invoiceFields);
|
|
@@ -32153,7 +32642,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32153
32642
|
const signature = await this.config.signer.signSchnorrWithIdentityKey(hash);
|
|
32154
32643
|
return encodeSparkAddressWithSignature(
|
|
32155
32644
|
{
|
|
32156
|
-
identityPublicKey: (0,
|
|
32645
|
+
identityPublicKey: (0, import_utils24.bytesToHex)(identityPublicKey),
|
|
32157
32646
|
network: this.config.getNetworkType(),
|
|
32158
32647
|
sparkInvoiceFields: invoiceFields
|
|
32159
32648
|
},
|
|
@@ -32199,7 +32688,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32199
32688
|
mnemonic = mnemonicOrSeed;
|
|
32200
32689
|
seed = await this.config.signer.mnemonicToSeed(mnemonicOrSeed);
|
|
32201
32690
|
} else {
|
|
32202
|
-
seed = (0,
|
|
32691
|
+
seed = (0, import_utils24.hexToBytes)(mnemonicOrSeed);
|
|
32203
32692
|
}
|
|
32204
32693
|
}
|
|
32205
32694
|
await this.initWalletFromSeed(seed, accountNumber);
|
|
@@ -32221,7 +32710,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32221
32710
|
});
|
|
32222
32711
|
}
|
|
32223
32712
|
this.sparkAddress = encodeSparkAddress({
|
|
32224
|
-
identityPublicKey: (0,
|
|
32713
|
+
identityPublicKey: (0, import_utils24.bytesToHex)(identityPublicKey),
|
|
32225
32714
|
network: this.config.getNetworkType()
|
|
32226
32715
|
});
|
|
32227
32716
|
return this.sparkAddress;
|
|
@@ -32341,7 +32830,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32341
32830
|
directFromCpfpSignatureMap
|
|
32342
32831
|
} = await this.transferService.startSwapSignRefund(
|
|
32343
32832
|
leafKeyTweaks,
|
|
32344
|
-
(0,
|
|
32833
|
+
(0, import_utils24.hexToBytes)(this.config.getSspIdentityPublicKey()),
|
|
32345
32834
|
new Date(Date.now() + 2 * 60 * 1e3)
|
|
32346
32835
|
);
|
|
32347
32836
|
try {
|
|
@@ -32401,18 +32890,18 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32401
32890
|
const userLeaves = [];
|
|
32402
32891
|
userLeaves.push({
|
|
32403
32892
|
leaf_id: transfer.leaves[0].leaf.id,
|
|
32404
|
-
raw_unsigned_refund_transaction: (0,
|
|
32893
|
+
raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
|
|
32405
32894
|
transfer.leaves[0].intermediateRefundTx
|
|
32406
32895
|
),
|
|
32407
|
-
direct_raw_unsigned_refund_transaction: (0,
|
|
32896
|
+
direct_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
|
|
32408
32897
|
transfer.leaves[0].intermediateDirectRefundTx
|
|
32409
32898
|
),
|
|
32410
|
-
direct_from_cpfp_raw_unsigned_refund_transaction: (0,
|
|
32899
|
+
direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
|
|
32411
32900
|
transfer.leaves[0].intermediateDirectFromCpfpRefundTx
|
|
32412
32901
|
),
|
|
32413
|
-
adaptor_added_signature: (0,
|
|
32414
|
-
direct_adaptor_added_signature: (0,
|
|
32415
|
-
direct_from_cpfp_adaptor_added_signature: (0,
|
|
32902
|
+
adaptor_added_signature: (0, import_utils24.bytesToHex)(cpfpAdaptorSignature),
|
|
32903
|
+
direct_adaptor_added_signature: (0, import_utils24.bytesToHex)(directAdaptorSignature),
|
|
32904
|
+
direct_from_cpfp_adaptor_added_signature: (0, import_utils24.bytesToHex)(
|
|
32416
32905
|
directFromCpfpAdaptorSignature
|
|
32417
32906
|
)
|
|
32418
32907
|
});
|
|
@@ -32465,24 +32954,24 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32465
32954
|
}
|
|
32466
32955
|
userLeaves.push({
|
|
32467
32956
|
leaf_id: leaf.leaf.id,
|
|
32468
|
-
raw_unsigned_refund_transaction: (0,
|
|
32957
|
+
raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
|
|
32469
32958
|
leaf.intermediateRefundTx
|
|
32470
32959
|
),
|
|
32471
|
-
direct_raw_unsigned_refund_transaction: (0,
|
|
32960
|
+
direct_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
|
|
32472
32961
|
leaf.intermediateDirectRefundTx
|
|
32473
32962
|
),
|
|
32474
|
-
direct_from_cpfp_raw_unsigned_refund_transaction: (0,
|
|
32963
|
+
direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils24.bytesToHex)(
|
|
32475
32964
|
leaf.intermediateDirectFromCpfpRefundTx
|
|
32476
32965
|
),
|
|
32477
|
-
adaptor_added_signature: (0,
|
|
32478
|
-
direct_adaptor_added_signature: (0,
|
|
32479
|
-
direct_from_cpfp_adaptor_added_signature: (0,
|
|
32966
|
+
adaptor_added_signature: (0, import_utils24.bytesToHex)(cpfpSignature),
|
|
32967
|
+
direct_adaptor_added_signature: (0, import_utils24.bytesToHex)(directSignature),
|
|
32968
|
+
direct_from_cpfp_adaptor_added_signature: (0, import_utils24.bytesToHex)(
|
|
32480
32969
|
directFromCpfpSignature
|
|
32481
32970
|
)
|
|
32482
32971
|
});
|
|
32483
32972
|
}
|
|
32484
32973
|
const sspClient = this.getSspClient();
|
|
32485
|
-
const cpfpAdaptorPubkey = (0,
|
|
32974
|
+
const cpfpAdaptorPubkey = (0, import_utils24.bytesToHex)(
|
|
32486
32975
|
import_secp256k115.secp256k1.getPublicKey(cpfpAdaptorPrivateKey)
|
|
32487
32976
|
);
|
|
32488
32977
|
if (!cpfpAdaptorPubkey) {
|
|
@@ -32490,13 +32979,13 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32490
32979
|
}
|
|
32491
32980
|
let directAdaptorPubkey;
|
|
32492
32981
|
if (directAdaptorPrivateKey.length > 0) {
|
|
32493
|
-
directAdaptorPubkey = (0,
|
|
32982
|
+
directAdaptorPubkey = (0, import_utils24.bytesToHex)(
|
|
32494
32983
|
import_secp256k115.secp256k1.getPublicKey(directAdaptorPrivateKey)
|
|
32495
32984
|
);
|
|
32496
32985
|
}
|
|
32497
32986
|
let directFromCpfpAdaptorPubkey;
|
|
32498
32987
|
if (directFromCpfpAdaptorPrivateKey.length > 0) {
|
|
32499
|
-
directFromCpfpAdaptorPubkey = (0,
|
|
32988
|
+
directFromCpfpAdaptorPubkey = (0, import_utils24.bytesToHex)(
|
|
32500
32989
|
import_secp256k115.secp256k1.getPublicKey(directFromCpfpAdaptorPrivateKey)
|
|
32501
32990
|
);
|
|
32502
32991
|
}
|
|
@@ -32556,7 +33045,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32556
33045
|
throw new Error(`Leaf not found for node ${nodeId}`);
|
|
32557
33046
|
}
|
|
32558
33047
|
const cpfpNodeTx = getTxFromRawTxBytes(node.nodeTx);
|
|
32559
|
-
const cpfpRefundTxBytes = (0,
|
|
33048
|
+
const cpfpRefundTxBytes = (0, import_utils24.hexToBytes)(leaf.rawUnsignedRefundTransaction);
|
|
32560
33049
|
const cpfpRefundTx = getTxFromRawTxBytes(cpfpRefundTxBytes);
|
|
32561
33050
|
const cpfpSighash = getSigHashFromTx(
|
|
32562
33051
|
cpfpRefundTx,
|
|
@@ -32565,7 +33054,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32565
33054
|
);
|
|
32566
33055
|
const nodePublicKey = node.verifyingPublicKey;
|
|
32567
33056
|
const taprootKey = computeTaprootKeyNoScript(nodePublicKey.slice(1));
|
|
32568
|
-
const cpfpAdaptorSignatureBytes = (0,
|
|
33057
|
+
const cpfpAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
|
|
32569
33058
|
leaf.adaptorSignedSignature
|
|
32570
33059
|
);
|
|
32571
33060
|
applyAdaptorToSignature(
|
|
@@ -32576,7 +33065,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32576
33065
|
);
|
|
32577
33066
|
if (leaf.directRawUnsignedRefundTransaction) {
|
|
32578
33067
|
const directNodeTx = getTxFromRawTxBytes(node.directTx);
|
|
32579
|
-
const directRefundTxBytes = (0,
|
|
33068
|
+
const directRefundTxBytes = (0, import_utils24.hexToBytes)(
|
|
32580
33069
|
leaf.directRawUnsignedRefundTransaction
|
|
32581
33070
|
);
|
|
32582
33071
|
const directRefundTx = getTxFromRawTxBytes(directRefundTxBytes);
|
|
@@ -32590,7 +33079,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32590
33079
|
`Direct adaptor signed signature missing for node ${nodeId}`
|
|
32591
33080
|
);
|
|
32592
33081
|
}
|
|
32593
|
-
const directAdaptorSignatureBytes = (0,
|
|
33082
|
+
const directAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
|
|
32594
33083
|
leaf.directAdaptorSignedSignature
|
|
32595
33084
|
);
|
|
32596
33085
|
applyAdaptorToSignature(
|
|
@@ -32601,7 +33090,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32601
33090
|
);
|
|
32602
33091
|
}
|
|
32603
33092
|
if (leaf.directFromCpfpRawUnsignedRefundTransaction) {
|
|
32604
|
-
const directFromCpfpRefundTxBytes = (0,
|
|
33093
|
+
const directFromCpfpRefundTxBytes = (0, import_utils24.hexToBytes)(
|
|
32605
33094
|
leaf.directFromCpfpRawUnsignedRefundTransaction
|
|
32606
33095
|
);
|
|
32607
33096
|
const directFromCpfpRefundTx = getTxFromRawTxBytes(
|
|
@@ -32617,7 +33106,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32617
33106
|
`Direct adaptor signed signature missing for node ${nodeId}`
|
|
32618
33107
|
);
|
|
32619
33108
|
}
|
|
32620
|
-
const directFromCpfpAdaptorSignatureBytes = (0,
|
|
33109
|
+
const directFromCpfpAdaptorSignatureBytes = (0, import_utils24.hexToBytes)(
|
|
32621
33110
|
leaf.directFromCpfpAdaptorSignedSignature
|
|
32622
33111
|
);
|
|
32623
33112
|
applyAdaptorToSignature(
|
|
@@ -32636,9 +33125,9 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32636
33125
|
directFromCpfpSignatureMap
|
|
32637
33126
|
);
|
|
32638
33127
|
const completeResponse = await sspClient.completeLeaveSwap({
|
|
32639
|
-
adaptorSecretKey: (0,
|
|
32640
|
-
directAdaptorSecretKey: (0,
|
|
32641
|
-
directFromCpfpAdaptorSecretKey: (0,
|
|
33128
|
+
adaptorSecretKey: (0, import_utils24.bytesToHex)(cpfpAdaptorPrivateKey),
|
|
33129
|
+
directAdaptorSecretKey: (0, import_utils24.bytesToHex)(directAdaptorPrivateKey),
|
|
33130
|
+
directFromCpfpAdaptorSecretKey: (0, import_utils24.bytesToHex)(
|
|
32642
33131
|
directFromCpfpAdaptorPrivateKey
|
|
32643
33132
|
),
|
|
32644
33133
|
userOutboundTransferExternalId: transfer.id,
|
|
@@ -32669,7 +33158,6 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32669
33158
|
message: e.message,
|
|
32670
33159
|
stack: e.stack
|
|
32671
33160
|
});
|
|
32672
|
-
await this.cancelAllSenderInitiatedTransfers();
|
|
32673
33161
|
throw new Error(`Failed to request leaves swap: ${e}`);
|
|
32674
33162
|
}
|
|
32675
33163
|
}
|
|
@@ -32733,12 +33221,12 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32733
33221
|
let tokenMetadataMap = /* @__PURE__ */ new Map();
|
|
32734
33222
|
for (const [tokenIdentifier, metadata] of this.tokenMetadata) {
|
|
32735
33223
|
tokenMetadataMap.set(tokenIdentifier, {
|
|
32736
|
-
tokenPublicKey: (0,
|
|
33224
|
+
tokenPublicKey: (0, import_utils24.bytesToHex)(metadata.issuerPublicKey),
|
|
32737
33225
|
rawTokenIdentifier: metadata.tokenIdentifier,
|
|
32738
33226
|
tokenName: metadata.tokenName,
|
|
32739
33227
|
tokenTicker: metadata.tokenTicker,
|
|
32740
33228
|
decimals: metadata.decimals,
|
|
32741
|
-
maxSupply: (0,
|
|
33229
|
+
maxSupply: (0, import_utils24.bytesToNumberBE)(metadata.maxSupply)
|
|
32742
33230
|
});
|
|
32743
33231
|
}
|
|
32744
33232
|
return tokenMetadataMap;
|
|
@@ -32773,7 +33261,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32773
33261
|
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
32774
33262
|
*/
|
|
32775
33263
|
async getSingleUseDepositAddress() {
|
|
32776
|
-
return await this.generateDepositAddress(
|
|
33264
|
+
return await this.generateDepositAddress();
|
|
32777
33265
|
}
|
|
32778
33266
|
/**
|
|
32779
33267
|
* Generates a new static deposit address for receiving bitcoin funds.
|
|
@@ -32782,43 +33270,32 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32782
33270
|
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
32783
33271
|
*/
|
|
32784
33272
|
async getStaticDepositAddress() {
|
|
32785
|
-
|
|
32786
|
-
|
|
32787
|
-
|
|
32788
|
-
|
|
32789
|
-
|
|
32790
|
-
|
|
32791
|
-
|
|
32792
|
-
|
|
32793
|
-
|
|
32794
|
-
}
|
|
32795
|
-
} else {
|
|
32796
|
-
throw error;
|
|
32797
|
-
}
|
|
33273
|
+
const signingPubkey = await this.config.signer.getStaticDepositSigningKey(0);
|
|
33274
|
+
const address2 = await this.depositService.generateStaticDepositAddress({
|
|
33275
|
+
signingPubkey
|
|
33276
|
+
});
|
|
33277
|
+
if (!address2.depositAddress) {
|
|
33278
|
+
throw new RPCError("Failed to generate static deposit address", {
|
|
33279
|
+
method: "generateStaticDepositAddress",
|
|
33280
|
+
params: { signingPubkey }
|
|
33281
|
+
});
|
|
32798
33282
|
}
|
|
33283
|
+
return address2.depositAddress.address;
|
|
32799
33284
|
}
|
|
32800
33285
|
/**
|
|
32801
33286
|
* Generates a deposit address for receiving funds.
|
|
32802
|
-
*
|
|
32803
|
-
* @param {boolean} static - Whether the address is static or single use
|
|
32804
33287
|
* @returns {Promise<string>} A deposit address
|
|
32805
33288
|
* @private
|
|
32806
33289
|
*/
|
|
32807
|
-
async generateDepositAddress(
|
|
33290
|
+
async generateDepositAddress() {
|
|
32808
33291
|
const leafId = (0, import_uuidv75.uuidv7)();
|
|
32809
|
-
|
|
32810
|
-
|
|
32811
|
-
|
|
32812
|
-
}
|
|
32813
|
-
signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
|
|
32814
|
-
type: "leaf" /* LEAF */,
|
|
32815
|
-
path: leafId
|
|
32816
|
-
});
|
|
32817
|
-
}
|
|
33292
|
+
const signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
|
|
33293
|
+
type: "leaf" /* LEAF */,
|
|
33294
|
+
path: leafId
|
|
33295
|
+
});
|
|
32818
33296
|
const address2 = await this.depositService.generateDepositAddress({
|
|
32819
33297
|
signingPubkey,
|
|
32820
|
-
leafId
|
|
32821
|
-
isStatic
|
|
33298
|
+
leafId
|
|
32822
33299
|
});
|
|
32823
33300
|
if (!address2.depositAddress) {
|
|
32824
33301
|
throw new RPCError("Failed to generate deposit address", {
|
|
@@ -32845,7 +33322,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32845
33322
|
* @param offset - Pagination offset (default 0).
|
|
32846
33323
|
* @returns {Promise<{ txid: string, vout: number }[]>} List of confirmed UTXOs.
|
|
32847
33324
|
*/
|
|
32848
|
-
async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0) {
|
|
33325
|
+
async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0, excludeClaimed = false) {
|
|
32849
33326
|
if (!depositAddress) {
|
|
32850
33327
|
throw new ValidationError("Deposit address cannot be empty", {
|
|
32851
33328
|
field: "depositAddress"
|
|
@@ -32859,10 +33336,11 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32859
33336
|
address: depositAddress,
|
|
32860
33337
|
network: NetworkToProto[this.config.getNetwork()],
|
|
32861
33338
|
limit,
|
|
32862
|
-
offset
|
|
33339
|
+
offset,
|
|
33340
|
+
excludeClaimed
|
|
32863
33341
|
});
|
|
32864
33342
|
return response.utxos.map((utxo) => ({
|
|
32865
|
-
txid: (0,
|
|
33343
|
+
txid: (0, import_utils24.bytesToHex)(utxo.txid),
|
|
32866
33344
|
vout: utxo.vout
|
|
32867
33345
|
})) ?? [];
|
|
32868
33346
|
} catch (error) {
|
|
@@ -32932,7 +33410,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32932
33410
|
if (network === BitcoinNetwork_default.FUTURE_VALUE) {
|
|
32933
33411
|
network = BitcoinNetwork_default.REGTEST;
|
|
32934
33412
|
}
|
|
32935
|
-
const depositSecretKey = (0,
|
|
33413
|
+
const depositSecretKey = (0, import_utils24.bytesToHex)(
|
|
32936
33414
|
await this.config.signer.getStaticDepositSecretKey(0)
|
|
32937
33415
|
);
|
|
32938
33416
|
const message = await this.getStaticDepositSigningPayload(
|
|
@@ -32945,7 +33423,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32945
33423
|
);
|
|
32946
33424
|
const hashBuffer = (0, import_sha213.sha256)(message);
|
|
32947
33425
|
const signatureBytes = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
|
|
32948
|
-
const signature = (0,
|
|
33426
|
+
const signature = (0, import_utils24.bytesToHex)(signatureBytes);
|
|
32949
33427
|
const response = await this.sspClient.claimStaticDeposit({
|
|
32950
33428
|
transactionId,
|
|
32951
33429
|
outputIndex,
|
|
@@ -33097,7 +33575,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33097
33575
|
networkJSON.toLowerCase(),
|
|
33098
33576
|
2 /* Refund */,
|
|
33099
33577
|
creditAmountSats,
|
|
33100
|
-
(0,
|
|
33578
|
+
(0, import_utils24.bytesToHex)(spendTxSighash)
|
|
33101
33579
|
);
|
|
33102
33580
|
const hashBuffer = (0, import_sha213.sha256)(message);
|
|
33103
33581
|
const swapResponseUserSignature = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
|
|
@@ -33106,7 +33584,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33106
33584
|
);
|
|
33107
33585
|
const swapResponse = await sparkClient.initiate_static_deposit_utxo_refund({
|
|
33108
33586
|
onChainUtxo: {
|
|
33109
|
-
txid: (0,
|
|
33587
|
+
txid: (0, import_utils24.hexToBytes)(depositTransactionId),
|
|
33110
33588
|
vout: outputIndex,
|
|
33111
33589
|
network: networkType
|
|
33112
33590
|
},
|
|
@@ -33142,6 +33620,64 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33142
33620
|
});
|
|
33143
33621
|
return tx.hex;
|
|
33144
33622
|
}
|
|
33623
|
+
/**
|
|
33624
|
+
* Refunds a static deposit and broadcasts the transaction to the network.
|
|
33625
|
+
*
|
|
33626
|
+
* @param {Object} params - The refund parameters
|
|
33627
|
+
* @param {string} params.depositTransactionId - The ID of the transaction
|
|
33628
|
+
* @param {number} [params.outputIndex] - The index of the output
|
|
33629
|
+
* @param {string} params.destinationAddress - The destination address
|
|
33630
|
+
* @param {number} [params.satsPerVbyteFee] - The fee per vbyte to refund
|
|
33631
|
+
* @returns {Promise<string>} The transaction ID
|
|
33632
|
+
*/
|
|
33633
|
+
async refundAndBroadcastStaticDeposit({
|
|
33634
|
+
depositTransactionId,
|
|
33635
|
+
outputIndex,
|
|
33636
|
+
destinationAddress,
|
|
33637
|
+
satsPerVbyteFee
|
|
33638
|
+
}) {
|
|
33639
|
+
const txHex = await this.refundStaticDeposit({
|
|
33640
|
+
depositTransactionId,
|
|
33641
|
+
outputIndex,
|
|
33642
|
+
destinationAddress,
|
|
33643
|
+
satsPerVbyteFee
|
|
33644
|
+
});
|
|
33645
|
+
return await this.broadcastTx(txHex);
|
|
33646
|
+
}
|
|
33647
|
+
/**
|
|
33648
|
+
* Broadcasts a transaction to the network.
|
|
33649
|
+
*
|
|
33650
|
+
* @param {string} txHex - The hex of the transaction
|
|
33651
|
+
* @returns {Promise<string>} The transaction ID
|
|
33652
|
+
*/
|
|
33653
|
+
async broadcastTx(txHex) {
|
|
33654
|
+
if (!txHex) {
|
|
33655
|
+
throw new ValidationError("Transaction hex cannot be empty", {
|
|
33656
|
+
field: "txHex"
|
|
33657
|
+
});
|
|
33658
|
+
}
|
|
33659
|
+
const { fetch, Headers: Headers2 } = getFetch();
|
|
33660
|
+
const baseUrl = this.config.getElectrsUrl();
|
|
33661
|
+
const headers = new Headers2();
|
|
33662
|
+
if (this.config.getNetwork() === 4 /* LOCAL */) {
|
|
33663
|
+
const localFaucet = BitcoinFaucet.getInstance();
|
|
33664
|
+
const response = await localFaucet.broadcastTx(txHex);
|
|
33665
|
+
return response;
|
|
33666
|
+
} else {
|
|
33667
|
+
if (this.config.getNetwork() === 3 /* REGTEST */) {
|
|
33668
|
+
const auth = btoa(
|
|
33669
|
+
`${ELECTRS_CREDENTIALS.username}:${ELECTRS_CREDENTIALS.password}`
|
|
33670
|
+
);
|
|
33671
|
+
headers.set("Authorization", `Basic ${auth}`);
|
|
33672
|
+
}
|
|
33673
|
+
const response = await fetch(`${baseUrl}/tx`, {
|
|
33674
|
+
method: "POST",
|
|
33675
|
+
body: txHex,
|
|
33676
|
+
headers
|
|
33677
|
+
});
|
|
33678
|
+
return response.text();
|
|
33679
|
+
}
|
|
33680
|
+
}
|
|
33145
33681
|
async getStaticDepositSigningPayload(transactionID, outputIndex, network, requestType, creditAmountSats, sspSignature) {
|
|
33146
33682
|
const encoder = new TextEncoder();
|
|
33147
33683
|
const parts = [];
|
|
@@ -33175,7 +33711,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33175
33711
|
creditAmountView.setUint32(0, lowerHalf, true);
|
|
33176
33712
|
creditAmountView.setUint32(4, upperHalf, true);
|
|
33177
33713
|
parts.push(new Uint8Array(creditAmountBuffer));
|
|
33178
|
-
parts.push((0,
|
|
33714
|
+
parts.push((0, import_utils24.hexToBytes)(sspSignature));
|
|
33179
33715
|
const totalLength = parts.reduce((sum, part) => sum + part.length, 0);
|
|
33180
33716
|
const payload = new Uint8Array(totalLength);
|
|
33181
33717
|
let offset = 0;
|
|
@@ -33580,9 +34116,9 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33580
34116
|
});
|
|
33581
34117
|
}
|
|
33582
34118
|
const signerIdentityPublicKey = await this.config.signer.getIdentityPublicKey();
|
|
33583
|
-
const isSelfTransfer = (0,
|
|
34119
|
+
const isSelfTransfer = (0, import_utils24.equalBytes)(
|
|
33584
34120
|
signerIdentityPublicKey,
|
|
33585
|
-
(0,
|
|
34121
|
+
(0, import_utils24.hexToBytes)(receiverAddress.identityPublicKey)
|
|
33586
34122
|
);
|
|
33587
34123
|
return await this.withLeaves(async () => {
|
|
33588
34124
|
let leavesToSend = (await this.selectLeaves([amountSats])).get(
|
|
@@ -33604,7 +34140,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33604
34140
|
);
|
|
33605
34141
|
const transfer = await this.transferService.sendTransferWithKeyTweaks(
|
|
33606
34142
|
leafKeyTweaks,
|
|
33607
|
-
(0,
|
|
34143
|
+
(0, import_utils24.hexToBytes)(receiverAddress.identityPublicKey)
|
|
33608
34144
|
);
|
|
33609
34145
|
const leavesToRemove = new Set(leavesToSend.map((leaf) => leaf.id));
|
|
33610
34146
|
this.leaves = this.leaves.filter((leaf) => !leavesToRemove.has(leaf.id));
|
|
@@ -33620,7 +34156,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33620
34156
|
}
|
|
33621
34157
|
return mapTransferToWalletTransfer(
|
|
33622
34158
|
transfer,
|
|
33623
|
-
(0,
|
|
34159
|
+
(0, import_utils24.bytesToHex)(await this.config.signer.getIdentityPublicKey())
|
|
33624
34160
|
);
|
|
33625
34161
|
});
|
|
33626
34162
|
}
|
|
@@ -33880,24 +34416,6 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33880
34416
|
(result) => result.status === "fulfilled" && result.value !== null
|
|
33881
34417
|
).map((result) => result.value);
|
|
33882
34418
|
}
|
|
33883
|
-
/**
|
|
33884
|
-
* Cancels all sender-initiated transfers.
|
|
33885
|
-
*
|
|
33886
|
-
* @returns {Promise<void>}
|
|
33887
|
-
* @private
|
|
33888
|
-
*/
|
|
33889
|
-
async cancelAllSenderInitiatedTransfers() {
|
|
33890
|
-
for (const operator of Object.values(this.config.getSigningOperators())) {
|
|
33891
|
-
const transfers = await this.transferService.queryPendingTransfersBySender(
|
|
33892
|
-
operator.address
|
|
33893
|
-
);
|
|
33894
|
-
for (const transfer of transfers.transfers) {
|
|
33895
|
-
if (transfer.status === 0 /* TRANSFER_STATUS_SENDER_INITIATED */) {
|
|
33896
|
-
await this.transferService.cancelTransfer(transfer, operator.address);
|
|
33897
|
-
}
|
|
33898
|
-
}
|
|
33899
|
-
}
|
|
33900
|
-
}
|
|
33901
34419
|
// ***** Lightning Flow *****
|
|
33902
34420
|
/**
|
|
33903
34421
|
* Creates a Lightning invoice for receiving payments.
|
|
@@ -33976,7 +34494,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33976
34494
|
const invoice2 = await sspClient.requestLightningReceive({
|
|
33977
34495
|
amountSats: amountSats2,
|
|
33978
34496
|
network: bitcoinNetwork,
|
|
33979
|
-
paymentHash: (0,
|
|
34497
|
+
paymentHash: (0, import_utils24.bytesToHex)(paymentHash),
|
|
33980
34498
|
expirySecs: expirySeconds,
|
|
33981
34499
|
memo: memo2,
|
|
33982
34500
|
includeSparkAddress,
|
|
@@ -34085,7 +34603,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34085
34603
|
const sparkFallbackAddress = decodedInvoice.fallbackAddress;
|
|
34086
34604
|
const paymentHash = decodedInvoice.paymentHash;
|
|
34087
34605
|
if (preferSpark) {
|
|
34088
|
-
if (sparkFallbackAddress === void 0 || isValidSparkFallback((0,
|
|
34606
|
+
if (sparkFallbackAddress === void 0 || isValidSparkFallback((0, import_utils24.hexToBytes)(sparkFallbackAddress)) === false) {
|
|
34089
34607
|
console.warn(
|
|
34090
34608
|
"No valid spark address found in invoice. Defaulting to lightning."
|
|
34091
34609
|
);
|
|
@@ -34139,10 +34657,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34139
34657
|
);
|
|
34140
34658
|
const swapResponse = await this.lightningService.swapNodesForPreimage({
|
|
34141
34659
|
leaves: leavesToSend,
|
|
34142
|
-
receiverIdentityPubkey: (0,
|
|
34660
|
+
receiverIdentityPubkey: (0, import_utils24.hexToBytes)(
|
|
34143
34661
|
this.config.getSspIdentityPublicKey()
|
|
34144
34662
|
),
|
|
34145
|
-
paymentHash: (0,
|
|
34663
|
+
paymentHash: (0, import_utils24.hexToBytes)(paymentHash),
|
|
34146
34664
|
isInboundPayment: false,
|
|
34147
34665
|
invoiceString: invoice,
|
|
34148
34666
|
feeSats: feeEstimate,
|
|
@@ -34260,7 +34778,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34260
34778
|
});
|
|
34261
34779
|
await this.syncTokenOutputs();
|
|
34262
34780
|
const bech32mTokenIdentifier = encodeBech32mTokenIdentifier({
|
|
34263
|
-
tokenIdentifier: (0,
|
|
34781
|
+
tokenIdentifier: (0, import_utils24.hexToBytes)(firstTokenIdentifierHexSeen),
|
|
34264
34782
|
network: this.config.getNetworkType()
|
|
34265
34783
|
});
|
|
34266
34784
|
const receiverOutputs = decoded.map((d) => ({
|
|
@@ -34448,11 +34966,11 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34448
34966
|
const connectorOutputs = [];
|
|
34449
34967
|
for (let i = 0; i < connectorTx.outputsLength - 1; i++) {
|
|
34450
34968
|
connectorOutputs.push({
|
|
34451
|
-
txid: (0,
|
|
34969
|
+
txid: (0, import_utils24.hexToBytes)(connectorTxId),
|
|
34452
34970
|
index: i
|
|
34453
34971
|
});
|
|
34454
34972
|
}
|
|
34455
|
-
const sspPubIdentityKey = (0,
|
|
34973
|
+
const sspPubIdentityKey = (0, import_utils24.hexToBytes)(this.config.getSspIdentityPublicKey());
|
|
34456
34974
|
const transfer = await this.coopExitService.getConnectorRefundSignatures({
|
|
34457
34975
|
leaves: leafKeyTweaks,
|
|
34458
34976
|
exitTxId: coopExitTxId,
|
|
@@ -34506,7 +35024,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34506
35024
|
return transfers?.[0];
|
|
34507
35025
|
}
|
|
34508
35026
|
async constructTransfersWithUserRequest(transfers) {
|
|
34509
|
-
const identityPublicKey = (0,
|
|
35027
|
+
const identityPublicKey = (0, import_utils24.bytesToHex)(
|
|
34510
35028
|
await this.config.signer.getIdentityPublicKey()
|
|
34511
35029
|
);
|
|
34512
35030
|
const userRequests = await this.sspClient?.getTransfers(
|
|
@@ -34750,7 +35268,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34750
35268
|
hash,
|
|
34751
35269
|
compact
|
|
34752
35270
|
);
|
|
34753
|
-
return (0,
|
|
35271
|
+
return (0, import_utils24.bytesToHex)(signature);
|
|
34754
35272
|
}
|
|
34755
35273
|
/**
|
|
34756
35274
|
* Validates a message with the identity key.
|
|
@@ -34762,7 +35280,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34762
35280
|
async validateMessageWithIdentityKey(message, signature) {
|
|
34763
35281
|
const hash = (0, import_sha213.sha256)(message);
|
|
34764
35282
|
if (typeof signature === "string") {
|
|
34765
|
-
signature = (0,
|
|
35283
|
+
signature = (0, import_utils24.hexToBytes)(signature);
|
|
34766
35284
|
}
|
|
34767
35285
|
return this.config.signer.validateMessageWithIdentityKey(hash, signature);
|
|
34768
35286
|
}
|
|
@@ -34775,7 +35293,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34775
35293
|
*/
|
|
34776
35294
|
async signTransaction(txHex, keyType = "auto-detect") {
|
|
34777
35295
|
try {
|
|
34778
|
-
const tx = import_btc_signer6.Transaction.fromRaw((0,
|
|
35296
|
+
const tx = import_btc_signer6.Transaction.fromRaw((0, import_utils24.hexToBytes)(txHex));
|
|
34779
35297
|
let publicKey;
|
|
34780
35298
|
switch (keyType.toLowerCase()) {
|
|
34781
35299
|
case "identity":
|
|
@@ -34808,7 +35326,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34808
35326
|
publicKey,
|
|
34809
35327
|
this.config.getNetwork()
|
|
34810
35328
|
);
|
|
34811
|
-
if ((0,
|
|
35329
|
+
if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(identityScript)) {
|
|
34812
35330
|
try {
|
|
34813
35331
|
this.config.signer.signTransactionIndex(tx, i, publicKey);
|
|
34814
35332
|
inputsSigned++;
|
|
@@ -34852,13 +35370,13 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34852
35370
|
depositPubKey,
|
|
34853
35371
|
this.config.getNetwork()
|
|
34854
35372
|
);
|
|
34855
|
-
if ((0,
|
|
35373
|
+
if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(identityScript)) {
|
|
34856
35374
|
return {
|
|
34857
35375
|
publicKey: identityPubKey,
|
|
34858
35376
|
keyType: "identity"
|
|
34859
35377
|
};
|
|
34860
35378
|
}
|
|
34861
|
-
if ((0,
|
|
35379
|
+
if ((0, import_utils24.bytesToHex)(script) === (0, import_utils24.bytesToHex)(depositScript)) {
|
|
34862
35380
|
return {
|
|
34863
35381
|
publicKey: depositPubKey,
|
|
34864
35382
|
keyType: "deposit"
|