@buildonspark/spark-sdk 0.4.1 → 0.4.2
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 +11 -0
- package/dist/bare/index.cjs +1038 -236
- package/dist/bare/index.d.cts +143 -14
- package/dist/bare/index.d.ts +143 -14
- package/dist/bare/index.js +1043 -240
- package/dist/{chunk-4E23VB7E.js → chunk-6UVL674M.js} +2 -2
- package/dist/{chunk-YEBEN7XD.js → chunk-BHFVMNXO.js} +623 -16
- package/dist/{chunk-EV2PTGGR.js → chunk-JZODGME5.js} +1 -1
- package/dist/{chunk-JLF6WJ7K.js → chunk-LUOP2ATD.js} +1 -1
- package/dist/{chunk-4YFT7DAE.js → chunk-Q537QTDY.js} +1 -1
- package/dist/{chunk-W2S4FPZ4.js → chunk-SUGTL4PD.js} +250 -27
- package/dist/{chunk-JR7ZU6LX.js → chunk-U7EELMDO.js} +1 -1
- package/dist/{client-BaQf-5gD.d.ts → client-3MdPdtnA.d.ts} +1 -1
- package/dist/{client-BIqiUNy4.d.cts → client-BZFWaZ1l.d.cts} +1 -1
- package/dist/debug.cjs +1038 -241
- package/dist/debug.d.cts +5 -5
- package/dist/debug.d.ts +5 -5
- package/dist/debug.js +5 -5
- package/dist/graphql/objects/index.d.cts +3 -3
- package/dist/graphql/objects/index.d.ts +3 -3
- package/dist/index.cjs +923 -119
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/index.node.cjs +923 -119
- package/dist/index.node.d.cts +6 -6
- package/dist/index.node.d.ts +6 -6
- package/dist/index.node.js +5 -5
- package/dist/{logging-BLzoEEoP.d.ts → logging-g6Oib3Ua.d.ts} +3 -3
- package/dist/{logging-Cl-gGtZz.d.cts → logging-miPhbIyT.d.cts} +3 -3
- package/dist/native/index.react-native.cjs +923 -119
- package/dist/native/index.react-native.d.cts +141 -16
- package/dist/native/index.react-native.d.ts +141 -16
- package/dist/native/index.react-native.js +926 -121
- package/dist/proto/spark.cjs +623 -16
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark.js +19 -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-DOpheE8_.d.cts → spark-BWkABx3N.d.cts} +124 -3
- package/dist/{spark-DOpheE8_.d.ts → spark-BWkABx3N.d.ts} +124 -3
- package/dist/{spark-wallet.browser-XT25hMYM.d.ts → spark-wallet.browser-Cm-JMRQB.d.ts} +2 -2
- package/dist/{spark-wallet.browser-BGMpYML0.d.cts → spark-wallet.browser-M7zcmZYm.d.cts} +2 -2
- package/dist/{spark-wallet.node-CAfuCfrU.d.ts → spark-wallet.node-B4y08Ri5.d.ts} +2 -2
- package/dist/{spark-wallet.node-C8dbiFsD.d.cts → spark-wallet.node-BotQbNoI.d.cts} +2 -2
- package/dist/tests/test-utils.cjs +1030 -60
- package/dist/tests/test-utils.d.cts +4 -4
- package/dist/tests/test-utils.d.ts +4 -4
- package/dist/tests/test-utils.js +7 -7
- package/dist/{token-transactions-DhVLTxEY.d.cts → token-transactions-C95IPSyM.d.cts} +2 -2
- package/dist/{token-transactions-vcOZg63D.d.ts → token-transactions-SPf4ygYc.d.ts} +2 -2
- package/dist/types/index.cjs +614 -16
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +5 -5
- package/dist/{wallet-config-w9e62Plc.d.ts → wallet-config-CQW-mDqN.d.ts} +41 -17
- package/dist/{wallet-config-DVEoQg3w.d.cts → wallet-config-JYsN3izc.d.cts} +41 -17
- package/package.json +1 -1
- package/src/proto/spark.ts +842 -80
- package/src/services/lightning.ts +1 -1
- package/src/services/transfer.ts +0 -1
- package/src/spark-wallet/proto-descriptors.ts +1 -1
- package/src/spark-wallet/spark-wallet.ts +279 -16
- package/src/spark-wallet/types.ts +6 -7
- package/src/spark_descriptors.pb +0 -0
- package/src/tests/address.test.ts +10 -103
- package/src/tests/integration/address.test.ts +7 -17
- package/src/tests/integration/ssp/coop-exit.test.ts +0 -1
- package/src/tests/integration/ssp/lightning.test.ts +67 -2
- package/src/tests/integration/ssp/swap.test.ts +0 -1
- package/src/tests/integration/static_deposit.test.ts +2 -1
- package/src/tests/integration/transfer.test.ts +8 -28
- package/src/tests/token-hashing.test.ts +4 -4
- package/src/tests/xchain-address.test.ts +3 -3
- package/src/utils/address.ts +6 -4
|
@@ -689,6 +689,36 @@ function orderToJSON(object) {
|
|
|
689
689
|
return "UNRECOGNIZED";
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
|
+
function preimageRequestStatusFromJSON(object) {
|
|
693
|
+
switch (object) {
|
|
694
|
+
case 0:
|
|
695
|
+
case "PREIMAGE_REQUEST_STATUS_WAITING_FOR_PREIMAGE":
|
|
696
|
+
return 0 /* PREIMAGE_REQUEST_STATUS_WAITING_FOR_PREIMAGE */;
|
|
697
|
+
case 1:
|
|
698
|
+
case "PREIMAGE_REQUEST_STATUS_PREIMAGE_SHARED":
|
|
699
|
+
return 1 /* PREIMAGE_REQUEST_STATUS_PREIMAGE_SHARED */;
|
|
700
|
+
case 2:
|
|
701
|
+
case "PREIMAGE_REQUEST_STATUS_RETURNED":
|
|
702
|
+
return 2 /* PREIMAGE_REQUEST_STATUS_RETURNED */;
|
|
703
|
+
case -1:
|
|
704
|
+
case "UNRECOGNIZED":
|
|
705
|
+
default:
|
|
706
|
+
return -1 /* UNRECOGNIZED */;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
function preimageRequestStatusToJSON(object) {
|
|
710
|
+
switch (object) {
|
|
711
|
+
case 0 /* PREIMAGE_REQUEST_STATUS_WAITING_FOR_PREIMAGE */:
|
|
712
|
+
return "PREIMAGE_REQUEST_STATUS_WAITING_FOR_PREIMAGE";
|
|
713
|
+
case 1 /* PREIMAGE_REQUEST_STATUS_PREIMAGE_SHARED */:
|
|
714
|
+
return "PREIMAGE_REQUEST_STATUS_PREIMAGE_SHARED";
|
|
715
|
+
case 2 /* PREIMAGE_REQUEST_STATUS_RETURNED */:
|
|
716
|
+
return "PREIMAGE_REQUEST_STATUS_RETURNED";
|
|
717
|
+
case -1 /* UNRECOGNIZED */:
|
|
718
|
+
default:
|
|
719
|
+
return "UNRECOGNIZED";
|
|
720
|
+
}
|
|
721
|
+
}
|
|
692
722
|
function utxoSwapRequestTypeFromJSON(object) {
|
|
693
723
|
switch (object) {
|
|
694
724
|
case 0:
|
|
@@ -2987,7 +3017,6 @@ function createBaseRenewNodeZeroTimelockSigningJob() {
|
|
|
2987
3017
|
nodeTxSigningJob: void 0,
|
|
2988
3018
|
refundTxSigningJob: void 0,
|
|
2989
3019
|
directNodeTxSigningJob: void 0,
|
|
2990
|
-
directRefundTxSigningJob: void 0,
|
|
2991
3020
|
directFromCpfpRefundTxSigningJob: void 0
|
|
2992
3021
|
};
|
|
2993
3022
|
}
|
|
@@ -3002,9 +3031,6 @@ var RenewNodeZeroTimelockSigningJob = {
|
|
|
3002
3031
|
if (message.directNodeTxSigningJob !== void 0) {
|
|
3003
3032
|
UserSignedTxSigningJob.encode(message.directNodeTxSigningJob, writer.uint32(26).fork()).join();
|
|
3004
3033
|
}
|
|
3005
|
-
if (message.directRefundTxSigningJob !== void 0) {
|
|
3006
|
-
UserSignedTxSigningJob.encode(message.directRefundTxSigningJob, writer.uint32(34).fork()).join();
|
|
3007
|
-
}
|
|
3008
3034
|
if (message.directFromCpfpRefundTxSigningJob !== void 0) {
|
|
3009
3035
|
UserSignedTxSigningJob.encode(message.directFromCpfpRefundTxSigningJob, writer.uint32(42).fork()).join();
|
|
3010
3036
|
}
|
|
@@ -3038,13 +3064,6 @@ var RenewNodeZeroTimelockSigningJob = {
|
|
|
3038
3064
|
message.directNodeTxSigningJob = UserSignedTxSigningJob.decode(reader, reader.uint32());
|
|
3039
3065
|
continue;
|
|
3040
3066
|
}
|
|
3041
|
-
case 4: {
|
|
3042
|
-
if (tag !== 34) {
|
|
3043
|
-
break;
|
|
3044
|
-
}
|
|
3045
|
-
message.directRefundTxSigningJob = UserSignedTxSigningJob.decode(reader, reader.uint32());
|
|
3046
|
-
continue;
|
|
3047
|
-
}
|
|
3048
3067
|
case 5: {
|
|
3049
3068
|
if (tag !== 42) {
|
|
3050
3069
|
break;
|
|
@@ -3065,7 +3084,6 @@ var RenewNodeZeroTimelockSigningJob = {
|
|
|
3065
3084
|
nodeTxSigningJob: isSet3(object.nodeTxSigningJob) ? UserSignedTxSigningJob.fromJSON(object.nodeTxSigningJob) : void 0,
|
|
3066
3085
|
refundTxSigningJob: isSet3(object.refundTxSigningJob) ? UserSignedTxSigningJob.fromJSON(object.refundTxSigningJob) : void 0,
|
|
3067
3086
|
directNodeTxSigningJob: isSet3(object.directNodeTxSigningJob) ? UserSignedTxSigningJob.fromJSON(object.directNodeTxSigningJob) : void 0,
|
|
3068
|
-
directRefundTxSigningJob: isSet3(object.directRefundTxSigningJob) ? UserSignedTxSigningJob.fromJSON(object.directRefundTxSigningJob) : void 0,
|
|
3069
3087
|
directFromCpfpRefundTxSigningJob: isSet3(object.directFromCpfpRefundTxSigningJob) ? UserSignedTxSigningJob.fromJSON(object.directFromCpfpRefundTxSigningJob) : void 0
|
|
3070
3088
|
};
|
|
3071
3089
|
},
|
|
@@ -3080,9 +3098,6 @@ var RenewNodeZeroTimelockSigningJob = {
|
|
|
3080
3098
|
if (message.directNodeTxSigningJob !== void 0) {
|
|
3081
3099
|
obj.directNodeTxSigningJob = UserSignedTxSigningJob.toJSON(message.directNodeTxSigningJob);
|
|
3082
3100
|
}
|
|
3083
|
-
if (message.directRefundTxSigningJob !== void 0) {
|
|
3084
|
-
obj.directRefundTxSigningJob = UserSignedTxSigningJob.toJSON(message.directRefundTxSigningJob);
|
|
3085
|
-
}
|
|
3086
3101
|
if (message.directFromCpfpRefundTxSigningJob !== void 0) {
|
|
3087
3102
|
obj.directFromCpfpRefundTxSigningJob = UserSignedTxSigningJob.toJSON(message.directFromCpfpRefundTxSigningJob);
|
|
3088
3103
|
}
|
|
@@ -3096,7 +3111,6 @@ var RenewNodeZeroTimelockSigningJob = {
|
|
|
3096
3111
|
message.nodeTxSigningJob = object.nodeTxSigningJob !== void 0 && object.nodeTxSigningJob !== null ? UserSignedTxSigningJob.fromPartial(object.nodeTxSigningJob) : void 0;
|
|
3097
3112
|
message.refundTxSigningJob = object.refundTxSigningJob !== void 0 && object.refundTxSigningJob !== null ? UserSignedTxSigningJob.fromPartial(object.refundTxSigningJob) : void 0;
|
|
3098
3113
|
message.directNodeTxSigningJob = object.directNodeTxSigningJob !== void 0 && object.directNodeTxSigningJob !== null ? UserSignedTxSigningJob.fromPartial(object.directNodeTxSigningJob) : void 0;
|
|
3099
|
-
message.directRefundTxSigningJob = object.directRefundTxSigningJob !== void 0 && object.directRefundTxSigningJob !== null ? UserSignedTxSigningJob.fromPartial(object.directRefundTxSigningJob) : void 0;
|
|
3100
3114
|
message.directFromCpfpRefundTxSigningJob = object.directFromCpfpRefundTxSigningJob !== void 0 && object.directFromCpfpRefundTxSigningJob !== null ? UserSignedTxSigningJob.fromPartial(object.directFromCpfpRefundTxSigningJob) : void 0;
|
|
3101
3115
|
return message;
|
|
3102
3116
|
}
|
|
@@ -11925,6 +11939,322 @@ var QueryUserSignedRefundsResponse = {
|
|
|
11925
11939
|
return message;
|
|
11926
11940
|
}
|
|
11927
11941
|
};
|
|
11942
|
+
function createBasePreimageRequestWithTransfer() {
|
|
11943
|
+
return {
|
|
11944
|
+
paymentHash: new Uint8Array(0),
|
|
11945
|
+
receiverIdentityPubkey: new Uint8Array(0),
|
|
11946
|
+
status: 0,
|
|
11947
|
+
createdTime: void 0,
|
|
11948
|
+
transfer: void 0,
|
|
11949
|
+
preimage: void 0
|
|
11950
|
+
};
|
|
11951
|
+
}
|
|
11952
|
+
var PreimageRequestWithTransfer = {
|
|
11953
|
+
encode(message, writer = new BinaryWriter4()) {
|
|
11954
|
+
if (message.paymentHash.length !== 0) {
|
|
11955
|
+
writer.uint32(10).bytes(message.paymentHash);
|
|
11956
|
+
}
|
|
11957
|
+
if (message.receiverIdentityPubkey.length !== 0) {
|
|
11958
|
+
writer.uint32(18).bytes(message.receiverIdentityPubkey);
|
|
11959
|
+
}
|
|
11960
|
+
if (message.status !== 0) {
|
|
11961
|
+
writer.uint32(24).int32(message.status);
|
|
11962
|
+
}
|
|
11963
|
+
if (message.createdTime !== void 0) {
|
|
11964
|
+
Timestamp.encode(toTimestamp(message.createdTime), writer.uint32(34).fork()).join();
|
|
11965
|
+
}
|
|
11966
|
+
if (message.transfer !== void 0) {
|
|
11967
|
+
Transfer.encode(message.transfer, writer.uint32(42).fork()).join();
|
|
11968
|
+
}
|
|
11969
|
+
if (message.preimage !== void 0) {
|
|
11970
|
+
writer.uint32(50).bytes(message.preimage);
|
|
11971
|
+
}
|
|
11972
|
+
return writer;
|
|
11973
|
+
},
|
|
11974
|
+
decode(input, length) {
|
|
11975
|
+
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
11976
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
11977
|
+
const message = createBasePreimageRequestWithTransfer();
|
|
11978
|
+
while (reader.pos < end) {
|
|
11979
|
+
const tag = reader.uint32();
|
|
11980
|
+
switch (tag >>> 3) {
|
|
11981
|
+
case 1: {
|
|
11982
|
+
if (tag !== 10) {
|
|
11983
|
+
break;
|
|
11984
|
+
}
|
|
11985
|
+
message.paymentHash = reader.bytes();
|
|
11986
|
+
continue;
|
|
11987
|
+
}
|
|
11988
|
+
case 2: {
|
|
11989
|
+
if (tag !== 18) {
|
|
11990
|
+
break;
|
|
11991
|
+
}
|
|
11992
|
+
message.receiverIdentityPubkey = reader.bytes();
|
|
11993
|
+
continue;
|
|
11994
|
+
}
|
|
11995
|
+
case 3: {
|
|
11996
|
+
if (tag !== 24) {
|
|
11997
|
+
break;
|
|
11998
|
+
}
|
|
11999
|
+
message.status = reader.int32();
|
|
12000
|
+
continue;
|
|
12001
|
+
}
|
|
12002
|
+
case 4: {
|
|
12003
|
+
if (tag !== 34) {
|
|
12004
|
+
break;
|
|
12005
|
+
}
|
|
12006
|
+
message.createdTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
|
|
12007
|
+
continue;
|
|
12008
|
+
}
|
|
12009
|
+
case 5: {
|
|
12010
|
+
if (tag !== 42) {
|
|
12011
|
+
break;
|
|
12012
|
+
}
|
|
12013
|
+
message.transfer = Transfer.decode(reader, reader.uint32());
|
|
12014
|
+
continue;
|
|
12015
|
+
}
|
|
12016
|
+
case 6: {
|
|
12017
|
+
if (tag !== 50) {
|
|
12018
|
+
break;
|
|
12019
|
+
}
|
|
12020
|
+
message.preimage = reader.bytes();
|
|
12021
|
+
continue;
|
|
12022
|
+
}
|
|
12023
|
+
}
|
|
12024
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
12025
|
+
break;
|
|
12026
|
+
}
|
|
12027
|
+
reader.skip(tag & 7);
|
|
12028
|
+
}
|
|
12029
|
+
return message;
|
|
12030
|
+
},
|
|
12031
|
+
fromJSON(object) {
|
|
12032
|
+
return {
|
|
12033
|
+
paymentHash: isSet3(object.paymentHash) ? bytesFromBase642(object.paymentHash) : new Uint8Array(0),
|
|
12034
|
+
receiverIdentityPubkey: isSet3(object.receiverIdentityPubkey) ? bytesFromBase642(object.receiverIdentityPubkey) : new Uint8Array(0),
|
|
12035
|
+
status: isSet3(object.status) ? preimageRequestStatusFromJSON(object.status) : 0,
|
|
12036
|
+
createdTime: isSet3(object.createdTime) ? fromJsonTimestamp(object.createdTime) : void 0,
|
|
12037
|
+
transfer: isSet3(object.transfer) ? Transfer.fromJSON(object.transfer) : void 0,
|
|
12038
|
+
preimage: isSet3(object.preimage) ? bytesFromBase642(object.preimage) : void 0
|
|
12039
|
+
};
|
|
12040
|
+
},
|
|
12041
|
+
toJSON(message) {
|
|
12042
|
+
const obj = {};
|
|
12043
|
+
if (message.paymentHash.length !== 0) {
|
|
12044
|
+
obj.paymentHash = base64FromBytes2(message.paymentHash);
|
|
12045
|
+
}
|
|
12046
|
+
if (message.receiverIdentityPubkey.length !== 0) {
|
|
12047
|
+
obj.receiverIdentityPubkey = base64FromBytes2(message.receiverIdentityPubkey);
|
|
12048
|
+
}
|
|
12049
|
+
if (message.status !== 0) {
|
|
12050
|
+
obj.status = preimageRequestStatusToJSON(message.status);
|
|
12051
|
+
}
|
|
12052
|
+
if (message.createdTime !== void 0) {
|
|
12053
|
+
obj.createdTime = message.createdTime.toISOString();
|
|
12054
|
+
}
|
|
12055
|
+
if (message.transfer !== void 0) {
|
|
12056
|
+
obj.transfer = Transfer.toJSON(message.transfer);
|
|
12057
|
+
}
|
|
12058
|
+
if (message.preimage !== void 0) {
|
|
12059
|
+
obj.preimage = base64FromBytes2(message.preimage);
|
|
12060
|
+
}
|
|
12061
|
+
return obj;
|
|
12062
|
+
},
|
|
12063
|
+
create(base) {
|
|
12064
|
+
return PreimageRequestWithTransfer.fromPartial(base ?? {});
|
|
12065
|
+
},
|
|
12066
|
+
fromPartial(object) {
|
|
12067
|
+
const message = createBasePreimageRequestWithTransfer();
|
|
12068
|
+
message.paymentHash = object.paymentHash ?? new Uint8Array(0);
|
|
12069
|
+
message.receiverIdentityPubkey = object.receiverIdentityPubkey ?? new Uint8Array(0);
|
|
12070
|
+
message.status = object.status ?? 0;
|
|
12071
|
+
message.createdTime = object.createdTime ?? void 0;
|
|
12072
|
+
message.transfer = object.transfer !== void 0 && object.transfer !== null ? Transfer.fromPartial(object.transfer) : void 0;
|
|
12073
|
+
message.preimage = object.preimage ?? void 0;
|
|
12074
|
+
return message;
|
|
12075
|
+
}
|
|
12076
|
+
};
|
|
12077
|
+
function createBaseQueryHtlcRequest() {
|
|
12078
|
+
return { paymentHashes: [], identityPublicKey: new Uint8Array(0), status: void 0, limit: 0, offset: 0 };
|
|
12079
|
+
}
|
|
12080
|
+
var QueryHtlcRequest = {
|
|
12081
|
+
encode(message, writer = new BinaryWriter4()) {
|
|
12082
|
+
for (const v of message.paymentHashes) {
|
|
12083
|
+
writer.uint32(10).bytes(v);
|
|
12084
|
+
}
|
|
12085
|
+
if (message.identityPublicKey.length !== 0) {
|
|
12086
|
+
writer.uint32(18).bytes(message.identityPublicKey);
|
|
12087
|
+
}
|
|
12088
|
+
if (message.status !== void 0) {
|
|
12089
|
+
writer.uint32(24).int32(message.status);
|
|
12090
|
+
}
|
|
12091
|
+
if (message.limit !== 0) {
|
|
12092
|
+
writer.uint32(32).int64(message.limit);
|
|
12093
|
+
}
|
|
12094
|
+
if (message.offset !== 0) {
|
|
12095
|
+
writer.uint32(40).int64(message.offset);
|
|
12096
|
+
}
|
|
12097
|
+
return writer;
|
|
12098
|
+
},
|
|
12099
|
+
decode(input, length) {
|
|
12100
|
+
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
12101
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
12102
|
+
const message = createBaseQueryHtlcRequest();
|
|
12103
|
+
while (reader.pos < end) {
|
|
12104
|
+
const tag = reader.uint32();
|
|
12105
|
+
switch (tag >>> 3) {
|
|
12106
|
+
case 1: {
|
|
12107
|
+
if (tag !== 10) {
|
|
12108
|
+
break;
|
|
12109
|
+
}
|
|
12110
|
+
message.paymentHashes.push(reader.bytes());
|
|
12111
|
+
continue;
|
|
12112
|
+
}
|
|
12113
|
+
case 2: {
|
|
12114
|
+
if (tag !== 18) {
|
|
12115
|
+
break;
|
|
12116
|
+
}
|
|
12117
|
+
message.identityPublicKey = reader.bytes();
|
|
12118
|
+
continue;
|
|
12119
|
+
}
|
|
12120
|
+
case 3: {
|
|
12121
|
+
if (tag !== 24) {
|
|
12122
|
+
break;
|
|
12123
|
+
}
|
|
12124
|
+
message.status = reader.int32();
|
|
12125
|
+
continue;
|
|
12126
|
+
}
|
|
12127
|
+
case 4: {
|
|
12128
|
+
if (tag !== 32) {
|
|
12129
|
+
break;
|
|
12130
|
+
}
|
|
12131
|
+
message.limit = longToNumber2(reader.int64());
|
|
12132
|
+
continue;
|
|
12133
|
+
}
|
|
12134
|
+
case 5: {
|
|
12135
|
+
if (tag !== 40) {
|
|
12136
|
+
break;
|
|
12137
|
+
}
|
|
12138
|
+
message.offset = longToNumber2(reader.int64());
|
|
12139
|
+
continue;
|
|
12140
|
+
}
|
|
12141
|
+
}
|
|
12142
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
12143
|
+
break;
|
|
12144
|
+
}
|
|
12145
|
+
reader.skip(tag & 7);
|
|
12146
|
+
}
|
|
12147
|
+
return message;
|
|
12148
|
+
},
|
|
12149
|
+
fromJSON(object) {
|
|
12150
|
+
return {
|
|
12151
|
+
paymentHashes: globalThis.Array.isArray(object?.paymentHashes) ? object.paymentHashes.map((e) => bytesFromBase642(e)) : [],
|
|
12152
|
+
identityPublicKey: isSet3(object.identityPublicKey) ? bytesFromBase642(object.identityPublicKey) : new Uint8Array(0),
|
|
12153
|
+
status: isSet3(object.status) ? preimageRequestStatusFromJSON(object.status) : void 0,
|
|
12154
|
+
limit: isSet3(object.limit) ? globalThis.Number(object.limit) : 0,
|
|
12155
|
+
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0
|
|
12156
|
+
};
|
|
12157
|
+
},
|
|
12158
|
+
toJSON(message) {
|
|
12159
|
+
const obj = {};
|
|
12160
|
+
if (message.paymentHashes?.length) {
|
|
12161
|
+
obj.paymentHashes = message.paymentHashes.map((e) => base64FromBytes2(e));
|
|
12162
|
+
}
|
|
12163
|
+
if (message.identityPublicKey.length !== 0) {
|
|
12164
|
+
obj.identityPublicKey = base64FromBytes2(message.identityPublicKey);
|
|
12165
|
+
}
|
|
12166
|
+
if (message.status !== void 0) {
|
|
12167
|
+
obj.status = preimageRequestStatusToJSON(message.status);
|
|
12168
|
+
}
|
|
12169
|
+
if (message.limit !== 0) {
|
|
12170
|
+
obj.limit = Math.round(message.limit);
|
|
12171
|
+
}
|
|
12172
|
+
if (message.offset !== 0) {
|
|
12173
|
+
obj.offset = Math.round(message.offset);
|
|
12174
|
+
}
|
|
12175
|
+
return obj;
|
|
12176
|
+
},
|
|
12177
|
+
create(base) {
|
|
12178
|
+
return QueryHtlcRequest.fromPartial(base ?? {});
|
|
12179
|
+
},
|
|
12180
|
+
fromPartial(object) {
|
|
12181
|
+
const message = createBaseQueryHtlcRequest();
|
|
12182
|
+
message.paymentHashes = object.paymentHashes?.map((e) => e) || [];
|
|
12183
|
+
message.identityPublicKey = object.identityPublicKey ?? new Uint8Array(0);
|
|
12184
|
+
message.status = object.status ?? void 0;
|
|
12185
|
+
message.limit = object.limit ?? 0;
|
|
12186
|
+
message.offset = object.offset ?? 0;
|
|
12187
|
+
return message;
|
|
12188
|
+
}
|
|
12189
|
+
};
|
|
12190
|
+
function createBaseQueryHtlcResponse() {
|
|
12191
|
+
return { preimageRequests: [], offset: 0 };
|
|
12192
|
+
}
|
|
12193
|
+
var QueryHtlcResponse = {
|
|
12194
|
+
encode(message, writer = new BinaryWriter4()) {
|
|
12195
|
+
for (const v of message.preimageRequests) {
|
|
12196
|
+
PreimageRequestWithTransfer.encode(v, writer.uint32(10).fork()).join();
|
|
12197
|
+
}
|
|
12198
|
+
if (message.offset !== 0) {
|
|
12199
|
+
writer.uint32(16).int64(message.offset);
|
|
12200
|
+
}
|
|
12201
|
+
return writer;
|
|
12202
|
+
},
|
|
12203
|
+
decode(input, length) {
|
|
12204
|
+
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
12205
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
12206
|
+
const message = createBaseQueryHtlcResponse();
|
|
12207
|
+
while (reader.pos < end) {
|
|
12208
|
+
const tag = reader.uint32();
|
|
12209
|
+
switch (tag >>> 3) {
|
|
12210
|
+
case 1: {
|
|
12211
|
+
if (tag !== 10) {
|
|
12212
|
+
break;
|
|
12213
|
+
}
|
|
12214
|
+
message.preimageRequests.push(PreimageRequestWithTransfer.decode(reader, reader.uint32()));
|
|
12215
|
+
continue;
|
|
12216
|
+
}
|
|
12217
|
+
case 2: {
|
|
12218
|
+
if (tag !== 16) {
|
|
12219
|
+
break;
|
|
12220
|
+
}
|
|
12221
|
+
message.offset = longToNumber2(reader.int64());
|
|
12222
|
+
continue;
|
|
12223
|
+
}
|
|
12224
|
+
}
|
|
12225
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
12226
|
+
break;
|
|
12227
|
+
}
|
|
12228
|
+
reader.skip(tag & 7);
|
|
12229
|
+
}
|
|
12230
|
+
return message;
|
|
12231
|
+
},
|
|
12232
|
+
fromJSON(object) {
|
|
12233
|
+
return {
|
|
12234
|
+
preimageRequests: globalThis.Array.isArray(object?.preimageRequests) ? object.preimageRequests.map((e) => PreimageRequestWithTransfer.fromJSON(e)) : [],
|
|
12235
|
+
offset: isSet3(object.offset) ? globalThis.Number(object.offset) : 0
|
|
12236
|
+
};
|
|
12237
|
+
},
|
|
12238
|
+
toJSON(message) {
|
|
12239
|
+
const obj = {};
|
|
12240
|
+
if (message.preimageRequests?.length) {
|
|
12241
|
+
obj.preimageRequests = message.preimageRequests.map((e) => PreimageRequestWithTransfer.toJSON(e));
|
|
12242
|
+
}
|
|
12243
|
+
if (message.offset !== 0) {
|
|
12244
|
+
obj.offset = Math.round(message.offset);
|
|
12245
|
+
}
|
|
12246
|
+
return obj;
|
|
12247
|
+
},
|
|
12248
|
+
create(base) {
|
|
12249
|
+
return QueryHtlcResponse.fromPartial(base ?? {});
|
|
12250
|
+
},
|
|
12251
|
+
fromPartial(object) {
|
|
12252
|
+
const message = createBaseQueryHtlcResponse();
|
|
12253
|
+
message.preimageRequests = object.preimageRequests?.map((e) => PreimageRequestWithTransfer.fromPartial(e)) || [];
|
|
12254
|
+
message.offset = object.offset ?? 0;
|
|
12255
|
+
return message;
|
|
12256
|
+
}
|
|
12257
|
+
};
|
|
11928
12258
|
function createBaseProvidePreimageRequest() {
|
|
11929
12259
|
return { paymentHash: new Uint8Array(0), preimage: new Uint8Array(0), identityPublicKey: new Uint8Array(0) };
|
|
11930
12260
|
}
|
|
@@ -15225,20 +15555,235 @@ var InvoiceResponse = {
|
|
|
15225
15555
|
if (message.status !== 0) {
|
|
15226
15556
|
writer.uint32(16).int32(message.status);
|
|
15227
15557
|
}
|
|
15228
|
-
switch (message.transferType?.$case) {
|
|
15229
|
-
case "satsTransfer":
|
|
15230
|
-
SatsTransfer.encode(message.transferType.satsTransfer, writer.uint32(26).fork()).join();
|
|
15231
|
-
break;
|
|
15232
|
-
case "tokenTransfer":
|
|
15233
|
-
TokenTransfer.encode(message.transferType.tokenTransfer, writer.uint32(34).fork()).join();
|
|
15234
|
-
break;
|
|
15558
|
+
switch (message.transferType?.$case) {
|
|
15559
|
+
case "satsTransfer":
|
|
15560
|
+
SatsTransfer.encode(message.transferType.satsTransfer, writer.uint32(26).fork()).join();
|
|
15561
|
+
break;
|
|
15562
|
+
case "tokenTransfer":
|
|
15563
|
+
TokenTransfer.encode(message.transferType.tokenTransfer, writer.uint32(34).fork()).join();
|
|
15564
|
+
break;
|
|
15565
|
+
}
|
|
15566
|
+
return writer;
|
|
15567
|
+
},
|
|
15568
|
+
decode(input, length) {
|
|
15569
|
+
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
15570
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15571
|
+
const message = createBaseInvoiceResponse();
|
|
15572
|
+
while (reader.pos < end) {
|
|
15573
|
+
const tag = reader.uint32();
|
|
15574
|
+
switch (tag >>> 3) {
|
|
15575
|
+
case 1: {
|
|
15576
|
+
if (tag !== 10) {
|
|
15577
|
+
break;
|
|
15578
|
+
}
|
|
15579
|
+
message.invoice = reader.string();
|
|
15580
|
+
continue;
|
|
15581
|
+
}
|
|
15582
|
+
case 2: {
|
|
15583
|
+
if (tag !== 16) {
|
|
15584
|
+
break;
|
|
15585
|
+
}
|
|
15586
|
+
message.status = reader.int32();
|
|
15587
|
+
continue;
|
|
15588
|
+
}
|
|
15589
|
+
case 3: {
|
|
15590
|
+
if (tag !== 26) {
|
|
15591
|
+
break;
|
|
15592
|
+
}
|
|
15593
|
+
message.transferType = { $case: "satsTransfer", satsTransfer: SatsTransfer.decode(reader, reader.uint32()) };
|
|
15594
|
+
continue;
|
|
15595
|
+
}
|
|
15596
|
+
case 4: {
|
|
15597
|
+
if (tag !== 34) {
|
|
15598
|
+
break;
|
|
15599
|
+
}
|
|
15600
|
+
message.transferType = {
|
|
15601
|
+
$case: "tokenTransfer",
|
|
15602
|
+
tokenTransfer: TokenTransfer.decode(reader, reader.uint32())
|
|
15603
|
+
};
|
|
15604
|
+
continue;
|
|
15605
|
+
}
|
|
15606
|
+
}
|
|
15607
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
15608
|
+
break;
|
|
15609
|
+
}
|
|
15610
|
+
reader.skip(tag & 7);
|
|
15611
|
+
}
|
|
15612
|
+
return message;
|
|
15613
|
+
},
|
|
15614
|
+
fromJSON(object) {
|
|
15615
|
+
return {
|
|
15616
|
+
invoice: isSet3(object.invoice) ? globalThis.String(object.invoice) : "",
|
|
15617
|
+
status: isSet3(object.status) ? invoiceStatusFromJSON(object.status) : 0,
|
|
15618
|
+
transferType: isSet3(object.satsTransfer) ? { $case: "satsTransfer", satsTransfer: SatsTransfer.fromJSON(object.satsTransfer) } : isSet3(object.tokenTransfer) ? { $case: "tokenTransfer", tokenTransfer: TokenTransfer.fromJSON(object.tokenTransfer) } : void 0
|
|
15619
|
+
};
|
|
15620
|
+
},
|
|
15621
|
+
toJSON(message) {
|
|
15622
|
+
const obj = {};
|
|
15623
|
+
if (message.invoice !== "") {
|
|
15624
|
+
obj.invoice = message.invoice;
|
|
15625
|
+
}
|
|
15626
|
+
if (message.status !== 0) {
|
|
15627
|
+
obj.status = invoiceStatusToJSON(message.status);
|
|
15628
|
+
}
|
|
15629
|
+
if (message.transferType?.$case === "satsTransfer") {
|
|
15630
|
+
obj.satsTransfer = SatsTransfer.toJSON(message.transferType.satsTransfer);
|
|
15631
|
+
} else if (message.transferType?.$case === "tokenTransfer") {
|
|
15632
|
+
obj.tokenTransfer = TokenTransfer.toJSON(message.transferType.tokenTransfer);
|
|
15633
|
+
}
|
|
15634
|
+
return obj;
|
|
15635
|
+
},
|
|
15636
|
+
create(base) {
|
|
15637
|
+
return InvoiceResponse.fromPartial(base ?? {});
|
|
15638
|
+
},
|
|
15639
|
+
fromPartial(object) {
|
|
15640
|
+
const message = createBaseInvoiceResponse();
|
|
15641
|
+
message.invoice = object.invoice ?? "";
|
|
15642
|
+
message.status = object.status ?? 0;
|
|
15643
|
+
switch (object.transferType?.$case) {
|
|
15644
|
+
case "satsTransfer": {
|
|
15645
|
+
if (object.transferType?.satsTransfer !== void 0 && object.transferType?.satsTransfer !== null) {
|
|
15646
|
+
message.transferType = {
|
|
15647
|
+
$case: "satsTransfer",
|
|
15648
|
+
satsTransfer: SatsTransfer.fromPartial(object.transferType.satsTransfer)
|
|
15649
|
+
};
|
|
15650
|
+
}
|
|
15651
|
+
break;
|
|
15652
|
+
}
|
|
15653
|
+
case "tokenTransfer": {
|
|
15654
|
+
if (object.transferType?.tokenTransfer !== void 0 && object.transferType?.tokenTransfer !== null) {
|
|
15655
|
+
message.transferType = {
|
|
15656
|
+
$case: "tokenTransfer",
|
|
15657
|
+
tokenTransfer: TokenTransfer.fromPartial(object.transferType.tokenTransfer)
|
|
15658
|
+
};
|
|
15659
|
+
}
|
|
15660
|
+
break;
|
|
15661
|
+
}
|
|
15662
|
+
}
|
|
15663
|
+
return message;
|
|
15664
|
+
}
|
|
15665
|
+
};
|
|
15666
|
+
function createBaseSatsTransfer() {
|
|
15667
|
+
return { transferId: new Uint8Array(0) };
|
|
15668
|
+
}
|
|
15669
|
+
var SatsTransfer = {
|
|
15670
|
+
encode(message, writer = new BinaryWriter4()) {
|
|
15671
|
+
if (message.transferId.length !== 0) {
|
|
15672
|
+
writer.uint32(10).bytes(message.transferId);
|
|
15673
|
+
}
|
|
15674
|
+
return writer;
|
|
15675
|
+
},
|
|
15676
|
+
decode(input, length) {
|
|
15677
|
+
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
15678
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15679
|
+
const message = createBaseSatsTransfer();
|
|
15680
|
+
while (reader.pos < end) {
|
|
15681
|
+
const tag = reader.uint32();
|
|
15682
|
+
switch (tag >>> 3) {
|
|
15683
|
+
case 1: {
|
|
15684
|
+
if (tag !== 10) {
|
|
15685
|
+
break;
|
|
15686
|
+
}
|
|
15687
|
+
message.transferId = reader.bytes();
|
|
15688
|
+
continue;
|
|
15689
|
+
}
|
|
15690
|
+
}
|
|
15691
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
15692
|
+
break;
|
|
15693
|
+
}
|
|
15694
|
+
reader.skip(tag & 7);
|
|
15695
|
+
}
|
|
15696
|
+
return message;
|
|
15697
|
+
},
|
|
15698
|
+
fromJSON(object) {
|
|
15699
|
+
return { transferId: isSet3(object.transferId) ? bytesFromBase642(object.transferId) : new Uint8Array(0) };
|
|
15700
|
+
},
|
|
15701
|
+
toJSON(message) {
|
|
15702
|
+
const obj = {};
|
|
15703
|
+
if (message.transferId.length !== 0) {
|
|
15704
|
+
obj.transferId = base64FromBytes2(message.transferId);
|
|
15705
|
+
}
|
|
15706
|
+
return obj;
|
|
15707
|
+
},
|
|
15708
|
+
create(base) {
|
|
15709
|
+
return SatsTransfer.fromPartial(base ?? {});
|
|
15710
|
+
},
|
|
15711
|
+
fromPartial(object) {
|
|
15712
|
+
const message = createBaseSatsTransfer();
|
|
15713
|
+
message.transferId = object.transferId ?? new Uint8Array(0);
|
|
15714
|
+
return message;
|
|
15715
|
+
}
|
|
15716
|
+
};
|
|
15717
|
+
function createBaseTokenTransfer() {
|
|
15718
|
+
return { finalTokenTransactionHash: new Uint8Array(0) };
|
|
15719
|
+
}
|
|
15720
|
+
var TokenTransfer = {
|
|
15721
|
+
encode(message, writer = new BinaryWriter4()) {
|
|
15722
|
+
if (message.finalTokenTransactionHash.length !== 0) {
|
|
15723
|
+
writer.uint32(10).bytes(message.finalTokenTransactionHash);
|
|
15724
|
+
}
|
|
15725
|
+
return writer;
|
|
15726
|
+
},
|
|
15727
|
+
decode(input, length) {
|
|
15728
|
+
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
15729
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15730
|
+
const message = createBaseTokenTransfer();
|
|
15731
|
+
while (reader.pos < end) {
|
|
15732
|
+
const tag = reader.uint32();
|
|
15733
|
+
switch (tag >>> 3) {
|
|
15734
|
+
case 1: {
|
|
15735
|
+
if (tag !== 10) {
|
|
15736
|
+
break;
|
|
15737
|
+
}
|
|
15738
|
+
message.finalTokenTransactionHash = reader.bytes();
|
|
15739
|
+
continue;
|
|
15740
|
+
}
|
|
15741
|
+
}
|
|
15742
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
15743
|
+
break;
|
|
15744
|
+
}
|
|
15745
|
+
reader.skip(tag & 7);
|
|
15746
|
+
}
|
|
15747
|
+
return message;
|
|
15748
|
+
},
|
|
15749
|
+
fromJSON(object) {
|
|
15750
|
+
return {
|
|
15751
|
+
finalTokenTransactionHash: isSet3(object.finalTokenTransactionHash) ? bytesFromBase642(object.finalTokenTransactionHash) : new Uint8Array(0)
|
|
15752
|
+
};
|
|
15753
|
+
},
|
|
15754
|
+
toJSON(message) {
|
|
15755
|
+
const obj = {};
|
|
15756
|
+
if (message.finalTokenTransactionHash.length !== 0) {
|
|
15757
|
+
obj.finalTokenTransactionHash = base64FromBytes2(message.finalTokenTransactionHash);
|
|
15758
|
+
}
|
|
15759
|
+
return obj;
|
|
15760
|
+
},
|
|
15761
|
+
create(base) {
|
|
15762
|
+
return TokenTransfer.fromPartial(base ?? {});
|
|
15763
|
+
},
|
|
15764
|
+
fromPartial(object) {
|
|
15765
|
+
const message = createBaseTokenTransfer();
|
|
15766
|
+
message.finalTokenTransactionHash = object.finalTokenTransactionHash ?? new Uint8Array(0);
|
|
15767
|
+
return message;
|
|
15768
|
+
}
|
|
15769
|
+
};
|
|
15770
|
+
function createBaseInitiateSwapPrimaryTransferRequest() {
|
|
15771
|
+
return { transfer: void 0, adaptorPublicKeys: void 0 };
|
|
15772
|
+
}
|
|
15773
|
+
var InitiateSwapPrimaryTransferRequest = {
|
|
15774
|
+
encode(message, writer = new BinaryWriter4()) {
|
|
15775
|
+
if (message.transfer !== void 0) {
|
|
15776
|
+
StartTransferRequest.encode(message.transfer, writer.uint32(10).fork()).join();
|
|
15777
|
+
}
|
|
15778
|
+
if (message.adaptorPublicKeys !== void 0) {
|
|
15779
|
+
AdaptorPublicKeyPackage.encode(message.adaptorPublicKeys, writer.uint32(18).fork()).join();
|
|
15235
15780
|
}
|
|
15236
15781
|
return writer;
|
|
15237
15782
|
},
|
|
15238
15783
|
decode(input, length) {
|
|
15239
15784
|
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
15240
15785
|
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15241
|
-
const message =
|
|
15786
|
+
const message = createBaseInitiateSwapPrimaryTransferRequest();
|
|
15242
15787
|
while (reader.pos < end) {
|
|
15243
15788
|
const tag = reader.uint32();
|
|
15244
15789
|
switch (tag >>> 3) {
|
|
@@ -15246,31 +15791,14 @@ var InvoiceResponse = {
|
|
|
15246
15791
|
if (tag !== 10) {
|
|
15247
15792
|
break;
|
|
15248
15793
|
}
|
|
15249
|
-
message.
|
|
15794
|
+
message.transfer = StartTransferRequest.decode(reader, reader.uint32());
|
|
15250
15795
|
continue;
|
|
15251
15796
|
}
|
|
15252
15797
|
case 2: {
|
|
15253
|
-
if (tag !==
|
|
15254
|
-
break;
|
|
15255
|
-
}
|
|
15256
|
-
message.status = reader.int32();
|
|
15257
|
-
continue;
|
|
15258
|
-
}
|
|
15259
|
-
case 3: {
|
|
15260
|
-
if (tag !== 26) {
|
|
15261
|
-
break;
|
|
15262
|
-
}
|
|
15263
|
-
message.transferType = { $case: "satsTransfer", satsTransfer: SatsTransfer.decode(reader, reader.uint32()) };
|
|
15264
|
-
continue;
|
|
15265
|
-
}
|
|
15266
|
-
case 4: {
|
|
15267
|
-
if (tag !== 34) {
|
|
15798
|
+
if (tag !== 18) {
|
|
15268
15799
|
break;
|
|
15269
15800
|
}
|
|
15270
|
-
message.
|
|
15271
|
-
$case: "tokenTransfer",
|
|
15272
|
-
tokenTransfer: TokenTransfer.decode(reader, reader.uint32())
|
|
15273
|
-
};
|
|
15801
|
+
message.adaptorPublicKeys = AdaptorPublicKeyPackage.decode(reader, reader.uint32());
|
|
15274
15802
|
continue;
|
|
15275
15803
|
}
|
|
15276
15804
|
}
|
|
@@ -15283,70 +15811,47 @@ var InvoiceResponse = {
|
|
|
15283
15811
|
},
|
|
15284
15812
|
fromJSON(object) {
|
|
15285
15813
|
return {
|
|
15286
|
-
|
|
15287
|
-
|
|
15288
|
-
transferType: isSet3(object.satsTransfer) ? { $case: "satsTransfer", satsTransfer: SatsTransfer.fromJSON(object.satsTransfer) } : isSet3(object.tokenTransfer) ? { $case: "tokenTransfer", tokenTransfer: TokenTransfer.fromJSON(object.tokenTransfer) } : void 0
|
|
15814
|
+
transfer: isSet3(object.transfer) ? StartTransferRequest.fromJSON(object.transfer) : void 0,
|
|
15815
|
+
adaptorPublicKeys: isSet3(object.adaptorPublicKeys) ? AdaptorPublicKeyPackage.fromJSON(object.adaptorPublicKeys) : void 0
|
|
15289
15816
|
};
|
|
15290
15817
|
},
|
|
15291
15818
|
toJSON(message) {
|
|
15292
15819
|
const obj = {};
|
|
15293
|
-
if (message.
|
|
15294
|
-
obj.
|
|
15295
|
-
}
|
|
15296
|
-
if (message.status !== 0) {
|
|
15297
|
-
obj.status = invoiceStatusToJSON(message.status);
|
|
15820
|
+
if (message.transfer !== void 0) {
|
|
15821
|
+
obj.transfer = StartTransferRequest.toJSON(message.transfer);
|
|
15298
15822
|
}
|
|
15299
|
-
if (message.
|
|
15300
|
-
obj.
|
|
15301
|
-
} else if (message.transferType?.$case === "tokenTransfer") {
|
|
15302
|
-
obj.tokenTransfer = TokenTransfer.toJSON(message.transferType.tokenTransfer);
|
|
15823
|
+
if (message.adaptorPublicKeys !== void 0) {
|
|
15824
|
+
obj.adaptorPublicKeys = AdaptorPublicKeyPackage.toJSON(message.adaptorPublicKeys);
|
|
15303
15825
|
}
|
|
15304
15826
|
return obj;
|
|
15305
15827
|
},
|
|
15306
15828
|
create(base) {
|
|
15307
|
-
return
|
|
15829
|
+
return InitiateSwapPrimaryTransferRequest.fromPartial(base ?? {});
|
|
15308
15830
|
},
|
|
15309
15831
|
fromPartial(object) {
|
|
15310
|
-
const message =
|
|
15311
|
-
message.
|
|
15312
|
-
message.
|
|
15313
|
-
switch (object.transferType?.$case) {
|
|
15314
|
-
case "satsTransfer": {
|
|
15315
|
-
if (object.transferType?.satsTransfer !== void 0 && object.transferType?.satsTransfer !== null) {
|
|
15316
|
-
message.transferType = {
|
|
15317
|
-
$case: "satsTransfer",
|
|
15318
|
-
satsTransfer: SatsTransfer.fromPartial(object.transferType.satsTransfer)
|
|
15319
|
-
};
|
|
15320
|
-
}
|
|
15321
|
-
break;
|
|
15322
|
-
}
|
|
15323
|
-
case "tokenTransfer": {
|
|
15324
|
-
if (object.transferType?.tokenTransfer !== void 0 && object.transferType?.tokenTransfer !== null) {
|
|
15325
|
-
message.transferType = {
|
|
15326
|
-
$case: "tokenTransfer",
|
|
15327
|
-
tokenTransfer: TokenTransfer.fromPartial(object.transferType.tokenTransfer)
|
|
15328
|
-
};
|
|
15329
|
-
}
|
|
15330
|
-
break;
|
|
15331
|
-
}
|
|
15332
|
-
}
|
|
15832
|
+
const message = createBaseInitiateSwapPrimaryTransferRequest();
|
|
15833
|
+
message.transfer = object.transfer !== void 0 && object.transfer !== null ? StartTransferRequest.fromPartial(object.transfer) : void 0;
|
|
15834
|
+
message.adaptorPublicKeys = object.adaptorPublicKeys !== void 0 && object.adaptorPublicKeys !== null ? AdaptorPublicKeyPackage.fromPartial(object.adaptorPublicKeys) : void 0;
|
|
15333
15835
|
return message;
|
|
15334
15836
|
}
|
|
15335
15837
|
};
|
|
15336
|
-
function
|
|
15337
|
-
return {
|
|
15838
|
+
function createBaseInitiateSwapPrimaryTransferResponse() {
|
|
15839
|
+
return { transfer: void 0, signingResults: [] };
|
|
15338
15840
|
}
|
|
15339
|
-
var
|
|
15841
|
+
var InitiateSwapPrimaryTransferResponse = {
|
|
15340
15842
|
encode(message, writer = new BinaryWriter4()) {
|
|
15341
|
-
if (message.
|
|
15342
|
-
writer.uint32(10).
|
|
15843
|
+
if (message.transfer !== void 0) {
|
|
15844
|
+
Transfer.encode(message.transfer, writer.uint32(10).fork()).join();
|
|
15845
|
+
}
|
|
15846
|
+
for (const v of message.signingResults) {
|
|
15847
|
+
LeafRefundTxSigningResult.encode(v, writer.uint32(18).fork()).join();
|
|
15343
15848
|
}
|
|
15344
15849
|
return writer;
|
|
15345
15850
|
},
|
|
15346
15851
|
decode(input, length) {
|
|
15347
15852
|
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
15348
15853
|
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15349
|
-
const message =
|
|
15854
|
+
const message = createBaseInitiateSwapPrimaryTransferResponse();
|
|
15350
15855
|
while (reader.pos < end) {
|
|
15351
15856
|
const tag = reader.uint32();
|
|
15352
15857
|
switch (tag >>> 3) {
|
|
@@ -15354,7 +15859,14 @@ var SatsTransfer = {
|
|
|
15354
15859
|
if (tag !== 10) {
|
|
15355
15860
|
break;
|
|
15356
15861
|
}
|
|
15357
|
-
message.
|
|
15862
|
+
message.transfer = Transfer.decode(reader, reader.uint32());
|
|
15863
|
+
continue;
|
|
15864
|
+
}
|
|
15865
|
+
case 2: {
|
|
15866
|
+
if (tag !== 18) {
|
|
15867
|
+
break;
|
|
15868
|
+
}
|
|
15869
|
+
message.signingResults.push(LeafRefundTxSigningResult.decode(reader, reader.uint32()));
|
|
15358
15870
|
continue;
|
|
15359
15871
|
}
|
|
15360
15872
|
}
|
|
@@ -15366,38 +15878,55 @@ var SatsTransfer = {
|
|
|
15366
15878
|
return message;
|
|
15367
15879
|
},
|
|
15368
15880
|
fromJSON(object) {
|
|
15369
|
-
return {
|
|
15881
|
+
return {
|
|
15882
|
+
transfer: isSet3(object.transfer) ? Transfer.fromJSON(object.transfer) : void 0,
|
|
15883
|
+
signingResults: globalThis.Array.isArray(object?.signingResults) ? object.signingResults.map((e) => LeafRefundTxSigningResult.fromJSON(e)) : []
|
|
15884
|
+
};
|
|
15370
15885
|
},
|
|
15371
15886
|
toJSON(message) {
|
|
15372
15887
|
const obj = {};
|
|
15373
|
-
if (message.
|
|
15374
|
-
obj.
|
|
15888
|
+
if (message.transfer !== void 0) {
|
|
15889
|
+
obj.transfer = Transfer.toJSON(message.transfer);
|
|
15890
|
+
}
|
|
15891
|
+
if (message.signingResults?.length) {
|
|
15892
|
+
obj.signingResults = message.signingResults.map((e) => LeafRefundTxSigningResult.toJSON(e));
|
|
15375
15893
|
}
|
|
15376
15894
|
return obj;
|
|
15377
15895
|
},
|
|
15378
15896
|
create(base) {
|
|
15379
|
-
return
|
|
15897
|
+
return InitiateSwapPrimaryTransferResponse.fromPartial(base ?? {});
|
|
15380
15898
|
},
|
|
15381
15899
|
fromPartial(object) {
|
|
15382
|
-
const message =
|
|
15383
|
-
message.
|
|
15900
|
+
const message = createBaseInitiateSwapPrimaryTransferResponse();
|
|
15901
|
+
message.transfer = object.transfer !== void 0 && object.transfer !== null ? Transfer.fromPartial(object.transfer) : void 0;
|
|
15902
|
+
message.signingResults = object.signingResults?.map((e) => LeafRefundTxSigningResult.fromPartial(e)) || [];
|
|
15384
15903
|
return message;
|
|
15385
15904
|
}
|
|
15386
15905
|
};
|
|
15387
|
-
function
|
|
15388
|
-
return {
|
|
15906
|
+
function createBaseAdaptorPublicKeyPackage() {
|
|
15907
|
+
return {
|
|
15908
|
+
adaptorPublicKey: new Uint8Array(0),
|
|
15909
|
+
directAdaptorPublicKey: new Uint8Array(0),
|
|
15910
|
+
directFromCpfpAdaptorPublicKey: new Uint8Array(0)
|
|
15911
|
+
};
|
|
15389
15912
|
}
|
|
15390
|
-
var
|
|
15913
|
+
var AdaptorPublicKeyPackage = {
|
|
15391
15914
|
encode(message, writer = new BinaryWriter4()) {
|
|
15392
|
-
if (message.
|
|
15393
|
-
writer.uint32(10).bytes(message.
|
|
15915
|
+
if (message.adaptorPublicKey.length !== 0) {
|
|
15916
|
+
writer.uint32(10).bytes(message.adaptorPublicKey);
|
|
15917
|
+
}
|
|
15918
|
+
if (message.directAdaptorPublicKey.length !== 0) {
|
|
15919
|
+
writer.uint32(18).bytes(message.directAdaptorPublicKey);
|
|
15920
|
+
}
|
|
15921
|
+
if (message.directFromCpfpAdaptorPublicKey.length !== 0) {
|
|
15922
|
+
writer.uint32(26).bytes(message.directFromCpfpAdaptorPublicKey);
|
|
15394
15923
|
}
|
|
15395
15924
|
return writer;
|
|
15396
15925
|
},
|
|
15397
15926
|
decode(input, length) {
|
|
15398
15927
|
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
15399
15928
|
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15400
|
-
const message =
|
|
15929
|
+
const message = createBaseAdaptorPublicKeyPackage();
|
|
15401
15930
|
while (reader.pos < end) {
|
|
15402
15931
|
const tag = reader.uint32();
|
|
15403
15932
|
switch (tag >>> 3) {
|
|
@@ -15405,7 +15934,21 @@ var TokenTransfer = {
|
|
|
15405
15934
|
if (tag !== 10) {
|
|
15406
15935
|
break;
|
|
15407
15936
|
}
|
|
15408
|
-
message.
|
|
15937
|
+
message.adaptorPublicKey = reader.bytes();
|
|
15938
|
+
continue;
|
|
15939
|
+
}
|
|
15940
|
+
case 2: {
|
|
15941
|
+
if (tag !== 18) {
|
|
15942
|
+
break;
|
|
15943
|
+
}
|
|
15944
|
+
message.directAdaptorPublicKey = reader.bytes();
|
|
15945
|
+
continue;
|
|
15946
|
+
}
|
|
15947
|
+
case 3: {
|
|
15948
|
+
if (tag !== 26) {
|
|
15949
|
+
break;
|
|
15950
|
+
}
|
|
15951
|
+
message.directFromCpfpAdaptorPublicKey = reader.bytes();
|
|
15409
15952
|
continue;
|
|
15410
15953
|
}
|
|
15411
15954
|
}
|
|
@@ -15418,22 +15961,32 @@ var TokenTransfer = {
|
|
|
15418
15961
|
},
|
|
15419
15962
|
fromJSON(object) {
|
|
15420
15963
|
return {
|
|
15421
|
-
|
|
15964
|
+
adaptorPublicKey: isSet3(object.adaptorPublicKey) ? bytesFromBase642(object.adaptorPublicKey) : new Uint8Array(0),
|
|
15965
|
+
directAdaptorPublicKey: isSet3(object.directAdaptorPublicKey) ? bytesFromBase642(object.directAdaptorPublicKey) : new Uint8Array(0),
|
|
15966
|
+
directFromCpfpAdaptorPublicKey: isSet3(object.directFromCpfpAdaptorPublicKey) ? bytesFromBase642(object.directFromCpfpAdaptorPublicKey) : new Uint8Array(0)
|
|
15422
15967
|
};
|
|
15423
15968
|
},
|
|
15424
15969
|
toJSON(message) {
|
|
15425
15970
|
const obj = {};
|
|
15426
|
-
if (message.
|
|
15427
|
-
obj.
|
|
15971
|
+
if (message.adaptorPublicKey.length !== 0) {
|
|
15972
|
+
obj.adaptorPublicKey = base64FromBytes2(message.adaptorPublicKey);
|
|
15973
|
+
}
|
|
15974
|
+
if (message.directAdaptorPublicKey.length !== 0) {
|
|
15975
|
+
obj.directAdaptorPublicKey = base64FromBytes2(message.directAdaptorPublicKey);
|
|
15976
|
+
}
|
|
15977
|
+
if (message.directFromCpfpAdaptorPublicKey.length !== 0) {
|
|
15978
|
+
obj.directFromCpfpAdaptorPublicKey = base64FromBytes2(message.directFromCpfpAdaptorPublicKey);
|
|
15428
15979
|
}
|
|
15429
15980
|
return obj;
|
|
15430
15981
|
},
|
|
15431
15982
|
create(base) {
|
|
15432
|
-
return
|
|
15983
|
+
return AdaptorPublicKeyPackage.fromPartial(base ?? {});
|
|
15433
15984
|
},
|
|
15434
15985
|
fromPartial(object) {
|
|
15435
|
-
const message =
|
|
15436
|
-
message.
|
|
15986
|
+
const message = createBaseAdaptorPublicKeyPackage();
|
|
15987
|
+
message.adaptorPublicKey = object.adaptorPublicKey ?? new Uint8Array(0);
|
|
15988
|
+
message.directAdaptorPublicKey = object.directAdaptorPublicKey ?? new Uint8Array(0);
|
|
15989
|
+
message.directFromCpfpAdaptorPublicKey = object.directFromCpfpAdaptorPublicKey ?? new Uint8Array(0);
|
|
15437
15990
|
return message;
|
|
15438
15991
|
}
|
|
15439
15992
|
};
|
|
@@ -15600,6 +16153,14 @@ var SparkServiceDefinition = {
|
|
|
15600
16153
|
responseStream: false,
|
|
15601
16154
|
options: {}
|
|
15602
16155
|
},
|
|
16156
|
+
query_htlc: {
|
|
16157
|
+
name: "query_htlc",
|
|
16158
|
+
requestType: QueryHtlcRequest,
|
|
16159
|
+
requestStream: false,
|
|
16160
|
+
responseType: QueryHtlcResponse,
|
|
16161
|
+
responseStream: false,
|
|
16162
|
+
options: {}
|
|
16163
|
+
},
|
|
15603
16164
|
/**
|
|
15604
16165
|
* This is the exact same as start_transfer, but expresses to the SO
|
|
15605
16166
|
* this transfer is specifically for a leaf swap.
|
|
@@ -15879,6 +16440,14 @@ var SparkServiceDefinition = {
|
|
|
15879
16440
|
responseStream: false,
|
|
15880
16441
|
options: {}
|
|
15881
16442
|
},
|
|
16443
|
+
initiate_preimage_swap_v3: {
|
|
16444
|
+
name: "initiate_preimage_swap_v3",
|
|
16445
|
+
requestType: InitiatePreimageSwapRequest,
|
|
16446
|
+
requestStream: false,
|
|
16447
|
+
responseType: InitiatePreimageSwapResponse,
|
|
16448
|
+
responseStream: false,
|
|
16449
|
+
options: {}
|
|
16450
|
+
},
|
|
15882
16451
|
start_leaf_swap_v2: {
|
|
15883
16452
|
name: "start_leaf_swap_v2",
|
|
15884
16453
|
requestType: StartTransferRequest,
|
|
@@ -15926,6 +16495,19 @@ var SparkServiceDefinition = {
|
|
|
15926
16495
|
responseType: QuerySparkInvoicesResponse,
|
|
15927
16496
|
responseStream: false,
|
|
15928
16497
|
options: {}
|
|
16498
|
+
},
|
|
16499
|
+
/**
|
|
16500
|
+
* Inititiates a primary transfer in a Swap V3 protocol. The sender submits the
|
|
16501
|
+
* transfer package, but the SOs will not tweak the keys at this stage of the flow.
|
|
16502
|
+
* It will be done later, when the SSP initiates a counter swap.
|
|
16503
|
+
*/
|
|
16504
|
+
initiate_swap_primary_transfer: {
|
|
16505
|
+
name: "initiate_swap_primary_transfer",
|
|
16506
|
+
requestType: InitiateSwapPrimaryTransferRequest,
|
|
16507
|
+
requestStream: false,
|
|
16508
|
+
responseType: InitiateSwapPrimaryTransferResponse,
|
|
16509
|
+
responseStream: false,
|
|
16510
|
+
options: {}
|
|
15929
16511
|
}
|
|
15930
16512
|
}
|
|
15931
16513
|
};
|
|
@@ -16194,7 +16776,7 @@ function encodeSparkAddressWithSignature(payload, signature) {
|
|
|
16194
16776
|
const serializedPayload = w.finish();
|
|
16195
16777
|
const words = bech32m.toWords(serializedPayload);
|
|
16196
16778
|
return bech32mEncode(
|
|
16197
|
-
|
|
16779
|
+
AddressNetwork[payload.network],
|
|
16198
16780
|
words
|
|
16199
16781
|
);
|
|
16200
16782
|
} catch (error) {
|
|
@@ -19724,7 +20306,7 @@ var isWebExtension = (
|
|
|
19724
20306
|
"chrome" in globalThis && globalThis.chrome.runtime?.id
|
|
19725
20307
|
);
|
|
19726
20308
|
var userAgent = "navigator" in globalThis ? globalThis.navigator.userAgent || "unknown-user-agent" : void 0;
|
|
19727
|
-
var packageVersion = true ? "0.4.
|
|
20309
|
+
var packageVersion = true ? "0.4.2" : "unknown";
|
|
19728
20310
|
var baseEnvStr = "unknown";
|
|
19729
20311
|
if (isBun) {
|
|
19730
20312
|
const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
|
|
@@ -20491,13 +21073,14 @@ import {
|
|
|
20491
21073
|
bytesToHex as bytesToHex12,
|
|
20492
21074
|
bytesToNumberBE as bytesToNumberBE8,
|
|
20493
21075
|
equalBytes as equalBytes6,
|
|
20494
|
-
hexToBytes as hexToBytes12
|
|
21076
|
+
hexToBytes as hexToBytes12,
|
|
21077
|
+
numberToVarBytesBE
|
|
20495
21078
|
} from "@noble/curves/utils";
|
|
20496
21079
|
import { validateMnemonic } from "@scure/bip39";
|
|
20497
21080
|
import { wordlist as wordlist2 } from "@scure/bip39/wordlists/english";
|
|
20498
21081
|
import { Address as Address5, OutScript as OutScript3, Transaction as Transaction7 } from "@scure/btc-signer";
|
|
20499
21082
|
import { Mutex } from "async-mutex";
|
|
20500
|
-
import { uuidv7 as uuidv74 } from "uuidv7";
|
|
21083
|
+
import { uuidv7 as uuidv74, uuidv7obj } from "uuidv7";
|
|
20501
21084
|
|
|
20502
21085
|
// src/graphql/client.ts
|
|
20503
21086
|
import {
|
|
@@ -22988,7 +23571,6 @@ var TransferService = class extends BaseTransferService {
|
|
|
22988
23571
|
nodeTxSigningJob: userSignedTxSigningJobs.get("node"),
|
|
22989
23572
|
refundTxSigningJob: userSignedTxSigningJobs.get("cpfp"),
|
|
22990
23573
|
directNodeTxSigningJob: userSignedTxSigningJobs.get("directNode"),
|
|
22991
|
-
directRefundTxSigningJob: void 0,
|
|
22992
23574
|
directFromCpfpRefundTxSigningJob: userSignedTxSigningJobs.get("directFromCpfp")
|
|
22993
23575
|
};
|
|
22994
23576
|
const response = await sparkClient.renew_leaf({
|
|
@@ -24173,7 +24755,7 @@ var LightningService = class {
|
|
|
24173
24755
|
const reason = isInboundPayment ? 1 /* REASON_RECEIVE */ : 0 /* REASON_SEND */;
|
|
24174
24756
|
let response;
|
|
24175
24757
|
try {
|
|
24176
|
-
response = await sparkClient.
|
|
24758
|
+
response = await sparkClient.initiate_preimage_swap_v3({
|
|
24177
24759
|
paymentHash,
|
|
24178
24760
|
invoiceAmount: {
|
|
24179
24761
|
invoiceAmountProof: {
|
|
@@ -30672,17 +31254,60 @@ var SparkWallet = class extends EventEmitter {
|
|
|
30672
31254
|
* @param {Object} params - Parameters for the sats payment
|
|
30673
31255
|
* @param {number} params.amount - The amount of sats to receive
|
|
30674
31256
|
* @param {string} [params.memo] - The memo for the payment
|
|
30675
|
-
* @param {string} [params.
|
|
31257
|
+
* @param {string} [params.senderSparkAddress] - The spark address of the expected sender
|
|
30676
31258
|
* @param {Date} [params.expiryTime] - The expiry time of the payment
|
|
30677
31259
|
* @returns {Promise<SparkAddressFormat>} The Spark address for the sats payment
|
|
30678
31260
|
*/
|
|
30679
31261
|
async createSatsInvoice({
|
|
30680
31262
|
amount,
|
|
30681
31263
|
memo,
|
|
30682
|
-
|
|
31264
|
+
senderSparkAddress,
|
|
30683
31265
|
expiryTime
|
|
30684
31266
|
}) {
|
|
30685
|
-
|
|
31267
|
+
const MAX_SATS_AMOUNT = 21e14;
|
|
31268
|
+
if (amount && (amount < 0 || amount > MAX_SATS_AMOUNT)) {
|
|
31269
|
+
throw new ValidationError(
|
|
31270
|
+
`Amount must be between 0 and ${MAX_SATS_AMOUNT} sats`,
|
|
31271
|
+
{
|
|
31272
|
+
field: "amount",
|
|
31273
|
+
value: amount,
|
|
31274
|
+
expected: `less than or equal to ${MAX_SATS_AMOUNT}`
|
|
31275
|
+
}
|
|
31276
|
+
);
|
|
31277
|
+
}
|
|
31278
|
+
const protoPayment = {
|
|
31279
|
+
$case: "satsPayment",
|
|
31280
|
+
satsPayment: {
|
|
31281
|
+
amount
|
|
31282
|
+
}
|
|
31283
|
+
};
|
|
31284
|
+
const senderPublicKey = senderSparkAddress ? hexToBytes12(
|
|
31285
|
+
decodeSparkAddress(senderSparkAddress, this.config.getNetworkType()).identityPublicKey
|
|
31286
|
+
) : void 0;
|
|
31287
|
+
const invoiceFields = {
|
|
31288
|
+
version: 1,
|
|
31289
|
+
id: uuidv7obj().bytes,
|
|
31290
|
+
paymentType: protoPayment,
|
|
31291
|
+
memo,
|
|
31292
|
+
senderPublicKey,
|
|
31293
|
+
expiryTime: expiryTime ?? void 0
|
|
31294
|
+
};
|
|
31295
|
+
validateSparkInvoiceFields(invoiceFields);
|
|
31296
|
+
const identityPublicKey = await this.config.signer.getIdentityPublicKey();
|
|
31297
|
+
const hash = HashSparkInvoice(
|
|
31298
|
+
invoiceFields,
|
|
31299
|
+
identityPublicKey,
|
|
31300
|
+
this.config.getNetworkType()
|
|
31301
|
+
);
|
|
31302
|
+
const signature = await this.config.signer.signSchnorrWithIdentityKey(hash);
|
|
31303
|
+
return encodeSparkAddressWithSignature(
|
|
31304
|
+
{
|
|
31305
|
+
identityPublicKey: bytesToHex12(identityPublicKey),
|
|
31306
|
+
network: this.config.getNetworkType(),
|
|
31307
|
+
sparkInvoiceFields: invoiceFields
|
|
31308
|
+
},
|
|
31309
|
+
signature
|
|
31310
|
+
);
|
|
30686
31311
|
}
|
|
30687
31312
|
/**
|
|
30688
31313
|
* Creates a Spark invoice for a tokens payment on Spark.
|
|
@@ -30691,7 +31316,7 @@ var SparkWallet = class extends EventEmitter {
|
|
|
30691
31316
|
* @param {bigint} [params.amount] - The amount of tokens to receive
|
|
30692
31317
|
* @param {Bech32mTokenIdentifier} [params.tokenIdentifier] - The token identifier
|
|
30693
31318
|
* @param {string} [params.memo] - The memo for the payment
|
|
30694
|
-
* @param {string} [params.
|
|
31319
|
+
* @param {string} [params.senderSparkAddress] - The spark address of the expected sender
|
|
30695
31320
|
* @param {Date} [params.expiryTime] - The expiry time of the payment
|
|
30696
31321
|
* @returns {Promise<SparkAddressFormat>} The Spark address for the tokens payment
|
|
30697
31322
|
*/
|
|
@@ -30699,10 +31324,58 @@ var SparkWallet = class extends EventEmitter {
|
|
|
30699
31324
|
amount,
|
|
30700
31325
|
tokenIdentifier,
|
|
30701
31326
|
memo,
|
|
30702
|
-
|
|
31327
|
+
senderSparkAddress,
|
|
30703
31328
|
expiryTime
|
|
30704
31329
|
}) {
|
|
30705
|
-
|
|
31330
|
+
const MAX_UINT128 = BigInt(2 ** 128 - 1);
|
|
31331
|
+
if (amount && (amount < 0 || amount > MAX_UINT128)) {
|
|
31332
|
+
throw new ValidationError(`Amount must be between 0 and ${MAX_UINT128}`, {
|
|
31333
|
+
field: "amount",
|
|
31334
|
+
value: amount,
|
|
31335
|
+
expected: `greater than or equal to 0 and less than or equal to ${MAX_UINT128}`
|
|
31336
|
+
});
|
|
31337
|
+
}
|
|
31338
|
+
let decodedTokenIdentifier = void 0;
|
|
31339
|
+
if (tokenIdentifier) {
|
|
31340
|
+
decodedTokenIdentifier = decodeBech32mTokenIdentifier(
|
|
31341
|
+
tokenIdentifier,
|
|
31342
|
+
this.config.getNetworkType()
|
|
31343
|
+
).tokenIdentifier;
|
|
31344
|
+
}
|
|
31345
|
+
const protoPayment = {
|
|
31346
|
+
$case: "tokensPayment",
|
|
31347
|
+
tokensPayment: {
|
|
31348
|
+
tokenIdentifier: decodedTokenIdentifier ?? void 0,
|
|
31349
|
+
amount: amount ? numberToVarBytesBE(amount) : void 0
|
|
31350
|
+
}
|
|
31351
|
+
};
|
|
31352
|
+
const senderPublicKey = senderSparkAddress ? hexToBytes12(
|
|
31353
|
+
decodeSparkAddress(senderSparkAddress, this.config.getNetworkType()).identityPublicKey
|
|
31354
|
+
) : void 0;
|
|
31355
|
+
const invoiceFields = {
|
|
31356
|
+
version: 1,
|
|
31357
|
+
id: uuidv7obj().bytes,
|
|
31358
|
+
paymentType: protoPayment,
|
|
31359
|
+
memo: memo ?? void 0,
|
|
31360
|
+
senderPublicKey,
|
|
31361
|
+
expiryTime: expiryTime ?? void 0
|
|
31362
|
+
};
|
|
31363
|
+
validateSparkInvoiceFields(invoiceFields);
|
|
31364
|
+
const identityPublicKey = await this.config.signer.getIdentityPublicKey();
|
|
31365
|
+
const hash = HashSparkInvoice(
|
|
31366
|
+
invoiceFields,
|
|
31367
|
+
identityPublicKey,
|
|
31368
|
+
this.config.getNetworkType()
|
|
31369
|
+
);
|
|
31370
|
+
const signature = await this.config.signer.signSchnorrWithIdentityKey(hash);
|
|
31371
|
+
return encodeSparkAddressWithSignature(
|
|
31372
|
+
{
|
|
31373
|
+
identityPublicKey: bytesToHex12(identityPublicKey),
|
|
31374
|
+
network: this.config.getNetworkType(),
|
|
31375
|
+
sparkInvoiceFields: invoiceFields
|
|
31376
|
+
},
|
|
31377
|
+
signature
|
|
31378
|
+
);
|
|
30706
31379
|
}
|
|
30707
31380
|
/**
|
|
30708
31381
|
* Initializes the wallet using either a mnemonic phrase or a raw seed.
|
|
@@ -32767,7 +33440,7 @@ var SparkWallet = class extends EventEmitter {
|
|
|
32767
33440
|
}
|
|
32768
33441
|
}
|
|
32769
33442
|
return await this.withLeaves(async () => {
|
|
32770
|
-
const expiryTime = new Date(Date.now() +
|
|
33443
|
+
const expiryTime = new Date(Date.now() + 16 * 24 * 60 * 60 * 1e3);
|
|
32771
33444
|
const sspClient = this.getSspClient();
|
|
32772
33445
|
const feeEstimate = await this.getLightningSendFeeEstimate({
|
|
32773
33446
|
encodedInvoice: invoice,
|
|
@@ -32847,8 +33520,124 @@ var SparkWallet = class extends EventEmitter {
|
|
|
32847
33520
|
return sspResponse;
|
|
32848
33521
|
});
|
|
32849
33522
|
}
|
|
33523
|
+
/**
|
|
33524
|
+
* Fulfills one or more Spark invoices.
|
|
33525
|
+
*
|
|
33526
|
+
* Processes each provided invoice and attempts to pay it according to the wallet’s
|
|
33527
|
+
* funding/selection strategy.
|
|
33528
|
+
*
|
|
33529
|
+
* @param sparkInvoices - Invoices to fulfill.
|
|
33530
|
+
* @param sparkInvoices[].invoice - The parsed Spark address/invoice to pay.
|
|
33531
|
+
* Must be a valid Spark address or invoice.
|
|
33532
|
+
* Must use spark1... prefixed invoices.
|
|
33533
|
+
* Deprecated sp1... prefixed invoices are not supported.
|
|
33534
|
+
* @param sparkInvoices[].amount - Used to define an amount for invoices without an amount encoded.
|
|
33535
|
+
* For sats invoices, this is the amount in sats. For token invoices, this is the amount in tokens.
|
|
33536
|
+
* Amount encoded in the invoice takes precedence if both are provided.
|
|
33537
|
+
*
|
|
33538
|
+
* @returns Promise<string> A payment or transaction identifier (implementation‑specific).
|
|
33539
|
+
*
|
|
33540
|
+
* @throws {ValidationError} If validation fails (malformed invoice, zero/negative amount, unsupported network),
|
|
33541
|
+
*
|
|
33542
|
+
* @example
|
|
33543
|
+
* await wallet.fulfillSparkInvoice([
|
|
33544
|
+
* { invoice: invoiceWithNilAmount, amount: 1000n },
|
|
33545
|
+
* { invoice: invoiceWithEncodedAmount }, // uses amount encoded in the invoice
|
|
33546
|
+
* ]);
|
|
33547
|
+
*/
|
|
32850
33548
|
async fulfillSparkInvoice(sparkInvoices) {
|
|
32851
|
-
|
|
33549
|
+
if (!Array.isArray(sparkInvoices) || sparkInvoices.length === 0) {
|
|
33550
|
+
throw new ValidationError("No Spark invoices provided", {
|
|
33551
|
+
field: "sparkInvoices",
|
|
33552
|
+
value: sparkInvoices,
|
|
33553
|
+
expected: "Non-empty array"
|
|
33554
|
+
});
|
|
33555
|
+
}
|
|
33556
|
+
const satsTransactionSuccess = [];
|
|
33557
|
+
const satsTransactionErrors = [];
|
|
33558
|
+
const tokenTransactionSuccess = [];
|
|
33559
|
+
const tokenTransactionErrors = [];
|
|
33560
|
+
const { satsInvoices, tokenInvoices, invalidInvoices } = await this.groupSparkInvoicesByPaymentType(sparkInvoices);
|
|
33561
|
+
if (invalidInvoices.length > 0) {
|
|
33562
|
+
return {
|
|
33563
|
+
satsTransactionSuccess,
|
|
33564
|
+
satsTransactionErrors,
|
|
33565
|
+
tokenTransactionSuccess,
|
|
33566
|
+
tokenTransactionErrors,
|
|
33567
|
+
invalidInvoices
|
|
33568
|
+
};
|
|
33569
|
+
}
|
|
33570
|
+
if (tokenInvoices.size > 0) {
|
|
33571
|
+
await this.syncTokenOutputs();
|
|
33572
|
+
const tokenTransferTasks = [];
|
|
33573
|
+
for (const [identifierHex, decodedInvoices] of tokenInvoices.entries()) {
|
|
33574
|
+
const tokenIdentifier = hexToBytes12(identifierHex);
|
|
33575
|
+
const tokenIdB32 = encodeBech32mTokenIdentifier({
|
|
33576
|
+
tokenIdentifier,
|
|
33577
|
+
network: this.config.getNetworkType()
|
|
33578
|
+
});
|
|
33579
|
+
const receiverOutputs = decodedInvoices.map((d) => ({
|
|
33580
|
+
tokenIdentifier: tokenIdB32,
|
|
33581
|
+
tokenAmount: d.amount,
|
|
33582
|
+
receiverSparkAddress: d.invoice
|
|
33583
|
+
}));
|
|
33584
|
+
const invoices = decodedInvoices.map(
|
|
33585
|
+
(d) => d.invoice
|
|
33586
|
+
);
|
|
33587
|
+
tokenTransferTasks.push(
|
|
33588
|
+
this.tokenTransactionService.tokenTransfer({ tokenOutputs: this.tokenOutputs, receiverOutputs }).then((txid) => ({
|
|
33589
|
+
ok: true,
|
|
33590
|
+
tokenIdentifier: tokenIdB32,
|
|
33591
|
+
invoices,
|
|
33592
|
+
txid
|
|
33593
|
+
})).catch((e) => ({
|
|
33594
|
+
ok: false,
|
|
33595
|
+
tokenIdentifier: tokenIdB32,
|
|
33596
|
+
invoices,
|
|
33597
|
+
error: e instanceof Error ? e : new Error(String(e))
|
|
33598
|
+
}))
|
|
33599
|
+
);
|
|
33600
|
+
}
|
|
33601
|
+
const results = await Promise.all(tokenTransferTasks);
|
|
33602
|
+
for (const r of results) {
|
|
33603
|
+
if (r.ok) {
|
|
33604
|
+
tokenTransactionSuccess.push({
|
|
33605
|
+
tokenIdentifier: r.tokenIdentifier,
|
|
33606
|
+
invoices: r.invoices,
|
|
33607
|
+
txid: r.txid
|
|
33608
|
+
});
|
|
33609
|
+
} else {
|
|
33610
|
+
tokenTransactionErrors.push({
|
|
33611
|
+
tokenIdentifier: r.tokenIdentifier,
|
|
33612
|
+
invoices: r.invoices,
|
|
33613
|
+
error: r.error
|
|
33614
|
+
});
|
|
33615
|
+
}
|
|
33616
|
+
}
|
|
33617
|
+
}
|
|
33618
|
+
if (satsInvoices.length > 0) {
|
|
33619
|
+
const transfers = await this.transferWithInvoice(satsInvoices);
|
|
33620
|
+
for (const transfer of transfers) {
|
|
33621
|
+
if (transfer.ok) {
|
|
33622
|
+
satsTransactionSuccess.push({
|
|
33623
|
+
invoice: transfer.param.sparkInvoice ?? "",
|
|
33624
|
+
transferResponse: transfer.transfer
|
|
33625
|
+
});
|
|
33626
|
+
} else {
|
|
33627
|
+
satsTransactionErrors.push({
|
|
33628
|
+
invoice: transfer.param.sparkInvoice ?? "",
|
|
33629
|
+
error: transfer.error
|
|
33630
|
+
});
|
|
33631
|
+
}
|
|
33632
|
+
}
|
|
33633
|
+
}
|
|
33634
|
+
return {
|
|
33635
|
+
satsTransactionSuccess,
|
|
33636
|
+
satsTransactionErrors,
|
|
33637
|
+
tokenTransactionSuccess,
|
|
33638
|
+
tokenTransactionErrors,
|
|
33639
|
+
invalidInvoices
|
|
33640
|
+
};
|
|
32852
33641
|
}
|
|
32853
33642
|
async groupSparkInvoicesByPaymentType(sparkInvoices) {
|
|
32854
33643
|
const satsInvoices = [];
|
|
@@ -32857,6 +33646,17 @@ var SparkWallet = class extends EventEmitter {
|
|
|
32857
33646
|
const identityPublicKey = await this.getIdentityPublicKey();
|
|
32858
33647
|
sparkInvoices.forEach((input) => {
|
|
32859
33648
|
const { invoice, amount } = input;
|
|
33649
|
+
if (isLegacySparkAddress(invoice)) {
|
|
33650
|
+
invalidInvoices.push({
|
|
33651
|
+
invoice,
|
|
33652
|
+
error: new ValidationError("Deprecated spark invoice format", {
|
|
33653
|
+
field: "invoice",
|
|
33654
|
+
value: invoice,
|
|
33655
|
+
expected: "Spark invoice prefixed with spark... Deprecated sp... formats are not supported."
|
|
33656
|
+
})
|
|
33657
|
+
});
|
|
33658
|
+
return;
|
|
33659
|
+
}
|
|
32860
33660
|
const addressData = decodeSparkAddress(
|
|
32861
33661
|
invoice,
|
|
32862
33662
|
this.config.getNetworkType()
|
|
@@ -32986,7 +33786,12 @@ var SparkWallet = class extends EventEmitter {
|
|
|
32986
33786
|
return { satsInvoices, tokenInvoices, invalidInvoices };
|
|
32987
33787
|
}
|
|
32988
33788
|
async querySparkInvoices(invoices) {
|
|
32989
|
-
|
|
33789
|
+
const sparkClient = await this.connectionManager.createSparkClient(
|
|
33790
|
+
this.config.getCoordinatorAddress()
|
|
33791
|
+
);
|
|
33792
|
+
return await sparkClient.query_spark_invoices({
|
|
33793
|
+
invoice: invoices
|
|
33794
|
+
});
|
|
32990
33795
|
}
|
|
32991
33796
|
/**
|
|
32992
33797
|
* Gets fee estimate for sending Lightning payments.
|