@buildonspark/spark-sdk 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/bare/index.cjs +703 -206
- package/dist/bare/index.d.cts +47 -3
- package/dist/bare/index.d.ts +47 -3
- package/dist/bare/index.js +626 -133
- package/dist/{chunk-A5M55UR3.js → chunk-5VWGOHED.js} +499 -8
- package/dist/{chunk-3WBPICWC.js → chunk-NQMQVXR5.js} +1 -1
- package/dist/{chunk-QNYJGFPD.js → chunk-OEK3R57K.js} +149 -123
- package/dist/{chunk-76SYPHOC.js → chunk-TB7DG5CU.js} +2 -2
- package/dist/{chunk-6CMNEDBK.js → chunk-XXTWWW6L.js} +1 -1
- package/dist/{client-Dd3QnxQu.d.ts → client-D7KDa4Ih.d.ts} +1 -1
- package/dist/{client-B9CAWKWz.d.cts → client-DVuA5-7M.d.cts} +1 -1
- package/dist/debug.cjs +703 -206
- package/dist/debug.d.cts +4 -4
- package/dist/debug.d.ts +4 -4
- package/dist/debug.js +4 -4
- package/dist/graphql/objects/index.d.cts +3 -3
- package/dist/graphql/objects/index.d.ts +3 -3
- package/dist/index.cjs +725 -228
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +5 -5
- package/dist/index.node.cjs +725 -228
- package/dist/index.node.d.cts +6 -6
- package/dist/index.node.d.ts +6 -6
- package/dist/index.node.js +4 -4
- package/dist/{logging-Bt_WdZbu.d.ts → logging-ClNhGzus.d.ts} +3 -3
- package/dist/{logging-BOAzMqpM.d.cts → logging-D3kvES69.d.cts} +3 -3
- package/dist/native/index.cjs +724 -227
- package/dist/native/index.d.cts +47 -3
- package/dist/native/index.d.ts +47 -3
- package/dist/native/index.js +628 -135
- package/dist/proto/spark.cjs +499 -8
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark.js +17 -1
- package/dist/proto/spark_token.d.cts +1 -1
- package/dist/proto/spark_token.d.ts +1 -1
- package/dist/proto/spark_token.js +2 -2
- package/dist/{spark-CtGJPkx4.d.cts → spark-C7OG9mGJ.d.cts} +79 -2
- package/dist/{spark-CtGJPkx4.d.ts → spark-C7OG9mGJ.d.ts} +79 -2
- package/dist/{spark-wallet-yc2KhsVY.d.cts → spark-wallet-Dg5IRQe2.d.cts} +3 -5
- package/dist/{spark-wallet-Cp3yv6cK.d.ts → spark-wallet-DiHSU-pz.d.ts} +3 -5
- package/dist/{spark-wallet.node-D4IovOHu.d.ts → spark-wallet.node-BZrxwomN.d.ts} +1 -1
- package/dist/{spark-wallet.node-D0Qw5Wb4.d.cts → spark-wallet.node-DSWb18zh.d.cts} +1 -1
- package/dist/tests/test-utils.cjs +573 -66
- package/dist/tests/test-utils.d.cts +4 -4
- package/dist/tests/test-utils.d.ts +4 -4
- package/dist/tests/test-utils.js +5 -5
- package/dist/{token-transactions-CwhlOgIP.d.cts → token-transactions-B-WqFYpW.d.cts} +2 -2
- package/dist/{token-transactions-0nmR9mQO.d.ts → token-transactions-DovxHIxV.d.ts} +2 -2
- package/dist/types/index.cjs +492 -9
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +2 -2
- package/package.json +1 -1
- package/src/proto/common.ts +1 -1
- package/src/proto/google/protobuf/descriptor.ts +4 -10
- package/src/proto/google/protobuf/duration.ts +1 -1
- package/src/proto/google/protobuf/empty.ts +1 -1
- package/src/proto/google/protobuf/timestamp.ts +1 -1
- package/src/proto/mock.ts +1 -1
- package/src/proto/spark.ts +593 -3
- package/src/proto/spark_authn.ts +1 -1
- package/src/proto/spark_token.ts +1 -1
- package/src/proto/validate/validate.ts +27 -79
- package/src/services/deposit.ts +55 -3
- package/src/services/lightning.ts +2 -2
- package/src/services/signing.ts +1 -1
- package/src/services/token-transactions.ts +2 -5
- package/src/services/transfer.ts +2 -2
- package/src/signer/signer.ts +2 -2
- package/src/spark-wallet/spark-wallet.ts +25 -33
- package/src/tests/address.test.ts +10 -10
- package/src/tests/bitcoin.test.ts +2 -2
- package/src/tests/integration/coop-exit.test.ts +1 -1
- package/src/tests/integration/lightning.test.ts +1 -1
- package/src/tests/integration/ssp/static_deposit.test.ts +122 -1
- package/src/tests/integration/swap.test.ts +1 -1
- package/src/tests/integration/transfer.test.ts +1 -5
- package/src/tests/integration/wallet.test.ts +7 -7
- package/src/tests/integration/watchtower.test.ts +1 -1
- package/src/tests/token-hashing.test.ts +3 -6
- package/src/tests/token-outputs.test.ts +3 -3
- package/src/tests/utils/test-faucet.ts +2 -2
- package/src/types/sdk-types.ts +1 -1
- package/src/utils/adaptor-signature.ts +1 -1
- package/src/utils/address.ts +1 -1
- package/src/utils/bitcoin.ts +1 -5
- package/src/utils/keys.ts +1 -1
- package/src/utils/secret-sharing.ts +1 -1
- package/src/utils/token-transactions.ts +1 -2
- package/src/utils/transfer_package.ts +1 -1
- package/src/utils/unilateral-exit.ts +1 -1
package/dist/bare/index.cjs
CHANGED
|
@@ -1611,8 +1611,8 @@ var NotImplementedError = class extends SparkSDKError {
|
|
|
1611
1611
|
|
|
1612
1612
|
// src/spark-wallet/spark-wallet.ts
|
|
1613
1613
|
var import_core13 = require("@lightsparkdev/core");
|
|
1614
|
-
var import_utils24 = require("@noble/curves/abstract/utils");
|
|
1615
1614
|
var import_secp256k115 = require("@noble/curves/secp256k1");
|
|
1615
|
+
var import_utils23 = require("@noble/curves/utils");
|
|
1616
1616
|
var import_bip392 = require("@scure/bip39");
|
|
1617
1617
|
var import_english2 = require("@scure/bip39/wordlists/english");
|
|
1618
1618
|
var import_btc_signer6 = require("@scure/btc-signer");
|
|
@@ -4185,6 +4185,41 @@ function utxoSwapRequestTypeToJSON(object) {
|
|
|
4185
4185
|
return "UNRECOGNIZED";
|
|
4186
4186
|
}
|
|
4187
4187
|
}
|
|
4188
|
+
function invoiceStatusFromJSON(object) {
|
|
4189
|
+
switch (object) {
|
|
4190
|
+
case 0:
|
|
4191
|
+
case "NOT_FOUND":
|
|
4192
|
+
return 0 /* NOT_FOUND */;
|
|
4193
|
+
case 1:
|
|
4194
|
+
case "PENDING":
|
|
4195
|
+
return 1 /* PENDING */;
|
|
4196
|
+
case 2:
|
|
4197
|
+
case "FINALIZED":
|
|
4198
|
+
return 2 /* FINALIZED */;
|
|
4199
|
+
case 3:
|
|
4200
|
+
case "EXPIRED":
|
|
4201
|
+
return 3 /* EXPIRED */;
|
|
4202
|
+
case -1:
|
|
4203
|
+
case "UNRECOGNIZED":
|
|
4204
|
+
default:
|
|
4205
|
+
return -1 /* UNRECOGNIZED */;
|
|
4206
|
+
}
|
|
4207
|
+
}
|
|
4208
|
+
function invoiceStatusToJSON(object) {
|
|
4209
|
+
switch (object) {
|
|
4210
|
+
case 0 /* NOT_FOUND */:
|
|
4211
|
+
return "NOT_FOUND";
|
|
4212
|
+
case 1 /* PENDING */:
|
|
4213
|
+
return "PENDING";
|
|
4214
|
+
case 2 /* FINALIZED */:
|
|
4215
|
+
return "FINALIZED";
|
|
4216
|
+
case 3 /* EXPIRED */:
|
|
4217
|
+
return "EXPIRED";
|
|
4218
|
+
case -1 /* UNRECOGNIZED */:
|
|
4219
|
+
default:
|
|
4220
|
+
return "UNRECOGNIZED";
|
|
4221
|
+
}
|
|
4222
|
+
}
|
|
4188
4223
|
function initiatePreimageSwapRequest_ReasonFromJSON(object) {
|
|
4189
4224
|
switch (object) {
|
|
4190
4225
|
case 0:
|
|
@@ -4924,6 +4959,140 @@ var GenerateDepositAddressResponse = {
|
|
|
4924
4959
|
return message;
|
|
4925
4960
|
}
|
|
4926
4961
|
};
|
|
4962
|
+
function createBaseGenerateStaticDepositAddressRequest() {
|
|
4963
|
+
return { signingPublicKey: new Uint8Array(0), identityPublicKey: new Uint8Array(0), network: 0 };
|
|
4964
|
+
}
|
|
4965
|
+
var GenerateStaticDepositAddressRequest = {
|
|
4966
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
4967
|
+
if (message.signingPublicKey.length !== 0) {
|
|
4968
|
+
writer.uint32(10).bytes(message.signingPublicKey);
|
|
4969
|
+
}
|
|
4970
|
+
if (message.identityPublicKey.length !== 0) {
|
|
4971
|
+
writer.uint32(18).bytes(message.identityPublicKey);
|
|
4972
|
+
}
|
|
4973
|
+
if (message.network !== 0) {
|
|
4974
|
+
writer.uint32(24).int32(message.network);
|
|
4975
|
+
}
|
|
4976
|
+
return writer;
|
|
4977
|
+
},
|
|
4978
|
+
decode(input, length) {
|
|
4979
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
4980
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
4981
|
+
const message = createBaseGenerateStaticDepositAddressRequest();
|
|
4982
|
+
while (reader.pos < end) {
|
|
4983
|
+
const tag = reader.uint32();
|
|
4984
|
+
switch (tag >>> 3) {
|
|
4985
|
+
case 1: {
|
|
4986
|
+
if (tag !== 10) {
|
|
4987
|
+
break;
|
|
4988
|
+
}
|
|
4989
|
+
message.signingPublicKey = reader.bytes();
|
|
4990
|
+
continue;
|
|
4991
|
+
}
|
|
4992
|
+
case 2: {
|
|
4993
|
+
if (tag !== 18) {
|
|
4994
|
+
break;
|
|
4995
|
+
}
|
|
4996
|
+
message.identityPublicKey = reader.bytes();
|
|
4997
|
+
continue;
|
|
4998
|
+
}
|
|
4999
|
+
case 3: {
|
|
5000
|
+
if (tag !== 24) {
|
|
5001
|
+
break;
|
|
5002
|
+
}
|
|
5003
|
+
message.network = reader.int32();
|
|
5004
|
+
continue;
|
|
5005
|
+
}
|
|
5006
|
+
}
|
|
5007
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
5008
|
+
break;
|
|
5009
|
+
}
|
|
5010
|
+
reader.skip(tag & 7);
|
|
5011
|
+
}
|
|
5012
|
+
return message;
|
|
5013
|
+
},
|
|
5014
|
+
fromJSON(object) {
|
|
5015
|
+
return {
|
|
5016
|
+
signingPublicKey: isSet3(object.signingPublicKey) ? bytesFromBase642(object.signingPublicKey) : new Uint8Array(0),
|
|
5017
|
+
identityPublicKey: isSet3(object.identityPublicKey) ? bytesFromBase642(object.identityPublicKey) : new Uint8Array(0),
|
|
5018
|
+
network: isSet3(object.network) ? networkFromJSON(object.network) : 0
|
|
5019
|
+
};
|
|
5020
|
+
},
|
|
5021
|
+
toJSON(message) {
|
|
5022
|
+
const obj = {};
|
|
5023
|
+
if (message.signingPublicKey.length !== 0) {
|
|
5024
|
+
obj.signingPublicKey = base64FromBytes2(message.signingPublicKey);
|
|
5025
|
+
}
|
|
5026
|
+
if (message.identityPublicKey.length !== 0) {
|
|
5027
|
+
obj.identityPublicKey = base64FromBytes2(message.identityPublicKey);
|
|
5028
|
+
}
|
|
5029
|
+
if (message.network !== 0) {
|
|
5030
|
+
obj.network = networkToJSON(message.network);
|
|
5031
|
+
}
|
|
5032
|
+
return obj;
|
|
5033
|
+
},
|
|
5034
|
+
create(base) {
|
|
5035
|
+
return GenerateStaticDepositAddressRequest.fromPartial(base ?? {});
|
|
5036
|
+
},
|
|
5037
|
+
fromPartial(object) {
|
|
5038
|
+
const message = createBaseGenerateStaticDepositAddressRequest();
|
|
5039
|
+
message.signingPublicKey = object.signingPublicKey ?? new Uint8Array(0);
|
|
5040
|
+
message.identityPublicKey = object.identityPublicKey ?? new Uint8Array(0);
|
|
5041
|
+
message.network = object.network ?? 0;
|
|
5042
|
+
return message;
|
|
5043
|
+
}
|
|
5044
|
+
};
|
|
5045
|
+
function createBaseGenerateStaticDepositAddressResponse() {
|
|
5046
|
+
return { depositAddress: void 0 };
|
|
5047
|
+
}
|
|
5048
|
+
var GenerateStaticDepositAddressResponse = {
|
|
5049
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
5050
|
+
if (message.depositAddress !== void 0) {
|
|
5051
|
+
Address.encode(message.depositAddress, writer.uint32(10).fork()).join();
|
|
5052
|
+
}
|
|
5053
|
+
return writer;
|
|
5054
|
+
},
|
|
5055
|
+
decode(input, length) {
|
|
5056
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
5057
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
5058
|
+
const message = createBaseGenerateStaticDepositAddressResponse();
|
|
5059
|
+
while (reader.pos < end) {
|
|
5060
|
+
const tag = reader.uint32();
|
|
5061
|
+
switch (tag >>> 3) {
|
|
5062
|
+
case 1: {
|
|
5063
|
+
if (tag !== 10) {
|
|
5064
|
+
break;
|
|
5065
|
+
}
|
|
5066
|
+
message.depositAddress = Address.decode(reader, reader.uint32());
|
|
5067
|
+
continue;
|
|
5068
|
+
}
|
|
5069
|
+
}
|
|
5070
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
5071
|
+
break;
|
|
5072
|
+
}
|
|
5073
|
+
reader.skip(tag & 7);
|
|
5074
|
+
}
|
|
5075
|
+
return message;
|
|
5076
|
+
},
|
|
5077
|
+
fromJSON(object) {
|
|
5078
|
+
return { depositAddress: isSet3(object.depositAddress) ? Address.fromJSON(object.depositAddress) : void 0 };
|
|
5079
|
+
},
|
|
5080
|
+
toJSON(message) {
|
|
5081
|
+
const obj = {};
|
|
5082
|
+
if (message.depositAddress !== void 0) {
|
|
5083
|
+
obj.depositAddress = Address.toJSON(message.depositAddress);
|
|
5084
|
+
}
|
|
5085
|
+
return obj;
|
|
5086
|
+
},
|
|
5087
|
+
create(base) {
|
|
5088
|
+
return GenerateStaticDepositAddressResponse.fromPartial(base ?? {});
|
|
5089
|
+
},
|
|
5090
|
+
fromPartial(object) {
|
|
5091
|
+
const message = createBaseGenerateStaticDepositAddressResponse();
|
|
5092
|
+
message.depositAddress = object.depositAddress !== void 0 && object.depositAddress !== null ? Address.fromPartial(object.depositAddress) : void 0;
|
|
5093
|
+
return message;
|
|
5094
|
+
}
|
|
5095
|
+
};
|
|
4927
5096
|
function createBaseUTXO() {
|
|
4928
5097
|
return { rawTx: new Uint8Array(0), vout: 0, network: 0, txid: new Uint8Array(0) };
|
|
4929
5098
|
}
|
|
@@ -11037,7 +11206,8 @@ function createBaseTransferLeaf() {
|
|
|
11037
11206
|
signature: new Uint8Array(0),
|
|
11038
11207
|
intermediateRefundTx: new Uint8Array(0),
|
|
11039
11208
|
intermediateDirectRefundTx: new Uint8Array(0),
|
|
11040
|
-
intermediateDirectFromCpfpRefundTx: new Uint8Array(0)
|
|
11209
|
+
intermediateDirectFromCpfpRefundTx: new Uint8Array(0),
|
|
11210
|
+
pendingKeyTweakPublicKey: new Uint8Array(0)
|
|
11041
11211
|
};
|
|
11042
11212
|
}
|
|
11043
11213
|
var TransferLeaf = {
|
|
@@ -11060,6 +11230,9 @@ var TransferLeaf = {
|
|
|
11060
11230
|
if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
|
|
11061
11231
|
writer.uint32(50).bytes(message.intermediateDirectFromCpfpRefundTx);
|
|
11062
11232
|
}
|
|
11233
|
+
if (message.pendingKeyTweakPublicKey.length !== 0) {
|
|
11234
|
+
writer.uint32(58).bytes(message.pendingKeyTweakPublicKey);
|
|
11235
|
+
}
|
|
11063
11236
|
return writer;
|
|
11064
11237
|
},
|
|
11065
11238
|
decode(input, length) {
|
|
@@ -11111,6 +11284,13 @@ var TransferLeaf = {
|
|
|
11111
11284
|
message.intermediateDirectFromCpfpRefundTx = reader.bytes();
|
|
11112
11285
|
continue;
|
|
11113
11286
|
}
|
|
11287
|
+
case 7: {
|
|
11288
|
+
if (tag !== 58) {
|
|
11289
|
+
break;
|
|
11290
|
+
}
|
|
11291
|
+
message.pendingKeyTweakPublicKey = reader.bytes();
|
|
11292
|
+
continue;
|
|
11293
|
+
}
|
|
11114
11294
|
}
|
|
11115
11295
|
if ((tag & 7) === 4 || tag === 0) {
|
|
11116
11296
|
break;
|
|
@@ -11126,7 +11306,8 @@ var TransferLeaf = {
|
|
|
11126
11306
|
signature: isSet3(object.signature) ? bytesFromBase642(object.signature) : new Uint8Array(0),
|
|
11127
11307
|
intermediateRefundTx: isSet3(object.intermediateRefundTx) ? bytesFromBase642(object.intermediateRefundTx) : new Uint8Array(0),
|
|
11128
11308
|
intermediateDirectRefundTx: isSet3(object.intermediateDirectRefundTx) ? bytesFromBase642(object.intermediateDirectRefundTx) : new Uint8Array(0),
|
|
11129
|
-
intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0)
|
|
11309
|
+
intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0),
|
|
11310
|
+
pendingKeyTweakPublicKey: isSet3(object.pendingKeyTweakPublicKey) ? bytesFromBase642(object.pendingKeyTweakPublicKey) : new Uint8Array(0)
|
|
11130
11311
|
};
|
|
11131
11312
|
},
|
|
11132
11313
|
toJSON(message) {
|
|
@@ -11149,6 +11330,9 @@ var TransferLeaf = {
|
|
|
11149
11330
|
if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
|
|
11150
11331
|
obj.intermediateDirectFromCpfpRefundTx = base64FromBytes2(message.intermediateDirectFromCpfpRefundTx);
|
|
11151
11332
|
}
|
|
11333
|
+
if (message.pendingKeyTweakPublicKey.length !== 0) {
|
|
11334
|
+
obj.pendingKeyTweakPublicKey = base64FromBytes2(message.pendingKeyTweakPublicKey);
|
|
11335
|
+
}
|
|
11152
11336
|
return obj;
|
|
11153
11337
|
},
|
|
11154
11338
|
create(base) {
|
|
@@ -11162,6 +11346,7 @@ var TransferLeaf = {
|
|
|
11162
11346
|
message.intermediateRefundTx = object.intermediateRefundTx ?? new Uint8Array(0);
|
|
11163
11347
|
message.intermediateDirectRefundTx = object.intermediateDirectRefundTx ?? new Uint8Array(0);
|
|
11164
11348
|
message.intermediateDirectFromCpfpRefundTx = object.intermediateDirectFromCpfpRefundTx ?? new Uint8Array(0);
|
|
11349
|
+
message.pendingKeyTweakPublicKey = object.pendingKeyTweakPublicKey ?? new Uint8Array(0);
|
|
11165
11350
|
return message;
|
|
11166
11351
|
}
|
|
11167
11352
|
};
|
|
@@ -14059,13 +14244,16 @@ var QueryUserSignedRefundsRequest = {
|
|
|
14059
14244
|
}
|
|
14060
14245
|
};
|
|
14061
14246
|
function createBaseQueryUserSignedRefundsResponse() {
|
|
14062
|
-
return { userSignedRefunds: [] };
|
|
14247
|
+
return { userSignedRefunds: [], transfer: void 0 };
|
|
14063
14248
|
}
|
|
14064
14249
|
var QueryUserSignedRefundsResponse = {
|
|
14065
14250
|
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
14066
14251
|
for (const v of message.userSignedRefunds) {
|
|
14067
14252
|
UserSignedRefund.encode(v, writer.uint32(10).fork()).join();
|
|
14068
14253
|
}
|
|
14254
|
+
if (message.transfer !== void 0) {
|
|
14255
|
+
Transfer6.encode(message.transfer, writer.uint32(26).fork()).join();
|
|
14256
|
+
}
|
|
14069
14257
|
return writer;
|
|
14070
14258
|
},
|
|
14071
14259
|
decode(input, length) {
|
|
@@ -14082,6 +14270,13 @@ var QueryUserSignedRefundsResponse = {
|
|
|
14082
14270
|
message.userSignedRefunds.push(UserSignedRefund.decode(reader, reader.uint32()));
|
|
14083
14271
|
continue;
|
|
14084
14272
|
}
|
|
14273
|
+
case 3: {
|
|
14274
|
+
if (tag !== 26) {
|
|
14275
|
+
break;
|
|
14276
|
+
}
|
|
14277
|
+
message.transfer = Transfer6.decode(reader, reader.uint32());
|
|
14278
|
+
continue;
|
|
14279
|
+
}
|
|
14085
14280
|
}
|
|
14086
14281
|
if ((tag & 7) === 4 || tag === 0) {
|
|
14087
14282
|
break;
|
|
@@ -14092,7 +14287,8 @@ var QueryUserSignedRefundsResponse = {
|
|
|
14092
14287
|
},
|
|
14093
14288
|
fromJSON(object) {
|
|
14094
14289
|
return {
|
|
14095
|
-
userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : []
|
|
14290
|
+
userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : [],
|
|
14291
|
+
transfer: isSet3(object.transfer) ? Transfer6.fromJSON(object.transfer) : void 0
|
|
14096
14292
|
};
|
|
14097
14293
|
},
|
|
14098
14294
|
toJSON(message) {
|
|
@@ -14100,6 +14296,9 @@ var QueryUserSignedRefundsResponse = {
|
|
|
14100
14296
|
if (message.userSignedRefunds?.length) {
|
|
14101
14297
|
obj.userSignedRefunds = message.userSignedRefunds.map((e) => UserSignedRefund.toJSON(e));
|
|
14102
14298
|
}
|
|
14299
|
+
if (message.transfer !== void 0) {
|
|
14300
|
+
obj.transfer = Transfer6.toJSON(message.transfer);
|
|
14301
|
+
}
|
|
14103
14302
|
return obj;
|
|
14104
14303
|
},
|
|
14105
14304
|
create(base) {
|
|
@@ -14108,6 +14307,7 @@ var QueryUserSignedRefundsResponse = {
|
|
|
14108
14307
|
fromPartial(object) {
|
|
14109
14308
|
const message = createBaseQueryUserSignedRefundsResponse();
|
|
14110
14309
|
message.userSignedRefunds = object.userSignedRefunds?.map((e) => UserSignedRefund.fromPartial(e)) || [];
|
|
14310
|
+
message.transfer = object.transfer !== void 0 && object.transfer !== null ? Transfer6.fromPartial(object.transfer) : void 0;
|
|
14111
14311
|
return message;
|
|
14112
14312
|
}
|
|
14113
14313
|
};
|
|
@@ -14994,7 +15194,8 @@ function createBaseDepositAddressQueryResult() {
|
|
|
14994
15194
|
depositAddress: "",
|
|
14995
15195
|
userSigningPublicKey: new Uint8Array(0),
|
|
14996
15196
|
verifyingPublicKey: new Uint8Array(0),
|
|
14997
|
-
leafId: void 0
|
|
15197
|
+
leafId: void 0,
|
|
15198
|
+
proofOfPossession: void 0
|
|
14998
15199
|
};
|
|
14999
15200
|
}
|
|
15000
15201
|
var DepositAddressQueryResult = {
|
|
@@ -15011,6 +15212,9 @@ var DepositAddressQueryResult = {
|
|
|
15011
15212
|
if (message.leafId !== void 0) {
|
|
15012
15213
|
writer.uint32(34).string(message.leafId);
|
|
15013
15214
|
}
|
|
15215
|
+
if (message.proofOfPossession !== void 0) {
|
|
15216
|
+
DepositAddressProof.encode(message.proofOfPossession, writer.uint32(42).fork()).join();
|
|
15217
|
+
}
|
|
15014
15218
|
return writer;
|
|
15015
15219
|
},
|
|
15016
15220
|
decode(input, length) {
|
|
@@ -15048,6 +15252,13 @@ var DepositAddressQueryResult = {
|
|
|
15048
15252
|
message.leafId = reader.string();
|
|
15049
15253
|
continue;
|
|
15050
15254
|
}
|
|
15255
|
+
case 5: {
|
|
15256
|
+
if (tag !== 42) {
|
|
15257
|
+
break;
|
|
15258
|
+
}
|
|
15259
|
+
message.proofOfPossession = DepositAddressProof.decode(reader, reader.uint32());
|
|
15260
|
+
continue;
|
|
15261
|
+
}
|
|
15051
15262
|
}
|
|
15052
15263
|
if ((tag & 7) === 4 || tag === 0) {
|
|
15053
15264
|
break;
|
|
@@ -15061,7 +15272,8 @@ var DepositAddressQueryResult = {
|
|
|
15061
15272
|
depositAddress: isSet3(object.depositAddress) ? globalThis.String(object.depositAddress) : "",
|
|
15062
15273
|
userSigningPublicKey: isSet3(object.userSigningPublicKey) ? bytesFromBase642(object.userSigningPublicKey) : new Uint8Array(0),
|
|
15063
15274
|
verifyingPublicKey: isSet3(object.verifyingPublicKey) ? bytesFromBase642(object.verifyingPublicKey) : new Uint8Array(0),
|
|
15064
|
-
leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0
|
|
15275
|
+
leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0,
|
|
15276
|
+
proofOfPossession: isSet3(object.proofOfPossession) ? DepositAddressProof.fromJSON(object.proofOfPossession) : void 0
|
|
15065
15277
|
};
|
|
15066
15278
|
},
|
|
15067
15279
|
toJSON(message) {
|
|
@@ -15078,6 +15290,9 @@ var DepositAddressQueryResult = {
|
|
|
15078
15290
|
if (message.leafId !== void 0) {
|
|
15079
15291
|
obj.leafId = message.leafId;
|
|
15080
15292
|
}
|
|
15293
|
+
if (message.proofOfPossession !== void 0) {
|
|
15294
|
+
obj.proofOfPossession = DepositAddressProof.toJSON(message.proofOfPossession);
|
|
15295
|
+
}
|
|
15081
15296
|
return obj;
|
|
15082
15297
|
},
|
|
15083
15298
|
create(base) {
|
|
@@ -15089,6 +15304,7 @@ var DepositAddressQueryResult = {
|
|
|
15089
15304
|
message.userSigningPublicKey = object.userSigningPublicKey ?? new Uint8Array(0);
|
|
15090
15305
|
message.verifyingPublicKey = object.verifyingPublicKey ?? new Uint8Array(0);
|
|
15091
15306
|
message.leafId = object.leafId ?? void 0;
|
|
15307
|
+
message.proofOfPossession = object.proofOfPossession !== void 0 && object.proofOfPossession !== null ? DepositAddressProof.fromPartial(object.proofOfPossession) : void 0;
|
|
15092
15308
|
return message;
|
|
15093
15309
|
}
|
|
15094
15310
|
};
|
|
@@ -17053,7 +17269,7 @@ var QueryNodesByValueResponse_NodesEntry = {
|
|
|
17053
17269
|
}
|
|
17054
17270
|
};
|
|
17055
17271
|
function createBaseGetUtxosForAddressRequest() {
|
|
17056
|
-
return { address: "", offset: 0, limit: 0, network: 0 };
|
|
17272
|
+
return { address: "", offset: 0, limit: 0, network: 0, excludeClaimed: false };
|
|
17057
17273
|
}
|
|
17058
17274
|
var GetUtxosForAddressRequest = {
|
|
17059
17275
|
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
@@ -17069,6 +17285,9 @@ var GetUtxosForAddressRequest = {
|
|
|
17069
17285
|
if (message.network !== 0) {
|
|
17070
17286
|
writer.uint32(32).int32(message.network);
|
|
17071
17287
|
}
|
|
17288
|
+
if (message.excludeClaimed !== false) {
|
|
17289
|
+
writer.uint32(40).bool(message.excludeClaimed);
|
|
17290
|
+
}
|
|
17072
17291
|
return writer;
|
|
17073
17292
|
},
|
|
17074
17293
|
decode(input, length) {
|
|
@@ -17106,6 +17325,13 @@ var GetUtxosForAddressRequest = {
|
|
|
17106
17325
|
message.network = reader.int32();
|
|
17107
17326
|
continue;
|
|
17108
17327
|
}
|
|
17328
|
+
case 5: {
|
|
17329
|
+
if (tag !== 40) {
|
|
17330
|
+
break;
|
|
17331
|
+
}
|
|
17332
|
+
message.excludeClaimed = reader.bool();
|
|
17333
|
+
continue;
|
|
17334
|
+
}
|
|
17109
17335
|
}
|
|
17110
17336
|
if ((tag & 7) === 4 || tag === 0) {
|
|
17111
17337
|
break;
|
|
@@ -17119,7 +17345,8 @@ var GetUtxosForAddressRequest = {
|
|
|
17119
17345
|
address: isSet3(object.address) ? globalThis.String(object.address) : "",
|
|
17120
17346
|
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
17121
17347
|
limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
|
|
17122
|
-
network: isSet3(object.network) ? networkFromJSON(object.network) : 0
|
|
17348
|
+
network: isSet3(object.network) ? networkFromJSON(object.network) : 0,
|
|
17349
|
+
excludeClaimed: isSet3(object.excludeClaimed) ? globalThis.Boolean(object.excludeClaimed) : false
|
|
17123
17350
|
};
|
|
17124
17351
|
},
|
|
17125
17352
|
toJSON(message) {
|
|
@@ -17136,6 +17363,9 @@ var GetUtxosForAddressRequest = {
|
|
|
17136
17363
|
if (message.network !== 0) {
|
|
17137
17364
|
obj.network = networkToJSON(message.network);
|
|
17138
17365
|
}
|
|
17366
|
+
if (message.excludeClaimed !== false) {
|
|
17367
|
+
obj.excludeClaimed = message.excludeClaimed;
|
|
17368
|
+
}
|
|
17139
17369
|
return obj;
|
|
17140
17370
|
},
|
|
17141
17371
|
create(base) {
|
|
@@ -17147,6 +17377,7 @@ var GetUtxosForAddressRequest = {
|
|
|
17147
17377
|
message.offset = object.offset ?? 0;
|
|
17148
17378
|
message.limit = object.limit ?? 0;
|
|
17149
17379
|
message.network = object.network ?? 0;
|
|
17380
|
+
message.excludeClaimed = object.excludeClaimed ?? false;
|
|
17150
17381
|
return message;
|
|
17151
17382
|
}
|
|
17152
17383
|
};
|
|
@@ -17218,6 +17449,225 @@ var GetUtxosForAddressResponse = {
|
|
|
17218
17449
|
return message;
|
|
17219
17450
|
}
|
|
17220
17451
|
};
|
|
17452
|
+
function createBaseQuerySparkInvoicesRequest() {
|
|
17453
|
+
return { limit: 0, offset: 0, invoice: [] };
|
|
17454
|
+
}
|
|
17455
|
+
var QuerySparkInvoicesRequest = {
|
|
17456
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
17457
|
+
if (message.limit !== 0) {
|
|
17458
|
+
writer.uint32(8).int64(message.limit);
|
|
17459
|
+
}
|
|
17460
|
+
if (message.offset !== 0) {
|
|
17461
|
+
writer.uint32(16).int64(message.offset);
|
|
17462
|
+
}
|
|
17463
|
+
for (const v of message.invoice) {
|
|
17464
|
+
writer.uint32(26).string(v);
|
|
17465
|
+
}
|
|
17466
|
+
return writer;
|
|
17467
|
+
},
|
|
17468
|
+
decode(input, length) {
|
|
17469
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
17470
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
17471
|
+
const message = createBaseQuerySparkInvoicesRequest();
|
|
17472
|
+
while (reader.pos < end) {
|
|
17473
|
+
const tag = reader.uint32();
|
|
17474
|
+
switch (tag >>> 3) {
|
|
17475
|
+
case 1: {
|
|
17476
|
+
if (tag !== 8) {
|
|
17477
|
+
break;
|
|
17478
|
+
}
|
|
17479
|
+
message.limit = longToNumber2(reader.int64());
|
|
17480
|
+
continue;
|
|
17481
|
+
}
|
|
17482
|
+
case 2: {
|
|
17483
|
+
if (tag !== 16) {
|
|
17484
|
+
break;
|
|
17485
|
+
}
|
|
17486
|
+
message.offset = longToNumber2(reader.int64());
|
|
17487
|
+
continue;
|
|
17488
|
+
}
|
|
17489
|
+
case 3: {
|
|
17490
|
+
if (tag !== 26) {
|
|
17491
|
+
break;
|
|
17492
|
+
}
|
|
17493
|
+
message.invoice.push(reader.string());
|
|
17494
|
+
continue;
|
|
17495
|
+
}
|
|
17496
|
+
}
|
|
17497
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
17498
|
+
break;
|
|
17499
|
+
}
|
|
17500
|
+
reader.skip(tag & 7);
|
|
17501
|
+
}
|
|
17502
|
+
return message;
|
|
17503
|
+
},
|
|
17504
|
+
fromJSON(object) {
|
|
17505
|
+
return {
|
|
17506
|
+
limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
|
|
17507
|
+
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
17508
|
+
invoice: globalThis.Array.isArray(object?.invoice) ? object.invoice.map((e) => globalThis.String(e)) : []
|
|
17509
|
+
};
|
|
17510
|
+
},
|
|
17511
|
+
toJSON(message) {
|
|
17512
|
+
const obj = {};
|
|
17513
|
+
if (message.limit !== 0) {
|
|
17514
|
+
obj.limit = Math.round(message.limit);
|
|
17515
|
+
}
|
|
17516
|
+
if (message.offset !== 0) {
|
|
17517
|
+
obj.offset = Math.round(message.offset);
|
|
17518
|
+
}
|
|
17519
|
+
if (message.invoice?.length) {
|
|
17520
|
+
obj.invoice = message.invoice;
|
|
17521
|
+
}
|
|
17522
|
+
return obj;
|
|
17523
|
+
},
|
|
17524
|
+
create(base) {
|
|
17525
|
+
return QuerySparkInvoicesRequest.fromPartial(base ?? {});
|
|
17526
|
+
},
|
|
17527
|
+
fromPartial(object) {
|
|
17528
|
+
const message = createBaseQuerySparkInvoicesRequest();
|
|
17529
|
+
message.limit = object.limit ?? 0;
|
|
17530
|
+
message.offset = object.offset ?? 0;
|
|
17531
|
+
message.invoice = object.invoice?.map((e) => e) || [];
|
|
17532
|
+
return message;
|
|
17533
|
+
}
|
|
17534
|
+
};
|
|
17535
|
+
function createBaseQuerySparkInvoicesResponse() {
|
|
17536
|
+
return { offset: 0, invoiceStatuses: [] };
|
|
17537
|
+
}
|
|
17538
|
+
var QuerySparkInvoicesResponse = {
|
|
17539
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
17540
|
+
if (message.offset !== 0) {
|
|
17541
|
+
writer.uint32(8).int64(message.offset);
|
|
17542
|
+
}
|
|
17543
|
+
for (const v of message.invoiceStatuses) {
|
|
17544
|
+
InvoiceResponse.encode(v, writer.uint32(18).fork()).join();
|
|
17545
|
+
}
|
|
17546
|
+
return writer;
|
|
17547
|
+
},
|
|
17548
|
+
decode(input, length) {
|
|
17549
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
17550
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
17551
|
+
const message = createBaseQuerySparkInvoicesResponse();
|
|
17552
|
+
while (reader.pos < end) {
|
|
17553
|
+
const tag = reader.uint32();
|
|
17554
|
+
switch (tag >>> 3) {
|
|
17555
|
+
case 1: {
|
|
17556
|
+
if (tag !== 8) {
|
|
17557
|
+
break;
|
|
17558
|
+
}
|
|
17559
|
+
message.offset = longToNumber2(reader.int64());
|
|
17560
|
+
continue;
|
|
17561
|
+
}
|
|
17562
|
+
case 2: {
|
|
17563
|
+
if (tag !== 18) {
|
|
17564
|
+
break;
|
|
17565
|
+
}
|
|
17566
|
+
message.invoiceStatuses.push(InvoiceResponse.decode(reader, reader.uint32()));
|
|
17567
|
+
continue;
|
|
17568
|
+
}
|
|
17569
|
+
}
|
|
17570
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
17571
|
+
break;
|
|
17572
|
+
}
|
|
17573
|
+
reader.skip(tag & 7);
|
|
17574
|
+
}
|
|
17575
|
+
return message;
|
|
17576
|
+
},
|
|
17577
|
+
fromJSON(object) {
|
|
17578
|
+
return {
|
|
17579
|
+
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
17580
|
+
invoiceStatuses: globalThis.Array.isArray(object?.invoiceStatuses) ? object.invoiceStatuses.map((e) => InvoiceResponse.fromJSON(e)) : []
|
|
17581
|
+
};
|
|
17582
|
+
},
|
|
17583
|
+
toJSON(message) {
|
|
17584
|
+
const obj = {};
|
|
17585
|
+
if (message.offset !== 0) {
|
|
17586
|
+
obj.offset = Math.round(message.offset);
|
|
17587
|
+
}
|
|
17588
|
+
if (message.invoiceStatuses?.length) {
|
|
17589
|
+
obj.invoiceStatuses = message.invoiceStatuses.map((e) => InvoiceResponse.toJSON(e));
|
|
17590
|
+
}
|
|
17591
|
+
return obj;
|
|
17592
|
+
},
|
|
17593
|
+
create(base) {
|
|
17594
|
+
return QuerySparkInvoicesResponse.fromPartial(base ?? {});
|
|
17595
|
+
},
|
|
17596
|
+
fromPartial(object) {
|
|
17597
|
+
const message = createBaseQuerySparkInvoicesResponse();
|
|
17598
|
+
message.offset = object.offset ?? 0;
|
|
17599
|
+
message.invoiceStatuses = object.invoiceStatuses?.map((e) => InvoiceResponse.fromPartial(e)) || [];
|
|
17600
|
+
return message;
|
|
17601
|
+
}
|
|
17602
|
+
};
|
|
17603
|
+
function createBaseInvoiceResponse() {
|
|
17604
|
+
return { invoice: "", status: 0 };
|
|
17605
|
+
}
|
|
17606
|
+
var InvoiceResponse = {
|
|
17607
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
17608
|
+
if (message.invoice !== "") {
|
|
17609
|
+
writer.uint32(10).string(message.invoice);
|
|
17610
|
+
}
|
|
17611
|
+
if (message.status !== 0) {
|
|
17612
|
+
writer.uint32(16).int32(message.status);
|
|
17613
|
+
}
|
|
17614
|
+
return writer;
|
|
17615
|
+
},
|
|
17616
|
+
decode(input, length) {
|
|
17617
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
17618
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
17619
|
+
const message = createBaseInvoiceResponse();
|
|
17620
|
+
while (reader.pos < end) {
|
|
17621
|
+
const tag = reader.uint32();
|
|
17622
|
+
switch (tag >>> 3) {
|
|
17623
|
+
case 1: {
|
|
17624
|
+
if (tag !== 10) {
|
|
17625
|
+
break;
|
|
17626
|
+
}
|
|
17627
|
+
message.invoice = reader.string();
|
|
17628
|
+
continue;
|
|
17629
|
+
}
|
|
17630
|
+
case 2: {
|
|
17631
|
+
if (tag !== 16) {
|
|
17632
|
+
break;
|
|
17633
|
+
}
|
|
17634
|
+
message.status = reader.int32();
|
|
17635
|
+
continue;
|
|
17636
|
+
}
|
|
17637
|
+
}
|
|
17638
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
17639
|
+
break;
|
|
17640
|
+
}
|
|
17641
|
+
reader.skip(tag & 7);
|
|
17642
|
+
}
|
|
17643
|
+
return message;
|
|
17644
|
+
},
|
|
17645
|
+
fromJSON(object) {
|
|
17646
|
+
return {
|
|
17647
|
+
invoice: isSet3(object.invoice) ? globalThis.String(object.invoice) : "",
|
|
17648
|
+
status: isSet3(object.status) ? invoiceStatusFromJSON(object.status) : 0
|
|
17649
|
+
};
|
|
17650
|
+
},
|
|
17651
|
+
toJSON(message) {
|
|
17652
|
+
const obj = {};
|
|
17653
|
+
if (message.invoice !== "") {
|
|
17654
|
+
obj.invoice = message.invoice;
|
|
17655
|
+
}
|
|
17656
|
+
if (message.status !== 0) {
|
|
17657
|
+
obj.status = invoiceStatusToJSON(message.status);
|
|
17658
|
+
}
|
|
17659
|
+
return obj;
|
|
17660
|
+
},
|
|
17661
|
+
create(base) {
|
|
17662
|
+
return InvoiceResponse.fromPartial(base ?? {});
|
|
17663
|
+
},
|
|
17664
|
+
fromPartial(object) {
|
|
17665
|
+
const message = createBaseInvoiceResponse();
|
|
17666
|
+
message.invoice = object.invoice ?? "";
|
|
17667
|
+
message.status = object.status ?? 0;
|
|
17668
|
+
return message;
|
|
17669
|
+
}
|
|
17670
|
+
};
|
|
17221
17671
|
var SparkServiceDefinition = {
|
|
17222
17672
|
name: "SparkService",
|
|
17223
17673
|
fullName: "spark.SparkService",
|
|
@@ -17230,6 +17680,15 @@ var SparkServiceDefinition = {
|
|
|
17230
17680
|
responseStream: false,
|
|
17231
17681
|
options: {}
|
|
17232
17682
|
},
|
|
17683
|
+
/** Generates a new static deposit address of the user or returns the existing one for the specified network. */
|
|
17684
|
+
generate_static_deposit_address: {
|
|
17685
|
+
name: "generate_static_deposit_address",
|
|
17686
|
+
requestType: GenerateStaticDepositAddressRequest,
|
|
17687
|
+
requestStream: false,
|
|
17688
|
+
responseType: GenerateStaticDepositAddressResponse,
|
|
17689
|
+
responseStream: false,
|
|
17690
|
+
options: {}
|
|
17691
|
+
},
|
|
17233
17692
|
start_deposit_tree_creation: {
|
|
17234
17693
|
name: "start_deposit_tree_creation",
|
|
17235
17694
|
requestType: StartDepositTreeCreationRequest,
|
|
@@ -17671,6 +18130,14 @@ var SparkServiceDefinition = {
|
|
|
17671
18130
|
responseType: GetUtxosForAddressResponse,
|
|
17672
18131
|
responseStream: false,
|
|
17673
18132
|
options: {}
|
|
18133
|
+
},
|
|
18134
|
+
query_spark_invoices: {
|
|
18135
|
+
name: "query_spark_invoices",
|
|
18136
|
+
requestType: QuerySparkInvoicesRequest,
|
|
18137
|
+
requestStream: false,
|
|
18138
|
+
responseType: QuerySparkInvoicesResponse,
|
|
18139
|
+
responseStream: false,
|
|
18140
|
+
options: {}
|
|
17674
18141
|
}
|
|
17675
18142
|
}
|
|
17676
18143
|
};
|
|
@@ -17735,8 +18202,8 @@ function isSet3(value) {
|
|
|
17735
18202
|
|
|
17736
18203
|
// src/signer/signer.ts
|
|
17737
18204
|
var import_secp256k14 = require("@bitcoinerlab/secp256k1");
|
|
17738
|
-
var import_utils5 = require("@noble/curves/abstract/utils");
|
|
17739
18205
|
var import_secp256k15 = require("@noble/curves/secp256k1");
|
|
18206
|
+
var import_utils5 = require("@noble/curves/utils");
|
|
17740
18207
|
var import_sha22 = require("@noble/hashes/sha2");
|
|
17741
18208
|
var import_bip32 = require("@scure/bip32");
|
|
17742
18209
|
var import_bip39 = require("@scure/bip39");
|
|
@@ -17748,7 +18215,7 @@ var ecies = __toESM(require("eciesjs"), 1);
|
|
|
17748
18215
|
var import_core10 = require("@lightsparkdev/core");
|
|
17749
18216
|
var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
17750
18217
|
var isBun = globalThis.Bun !== void 0;
|
|
17751
|
-
var packageVersion = true ? "0.2.
|
|
18218
|
+
var packageVersion = true ? "0.2.12" : "unknown";
|
|
17752
18219
|
var baseEnvStr = "unknown";
|
|
17753
18220
|
if (isBun) {
|
|
17754
18221
|
const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
|
|
@@ -17767,8 +18234,8 @@ if (isBun) {
|
|
|
17767
18234
|
var clientEnv = `js-spark-sdk/${packageVersion} ${baseEnvStr}`;
|
|
17768
18235
|
|
|
17769
18236
|
// src/utils/keys.ts
|
|
17770
|
-
var import_utils2 = require("@noble/curves/abstract/utils");
|
|
17771
18237
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
|
18238
|
+
var import_utils2 = require("@noble/curves/utils");
|
|
17772
18239
|
function addPublicKeys(a, b) {
|
|
17773
18240
|
if (a.length !== 33 || b.length !== 33) {
|
|
17774
18241
|
throw new ValidationError("Public keys must be 33 bytes", {
|
|
@@ -17865,8 +18332,8 @@ function lastKeyWithTarget(target, keys) {
|
|
|
17865
18332
|
}
|
|
17866
18333
|
|
|
17867
18334
|
// src/utils/secret-sharing.ts
|
|
17868
|
-
var import_utils3 = require("@noble/curves/abstract/utils");
|
|
17869
18335
|
var import_secp256k12 = require("@noble/curves/secp256k1");
|
|
18336
|
+
var import_utils3 = require("@noble/curves/utils");
|
|
17870
18337
|
function getRandomBigInt(max) {
|
|
17871
18338
|
const byteLength = max.toString(2).length + 7 >> 3;
|
|
17872
18339
|
const maxBigInt = max;
|
|
@@ -23153,8 +23620,8 @@ var import_btc_signer3 = require("@scure/btc-signer");
|
|
|
23153
23620
|
var import_uuidv72 = require("uuidv7");
|
|
23154
23621
|
|
|
23155
23622
|
// src/utils/bitcoin.ts
|
|
23156
|
-
var import_utils7 = require("@noble/curves/abstract/utils");
|
|
23157
23623
|
var import_secp256k16 = require("@noble/curves/secp256k1");
|
|
23624
|
+
var import_utils7 = require("@noble/curves/utils");
|
|
23158
23625
|
var import_sha24 = require("@noble/hashes/sha2");
|
|
23159
23626
|
var btc2 = __toESM(require("@scure/btc-signer"), 1);
|
|
23160
23627
|
function computeTaprootKeyNoScript(pubkey) {
|
|
@@ -23640,15 +24107,15 @@ function getEphemeralAnchorOutput() {
|
|
|
23640
24107
|
}
|
|
23641
24108
|
|
|
23642
24109
|
// src/services/transfer.ts
|
|
23643
|
-
var import_utils9 = require("@noble/curves/abstract/utils");
|
|
23644
24110
|
var import_secp256k17 = require("@noble/curves/secp256k1");
|
|
24111
|
+
var import_utils9 = require("@noble/curves/utils");
|
|
23645
24112
|
var import_sha26 = require("@noble/hashes/sha2");
|
|
23646
24113
|
var import_btc_signer2 = require("@scure/btc-signer");
|
|
23647
24114
|
var ecies2 = __toESM(require("eciesjs"), 1);
|
|
23648
24115
|
var import_uuidv7 = require("uuidv7");
|
|
23649
24116
|
|
|
23650
24117
|
// src/utils/transfer_package.ts
|
|
23651
|
-
var import_utils8 = require("@noble/curves/
|
|
24118
|
+
var import_utils8 = require("@noble/curves/utils");
|
|
23652
24119
|
var import_sha25 = require("@noble/hashes/sha2");
|
|
23653
24120
|
function getTransferPackageSigningPayload(transferID, transferPackage) {
|
|
23654
24121
|
const encryptedPayload = transferPackage.keyTweakPackage;
|
|
@@ -25585,7 +26052,8 @@ var DepositService = class {
|
|
|
25585
26052
|
}
|
|
25586
26053
|
async validateDepositAddress({
|
|
25587
26054
|
address: address2,
|
|
25588
|
-
userPubkey
|
|
26055
|
+
userPubkey,
|
|
26056
|
+
verifyCoordinatorProof = false
|
|
25589
26057
|
}) {
|
|
25590
26058
|
if (!address2.depositAddressProof || !address2.depositAddressProof.proofOfPossessionSignature || !address2.depositAddressProof.addressSignatures) {
|
|
25591
26059
|
throw new ValidationError(
|
|
@@ -25623,7 +26091,7 @@ var DepositService = class {
|
|
|
25623
26091
|
}
|
|
25624
26092
|
const addrHash = (0, import_sha28.sha256)(address2.address);
|
|
25625
26093
|
for (const operator of Object.values(this.config.getSigningOperators())) {
|
|
25626
|
-
if (operator.identifier === this.config.getCoordinatorIdentifier()) {
|
|
26094
|
+
if (operator.identifier === this.config.getCoordinatorIdentifier() && !verifyCoordinatorProof) {
|
|
25627
26095
|
continue;
|
|
25628
26096
|
}
|
|
25629
26097
|
const operatorPubkey2 = (0, import_utils10.hexToBytes)(operator.identityPublicKey);
|
|
@@ -25648,6 +26116,46 @@ var DepositService = class {
|
|
|
25648
26116
|
}
|
|
25649
26117
|
}
|
|
25650
26118
|
}
|
|
26119
|
+
async generateStaticDepositAddress({
|
|
26120
|
+
signingPubkey
|
|
26121
|
+
}) {
|
|
26122
|
+
const sparkClient = await this.connectionManager.createSparkClient(
|
|
26123
|
+
this.config.getCoordinatorAddress()
|
|
26124
|
+
);
|
|
26125
|
+
let depositResp;
|
|
26126
|
+
try {
|
|
26127
|
+
depositResp = await sparkClient.generate_static_deposit_address({
|
|
26128
|
+
signingPublicKey: signingPubkey,
|
|
26129
|
+
identityPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
26130
|
+
network: this.config.getNetworkProto()
|
|
26131
|
+
});
|
|
26132
|
+
} catch (error) {
|
|
26133
|
+
throw new NetworkError(
|
|
26134
|
+
"Failed to generate static deposit address",
|
|
26135
|
+
{
|
|
26136
|
+
operation: "generate_static_deposit_address",
|
|
26137
|
+
errorCount: 1,
|
|
26138
|
+
errors: error instanceof Error ? error.message : String(error)
|
|
26139
|
+
},
|
|
26140
|
+
error
|
|
26141
|
+
);
|
|
26142
|
+
}
|
|
26143
|
+
if (!depositResp.depositAddress) {
|
|
26144
|
+
throw new ValidationError(
|
|
26145
|
+
"No static deposit address response from coordinator",
|
|
26146
|
+
{
|
|
26147
|
+
field: "depositAddress",
|
|
26148
|
+
value: depositResp
|
|
26149
|
+
}
|
|
26150
|
+
);
|
|
26151
|
+
}
|
|
26152
|
+
await this.validateDepositAddress({
|
|
26153
|
+
address: depositResp.depositAddress,
|
|
26154
|
+
userPubkey: signingPubkey,
|
|
26155
|
+
verifyCoordinatorProof: true
|
|
26156
|
+
});
|
|
26157
|
+
return depositResp;
|
|
26158
|
+
}
|
|
25651
26159
|
async generateDepositAddress({
|
|
25652
26160
|
signingPubkey,
|
|
25653
26161
|
leafId,
|
|
@@ -26187,8 +26695,8 @@ var DepositService = class {
|
|
|
26187
26695
|
};
|
|
26188
26696
|
|
|
26189
26697
|
// src/services/lightning.ts
|
|
26190
|
-
var import_utils12 = require("@noble/curves/abstract/utils");
|
|
26191
26698
|
var import_secp256k19 = require("@noble/curves/secp256k1");
|
|
26699
|
+
var import_utils12 = require("@noble/curves/utils");
|
|
26192
26700
|
var import_sha29 = require("@noble/hashes/sha2");
|
|
26193
26701
|
var import_uuidv73 = require("uuidv7");
|
|
26194
26702
|
|
|
@@ -26534,14 +27042,14 @@ var LightningService = class {
|
|
|
26534
27042
|
};
|
|
26535
27043
|
|
|
26536
27044
|
// src/services/token-transactions.ts
|
|
26537
|
-
var import_utils17 = require("@noble/curves/abstract/utils");
|
|
26538
27045
|
var import_secp256k112 = require("@noble/curves/secp256k1");
|
|
26539
|
-
var
|
|
27046
|
+
var import_utils16 = require("@noble/curves/utils");
|
|
27047
|
+
var import_utils17 = require("@noble/hashes/utils");
|
|
26540
27048
|
|
|
26541
27049
|
// src/utils/address.ts
|
|
26542
27050
|
var import_wire8 = require("@bufbuild/protobuf/wire");
|
|
26543
|
-
var import_utils13 = require("@noble/curves/abstract/utils");
|
|
26544
27051
|
var import_secp256k110 = require("@noble/curves/secp256k1");
|
|
27052
|
+
var import_utils13 = require("@noble/curves/utils");
|
|
26545
27053
|
var import_utils14 = require("@noble/hashes/utils");
|
|
26546
27054
|
var import_base2 = require("@scure/base");
|
|
26547
27055
|
var import_uuidv74 = require("uuidv7");
|
|
@@ -29026,8 +29534,7 @@ function validateTokenTransaction(finalTokenTransaction, partialTokenTransaction
|
|
|
29026
29534
|
}
|
|
29027
29535
|
|
|
29028
29536
|
// src/utils/token-transactions.ts
|
|
29029
|
-
var import_utils15 = require("@noble/curves/
|
|
29030
|
-
var import_utils16 = require("@scure/btc-signer/utils");
|
|
29537
|
+
var import_utils15 = require("@noble/curves/utils");
|
|
29031
29538
|
function sumAvailableTokens(outputs) {
|
|
29032
29539
|
try {
|
|
29033
29540
|
return outputs.reduce(
|
|
@@ -29062,7 +29569,7 @@ function filterTokenBalanceForTokenIdentifier(tokenBalances, tokenIdentifier) {
|
|
|
29062
29569
|
}
|
|
29063
29570
|
const tokenIdentifierBytes = decodeBech32mTokenIdentifier(tokenIdentifier).tokenIdentifier;
|
|
29064
29571
|
const tokenBalance = [...tokenBalances.entries()].find(
|
|
29065
|
-
([, info]) => (0,
|
|
29572
|
+
([, info]) => (0, import_utils15.equalBytes)(info.tokenMetadata.rawTokenIdentifier, tokenIdentifierBytes)
|
|
29066
29573
|
);
|
|
29067
29574
|
if (!tokenBalance) {
|
|
29068
29575
|
return {
|
|
@@ -29165,14 +29672,14 @@ var TokenTransactionService = class {
|
|
|
29165
29672
|
}
|
|
29166
29673
|
if (this.config.getTokenTransactionVersion() !== "V0" && receiverAddress.sparkInvoiceFields) {
|
|
29167
29674
|
return {
|
|
29168
|
-
receiverPublicKey: (0,
|
|
29675
|
+
receiverPublicKey: (0, import_utils17.hexToBytes)(receiverAddress.identityPublicKey),
|
|
29169
29676
|
rawTokenIdentifier,
|
|
29170
29677
|
tokenAmount: transfer.tokenAmount,
|
|
29171
29678
|
sparkInvoice: transfer.receiverSparkAddress
|
|
29172
29679
|
};
|
|
29173
29680
|
}
|
|
29174
29681
|
return {
|
|
29175
|
-
receiverPublicKey: (0,
|
|
29682
|
+
receiverPublicKey: (0, import_utils17.hexToBytes)(receiverAddress.identityPublicKey),
|
|
29176
29683
|
rawTokenIdentifier,
|
|
29177
29684
|
tokenPublicKey,
|
|
29178
29685
|
// Remove for full v0 deprecation
|
|
@@ -29211,7 +29718,7 @@ var TokenTransactionService = class {
|
|
|
29211
29718
|
const tokenOutputs = tokenOutputData.map((output) => ({
|
|
29212
29719
|
ownerPublicKey: output.receiverPublicKey,
|
|
29213
29720
|
tokenPublicKey: output.tokenPublicKey,
|
|
29214
|
-
tokenAmount: (0,
|
|
29721
|
+
tokenAmount: (0, import_utils16.numberToBytesBE)(output.tokenAmount, 16)
|
|
29215
29722
|
}));
|
|
29216
29723
|
if (availableTokenAmount > totalRequestedAmount) {
|
|
29217
29724
|
const changeAmount = availableTokenAmount - totalRequestedAmount;
|
|
@@ -29219,7 +29726,7 @@ var TokenTransactionService = class {
|
|
|
29219
29726
|
tokenOutputs.push({
|
|
29220
29727
|
ownerPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
29221
29728
|
tokenPublicKey: firstTokenPublicKey,
|
|
29222
|
-
tokenAmount: (0,
|
|
29729
|
+
tokenAmount: (0, import_utils16.numberToBytesBE)(changeAmount, 16)
|
|
29223
29730
|
});
|
|
29224
29731
|
}
|
|
29225
29732
|
return {
|
|
@@ -29250,7 +29757,7 @@ var TokenTransactionService = class {
|
|
|
29250
29757
|
(output) => ({
|
|
29251
29758
|
ownerPublicKey: output.receiverPublicKey,
|
|
29252
29759
|
tokenIdentifier: output.rawTokenIdentifier,
|
|
29253
|
-
tokenAmount: (0,
|
|
29760
|
+
tokenAmount: (0, import_utils16.numberToBytesBE)(output.tokenAmount, 16)
|
|
29254
29761
|
})
|
|
29255
29762
|
);
|
|
29256
29763
|
if (availableTokenAmount > totalRequestedAmount) {
|
|
@@ -29259,7 +29766,7 @@ var TokenTransactionService = class {
|
|
|
29259
29766
|
tokenOutputs.push({
|
|
29260
29767
|
ownerPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
29261
29768
|
tokenIdentifier: firstTokenIdentifierBytes,
|
|
29262
|
-
tokenAmount: (0,
|
|
29769
|
+
tokenAmount: (0, import_utils16.numberToBytesBE)(changeAmount, 16)
|
|
29263
29770
|
});
|
|
29264
29771
|
}
|
|
29265
29772
|
return {
|
|
@@ -29286,7 +29793,7 @@ var TokenTransactionService = class {
|
|
|
29286
29793
|
for (const [_, operator] of Object.entries(
|
|
29287
29794
|
this.config.getSigningOperators()
|
|
29288
29795
|
)) {
|
|
29289
|
-
operatorKeys.push((0,
|
|
29796
|
+
operatorKeys.push((0, import_utils17.hexToBytes)(operator.identityPublicKey));
|
|
29290
29797
|
}
|
|
29291
29798
|
return operatorKeys;
|
|
29292
29799
|
}
|
|
@@ -29370,7 +29877,7 @@ var TokenTransactionService = class {
|
|
|
29370
29877
|
{
|
|
29371
29878
|
field: "revocationCommitment",
|
|
29372
29879
|
value: derivedRevocationCommitment,
|
|
29373
|
-
expected: (0,
|
|
29880
|
+
expected: (0, import_utils16.bytesToHex)(outputsToSpendCommitments[outputIndex]),
|
|
29374
29881
|
outputIndex
|
|
29375
29882
|
}
|
|
29376
29883
|
)
|
|
@@ -29396,7 +29903,7 @@ var TokenTransactionService = class {
|
|
|
29396
29903
|
threshold
|
|
29397
29904
|
);
|
|
29398
29905
|
}
|
|
29399
|
-
return (0,
|
|
29906
|
+
return (0, import_utils16.bytesToHex)(finalTokenTransactionHash);
|
|
29400
29907
|
}
|
|
29401
29908
|
async broadcastTokenTransactionV1(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
|
|
29402
29909
|
const { finalTokenTransaction, finalTokenTransactionHash, threshold } = await this.startTokenTransaction(
|
|
@@ -29410,7 +29917,7 @@ var TokenTransactionService = class {
|
|
|
29410
29917
|
finalTokenTransactionHash,
|
|
29411
29918
|
signingOperators
|
|
29412
29919
|
);
|
|
29413
|
-
return (0,
|
|
29920
|
+
return (0, import_utils16.bytesToHex)(finalTokenTransactionHash);
|
|
29414
29921
|
}
|
|
29415
29922
|
async startTokenTransactionV0(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
|
|
29416
29923
|
const sparkClient = await this.connectionManager.createSparkClient(
|
|
@@ -29634,7 +30141,7 @@ var TokenTransactionService = class {
|
|
|
29634
30141
|
const identityPublicKey = await this.config.signer.getIdentityPublicKey();
|
|
29635
30142
|
const payload = {
|
|
29636
30143
|
finalTokenTransactionHash,
|
|
29637
|
-
operatorIdentityPublicKey: (0,
|
|
30144
|
+
operatorIdentityPublicKey: (0, import_utils17.hexToBytes)(operator.identityPublicKey)
|
|
29638
30145
|
};
|
|
29639
30146
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
29640
30147
|
let operatorSpecificSignatures = [];
|
|
@@ -29849,8 +30356,8 @@ var TokenTransactionService = class {
|
|
|
29849
30356
|
this.config.getCoordinatorAddress()
|
|
29850
30357
|
);
|
|
29851
30358
|
let queryParams = {
|
|
29852
|
-
tokenPublicKeys: issuerPublicKeys?.map(
|
|
29853
|
-
ownerPublicKeys: ownerPublicKeys?.map(
|
|
30359
|
+
tokenPublicKeys: issuerPublicKeys?.map(import_utils17.hexToBytes),
|
|
30360
|
+
ownerPublicKeys: ownerPublicKeys?.map(import_utils17.hexToBytes),
|
|
29854
30361
|
tokenIdentifiers: tokenIdentifiers?.map((identifier) => {
|
|
29855
30362
|
const { tokenIdentifier } = decodeBech32mTokenIdentifier(
|
|
29856
30363
|
identifier,
|
|
@@ -29858,7 +30365,7 @@ var TokenTransactionService = class {
|
|
|
29858
30365
|
);
|
|
29859
30366
|
return tokenIdentifier;
|
|
29860
30367
|
}),
|
|
29861
|
-
tokenTransactionHashes: tokenTransactionHashes?.map(
|
|
30368
|
+
tokenTransactionHashes: tokenTransactionHashes?.map(import_utils17.hexToBytes),
|
|
29862
30369
|
outputIds: outputIds || [],
|
|
29863
30370
|
limit: pageSize,
|
|
29864
30371
|
offset
|
|
@@ -29917,8 +30424,8 @@ var TokenTransactionService = class {
|
|
|
29917
30424
|
this.config.getCoordinatorAddress()
|
|
29918
30425
|
);
|
|
29919
30426
|
let queryParams = {
|
|
29920
|
-
issuerPublicKeys: issuerPublicKeys?.map(
|
|
29921
|
-
ownerPublicKeys: ownerPublicKeys?.map(
|
|
30427
|
+
issuerPublicKeys: issuerPublicKeys?.map(import_utils17.hexToBytes),
|
|
30428
|
+
ownerPublicKeys: ownerPublicKeys?.map(import_utils17.hexToBytes),
|
|
29922
30429
|
tokenIdentifiers: tokenIdentifiers?.map((identifier) => {
|
|
29923
30430
|
const { tokenIdentifier } = decodeBech32mTokenIdentifier(
|
|
29924
30431
|
identifier,
|
|
@@ -29926,7 +30433,7 @@ var TokenTransactionService = class {
|
|
|
29926
30433
|
);
|
|
29927
30434
|
return tokenIdentifier;
|
|
29928
30435
|
}),
|
|
29929
|
-
tokenTransactionHashes: tokenTransactionHashes?.map(
|
|
30436
|
+
tokenTransactionHashes: tokenTransactionHashes?.map(import_utils17.hexToBytes),
|
|
29930
30437
|
outputIds: outputIds || [],
|
|
29931
30438
|
limit: pageSize,
|
|
29932
30439
|
offset
|
|
@@ -29961,7 +30468,7 @@ var TokenTransactionService = class {
|
|
|
29961
30468
|
});
|
|
29962
30469
|
}
|
|
29963
30470
|
const exactMatch = tokenOutputs.find(
|
|
29964
|
-
(item) => (0,
|
|
30471
|
+
(item) => (0, import_utils16.bytesToNumberBE)(item.output.tokenAmount) === tokenAmount
|
|
29965
30472
|
);
|
|
29966
30473
|
if (exactMatch) {
|
|
29967
30474
|
return [exactMatch];
|
|
@@ -29972,7 +30479,7 @@ var TokenTransactionService = class {
|
|
|
29972
30479
|
for (const outputWithPreviousTransactionData of tokenOutputs) {
|
|
29973
30480
|
if (remainingAmount <= 0n) break;
|
|
29974
30481
|
selectedOutputs.push(outputWithPreviousTransactionData);
|
|
29975
|
-
remainingAmount -= (0,
|
|
30482
|
+
remainingAmount -= (0, import_utils16.bytesToNumberBE)(
|
|
29976
30483
|
outputWithPreviousTransactionData.output.tokenAmount
|
|
29977
30484
|
);
|
|
29978
30485
|
}
|
|
@@ -29988,13 +30495,13 @@ var TokenTransactionService = class {
|
|
|
29988
30495
|
if (strategy === "SMALL_FIRST") {
|
|
29989
30496
|
tokenOutputs.sort((a, b) => {
|
|
29990
30497
|
return Number(
|
|
29991
|
-
(0,
|
|
30498
|
+
(0, import_utils16.bytesToNumberBE)(a.output.tokenAmount) - (0, import_utils16.bytesToNumberBE)(b.output.tokenAmount)
|
|
29992
30499
|
);
|
|
29993
30500
|
});
|
|
29994
30501
|
} else {
|
|
29995
30502
|
tokenOutputs.sort((a, b) => {
|
|
29996
30503
|
return Number(
|
|
29997
|
-
(0,
|
|
30504
|
+
(0, import_utils16.bytesToNumberBE)(b.output.tokenAmount) - (0, import_utils16.bytesToNumberBE)(a.output.tokenAmount)
|
|
29998
30505
|
);
|
|
29999
30506
|
});
|
|
30000
30507
|
}
|
|
@@ -30002,7 +30509,7 @@ var TokenTransactionService = class {
|
|
|
30002
30509
|
// Helper function for deciding if the signer public key is the identity public key
|
|
30003
30510
|
async signMessageWithKey(message, publicKey) {
|
|
30004
30511
|
const tokenSignatures = this.config.getTokenSignatures();
|
|
30005
|
-
if ((0,
|
|
30512
|
+
if ((0, import_utils16.bytesToHex)(publicKey) === (0, import_utils16.bytesToHex)(await this.config.signer.getIdentityPublicKey())) {
|
|
30006
30513
|
if (tokenSignatures === "SCHNORR") {
|
|
30007
30514
|
return await this.config.signer.signSchnorrWithIdentityKey(message);
|
|
30008
30515
|
} else {
|
|
@@ -30011,8 +30518,8 @@ var TokenTransactionService = class {
|
|
|
30011
30518
|
} else {
|
|
30012
30519
|
throw new ValidationError("Invalid public key", {
|
|
30013
30520
|
field: "publicKey",
|
|
30014
|
-
value: (0,
|
|
30015
|
-
expected: (0,
|
|
30521
|
+
value: (0, import_utils16.bytesToHex)(publicKey),
|
|
30522
|
+
expected: (0, import_utils16.bytesToHex)(await this.config.signer.getIdentityPublicKey())
|
|
30016
30523
|
});
|
|
30017
30524
|
}
|
|
30018
30525
|
}
|
|
@@ -30075,7 +30582,7 @@ var TokenTransactionService = class {
|
|
|
30075
30582
|
}
|
|
30076
30583
|
const payload = {
|
|
30077
30584
|
finalTokenTransactionHash,
|
|
30078
|
-
operatorIdentityPublicKey: (0,
|
|
30585
|
+
operatorIdentityPublicKey: (0, import_utils17.hexToBytes)(operator.identityPublicKey)
|
|
30079
30586
|
};
|
|
30080
30587
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
30081
30588
|
const ownerSignature = await this.signMessageWithKey(
|
|
@@ -30097,7 +30604,7 @@ var TokenTransactionService = class {
|
|
|
30097
30604
|
}
|
|
30098
30605
|
const payload = {
|
|
30099
30606
|
finalTokenTransactionHash,
|
|
30100
|
-
operatorIdentityPublicKey: (0,
|
|
30607
|
+
operatorIdentityPublicKey: (0, import_utils17.hexToBytes)(operator.identityPublicKey)
|
|
30101
30608
|
};
|
|
30102
30609
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
30103
30610
|
const ownerSignature = await this.signMessageWithKey(
|
|
@@ -30113,7 +30620,7 @@ var TokenTransactionService = class {
|
|
|
30113
30620
|
for (let i = 0; i < transferInput.outputsToSpend.length; i++) {
|
|
30114
30621
|
const payload = {
|
|
30115
30622
|
finalTokenTransactionHash,
|
|
30116
|
-
operatorIdentityPublicKey: (0,
|
|
30623
|
+
operatorIdentityPublicKey: (0, import_utils17.hexToBytes)(operator.identityPublicKey)
|
|
30117
30624
|
};
|
|
30118
30625
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
30119
30626
|
let ownerSignature;
|
|
@@ -30130,7 +30637,7 @@ var TokenTransactionService = class {
|
|
|
30130
30637
|
}
|
|
30131
30638
|
inputTtxoSignaturesPerOperator.push({
|
|
30132
30639
|
ttxoSignatures,
|
|
30133
|
-
operatorIdentityPublicKey: (0,
|
|
30640
|
+
operatorIdentityPublicKey: (0, import_utils17.hexToBytes)(operator.identityPublicKey)
|
|
30134
30641
|
});
|
|
30135
30642
|
}
|
|
30136
30643
|
return inputTtxoSignaturesPerOperator;
|
|
@@ -30142,23 +30649,23 @@ function isTokenTransaction(tokenTransaction) {
|
|
|
30142
30649
|
|
|
30143
30650
|
// src/utils/adaptor-signature.ts
|
|
30144
30651
|
var import_modular = require("@noble/curves/abstract/modular");
|
|
30145
|
-
var import_utils19 = require("@noble/curves/abstract/utils");
|
|
30146
30652
|
var import_secp256k113 = require("@noble/curves/secp256k1");
|
|
30653
|
+
var import_utils18 = require("@noble/curves/utils");
|
|
30147
30654
|
function generateSignatureFromExistingAdaptor(signature, adaptorPrivateKeyBytes) {
|
|
30148
30655
|
const { r, s } = parseSignature(signature);
|
|
30149
|
-
const sBigInt = (0,
|
|
30150
|
-
const tBigInt = (0,
|
|
30656
|
+
const sBigInt = (0, import_utils18.bytesToNumberBE)(s);
|
|
30657
|
+
const tBigInt = (0, import_utils18.bytesToNumberBE)(adaptorPrivateKeyBytes);
|
|
30151
30658
|
const newS = (0, import_modular.mod)(sBigInt - tBigInt, import_secp256k113.secp256k1.CURVE.n);
|
|
30152
|
-
const newSignature = new Uint8Array([...r, ...(0,
|
|
30659
|
+
const newSignature = new Uint8Array([...r, ...(0, import_utils18.numberToBytesBE)(newS, 32)]);
|
|
30153
30660
|
return newSignature;
|
|
30154
30661
|
}
|
|
30155
30662
|
function generateAdaptorFromSignature(signature) {
|
|
30156
30663
|
const adaptorPrivateKey = import_secp256k113.secp256k1.utils.randomPrivateKey();
|
|
30157
30664
|
const { r, s } = parseSignature(signature);
|
|
30158
|
-
const sBigInt = (0,
|
|
30159
|
-
const tBigInt = (0,
|
|
30665
|
+
const sBigInt = (0, import_utils18.bytesToNumberBE)(s);
|
|
30666
|
+
const tBigInt = (0, import_utils18.bytesToNumberBE)(adaptorPrivateKey);
|
|
30160
30667
|
const newS = (0, import_modular.mod)(sBigInt - tBigInt, import_secp256k113.secp256k1.CURVE.n);
|
|
30161
|
-
const newSignature = new Uint8Array([...r, ...(0,
|
|
30668
|
+
const newSignature = new Uint8Array([...r, ...(0, import_utils18.numberToBytesBE)(newS, 32)]);
|
|
30162
30669
|
return {
|
|
30163
30670
|
adaptorSignature: newSignature,
|
|
30164
30671
|
adaptorPrivateKey
|
|
@@ -30175,10 +30682,10 @@ function validateOutboundAdaptorSignature(pubkey, hash, signature, adaptorPubkey
|
|
|
30175
30682
|
}
|
|
30176
30683
|
function applyAdaptorToSignature(pubkey, hash, signature, adaptorPrivateKeyBytes) {
|
|
30177
30684
|
const { r, s } = parseSignature(signature);
|
|
30178
|
-
const sBigInt = (0,
|
|
30179
|
-
const adaptorPrivateKey = (0,
|
|
30685
|
+
const sBigInt = (0, import_utils18.bytesToNumberBE)(s);
|
|
30686
|
+
const adaptorPrivateKey = (0, import_utils18.bytesToNumberBE)(adaptorPrivateKeyBytes);
|
|
30180
30687
|
const newS = (0, import_modular.mod)(sBigInt + adaptorPrivateKey, import_secp256k113.secp256k1.CURVE.n);
|
|
30181
|
-
const newSig = new Uint8Array([...r, ...(0,
|
|
30688
|
+
const newSig = new Uint8Array([...r, ...(0, import_utils18.numberToBytesBE)(newS, 32)]);
|
|
30182
30689
|
try {
|
|
30183
30690
|
if (import_secp256k113.schnorr.verify(newSig, hash, pubkey)) {
|
|
30184
30691
|
return newSig;
|
|
@@ -30187,7 +30694,7 @@ function applyAdaptorToSignature(pubkey, hash, signature, adaptorPrivateKeyBytes
|
|
|
30187
30694
|
console.error("[applyAdaptorToSignature] Addition verification failed:", e);
|
|
30188
30695
|
}
|
|
30189
30696
|
const altS = (0, import_modular.mod)(sBigInt - adaptorPrivateKey, import_secp256k113.secp256k1.CURVE.n);
|
|
30190
|
-
const altSig = new Uint8Array([...r, ...(0,
|
|
30697
|
+
const altSig = new Uint8Array([...r, ...(0, import_utils18.numberToBytesBE)(altS, 32)]);
|
|
30191
30698
|
try {
|
|
30192
30699
|
if (import_secp256k113.schnorr.verify(altSig, hash, pubkey)) {
|
|
30193
30700
|
return altSig;
|
|
@@ -30204,7 +30711,7 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
|
|
|
30204
30711
|
if (hash.length !== 32) {
|
|
30205
30712
|
throw new Error(`wrong size for message (got ${hash.length}, want 32)`);
|
|
30206
30713
|
}
|
|
30207
|
-
const pubKey = import_secp256k113.schnorr.utils.lift_x((0,
|
|
30714
|
+
const pubKey = import_secp256k113.schnorr.utils.lift_x((0, import_utils18.bytesToNumberBE)(pubKeyBytes));
|
|
30208
30715
|
pubKey.assertValidity();
|
|
30209
30716
|
const { r, s } = parseSignature(signature);
|
|
30210
30717
|
const commitmenet = import_secp256k113.schnorr.utils.taggedHash(
|
|
@@ -30216,9 +30723,9 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
|
|
|
30216
30723
|
if (commitmenet.length > 32) {
|
|
30217
30724
|
throw new Error("hash of (r || P || m) too big");
|
|
30218
30725
|
}
|
|
30219
|
-
const e = (0, import_modular.mod)((0,
|
|
30726
|
+
const e = (0, import_modular.mod)((0, import_utils18.bytesToNumberBE)(commitmenet), import_secp256k113.secp256k1.CURVE.n);
|
|
30220
30727
|
const negE = (0, import_modular.mod)(-e, import_secp256k113.secp256k1.CURVE.n);
|
|
30221
|
-
const sG = import_secp256k113.secp256k1.Point.BASE.multiplyUnsafe((0,
|
|
30728
|
+
const sG = import_secp256k113.secp256k1.Point.BASE.multiplyUnsafe((0, import_utils18.bytesToNumberBE)(s));
|
|
30222
30729
|
const eP = pubKey.multiplyUnsafe(negE);
|
|
30223
30730
|
const R = sG.add(eP);
|
|
30224
30731
|
if (R.is0()) {
|
|
@@ -30234,7 +30741,7 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
|
|
|
30234
30741
|
if (newR.y % 2n !== 0n) {
|
|
30235
30742
|
throw new Error("calculated R y-value is odd");
|
|
30236
30743
|
}
|
|
30237
|
-
const rNum = (0,
|
|
30744
|
+
const rNum = (0, import_utils18.bytesToNumberBE)(r);
|
|
30238
30745
|
if (newR.toAffine().x !== rNum) {
|
|
30239
30746
|
throw new Error("calculated R point was not given R");
|
|
30240
30747
|
}
|
|
@@ -30255,15 +30762,15 @@ function parseSignature(signature) {
|
|
|
30255
30762
|
}
|
|
30256
30763
|
const r = signature.slice(0, 32);
|
|
30257
30764
|
const s = signature.slice(32, 64);
|
|
30258
|
-
if ((0,
|
|
30765
|
+
if ((0, import_utils18.bytesToNumberBE)(r) >= import_secp256k113.secp256k1.CURVE.Fp.ORDER) {
|
|
30259
30766
|
throw new ValidationError("Invalid signature: r >= field prime", {
|
|
30260
|
-
rValue: (0,
|
|
30767
|
+
rValue: (0, import_utils18.bytesToNumberBE)(r),
|
|
30261
30768
|
fieldPrime: import_secp256k113.secp256k1.CURVE.Fp.ORDER
|
|
30262
30769
|
});
|
|
30263
30770
|
}
|
|
30264
|
-
if ((0,
|
|
30771
|
+
if ((0, import_utils18.bytesToNumberBE)(s) >= import_secp256k113.secp256k1.CURVE.n) {
|
|
30265
30772
|
throw new ValidationError("Invalid signature: s >= group order", {
|
|
30266
|
-
sValue: (0,
|
|
30773
|
+
sValue: (0, import_utils18.bytesToNumberBE)(s),
|
|
30267
30774
|
groupOrder: import_secp256k113.secp256k1.CURVE.n
|
|
30268
30775
|
});
|
|
30269
30776
|
}
|
|
@@ -30278,7 +30785,7 @@ var import_eventemitter3 = require("eventemitter3");
|
|
|
30278
30785
|
var import_nice_grpc_common3 = require("nice-grpc-common");
|
|
30279
30786
|
|
|
30280
30787
|
// src/services/signing.ts
|
|
30281
|
-
var
|
|
30788
|
+
var import_utils19 = require("@noble/curves/utils");
|
|
30282
30789
|
var SigningService = class {
|
|
30283
30790
|
config;
|
|
30284
30791
|
constructor(config) {
|
|
@@ -30334,7 +30841,7 @@ var SigningService = class {
|
|
|
30334
30841
|
}
|
|
30335
30842
|
const nodeTx = getTxFromRawTxBytes(leaf.leaf.nodeTx);
|
|
30336
30843
|
const cpfpNodeOutPoint = {
|
|
30337
|
-
txid: (0,
|
|
30844
|
+
txid: (0, import_utils19.hexToBytes)(getTxId(nodeTx)),
|
|
30338
30845
|
index: 0
|
|
30339
30846
|
};
|
|
30340
30847
|
const currRefundTx = getTxFromRawTxBytes(leaf.leaf.refundTx);
|
|
@@ -30360,7 +30867,7 @@ var SigningService = class {
|
|
|
30360
30867
|
if (leaf.leaf.directTx.length > 0) {
|
|
30361
30868
|
directNodeTx = getTxFromRawTxBytes(leaf.leaf.directTx);
|
|
30362
30869
|
directNodeOutPoint = {
|
|
30363
|
-
txid: (0,
|
|
30870
|
+
txid: (0, import_utils19.hexToBytes)(getTxId(directNodeTx)),
|
|
30364
30871
|
index: 0
|
|
30365
30872
|
};
|
|
30366
30873
|
}
|
|
@@ -30443,15 +30950,15 @@ var SigningService = class {
|
|
|
30443
30950
|
};
|
|
30444
30951
|
|
|
30445
30952
|
// src/tests/utils/test-faucet.ts
|
|
30446
|
-
var import_utils21 = require("@noble/curves/abstract/utils");
|
|
30447
30953
|
var import_secp256k114 = require("@noble/curves/secp256k1");
|
|
30954
|
+
var import_utils20 = require("@noble/curves/utils");
|
|
30448
30955
|
var btc3 = __toESM(require("@scure/btc-signer"), 1);
|
|
30449
30956
|
var import_btc_signer5 = require("@scure/btc-signer");
|
|
30450
|
-
var
|
|
30451
|
-
var STATIC_FAUCET_KEY = (0,
|
|
30957
|
+
var import_utils21 = require("@scure/btc-signer/utils");
|
|
30958
|
+
var STATIC_FAUCET_KEY = (0, import_utils20.hexToBytes)(
|
|
30452
30959
|
"deadbeef1337cafe4242424242424242deadbeef1337cafe4242424242424242"
|
|
30453
30960
|
);
|
|
30454
|
-
var STATIC_MINING_KEY = (0,
|
|
30961
|
+
var STATIC_MINING_KEY = (0, import_utils20.hexToBytes)(
|
|
30455
30962
|
"1337cafe4242deadbeef4242424242421337cafe4242deadbeef424242424242"
|
|
30456
30963
|
);
|
|
30457
30964
|
var SATS_PER_BTC = 1e8;
|
|
@@ -30514,7 +31021,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
30514
31021
|
if (!scanResult.success || scanResult.unspents.length === 0) {
|
|
30515
31022
|
const blockHash = await this.generateToAddress(1, address2);
|
|
30516
31023
|
const block = await this.getBlock(blockHash[0]);
|
|
30517
|
-
const fundingTx = import_btc_signer5.Transaction.fromRaw((0,
|
|
31024
|
+
const fundingTx = import_btc_signer5.Transaction.fromRaw((0, import_utils20.hexToBytes)(block.tx[0].hex), {
|
|
30518
31025
|
allowUnknownOutputs: true
|
|
30519
31026
|
});
|
|
30520
31027
|
await this.generateToAddress(100, this.miningAddress);
|
|
@@ -30576,13 +31083,13 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
30576
31083
|
},
|
|
30577
31084
|
STATIC_MINING_KEY
|
|
30578
31085
|
);
|
|
30579
|
-
await this.broadcastTx((0,
|
|
31086
|
+
await this.broadcastTx((0, import_utils20.bytesToHex)(signedSplitTx.extract()));
|
|
30580
31087
|
const splitTxId = signedSplitTx.id;
|
|
30581
31088
|
for (let i = 0; i < numCoinsToCreate; i++) {
|
|
30582
31089
|
this.coins.push({
|
|
30583
31090
|
key: STATIC_FAUCET_KEY,
|
|
30584
31091
|
outpoint: {
|
|
30585
|
-
txid: (0,
|
|
31092
|
+
txid: (0, import_utils20.hexToBytes)(splitTxId),
|
|
30586
31093
|
index: i
|
|
30587
31094
|
},
|
|
30588
31095
|
txout: signedSplitTx.getOutput(i)
|
|
@@ -30610,7 +31117,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
30610
31117
|
coinToSend.txout,
|
|
30611
31118
|
coinToSend.key
|
|
30612
31119
|
);
|
|
30613
|
-
await this.broadcastTx((0,
|
|
31120
|
+
await this.broadcastTx((0, import_utils20.bytesToHex)(signedTx.extract()));
|
|
30614
31121
|
}
|
|
30615
31122
|
async signFaucetCoin(unsignedTx, fundingTxOut, key) {
|
|
30616
31123
|
const pubKey = import_secp256k114.secp256k1.getPublicKey(key);
|
|
@@ -30630,7 +31137,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
30630
31137
|
new Array(unsignedTx.inputsLength).fill(fundingTxOut.amount)
|
|
30631
31138
|
);
|
|
30632
31139
|
const merkleRoot = new Uint8Array();
|
|
30633
|
-
const tweakedKey = (0,
|
|
31140
|
+
const tweakedKey = (0, import_utils21.taprootTweakPrivKey)(key, merkleRoot);
|
|
30634
31141
|
if (!tweakedKey)
|
|
30635
31142
|
throw new Error("Invalid private key for taproot tweaking");
|
|
30636
31143
|
const signature = import_secp256k114.schnorr.sign(sighash, tweakedKey);
|
|
@@ -30730,7 +31237,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
30730
31237
|
});
|
|
30731
31238
|
}
|
|
30732
31239
|
const signedTx = await this.signFaucetCoin(tx, coin.txout, coin.key);
|
|
30733
|
-
const txHex = (0,
|
|
31240
|
+
const txHex = (0, import_utils20.bytesToHex)(signedTx.extract());
|
|
30734
31241
|
await this.broadcastTx(txHex);
|
|
30735
31242
|
const randomKey = import_secp256k114.secp256k1.utils.randomPrivateKey();
|
|
30736
31243
|
const randomPubKey = import_secp256k114.secp256k1.getPublicKey(randomKey);
|
|
@@ -30747,18 +31254,18 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
30747
31254
|
};
|
|
30748
31255
|
|
|
30749
31256
|
// src/types/sdk-types.ts
|
|
30750
|
-
var
|
|
31257
|
+
var import_utils22 = require("@noble/curves/utils");
|
|
30751
31258
|
function mapTreeNodeToWalletLeaf(proto) {
|
|
30752
31259
|
return {
|
|
30753
31260
|
id: proto.id,
|
|
30754
31261
|
treeId: proto.treeId,
|
|
30755
31262
|
value: proto.value,
|
|
30756
31263
|
parentNodeId: proto.parentNodeId,
|
|
30757
|
-
nodeTx: (0,
|
|
30758
|
-
refundTx: (0,
|
|
31264
|
+
nodeTx: (0, import_utils22.bytesToHex)(proto.nodeTx),
|
|
31265
|
+
refundTx: (0, import_utils22.bytesToHex)(proto.refundTx),
|
|
30759
31266
|
vout: proto.vout,
|
|
30760
|
-
verifyingPublicKey: (0,
|
|
30761
|
-
ownerIdentityPublicKey: (0,
|
|
31267
|
+
verifyingPublicKey: (0, import_utils22.bytesToHex)(proto.verifyingPublicKey),
|
|
31268
|
+
ownerIdentityPublicKey: (0, import_utils22.bytesToHex)(proto.ownerIdentityPublicKey),
|
|
30762
31269
|
signingKeyshare: proto.signingKeyshare,
|
|
30763
31270
|
status: proto.status,
|
|
30764
31271
|
network: Network[proto.network]
|
|
@@ -30767,14 +31274,14 @@ function mapTreeNodeToWalletLeaf(proto) {
|
|
|
30767
31274
|
function mapTransferLeafToWalletTransferLeaf(proto) {
|
|
30768
31275
|
return {
|
|
30769
31276
|
leaf: proto.leaf ? mapTreeNodeToWalletLeaf(proto.leaf) : void 0,
|
|
30770
|
-
secretCipher: (0,
|
|
30771
|
-
signature: (0,
|
|
30772
|
-
intermediateRefundTx: (0,
|
|
31277
|
+
secretCipher: (0, import_utils22.bytesToHex)(proto.secretCipher),
|
|
31278
|
+
signature: (0, import_utils22.bytesToHex)(proto.signature),
|
|
31279
|
+
intermediateRefundTx: (0, import_utils22.bytesToHex)(proto.intermediateRefundTx)
|
|
30773
31280
|
};
|
|
30774
31281
|
}
|
|
30775
31282
|
function mapTransferToWalletTransfer(proto, identityPublicKey, userRequest) {
|
|
30776
|
-
const receiverIdentityPublicKey = (0,
|
|
30777
|
-
const senderIdentityPublicKey = (0,
|
|
31283
|
+
const receiverIdentityPublicKey = (0, import_utils22.bytesToHex)(proto.receiverIdentityPublicKey);
|
|
31284
|
+
const senderIdentityPublicKey = (0, import_utils22.bytesToHex)(proto.senderIdentityPublicKey);
|
|
30778
31285
|
return {
|
|
30779
31286
|
id: proto.id,
|
|
30780
31287
|
senderIdentityPublicKey,
|
|
@@ -30964,7 +31471,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
30964
31471
|
try {
|
|
30965
31472
|
if (event?.$case === "transfer" && event.transfer.transfer && event.transfer.transfer.type !== 40 /* COUNTER_SWAP */) {
|
|
30966
31473
|
const { senderIdentityPublicKey, receiverIdentityPublicKey } = event.transfer.transfer;
|
|
30967
|
-
if (event.transfer.transfer && !(0,
|
|
31474
|
+
if (event.transfer.transfer && !(0, import_utils23.equalBytes)(senderIdentityPublicKey, receiverIdentityPublicKey)) {
|
|
30968
31475
|
await this.claimTransfer({
|
|
30969
31476
|
transfer: event.transfer.transfer,
|
|
30970
31477
|
emit: true,
|
|
@@ -31129,10 +31636,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31129
31636
|
leavesToIgnore.add(nodeId);
|
|
31130
31637
|
continue;
|
|
31131
31638
|
}
|
|
31132
|
-
if (leaf.status !== operatorLeaf.status || !leaf.signingKeyshare || !operatorLeaf.signingKeyshare || !(0,
|
|
31639
|
+
if (leaf.status !== operatorLeaf.status || !leaf.signingKeyshare || !operatorLeaf.signingKeyshare || !(0, import_utils23.equalBytes)(
|
|
31133
31640
|
leaf.signingKeyshare.publicKey,
|
|
31134
31641
|
operatorLeaf.signingKeyshare.publicKey
|
|
31135
|
-
) || !(0,
|
|
31642
|
+
) || !(0, import_utils23.equalBytes)(leaf.nodeTx, operatorLeaf.nodeTx)) {
|
|
31136
31643
|
leavesToIgnore.add(nodeId);
|
|
31137
31644
|
}
|
|
31138
31645
|
}
|
|
@@ -31183,7 +31690,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31183
31690
|
});
|
|
31184
31691
|
}
|
|
31185
31692
|
verifyKey(pubkey1, pubkey2, verifyingKey) {
|
|
31186
|
-
return (0,
|
|
31693
|
+
return (0, import_utils23.equalBytes)(addPublicKeys(pubkey1, pubkey2), verifyingKey);
|
|
31187
31694
|
}
|
|
31188
31695
|
async selectLeaves(targetAmounts) {
|
|
31189
31696
|
if (targetAmounts.length === 0) {
|
|
@@ -31341,7 +31848,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31341
31848
|
* @returns {Promise<string>} The identity public key as a hex string.
|
|
31342
31849
|
*/
|
|
31343
31850
|
async getIdentityPublicKey() {
|
|
31344
|
-
return (0,
|
|
31851
|
+
return (0, import_utils23.bytesToHex)(await this.config.signer.getIdentityPublicKey());
|
|
31345
31852
|
}
|
|
31346
31853
|
/**
|
|
31347
31854
|
* Gets the Spark address of the wallet.
|
|
@@ -31351,7 +31858,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31351
31858
|
async getSparkAddress() {
|
|
31352
31859
|
if (!this.sparkAddress) {
|
|
31353
31860
|
this.sparkAddress = encodeSparkAddress({
|
|
31354
|
-
identityPublicKey: (0,
|
|
31861
|
+
identityPublicKey: (0, import_utils23.bytesToHex)(
|
|
31355
31862
|
await this.config.signer.getIdentityPublicKey()
|
|
31356
31863
|
),
|
|
31357
31864
|
network: this.config.getNetworkType()
|
|
@@ -31414,7 +31921,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31414
31921
|
$case: "tokensPayment",
|
|
31415
31922
|
tokensPayment: {
|
|
31416
31923
|
tokenIdentifier: decodedTokenIdentifier ?? void 0,
|
|
31417
|
-
amount: amount ? (0,
|
|
31924
|
+
amount: amount ? (0, import_utils23.numberToVarBytesBE)(amount) : void 0
|
|
31418
31925
|
}
|
|
31419
31926
|
};
|
|
31420
31927
|
const invoiceFields = {
|
|
@@ -31422,7 +31929,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31422
31929
|
id: (0, import_uuidv75.uuidv7obj)().bytes,
|
|
31423
31930
|
paymentType: protoPayment,
|
|
31424
31931
|
memo: memo ?? void 0,
|
|
31425
|
-
senderPublicKey: senderPublicKey ? (0,
|
|
31932
|
+
senderPublicKey: senderPublicKey ? (0, import_utils23.hexToBytes)(senderPublicKey) : void 0,
|
|
31426
31933
|
expiryTime: expiryTime ?? void 0
|
|
31427
31934
|
};
|
|
31428
31935
|
validateSparkInvoiceFields(invoiceFields);
|
|
@@ -31435,7 +31942,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31435
31942
|
const signature = await this.config.signer.signSchnorrWithIdentityKey(hash);
|
|
31436
31943
|
return encodeSparkAddressWithSignature(
|
|
31437
31944
|
{
|
|
31438
|
-
identityPublicKey: (0,
|
|
31945
|
+
identityPublicKey: (0, import_utils23.bytesToHex)(identityPublicKey),
|
|
31439
31946
|
network: this.config.getNetworkType(),
|
|
31440
31947
|
sparkInvoiceFields: invoiceFields
|
|
31441
31948
|
},
|
|
@@ -31481,7 +31988,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31481
31988
|
mnemonic = mnemonicOrSeed;
|
|
31482
31989
|
seed = await this.config.signer.mnemonicToSeed(mnemonicOrSeed);
|
|
31483
31990
|
} else {
|
|
31484
|
-
seed = (0,
|
|
31991
|
+
seed = (0, import_utils23.hexToBytes)(mnemonicOrSeed);
|
|
31485
31992
|
}
|
|
31486
31993
|
}
|
|
31487
31994
|
await this.initWalletFromSeed(seed, accountNumber);
|
|
@@ -31503,7 +32010,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31503
32010
|
});
|
|
31504
32011
|
}
|
|
31505
32012
|
this.sparkAddress = encodeSparkAddress({
|
|
31506
|
-
identityPublicKey: (0,
|
|
32013
|
+
identityPublicKey: (0, import_utils23.bytesToHex)(identityPublicKey),
|
|
31507
32014
|
network: this.config.getNetworkType()
|
|
31508
32015
|
});
|
|
31509
32016
|
return this.sparkAddress;
|
|
@@ -31623,7 +32130,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31623
32130
|
directFromCpfpSignatureMap
|
|
31624
32131
|
} = await this.transferService.startSwapSignRefund(
|
|
31625
32132
|
leafKeyTweaks,
|
|
31626
|
-
(0,
|
|
32133
|
+
(0, import_utils23.hexToBytes)(this.config.getSspIdentityPublicKey()),
|
|
31627
32134
|
new Date(Date.now() + 2 * 60 * 1e3)
|
|
31628
32135
|
);
|
|
31629
32136
|
try {
|
|
@@ -31683,18 +32190,18 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31683
32190
|
const userLeaves = [];
|
|
31684
32191
|
userLeaves.push({
|
|
31685
32192
|
leaf_id: transfer.leaves[0].leaf.id,
|
|
31686
|
-
raw_unsigned_refund_transaction: (0,
|
|
32193
|
+
raw_unsigned_refund_transaction: (0, import_utils23.bytesToHex)(
|
|
31687
32194
|
transfer.leaves[0].intermediateRefundTx
|
|
31688
32195
|
),
|
|
31689
|
-
direct_raw_unsigned_refund_transaction: (0,
|
|
32196
|
+
direct_raw_unsigned_refund_transaction: (0, import_utils23.bytesToHex)(
|
|
31690
32197
|
transfer.leaves[0].intermediateDirectRefundTx
|
|
31691
32198
|
),
|
|
31692
|
-
direct_from_cpfp_raw_unsigned_refund_transaction: (0,
|
|
32199
|
+
direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils23.bytesToHex)(
|
|
31693
32200
|
transfer.leaves[0].intermediateDirectFromCpfpRefundTx
|
|
31694
32201
|
),
|
|
31695
|
-
adaptor_added_signature: (0,
|
|
31696
|
-
direct_adaptor_added_signature: (0,
|
|
31697
|
-
direct_from_cpfp_adaptor_added_signature: (0,
|
|
32202
|
+
adaptor_added_signature: (0, import_utils23.bytesToHex)(cpfpAdaptorSignature),
|
|
32203
|
+
direct_adaptor_added_signature: (0, import_utils23.bytesToHex)(directAdaptorSignature),
|
|
32204
|
+
direct_from_cpfp_adaptor_added_signature: (0, import_utils23.bytesToHex)(
|
|
31698
32205
|
directFromCpfpAdaptorSignature
|
|
31699
32206
|
)
|
|
31700
32207
|
});
|
|
@@ -31747,24 +32254,24 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31747
32254
|
}
|
|
31748
32255
|
userLeaves.push({
|
|
31749
32256
|
leaf_id: leaf.leaf.id,
|
|
31750
|
-
raw_unsigned_refund_transaction: (0,
|
|
32257
|
+
raw_unsigned_refund_transaction: (0, import_utils23.bytesToHex)(
|
|
31751
32258
|
leaf.intermediateRefundTx
|
|
31752
32259
|
),
|
|
31753
|
-
direct_raw_unsigned_refund_transaction: (0,
|
|
32260
|
+
direct_raw_unsigned_refund_transaction: (0, import_utils23.bytesToHex)(
|
|
31754
32261
|
leaf.intermediateDirectRefundTx
|
|
31755
32262
|
),
|
|
31756
|
-
direct_from_cpfp_raw_unsigned_refund_transaction: (0,
|
|
32263
|
+
direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils23.bytesToHex)(
|
|
31757
32264
|
leaf.intermediateDirectFromCpfpRefundTx
|
|
31758
32265
|
),
|
|
31759
|
-
adaptor_added_signature: (0,
|
|
31760
|
-
direct_adaptor_added_signature: (0,
|
|
31761
|
-
direct_from_cpfp_adaptor_added_signature: (0,
|
|
32266
|
+
adaptor_added_signature: (0, import_utils23.bytesToHex)(cpfpSignature),
|
|
32267
|
+
direct_adaptor_added_signature: (0, import_utils23.bytesToHex)(directSignature),
|
|
32268
|
+
direct_from_cpfp_adaptor_added_signature: (0, import_utils23.bytesToHex)(
|
|
31762
32269
|
directFromCpfpSignature
|
|
31763
32270
|
)
|
|
31764
32271
|
});
|
|
31765
32272
|
}
|
|
31766
32273
|
const sspClient = this.getSspClient();
|
|
31767
|
-
const cpfpAdaptorPubkey = (0,
|
|
32274
|
+
const cpfpAdaptorPubkey = (0, import_utils23.bytesToHex)(
|
|
31768
32275
|
import_secp256k115.secp256k1.getPublicKey(cpfpAdaptorPrivateKey)
|
|
31769
32276
|
);
|
|
31770
32277
|
if (!cpfpAdaptorPubkey) {
|
|
@@ -31772,13 +32279,13 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31772
32279
|
}
|
|
31773
32280
|
let directAdaptorPubkey;
|
|
31774
32281
|
if (directAdaptorPrivateKey.length > 0) {
|
|
31775
|
-
directAdaptorPubkey = (0,
|
|
32282
|
+
directAdaptorPubkey = (0, import_utils23.bytesToHex)(
|
|
31776
32283
|
import_secp256k115.secp256k1.getPublicKey(directAdaptorPrivateKey)
|
|
31777
32284
|
);
|
|
31778
32285
|
}
|
|
31779
32286
|
let directFromCpfpAdaptorPubkey;
|
|
31780
32287
|
if (directFromCpfpAdaptorPrivateKey.length > 0) {
|
|
31781
|
-
directFromCpfpAdaptorPubkey = (0,
|
|
32288
|
+
directFromCpfpAdaptorPubkey = (0, import_utils23.bytesToHex)(
|
|
31782
32289
|
import_secp256k115.secp256k1.getPublicKey(directFromCpfpAdaptorPrivateKey)
|
|
31783
32290
|
);
|
|
31784
32291
|
}
|
|
@@ -31838,7 +32345,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31838
32345
|
throw new Error(`Leaf not found for node ${nodeId}`);
|
|
31839
32346
|
}
|
|
31840
32347
|
const cpfpNodeTx = getTxFromRawTxBytes(node.nodeTx);
|
|
31841
|
-
const cpfpRefundTxBytes = (0,
|
|
32348
|
+
const cpfpRefundTxBytes = (0, import_utils23.hexToBytes)(leaf.rawUnsignedRefundTransaction);
|
|
31842
32349
|
const cpfpRefundTx = getTxFromRawTxBytes(cpfpRefundTxBytes);
|
|
31843
32350
|
const cpfpSighash = getSigHashFromTx(
|
|
31844
32351
|
cpfpRefundTx,
|
|
@@ -31847,7 +32354,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31847
32354
|
);
|
|
31848
32355
|
const nodePublicKey = node.verifyingPublicKey;
|
|
31849
32356
|
const taprootKey = computeTaprootKeyNoScript(nodePublicKey.slice(1));
|
|
31850
|
-
const cpfpAdaptorSignatureBytes = (0,
|
|
32357
|
+
const cpfpAdaptorSignatureBytes = (0, import_utils23.hexToBytes)(
|
|
31851
32358
|
leaf.adaptorSignedSignature
|
|
31852
32359
|
);
|
|
31853
32360
|
applyAdaptorToSignature(
|
|
@@ -31858,7 +32365,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31858
32365
|
);
|
|
31859
32366
|
if (leaf.directRawUnsignedRefundTransaction) {
|
|
31860
32367
|
const directNodeTx = getTxFromRawTxBytes(node.directTx);
|
|
31861
|
-
const directRefundTxBytes = (0,
|
|
32368
|
+
const directRefundTxBytes = (0, import_utils23.hexToBytes)(
|
|
31862
32369
|
leaf.directRawUnsignedRefundTransaction
|
|
31863
32370
|
);
|
|
31864
32371
|
const directRefundTx = getTxFromRawTxBytes(directRefundTxBytes);
|
|
@@ -31872,7 +32379,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31872
32379
|
`Direct adaptor signed signature missing for node ${nodeId}`
|
|
31873
32380
|
);
|
|
31874
32381
|
}
|
|
31875
|
-
const directAdaptorSignatureBytes = (0,
|
|
32382
|
+
const directAdaptorSignatureBytes = (0, import_utils23.hexToBytes)(
|
|
31876
32383
|
leaf.directAdaptorSignedSignature
|
|
31877
32384
|
);
|
|
31878
32385
|
applyAdaptorToSignature(
|
|
@@ -31883,7 +32390,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31883
32390
|
);
|
|
31884
32391
|
}
|
|
31885
32392
|
if (leaf.directFromCpfpRawUnsignedRefundTransaction) {
|
|
31886
|
-
const directFromCpfpRefundTxBytes = (0,
|
|
32393
|
+
const directFromCpfpRefundTxBytes = (0, import_utils23.hexToBytes)(
|
|
31887
32394
|
leaf.directFromCpfpRawUnsignedRefundTransaction
|
|
31888
32395
|
);
|
|
31889
32396
|
const directFromCpfpRefundTx = getTxFromRawTxBytes(
|
|
@@ -31899,7 +32406,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31899
32406
|
`Direct adaptor signed signature missing for node ${nodeId}`
|
|
31900
32407
|
);
|
|
31901
32408
|
}
|
|
31902
|
-
const directFromCpfpAdaptorSignatureBytes = (0,
|
|
32409
|
+
const directFromCpfpAdaptorSignatureBytes = (0, import_utils23.hexToBytes)(
|
|
31903
32410
|
leaf.directFromCpfpAdaptorSignedSignature
|
|
31904
32411
|
);
|
|
31905
32412
|
applyAdaptorToSignature(
|
|
@@ -31918,9 +32425,9 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31918
32425
|
directFromCpfpSignatureMap
|
|
31919
32426
|
);
|
|
31920
32427
|
const completeResponse = await sspClient.completeLeaveSwap({
|
|
31921
|
-
adaptorSecretKey: (0,
|
|
31922
|
-
directAdaptorSecretKey: (0,
|
|
31923
|
-
directFromCpfpAdaptorSecretKey: (0,
|
|
32428
|
+
adaptorSecretKey: (0, import_utils23.bytesToHex)(cpfpAdaptorPrivateKey),
|
|
32429
|
+
directAdaptorSecretKey: (0, import_utils23.bytesToHex)(directAdaptorPrivateKey),
|
|
32430
|
+
directFromCpfpAdaptorSecretKey: (0, import_utils23.bytesToHex)(
|
|
31924
32431
|
directFromCpfpAdaptorPrivateKey
|
|
31925
32432
|
),
|
|
31926
32433
|
userOutboundTransferExternalId: transfer.id,
|
|
@@ -32015,12 +32522,12 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32015
32522
|
let tokenMetadataMap = /* @__PURE__ */ new Map();
|
|
32016
32523
|
for (const [tokenIdentifier, metadata] of this.tokenMetadata) {
|
|
32017
32524
|
tokenMetadataMap.set(tokenIdentifier, {
|
|
32018
|
-
tokenPublicKey: (0,
|
|
32525
|
+
tokenPublicKey: (0, import_utils23.bytesToHex)(metadata.issuerPublicKey),
|
|
32019
32526
|
rawTokenIdentifier: metadata.tokenIdentifier,
|
|
32020
32527
|
tokenName: metadata.tokenName,
|
|
32021
32528
|
tokenTicker: metadata.tokenTicker,
|
|
32022
32529
|
decimals: metadata.decimals,
|
|
32023
|
-
maxSupply: (0,
|
|
32530
|
+
maxSupply: (0, import_utils23.bytesToNumberBE)(metadata.maxSupply)
|
|
32024
32531
|
});
|
|
32025
32532
|
}
|
|
32026
32533
|
return tokenMetadataMap;
|
|
@@ -32055,7 +32562,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32055
32562
|
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
32056
32563
|
*/
|
|
32057
32564
|
async getSingleUseDepositAddress() {
|
|
32058
|
-
return await this.generateDepositAddress(
|
|
32565
|
+
return await this.generateDepositAddress();
|
|
32059
32566
|
}
|
|
32060
32567
|
/**
|
|
32061
32568
|
* Generates a new static deposit address for receiving bitcoin funds.
|
|
@@ -32064,43 +32571,32 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32064
32571
|
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
32065
32572
|
*/
|
|
32066
32573
|
async getStaticDepositAddress() {
|
|
32067
|
-
|
|
32068
|
-
|
|
32069
|
-
|
|
32070
|
-
|
|
32071
|
-
|
|
32072
|
-
|
|
32073
|
-
|
|
32074
|
-
|
|
32075
|
-
|
|
32076
|
-
}
|
|
32077
|
-
} else {
|
|
32078
|
-
throw error;
|
|
32079
|
-
}
|
|
32574
|
+
const signingPubkey = await this.config.signer.getStaticDepositSigningKey(0);
|
|
32575
|
+
const address2 = await this.depositService.generateStaticDepositAddress({
|
|
32576
|
+
signingPubkey
|
|
32577
|
+
});
|
|
32578
|
+
if (!address2.depositAddress) {
|
|
32579
|
+
throw new RPCError("Failed to generate static deposit address", {
|
|
32580
|
+
method: "generateStaticDepositAddress",
|
|
32581
|
+
params: { signingPubkey }
|
|
32582
|
+
});
|
|
32080
32583
|
}
|
|
32584
|
+
return address2.depositAddress.address;
|
|
32081
32585
|
}
|
|
32082
32586
|
/**
|
|
32083
32587
|
* Generates a deposit address for receiving funds.
|
|
32084
|
-
*
|
|
32085
|
-
* @param {boolean} static - Whether the address is static or single use
|
|
32086
32588
|
* @returns {Promise<string>} A deposit address
|
|
32087
32589
|
* @private
|
|
32088
32590
|
*/
|
|
32089
|
-
async generateDepositAddress(
|
|
32591
|
+
async generateDepositAddress() {
|
|
32090
32592
|
const leafId = (0, import_uuidv75.uuidv7)();
|
|
32091
|
-
|
|
32092
|
-
|
|
32093
|
-
|
|
32094
|
-
}
|
|
32095
|
-
signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
|
|
32096
|
-
type: "leaf" /* LEAF */,
|
|
32097
|
-
path: leafId
|
|
32098
|
-
});
|
|
32099
|
-
}
|
|
32593
|
+
const signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
|
|
32594
|
+
type: "leaf" /* LEAF */,
|
|
32595
|
+
path: leafId
|
|
32596
|
+
});
|
|
32100
32597
|
const address2 = await this.depositService.generateDepositAddress({
|
|
32101
32598
|
signingPubkey,
|
|
32102
|
-
leafId
|
|
32103
|
-
isStatic
|
|
32599
|
+
leafId
|
|
32104
32600
|
});
|
|
32105
32601
|
if (!address2.depositAddress) {
|
|
32106
32602
|
throw new RPCError("Failed to generate deposit address", {
|
|
@@ -32127,7 +32623,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32127
32623
|
* @param offset - Pagination offset (default 0).
|
|
32128
32624
|
* @returns {Promise<{ txid: string, vout: number }[]>} List of confirmed UTXOs.
|
|
32129
32625
|
*/
|
|
32130
|
-
async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0) {
|
|
32626
|
+
async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0, excludeClaimed = false) {
|
|
32131
32627
|
if (!depositAddress) {
|
|
32132
32628
|
throw new ValidationError("Deposit address cannot be empty", {
|
|
32133
32629
|
field: "depositAddress"
|
|
@@ -32141,10 +32637,11 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32141
32637
|
address: depositAddress,
|
|
32142
32638
|
network: NetworkToProto[this.config.getNetwork()],
|
|
32143
32639
|
limit,
|
|
32144
|
-
offset
|
|
32640
|
+
offset,
|
|
32641
|
+
excludeClaimed
|
|
32145
32642
|
});
|
|
32146
32643
|
return response.utxos.map((utxo) => ({
|
|
32147
|
-
txid: (0,
|
|
32644
|
+
txid: (0, import_utils23.bytesToHex)(utxo.txid),
|
|
32148
32645
|
vout: utxo.vout
|
|
32149
32646
|
})) ?? [];
|
|
32150
32647
|
} catch (error) {
|
|
@@ -32214,7 +32711,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32214
32711
|
if (network === BitcoinNetwork_default.FUTURE_VALUE) {
|
|
32215
32712
|
network = BitcoinNetwork_default.REGTEST;
|
|
32216
32713
|
}
|
|
32217
|
-
const depositSecretKey = (0,
|
|
32714
|
+
const depositSecretKey = (0, import_utils23.bytesToHex)(
|
|
32218
32715
|
await this.config.signer.getStaticDepositSecretKey(0)
|
|
32219
32716
|
);
|
|
32220
32717
|
const message = await this.getStaticDepositSigningPayload(
|
|
@@ -32227,7 +32724,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32227
32724
|
);
|
|
32228
32725
|
const hashBuffer = (0, import_sha212.sha256)(message);
|
|
32229
32726
|
const signatureBytes = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
|
|
32230
|
-
const signature = (0,
|
|
32727
|
+
const signature = (0, import_utils23.bytesToHex)(signatureBytes);
|
|
32231
32728
|
const response = await this.sspClient.claimStaticDeposit({
|
|
32232
32729
|
transactionId,
|
|
32233
32730
|
outputIndex,
|
|
@@ -32379,7 +32876,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32379
32876
|
networkJSON.toLowerCase(),
|
|
32380
32877
|
2 /* Refund */,
|
|
32381
32878
|
creditAmountSats,
|
|
32382
|
-
(0,
|
|
32879
|
+
(0, import_utils23.bytesToHex)(spendTxSighash)
|
|
32383
32880
|
);
|
|
32384
32881
|
const hashBuffer = (0, import_sha212.sha256)(message);
|
|
32385
32882
|
const swapResponseUserSignature = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
|
|
@@ -32388,7 +32885,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32388
32885
|
);
|
|
32389
32886
|
const swapResponse = await sparkClient.initiate_static_deposit_utxo_refund({
|
|
32390
32887
|
onChainUtxo: {
|
|
32391
|
-
txid: (0,
|
|
32888
|
+
txid: (0, import_utils23.hexToBytes)(depositTransactionId),
|
|
32392
32889
|
vout: outputIndex,
|
|
32393
32890
|
network: networkType
|
|
32394
32891
|
},
|
|
@@ -32457,7 +32954,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32457
32954
|
creditAmountView.setUint32(0, lowerHalf, true);
|
|
32458
32955
|
creditAmountView.setUint32(4, upperHalf, true);
|
|
32459
32956
|
parts.push(new Uint8Array(creditAmountBuffer));
|
|
32460
|
-
parts.push((0,
|
|
32957
|
+
parts.push((0, import_utils23.hexToBytes)(sspSignature));
|
|
32461
32958
|
const totalLength = parts.reduce((sum, part) => sum + part.length, 0);
|
|
32462
32959
|
const payload = new Uint8Array(totalLength);
|
|
32463
32960
|
let offset = 0;
|
|
@@ -32862,9 +33359,9 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32862
33359
|
});
|
|
32863
33360
|
}
|
|
32864
33361
|
const signerIdentityPublicKey = await this.config.signer.getIdentityPublicKey();
|
|
32865
|
-
const isSelfTransfer = (0,
|
|
33362
|
+
const isSelfTransfer = (0, import_utils23.equalBytes)(
|
|
32866
33363
|
signerIdentityPublicKey,
|
|
32867
|
-
(0,
|
|
33364
|
+
(0, import_utils23.hexToBytes)(receiverAddress.identityPublicKey)
|
|
32868
33365
|
);
|
|
32869
33366
|
return await this.withLeaves(async () => {
|
|
32870
33367
|
let leavesToSend = (await this.selectLeaves([amountSats])).get(
|
|
@@ -32886,7 +33383,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32886
33383
|
);
|
|
32887
33384
|
const transfer = await this.transferService.sendTransferWithKeyTweaks(
|
|
32888
33385
|
leafKeyTweaks,
|
|
32889
|
-
(0,
|
|
33386
|
+
(0, import_utils23.hexToBytes)(receiverAddress.identityPublicKey)
|
|
32890
33387
|
);
|
|
32891
33388
|
const leavesToRemove = new Set(leavesToSend.map((leaf) => leaf.id));
|
|
32892
33389
|
this.leaves = this.leaves.filter((leaf) => !leavesToRemove.has(leaf.id));
|
|
@@ -32902,7 +33399,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32902
33399
|
}
|
|
32903
33400
|
return mapTransferToWalletTransfer(
|
|
32904
33401
|
transfer,
|
|
32905
|
-
(0,
|
|
33402
|
+
(0, import_utils23.bytesToHex)(await this.config.signer.getIdentityPublicKey())
|
|
32906
33403
|
);
|
|
32907
33404
|
});
|
|
32908
33405
|
}
|
|
@@ -33258,7 +33755,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33258
33755
|
const invoice2 = await sspClient.requestLightningReceive({
|
|
33259
33756
|
amountSats: amountSats2,
|
|
33260
33757
|
network: bitcoinNetwork,
|
|
33261
|
-
paymentHash: (0,
|
|
33758
|
+
paymentHash: (0, import_utils23.bytesToHex)(paymentHash),
|
|
33262
33759
|
expirySecs: expirySeconds,
|
|
33263
33760
|
memo: memo2,
|
|
33264
33761
|
includeSparkAddress,
|
|
@@ -33367,7 +33864,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33367
33864
|
const sparkFallbackAddress = decodedInvoice.fallbackAddress;
|
|
33368
33865
|
const paymentHash = decodedInvoice.paymentHash;
|
|
33369
33866
|
if (preferSpark) {
|
|
33370
|
-
if (sparkFallbackAddress === void 0 || isValidSparkFallback((0,
|
|
33867
|
+
if (sparkFallbackAddress === void 0 || isValidSparkFallback((0, import_utils23.hexToBytes)(sparkFallbackAddress)) === false) {
|
|
33371
33868
|
console.warn(
|
|
33372
33869
|
"No valid spark address found in invoice. Defaulting to lightning."
|
|
33373
33870
|
);
|
|
@@ -33421,10 +33918,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33421
33918
|
);
|
|
33422
33919
|
const swapResponse = await this.lightningService.swapNodesForPreimage({
|
|
33423
33920
|
leaves: leavesToSend,
|
|
33424
|
-
receiverIdentityPubkey: (0,
|
|
33921
|
+
receiverIdentityPubkey: (0, import_utils23.hexToBytes)(
|
|
33425
33922
|
this.config.getSspIdentityPublicKey()
|
|
33426
33923
|
),
|
|
33427
|
-
paymentHash: (0,
|
|
33924
|
+
paymentHash: (0, import_utils23.hexToBytes)(paymentHash),
|
|
33428
33925
|
isInboundPayment: false,
|
|
33429
33926
|
invoiceString: invoice,
|
|
33430
33927
|
feeSats: feeEstimate,
|
|
@@ -33542,7 +34039,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33542
34039
|
});
|
|
33543
34040
|
await this.syncTokenOutputs();
|
|
33544
34041
|
const bech32mTokenIdentifier = encodeBech32mTokenIdentifier({
|
|
33545
|
-
tokenIdentifier: (0,
|
|
34042
|
+
tokenIdentifier: (0, import_utils23.hexToBytes)(firstTokenIdentifierHexSeen),
|
|
33546
34043
|
network: this.config.getNetworkType()
|
|
33547
34044
|
});
|
|
33548
34045
|
const receiverOutputs = decoded.map((d) => ({
|
|
@@ -33730,11 +34227,11 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33730
34227
|
const connectorOutputs = [];
|
|
33731
34228
|
for (let i = 0; i < connectorTx.outputsLength - 1; i++) {
|
|
33732
34229
|
connectorOutputs.push({
|
|
33733
|
-
txid: (0,
|
|
34230
|
+
txid: (0, import_utils23.hexToBytes)(connectorTxId),
|
|
33734
34231
|
index: i
|
|
33735
34232
|
});
|
|
33736
34233
|
}
|
|
33737
|
-
const sspPubIdentityKey = (0,
|
|
34234
|
+
const sspPubIdentityKey = (0, import_utils23.hexToBytes)(this.config.getSspIdentityPublicKey());
|
|
33738
34235
|
const transfer = await this.coopExitService.getConnectorRefundSignatures({
|
|
33739
34236
|
leaves: leafKeyTweaks,
|
|
33740
34237
|
exitTxId: coopExitTxId,
|
|
@@ -33788,7 +34285,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33788
34285
|
return transfers?.[0];
|
|
33789
34286
|
}
|
|
33790
34287
|
async constructTransfersWithUserRequest(transfers) {
|
|
33791
|
-
const identityPublicKey = (0,
|
|
34288
|
+
const identityPublicKey = (0, import_utils23.bytesToHex)(
|
|
33792
34289
|
await this.config.signer.getIdentityPublicKey()
|
|
33793
34290
|
);
|
|
33794
34291
|
const userRequests = await this.sspClient?.getTransfers(
|
|
@@ -34032,7 +34529,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34032
34529
|
hash,
|
|
34033
34530
|
compact
|
|
34034
34531
|
);
|
|
34035
|
-
return (0,
|
|
34532
|
+
return (0, import_utils23.bytesToHex)(signature);
|
|
34036
34533
|
}
|
|
34037
34534
|
/**
|
|
34038
34535
|
* Validates a message with the identity key.
|
|
@@ -34044,7 +34541,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34044
34541
|
async validateMessageWithIdentityKey(message, signature) {
|
|
34045
34542
|
const hash = (0, import_sha212.sha256)(message);
|
|
34046
34543
|
if (typeof signature === "string") {
|
|
34047
|
-
signature = (0,
|
|
34544
|
+
signature = (0, import_utils23.hexToBytes)(signature);
|
|
34048
34545
|
}
|
|
34049
34546
|
return this.config.signer.validateMessageWithIdentityKey(hash, signature);
|
|
34050
34547
|
}
|
|
@@ -34057,7 +34554,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34057
34554
|
*/
|
|
34058
34555
|
async signTransaction(txHex, keyType = "auto-detect") {
|
|
34059
34556
|
try {
|
|
34060
|
-
const tx = import_btc_signer6.Transaction.fromRaw((0,
|
|
34557
|
+
const tx = import_btc_signer6.Transaction.fromRaw((0, import_utils23.hexToBytes)(txHex));
|
|
34061
34558
|
let publicKey;
|
|
34062
34559
|
switch (keyType.toLowerCase()) {
|
|
34063
34560
|
case "identity":
|
|
@@ -34090,7 +34587,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34090
34587
|
publicKey,
|
|
34091
34588
|
this.config.getNetwork()
|
|
34092
34589
|
);
|
|
34093
|
-
if ((0,
|
|
34590
|
+
if ((0, import_utils23.bytesToHex)(script) === (0, import_utils23.bytesToHex)(identityScript)) {
|
|
34094
34591
|
try {
|
|
34095
34592
|
this.config.signer.signTransactionIndex(tx, i, publicKey);
|
|
34096
34593
|
inputsSigned++;
|
|
@@ -34134,13 +34631,13 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34134
34631
|
depositPubKey,
|
|
34135
34632
|
this.config.getNetwork()
|
|
34136
34633
|
);
|
|
34137
|
-
if ((0,
|
|
34634
|
+
if ((0, import_utils23.bytesToHex)(script) === (0, import_utils23.bytesToHex)(identityScript)) {
|
|
34138
34635
|
return {
|
|
34139
34636
|
publicKey: identityPubKey,
|
|
34140
34637
|
keyType: "identity"
|
|
34141
34638
|
};
|
|
34142
34639
|
}
|
|
34143
|
-
if ((0,
|
|
34640
|
+
if ((0, import_utils23.bytesToHex)(script) === (0, import_utils23.bytesToHex)(depositScript)) {
|
|
34144
34641
|
return {
|
|
34145
34642
|
publicKey: depositPubKey,
|
|
34146
34643
|
keyType: "deposit"
|
|
@@ -34657,7 +35154,7 @@ async function isTxBroadcast(txid, baseUrl, network) {
|
|
|
34657
35154
|
}
|
|
34658
35155
|
|
|
34659
35156
|
// src/utils/unilateral-exit.ts
|
|
34660
|
-
var
|
|
35157
|
+
var import_utils24 = require("@noble/curves/utils");
|
|
34661
35158
|
var import_legacy = require("@noble/hashes/legacy");
|
|
34662
35159
|
var import_sha213 = require("@noble/hashes/sha2");
|
|
34663
35160
|
var btc4 = __toESM(require("@scure/btc-signer"), 1);
|
|
@@ -34672,7 +35169,7 @@ function isEphemeralAnchorOutput(script, amount) {
|
|
|
34672
35169
|
}
|
|
34673
35170
|
async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network) {
|
|
34674
35171
|
const result = [];
|
|
34675
|
-
const nodes = nodeHexStrings.map((hex) => TreeNode.decode((0,
|
|
35172
|
+
const nodes = nodeHexStrings.map((hex) => TreeNode.decode((0, import_utils24.hexToBytes)(hex)));
|
|
34676
35173
|
const nodeMap = /* @__PURE__ */ new Map();
|
|
34677
35174
|
for (const node of nodes) {
|
|
34678
35175
|
nodeMap.set(node.id, node);
|
|
@@ -34728,10 +35225,10 @@ async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network)
|
|
|
34728
35225
|
}
|
|
34729
35226
|
}
|
|
34730
35227
|
for (const chainNode of chain) {
|
|
34731
|
-
const nodeTx = (0,
|
|
35228
|
+
const nodeTx = (0, import_utils24.bytesToHex)(chainNode.nodeTx);
|
|
34732
35229
|
transactions.push(nodeTx);
|
|
34733
35230
|
if (chainNode.id === node.id) {
|
|
34734
|
-
const refundTx = (0,
|
|
35231
|
+
const refundTx = (0, import_utils24.bytesToHex)(chainNode.refundTx);
|
|
34735
35232
|
transactions.push(refundTx);
|
|
34736
35233
|
}
|
|
34737
35234
|
}
|
|
@@ -34761,7 +35258,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
34761
35258
|
`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.`
|
|
34762
35259
|
);
|
|
34763
35260
|
}
|
|
34764
|
-
const nodeBytes = (0,
|
|
35261
|
+
const nodeBytes = (0, import_utils24.hexToBytes)(hex);
|
|
34765
35262
|
const node = TreeNode.decode(nodeBytes);
|
|
34766
35263
|
if (!node.id) {
|
|
34767
35264
|
throw new Error(
|
|
@@ -34837,7 +35334,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
34837
35334
|
}
|
|
34838
35335
|
}
|
|
34839
35336
|
for (const chainNode of chain) {
|
|
34840
|
-
let nodeTxHex = (0,
|
|
35337
|
+
let nodeTxHex = (0, import_utils24.bytesToHex)(chainNode.nodeTx);
|
|
34841
35338
|
try {
|
|
34842
35339
|
const txObj = getTxFromRawTxHex(nodeTxHex);
|
|
34843
35340
|
const txid = getTxId(txObj);
|
|
@@ -34854,7 +35351,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
34854
35351
|
for (let i = txObj.outputsLength - 1; i >= 0; i--) {
|
|
34855
35352
|
const output = txObj.getOutput(i);
|
|
34856
35353
|
if (output?.amount === 0n && output.script) {
|
|
34857
|
-
anchorOutputScriptHex = (0,
|
|
35354
|
+
anchorOutputScriptHex = (0, import_utils24.bytesToHex)(output.script);
|
|
34858
35355
|
break;
|
|
34859
35356
|
}
|
|
34860
35357
|
}
|
|
@@ -34875,11 +35372,11 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
34875
35372
|
usedUtxos,
|
|
34876
35373
|
correctedParentTx
|
|
34877
35374
|
} = constructFeeBumpTx(nodeTxHex, availableUtxos, feeRate, void 0);
|
|
34878
|
-
const feeBumpTx = btc4.Transaction.fromPSBT((0,
|
|
35375
|
+
const feeBumpTx = btc4.Transaction.fromPSBT((0, import_utils24.hexToBytes)(nodeFeeBumpPsbt));
|
|
34879
35376
|
var feeBumpOut = feeBumpTx.outputsLength === 1 ? feeBumpTx.getOutput(0) : null;
|
|
34880
35377
|
var feeBumpOutPubKey = null;
|
|
34881
35378
|
for (const usedUtxo of usedUtxos) {
|
|
34882
|
-
if (feeBumpOut && (0,
|
|
35379
|
+
if (feeBumpOut && (0, import_utils24.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
|
|
34883
35380
|
feeBumpOutPubKey = usedUtxo.publicKey;
|
|
34884
35381
|
}
|
|
34885
35382
|
const index = availableUtxos.findIndex(
|
|
@@ -34894,20 +35391,20 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
34894
35391
|
txid: getTxId(feeBumpTx),
|
|
34895
35392
|
vout: 0,
|
|
34896
35393
|
value: feeBumpOut.amount,
|
|
34897
|
-
script: (0,
|
|
35394
|
+
script: (0, import_utils24.bytesToHex)(feeBumpOut.script),
|
|
34898
35395
|
publicKey: feeBumpOutPubKey
|
|
34899
35396
|
});
|
|
34900
35397
|
const finalNodeTx = correctedParentTx || nodeTxHex;
|
|
34901
35398
|
txPackages.push({ tx: finalNodeTx, feeBumpPsbt: nodeFeeBumpPsbt });
|
|
34902
35399
|
if (chainNode.id === node.id) {
|
|
34903
|
-
let refundTxHex = (0,
|
|
35400
|
+
let refundTxHex = (0, import_utils24.bytesToHex)(chainNode.refundTx);
|
|
34904
35401
|
try {
|
|
34905
35402
|
const txObj = getTxFromRawTxHex(refundTxHex);
|
|
34906
35403
|
let anchorOutputScriptHex;
|
|
34907
35404
|
for (let i = txObj.outputsLength - 1; i >= 0; i--) {
|
|
34908
35405
|
const output = txObj.getOutput(i);
|
|
34909
35406
|
if (output?.amount === 0n && output.script) {
|
|
34910
|
-
anchorOutputScriptHex = (0,
|
|
35407
|
+
anchorOutputScriptHex = (0, import_utils24.bytesToHex)(output.script);
|
|
34911
35408
|
break;
|
|
34912
35409
|
}
|
|
34913
35410
|
}
|
|
@@ -34930,12 +35427,12 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
34930
35427
|
void 0
|
|
34931
35428
|
);
|
|
34932
35429
|
const feeBumpTx2 = btc4.Transaction.fromPSBT(
|
|
34933
|
-
(0,
|
|
35430
|
+
(0, import_utils24.hexToBytes)(refundFeeBump.feeBumpPsbt)
|
|
34934
35431
|
);
|
|
34935
35432
|
var feeBumpOut = feeBumpTx2.outputsLength === 1 ? feeBumpTx2.getOutput(0) : null;
|
|
34936
35433
|
var feeBumpOutPubKey = null;
|
|
34937
35434
|
for (const usedUtxo of usedUtxos) {
|
|
34938
|
-
if (feeBumpOut && (0,
|
|
35435
|
+
if (feeBumpOut && (0, import_utils24.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
|
|
34939
35436
|
feeBumpOutPubKey = usedUtxo.publicKey;
|
|
34940
35437
|
}
|
|
34941
35438
|
const index = availableUtxos.findIndex(
|
|
@@ -34950,7 +35447,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
34950
35447
|
txid: getTxId(feeBumpTx2),
|
|
34951
35448
|
vout: 0,
|
|
34952
35449
|
value: feeBumpOut.amount,
|
|
34953
|
-
script: (0,
|
|
35450
|
+
script: (0, import_utils24.bytesToHex)(feeBumpOut.script),
|
|
34954
35451
|
publicKey: feeBumpOutPubKey
|
|
34955
35452
|
});
|
|
34956
35453
|
txPackages.push({
|
|
@@ -35045,10 +35542,10 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
|
|
|
35045
35542
|
if (!fundingUtxo) {
|
|
35046
35543
|
throw new Error(`UTXO at index ${i} is undefined`);
|
|
35047
35544
|
}
|
|
35048
|
-
const pubKeyHash = hash160((0,
|
|
35545
|
+
const pubKeyHash = hash160((0, import_utils24.hexToBytes)(fundingUtxo.publicKey));
|
|
35049
35546
|
const scriptToUse = new Uint8Array([0, 20, ...pubKeyHash]);
|
|
35050
|
-
const providedScript = (0,
|
|
35051
|
-
if ((0,
|
|
35547
|
+
const providedScript = (0, import_utils24.hexToBytes)(fundingUtxo.script);
|
|
35548
|
+
if ((0, import_utils24.bytesToHex)(scriptToUse) !== (0, import_utils24.bytesToHex)(providedScript)) {
|
|
35052
35549
|
throw new Error(
|
|
35053
35550
|
`\u274C Derived script doesn't match provided script for UTXO ${i + 1}.`
|
|
35054
35551
|
);
|
|
@@ -35113,7 +35610,7 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
|
|
|
35113
35610
|
}
|
|
35114
35611
|
let psbtHex;
|
|
35115
35612
|
try {
|
|
35116
|
-
psbtHex = (0,
|
|
35613
|
+
psbtHex = (0, import_utils24.bytesToHex)(builder.toPSBT());
|
|
35117
35614
|
} catch (error) {
|
|
35118
35615
|
throw new Error(`Failed to extract transaction: ${error}`);
|
|
35119
35616
|
}
|