@buildonspark/spark-sdk 0.2.11 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/bare/index.cjs +761 -243
- package/dist/bare/index.d.cts +70 -11
- package/dist/bare/index.d.ts +70 -11
- package/dist/bare/index.js +684 -170
- package/dist/{chunk-A5M55UR3.js → chunk-5VWGOHED.js} +499 -8
- package/dist/{chunk-3WBPICWC.js → chunk-CKHJFQUA.js} +1 -1
- package/dist/{chunk-QNYJGFPD.js → chunk-LX45BCZW.js} +207 -160
- package/dist/{chunk-76SYPHOC.js → chunk-TB7DG5CU.js} +2 -2
- package/dist/{chunk-6CMNEDBK.js → chunk-XXTWWW6L.js} +1 -1
- package/dist/{client-Dd3QnxQu.d.ts → client-D7KDa4Ih.d.ts} +1 -1
- package/dist/{client-B9CAWKWz.d.cts → client-DVuA5-7M.d.cts} +1 -1
- package/dist/debug.cjs +761 -243
- package/dist/debug.d.cts +4 -4
- package/dist/debug.d.ts +4 -4
- package/dist/debug.js +4 -4
- package/dist/graphql/objects/index.d.cts +3 -3
- package/dist/graphql/objects/index.d.ts +3 -3
- package/dist/index.cjs +783 -265
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +5 -5
- package/dist/index.node.cjs +783 -265
- package/dist/index.node.d.cts +6 -6
- package/dist/index.node.d.ts +6 -6
- package/dist/index.node.js +4 -4
- package/dist/{logging-BOAzMqpM.d.cts → logging-BfTyKwqb.d.cts} +3 -3
- package/dist/{logging-Bt_WdZbu.d.ts → logging-CaNpBgiE.d.ts} +3 -3
- package/dist/native/index.cjs +782 -264
- package/dist/native/index.d.cts +70 -11
- package/dist/native/index.d.ts +70 -11
- package/dist/native/index.js +686 -172
- package/dist/proto/spark.cjs +499 -8
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark.js +17 -1
- package/dist/proto/spark_token.d.cts +1 -1
- package/dist/proto/spark_token.d.ts +1 -1
- package/dist/proto/spark_token.js +2 -2
- package/dist/{spark-CtGJPkx4.d.cts → spark-C7OG9mGJ.d.cts} +79 -2
- package/dist/{spark-CtGJPkx4.d.ts → spark-C7OG9mGJ.d.ts} +79 -2
- package/dist/{spark-wallet-Cp3yv6cK.d.ts → spark-wallet-D0Df_P_x.d.ts} +26 -13
- package/dist/{spark-wallet-yc2KhsVY.d.cts → spark-wallet-Dvh1BLP6.d.cts} +26 -13
- package/dist/{spark-wallet.node-D0Qw5Wb4.d.cts → spark-wallet.node-B3V8_fgw.d.cts} +1 -1
- package/dist/{spark-wallet.node-D4IovOHu.d.ts → spark-wallet.node-bGmy8-T8.d.ts} +1 -1
- package/dist/tests/test-utils.cjs +573 -66
- package/dist/tests/test-utils.d.cts +4 -4
- package/dist/tests/test-utils.d.ts +4 -4
- package/dist/tests/test-utils.js +5 -5
- package/dist/{token-transactions-CwhlOgIP.d.cts → token-transactions-D1ta-sHH.d.cts} +2 -2
- package/dist/{token-transactions-0nmR9mQO.d.ts → token-transactions-DINiKBzd.d.ts} +2 -2
- package/dist/types/index.cjs +492 -9
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +2 -2
- package/package.json +3 -3
- package/src/proto/common.ts +1 -1
- package/src/proto/google/protobuf/descriptor.ts +4 -10
- package/src/proto/google/protobuf/duration.ts +1 -1
- package/src/proto/google/protobuf/empty.ts +1 -1
- package/src/proto/google/protobuf/timestamp.ts +1 -1
- package/src/proto/mock.ts +1 -1
- package/src/proto/spark.ts +593 -3
- package/src/proto/spark_authn.ts +1 -1
- package/src/proto/spark_token.ts +1 -1
- package/src/proto/validate/validate.ts +27 -79
- package/src/services/deposit.ts +55 -3
- package/src/services/lightning.ts +2 -2
- package/src/services/signing.ts +1 -1
- package/src/services/token-transactions.ts +2 -5
- package/src/services/transfer.ts +2 -28
- package/src/signer/signer.ts +2 -2
- package/src/spark-wallet/proto-descriptors.ts +22 -0
- package/src/spark-wallet/proto-hash.ts +743 -0
- package/src/spark-wallet/proto-reflection.ts +193 -0
- package/src/spark-wallet/spark-wallet.ts +95 -57
- package/src/spark_descriptors.pb +0 -0
- package/src/tests/address.test.ts +10 -10
- package/src/tests/bitcoin.test.ts +2 -2
- package/src/tests/bufbuild-reflection.test.ts +151 -0
- package/src/tests/cross-language-hash.test.ts +79 -0
- package/src/tests/integration/address.test.ts +3 -12
- package/src/tests/integration/coop-exit.test.ts +1 -1
- package/src/tests/integration/lightning.test.ts +1 -1
- package/src/tests/integration/ssp/static_deposit.test.ts +128 -1
- package/src/tests/integration/static_deposit.test.ts +26 -0
- package/src/tests/integration/swap.test.ts +1 -1
- package/src/tests/integration/transfer.test.ts +1 -129
- package/src/tests/integration/wallet.test.ts +7 -7
- package/src/tests/integration/watchtower.test.ts +1 -1
- package/src/tests/token-hashing.test.ts +3 -6
- package/src/tests/token-outputs.test.ts +3 -3
- package/src/tests/utils/test-faucet.ts +2 -2
- package/src/types/sdk-types.ts +1 -1
- package/src/utils/adaptor-signature.ts +1 -1
- package/src/utils/address.ts +1 -1
- package/src/utils/bitcoin.ts +1 -5
- package/src/utils/keys.ts +1 -1
- package/src/utils/secret-sharing.ts +1 -1
- package/src/utils/token-transactions.ts +1 -2
- package/src/utils/transfer_package.ts +1 -1
- package/src/utils/unilateral-exit.ts +1 -1
package/dist/debug.cjs
CHANGED
|
@@ -1374,8 +1374,8 @@ init_buffer();
|
|
|
1374
1374
|
// src/spark-wallet/spark-wallet.ts
|
|
1375
1375
|
init_buffer();
|
|
1376
1376
|
var import_core13 = require("@lightsparkdev/core");
|
|
1377
|
-
var import_utils24 = require("@noble/curves/abstract/utils");
|
|
1378
1377
|
var import_secp256k115 = require("@noble/curves/secp256k1");
|
|
1378
|
+
var import_utils23 = require("@noble/curves/utils");
|
|
1379
1379
|
var import_bip392 = require("@scure/bip39");
|
|
1380
1380
|
var import_english2 = require("@scure/bip39/wordlists/english");
|
|
1381
1381
|
var import_btc_signer6 = require("@scure/btc-signer");
|
|
@@ -4174,6 +4174,41 @@ function utxoSwapRequestTypeToJSON(object) {
|
|
|
4174
4174
|
return "UNRECOGNIZED";
|
|
4175
4175
|
}
|
|
4176
4176
|
}
|
|
4177
|
+
function invoiceStatusFromJSON(object) {
|
|
4178
|
+
switch (object) {
|
|
4179
|
+
case 0:
|
|
4180
|
+
case "NOT_FOUND":
|
|
4181
|
+
return 0 /* NOT_FOUND */;
|
|
4182
|
+
case 1:
|
|
4183
|
+
case "PENDING":
|
|
4184
|
+
return 1 /* PENDING */;
|
|
4185
|
+
case 2:
|
|
4186
|
+
case "FINALIZED":
|
|
4187
|
+
return 2 /* FINALIZED */;
|
|
4188
|
+
case 3:
|
|
4189
|
+
case "EXPIRED":
|
|
4190
|
+
return 3 /* EXPIRED */;
|
|
4191
|
+
case -1:
|
|
4192
|
+
case "UNRECOGNIZED":
|
|
4193
|
+
default:
|
|
4194
|
+
return -1 /* UNRECOGNIZED */;
|
|
4195
|
+
}
|
|
4196
|
+
}
|
|
4197
|
+
function invoiceStatusToJSON(object) {
|
|
4198
|
+
switch (object) {
|
|
4199
|
+
case 0 /* NOT_FOUND */:
|
|
4200
|
+
return "NOT_FOUND";
|
|
4201
|
+
case 1 /* PENDING */:
|
|
4202
|
+
return "PENDING";
|
|
4203
|
+
case 2 /* FINALIZED */:
|
|
4204
|
+
return "FINALIZED";
|
|
4205
|
+
case 3 /* EXPIRED */:
|
|
4206
|
+
return "EXPIRED";
|
|
4207
|
+
case -1 /* UNRECOGNIZED */:
|
|
4208
|
+
default:
|
|
4209
|
+
return "UNRECOGNIZED";
|
|
4210
|
+
}
|
|
4211
|
+
}
|
|
4177
4212
|
function initiatePreimageSwapRequest_ReasonFromJSON(object) {
|
|
4178
4213
|
switch (object) {
|
|
4179
4214
|
case 0:
|
|
@@ -4913,6 +4948,140 @@ var GenerateDepositAddressResponse = {
|
|
|
4913
4948
|
return message;
|
|
4914
4949
|
}
|
|
4915
4950
|
};
|
|
4951
|
+
function createBaseGenerateStaticDepositAddressRequest() {
|
|
4952
|
+
return { signingPublicKey: new Uint8Array(0), identityPublicKey: new Uint8Array(0), network: 0 };
|
|
4953
|
+
}
|
|
4954
|
+
var GenerateStaticDepositAddressRequest = {
|
|
4955
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
4956
|
+
if (message.signingPublicKey.length !== 0) {
|
|
4957
|
+
writer.uint32(10).bytes(message.signingPublicKey);
|
|
4958
|
+
}
|
|
4959
|
+
if (message.identityPublicKey.length !== 0) {
|
|
4960
|
+
writer.uint32(18).bytes(message.identityPublicKey);
|
|
4961
|
+
}
|
|
4962
|
+
if (message.network !== 0) {
|
|
4963
|
+
writer.uint32(24).int32(message.network);
|
|
4964
|
+
}
|
|
4965
|
+
return writer;
|
|
4966
|
+
},
|
|
4967
|
+
decode(input, length) {
|
|
4968
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
4969
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
4970
|
+
const message = createBaseGenerateStaticDepositAddressRequest();
|
|
4971
|
+
while (reader.pos < end) {
|
|
4972
|
+
const tag = reader.uint32();
|
|
4973
|
+
switch (tag >>> 3) {
|
|
4974
|
+
case 1: {
|
|
4975
|
+
if (tag !== 10) {
|
|
4976
|
+
break;
|
|
4977
|
+
}
|
|
4978
|
+
message.signingPublicKey = reader.bytes();
|
|
4979
|
+
continue;
|
|
4980
|
+
}
|
|
4981
|
+
case 2: {
|
|
4982
|
+
if (tag !== 18) {
|
|
4983
|
+
break;
|
|
4984
|
+
}
|
|
4985
|
+
message.identityPublicKey = reader.bytes();
|
|
4986
|
+
continue;
|
|
4987
|
+
}
|
|
4988
|
+
case 3: {
|
|
4989
|
+
if (tag !== 24) {
|
|
4990
|
+
break;
|
|
4991
|
+
}
|
|
4992
|
+
message.network = reader.int32();
|
|
4993
|
+
continue;
|
|
4994
|
+
}
|
|
4995
|
+
}
|
|
4996
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
4997
|
+
break;
|
|
4998
|
+
}
|
|
4999
|
+
reader.skip(tag & 7);
|
|
5000
|
+
}
|
|
5001
|
+
return message;
|
|
5002
|
+
},
|
|
5003
|
+
fromJSON(object) {
|
|
5004
|
+
return {
|
|
5005
|
+
signingPublicKey: isSet3(object.signingPublicKey) ? bytesFromBase642(object.signingPublicKey) : new Uint8Array(0),
|
|
5006
|
+
identityPublicKey: isSet3(object.identityPublicKey) ? bytesFromBase642(object.identityPublicKey) : new Uint8Array(0),
|
|
5007
|
+
network: isSet3(object.network) ? networkFromJSON(object.network) : 0
|
|
5008
|
+
};
|
|
5009
|
+
},
|
|
5010
|
+
toJSON(message) {
|
|
5011
|
+
const obj = {};
|
|
5012
|
+
if (message.signingPublicKey.length !== 0) {
|
|
5013
|
+
obj.signingPublicKey = base64FromBytes2(message.signingPublicKey);
|
|
5014
|
+
}
|
|
5015
|
+
if (message.identityPublicKey.length !== 0) {
|
|
5016
|
+
obj.identityPublicKey = base64FromBytes2(message.identityPublicKey);
|
|
5017
|
+
}
|
|
5018
|
+
if (message.network !== 0) {
|
|
5019
|
+
obj.network = networkToJSON(message.network);
|
|
5020
|
+
}
|
|
5021
|
+
return obj;
|
|
5022
|
+
},
|
|
5023
|
+
create(base) {
|
|
5024
|
+
return GenerateStaticDepositAddressRequest.fromPartial(base ?? {});
|
|
5025
|
+
},
|
|
5026
|
+
fromPartial(object) {
|
|
5027
|
+
const message = createBaseGenerateStaticDepositAddressRequest();
|
|
5028
|
+
message.signingPublicKey = object.signingPublicKey ?? new Uint8Array(0);
|
|
5029
|
+
message.identityPublicKey = object.identityPublicKey ?? new Uint8Array(0);
|
|
5030
|
+
message.network = object.network ?? 0;
|
|
5031
|
+
return message;
|
|
5032
|
+
}
|
|
5033
|
+
};
|
|
5034
|
+
function createBaseGenerateStaticDepositAddressResponse() {
|
|
5035
|
+
return { depositAddress: void 0 };
|
|
5036
|
+
}
|
|
5037
|
+
var GenerateStaticDepositAddressResponse = {
|
|
5038
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
5039
|
+
if (message.depositAddress !== void 0) {
|
|
5040
|
+
Address.encode(message.depositAddress, writer.uint32(10).fork()).join();
|
|
5041
|
+
}
|
|
5042
|
+
return writer;
|
|
5043
|
+
},
|
|
5044
|
+
decode(input, length) {
|
|
5045
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
5046
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
5047
|
+
const message = createBaseGenerateStaticDepositAddressResponse();
|
|
5048
|
+
while (reader.pos < end) {
|
|
5049
|
+
const tag = reader.uint32();
|
|
5050
|
+
switch (tag >>> 3) {
|
|
5051
|
+
case 1: {
|
|
5052
|
+
if (tag !== 10) {
|
|
5053
|
+
break;
|
|
5054
|
+
}
|
|
5055
|
+
message.depositAddress = Address.decode(reader, reader.uint32());
|
|
5056
|
+
continue;
|
|
5057
|
+
}
|
|
5058
|
+
}
|
|
5059
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
5060
|
+
break;
|
|
5061
|
+
}
|
|
5062
|
+
reader.skip(tag & 7);
|
|
5063
|
+
}
|
|
5064
|
+
return message;
|
|
5065
|
+
},
|
|
5066
|
+
fromJSON(object) {
|
|
5067
|
+
return { depositAddress: isSet3(object.depositAddress) ? Address.fromJSON(object.depositAddress) : void 0 };
|
|
5068
|
+
},
|
|
5069
|
+
toJSON(message) {
|
|
5070
|
+
const obj = {};
|
|
5071
|
+
if (message.depositAddress !== void 0) {
|
|
5072
|
+
obj.depositAddress = Address.toJSON(message.depositAddress);
|
|
5073
|
+
}
|
|
5074
|
+
return obj;
|
|
5075
|
+
},
|
|
5076
|
+
create(base) {
|
|
5077
|
+
return GenerateStaticDepositAddressResponse.fromPartial(base ?? {});
|
|
5078
|
+
},
|
|
5079
|
+
fromPartial(object) {
|
|
5080
|
+
const message = createBaseGenerateStaticDepositAddressResponse();
|
|
5081
|
+
message.depositAddress = object.depositAddress !== void 0 && object.depositAddress !== null ? Address.fromPartial(object.depositAddress) : void 0;
|
|
5082
|
+
return message;
|
|
5083
|
+
}
|
|
5084
|
+
};
|
|
4916
5085
|
function createBaseUTXO() {
|
|
4917
5086
|
return { rawTx: new Uint8Array(0), vout: 0, network: 0, txid: new Uint8Array(0) };
|
|
4918
5087
|
}
|
|
@@ -11026,7 +11195,8 @@ function createBaseTransferLeaf() {
|
|
|
11026
11195
|
signature: new Uint8Array(0),
|
|
11027
11196
|
intermediateRefundTx: new Uint8Array(0),
|
|
11028
11197
|
intermediateDirectRefundTx: new Uint8Array(0),
|
|
11029
|
-
intermediateDirectFromCpfpRefundTx: new Uint8Array(0)
|
|
11198
|
+
intermediateDirectFromCpfpRefundTx: new Uint8Array(0),
|
|
11199
|
+
pendingKeyTweakPublicKey: new Uint8Array(0)
|
|
11030
11200
|
};
|
|
11031
11201
|
}
|
|
11032
11202
|
var TransferLeaf = {
|
|
@@ -11049,6 +11219,9 @@ var TransferLeaf = {
|
|
|
11049
11219
|
if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
|
|
11050
11220
|
writer.uint32(50).bytes(message.intermediateDirectFromCpfpRefundTx);
|
|
11051
11221
|
}
|
|
11222
|
+
if (message.pendingKeyTweakPublicKey.length !== 0) {
|
|
11223
|
+
writer.uint32(58).bytes(message.pendingKeyTweakPublicKey);
|
|
11224
|
+
}
|
|
11052
11225
|
return writer;
|
|
11053
11226
|
},
|
|
11054
11227
|
decode(input, length) {
|
|
@@ -11100,6 +11273,13 @@ var TransferLeaf = {
|
|
|
11100
11273
|
message.intermediateDirectFromCpfpRefundTx = reader.bytes();
|
|
11101
11274
|
continue;
|
|
11102
11275
|
}
|
|
11276
|
+
case 7: {
|
|
11277
|
+
if (tag !== 58) {
|
|
11278
|
+
break;
|
|
11279
|
+
}
|
|
11280
|
+
message.pendingKeyTweakPublicKey = reader.bytes();
|
|
11281
|
+
continue;
|
|
11282
|
+
}
|
|
11103
11283
|
}
|
|
11104
11284
|
if ((tag & 7) === 4 || tag === 0) {
|
|
11105
11285
|
break;
|
|
@@ -11115,7 +11295,8 @@ var TransferLeaf = {
|
|
|
11115
11295
|
signature: isSet3(object.signature) ? bytesFromBase642(object.signature) : new Uint8Array(0),
|
|
11116
11296
|
intermediateRefundTx: isSet3(object.intermediateRefundTx) ? bytesFromBase642(object.intermediateRefundTx) : new Uint8Array(0),
|
|
11117
11297
|
intermediateDirectRefundTx: isSet3(object.intermediateDirectRefundTx) ? bytesFromBase642(object.intermediateDirectRefundTx) : new Uint8Array(0),
|
|
11118
|
-
intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0)
|
|
11298
|
+
intermediateDirectFromCpfpRefundTx: isSet3(object.intermediateDirectFromCpfpRefundTx) ? bytesFromBase642(object.intermediateDirectFromCpfpRefundTx) : new Uint8Array(0),
|
|
11299
|
+
pendingKeyTweakPublicKey: isSet3(object.pendingKeyTweakPublicKey) ? bytesFromBase642(object.pendingKeyTweakPublicKey) : new Uint8Array(0)
|
|
11119
11300
|
};
|
|
11120
11301
|
},
|
|
11121
11302
|
toJSON(message) {
|
|
@@ -11138,6 +11319,9 @@ var TransferLeaf = {
|
|
|
11138
11319
|
if (message.intermediateDirectFromCpfpRefundTx.length !== 0) {
|
|
11139
11320
|
obj.intermediateDirectFromCpfpRefundTx = base64FromBytes2(message.intermediateDirectFromCpfpRefundTx);
|
|
11140
11321
|
}
|
|
11322
|
+
if (message.pendingKeyTweakPublicKey.length !== 0) {
|
|
11323
|
+
obj.pendingKeyTweakPublicKey = base64FromBytes2(message.pendingKeyTweakPublicKey);
|
|
11324
|
+
}
|
|
11141
11325
|
return obj;
|
|
11142
11326
|
},
|
|
11143
11327
|
create(base) {
|
|
@@ -11151,6 +11335,7 @@ var TransferLeaf = {
|
|
|
11151
11335
|
message.intermediateRefundTx = object.intermediateRefundTx ?? new Uint8Array(0);
|
|
11152
11336
|
message.intermediateDirectRefundTx = object.intermediateDirectRefundTx ?? new Uint8Array(0);
|
|
11153
11337
|
message.intermediateDirectFromCpfpRefundTx = object.intermediateDirectFromCpfpRefundTx ?? new Uint8Array(0);
|
|
11338
|
+
message.pendingKeyTweakPublicKey = object.pendingKeyTweakPublicKey ?? new Uint8Array(0);
|
|
11154
11339
|
return message;
|
|
11155
11340
|
}
|
|
11156
11341
|
};
|
|
@@ -14048,13 +14233,16 @@ var QueryUserSignedRefundsRequest = {
|
|
|
14048
14233
|
}
|
|
14049
14234
|
};
|
|
14050
14235
|
function createBaseQueryUserSignedRefundsResponse() {
|
|
14051
|
-
return { userSignedRefunds: [] };
|
|
14236
|
+
return { userSignedRefunds: [], transfer: void 0 };
|
|
14052
14237
|
}
|
|
14053
14238
|
var QueryUserSignedRefundsResponse = {
|
|
14054
14239
|
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
14055
14240
|
for (const v of message.userSignedRefunds) {
|
|
14056
14241
|
UserSignedRefund.encode(v, writer.uint32(10).fork()).join();
|
|
14057
14242
|
}
|
|
14243
|
+
if (message.transfer !== void 0) {
|
|
14244
|
+
Transfer6.encode(message.transfer, writer.uint32(26).fork()).join();
|
|
14245
|
+
}
|
|
14058
14246
|
return writer;
|
|
14059
14247
|
},
|
|
14060
14248
|
decode(input, length) {
|
|
@@ -14071,6 +14259,13 @@ var QueryUserSignedRefundsResponse = {
|
|
|
14071
14259
|
message.userSignedRefunds.push(UserSignedRefund.decode(reader, reader.uint32()));
|
|
14072
14260
|
continue;
|
|
14073
14261
|
}
|
|
14262
|
+
case 3: {
|
|
14263
|
+
if (tag !== 26) {
|
|
14264
|
+
break;
|
|
14265
|
+
}
|
|
14266
|
+
message.transfer = Transfer6.decode(reader, reader.uint32());
|
|
14267
|
+
continue;
|
|
14268
|
+
}
|
|
14074
14269
|
}
|
|
14075
14270
|
if ((tag & 7) === 4 || tag === 0) {
|
|
14076
14271
|
break;
|
|
@@ -14081,7 +14276,8 @@ var QueryUserSignedRefundsResponse = {
|
|
|
14081
14276
|
},
|
|
14082
14277
|
fromJSON(object) {
|
|
14083
14278
|
return {
|
|
14084
|
-
userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : []
|
|
14279
|
+
userSignedRefunds: globalThis.Array.isArray(object?.userSignedRefunds) ? object.userSignedRefunds.map((e) => UserSignedRefund.fromJSON(e)) : [],
|
|
14280
|
+
transfer: isSet3(object.transfer) ? Transfer6.fromJSON(object.transfer) : void 0
|
|
14085
14281
|
};
|
|
14086
14282
|
},
|
|
14087
14283
|
toJSON(message) {
|
|
@@ -14089,6 +14285,9 @@ var QueryUserSignedRefundsResponse = {
|
|
|
14089
14285
|
if (message.userSignedRefunds?.length) {
|
|
14090
14286
|
obj.userSignedRefunds = message.userSignedRefunds.map((e) => UserSignedRefund.toJSON(e));
|
|
14091
14287
|
}
|
|
14288
|
+
if (message.transfer !== void 0) {
|
|
14289
|
+
obj.transfer = Transfer6.toJSON(message.transfer);
|
|
14290
|
+
}
|
|
14092
14291
|
return obj;
|
|
14093
14292
|
},
|
|
14094
14293
|
create(base) {
|
|
@@ -14097,6 +14296,7 @@ var QueryUserSignedRefundsResponse = {
|
|
|
14097
14296
|
fromPartial(object) {
|
|
14098
14297
|
const message = createBaseQueryUserSignedRefundsResponse();
|
|
14099
14298
|
message.userSignedRefunds = object.userSignedRefunds?.map((e) => UserSignedRefund.fromPartial(e)) || [];
|
|
14299
|
+
message.transfer = object.transfer !== void 0 && object.transfer !== null ? Transfer6.fromPartial(object.transfer) : void 0;
|
|
14100
14300
|
return message;
|
|
14101
14301
|
}
|
|
14102
14302
|
};
|
|
@@ -14983,7 +15183,8 @@ function createBaseDepositAddressQueryResult() {
|
|
|
14983
15183
|
depositAddress: "",
|
|
14984
15184
|
userSigningPublicKey: new Uint8Array(0),
|
|
14985
15185
|
verifyingPublicKey: new Uint8Array(0),
|
|
14986
|
-
leafId: void 0
|
|
15186
|
+
leafId: void 0,
|
|
15187
|
+
proofOfPossession: void 0
|
|
14987
15188
|
};
|
|
14988
15189
|
}
|
|
14989
15190
|
var DepositAddressQueryResult = {
|
|
@@ -15000,6 +15201,9 @@ var DepositAddressQueryResult = {
|
|
|
15000
15201
|
if (message.leafId !== void 0) {
|
|
15001
15202
|
writer.uint32(34).string(message.leafId);
|
|
15002
15203
|
}
|
|
15204
|
+
if (message.proofOfPossession !== void 0) {
|
|
15205
|
+
DepositAddressProof.encode(message.proofOfPossession, writer.uint32(42).fork()).join();
|
|
15206
|
+
}
|
|
15003
15207
|
return writer;
|
|
15004
15208
|
},
|
|
15005
15209
|
decode(input, length) {
|
|
@@ -15037,6 +15241,13 @@ var DepositAddressQueryResult = {
|
|
|
15037
15241
|
message.leafId = reader.string();
|
|
15038
15242
|
continue;
|
|
15039
15243
|
}
|
|
15244
|
+
case 5: {
|
|
15245
|
+
if (tag !== 42) {
|
|
15246
|
+
break;
|
|
15247
|
+
}
|
|
15248
|
+
message.proofOfPossession = DepositAddressProof.decode(reader, reader.uint32());
|
|
15249
|
+
continue;
|
|
15250
|
+
}
|
|
15040
15251
|
}
|
|
15041
15252
|
if ((tag & 7) === 4 || tag === 0) {
|
|
15042
15253
|
break;
|
|
@@ -15050,7 +15261,8 @@ var DepositAddressQueryResult = {
|
|
|
15050
15261
|
depositAddress: isSet3(object.depositAddress) ? globalThis.String(object.depositAddress) : "",
|
|
15051
15262
|
userSigningPublicKey: isSet3(object.userSigningPublicKey) ? bytesFromBase642(object.userSigningPublicKey) : new Uint8Array(0),
|
|
15052
15263
|
verifyingPublicKey: isSet3(object.verifyingPublicKey) ? bytesFromBase642(object.verifyingPublicKey) : new Uint8Array(0),
|
|
15053
|
-
leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0
|
|
15264
|
+
leafId: isSet3(object.leafId) ? globalThis.String(object.leafId) : void 0,
|
|
15265
|
+
proofOfPossession: isSet3(object.proofOfPossession) ? DepositAddressProof.fromJSON(object.proofOfPossession) : void 0
|
|
15054
15266
|
};
|
|
15055
15267
|
},
|
|
15056
15268
|
toJSON(message) {
|
|
@@ -15067,6 +15279,9 @@ var DepositAddressQueryResult = {
|
|
|
15067
15279
|
if (message.leafId !== void 0) {
|
|
15068
15280
|
obj.leafId = message.leafId;
|
|
15069
15281
|
}
|
|
15282
|
+
if (message.proofOfPossession !== void 0) {
|
|
15283
|
+
obj.proofOfPossession = DepositAddressProof.toJSON(message.proofOfPossession);
|
|
15284
|
+
}
|
|
15070
15285
|
return obj;
|
|
15071
15286
|
},
|
|
15072
15287
|
create(base) {
|
|
@@ -15078,6 +15293,7 @@ var DepositAddressQueryResult = {
|
|
|
15078
15293
|
message.userSigningPublicKey = object.userSigningPublicKey ?? new Uint8Array(0);
|
|
15079
15294
|
message.verifyingPublicKey = object.verifyingPublicKey ?? new Uint8Array(0);
|
|
15080
15295
|
message.leafId = object.leafId ?? void 0;
|
|
15296
|
+
message.proofOfPossession = object.proofOfPossession !== void 0 && object.proofOfPossession !== null ? DepositAddressProof.fromPartial(object.proofOfPossession) : void 0;
|
|
15081
15297
|
return message;
|
|
15082
15298
|
}
|
|
15083
15299
|
};
|
|
@@ -17042,7 +17258,7 @@ var QueryNodesByValueResponse_NodesEntry = {
|
|
|
17042
17258
|
}
|
|
17043
17259
|
};
|
|
17044
17260
|
function createBaseGetUtxosForAddressRequest() {
|
|
17045
|
-
return { address: "", offset: 0, limit: 0, network: 0 };
|
|
17261
|
+
return { address: "", offset: 0, limit: 0, network: 0, excludeClaimed: false };
|
|
17046
17262
|
}
|
|
17047
17263
|
var GetUtxosForAddressRequest = {
|
|
17048
17264
|
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
@@ -17058,6 +17274,9 @@ var GetUtxosForAddressRequest = {
|
|
|
17058
17274
|
if (message.network !== 0) {
|
|
17059
17275
|
writer.uint32(32).int32(message.network);
|
|
17060
17276
|
}
|
|
17277
|
+
if (message.excludeClaimed !== false) {
|
|
17278
|
+
writer.uint32(40).bool(message.excludeClaimed);
|
|
17279
|
+
}
|
|
17061
17280
|
return writer;
|
|
17062
17281
|
},
|
|
17063
17282
|
decode(input, length) {
|
|
@@ -17095,6 +17314,13 @@ var GetUtxosForAddressRequest = {
|
|
|
17095
17314
|
message.network = reader.int32();
|
|
17096
17315
|
continue;
|
|
17097
17316
|
}
|
|
17317
|
+
case 5: {
|
|
17318
|
+
if (tag !== 40) {
|
|
17319
|
+
break;
|
|
17320
|
+
}
|
|
17321
|
+
message.excludeClaimed = reader.bool();
|
|
17322
|
+
continue;
|
|
17323
|
+
}
|
|
17098
17324
|
}
|
|
17099
17325
|
if ((tag & 7) === 4 || tag === 0) {
|
|
17100
17326
|
break;
|
|
@@ -17108,7 +17334,8 @@ var GetUtxosForAddressRequest = {
|
|
|
17108
17334
|
address: isSet3(object.address) ? globalThis.String(object.address) : "",
|
|
17109
17335
|
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
17110
17336
|
limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
|
|
17111
|
-
network: isSet3(object.network) ? networkFromJSON(object.network) : 0
|
|
17337
|
+
network: isSet3(object.network) ? networkFromJSON(object.network) : 0,
|
|
17338
|
+
excludeClaimed: isSet3(object.excludeClaimed) ? globalThis.Boolean(object.excludeClaimed) : false
|
|
17112
17339
|
};
|
|
17113
17340
|
},
|
|
17114
17341
|
toJSON(message) {
|
|
@@ -17125,6 +17352,9 @@ var GetUtxosForAddressRequest = {
|
|
|
17125
17352
|
if (message.network !== 0) {
|
|
17126
17353
|
obj.network = networkToJSON(message.network);
|
|
17127
17354
|
}
|
|
17355
|
+
if (message.excludeClaimed !== false) {
|
|
17356
|
+
obj.excludeClaimed = message.excludeClaimed;
|
|
17357
|
+
}
|
|
17128
17358
|
return obj;
|
|
17129
17359
|
},
|
|
17130
17360
|
create(base) {
|
|
@@ -17136,6 +17366,7 @@ var GetUtxosForAddressRequest = {
|
|
|
17136
17366
|
message.offset = object.offset ?? 0;
|
|
17137
17367
|
message.limit = object.limit ?? 0;
|
|
17138
17368
|
message.network = object.network ?? 0;
|
|
17369
|
+
message.excludeClaimed = object.excludeClaimed ?? false;
|
|
17139
17370
|
return message;
|
|
17140
17371
|
}
|
|
17141
17372
|
};
|
|
@@ -17207,6 +17438,225 @@ var GetUtxosForAddressResponse = {
|
|
|
17207
17438
|
return message;
|
|
17208
17439
|
}
|
|
17209
17440
|
};
|
|
17441
|
+
function createBaseQuerySparkInvoicesRequest() {
|
|
17442
|
+
return { limit: 0, offset: 0, invoice: [] };
|
|
17443
|
+
}
|
|
17444
|
+
var QuerySparkInvoicesRequest = {
|
|
17445
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
17446
|
+
if (message.limit !== 0) {
|
|
17447
|
+
writer.uint32(8).int64(message.limit);
|
|
17448
|
+
}
|
|
17449
|
+
if (message.offset !== 0) {
|
|
17450
|
+
writer.uint32(16).int64(message.offset);
|
|
17451
|
+
}
|
|
17452
|
+
for (const v of message.invoice) {
|
|
17453
|
+
writer.uint32(26).string(v);
|
|
17454
|
+
}
|
|
17455
|
+
return writer;
|
|
17456
|
+
},
|
|
17457
|
+
decode(input, length) {
|
|
17458
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
17459
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
17460
|
+
const message = createBaseQuerySparkInvoicesRequest();
|
|
17461
|
+
while (reader.pos < end) {
|
|
17462
|
+
const tag = reader.uint32();
|
|
17463
|
+
switch (tag >>> 3) {
|
|
17464
|
+
case 1: {
|
|
17465
|
+
if (tag !== 8) {
|
|
17466
|
+
break;
|
|
17467
|
+
}
|
|
17468
|
+
message.limit = longToNumber2(reader.int64());
|
|
17469
|
+
continue;
|
|
17470
|
+
}
|
|
17471
|
+
case 2: {
|
|
17472
|
+
if (tag !== 16) {
|
|
17473
|
+
break;
|
|
17474
|
+
}
|
|
17475
|
+
message.offset = longToNumber2(reader.int64());
|
|
17476
|
+
continue;
|
|
17477
|
+
}
|
|
17478
|
+
case 3: {
|
|
17479
|
+
if (tag !== 26) {
|
|
17480
|
+
break;
|
|
17481
|
+
}
|
|
17482
|
+
message.invoice.push(reader.string());
|
|
17483
|
+
continue;
|
|
17484
|
+
}
|
|
17485
|
+
}
|
|
17486
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
17487
|
+
break;
|
|
17488
|
+
}
|
|
17489
|
+
reader.skip(tag & 7);
|
|
17490
|
+
}
|
|
17491
|
+
return message;
|
|
17492
|
+
},
|
|
17493
|
+
fromJSON(object) {
|
|
17494
|
+
return {
|
|
17495
|
+
limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
|
|
17496
|
+
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
17497
|
+
invoice: globalThis.Array.isArray(object?.invoice) ? object.invoice.map((e) => globalThis.String(e)) : []
|
|
17498
|
+
};
|
|
17499
|
+
},
|
|
17500
|
+
toJSON(message) {
|
|
17501
|
+
const obj = {};
|
|
17502
|
+
if (message.limit !== 0) {
|
|
17503
|
+
obj.limit = Math.round(message.limit);
|
|
17504
|
+
}
|
|
17505
|
+
if (message.offset !== 0) {
|
|
17506
|
+
obj.offset = Math.round(message.offset);
|
|
17507
|
+
}
|
|
17508
|
+
if (message.invoice?.length) {
|
|
17509
|
+
obj.invoice = message.invoice;
|
|
17510
|
+
}
|
|
17511
|
+
return obj;
|
|
17512
|
+
},
|
|
17513
|
+
create(base) {
|
|
17514
|
+
return QuerySparkInvoicesRequest.fromPartial(base ?? {});
|
|
17515
|
+
},
|
|
17516
|
+
fromPartial(object) {
|
|
17517
|
+
const message = createBaseQuerySparkInvoicesRequest();
|
|
17518
|
+
message.limit = object.limit ?? 0;
|
|
17519
|
+
message.offset = object.offset ?? 0;
|
|
17520
|
+
message.invoice = object.invoice?.map((e) => e) || [];
|
|
17521
|
+
return message;
|
|
17522
|
+
}
|
|
17523
|
+
};
|
|
17524
|
+
function createBaseQuerySparkInvoicesResponse() {
|
|
17525
|
+
return { offset: 0, invoiceStatuses: [] };
|
|
17526
|
+
}
|
|
17527
|
+
var QuerySparkInvoicesResponse = {
|
|
17528
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
17529
|
+
if (message.offset !== 0) {
|
|
17530
|
+
writer.uint32(8).int64(message.offset);
|
|
17531
|
+
}
|
|
17532
|
+
for (const v of message.invoiceStatuses) {
|
|
17533
|
+
InvoiceResponse.encode(v, writer.uint32(18).fork()).join();
|
|
17534
|
+
}
|
|
17535
|
+
return writer;
|
|
17536
|
+
},
|
|
17537
|
+
decode(input, length) {
|
|
17538
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
17539
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
17540
|
+
const message = createBaseQuerySparkInvoicesResponse();
|
|
17541
|
+
while (reader.pos < end) {
|
|
17542
|
+
const tag = reader.uint32();
|
|
17543
|
+
switch (tag >>> 3) {
|
|
17544
|
+
case 1: {
|
|
17545
|
+
if (tag !== 8) {
|
|
17546
|
+
break;
|
|
17547
|
+
}
|
|
17548
|
+
message.offset = longToNumber2(reader.int64());
|
|
17549
|
+
continue;
|
|
17550
|
+
}
|
|
17551
|
+
case 2: {
|
|
17552
|
+
if (tag !== 18) {
|
|
17553
|
+
break;
|
|
17554
|
+
}
|
|
17555
|
+
message.invoiceStatuses.push(InvoiceResponse.decode(reader, reader.uint32()));
|
|
17556
|
+
continue;
|
|
17557
|
+
}
|
|
17558
|
+
}
|
|
17559
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
17560
|
+
break;
|
|
17561
|
+
}
|
|
17562
|
+
reader.skip(tag & 7);
|
|
17563
|
+
}
|
|
17564
|
+
return message;
|
|
17565
|
+
},
|
|
17566
|
+
fromJSON(object) {
|
|
17567
|
+
return {
|
|
17568
|
+
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0,
|
|
17569
|
+
invoiceStatuses: globalThis.Array.isArray(object?.invoiceStatuses) ? object.invoiceStatuses.map((e) => InvoiceResponse.fromJSON(e)) : []
|
|
17570
|
+
};
|
|
17571
|
+
},
|
|
17572
|
+
toJSON(message) {
|
|
17573
|
+
const obj = {};
|
|
17574
|
+
if (message.offset !== 0) {
|
|
17575
|
+
obj.offset = Math.round(message.offset);
|
|
17576
|
+
}
|
|
17577
|
+
if (message.invoiceStatuses?.length) {
|
|
17578
|
+
obj.invoiceStatuses = message.invoiceStatuses.map((e) => InvoiceResponse.toJSON(e));
|
|
17579
|
+
}
|
|
17580
|
+
return obj;
|
|
17581
|
+
},
|
|
17582
|
+
create(base) {
|
|
17583
|
+
return QuerySparkInvoicesResponse.fromPartial(base ?? {});
|
|
17584
|
+
},
|
|
17585
|
+
fromPartial(object) {
|
|
17586
|
+
const message = createBaseQuerySparkInvoicesResponse();
|
|
17587
|
+
message.offset = object.offset ?? 0;
|
|
17588
|
+
message.invoiceStatuses = object.invoiceStatuses?.map((e) => InvoiceResponse.fromPartial(e)) || [];
|
|
17589
|
+
return message;
|
|
17590
|
+
}
|
|
17591
|
+
};
|
|
17592
|
+
function createBaseInvoiceResponse() {
|
|
17593
|
+
return { invoice: "", status: 0 };
|
|
17594
|
+
}
|
|
17595
|
+
var InvoiceResponse = {
|
|
17596
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
17597
|
+
if (message.invoice !== "") {
|
|
17598
|
+
writer.uint32(10).string(message.invoice);
|
|
17599
|
+
}
|
|
17600
|
+
if (message.status !== 0) {
|
|
17601
|
+
writer.uint32(16).int32(message.status);
|
|
17602
|
+
}
|
|
17603
|
+
return writer;
|
|
17604
|
+
},
|
|
17605
|
+
decode(input, length) {
|
|
17606
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
17607
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
17608
|
+
const message = createBaseInvoiceResponse();
|
|
17609
|
+
while (reader.pos < end) {
|
|
17610
|
+
const tag = reader.uint32();
|
|
17611
|
+
switch (tag >>> 3) {
|
|
17612
|
+
case 1: {
|
|
17613
|
+
if (tag !== 10) {
|
|
17614
|
+
break;
|
|
17615
|
+
}
|
|
17616
|
+
message.invoice = reader.string();
|
|
17617
|
+
continue;
|
|
17618
|
+
}
|
|
17619
|
+
case 2: {
|
|
17620
|
+
if (tag !== 16) {
|
|
17621
|
+
break;
|
|
17622
|
+
}
|
|
17623
|
+
message.status = reader.int32();
|
|
17624
|
+
continue;
|
|
17625
|
+
}
|
|
17626
|
+
}
|
|
17627
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
17628
|
+
break;
|
|
17629
|
+
}
|
|
17630
|
+
reader.skip(tag & 7);
|
|
17631
|
+
}
|
|
17632
|
+
return message;
|
|
17633
|
+
},
|
|
17634
|
+
fromJSON(object) {
|
|
17635
|
+
return {
|
|
17636
|
+
invoice: isSet3(object.invoice) ? globalThis.String(object.invoice) : "",
|
|
17637
|
+
status: isSet3(object.status) ? invoiceStatusFromJSON(object.status) : 0
|
|
17638
|
+
};
|
|
17639
|
+
},
|
|
17640
|
+
toJSON(message) {
|
|
17641
|
+
const obj = {};
|
|
17642
|
+
if (message.invoice !== "") {
|
|
17643
|
+
obj.invoice = message.invoice;
|
|
17644
|
+
}
|
|
17645
|
+
if (message.status !== 0) {
|
|
17646
|
+
obj.status = invoiceStatusToJSON(message.status);
|
|
17647
|
+
}
|
|
17648
|
+
return obj;
|
|
17649
|
+
},
|
|
17650
|
+
create(base) {
|
|
17651
|
+
return InvoiceResponse.fromPartial(base ?? {});
|
|
17652
|
+
},
|
|
17653
|
+
fromPartial(object) {
|
|
17654
|
+
const message = createBaseInvoiceResponse();
|
|
17655
|
+
message.invoice = object.invoice ?? "";
|
|
17656
|
+
message.status = object.status ?? 0;
|
|
17657
|
+
return message;
|
|
17658
|
+
}
|
|
17659
|
+
};
|
|
17210
17660
|
var SparkServiceDefinition = {
|
|
17211
17661
|
name: "SparkService",
|
|
17212
17662
|
fullName: "spark.SparkService",
|
|
@@ -17219,6 +17669,15 @@ var SparkServiceDefinition = {
|
|
|
17219
17669
|
responseStream: false,
|
|
17220
17670
|
options: {}
|
|
17221
17671
|
},
|
|
17672
|
+
/** Generates a new static deposit address of the user or returns the existing one for the specified network. */
|
|
17673
|
+
generate_static_deposit_address: {
|
|
17674
|
+
name: "generate_static_deposit_address",
|
|
17675
|
+
requestType: GenerateStaticDepositAddressRequest,
|
|
17676
|
+
requestStream: false,
|
|
17677
|
+
responseType: GenerateStaticDepositAddressResponse,
|
|
17678
|
+
responseStream: false,
|
|
17679
|
+
options: {}
|
|
17680
|
+
},
|
|
17222
17681
|
start_deposit_tree_creation: {
|
|
17223
17682
|
name: "start_deposit_tree_creation",
|
|
17224
17683
|
requestType: StartDepositTreeCreationRequest,
|
|
@@ -17660,6 +18119,14 @@ var SparkServiceDefinition = {
|
|
|
17660
18119
|
responseType: GetUtxosForAddressResponse,
|
|
17661
18120
|
responseStream: false,
|
|
17662
18121
|
options: {}
|
|
18122
|
+
},
|
|
18123
|
+
query_spark_invoices: {
|
|
18124
|
+
name: "query_spark_invoices",
|
|
18125
|
+
requestType: QuerySparkInvoicesRequest,
|
|
18126
|
+
requestStream: false,
|
|
18127
|
+
responseType: QuerySparkInvoicesResponse,
|
|
18128
|
+
responseStream: false,
|
|
18129
|
+
options: {}
|
|
17663
18130
|
}
|
|
17664
18131
|
}
|
|
17665
18132
|
};
|
|
@@ -17728,8 +18195,8 @@ init_buffer();
|
|
|
17728
18195
|
// src/signer/signer.ts
|
|
17729
18196
|
init_buffer();
|
|
17730
18197
|
var import_secp256k14 = require("@bitcoinerlab/secp256k1");
|
|
17731
|
-
var import_utils5 = require("@noble/curves/abstract/utils");
|
|
17732
18198
|
var import_secp256k15 = require("@noble/curves/secp256k1");
|
|
18199
|
+
var import_utils5 = require("@noble/curves/utils");
|
|
17733
18200
|
var import_sha22 = require("@noble/hashes/sha2");
|
|
17734
18201
|
var import_bip32 = require("@scure/bip32");
|
|
17735
18202
|
var import_bip39 = require("@scure/bip39");
|
|
@@ -17742,7 +18209,7 @@ init_buffer();
|
|
|
17742
18209
|
var import_core10 = require("@lightsparkdev/core");
|
|
17743
18210
|
var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
17744
18211
|
var isBun = globalThis.Bun !== void 0;
|
|
17745
|
-
var packageVersion = true ? "0.2.
|
|
18212
|
+
var packageVersion = true ? "0.2.13" : "unknown";
|
|
17746
18213
|
var baseEnvStr = "unknown";
|
|
17747
18214
|
if (isBun) {
|
|
17748
18215
|
const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
|
|
@@ -17762,8 +18229,8 @@ var clientEnv = `js-spark-sdk/${packageVersion} ${baseEnvStr}`;
|
|
|
17762
18229
|
|
|
17763
18230
|
// src/utils/keys.ts
|
|
17764
18231
|
init_buffer();
|
|
17765
|
-
var import_utils2 = require("@noble/curves/abstract/utils");
|
|
17766
18232
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
|
18233
|
+
var import_utils2 = require("@noble/curves/utils");
|
|
17767
18234
|
function addPublicKeys(a, b) {
|
|
17768
18235
|
if (a.length !== 33 || b.length !== 33) {
|
|
17769
18236
|
throw new ValidationError("Public keys must be 33 bytes", {
|
|
@@ -17861,8 +18328,8 @@ function lastKeyWithTarget(target, keys) {
|
|
|
17861
18328
|
|
|
17862
18329
|
// src/utils/secret-sharing.ts
|
|
17863
18330
|
init_buffer();
|
|
17864
|
-
var import_utils3 = require("@noble/curves/abstract/utils");
|
|
17865
18331
|
var import_secp256k12 = require("@noble/curves/secp256k1");
|
|
18332
|
+
var import_utils3 = require("@noble/curves/utils");
|
|
17866
18333
|
|
|
17867
18334
|
// src/utils/crypto.ts
|
|
17868
18335
|
init_buffer();
|
|
@@ -23056,8 +23523,8 @@ var import_uuidv72 = require("uuidv7");
|
|
|
23056
23523
|
|
|
23057
23524
|
// src/utils/bitcoin.ts
|
|
23058
23525
|
init_buffer();
|
|
23059
|
-
var import_utils7 = require("@noble/curves/abstract/utils");
|
|
23060
23526
|
var import_secp256k16 = require("@noble/curves/secp256k1");
|
|
23527
|
+
var import_utils7 = require("@noble/curves/utils");
|
|
23061
23528
|
var import_sha24 = require("@noble/hashes/sha2");
|
|
23062
23529
|
var btc2 = __toESM(require("@scure/btc-signer"), 1);
|
|
23063
23530
|
function computeTaprootKeyNoScript(pubkey) {
|
|
@@ -23545,8 +24012,8 @@ function getEphemeralAnchorOutput() {
|
|
|
23545
24012
|
|
|
23546
24013
|
// src/services/transfer.ts
|
|
23547
24014
|
init_buffer();
|
|
23548
|
-
var import_utils9 = require("@noble/curves/abstract/utils");
|
|
23549
24015
|
var import_secp256k17 = require("@noble/curves/secp256k1");
|
|
24016
|
+
var import_utils9 = require("@noble/curves/utils");
|
|
23550
24017
|
var import_sha26 = require("@noble/hashes/sha2");
|
|
23551
24018
|
var import_btc_signer2 = require("@scure/btc-signer");
|
|
23552
24019
|
var ecies2 = __toESM(require("eciesjs"), 1);
|
|
@@ -23554,7 +24021,7 @@ var import_uuidv7 = require("uuidv7");
|
|
|
23554
24021
|
|
|
23555
24022
|
// src/utils/transfer_package.ts
|
|
23556
24023
|
init_buffer();
|
|
23557
|
-
var import_utils8 = require("@noble/curves/
|
|
24024
|
+
var import_utils8 = require("@noble/curves/utils");
|
|
23558
24025
|
var import_sha25 = require("@noble/hashes/sha2");
|
|
23559
24026
|
function getTransferPackageSigningPayload(transferID, transferPackage) {
|
|
23560
24027
|
const encryptedPayload = transferPackage.keyTweakPackage;
|
|
@@ -24565,24 +25032,6 @@ var TransferService = class extends BaseTransferService {
|
|
|
24565
25032
|
throw new Error(`Error finalizing node signatures in transfer: ${error}`);
|
|
24566
25033
|
}
|
|
24567
25034
|
}
|
|
24568
|
-
async cancelTransfer(transfer, operatorAddress) {
|
|
24569
|
-
const sparkClient = await this.connectionManager.createSparkClient(operatorAddress);
|
|
24570
|
-
try {
|
|
24571
|
-
const response = await sparkClient.cancel_transfer({
|
|
24572
|
-
transferId: transfer.id,
|
|
24573
|
-
senderIdentityPublicKey: await this.config.signer.getIdentityPublicKey()
|
|
24574
|
-
});
|
|
24575
|
-
return response.transfer;
|
|
24576
|
-
} catch (error) {
|
|
24577
|
-
throw new NetworkError(
|
|
24578
|
-
"Failed to cancel transfer",
|
|
24579
|
-
{
|
|
24580
|
-
method: "POST"
|
|
24581
|
-
},
|
|
24582
|
-
error
|
|
24583
|
-
);
|
|
24584
|
-
}
|
|
24585
|
-
}
|
|
24586
25035
|
async queryPendingTransfersBySender(operatorAddress) {
|
|
24587
25036
|
const sparkClient = await this.connectionManager.createSparkClient(operatorAddress);
|
|
24588
25037
|
try {
|
|
@@ -25493,7 +25942,8 @@ var DepositService = class {
|
|
|
25493
25942
|
}
|
|
25494
25943
|
async validateDepositAddress({
|
|
25495
25944
|
address: address2,
|
|
25496
|
-
userPubkey
|
|
25945
|
+
userPubkey,
|
|
25946
|
+
verifyCoordinatorProof = false
|
|
25497
25947
|
}) {
|
|
25498
25948
|
if (!address2.depositAddressProof || !address2.depositAddressProof.proofOfPossessionSignature || !address2.depositAddressProof.addressSignatures) {
|
|
25499
25949
|
throw new ValidationError(
|
|
@@ -25531,7 +25981,7 @@ var DepositService = class {
|
|
|
25531
25981
|
}
|
|
25532
25982
|
const addrHash = (0, import_sha28.sha256)(address2.address);
|
|
25533
25983
|
for (const operator of Object.values(this.config.getSigningOperators())) {
|
|
25534
|
-
if (operator.identifier === this.config.getCoordinatorIdentifier()) {
|
|
25984
|
+
if (operator.identifier === this.config.getCoordinatorIdentifier() && !verifyCoordinatorProof) {
|
|
25535
25985
|
continue;
|
|
25536
25986
|
}
|
|
25537
25987
|
const operatorPubkey2 = (0, import_utils10.hexToBytes)(operator.identityPublicKey);
|
|
@@ -25556,6 +26006,46 @@ var DepositService = class {
|
|
|
25556
26006
|
}
|
|
25557
26007
|
}
|
|
25558
26008
|
}
|
|
26009
|
+
async generateStaticDepositAddress({
|
|
26010
|
+
signingPubkey
|
|
26011
|
+
}) {
|
|
26012
|
+
const sparkClient = await this.connectionManager.createSparkClient(
|
|
26013
|
+
this.config.getCoordinatorAddress()
|
|
26014
|
+
);
|
|
26015
|
+
let depositResp;
|
|
26016
|
+
try {
|
|
26017
|
+
depositResp = await sparkClient.generate_static_deposit_address({
|
|
26018
|
+
signingPublicKey: signingPubkey,
|
|
26019
|
+
identityPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
26020
|
+
network: this.config.getNetworkProto()
|
|
26021
|
+
});
|
|
26022
|
+
} catch (error) {
|
|
26023
|
+
throw new NetworkError(
|
|
26024
|
+
"Failed to generate static deposit address",
|
|
26025
|
+
{
|
|
26026
|
+
operation: "generate_static_deposit_address",
|
|
26027
|
+
errorCount: 1,
|
|
26028
|
+
errors: error instanceof Error ? error.message : String(error)
|
|
26029
|
+
},
|
|
26030
|
+
error
|
|
26031
|
+
);
|
|
26032
|
+
}
|
|
26033
|
+
if (!depositResp.depositAddress) {
|
|
26034
|
+
throw new ValidationError(
|
|
26035
|
+
"No static deposit address response from coordinator",
|
|
26036
|
+
{
|
|
26037
|
+
field: "depositAddress",
|
|
26038
|
+
value: depositResp
|
|
26039
|
+
}
|
|
26040
|
+
);
|
|
26041
|
+
}
|
|
26042
|
+
await this.validateDepositAddress({
|
|
26043
|
+
address: depositResp.depositAddress,
|
|
26044
|
+
userPubkey: signingPubkey,
|
|
26045
|
+
verifyCoordinatorProof: true
|
|
26046
|
+
});
|
|
26047
|
+
return depositResp;
|
|
26048
|
+
}
|
|
25559
26049
|
async generateDepositAddress({
|
|
25560
26050
|
signingPubkey,
|
|
25561
26051
|
leafId,
|
|
@@ -26096,8 +26586,8 @@ var DepositService = class {
|
|
|
26096
26586
|
|
|
26097
26587
|
// src/services/lightning.ts
|
|
26098
26588
|
init_buffer();
|
|
26099
|
-
var import_utils12 = require("@noble/curves/abstract/utils");
|
|
26100
26589
|
var import_secp256k19 = require("@noble/curves/secp256k1");
|
|
26590
|
+
var import_utils12 = require("@noble/curves/utils");
|
|
26101
26591
|
var import_sha29 = require("@noble/hashes/sha2");
|
|
26102
26592
|
var import_uuidv73 = require("uuidv7");
|
|
26103
26593
|
|
|
@@ -26445,15 +26935,15 @@ var LightningService = class {
|
|
|
26445
26935
|
|
|
26446
26936
|
// src/services/token-transactions.ts
|
|
26447
26937
|
init_buffer();
|
|
26448
|
-
var import_utils17 = require("@noble/curves/abstract/utils");
|
|
26449
26938
|
var import_secp256k112 = require("@noble/curves/secp256k1");
|
|
26450
|
-
var
|
|
26939
|
+
var import_utils16 = require("@noble/curves/utils");
|
|
26940
|
+
var import_utils17 = require("@noble/hashes/utils");
|
|
26451
26941
|
|
|
26452
26942
|
// src/utils/address.ts
|
|
26453
26943
|
init_buffer();
|
|
26454
26944
|
var import_wire8 = require("@bufbuild/protobuf/wire");
|
|
26455
|
-
var import_utils13 = require("@noble/curves/abstract/utils");
|
|
26456
26945
|
var import_secp256k110 = require("@noble/curves/secp256k1");
|
|
26946
|
+
var import_utils13 = require("@noble/curves/utils");
|
|
26457
26947
|
var import_utils14 = require("@noble/hashes/utils");
|
|
26458
26948
|
var import_base2 = require("@scure/base");
|
|
26459
26949
|
var import_uuidv74 = require("uuidv7");
|
|
@@ -28945,8 +29435,7 @@ function validateTokenTransaction(finalTokenTransaction, partialTokenTransaction
|
|
|
28945
29435
|
|
|
28946
29436
|
// src/utils/token-transactions.ts
|
|
28947
29437
|
init_buffer();
|
|
28948
|
-
var import_utils15 = require("@noble/curves/
|
|
28949
|
-
var import_utils16 = require("@scure/btc-signer/utils");
|
|
29438
|
+
var import_utils15 = require("@noble/curves/utils");
|
|
28950
29439
|
function sumAvailableTokens(outputs) {
|
|
28951
29440
|
try {
|
|
28952
29441
|
return outputs.reduce(
|
|
@@ -28981,7 +29470,7 @@ function filterTokenBalanceForTokenIdentifier(tokenBalances, tokenIdentifier) {
|
|
|
28981
29470
|
}
|
|
28982
29471
|
const tokenIdentifierBytes = decodeBech32mTokenIdentifier(tokenIdentifier).tokenIdentifier;
|
|
28983
29472
|
const tokenBalance = [...tokenBalances.entries()].find(
|
|
28984
|
-
([, info]) => (0,
|
|
29473
|
+
([, info]) => (0, import_utils15.equalBytes)(info.tokenMetadata.rawTokenIdentifier, tokenIdentifierBytes)
|
|
28985
29474
|
);
|
|
28986
29475
|
if (!tokenBalance) {
|
|
28987
29476
|
return {
|
|
@@ -29084,14 +29573,14 @@ var TokenTransactionService = class {
|
|
|
29084
29573
|
}
|
|
29085
29574
|
if (this.config.getTokenTransactionVersion() !== "V0" && receiverAddress.sparkInvoiceFields) {
|
|
29086
29575
|
return {
|
|
29087
|
-
receiverPublicKey: (0,
|
|
29576
|
+
receiverPublicKey: (0, import_utils17.hexToBytes)(receiverAddress.identityPublicKey),
|
|
29088
29577
|
rawTokenIdentifier,
|
|
29089
29578
|
tokenAmount: transfer.tokenAmount,
|
|
29090
29579
|
sparkInvoice: transfer.receiverSparkAddress
|
|
29091
29580
|
};
|
|
29092
29581
|
}
|
|
29093
29582
|
return {
|
|
29094
|
-
receiverPublicKey: (0,
|
|
29583
|
+
receiverPublicKey: (0, import_utils17.hexToBytes)(receiverAddress.identityPublicKey),
|
|
29095
29584
|
rawTokenIdentifier,
|
|
29096
29585
|
tokenPublicKey,
|
|
29097
29586
|
// Remove for full v0 deprecation
|
|
@@ -29130,7 +29619,7 @@ var TokenTransactionService = class {
|
|
|
29130
29619
|
const tokenOutputs = tokenOutputData.map((output) => ({
|
|
29131
29620
|
ownerPublicKey: output.receiverPublicKey,
|
|
29132
29621
|
tokenPublicKey: output.tokenPublicKey,
|
|
29133
|
-
tokenAmount: (0,
|
|
29622
|
+
tokenAmount: (0, import_utils16.numberToBytesBE)(output.tokenAmount, 16)
|
|
29134
29623
|
}));
|
|
29135
29624
|
if (availableTokenAmount > totalRequestedAmount) {
|
|
29136
29625
|
const changeAmount = availableTokenAmount - totalRequestedAmount;
|
|
@@ -29138,7 +29627,7 @@ var TokenTransactionService = class {
|
|
|
29138
29627
|
tokenOutputs.push({
|
|
29139
29628
|
ownerPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
29140
29629
|
tokenPublicKey: firstTokenPublicKey,
|
|
29141
|
-
tokenAmount: (0,
|
|
29630
|
+
tokenAmount: (0, import_utils16.numberToBytesBE)(changeAmount, 16)
|
|
29142
29631
|
});
|
|
29143
29632
|
}
|
|
29144
29633
|
return {
|
|
@@ -29169,7 +29658,7 @@ var TokenTransactionService = class {
|
|
|
29169
29658
|
(output) => ({
|
|
29170
29659
|
ownerPublicKey: output.receiverPublicKey,
|
|
29171
29660
|
tokenIdentifier: output.rawTokenIdentifier,
|
|
29172
|
-
tokenAmount: (0,
|
|
29661
|
+
tokenAmount: (0, import_utils16.numberToBytesBE)(output.tokenAmount, 16)
|
|
29173
29662
|
})
|
|
29174
29663
|
);
|
|
29175
29664
|
if (availableTokenAmount > totalRequestedAmount) {
|
|
@@ -29178,7 +29667,7 @@ var TokenTransactionService = class {
|
|
|
29178
29667
|
tokenOutputs.push({
|
|
29179
29668
|
ownerPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
29180
29669
|
tokenIdentifier: firstTokenIdentifierBytes,
|
|
29181
|
-
tokenAmount: (0,
|
|
29670
|
+
tokenAmount: (0, import_utils16.numberToBytesBE)(changeAmount, 16)
|
|
29182
29671
|
});
|
|
29183
29672
|
}
|
|
29184
29673
|
return {
|
|
@@ -29205,7 +29694,7 @@ var TokenTransactionService = class {
|
|
|
29205
29694
|
for (const [_, operator] of Object.entries(
|
|
29206
29695
|
this.config.getSigningOperators()
|
|
29207
29696
|
)) {
|
|
29208
|
-
operatorKeys.push((0,
|
|
29697
|
+
operatorKeys.push((0, import_utils17.hexToBytes)(operator.identityPublicKey));
|
|
29209
29698
|
}
|
|
29210
29699
|
return operatorKeys;
|
|
29211
29700
|
}
|
|
@@ -29289,7 +29778,7 @@ var TokenTransactionService = class {
|
|
|
29289
29778
|
{
|
|
29290
29779
|
field: "revocationCommitment",
|
|
29291
29780
|
value: derivedRevocationCommitment,
|
|
29292
|
-
expected: (0,
|
|
29781
|
+
expected: (0, import_utils16.bytesToHex)(outputsToSpendCommitments[outputIndex]),
|
|
29293
29782
|
outputIndex
|
|
29294
29783
|
}
|
|
29295
29784
|
)
|
|
@@ -29315,7 +29804,7 @@ var TokenTransactionService = class {
|
|
|
29315
29804
|
threshold
|
|
29316
29805
|
);
|
|
29317
29806
|
}
|
|
29318
|
-
return (0,
|
|
29807
|
+
return (0, import_utils16.bytesToHex)(finalTokenTransactionHash);
|
|
29319
29808
|
}
|
|
29320
29809
|
async broadcastTokenTransactionV1(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
|
|
29321
29810
|
const { finalTokenTransaction, finalTokenTransactionHash, threshold } = await this.startTokenTransaction(
|
|
@@ -29329,7 +29818,7 @@ var TokenTransactionService = class {
|
|
|
29329
29818
|
finalTokenTransactionHash,
|
|
29330
29819
|
signingOperators
|
|
29331
29820
|
);
|
|
29332
|
-
return (0,
|
|
29821
|
+
return (0, import_utils16.bytesToHex)(finalTokenTransactionHash);
|
|
29333
29822
|
}
|
|
29334
29823
|
async startTokenTransactionV0(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
|
|
29335
29824
|
const sparkClient = await this.connectionManager.createSparkClient(
|
|
@@ -29553,7 +30042,7 @@ var TokenTransactionService = class {
|
|
|
29553
30042
|
const identityPublicKey = await this.config.signer.getIdentityPublicKey();
|
|
29554
30043
|
const payload = {
|
|
29555
30044
|
finalTokenTransactionHash,
|
|
29556
|
-
operatorIdentityPublicKey: (0,
|
|
30045
|
+
operatorIdentityPublicKey: (0, import_utils17.hexToBytes)(operator.identityPublicKey)
|
|
29557
30046
|
};
|
|
29558
30047
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
29559
30048
|
let operatorSpecificSignatures = [];
|
|
@@ -29768,8 +30257,8 @@ var TokenTransactionService = class {
|
|
|
29768
30257
|
this.config.getCoordinatorAddress()
|
|
29769
30258
|
);
|
|
29770
30259
|
let queryParams = {
|
|
29771
|
-
tokenPublicKeys: issuerPublicKeys?.map(
|
|
29772
|
-
ownerPublicKeys: ownerPublicKeys?.map(
|
|
30260
|
+
tokenPublicKeys: issuerPublicKeys?.map(import_utils17.hexToBytes),
|
|
30261
|
+
ownerPublicKeys: ownerPublicKeys?.map(import_utils17.hexToBytes),
|
|
29773
30262
|
tokenIdentifiers: tokenIdentifiers?.map((identifier) => {
|
|
29774
30263
|
const { tokenIdentifier } = decodeBech32mTokenIdentifier(
|
|
29775
30264
|
identifier,
|
|
@@ -29777,7 +30266,7 @@ var TokenTransactionService = class {
|
|
|
29777
30266
|
);
|
|
29778
30267
|
return tokenIdentifier;
|
|
29779
30268
|
}),
|
|
29780
|
-
tokenTransactionHashes: tokenTransactionHashes?.map(
|
|
30269
|
+
tokenTransactionHashes: tokenTransactionHashes?.map(import_utils17.hexToBytes),
|
|
29781
30270
|
outputIds: outputIds || [],
|
|
29782
30271
|
limit: pageSize,
|
|
29783
30272
|
offset
|
|
@@ -29836,8 +30325,8 @@ var TokenTransactionService = class {
|
|
|
29836
30325
|
this.config.getCoordinatorAddress()
|
|
29837
30326
|
);
|
|
29838
30327
|
let queryParams = {
|
|
29839
|
-
issuerPublicKeys: issuerPublicKeys?.map(
|
|
29840
|
-
ownerPublicKeys: ownerPublicKeys?.map(
|
|
30328
|
+
issuerPublicKeys: issuerPublicKeys?.map(import_utils17.hexToBytes),
|
|
30329
|
+
ownerPublicKeys: ownerPublicKeys?.map(import_utils17.hexToBytes),
|
|
29841
30330
|
tokenIdentifiers: tokenIdentifiers?.map((identifier) => {
|
|
29842
30331
|
const { tokenIdentifier } = decodeBech32mTokenIdentifier(
|
|
29843
30332
|
identifier,
|
|
@@ -29845,7 +30334,7 @@ var TokenTransactionService = class {
|
|
|
29845
30334
|
);
|
|
29846
30335
|
return tokenIdentifier;
|
|
29847
30336
|
}),
|
|
29848
|
-
tokenTransactionHashes: tokenTransactionHashes?.map(
|
|
30337
|
+
tokenTransactionHashes: tokenTransactionHashes?.map(import_utils17.hexToBytes),
|
|
29849
30338
|
outputIds: outputIds || [],
|
|
29850
30339
|
limit: pageSize,
|
|
29851
30340
|
offset
|
|
@@ -29880,7 +30369,7 @@ var TokenTransactionService = class {
|
|
|
29880
30369
|
});
|
|
29881
30370
|
}
|
|
29882
30371
|
const exactMatch = tokenOutputs.find(
|
|
29883
|
-
(item) => (0,
|
|
30372
|
+
(item) => (0, import_utils16.bytesToNumberBE)(item.output.tokenAmount) === tokenAmount
|
|
29884
30373
|
);
|
|
29885
30374
|
if (exactMatch) {
|
|
29886
30375
|
return [exactMatch];
|
|
@@ -29891,7 +30380,7 @@ var TokenTransactionService = class {
|
|
|
29891
30380
|
for (const outputWithPreviousTransactionData of tokenOutputs) {
|
|
29892
30381
|
if (remainingAmount <= 0n) break;
|
|
29893
30382
|
selectedOutputs.push(outputWithPreviousTransactionData);
|
|
29894
|
-
remainingAmount -= (0,
|
|
30383
|
+
remainingAmount -= (0, import_utils16.bytesToNumberBE)(
|
|
29895
30384
|
outputWithPreviousTransactionData.output.tokenAmount
|
|
29896
30385
|
);
|
|
29897
30386
|
}
|
|
@@ -29907,13 +30396,13 @@ var TokenTransactionService = class {
|
|
|
29907
30396
|
if (strategy === "SMALL_FIRST") {
|
|
29908
30397
|
tokenOutputs.sort((a, b) => {
|
|
29909
30398
|
return Number(
|
|
29910
|
-
(0,
|
|
30399
|
+
(0, import_utils16.bytesToNumberBE)(a.output.tokenAmount) - (0, import_utils16.bytesToNumberBE)(b.output.tokenAmount)
|
|
29911
30400
|
);
|
|
29912
30401
|
});
|
|
29913
30402
|
} else {
|
|
29914
30403
|
tokenOutputs.sort((a, b) => {
|
|
29915
30404
|
return Number(
|
|
29916
|
-
(0,
|
|
30405
|
+
(0, import_utils16.bytesToNumberBE)(b.output.tokenAmount) - (0, import_utils16.bytesToNumberBE)(a.output.tokenAmount)
|
|
29917
30406
|
);
|
|
29918
30407
|
});
|
|
29919
30408
|
}
|
|
@@ -29921,7 +30410,7 @@ var TokenTransactionService = class {
|
|
|
29921
30410
|
// Helper function for deciding if the signer public key is the identity public key
|
|
29922
30411
|
async signMessageWithKey(message, publicKey) {
|
|
29923
30412
|
const tokenSignatures = this.config.getTokenSignatures();
|
|
29924
|
-
if ((0,
|
|
30413
|
+
if ((0, import_utils16.bytesToHex)(publicKey) === (0, import_utils16.bytesToHex)(await this.config.signer.getIdentityPublicKey())) {
|
|
29925
30414
|
if (tokenSignatures === "SCHNORR") {
|
|
29926
30415
|
return await this.config.signer.signSchnorrWithIdentityKey(message);
|
|
29927
30416
|
} else {
|
|
@@ -29930,8 +30419,8 @@ var TokenTransactionService = class {
|
|
|
29930
30419
|
} else {
|
|
29931
30420
|
throw new ValidationError("Invalid public key", {
|
|
29932
30421
|
field: "publicKey",
|
|
29933
|
-
value: (0,
|
|
29934
|
-
expected: (0,
|
|
30422
|
+
value: (0, import_utils16.bytesToHex)(publicKey),
|
|
30423
|
+
expected: (0, import_utils16.bytesToHex)(await this.config.signer.getIdentityPublicKey())
|
|
29935
30424
|
});
|
|
29936
30425
|
}
|
|
29937
30426
|
}
|
|
@@ -29994,7 +30483,7 @@ var TokenTransactionService = class {
|
|
|
29994
30483
|
}
|
|
29995
30484
|
const payload = {
|
|
29996
30485
|
finalTokenTransactionHash,
|
|
29997
|
-
operatorIdentityPublicKey: (0,
|
|
30486
|
+
operatorIdentityPublicKey: (0, import_utils17.hexToBytes)(operator.identityPublicKey)
|
|
29998
30487
|
};
|
|
29999
30488
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
30000
30489
|
const ownerSignature = await this.signMessageWithKey(
|
|
@@ -30016,7 +30505,7 @@ var TokenTransactionService = class {
|
|
|
30016
30505
|
}
|
|
30017
30506
|
const payload = {
|
|
30018
30507
|
finalTokenTransactionHash,
|
|
30019
|
-
operatorIdentityPublicKey: (0,
|
|
30508
|
+
operatorIdentityPublicKey: (0, import_utils17.hexToBytes)(operator.identityPublicKey)
|
|
30020
30509
|
};
|
|
30021
30510
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
30022
30511
|
const ownerSignature = await this.signMessageWithKey(
|
|
@@ -30032,7 +30521,7 @@ var TokenTransactionService = class {
|
|
|
30032
30521
|
for (let i = 0; i < transferInput.outputsToSpend.length; i++) {
|
|
30033
30522
|
const payload = {
|
|
30034
30523
|
finalTokenTransactionHash,
|
|
30035
|
-
operatorIdentityPublicKey: (0,
|
|
30524
|
+
operatorIdentityPublicKey: (0, import_utils17.hexToBytes)(operator.identityPublicKey)
|
|
30036
30525
|
};
|
|
30037
30526
|
const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
|
|
30038
30527
|
let ownerSignature;
|
|
@@ -30049,7 +30538,7 @@ var TokenTransactionService = class {
|
|
|
30049
30538
|
}
|
|
30050
30539
|
inputTtxoSignaturesPerOperator.push({
|
|
30051
30540
|
ttxoSignatures,
|
|
30052
|
-
operatorIdentityPublicKey: (0,
|
|
30541
|
+
operatorIdentityPublicKey: (0, import_utils17.hexToBytes)(operator.identityPublicKey)
|
|
30053
30542
|
});
|
|
30054
30543
|
}
|
|
30055
30544
|
return inputTtxoSignaturesPerOperator;
|
|
@@ -30062,23 +30551,23 @@ function isTokenTransaction(tokenTransaction) {
|
|
|
30062
30551
|
// src/utils/adaptor-signature.ts
|
|
30063
30552
|
init_buffer();
|
|
30064
30553
|
var import_modular = require("@noble/curves/abstract/modular");
|
|
30065
|
-
var import_utils19 = require("@noble/curves/abstract/utils");
|
|
30066
30554
|
var import_secp256k113 = require("@noble/curves/secp256k1");
|
|
30555
|
+
var import_utils18 = require("@noble/curves/utils");
|
|
30067
30556
|
function generateSignatureFromExistingAdaptor(signature, adaptorPrivateKeyBytes) {
|
|
30068
30557
|
const { r, s: s2 } = parseSignature(signature);
|
|
30069
|
-
const sBigInt = (0,
|
|
30070
|
-
const tBigInt = (0,
|
|
30558
|
+
const sBigInt = (0, import_utils18.bytesToNumberBE)(s2);
|
|
30559
|
+
const tBigInt = (0, import_utils18.bytesToNumberBE)(adaptorPrivateKeyBytes);
|
|
30071
30560
|
const newS = (0, import_modular.mod)(sBigInt - tBigInt, import_secp256k113.secp256k1.CURVE.n);
|
|
30072
|
-
const newSignature = new Uint8Array([...r, ...(0,
|
|
30561
|
+
const newSignature = new Uint8Array([...r, ...(0, import_utils18.numberToBytesBE)(newS, 32)]);
|
|
30073
30562
|
return newSignature;
|
|
30074
30563
|
}
|
|
30075
30564
|
function generateAdaptorFromSignature(signature) {
|
|
30076
30565
|
const adaptorPrivateKey = import_secp256k113.secp256k1.utils.randomPrivateKey();
|
|
30077
30566
|
const { r, s: s2 } = parseSignature(signature);
|
|
30078
|
-
const sBigInt = (0,
|
|
30079
|
-
const tBigInt = (0,
|
|
30567
|
+
const sBigInt = (0, import_utils18.bytesToNumberBE)(s2);
|
|
30568
|
+
const tBigInt = (0, import_utils18.bytesToNumberBE)(adaptorPrivateKey);
|
|
30080
30569
|
const newS = (0, import_modular.mod)(sBigInt - tBigInt, import_secp256k113.secp256k1.CURVE.n);
|
|
30081
|
-
const newSignature = new Uint8Array([...r, ...(0,
|
|
30570
|
+
const newSignature = new Uint8Array([...r, ...(0, import_utils18.numberToBytesBE)(newS, 32)]);
|
|
30082
30571
|
return {
|
|
30083
30572
|
adaptorSignature: newSignature,
|
|
30084
30573
|
adaptorPrivateKey
|
|
@@ -30095,10 +30584,10 @@ function validateOutboundAdaptorSignature(pubkey, hash, signature, adaptorPubkey
|
|
|
30095
30584
|
}
|
|
30096
30585
|
function applyAdaptorToSignature(pubkey, hash, signature, adaptorPrivateKeyBytes) {
|
|
30097
30586
|
const { r, s: s2 } = parseSignature(signature);
|
|
30098
|
-
const sBigInt = (0,
|
|
30099
|
-
const adaptorPrivateKey = (0,
|
|
30587
|
+
const sBigInt = (0, import_utils18.bytesToNumberBE)(s2);
|
|
30588
|
+
const adaptorPrivateKey = (0, import_utils18.bytesToNumberBE)(adaptorPrivateKeyBytes);
|
|
30100
30589
|
const newS = (0, import_modular.mod)(sBigInt + adaptorPrivateKey, import_secp256k113.secp256k1.CURVE.n);
|
|
30101
|
-
const newSig = new Uint8Array([...r, ...(0,
|
|
30590
|
+
const newSig = new Uint8Array([...r, ...(0, import_utils18.numberToBytesBE)(newS, 32)]);
|
|
30102
30591
|
try {
|
|
30103
30592
|
if (import_secp256k113.schnorr.verify(newSig, hash, pubkey)) {
|
|
30104
30593
|
return newSig;
|
|
@@ -30107,7 +30596,7 @@ function applyAdaptorToSignature(pubkey, hash, signature, adaptorPrivateKeyBytes
|
|
|
30107
30596
|
console.error("[applyAdaptorToSignature] Addition verification failed:", e);
|
|
30108
30597
|
}
|
|
30109
30598
|
const altS = (0, import_modular.mod)(sBigInt - adaptorPrivateKey, import_secp256k113.secp256k1.CURVE.n);
|
|
30110
|
-
const altSig = new Uint8Array([...r, ...(0,
|
|
30599
|
+
const altSig = new Uint8Array([...r, ...(0, import_utils18.numberToBytesBE)(altS, 32)]);
|
|
30111
30600
|
try {
|
|
30112
30601
|
if (import_secp256k113.schnorr.verify(altSig, hash, pubkey)) {
|
|
30113
30602
|
return altSig;
|
|
@@ -30124,7 +30613,7 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
|
|
|
30124
30613
|
if (hash.length !== 32) {
|
|
30125
30614
|
throw new Error(`wrong size for message (got ${hash.length}, want 32)`);
|
|
30126
30615
|
}
|
|
30127
|
-
const pubKey = import_secp256k113.schnorr.utils.lift_x((0,
|
|
30616
|
+
const pubKey = import_secp256k113.schnorr.utils.lift_x((0, import_utils18.bytesToNumberBE)(pubKeyBytes));
|
|
30128
30617
|
pubKey.assertValidity();
|
|
30129
30618
|
const { r, s: s2 } = parseSignature(signature);
|
|
30130
30619
|
const commitmenet = import_secp256k113.schnorr.utils.taggedHash(
|
|
@@ -30136,9 +30625,9 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
|
|
|
30136
30625
|
if (commitmenet.length > 32) {
|
|
30137
30626
|
throw new Error("hash of (r || P || m) too big");
|
|
30138
30627
|
}
|
|
30139
|
-
const e = (0, import_modular.mod)((0,
|
|
30628
|
+
const e = (0, import_modular.mod)((0, import_utils18.bytesToNumberBE)(commitmenet), import_secp256k113.secp256k1.CURVE.n);
|
|
30140
30629
|
const negE = (0, import_modular.mod)(-e, import_secp256k113.secp256k1.CURVE.n);
|
|
30141
|
-
const sG = import_secp256k113.secp256k1.Point.BASE.multiplyUnsafe((0,
|
|
30630
|
+
const sG = import_secp256k113.secp256k1.Point.BASE.multiplyUnsafe((0, import_utils18.bytesToNumberBE)(s2));
|
|
30142
30631
|
const eP = pubKey.multiplyUnsafe(negE);
|
|
30143
30632
|
const R = sG.add(eP);
|
|
30144
30633
|
if (R.is0()) {
|
|
@@ -30154,7 +30643,7 @@ function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, i
|
|
|
30154
30643
|
if (newR.y % 2n !== 0n) {
|
|
30155
30644
|
throw new Error("calculated R y-value is odd");
|
|
30156
30645
|
}
|
|
30157
|
-
const rNum = (0,
|
|
30646
|
+
const rNum = (0, import_utils18.bytesToNumberBE)(r);
|
|
30158
30647
|
if (newR.toAffine().x !== rNum) {
|
|
30159
30648
|
throw new Error("calculated R point was not given R");
|
|
30160
30649
|
}
|
|
@@ -30175,15 +30664,15 @@ function parseSignature(signature) {
|
|
|
30175
30664
|
}
|
|
30176
30665
|
const r = signature.slice(0, 32);
|
|
30177
30666
|
const s2 = signature.slice(32, 64);
|
|
30178
|
-
if ((0,
|
|
30667
|
+
if ((0, import_utils18.bytesToNumberBE)(r) >= import_secp256k113.secp256k1.CURVE.Fp.ORDER) {
|
|
30179
30668
|
throw new ValidationError("Invalid signature: r >= field prime", {
|
|
30180
|
-
rValue: (0,
|
|
30669
|
+
rValue: (0, import_utils18.bytesToNumberBE)(r),
|
|
30181
30670
|
fieldPrime: import_secp256k113.secp256k1.CURVE.Fp.ORDER
|
|
30182
30671
|
});
|
|
30183
30672
|
}
|
|
30184
|
-
if ((0,
|
|
30673
|
+
if ((0, import_utils18.bytesToNumberBE)(s2) >= import_secp256k113.secp256k1.CURVE.n) {
|
|
30185
30674
|
throw new ValidationError("Invalid signature: s >= group order", {
|
|
30186
|
-
sValue: (0,
|
|
30675
|
+
sValue: (0, import_utils18.bytesToNumberBE)(s2),
|
|
30187
30676
|
groupOrder: import_secp256k113.secp256k1.CURVE.n
|
|
30188
30677
|
});
|
|
30189
30678
|
}
|
|
@@ -30199,7 +30688,7 @@ var import_nice_grpc_common3 = require("nice-grpc-common");
|
|
|
30199
30688
|
|
|
30200
30689
|
// src/services/signing.ts
|
|
30201
30690
|
init_buffer();
|
|
30202
|
-
var
|
|
30691
|
+
var import_utils19 = require("@noble/curves/utils");
|
|
30203
30692
|
var SigningService = class {
|
|
30204
30693
|
config;
|
|
30205
30694
|
constructor(config) {
|
|
@@ -30255,7 +30744,7 @@ var SigningService = class {
|
|
|
30255
30744
|
}
|
|
30256
30745
|
const nodeTx = getTxFromRawTxBytes(leaf.leaf.nodeTx);
|
|
30257
30746
|
const cpfpNodeOutPoint = {
|
|
30258
|
-
txid: (0,
|
|
30747
|
+
txid: (0, import_utils19.hexToBytes)(getTxId(nodeTx)),
|
|
30259
30748
|
index: 0
|
|
30260
30749
|
};
|
|
30261
30750
|
const currRefundTx = getTxFromRawTxBytes(leaf.leaf.refundTx);
|
|
@@ -30281,7 +30770,7 @@ var SigningService = class {
|
|
|
30281
30770
|
if (leaf.leaf.directTx.length > 0) {
|
|
30282
30771
|
directNodeTx = getTxFromRawTxBytes(leaf.leaf.directTx);
|
|
30283
30772
|
directNodeOutPoint = {
|
|
30284
|
-
txid: (0,
|
|
30773
|
+
txid: (0, import_utils19.hexToBytes)(getTxId(directNodeTx)),
|
|
30285
30774
|
index: 0
|
|
30286
30775
|
};
|
|
30287
30776
|
}
|
|
@@ -30365,15 +30854,15 @@ var SigningService = class {
|
|
|
30365
30854
|
|
|
30366
30855
|
// src/tests/utils/test-faucet.ts
|
|
30367
30856
|
init_buffer();
|
|
30368
|
-
var import_utils21 = require("@noble/curves/abstract/utils");
|
|
30369
30857
|
var import_secp256k114 = require("@noble/curves/secp256k1");
|
|
30858
|
+
var import_utils20 = require("@noble/curves/utils");
|
|
30370
30859
|
var btc3 = __toESM(require("@scure/btc-signer"), 1);
|
|
30371
30860
|
var import_btc_signer5 = require("@scure/btc-signer");
|
|
30372
|
-
var
|
|
30373
|
-
var STATIC_FAUCET_KEY = (0,
|
|
30861
|
+
var import_utils21 = require("@scure/btc-signer/utils");
|
|
30862
|
+
var STATIC_FAUCET_KEY = (0, import_utils20.hexToBytes)(
|
|
30374
30863
|
"deadbeef1337cafe4242424242424242deadbeef1337cafe4242424242424242"
|
|
30375
30864
|
);
|
|
30376
|
-
var STATIC_MINING_KEY = (0,
|
|
30865
|
+
var STATIC_MINING_KEY = (0, import_utils20.hexToBytes)(
|
|
30377
30866
|
"1337cafe4242deadbeef4242424242421337cafe4242deadbeef424242424242"
|
|
30378
30867
|
);
|
|
30379
30868
|
var SATS_PER_BTC = 1e8;
|
|
@@ -30436,7 +30925,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
30436
30925
|
if (!scanResult.success || scanResult.unspents.length === 0) {
|
|
30437
30926
|
const blockHash = await this.generateToAddress(1, address2);
|
|
30438
30927
|
const block = await this.getBlock(blockHash[0]);
|
|
30439
|
-
const fundingTx = import_btc_signer5.Transaction.fromRaw((0,
|
|
30928
|
+
const fundingTx = import_btc_signer5.Transaction.fromRaw((0, import_utils20.hexToBytes)(block.tx[0].hex), {
|
|
30440
30929
|
allowUnknownOutputs: true
|
|
30441
30930
|
});
|
|
30442
30931
|
await this.generateToAddress(100, this.miningAddress);
|
|
@@ -30498,13 +30987,13 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
30498
30987
|
},
|
|
30499
30988
|
STATIC_MINING_KEY
|
|
30500
30989
|
);
|
|
30501
|
-
await this.broadcastTx((0,
|
|
30990
|
+
await this.broadcastTx((0, import_utils20.bytesToHex)(signedSplitTx.extract()));
|
|
30502
30991
|
const splitTxId = signedSplitTx.id;
|
|
30503
30992
|
for (let i = 0; i < numCoinsToCreate; i++) {
|
|
30504
30993
|
this.coins.push({
|
|
30505
30994
|
key: STATIC_FAUCET_KEY,
|
|
30506
30995
|
outpoint: {
|
|
30507
|
-
txid: (0,
|
|
30996
|
+
txid: (0, import_utils20.hexToBytes)(splitTxId),
|
|
30508
30997
|
index: i
|
|
30509
30998
|
},
|
|
30510
30999
|
txout: signedSplitTx.getOutput(i)
|
|
@@ -30532,7 +31021,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
30532
31021
|
coinToSend.txout,
|
|
30533
31022
|
coinToSend.key
|
|
30534
31023
|
);
|
|
30535
|
-
await this.broadcastTx((0,
|
|
31024
|
+
await this.broadcastTx((0, import_utils20.bytesToHex)(signedTx.extract()));
|
|
30536
31025
|
}
|
|
30537
31026
|
async signFaucetCoin(unsignedTx, fundingTxOut, key) {
|
|
30538
31027
|
const pubKey = import_secp256k114.secp256k1.getPublicKey(key);
|
|
@@ -30552,7 +31041,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
30552
31041
|
new Array(unsignedTx.inputsLength).fill(fundingTxOut.amount)
|
|
30553
31042
|
);
|
|
30554
31043
|
const merkleRoot = new Uint8Array();
|
|
30555
|
-
const tweakedKey = (0,
|
|
31044
|
+
const tweakedKey = (0, import_utils21.taprootTweakPrivKey)(key, merkleRoot);
|
|
30556
31045
|
if (!tweakedKey)
|
|
30557
31046
|
throw new Error("Invalid private key for taproot tweaking");
|
|
30558
31047
|
const signature = import_secp256k114.schnorr.sign(sighash, tweakedKey);
|
|
@@ -30652,7 +31141,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
30652
31141
|
});
|
|
30653
31142
|
}
|
|
30654
31143
|
const signedTx = await this.signFaucetCoin(tx, coin.txout, coin.key);
|
|
30655
|
-
const txHex = (0,
|
|
31144
|
+
const txHex = (0, import_utils20.bytesToHex)(signedTx.extract());
|
|
30656
31145
|
await this.broadcastTx(txHex);
|
|
30657
31146
|
const randomKey = import_secp256k114.secp256k1.utils.randomPrivateKey();
|
|
30658
31147
|
const randomPubKey = import_secp256k114.secp256k1.getPublicKey(randomKey);
|
|
@@ -30670,18 +31159,18 @@ var BitcoinFaucet = class _BitcoinFaucet {
|
|
|
30670
31159
|
|
|
30671
31160
|
// src/types/sdk-types.ts
|
|
30672
31161
|
init_buffer();
|
|
30673
|
-
var
|
|
31162
|
+
var import_utils22 = require("@noble/curves/utils");
|
|
30674
31163
|
function mapTreeNodeToWalletLeaf(proto) {
|
|
30675
31164
|
return {
|
|
30676
31165
|
id: proto.id,
|
|
30677
31166
|
treeId: proto.treeId,
|
|
30678
31167
|
value: proto.value,
|
|
30679
31168
|
parentNodeId: proto.parentNodeId,
|
|
30680
|
-
nodeTx: (0,
|
|
30681
|
-
refundTx: (0,
|
|
31169
|
+
nodeTx: (0, import_utils22.bytesToHex)(proto.nodeTx),
|
|
31170
|
+
refundTx: (0, import_utils22.bytesToHex)(proto.refundTx),
|
|
30682
31171
|
vout: proto.vout,
|
|
30683
|
-
verifyingPublicKey: (0,
|
|
30684
|
-
ownerIdentityPublicKey: (0,
|
|
31172
|
+
verifyingPublicKey: (0, import_utils22.bytesToHex)(proto.verifyingPublicKey),
|
|
31173
|
+
ownerIdentityPublicKey: (0, import_utils22.bytesToHex)(proto.ownerIdentityPublicKey),
|
|
30685
31174
|
signingKeyshare: proto.signingKeyshare,
|
|
30686
31175
|
status: proto.status,
|
|
30687
31176
|
network: Network[proto.network]
|
|
@@ -30690,14 +31179,14 @@ function mapTreeNodeToWalletLeaf(proto) {
|
|
|
30690
31179
|
function mapTransferLeafToWalletTransferLeaf(proto) {
|
|
30691
31180
|
return {
|
|
30692
31181
|
leaf: proto.leaf ? mapTreeNodeToWalletLeaf(proto.leaf) : void 0,
|
|
30693
|
-
secretCipher: (0,
|
|
30694
|
-
signature: (0,
|
|
30695
|
-
intermediateRefundTx: (0,
|
|
31182
|
+
secretCipher: (0, import_utils22.bytesToHex)(proto.secretCipher),
|
|
31183
|
+
signature: (0, import_utils22.bytesToHex)(proto.signature),
|
|
31184
|
+
intermediateRefundTx: (0, import_utils22.bytesToHex)(proto.intermediateRefundTx)
|
|
30696
31185
|
};
|
|
30697
31186
|
}
|
|
30698
31187
|
function mapTransferToWalletTransfer(proto, identityPublicKey, userRequest) {
|
|
30699
|
-
const receiverIdentityPublicKey = (0,
|
|
30700
|
-
const senderIdentityPublicKey = (0,
|
|
31188
|
+
const receiverIdentityPublicKey = (0, import_utils22.bytesToHex)(proto.receiverIdentityPublicKey);
|
|
31189
|
+
const senderIdentityPublicKey = (0, import_utils22.bytesToHex)(proto.senderIdentityPublicKey);
|
|
30701
31190
|
return {
|
|
30702
31191
|
id: proto.id,
|
|
30703
31192
|
senderIdentityPublicKey,
|
|
@@ -30889,7 +31378,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
30889
31378
|
try {
|
|
30890
31379
|
if (event?.$case === "transfer" && event.transfer.transfer && event.transfer.transfer.type !== 40 /* COUNTER_SWAP */) {
|
|
30891
31380
|
const { senderIdentityPublicKey, receiverIdentityPublicKey } = event.transfer.transfer;
|
|
30892
|
-
if (event.transfer.transfer && !(0,
|
|
31381
|
+
if (event.transfer.transfer && !(0, import_utils23.equalBytes)(senderIdentityPublicKey, receiverIdentityPublicKey)) {
|
|
30893
31382
|
await this.claimTransfer({
|
|
30894
31383
|
transfer: event.transfer.transfer,
|
|
30895
31384
|
emit: true,
|
|
@@ -31054,10 +31543,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31054
31543
|
leavesToIgnore.add(nodeId);
|
|
31055
31544
|
continue;
|
|
31056
31545
|
}
|
|
31057
|
-
if (leaf.status !== operatorLeaf.status || !leaf.signingKeyshare || !operatorLeaf.signingKeyshare || !(0,
|
|
31546
|
+
if (leaf.status !== operatorLeaf.status || !leaf.signingKeyshare || !operatorLeaf.signingKeyshare || !(0, import_utils23.equalBytes)(
|
|
31058
31547
|
leaf.signingKeyshare.publicKey,
|
|
31059
31548
|
operatorLeaf.signingKeyshare.publicKey
|
|
31060
|
-
) || !(0,
|
|
31549
|
+
) || !(0, import_utils23.equalBytes)(leaf.nodeTx, operatorLeaf.nodeTx)) {
|
|
31061
31550
|
leavesToIgnore.add(nodeId);
|
|
31062
31551
|
}
|
|
31063
31552
|
}
|
|
@@ -31108,7 +31597,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31108
31597
|
});
|
|
31109
31598
|
}
|
|
31110
31599
|
verifyKey(pubkey1, pubkey2, verifyingKey) {
|
|
31111
|
-
return (0,
|
|
31600
|
+
return (0, import_utils23.equalBytes)(addPublicKeys(pubkey1, pubkey2), verifyingKey);
|
|
31112
31601
|
}
|
|
31113
31602
|
async selectLeaves(targetAmounts) {
|
|
31114
31603
|
if (targetAmounts.length === 0) {
|
|
@@ -31266,7 +31755,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31266
31755
|
* @returns {Promise<string>} The identity public key as a hex string.
|
|
31267
31756
|
*/
|
|
31268
31757
|
async getIdentityPublicKey() {
|
|
31269
|
-
return (0,
|
|
31758
|
+
return (0, import_utils23.bytesToHex)(await this.config.signer.getIdentityPublicKey());
|
|
31270
31759
|
}
|
|
31271
31760
|
/**
|
|
31272
31761
|
* Gets the Spark address of the wallet.
|
|
@@ -31276,7 +31765,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31276
31765
|
async getSparkAddress() {
|
|
31277
31766
|
if (!this.sparkAddress) {
|
|
31278
31767
|
this.sparkAddress = encodeSparkAddress({
|
|
31279
|
-
identityPublicKey: (0,
|
|
31768
|
+
identityPublicKey: (0, import_utils23.bytesToHex)(
|
|
31280
31769
|
await this.config.signer.getIdentityPublicKey()
|
|
31281
31770
|
),
|
|
31282
31771
|
network: this.config.getNetworkType()
|
|
@@ -31339,7 +31828,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31339
31828
|
$case: "tokensPayment",
|
|
31340
31829
|
tokensPayment: {
|
|
31341
31830
|
tokenIdentifier: decodedTokenIdentifier ?? void 0,
|
|
31342
|
-
amount: amount ? (0,
|
|
31831
|
+
amount: amount ? (0, import_utils23.numberToVarBytesBE)(amount) : void 0
|
|
31343
31832
|
}
|
|
31344
31833
|
};
|
|
31345
31834
|
const invoiceFields = {
|
|
@@ -31347,7 +31836,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31347
31836
|
id: (0, import_uuidv75.uuidv7obj)().bytes,
|
|
31348
31837
|
paymentType: protoPayment,
|
|
31349
31838
|
memo: memo ?? void 0,
|
|
31350
|
-
senderPublicKey: senderPublicKey ? (0,
|
|
31839
|
+
senderPublicKey: senderPublicKey ? (0, import_utils23.hexToBytes)(senderPublicKey) : void 0,
|
|
31351
31840
|
expiryTime: expiryTime ?? void 0
|
|
31352
31841
|
};
|
|
31353
31842
|
validateSparkInvoiceFields(invoiceFields);
|
|
@@ -31360,7 +31849,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31360
31849
|
const signature = await this.config.signer.signSchnorrWithIdentityKey(hash);
|
|
31361
31850
|
return encodeSparkAddressWithSignature(
|
|
31362
31851
|
{
|
|
31363
|
-
identityPublicKey: (0,
|
|
31852
|
+
identityPublicKey: (0, import_utils23.bytesToHex)(identityPublicKey),
|
|
31364
31853
|
network: this.config.getNetworkType(),
|
|
31365
31854
|
sparkInvoiceFields: invoiceFields
|
|
31366
31855
|
},
|
|
@@ -31406,7 +31895,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31406
31895
|
mnemonic = mnemonicOrSeed;
|
|
31407
31896
|
seed = await this.config.signer.mnemonicToSeed(mnemonicOrSeed);
|
|
31408
31897
|
} else {
|
|
31409
|
-
seed = (0,
|
|
31898
|
+
seed = (0, import_utils23.hexToBytes)(mnemonicOrSeed);
|
|
31410
31899
|
}
|
|
31411
31900
|
}
|
|
31412
31901
|
await this.initWalletFromSeed(seed, accountNumber);
|
|
@@ -31428,7 +31917,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31428
31917
|
});
|
|
31429
31918
|
}
|
|
31430
31919
|
this.sparkAddress = encodeSparkAddress({
|
|
31431
|
-
identityPublicKey: (0,
|
|
31920
|
+
identityPublicKey: (0, import_utils23.bytesToHex)(identityPublicKey),
|
|
31432
31921
|
network: this.config.getNetworkType()
|
|
31433
31922
|
});
|
|
31434
31923
|
return this.sparkAddress;
|
|
@@ -31548,7 +32037,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31548
32037
|
directFromCpfpSignatureMap
|
|
31549
32038
|
} = await this.transferService.startSwapSignRefund(
|
|
31550
32039
|
leafKeyTweaks,
|
|
31551
|
-
(0,
|
|
32040
|
+
(0, import_utils23.hexToBytes)(this.config.getSspIdentityPublicKey()),
|
|
31552
32041
|
new Date(Date.now() + 2 * 60 * 1e3)
|
|
31553
32042
|
);
|
|
31554
32043
|
try {
|
|
@@ -31608,18 +32097,18 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31608
32097
|
const userLeaves = [];
|
|
31609
32098
|
userLeaves.push({
|
|
31610
32099
|
leaf_id: transfer.leaves[0].leaf.id,
|
|
31611
|
-
raw_unsigned_refund_transaction: (0,
|
|
32100
|
+
raw_unsigned_refund_transaction: (0, import_utils23.bytesToHex)(
|
|
31612
32101
|
transfer.leaves[0].intermediateRefundTx
|
|
31613
32102
|
),
|
|
31614
|
-
direct_raw_unsigned_refund_transaction: (0,
|
|
32103
|
+
direct_raw_unsigned_refund_transaction: (0, import_utils23.bytesToHex)(
|
|
31615
32104
|
transfer.leaves[0].intermediateDirectRefundTx
|
|
31616
32105
|
),
|
|
31617
|
-
direct_from_cpfp_raw_unsigned_refund_transaction: (0,
|
|
32106
|
+
direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils23.bytesToHex)(
|
|
31618
32107
|
transfer.leaves[0].intermediateDirectFromCpfpRefundTx
|
|
31619
32108
|
),
|
|
31620
|
-
adaptor_added_signature: (0,
|
|
31621
|
-
direct_adaptor_added_signature: (0,
|
|
31622
|
-
direct_from_cpfp_adaptor_added_signature: (0,
|
|
32109
|
+
adaptor_added_signature: (0, import_utils23.bytesToHex)(cpfpAdaptorSignature),
|
|
32110
|
+
direct_adaptor_added_signature: (0, import_utils23.bytesToHex)(directAdaptorSignature),
|
|
32111
|
+
direct_from_cpfp_adaptor_added_signature: (0, import_utils23.bytesToHex)(
|
|
31623
32112
|
directFromCpfpAdaptorSignature
|
|
31624
32113
|
)
|
|
31625
32114
|
});
|
|
@@ -31672,24 +32161,24 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31672
32161
|
}
|
|
31673
32162
|
userLeaves.push({
|
|
31674
32163
|
leaf_id: leaf.leaf.id,
|
|
31675
|
-
raw_unsigned_refund_transaction: (0,
|
|
32164
|
+
raw_unsigned_refund_transaction: (0, import_utils23.bytesToHex)(
|
|
31676
32165
|
leaf.intermediateRefundTx
|
|
31677
32166
|
),
|
|
31678
|
-
direct_raw_unsigned_refund_transaction: (0,
|
|
32167
|
+
direct_raw_unsigned_refund_transaction: (0, import_utils23.bytesToHex)(
|
|
31679
32168
|
leaf.intermediateDirectRefundTx
|
|
31680
32169
|
),
|
|
31681
|
-
direct_from_cpfp_raw_unsigned_refund_transaction: (0,
|
|
32170
|
+
direct_from_cpfp_raw_unsigned_refund_transaction: (0, import_utils23.bytesToHex)(
|
|
31682
32171
|
leaf.intermediateDirectFromCpfpRefundTx
|
|
31683
32172
|
),
|
|
31684
|
-
adaptor_added_signature: (0,
|
|
31685
|
-
direct_adaptor_added_signature: (0,
|
|
31686
|
-
direct_from_cpfp_adaptor_added_signature: (0,
|
|
32173
|
+
adaptor_added_signature: (0, import_utils23.bytesToHex)(cpfpSignature),
|
|
32174
|
+
direct_adaptor_added_signature: (0, import_utils23.bytesToHex)(directSignature),
|
|
32175
|
+
direct_from_cpfp_adaptor_added_signature: (0, import_utils23.bytesToHex)(
|
|
31687
32176
|
directFromCpfpSignature
|
|
31688
32177
|
)
|
|
31689
32178
|
});
|
|
31690
32179
|
}
|
|
31691
32180
|
const sspClient = this.getSspClient();
|
|
31692
|
-
const cpfpAdaptorPubkey = (0,
|
|
32181
|
+
const cpfpAdaptorPubkey = (0, import_utils23.bytesToHex)(
|
|
31693
32182
|
import_secp256k115.secp256k1.getPublicKey(cpfpAdaptorPrivateKey)
|
|
31694
32183
|
);
|
|
31695
32184
|
if (!cpfpAdaptorPubkey) {
|
|
@@ -31697,13 +32186,13 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31697
32186
|
}
|
|
31698
32187
|
let directAdaptorPubkey;
|
|
31699
32188
|
if (directAdaptorPrivateKey.length > 0) {
|
|
31700
|
-
directAdaptorPubkey = (0,
|
|
32189
|
+
directAdaptorPubkey = (0, import_utils23.bytesToHex)(
|
|
31701
32190
|
import_secp256k115.secp256k1.getPublicKey(directAdaptorPrivateKey)
|
|
31702
32191
|
);
|
|
31703
32192
|
}
|
|
31704
32193
|
let directFromCpfpAdaptorPubkey;
|
|
31705
32194
|
if (directFromCpfpAdaptorPrivateKey.length > 0) {
|
|
31706
|
-
directFromCpfpAdaptorPubkey = (0,
|
|
32195
|
+
directFromCpfpAdaptorPubkey = (0, import_utils23.bytesToHex)(
|
|
31707
32196
|
import_secp256k115.secp256k1.getPublicKey(directFromCpfpAdaptorPrivateKey)
|
|
31708
32197
|
);
|
|
31709
32198
|
}
|
|
@@ -31763,7 +32252,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31763
32252
|
throw new Error(`Leaf not found for node ${nodeId}`);
|
|
31764
32253
|
}
|
|
31765
32254
|
const cpfpNodeTx = getTxFromRawTxBytes(node.nodeTx);
|
|
31766
|
-
const cpfpRefundTxBytes = (0,
|
|
32255
|
+
const cpfpRefundTxBytes = (0, import_utils23.hexToBytes)(leaf.rawUnsignedRefundTransaction);
|
|
31767
32256
|
const cpfpRefundTx = getTxFromRawTxBytes(cpfpRefundTxBytes);
|
|
31768
32257
|
const cpfpSighash = getSigHashFromTx(
|
|
31769
32258
|
cpfpRefundTx,
|
|
@@ -31772,7 +32261,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31772
32261
|
);
|
|
31773
32262
|
const nodePublicKey = node.verifyingPublicKey;
|
|
31774
32263
|
const taprootKey = computeTaprootKeyNoScript(nodePublicKey.slice(1));
|
|
31775
|
-
const cpfpAdaptorSignatureBytes = (0,
|
|
32264
|
+
const cpfpAdaptorSignatureBytes = (0, import_utils23.hexToBytes)(
|
|
31776
32265
|
leaf.adaptorSignedSignature
|
|
31777
32266
|
);
|
|
31778
32267
|
applyAdaptorToSignature(
|
|
@@ -31783,7 +32272,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31783
32272
|
);
|
|
31784
32273
|
if (leaf.directRawUnsignedRefundTransaction) {
|
|
31785
32274
|
const directNodeTx = getTxFromRawTxBytes(node.directTx);
|
|
31786
|
-
const directRefundTxBytes = (0,
|
|
32275
|
+
const directRefundTxBytes = (0, import_utils23.hexToBytes)(
|
|
31787
32276
|
leaf.directRawUnsignedRefundTransaction
|
|
31788
32277
|
);
|
|
31789
32278
|
const directRefundTx = getTxFromRawTxBytes(directRefundTxBytes);
|
|
@@ -31797,7 +32286,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31797
32286
|
`Direct adaptor signed signature missing for node ${nodeId}`
|
|
31798
32287
|
);
|
|
31799
32288
|
}
|
|
31800
|
-
const directAdaptorSignatureBytes = (0,
|
|
32289
|
+
const directAdaptorSignatureBytes = (0, import_utils23.hexToBytes)(
|
|
31801
32290
|
leaf.directAdaptorSignedSignature
|
|
31802
32291
|
);
|
|
31803
32292
|
applyAdaptorToSignature(
|
|
@@ -31808,7 +32297,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31808
32297
|
);
|
|
31809
32298
|
}
|
|
31810
32299
|
if (leaf.directFromCpfpRawUnsignedRefundTransaction) {
|
|
31811
|
-
const directFromCpfpRefundTxBytes = (0,
|
|
32300
|
+
const directFromCpfpRefundTxBytes = (0, import_utils23.hexToBytes)(
|
|
31812
32301
|
leaf.directFromCpfpRawUnsignedRefundTransaction
|
|
31813
32302
|
);
|
|
31814
32303
|
const directFromCpfpRefundTx = getTxFromRawTxBytes(
|
|
@@ -31824,7 +32313,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31824
32313
|
`Direct adaptor signed signature missing for node ${nodeId}`
|
|
31825
32314
|
);
|
|
31826
32315
|
}
|
|
31827
|
-
const directFromCpfpAdaptorSignatureBytes = (0,
|
|
32316
|
+
const directFromCpfpAdaptorSignatureBytes = (0, import_utils23.hexToBytes)(
|
|
31828
32317
|
leaf.directFromCpfpAdaptorSignedSignature
|
|
31829
32318
|
);
|
|
31830
32319
|
applyAdaptorToSignature(
|
|
@@ -31843,9 +32332,9 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31843
32332
|
directFromCpfpSignatureMap
|
|
31844
32333
|
);
|
|
31845
32334
|
const completeResponse = await sspClient.completeLeaveSwap({
|
|
31846
|
-
adaptorSecretKey: (0,
|
|
31847
|
-
directAdaptorSecretKey: (0,
|
|
31848
|
-
directFromCpfpAdaptorSecretKey: (0,
|
|
32335
|
+
adaptorSecretKey: (0, import_utils23.bytesToHex)(cpfpAdaptorPrivateKey),
|
|
32336
|
+
directAdaptorSecretKey: (0, import_utils23.bytesToHex)(directAdaptorPrivateKey),
|
|
32337
|
+
directFromCpfpAdaptorSecretKey: (0, import_utils23.bytesToHex)(
|
|
31849
32338
|
directFromCpfpAdaptorPrivateKey
|
|
31850
32339
|
),
|
|
31851
32340
|
userOutboundTransferExternalId: transfer.id,
|
|
@@ -31876,7 +32365,6 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31876
32365
|
message: e.message,
|
|
31877
32366
|
stack: e.stack
|
|
31878
32367
|
});
|
|
31879
|
-
await this.cancelAllSenderInitiatedTransfers();
|
|
31880
32368
|
throw new Error(`Failed to request leaves swap: ${e}`);
|
|
31881
32369
|
}
|
|
31882
32370
|
}
|
|
@@ -31940,12 +32428,12 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31940
32428
|
let tokenMetadataMap = /* @__PURE__ */ new Map();
|
|
31941
32429
|
for (const [tokenIdentifier, metadata] of this.tokenMetadata) {
|
|
31942
32430
|
tokenMetadataMap.set(tokenIdentifier, {
|
|
31943
|
-
tokenPublicKey: (0,
|
|
32431
|
+
tokenPublicKey: (0, import_utils23.bytesToHex)(metadata.issuerPublicKey),
|
|
31944
32432
|
rawTokenIdentifier: metadata.tokenIdentifier,
|
|
31945
32433
|
tokenName: metadata.tokenName,
|
|
31946
32434
|
tokenTicker: metadata.tokenTicker,
|
|
31947
32435
|
decimals: metadata.decimals,
|
|
31948
|
-
maxSupply: (0,
|
|
32436
|
+
maxSupply: (0, import_utils23.bytesToNumberBE)(metadata.maxSupply)
|
|
31949
32437
|
});
|
|
31950
32438
|
}
|
|
31951
32439
|
return tokenMetadataMap;
|
|
@@ -31980,7 +32468,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31980
32468
|
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
31981
32469
|
*/
|
|
31982
32470
|
async getSingleUseDepositAddress() {
|
|
31983
|
-
return await this.generateDepositAddress(
|
|
32471
|
+
return await this.generateDepositAddress();
|
|
31984
32472
|
}
|
|
31985
32473
|
/**
|
|
31986
32474
|
* Generates a new static deposit address for receiving bitcoin funds.
|
|
@@ -31989,43 +32477,32 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
31989
32477
|
* @returns {Promise<string>} A Bitcoin address for depositing funds
|
|
31990
32478
|
*/
|
|
31991
32479
|
async getStaticDepositAddress() {
|
|
31992
|
-
|
|
31993
|
-
|
|
31994
|
-
|
|
31995
|
-
|
|
31996
|
-
|
|
31997
|
-
|
|
31998
|
-
|
|
31999
|
-
|
|
32000
|
-
|
|
32001
|
-
}
|
|
32002
|
-
} else {
|
|
32003
|
-
throw error;
|
|
32004
|
-
}
|
|
32480
|
+
const signingPubkey = await this.config.signer.getStaticDepositSigningKey(0);
|
|
32481
|
+
const address2 = await this.depositService.generateStaticDepositAddress({
|
|
32482
|
+
signingPubkey
|
|
32483
|
+
});
|
|
32484
|
+
if (!address2.depositAddress) {
|
|
32485
|
+
throw new RPCError("Failed to generate static deposit address", {
|
|
32486
|
+
method: "generateStaticDepositAddress",
|
|
32487
|
+
params: { signingPubkey }
|
|
32488
|
+
});
|
|
32005
32489
|
}
|
|
32490
|
+
return address2.depositAddress.address;
|
|
32006
32491
|
}
|
|
32007
32492
|
/**
|
|
32008
32493
|
* Generates a deposit address for receiving funds.
|
|
32009
|
-
*
|
|
32010
|
-
* @param {boolean} static - Whether the address is static or single use
|
|
32011
32494
|
* @returns {Promise<string>} A deposit address
|
|
32012
32495
|
* @private
|
|
32013
32496
|
*/
|
|
32014
|
-
async generateDepositAddress(
|
|
32497
|
+
async generateDepositAddress() {
|
|
32015
32498
|
const leafId = (0, import_uuidv75.uuidv7)();
|
|
32016
|
-
|
|
32017
|
-
|
|
32018
|
-
|
|
32019
|
-
}
|
|
32020
|
-
signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
|
|
32021
|
-
type: "leaf" /* LEAF */,
|
|
32022
|
-
path: leafId
|
|
32023
|
-
});
|
|
32024
|
-
}
|
|
32499
|
+
const signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
|
|
32500
|
+
type: "leaf" /* LEAF */,
|
|
32501
|
+
path: leafId
|
|
32502
|
+
});
|
|
32025
32503
|
const address2 = await this.depositService.generateDepositAddress({
|
|
32026
32504
|
signingPubkey,
|
|
32027
|
-
leafId
|
|
32028
|
-
isStatic
|
|
32505
|
+
leafId
|
|
32029
32506
|
});
|
|
32030
32507
|
if (!address2.depositAddress) {
|
|
32031
32508
|
throw new RPCError("Failed to generate deposit address", {
|
|
@@ -32052,7 +32529,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32052
32529
|
* @param offset - Pagination offset (default 0).
|
|
32053
32530
|
* @returns {Promise<{ txid: string, vout: number }[]>} List of confirmed UTXOs.
|
|
32054
32531
|
*/
|
|
32055
|
-
async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0) {
|
|
32532
|
+
async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0, excludeClaimed = false) {
|
|
32056
32533
|
if (!depositAddress) {
|
|
32057
32534
|
throw new ValidationError("Deposit address cannot be empty", {
|
|
32058
32535
|
field: "depositAddress"
|
|
@@ -32066,10 +32543,11 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32066
32543
|
address: depositAddress,
|
|
32067
32544
|
network: NetworkToProto[this.config.getNetwork()],
|
|
32068
32545
|
limit,
|
|
32069
|
-
offset
|
|
32546
|
+
offset,
|
|
32547
|
+
excludeClaimed
|
|
32070
32548
|
});
|
|
32071
32549
|
return response.utxos.map((utxo) => ({
|
|
32072
|
-
txid: (0,
|
|
32550
|
+
txid: (0, import_utils23.bytesToHex)(utxo.txid),
|
|
32073
32551
|
vout: utxo.vout
|
|
32074
32552
|
})) ?? [];
|
|
32075
32553
|
} catch (error) {
|
|
@@ -32139,7 +32617,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32139
32617
|
if (network === BitcoinNetwork_default.FUTURE_VALUE) {
|
|
32140
32618
|
network = BitcoinNetwork_default.REGTEST;
|
|
32141
32619
|
}
|
|
32142
|
-
const depositSecretKey = (0,
|
|
32620
|
+
const depositSecretKey = (0, import_utils23.bytesToHex)(
|
|
32143
32621
|
await this.config.signer.getStaticDepositSecretKey(0)
|
|
32144
32622
|
);
|
|
32145
32623
|
const message = await this.getStaticDepositSigningPayload(
|
|
@@ -32152,7 +32630,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32152
32630
|
);
|
|
32153
32631
|
const hashBuffer = (0, import_sha212.sha256)(message);
|
|
32154
32632
|
const signatureBytes = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
|
|
32155
|
-
const signature = (0,
|
|
32633
|
+
const signature = (0, import_utils23.bytesToHex)(signatureBytes);
|
|
32156
32634
|
const response = await this.sspClient.claimStaticDeposit({
|
|
32157
32635
|
transactionId,
|
|
32158
32636
|
outputIndex,
|
|
@@ -32304,7 +32782,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32304
32782
|
networkJSON.toLowerCase(),
|
|
32305
32783
|
2 /* Refund */,
|
|
32306
32784
|
creditAmountSats,
|
|
32307
|
-
(0,
|
|
32785
|
+
(0, import_utils23.bytesToHex)(spendTxSighash)
|
|
32308
32786
|
);
|
|
32309
32787
|
const hashBuffer = (0, import_sha212.sha256)(message);
|
|
32310
32788
|
const swapResponseUserSignature = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
|
|
@@ -32313,7 +32791,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32313
32791
|
);
|
|
32314
32792
|
const swapResponse = await sparkClient.initiate_static_deposit_utxo_refund({
|
|
32315
32793
|
onChainUtxo: {
|
|
32316
|
-
txid: (0,
|
|
32794
|
+
txid: (0, import_utils23.hexToBytes)(depositTransactionId),
|
|
32317
32795
|
vout: outputIndex,
|
|
32318
32796
|
network: networkType
|
|
32319
32797
|
},
|
|
@@ -32349,6 +32827,64 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32349
32827
|
});
|
|
32350
32828
|
return tx.hex;
|
|
32351
32829
|
}
|
|
32830
|
+
/**
|
|
32831
|
+
* Refunds a static deposit and broadcasts the transaction to the network.
|
|
32832
|
+
*
|
|
32833
|
+
* @param {Object} params - The refund parameters
|
|
32834
|
+
* @param {string} params.depositTransactionId - The ID of the transaction
|
|
32835
|
+
* @param {number} [params.outputIndex] - The index of the output
|
|
32836
|
+
* @param {string} params.destinationAddress - The destination address
|
|
32837
|
+
* @param {number} [params.satsPerVbyteFee] - The fee per vbyte to refund
|
|
32838
|
+
* @returns {Promise<string>} The transaction ID
|
|
32839
|
+
*/
|
|
32840
|
+
async refundAndBroadcastStaticDeposit({
|
|
32841
|
+
depositTransactionId,
|
|
32842
|
+
outputIndex,
|
|
32843
|
+
destinationAddress,
|
|
32844
|
+
satsPerVbyteFee
|
|
32845
|
+
}) {
|
|
32846
|
+
const txHex = await this.refundStaticDeposit({
|
|
32847
|
+
depositTransactionId,
|
|
32848
|
+
outputIndex,
|
|
32849
|
+
destinationAddress,
|
|
32850
|
+
satsPerVbyteFee
|
|
32851
|
+
});
|
|
32852
|
+
return await this.broadcastTx(txHex);
|
|
32853
|
+
}
|
|
32854
|
+
/**
|
|
32855
|
+
* Broadcasts a transaction to the network.
|
|
32856
|
+
*
|
|
32857
|
+
* @param {string} txHex - The hex of the transaction
|
|
32858
|
+
* @returns {Promise<string>} The transaction ID
|
|
32859
|
+
*/
|
|
32860
|
+
async broadcastTx(txHex) {
|
|
32861
|
+
if (!txHex) {
|
|
32862
|
+
throw new ValidationError("Transaction hex cannot be empty", {
|
|
32863
|
+
field: "txHex"
|
|
32864
|
+
});
|
|
32865
|
+
}
|
|
32866
|
+
const { fetch, Headers: Headers2 } = getFetch();
|
|
32867
|
+
const baseUrl = this.config.getElectrsUrl();
|
|
32868
|
+
const headers = new Headers2();
|
|
32869
|
+
if (this.config.getNetwork() === 4 /* LOCAL */) {
|
|
32870
|
+
const localFaucet = BitcoinFaucet.getInstance();
|
|
32871
|
+
const response = await localFaucet.broadcastTx(txHex);
|
|
32872
|
+
return response;
|
|
32873
|
+
} else {
|
|
32874
|
+
if (this.config.getNetwork() === 3 /* REGTEST */) {
|
|
32875
|
+
const auth = btoa(
|
|
32876
|
+
`${ELECTRS_CREDENTIALS.username}:${ELECTRS_CREDENTIALS.password}`
|
|
32877
|
+
);
|
|
32878
|
+
headers.set("Authorization", `Basic ${auth}`);
|
|
32879
|
+
}
|
|
32880
|
+
const response = await fetch(`${baseUrl}/tx`, {
|
|
32881
|
+
method: "POST",
|
|
32882
|
+
body: txHex,
|
|
32883
|
+
headers
|
|
32884
|
+
});
|
|
32885
|
+
return response.text();
|
|
32886
|
+
}
|
|
32887
|
+
}
|
|
32352
32888
|
async getStaticDepositSigningPayload(transactionID, outputIndex, network, requestType, creditAmountSats, sspSignature) {
|
|
32353
32889
|
const encoder = new TextEncoder();
|
|
32354
32890
|
const parts = [];
|
|
@@ -32382,7 +32918,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32382
32918
|
creditAmountView.setUint32(0, lowerHalf, true);
|
|
32383
32919
|
creditAmountView.setUint32(4, upperHalf, true);
|
|
32384
32920
|
parts.push(new Uint8Array(creditAmountBuffer));
|
|
32385
|
-
parts.push((0,
|
|
32921
|
+
parts.push((0, import_utils23.hexToBytes)(sspSignature));
|
|
32386
32922
|
const totalLength = parts.reduce((sum, part) => sum + part.length, 0);
|
|
32387
32923
|
const payload = new Uint8Array(totalLength);
|
|
32388
32924
|
let offset = 0;
|
|
@@ -32787,9 +33323,9 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32787
33323
|
});
|
|
32788
33324
|
}
|
|
32789
33325
|
const signerIdentityPublicKey = await this.config.signer.getIdentityPublicKey();
|
|
32790
|
-
const isSelfTransfer = (0,
|
|
33326
|
+
const isSelfTransfer = (0, import_utils23.equalBytes)(
|
|
32791
33327
|
signerIdentityPublicKey,
|
|
32792
|
-
(0,
|
|
33328
|
+
(0, import_utils23.hexToBytes)(receiverAddress.identityPublicKey)
|
|
32793
33329
|
);
|
|
32794
33330
|
return await this.withLeaves(async () => {
|
|
32795
33331
|
let leavesToSend = (await this.selectLeaves([amountSats])).get(
|
|
@@ -32811,7 +33347,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32811
33347
|
);
|
|
32812
33348
|
const transfer = await this.transferService.sendTransferWithKeyTweaks(
|
|
32813
33349
|
leafKeyTweaks,
|
|
32814
|
-
(0,
|
|
33350
|
+
(0, import_utils23.hexToBytes)(receiverAddress.identityPublicKey)
|
|
32815
33351
|
);
|
|
32816
33352
|
const leavesToRemove = new Set(leavesToSend.map((leaf) => leaf.id));
|
|
32817
33353
|
this.leaves = this.leaves.filter((leaf) => !leavesToRemove.has(leaf.id));
|
|
@@ -32827,7 +33363,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32827
33363
|
}
|
|
32828
33364
|
return mapTransferToWalletTransfer(
|
|
32829
33365
|
transfer,
|
|
32830
|
-
(0,
|
|
33366
|
+
(0, import_utils23.bytesToHex)(await this.config.signer.getIdentityPublicKey())
|
|
32831
33367
|
);
|
|
32832
33368
|
});
|
|
32833
33369
|
}
|
|
@@ -33087,24 +33623,6 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33087
33623
|
(result) => result.status === "fulfilled" && result.value !== null
|
|
33088
33624
|
).map((result) => result.value);
|
|
33089
33625
|
}
|
|
33090
|
-
/**
|
|
33091
|
-
* Cancels all sender-initiated transfers.
|
|
33092
|
-
*
|
|
33093
|
-
* @returns {Promise<void>}
|
|
33094
|
-
* @private
|
|
33095
|
-
*/
|
|
33096
|
-
async cancelAllSenderInitiatedTransfers() {
|
|
33097
|
-
for (const operator of Object.values(this.config.getSigningOperators())) {
|
|
33098
|
-
const transfers = await this.transferService.queryPendingTransfersBySender(
|
|
33099
|
-
operator.address
|
|
33100
|
-
);
|
|
33101
|
-
for (const transfer of transfers.transfers) {
|
|
33102
|
-
if (transfer.status === 0 /* TRANSFER_STATUS_SENDER_INITIATED */) {
|
|
33103
|
-
await this.transferService.cancelTransfer(transfer, operator.address);
|
|
33104
|
-
}
|
|
33105
|
-
}
|
|
33106
|
-
}
|
|
33107
|
-
}
|
|
33108
33626
|
// ***** Lightning Flow *****
|
|
33109
33627
|
/**
|
|
33110
33628
|
* Creates a Lightning invoice for receiving payments.
|
|
@@ -33183,7 +33701,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33183
33701
|
const invoice2 = await sspClient.requestLightningReceive({
|
|
33184
33702
|
amountSats: amountSats2,
|
|
33185
33703
|
network: bitcoinNetwork,
|
|
33186
|
-
paymentHash: (0,
|
|
33704
|
+
paymentHash: (0, import_utils23.bytesToHex)(paymentHash),
|
|
33187
33705
|
expirySecs: expirySeconds,
|
|
33188
33706
|
memo: memo2,
|
|
33189
33707
|
includeSparkAddress,
|
|
@@ -33292,7 +33810,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33292
33810
|
const sparkFallbackAddress = decodedInvoice.fallbackAddress;
|
|
33293
33811
|
const paymentHash = decodedInvoice.paymentHash;
|
|
33294
33812
|
if (preferSpark) {
|
|
33295
|
-
if (sparkFallbackAddress === void 0 || isValidSparkFallback((0,
|
|
33813
|
+
if (sparkFallbackAddress === void 0 || isValidSparkFallback((0, import_utils23.hexToBytes)(sparkFallbackAddress)) === false) {
|
|
33296
33814
|
console.warn(
|
|
33297
33815
|
"No valid spark address found in invoice. Defaulting to lightning."
|
|
33298
33816
|
);
|
|
@@ -33346,10 +33864,10 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33346
33864
|
);
|
|
33347
33865
|
const swapResponse = await this.lightningService.swapNodesForPreimage({
|
|
33348
33866
|
leaves: leavesToSend,
|
|
33349
|
-
receiverIdentityPubkey: (0,
|
|
33867
|
+
receiverIdentityPubkey: (0, import_utils23.hexToBytes)(
|
|
33350
33868
|
this.config.getSspIdentityPublicKey()
|
|
33351
33869
|
),
|
|
33352
|
-
paymentHash: (0,
|
|
33870
|
+
paymentHash: (0, import_utils23.hexToBytes)(paymentHash),
|
|
33353
33871
|
isInboundPayment: false,
|
|
33354
33872
|
invoiceString: invoice,
|
|
33355
33873
|
feeSats: feeEstimate,
|
|
@@ -33467,7 +33985,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33467
33985
|
});
|
|
33468
33986
|
await this.syncTokenOutputs();
|
|
33469
33987
|
const bech32mTokenIdentifier = encodeBech32mTokenIdentifier({
|
|
33470
|
-
tokenIdentifier: (0,
|
|
33988
|
+
tokenIdentifier: (0, import_utils23.hexToBytes)(firstTokenIdentifierHexSeen),
|
|
33471
33989
|
network: this.config.getNetworkType()
|
|
33472
33990
|
});
|
|
33473
33991
|
const receiverOutputs = decoded.map((d) => ({
|
|
@@ -33655,11 +34173,11 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33655
34173
|
const connectorOutputs = [];
|
|
33656
34174
|
for (let i = 0; i < connectorTx.outputsLength - 1; i++) {
|
|
33657
34175
|
connectorOutputs.push({
|
|
33658
|
-
txid: (0,
|
|
34176
|
+
txid: (0, import_utils23.hexToBytes)(connectorTxId),
|
|
33659
34177
|
index: i
|
|
33660
34178
|
});
|
|
33661
34179
|
}
|
|
33662
|
-
const sspPubIdentityKey = (0,
|
|
34180
|
+
const sspPubIdentityKey = (0, import_utils23.hexToBytes)(this.config.getSspIdentityPublicKey());
|
|
33663
34181
|
const transfer = await this.coopExitService.getConnectorRefundSignatures({
|
|
33664
34182
|
leaves: leafKeyTweaks,
|
|
33665
34183
|
exitTxId: coopExitTxId,
|
|
@@ -33713,7 +34231,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33713
34231
|
return transfers?.[0];
|
|
33714
34232
|
}
|
|
33715
34233
|
async constructTransfersWithUserRequest(transfers) {
|
|
33716
|
-
const identityPublicKey = (0,
|
|
34234
|
+
const identityPublicKey = (0, import_utils23.bytesToHex)(
|
|
33717
34235
|
await this.config.signer.getIdentityPublicKey()
|
|
33718
34236
|
);
|
|
33719
34237
|
const userRequests = await this.sspClient?.getTransfers(
|
|
@@ -33957,7 +34475,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33957
34475
|
hash,
|
|
33958
34476
|
compact
|
|
33959
34477
|
);
|
|
33960
|
-
return (0,
|
|
34478
|
+
return (0, import_utils23.bytesToHex)(signature);
|
|
33961
34479
|
}
|
|
33962
34480
|
/**
|
|
33963
34481
|
* Validates a message with the identity key.
|
|
@@ -33969,7 +34487,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33969
34487
|
async validateMessageWithIdentityKey(message, signature) {
|
|
33970
34488
|
const hash = (0, import_sha212.sha256)(message);
|
|
33971
34489
|
if (typeof signature === "string") {
|
|
33972
|
-
signature = (0,
|
|
34490
|
+
signature = (0, import_utils23.hexToBytes)(signature);
|
|
33973
34491
|
}
|
|
33974
34492
|
return this.config.signer.validateMessageWithIdentityKey(hash, signature);
|
|
33975
34493
|
}
|
|
@@ -33982,7 +34500,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
33982
34500
|
*/
|
|
33983
34501
|
async signTransaction(txHex, keyType = "auto-detect") {
|
|
33984
34502
|
try {
|
|
33985
|
-
const tx = import_btc_signer6.Transaction.fromRaw((0,
|
|
34503
|
+
const tx = import_btc_signer6.Transaction.fromRaw((0, import_utils23.hexToBytes)(txHex));
|
|
33986
34504
|
let publicKey;
|
|
33987
34505
|
switch (keyType.toLowerCase()) {
|
|
33988
34506
|
case "identity":
|
|
@@ -34015,7 +34533,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34015
34533
|
publicKey,
|
|
34016
34534
|
this.config.getNetwork()
|
|
34017
34535
|
);
|
|
34018
|
-
if ((0,
|
|
34536
|
+
if ((0, import_utils23.bytesToHex)(script) === (0, import_utils23.bytesToHex)(identityScript)) {
|
|
34019
34537
|
try {
|
|
34020
34538
|
this.config.signer.signTransactionIndex(tx, i, publicKey);
|
|
34021
34539
|
inputsSigned++;
|
|
@@ -34059,13 +34577,13 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
34059
34577
|
depositPubKey,
|
|
34060
34578
|
this.config.getNetwork()
|
|
34061
34579
|
);
|
|
34062
|
-
if ((0,
|
|
34580
|
+
if ((0, import_utils23.bytesToHex)(script) === (0, import_utils23.bytesToHex)(identityScript)) {
|
|
34063
34581
|
return {
|
|
34064
34582
|
publicKey: identityPubKey,
|
|
34065
34583
|
keyType: "identity"
|
|
34066
34584
|
};
|
|
34067
34585
|
}
|
|
34068
|
-
if ((0,
|
|
34586
|
+
if ((0, import_utils23.bytesToHex)(script) === (0, import_utils23.bytesToHex)(depositScript)) {
|
|
34069
34587
|
return {
|
|
34070
34588
|
publicKey: depositPubKey,
|
|
34071
34589
|
keyType: "deposit"
|
|
@@ -34635,7 +35153,7 @@ async function isTxBroadcast(txid, baseUrl, network) {
|
|
|
34635
35153
|
|
|
34636
35154
|
// src/utils/unilateral-exit.ts
|
|
34637
35155
|
init_buffer();
|
|
34638
|
-
var
|
|
35156
|
+
var import_utils24 = require("@noble/curves/utils");
|
|
34639
35157
|
var import_legacy = require("@noble/hashes/legacy");
|
|
34640
35158
|
var import_sha213 = require("@noble/hashes/sha2");
|
|
34641
35159
|
var btc4 = __toESM(require("@scure/btc-signer"), 1);
|
|
@@ -34650,7 +35168,7 @@ function isEphemeralAnchorOutput(script, amount) {
|
|
|
34650
35168
|
}
|
|
34651
35169
|
async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network) {
|
|
34652
35170
|
const result = [];
|
|
34653
|
-
const nodes = nodeHexStrings.map((hex) => TreeNode.decode((0,
|
|
35171
|
+
const nodes = nodeHexStrings.map((hex) => TreeNode.decode((0, import_utils24.hexToBytes)(hex)));
|
|
34654
35172
|
const nodeMap = /* @__PURE__ */ new Map();
|
|
34655
35173
|
for (const node of nodes) {
|
|
34656
35174
|
nodeMap.set(node.id, node);
|
|
@@ -34706,10 +35224,10 @@ async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network)
|
|
|
34706
35224
|
}
|
|
34707
35225
|
}
|
|
34708
35226
|
for (const chainNode of chain) {
|
|
34709
|
-
const nodeTx = (0,
|
|
35227
|
+
const nodeTx = (0, import_utils24.bytesToHex)(chainNode.nodeTx);
|
|
34710
35228
|
transactions.push(nodeTx);
|
|
34711
35229
|
if (chainNode.id === node.id) {
|
|
34712
|
-
const refundTx = (0,
|
|
35230
|
+
const refundTx = (0, import_utils24.bytesToHex)(chainNode.refundTx);
|
|
34713
35231
|
transactions.push(refundTx);
|
|
34714
35232
|
}
|
|
34715
35233
|
}
|
|
@@ -34739,7 +35257,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
34739
35257
|
`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.`
|
|
34740
35258
|
);
|
|
34741
35259
|
}
|
|
34742
|
-
const nodeBytes = (0,
|
|
35260
|
+
const nodeBytes = (0, import_utils24.hexToBytes)(hex);
|
|
34743
35261
|
const node = TreeNode.decode(nodeBytes);
|
|
34744
35262
|
if (!node.id) {
|
|
34745
35263
|
throw new Error(
|
|
@@ -34815,7 +35333,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
34815
35333
|
}
|
|
34816
35334
|
}
|
|
34817
35335
|
for (const chainNode of chain) {
|
|
34818
|
-
let nodeTxHex = (0,
|
|
35336
|
+
let nodeTxHex = (0, import_utils24.bytesToHex)(chainNode.nodeTx);
|
|
34819
35337
|
try {
|
|
34820
35338
|
const txObj = getTxFromRawTxHex(nodeTxHex);
|
|
34821
35339
|
const txid = getTxId(txObj);
|
|
@@ -34832,7 +35350,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
34832
35350
|
for (let i = txObj.outputsLength - 1; i >= 0; i--) {
|
|
34833
35351
|
const output = txObj.getOutput(i);
|
|
34834
35352
|
if (output?.amount === 0n && output.script) {
|
|
34835
|
-
anchorOutputScriptHex = (0,
|
|
35353
|
+
anchorOutputScriptHex = (0, import_utils24.bytesToHex)(output.script);
|
|
34836
35354
|
break;
|
|
34837
35355
|
}
|
|
34838
35356
|
}
|
|
@@ -34853,11 +35371,11 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
34853
35371
|
usedUtxos,
|
|
34854
35372
|
correctedParentTx
|
|
34855
35373
|
} = constructFeeBumpTx(nodeTxHex, availableUtxos, feeRate, void 0);
|
|
34856
|
-
const feeBumpTx = btc4.Transaction.fromPSBT((0,
|
|
35374
|
+
const feeBumpTx = btc4.Transaction.fromPSBT((0, import_utils24.hexToBytes)(nodeFeeBumpPsbt));
|
|
34857
35375
|
var feeBumpOut = feeBumpTx.outputsLength === 1 ? feeBumpTx.getOutput(0) : null;
|
|
34858
35376
|
var feeBumpOutPubKey = null;
|
|
34859
35377
|
for (const usedUtxo of usedUtxos) {
|
|
34860
|
-
if (feeBumpOut && (0,
|
|
35378
|
+
if (feeBumpOut && (0, import_utils24.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
|
|
34861
35379
|
feeBumpOutPubKey = usedUtxo.publicKey;
|
|
34862
35380
|
}
|
|
34863
35381
|
const index = availableUtxos.findIndex(
|
|
@@ -34872,20 +35390,20 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
34872
35390
|
txid: getTxId(feeBumpTx),
|
|
34873
35391
|
vout: 0,
|
|
34874
35392
|
value: feeBumpOut.amount,
|
|
34875
|
-
script: (0,
|
|
35393
|
+
script: (0, import_utils24.bytesToHex)(feeBumpOut.script),
|
|
34876
35394
|
publicKey: feeBumpOutPubKey
|
|
34877
35395
|
});
|
|
34878
35396
|
const finalNodeTx = correctedParentTx || nodeTxHex;
|
|
34879
35397
|
txPackages.push({ tx: finalNodeTx, feeBumpPsbt: nodeFeeBumpPsbt });
|
|
34880
35398
|
if (chainNode.id === node.id) {
|
|
34881
|
-
let refundTxHex = (0,
|
|
35399
|
+
let refundTxHex = (0, import_utils24.bytesToHex)(chainNode.refundTx);
|
|
34882
35400
|
try {
|
|
34883
35401
|
const txObj = getTxFromRawTxHex(refundTxHex);
|
|
34884
35402
|
let anchorOutputScriptHex;
|
|
34885
35403
|
for (let i = txObj.outputsLength - 1; i >= 0; i--) {
|
|
34886
35404
|
const output = txObj.getOutput(i);
|
|
34887
35405
|
if (output?.amount === 0n && output.script) {
|
|
34888
|
-
anchorOutputScriptHex = (0,
|
|
35406
|
+
anchorOutputScriptHex = (0, import_utils24.bytesToHex)(output.script);
|
|
34889
35407
|
break;
|
|
34890
35408
|
}
|
|
34891
35409
|
}
|
|
@@ -34908,12 +35426,12 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
34908
35426
|
void 0
|
|
34909
35427
|
);
|
|
34910
35428
|
const feeBumpTx2 = btc4.Transaction.fromPSBT(
|
|
34911
|
-
(0,
|
|
35429
|
+
(0, import_utils24.hexToBytes)(refundFeeBump.feeBumpPsbt)
|
|
34912
35430
|
);
|
|
34913
35431
|
var feeBumpOut = feeBumpTx2.outputsLength === 1 ? feeBumpTx2.getOutput(0) : null;
|
|
34914
35432
|
var feeBumpOutPubKey = null;
|
|
34915
35433
|
for (const usedUtxo of usedUtxos) {
|
|
34916
|
-
if (feeBumpOut && (0,
|
|
35434
|
+
if (feeBumpOut && (0, import_utils24.bytesToHex)(feeBumpOut.script) == usedUtxo.script) {
|
|
34917
35435
|
feeBumpOutPubKey = usedUtxo.publicKey;
|
|
34918
35436
|
}
|
|
34919
35437
|
const index = availableUtxos.findIndex(
|
|
@@ -34928,7 +35446,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
|
|
|
34928
35446
|
txid: getTxId(feeBumpTx2),
|
|
34929
35447
|
vout: 0,
|
|
34930
35448
|
value: feeBumpOut.amount,
|
|
34931
|
-
script: (0,
|
|
35449
|
+
script: (0, import_utils24.bytesToHex)(feeBumpOut.script),
|
|
34932
35450
|
publicKey: feeBumpOutPubKey
|
|
34933
35451
|
});
|
|
34934
35452
|
txPackages.push({
|
|
@@ -35023,10 +35541,10 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
|
|
|
35023
35541
|
if (!fundingUtxo) {
|
|
35024
35542
|
throw new Error(`UTXO at index ${i} is undefined`);
|
|
35025
35543
|
}
|
|
35026
|
-
const pubKeyHash = hash160((0,
|
|
35544
|
+
const pubKeyHash = hash160((0, import_utils24.hexToBytes)(fundingUtxo.publicKey));
|
|
35027
35545
|
const scriptToUse = new Uint8Array([0, 20, ...pubKeyHash]);
|
|
35028
|
-
const providedScript = (0,
|
|
35029
|
-
if ((0,
|
|
35546
|
+
const providedScript = (0, import_utils24.hexToBytes)(fundingUtxo.script);
|
|
35547
|
+
if ((0, import_utils24.bytesToHex)(scriptToUse) !== (0, import_utils24.bytesToHex)(providedScript)) {
|
|
35030
35548
|
throw new Error(
|
|
35031
35549
|
`\u274C Derived script doesn't match provided script for UTXO ${i + 1}.`
|
|
35032
35550
|
);
|
|
@@ -35091,7 +35609,7 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
|
|
|
35091
35609
|
}
|
|
35092
35610
|
let psbtHex;
|
|
35093
35611
|
try {
|
|
35094
|
-
psbtHex = (0,
|
|
35612
|
+
psbtHex = (0, import_utils24.bytesToHex)(builder.toPSBT());
|
|
35095
35613
|
} catch (error) {
|
|
35096
35614
|
throw new Error(`Failed to extract transaction: ${error}`);
|
|
35097
35615
|
}
|