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