@arkade-os/swap 0.1.8 → 0.1.10
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/dist/advanced.cjs +1125 -554
- package/dist/advanced.d.cts +19 -21
- package/dist/advanced.d.ts +19 -21
- package/dist/advanced.js +40 -34
- package/dist/{chunk-ISWLKKSS.js → chunk-2HQZLIVX.js} +106 -39
- package/dist/{chunk-5QPJWOCN.js → chunk-6RJVT65W.js} +2 -0
- package/dist/chunk-AUJDREZN.js +445 -0
- package/dist/{chunk-ZBJGLLYV.js → chunk-FWRDAL73.js} +157 -477
- package/dist/{chunk-PDNVKH5L.js → chunk-LCO6AJOS.js} +453 -70
- package/dist/index.cjs +1110 -542
- package/dist/index.d.cts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/index.js +24 -22
- package/dist/{lockupContract-DguuT7NK.d.cts → lockupContract-BTTRVwOt.d.cts} +1 -1
- package/dist/{lockupContract-BUOsghl1.d.ts → lockupContract-aFarhlxj.d.ts} +1 -1
- package/dist/node/index.d.cts +97 -67
- package/dist/node/index.d.ts +97 -67
- package/dist/nostr.cjs +925 -516
- package/dist/nostr.d.cts +1 -1
- package/dist/nostr.d.ts +1 -1
- package/dist/nostr.js +3 -2
- package/dist/{offerFillPlan-_AOLo6kh.d.ts → offerFillPlan-CJC5tnEd.d.ts} +10 -42
- package/dist/{offerFillPlan-Bp6-z6dS.d.cts → offerFillPlan-FmyaQoYT.d.cts} +10 -42
- package/dist/protocol.cjs +1082 -188
- package/dist/protocol.d.cts +42 -23
- package/dist/protocol.d.ts +42 -23
- package/dist/protocol.js +20 -7
- package/dist/repositories/realm/index.d.cts +3 -2
- package/dist/repositories/realm/index.d.ts +3 -2
- package/dist/repositories/sqlite/index.d.cts +3 -2
- package/dist/repositories/sqlite/index.d.ts +3 -2
- package/dist/{repository-CkKK0dGO.d.ts → repository-CwwhIAEd.d.cts} +406 -74
- package/dist/{repository--pfikw2R.d.cts → repository-DO6QKxBx.d.ts} +406 -74
- package/dist/{rfq-IzhOCG02.d.ts → rfq-CYxOyniL.d.ts} +52 -11
- package/dist/rfq-contract.cjs +3 -0
- package/dist/rfq-contract.d.cts +3 -1
- package/dist/rfq-contract.d.ts +3 -1
- package/dist/rfq-contract.js +3 -1
- package/dist/{rfq-BRpo5uWU.d.cts → rfq-nMGywkqI.d.cts} +52 -11
- package/dist/verify-ENO36VPK.js +33 -0
- package/dist/{watch-pvTVFp6-.d.cts → watch-DpDSP2tu.d.cts} +4 -3
- package/dist/{watch-DDNycuUa.d.ts → watch-_fZSgx_l.d.ts} +4 -3
- package/package.json +2 -2
- package/dist/offer-BhonWuKR.d.ts +0 -274
- package/dist/offer-D_qHpWo2.d.cts +0 -274
package/dist/protocol.cjs
CHANGED
|
@@ -52,9 +52,9 @@ function onchainHtlcScript(params, network) {
|
|
|
52
52
|
if (params.claimKey.length !== 32 || params.refundKey.length !== 32) {
|
|
53
53
|
throw new Error("claimKey and refundKey must be 32-byte x-only keys");
|
|
54
54
|
}
|
|
55
|
-
if (!Number.isInteger(params.refundLocktime) || params.refundLocktime <= 0) {
|
|
55
|
+
if (!Number.isInteger(params.refundLocktime) || params.refundLocktime <= 0 || params.refundLocktime > 4294967295) {
|
|
56
56
|
throw new Error(
|
|
57
|
-
`refundLocktime must be a positive unix timestamp, got ${params.refundLocktime}`
|
|
57
|
+
`refundLocktime must be a positive uint32 unix timestamp, got ${params.refundLocktime}`
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
if (params.refundLocktime < LOCKTIME_THRESHOLD) {
|
|
@@ -147,15 +147,20 @@ async function claimOnchainFill(chain, input) {
|
|
|
147
147
|
}
|
|
148
148
|
async function classifyOnchainHtlc(chain, input) {
|
|
149
149
|
const utxos = await chain.getScriptUtxos(input.htlc.pkScript);
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
150
|
+
const deep = (u) => u.confirmations >= input.minConfirmations;
|
|
151
|
+
const best = utxos.sort(
|
|
152
|
+
(a, b) => deep(a) !== deep(b) ? deep(a) ? -1 : 1 : b.amount > a.amount ? 1 : -1
|
|
153
|
+
)[0];
|
|
154
|
+
const { funding } = input;
|
|
155
|
+
let spend = null;
|
|
156
|
+
if (funding && !utxos.some((u) => u.txid === funding.txid && u.vout === funding.vout)) {
|
|
157
|
+
try {
|
|
158
|
+
spend = await chain.getSpendingTx(funding.txid, funding.vout, input.htlc.pkScript);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
if (!best) throw error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (spend) {
|
|
159
164
|
const preimage = extractPreimage(spend.txHex, input.htlc.paymentHash);
|
|
160
165
|
const txid = btc.Transaction.fromRaw(import_base.hex.decode(spend.txHex), {
|
|
161
166
|
allowUnknownInputs: true,
|
|
@@ -163,6 +168,7 @@ async function classifyOnchainHtlc(chain, input) {
|
|
|
163
168
|
}).id;
|
|
164
169
|
return preimage ? { phase: "claimed", txid, preimage } : { phase: "swept", txid };
|
|
165
170
|
}
|
|
171
|
+
if (!best) return { phase: "unfunded" };
|
|
166
172
|
if (best.confirmations < input.minConfirmations)
|
|
167
173
|
return { phase: "awaiting_confirmations", utxo: best };
|
|
168
174
|
const mtp = await chain.getMtp();
|
|
@@ -616,6 +622,141 @@ var init_asset_swap = __esm({
|
|
|
616
622
|
}
|
|
617
623
|
});
|
|
618
624
|
|
|
625
|
+
// src/contracts/asset-swap-v4.json
|
|
626
|
+
var asset_swap_v4_default;
|
|
627
|
+
var init_asset_swap_v4 = __esm({
|
|
628
|
+
"src/contracts/asset-swap-v4.json"() {
|
|
629
|
+
asset_swap_v4_default = {
|
|
630
|
+
formatVersion: 1,
|
|
631
|
+
contractName: "AssetSwap",
|
|
632
|
+
constructorInputs: [
|
|
633
|
+
{
|
|
634
|
+
name: "receiver",
|
|
635
|
+
type: "pubkey"
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
name: "amount",
|
|
639
|
+
type: "int"
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
name: "assetTxid",
|
|
643
|
+
type: "bytes32"
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
name: "assetGroupIndex",
|
|
647
|
+
type: "int"
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
name: "user",
|
|
651
|
+
type: "pubkey"
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
name: "taker",
|
|
655
|
+
type: "pubkey"
|
|
656
|
+
}
|
|
657
|
+
],
|
|
658
|
+
functions: [
|
|
659
|
+
{
|
|
660
|
+
name: "fulfill",
|
|
661
|
+
arkade: {
|
|
662
|
+
inputs: [],
|
|
663
|
+
asm: [
|
|
664
|
+
"OP_PUSHCURRENTINPUTINDEX",
|
|
665
|
+
"OP_DUP",
|
|
666
|
+
"<assetTxid>",
|
|
667
|
+
"<assetGroupIndex>",
|
|
668
|
+
"OP_INSPECTOUTASSETLOOKUP",
|
|
669
|
+
"OP_VERIFY",
|
|
670
|
+
"<amount>",
|
|
671
|
+
"OP_GREATERTHANOREQUAL",
|
|
672
|
+
"OP_VERIFY",
|
|
673
|
+
"OP_INSPECTOUTPUTSCRIPTPUBKEY",
|
|
674
|
+
"1",
|
|
675
|
+
"OP_NUMEQUALVERIFY",
|
|
676
|
+
"<receiver>",
|
|
677
|
+
"OP_EQUAL"
|
|
678
|
+
]
|
|
679
|
+
},
|
|
680
|
+
leaves: [
|
|
681
|
+
{
|
|
682
|
+
name: "fulfill",
|
|
683
|
+
witness: [
|
|
684
|
+
{
|
|
685
|
+
name: "takerSig",
|
|
686
|
+
type: "signature",
|
|
687
|
+
encoding: "schnorr-64"
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
name: "serverSig",
|
|
691
|
+
type: "signature",
|
|
692
|
+
encoding: "schnorr-64",
|
|
693
|
+
injected: true
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
name: "emulatorSig",
|
|
697
|
+
type: "signature",
|
|
698
|
+
encoding: "schnorr-64",
|
|
699
|
+
injected: true
|
|
700
|
+
}
|
|
701
|
+
],
|
|
702
|
+
asm: [
|
|
703
|
+
"<taker>",
|
|
704
|
+
"OP_CHECKSIGVERIFY",
|
|
705
|
+
"<SERVER_KEY>",
|
|
706
|
+
"OP_CHECKSIGVERIFY",
|
|
707
|
+
"<EMULATOR_KEY:fulfill>",
|
|
708
|
+
"OP_CHECKSIG"
|
|
709
|
+
]
|
|
710
|
+
}
|
|
711
|
+
]
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
name: "cancel",
|
|
715
|
+
leaves: [
|
|
716
|
+
{
|
|
717
|
+
name: "cancel",
|
|
718
|
+
witness: [
|
|
719
|
+
{
|
|
720
|
+
name: "userSig",
|
|
721
|
+
type: "signature",
|
|
722
|
+
encoding: "schnorr-64"
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
name: "serverSig",
|
|
726
|
+
type: "signature",
|
|
727
|
+
encoding: "schnorr-64",
|
|
728
|
+
injected: true
|
|
729
|
+
}
|
|
730
|
+
],
|
|
731
|
+
asm: [
|
|
732
|
+
"<user>",
|
|
733
|
+
"OP_CHECKSIGVERIFY",
|
|
734
|
+
"<SERVER_KEY>",
|
|
735
|
+
"OP_CHECKSIG"
|
|
736
|
+
]
|
|
737
|
+
}
|
|
738
|
+
]
|
|
739
|
+
}
|
|
740
|
+
],
|
|
741
|
+
source: {
|
|
742
|
+
entry: "asset-swap-v4.ark",
|
|
743
|
+
files: {
|
|
744
|
+
"asset-swap-v4.ark": "pragma arkade ^0.1.0;\n\n// The output at this input's index pays `receiver` at least `amount` of the asset,\n// and only `taker` can make that spend.\ncontract AssetSwap(\n pubkey receiver,\n int amount,\n bytes32 assetTxid,\n int assetGroupIndex,\n pubkey user,\n pubkey taker\n) {\n function fulfill() {\n int i = this.activeInputIndex;\n require(tx.outputs[i].assets.lookup(assetTxid, assetGroupIndex) >= amount);\n let paid = tx.outputs[i].script;\n require(paid.version == 1);\n require(paid.program == receiver);\n }\n\n // Replaces the synthesized collaborative leaf: the quoting solver is a third\n // conjunct, so an observer who reads the deposit cannot complete it.\n function fulfill(signature takerSig, signature serverSig, signature emulatorSig) tapscript {\n require(checkMultisig([taker, server, emulator], [takerSig, serverSig, emulatorSig], 3));\n }\n\n function cancel(signature userSig, signature serverSig) tapscript {\n require(checkMultisig([user, server], [userSig, serverSig], 2));\n }\n}\n"
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
compiler: {
|
|
748
|
+
name: "arkadec",
|
|
749
|
+
version: "0.1.0-rc.1",
|
|
750
|
+
options: {
|
|
751
|
+
optimize: true
|
|
752
|
+
}
|
|
753
|
+
},
|
|
754
|
+
updatedAt: "2026-11-19T20:57:50.605738400+00:00",
|
|
755
|
+
fingerprint: "sha256:d830de32cd1d286a0a1fac698ff114a6c8ef5338a69f9f813717d1038ab2fb4a"
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
|
|
619
760
|
// src/contracts/sats-swap.json
|
|
620
761
|
var sats_swap_default;
|
|
621
762
|
var init_sats_swap = __esm({
|
|
@@ -729,6 +870,130 @@ var init_sats_swap = __esm({
|
|
|
729
870
|
}
|
|
730
871
|
});
|
|
731
872
|
|
|
873
|
+
// src/contracts/sats-swap-v4.json
|
|
874
|
+
var sats_swap_v4_default;
|
|
875
|
+
var init_sats_swap_v4 = __esm({
|
|
876
|
+
"src/contracts/sats-swap-v4.json"() {
|
|
877
|
+
sats_swap_v4_default = {
|
|
878
|
+
formatVersion: 1,
|
|
879
|
+
contractName: "SatsSwap",
|
|
880
|
+
constructorInputs: [
|
|
881
|
+
{
|
|
882
|
+
name: "receiver",
|
|
883
|
+
type: "pubkey"
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
name: "amount",
|
|
887
|
+
type: "int"
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
name: "user",
|
|
891
|
+
type: "pubkey"
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
name: "taker",
|
|
895
|
+
type: "pubkey"
|
|
896
|
+
}
|
|
897
|
+
],
|
|
898
|
+
functions: [
|
|
899
|
+
{
|
|
900
|
+
name: "fulfill",
|
|
901
|
+
arkade: {
|
|
902
|
+
inputs: [],
|
|
903
|
+
asm: [
|
|
904
|
+
"OP_PUSHCURRENTINPUTINDEX",
|
|
905
|
+
"OP_DUP",
|
|
906
|
+
"OP_INSPECTOUTPUTVALUE",
|
|
907
|
+
"<amount>",
|
|
908
|
+
"OP_GREATERTHANOREQUAL",
|
|
909
|
+
"OP_VERIFY",
|
|
910
|
+
"OP_INSPECTOUTPUTSCRIPTPUBKEY",
|
|
911
|
+
"1",
|
|
912
|
+
"OP_NUMEQUALVERIFY",
|
|
913
|
+
"<receiver>",
|
|
914
|
+
"OP_EQUAL"
|
|
915
|
+
]
|
|
916
|
+
},
|
|
917
|
+
leaves: [
|
|
918
|
+
{
|
|
919
|
+
name: "fulfill",
|
|
920
|
+
witness: [
|
|
921
|
+
{
|
|
922
|
+
name: "takerSig",
|
|
923
|
+
type: "signature",
|
|
924
|
+
encoding: "schnorr-64"
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
name: "serverSig",
|
|
928
|
+
type: "signature",
|
|
929
|
+
encoding: "schnorr-64",
|
|
930
|
+
injected: true
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
name: "emulatorSig",
|
|
934
|
+
type: "signature",
|
|
935
|
+
encoding: "schnorr-64",
|
|
936
|
+
injected: true
|
|
937
|
+
}
|
|
938
|
+
],
|
|
939
|
+
asm: [
|
|
940
|
+
"<taker>",
|
|
941
|
+
"OP_CHECKSIGVERIFY",
|
|
942
|
+
"<SERVER_KEY>",
|
|
943
|
+
"OP_CHECKSIGVERIFY",
|
|
944
|
+
"<EMULATOR_KEY:fulfill>",
|
|
945
|
+
"OP_CHECKSIG"
|
|
946
|
+
]
|
|
947
|
+
}
|
|
948
|
+
]
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
name: "cancel",
|
|
952
|
+
leaves: [
|
|
953
|
+
{
|
|
954
|
+
name: "cancel",
|
|
955
|
+
witness: [
|
|
956
|
+
{
|
|
957
|
+
name: "userSig",
|
|
958
|
+
type: "signature",
|
|
959
|
+
encoding: "schnorr-64"
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
name: "serverSig",
|
|
963
|
+
type: "signature",
|
|
964
|
+
encoding: "schnorr-64",
|
|
965
|
+
injected: true
|
|
966
|
+
}
|
|
967
|
+
],
|
|
968
|
+
asm: [
|
|
969
|
+
"<user>",
|
|
970
|
+
"OP_CHECKSIGVERIFY",
|
|
971
|
+
"<SERVER_KEY>",
|
|
972
|
+
"OP_CHECKSIG"
|
|
973
|
+
]
|
|
974
|
+
}
|
|
975
|
+
]
|
|
976
|
+
}
|
|
977
|
+
],
|
|
978
|
+
source: {
|
|
979
|
+
entry: "sats-swap-v4.ark",
|
|
980
|
+
files: {
|
|
981
|
+
"sats-swap-v4.ark": "pragma arkade ^0.1.0;\n\n// The output at this input's index pays `receiver` at least `amount` sats,\n// and only `taker` can make that spend.\ncontract SatsSwap(\n pubkey receiver,\n int amount,\n pubkey user,\n pubkey taker\n) {\n function fulfill() {\n int i = this.activeInputIndex;\n require(tx.outputs[i].value >= amount);\n let paid = tx.outputs[i].script;\n require(paid.version == 1);\n require(paid.program == receiver);\n }\n\n function fulfill(signature takerSig, signature serverSig, signature emulatorSig) tapscript {\n require(checkMultisig([taker, server, emulator], [takerSig, serverSig, emulatorSig], 3));\n }\n\n function cancel(signature userSig, signature serverSig) tapscript {\n require(checkMultisig([user, server], [userSig, serverSig], 2));\n }\n}\n"
|
|
982
|
+
}
|
|
983
|
+
},
|
|
984
|
+
compiler: {
|
|
985
|
+
name: "arkadec",
|
|
986
|
+
version: "0.1.0-rc.1",
|
|
987
|
+
options: {
|
|
988
|
+
optimize: true
|
|
989
|
+
}
|
|
990
|
+
},
|
|
991
|
+
updatedAt: "2026-11-19T20:57:50.848496600+00:00",
|
|
992
|
+
fingerprint: "sha256:6ca61bf7ed8d8f65af3141da4e95fcc896863650127dd20949a84e72258053f4"
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
|
|
732
997
|
// src/legacy/swap-want-asset.program.v1.json
|
|
733
998
|
var swap_want_asset_program_v1_default;
|
|
734
999
|
var init_swap_want_asset_program_v1 = __esm({
|
|
@@ -815,7 +1080,7 @@ var init_swap_want_btc_program_v1 = __esm({
|
|
|
815
1080
|
});
|
|
816
1081
|
|
|
817
1082
|
// src/rfq-contract.ts
|
|
818
|
-
var RFQ_CONTRACT_VERSIONS_KEY, RFQ_CONTRACT_VERSION_KEY, RFQ_CONTRACT_VERSION_UNSUPPORTED, ASSET_SWAP_V2, ASSET_SWAP_V3, ASSET_SWAP_BASELINE;
|
|
1083
|
+
var RFQ_CONTRACT_VERSIONS_KEY, RFQ_CONTRACT_VERSION_KEY, RFQ_CONTRACT_VERSION_UNSUPPORTED, ASSET_SWAP_V2, ASSET_SWAP_V3, ASSET_SWAP_V4, ASSET_SWAP_BASELINE;
|
|
819
1084
|
var init_rfq_contract = __esm({
|
|
820
1085
|
"src/rfq-contract.ts"() {
|
|
821
1086
|
"use strict";
|
|
@@ -824,18 +1089,21 @@ var init_rfq_contract = __esm({
|
|
|
824
1089
|
RFQ_CONTRACT_VERSION_UNSUPPORTED = "contract_version_unsupported";
|
|
825
1090
|
ASSET_SWAP_V2 = "asset-swap-v2";
|
|
826
1091
|
ASSET_SWAP_V3 = "asset-swap-v3";
|
|
1092
|
+
ASSET_SWAP_V4 = "asset-swap-v4";
|
|
827
1093
|
ASSET_SWAP_BASELINE = ASSET_SWAP_V2;
|
|
828
1094
|
}
|
|
829
1095
|
});
|
|
830
1096
|
|
|
831
1097
|
// src/program.ts
|
|
832
|
-
var import_sdk3, swapPrograms, legacySwapPrograms, sharedArgs, ASSET_SWAP_CONTRACTS, ASSET_SWAP_CONTRACT_VERSIONS, assetSwapContractVersion;
|
|
1098
|
+
var import_sdk3, swapPrograms, legacySwapPrograms, directedSwapPrograms, sharedArgs, refuseTaker, v3Args, ASSET_SWAP_CONTRACTS, ASSET_SWAP_CONTRACT_VERSIONS, ASSET_SWAP_DERIVABLE_VERSIONS, assetSwapContractVersion;
|
|
833
1099
|
var init_program = __esm({
|
|
834
1100
|
"src/program.ts"() {
|
|
835
1101
|
"use strict";
|
|
836
1102
|
import_sdk3 = require("@arkade-os/sdk");
|
|
837
1103
|
init_asset_swap();
|
|
1104
|
+
init_asset_swap_v4();
|
|
838
1105
|
init_sats_swap();
|
|
1106
|
+
init_sats_swap_v4();
|
|
839
1107
|
init_swap_want_asset_program_v1();
|
|
840
1108
|
init_swap_want_btc_program_v1();
|
|
841
1109
|
init_rfq_contract();
|
|
@@ -848,38 +1116,60 @@ var init_program = __esm({
|
|
|
848
1116
|
wantAsset: import_sdk3.arkade.parseArtifact(swap_want_asset_program_v1_default),
|
|
849
1117
|
wantBtc: import_sdk3.arkade.parseArtifact(swap_want_btc_program_v1_default)
|
|
850
1118
|
};
|
|
1119
|
+
directedSwapPrograms = {
|
|
1120
|
+
wantAsset: import_sdk3.arkade.programFromArtifact(asset_swap_v4_default),
|
|
1121
|
+
wantBtc: import_sdk3.arkade.programFromArtifact(sats_swap_v4_default)
|
|
1122
|
+
};
|
|
851
1123
|
sharedArgs = ({ user, server, exitDelay }) => ({
|
|
852
1124
|
user,
|
|
853
1125
|
server,
|
|
854
1126
|
...exitDelay && { exitDelay }
|
|
855
1127
|
});
|
|
1128
|
+
refuseTaker = (version, { taker }) => {
|
|
1129
|
+
if (taker !== void 0) throw new Error(`${version} binds no taker key`);
|
|
1130
|
+
};
|
|
1131
|
+
v3Args = (inputs) => ({
|
|
1132
|
+
receiver: inputs.receiver,
|
|
1133
|
+
amount: inputs.amount,
|
|
1134
|
+
...inputs.asset && {
|
|
1135
|
+
assetTxid: inputs.asset.txid,
|
|
1136
|
+
assetGroupIndex: inputs.asset.groupIndex
|
|
1137
|
+
},
|
|
1138
|
+
...sharedArgs(inputs)
|
|
1139
|
+
});
|
|
856
1140
|
ASSET_SWAP_CONTRACTS = {
|
|
857
1141
|
[ASSET_SWAP_V2]: {
|
|
858
1142
|
programs: legacySwapPrograms,
|
|
859
|
-
args: (inputs) =>
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
1143
|
+
args: (inputs) => {
|
|
1144
|
+
refuseTaker(ASSET_SWAP_V2, inputs);
|
|
1145
|
+
return {
|
|
1146
|
+
makerWP: inputs.receiver,
|
|
1147
|
+
wantAmount: inputs.amount,
|
|
1148
|
+
...inputs.asset && {
|
|
1149
|
+
wantAssetTxid: inputs.asset.txid,
|
|
1150
|
+
wantAssetGroupIndex: inputs.asset.groupIndex
|
|
1151
|
+
},
|
|
1152
|
+
...sharedArgs(inputs)
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
868
1155
|
},
|
|
869
1156
|
[ASSET_SWAP_V3]: {
|
|
870
1157
|
programs: swapPrograms,
|
|
871
|
-
args: (inputs) =>
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
1158
|
+
args: (inputs) => {
|
|
1159
|
+
refuseTaker(ASSET_SWAP_V3, inputs);
|
|
1160
|
+
return v3Args(inputs);
|
|
1161
|
+
}
|
|
1162
|
+
},
|
|
1163
|
+
[ASSET_SWAP_V4]: {
|
|
1164
|
+
programs: directedSwapPrograms,
|
|
1165
|
+
args: (inputs) => {
|
|
1166
|
+
if (inputs.taker === void 0) throw new Error(`${ASSET_SWAP_V4} needs a taker key`);
|
|
1167
|
+
return { ...v3Args(inputs), taker: inputs.taker };
|
|
1168
|
+
}
|
|
880
1169
|
}
|
|
881
1170
|
};
|
|
882
|
-
ASSET_SWAP_CONTRACT_VERSIONS = [
|
|
1171
|
+
ASSET_SWAP_CONTRACT_VERSIONS = [ASSET_SWAP_V4];
|
|
1172
|
+
ASSET_SWAP_DERIVABLE_VERSIONS = [ASSET_SWAP_V4, ASSET_SWAP_V3, ASSET_SWAP_V2];
|
|
883
1173
|
assetSwapContractVersion = (id) => {
|
|
884
1174
|
if (id === void 0) return ASSET_SWAP_BASELINE;
|
|
885
1175
|
if (Object.hasOwn(ASSET_SWAP_CONTRACTS, id)) return id;
|
|
@@ -956,9 +1246,9 @@ var init_store = __esm({
|
|
|
956
1246
|
byNewest = (a, b) => b.createdAt - a.createdAt;
|
|
957
1247
|
getAssetSwapsOrThrow = async (repository) => {
|
|
958
1248
|
return (await collectAssetSwaps(repository)).filter(
|
|
959
|
-
(s) => s && typeof s.id === "string" && // offer swaps carry the TLV; onchain-corridor swaps carry
|
|
960
|
-
// the payment hash instead —
|
|
961
|
-
(typeof s.offerHex === "string" || typeof s.paymentHash === "string")
|
|
1249
|
+
(s) => s && typeof s.id === "string" && // offer swaps carry the TLV or the binding; onchain-corridor swaps carry
|
|
1250
|
+
// the payment hash instead — any of them marks a valid record
|
|
1251
|
+
(typeof s.offerHex === "string" || s.binding !== void 0 || typeof s.paymentHash === "string")
|
|
962
1252
|
).sort(byNewest);
|
|
963
1253
|
};
|
|
964
1254
|
getAssetSwaps = async (repository) => {
|
|
@@ -1157,28 +1447,28 @@ function withExitClosure(program, exit) {
|
|
|
1157
1447
|
}
|
|
1158
1448
|
};
|
|
1159
1449
|
}
|
|
1160
|
-
function swapProgramBinding(offer, operatorPubkey, contractVersion
|
|
1450
|
+
function swapProgramBinding(offer, operatorPubkey, contractVersion) {
|
|
1161
1451
|
if (offer.makerPkScript.length !== FIELDS.makerPkScript.width) {
|
|
1162
1452
|
throw new Error("makerPkScript is not a 34-byte taproot scriptPubKey");
|
|
1163
1453
|
}
|
|
1454
|
+
const directed = offer.taker !== void 0;
|
|
1455
|
+
const version = contractVersion ?? (directed ? ASSET_SWAP_V4 : ASSET_SWAP_BASELINE);
|
|
1164
1456
|
const expected = offer.swapPkScript;
|
|
1165
|
-
if (!expected?.length) return bindSwapProgram(offer, operatorPubkey,
|
|
1457
|
+
if (!expected?.length) return bindSwapProgram(offer, operatorPubkey, version);
|
|
1166
1458
|
const funded = import_base5.hex.encode(expected);
|
|
1167
|
-
const order = [
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
];
|
|
1171
|
-
for (const version of order) {
|
|
1172
|
-
const binding = bindSwapProgram(offer, operatorPubkey, version);
|
|
1459
|
+
const order = directed ? [ASSET_SWAP_V4] : [ASSET_SWAP_BASELINE, ASSET_SWAP_V3];
|
|
1460
|
+
for (const candidate of order) {
|
|
1461
|
+
const binding = bindSwapProgram(offer, operatorPubkey, candidate);
|
|
1173
1462
|
if (pkOf(binding) === funded) return binding;
|
|
1174
1463
|
}
|
|
1175
|
-
return bindSwapProgram(offer, operatorPubkey,
|
|
1464
|
+
return bindSwapProgram(offer, operatorPubkey, directed ? ASSET_SWAP_V4 : version);
|
|
1176
1465
|
}
|
|
1177
1466
|
function bindSwapProgram(offer, operatorPubkey, contractVersion) {
|
|
1178
1467
|
const { programs, args } = ASSET_SWAP_CONTRACTS[contractVersion];
|
|
1179
1468
|
const user = offer.makerPublicKey;
|
|
1180
1469
|
const assetId = offer.wantAsset;
|
|
1181
1470
|
return {
|
|
1471
|
+
version: contractVersion,
|
|
1182
1472
|
program: withExitClosure(assetId ? programs.wantAsset : programs.wantBtc, offer.exitDelay),
|
|
1183
1473
|
args: args({
|
|
1184
1474
|
receiver: offer.makerPkScript.subarray(2),
|
|
@@ -1189,7 +1479,8 @@ function bindSwapProgram(offer, operatorPubkey, contractVersion) {
|
|
|
1189
1479
|
},
|
|
1190
1480
|
user,
|
|
1191
1481
|
server: operatorPubkey,
|
|
1192
|
-
...offer.exitDelay && { exitDelay: offer.exitDelay.value }
|
|
1482
|
+
...offer.exitDelay && { exitDelay: offer.exitDelay.value },
|
|
1483
|
+
...offer.taker && { taker: offer.taker }
|
|
1193
1484
|
}),
|
|
1194
1485
|
keys: {
|
|
1195
1486
|
serverKey: operatorPubkey,
|
|
@@ -1212,6 +1503,33 @@ function pkOf(binding) {
|
|
|
1212
1503
|
function offerContract(offer, operatorPubkey, contractVersion) {
|
|
1213
1504
|
return compileSwapBinding(swapProgramBinding(offer, operatorPubkey, contractVersion));
|
|
1214
1505
|
}
|
|
1506
|
+
function bindingProgram(binding) {
|
|
1507
|
+
if (Boolean(binding.wantAsset) === Boolean(binding.offerAsset)) {
|
|
1508
|
+
throw new Error("an offer binding names exactly one of wantAsset or offerAsset");
|
|
1509
|
+
}
|
|
1510
|
+
return swapProgramBinding(termsOf(binding), binding.serverPublicKey, binding.version);
|
|
1511
|
+
}
|
|
1512
|
+
function bindingFromOffer(offer, operatorPubkey) {
|
|
1513
|
+
const program = swapProgramBinding(offer, operatorPubkey);
|
|
1514
|
+
if (pkOf(program) !== import_base5.hex.encode(offer.swapPkScript)) {
|
|
1515
|
+
throw new OfferCovenantMismatchError(import_base5.hex.encode(offer.swapPkScript));
|
|
1516
|
+
}
|
|
1517
|
+
return {
|
|
1518
|
+
version: program.version,
|
|
1519
|
+
receiverPkScript: offer.makerPkScript,
|
|
1520
|
+
amount: offer.wantAmount,
|
|
1521
|
+
...offer.wantAsset && { wantAsset: offer.wantAsset },
|
|
1522
|
+
...offer.offerAsset && { offerAsset: offer.offerAsset },
|
|
1523
|
+
userPublicKey: offer.makerPublicKey,
|
|
1524
|
+
serverPublicKey: operatorPubkey,
|
|
1525
|
+
emulatorPublicKey: offer.emulatorPubkey,
|
|
1526
|
+
...offer.exitDelay && { exitDelay: offer.exitDelay },
|
|
1527
|
+
...offer.taker && { taker: offer.taker }
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1530
|
+
function offerFromBinding(binding) {
|
|
1531
|
+
return offerOf(binding, compileSwapBinding(bindingProgram(binding)).pkScript);
|
|
1532
|
+
}
|
|
1215
1533
|
function u64(name, value) {
|
|
1216
1534
|
if (value < BigInt(0) || value >> BigInt(64) > BigInt(0)) {
|
|
1217
1535
|
throw new Error(`${name} does not fit the offer wire format (u64)`);
|
|
@@ -1238,6 +1556,9 @@ function encodeOffer(offer) {
|
|
|
1238
1556
|
throw new Error(`${name} must be ${FIELDS[name].width} bytes`);
|
|
1239
1557
|
}
|
|
1240
1558
|
}
|
|
1559
|
+
if (offer.taker !== void 0 && offer.taker.length !== FIELDS.taker.width) {
|
|
1560
|
+
throw new Error(`taker must be ${FIELDS.taker.width} bytes`);
|
|
1561
|
+
}
|
|
1241
1562
|
const ratioNum = setRatio("ratioNum", offer.ratioNum);
|
|
1242
1563
|
const ratioDen = setRatio("ratioDen", offer.ratioDen);
|
|
1243
1564
|
if (ratioNum === void 0 !== (ratioDen === void 0)) {
|
|
@@ -1253,9 +1574,10 @@ function encodeOffer(offer) {
|
|
|
1253
1574
|
if (offer.offerAsset) recs.push(tlv2(FIELDS.offerAsset.tag, offer.offerAsset.serialize()));
|
|
1254
1575
|
recs.push(
|
|
1255
1576
|
tlv2(FIELDS.makerPkScript.tag, offer.makerPkScript),
|
|
1256
|
-
tlv2(FIELDS.makerPublicKey.tag, offer.makerPublicKey)
|
|
1257
|
-
tlv2(FIELDS.emulatorPubkey.tag, offer.emulatorPubkey)
|
|
1577
|
+
tlv2(FIELDS.makerPublicKey.tag, offer.makerPublicKey)
|
|
1258
1578
|
);
|
|
1579
|
+
if (offer.taker) recs.push(tlv2(FIELDS.taker.tag, offer.taker));
|
|
1580
|
+
recs.push(tlv2(FIELDS.emulatorPubkey.tag, offer.emulatorPubkey));
|
|
1259
1581
|
if (offer.exitDelay) recs.push(tlv2(FIELDS.exitTimelock.tag, encodeExitDelay(offer.exitDelay)));
|
|
1260
1582
|
return (0, import_utils2.concatBytes)(...recs);
|
|
1261
1583
|
}
|
|
@@ -1333,7 +1655,8 @@ function decodeOffer(data) {
|
|
|
1333
1655
|
emulatorPubkey: need("emulatorPubkey"),
|
|
1334
1656
|
...ratioNum !== void 0 && { ratioNum },
|
|
1335
1657
|
...ratioDen !== void 0 && { ratioDen },
|
|
1336
|
-
...fields.exitTimelock && { exitDelay: decodeExitDelay(fields.exitTimelock) }
|
|
1658
|
+
...fields.exitTimelock && { exitDelay: decodeExitDelay(fields.exitTimelock) },
|
|
1659
|
+
...fields.taker && { taker: fields.taker }
|
|
1337
1660
|
};
|
|
1338
1661
|
}
|
|
1339
1662
|
function decodeExitDelay(value) {
|
|
@@ -1353,10 +1676,7 @@ async function registerOfferContract(wallet, info, binding, operatorPubkey, expe
|
|
|
1353
1676
|
});
|
|
1354
1677
|
}
|
|
1355
1678
|
function offerContractParams(client, binding, operatorPubkey, expectedPkScript) {
|
|
1356
|
-
const { program, args, keys } = swapProgramBinding(
|
|
1357
|
-
{ ...binding, swapPkScript: expectedPkScript },
|
|
1358
|
-
operatorPubkey
|
|
1359
|
-
);
|
|
1679
|
+
const { program, args, keys } = "version" in binding ? bindingProgram(binding) : swapProgramBinding({ ...binding, swapPkScript: expectedPkScript }, operatorPubkey);
|
|
1360
1680
|
const contract = new import_sdk6.arkade.ArkadeContract(client, program, args, keys);
|
|
1361
1681
|
if (import_base5.hex.encode(contract.pkScript) !== import_base5.hex.encode(expectedPkScript)) {
|
|
1362
1682
|
throw new Error("derived covenant does not match the offer's swapPkScript");
|
|
@@ -1445,7 +1765,8 @@ async function deriveOffer(wallet, params) {
|
|
|
1445
1765
|
makerPublicKey: maker.publicKey,
|
|
1446
1766
|
emulatorPubkey: emuKey,
|
|
1447
1767
|
// checked before registration below. @see assertExitDelay
|
|
1448
|
-
exitDelay: params.noExit ? void 0 : params.exitDelay ? assertExitDelay(params.exitDelay) : serverExitDelay(info.unilateralExitDelay)
|
|
1768
|
+
exitDelay: params.noExit ? void 0 : params.exitDelay ? assertExitDelay(params.exitDelay) : serverExitDelay(info.unilateralExitDelay),
|
|
1769
|
+
...params.taker && { taker: params.taker }
|
|
1449
1770
|
});
|
|
1450
1771
|
const script = offerContract(binding, operatorPubKey, params.contractVersion);
|
|
1451
1772
|
const offer = { ...binding, swapPkScript: script.pkScript };
|
|
@@ -1458,6 +1779,7 @@ async function deriveOffer(wallet, params) {
|
|
|
1458
1779
|
address: script.address(network.hrp, operatorPubKey).encode(),
|
|
1459
1780
|
swapPkScript: script.pkScript,
|
|
1460
1781
|
binding,
|
|
1782
|
+
offerBinding: Object.freeze(bindingFromOffer(offer, operatorPubKey)),
|
|
1461
1783
|
info,
|
|
1462
1784
|
operatorPubkey: operatorPubKey
|
|
1463
1785
|
});
|
|
@@ -1502,7 +1824,7 @@ async function cancelOffer(wallet, offerHex, opts) {
|
|
|
1502
1824
|
}
|
|
1503
1825
|
async function prepareOfferCancel(wallet, offerHex, opts) {
|
|
1504
1826
|
const { fundingTxid, fundingOutpoint, swapAddress } = opts;
|
|
1505
|
-
const
|
|
1827
|
+
const decoded = typeof offerHex === "string" ? decodeOffer(import_base5.hex.decode(offerHex)) : isOfferBinding(offerHex) ? void 0 : offerHex;
|
|
1506
1828
|
const [contractManager, info, reader, broadcaster] = await Promise.all([
|
|
1507
1829
|
wallet.getContractManager(),
|
|
1508
1830
|
wallet.getArkadeInfo({ requireLive: true }),
|
|
@@ -1519,18 +1841,20 @@ async function prepareOfferCancel(wallet, offerHex, opts) {
|
|
|
1519
1841
|
// no `network`: the row lookup is by script and the payout comes from wallet.getAddress()
|
|
1520
1842
|
oneShotSubmit: wallet.oneShotSubmit
|
|
1521
1843
|
});
|
|
1522
|
-
const
|
|
1844
|
+
const pinned = swapAddress ? import_sdk6.ArkAddress.decode(swapAddress) : void 0;
|
|
1845
|
+
const funded = decoded ? decoded.swapPkScript : pinned?.pkScript;
|
|
1523
1846
|
let binding;
|
|
1524
1847
|
let rebuilt;
|
|
1525
1848
|
try {
|
|
1526
|
-
binding = swapProgramBinding(
|
|
1849
|
+
binding = decoded ? swapProgramBinding(decoded, pinned?.serverPubKey ?? client.serverKey) : bindingProgram(offerHex);
|
|
1527
1850
|
rebuilt = compileSwapBinding(binding);
|
|
1528
1851
|
} catch (cause) {
|
|
1529
|
-
throw new OfferCovenantMismatchError(import_base5.hex.encode(
|
|
1852
|
+
throw new OfferCovenantMismatchError(import_base5.hex.encode(funded ?? new Uint8Array()), { cause });
|
|
1530
1853
|
}
|
|
1531
|
-
if (import_base5.hex.encode(rebuilt.pkScript) !== import_base5.hex.encode(
|
|
1532
|
-
throw new OfferCovenantMismatchError(import_base5.hex.encode(
|
|
1854
|
+
if (funded && import_base5.hex.encode(rebuilt.pkScript) !== import_base5.hex.encode(funded)) {
|
|
1855
|
+
throw new OfferCovenantMismatchError(import_base5.hex.encode(funded));
|
|
1533
1856
|
}
|
|
1857
|
+
const offer = decoded ?? offerOf(offerHex, rebuilt.pkScript);
|
|
1534
1858
|
const contract = new import_sdk6.arkade.ArkadeContract(client, binding.program, binding.args, binding.keys);
|
|
1535
1859
|
const [vtxos, makerAddress] = await Promise.all([contract.getUtxos(), wallet.getAddress()]);
|
|
1536
1860
|
const vtxo = resolveDeposit(vtxos, { fundingTxid, fundingOutpoint });
|
|
@@ -1560,8 +1884,8 @@ async function fillOffer(wallet, arkServerUrl, offerHex, opts) {
|
|
|
1560
1884
|
emulator,
|
|
1561
1885
|
emulatorPubkey
|
|
1562
1886
|
} = opts;
|
|
1563
|
-
const
|
|
1564
|
-
const contract = await connectFillContract(wallet, arkServerUrl,
|
|
1887
|
+
const target = typeof offerHex === "string" ? decodeOffer(import_base5.hex.decode(offerHex)) : offerHex;
|
|
1888
|
+
const contract = await connectFillContract(wallet, arkServerUrl, target, {
|
|
1565
1889
|
swapAddress,
|
|
1566
1890
|
emulator,
|
|
1567
1891
|
emulatorPubkey
|
|
@@ -1570,7 +1894,7 @@ async function fillOffer(wallet, arkServerUrl, offerHex, opts) {
|
|
|
1570
1894
|
const vtxo = resolveDeposit(vtxos, { fundingTxid, fundingOutpoint });
|
|
1571
1895
|
const fill = contract.functions.fulfill();
|
|
1572
1896
|
assembleOfferFill(fill, {
|
|
1573
|
-
offer,
|
|
1897
|
+
offer: offerOf(target, contract.pkScript),
|
|
1574
1898
|
vtxo,
|
|
1575
1899
|
solverFund: fund,
|
|
1576
1900
|
solverPayout: payoutScript ?? import_sdk6.ArkAddress.decode(takerAddress).pkScript,
|
|
@@ -1592,10 +1916,11 @@ async function connectFillContract(wallet, arkServerUrl, offer, opts = {}) {
|
|
|
1592
1916
|
} : {},
|
|
1593
1917
|
...emulatorPubkey ? { emulatorPubkey } : {}
|
|
1594
1918
|
});
|
|
1595
|
-
const
|
|
1596
|
-
const binding = swapProgramBinding(offer, serverKey);
|
|
1919
|
+
const pinned = swapAddress ? import_sdk6.ArkAddress.decode(swapAddress) : void 0;
|
|
1920
|
+
const binding = isOfferBinding(offer) ? bindingProgram(offer) : swapProgramBinding(offer, pinned?.serverPubKey ?? client.serverKey);
|
|
1921
|
+
const funded = isOfferBinding(offer) ? pinned?.pkScript : offer.swapPkScript;
|
|
1597
1922
|
const rebuilt = compileSwapBinding(binding);
|
|
1598
|
-
if (import_base5.hex.encode(rebuilt.pkScript) !== import_base5.hex.encode(
|
|
1923
|
+
if (funded && import_base5.hex.encode(rebuilt.pkScript) !== import_base5.hex.encode(funded)) {
|
|
1599
1924
|
throw new Error(
|
|
1600
1925
|
"rebuilt covenant does not match the offer's swapPkScript \u2014 the server signing key has likely rotated since funding; pass swapAddress (the funded address) to pin the original key"
|
|
1601
1926
|
);
|
|
@@ -1911,7 +2236,7 @@ function assertFillCoin(coin, what) {
|
|
|
1911
2236
|
toAmount(coin.value, `${what}.value`, "sats", BigInt(1));
|
|
1912
2237
|
assertAssetEntries(coin.assets, what);
|
|
1913
2238
|
}
|
|
1914
|
-
var import_base5, import_utils2, import_sdk6, compiledBindings, OFFER_PACKET_TYPE, FIELDS, EXIT_TYPES, NAMES, readU64, setRatio, OFFER_CONTRACT_LABEL, OFFER_CONTRACT_KIND, derivingClient, NoSpendableDepositError, OfferCovenantMismatchError, ASSET_CARRIER_SATS, amountOfAsset, U64_MAX, MAX_SAFE_SATS, offerVtxoScript;
|
|
2239
|
+
var import_base5, import_utils2, import_sdk6, compiledBindings, isOfferBinding, termsOf, offerOf, recordOfferBinding, decimal, offerBindingOf, storedOffer, OFFER_PACKET_TYPE, FIELDS, EXIT_TYPES, NAMES, readU64, setRatio, OFFER_CONTRACT_LABEL, OFFER_CONTRACT_KIND, derivingClient, NoSpendableDepositError, OfferCovenantMismatchError, ASSET_CARRIER_SATS, amountOfAsset, U64_MAX, MAX_SAFE_SATS, offerVtxoScript;
|
|
1915
2240
|
var init_offer = __esm({
|
|
1916
2241
|
"src/offer.ts"() {
|
|
1917
2242
|
"use strict";
|
|
@@ -1923,11 +2248,67 @@ var init_offer = __esm({
|
|
|
1923
2248
|
init_rfqProfileParts();
|
|
1924
2249
|
init_store();
|
|
1925
2250
|
compiledBindings = /* @__PURE__ */ new WeakMap();
|
|
2251
|
+
isOfferBinding = (offer) => "version" in offer;
|
|
2252
|
+
termsOf = (binding) => ({
|
|
2253
|
+
wantAmount: binding.amount,
|
|
2254
|
+
...binding.wantAsset && { wantAsset: binding.wantAsset },
|
|
2255
|
+
...binding.offerAsset && { offerAsset: binding.offerAsset },
|
|
2256
|
+
makerPkScript: binding.receiverPkScript,
|
|
2257
|
+
makerPublicKey: binding.userPublicKey,
|
|
2258
|
+
emulatorPubkey: binding.emulatorPublicKey,
|
|
2259
|
+
...binding.exitDelay && { exitDelay: binding.exitDelay },
|
|
2260
|
+
...binding.taker && { taker: binding.taker }
|
|
2261
|
+
});
|
|
2262
|
+
offerOf = (offer, swapPkScript) => isOfferBinding(offer) ? { ...termsOf(offer), swapPkScript } : offer;
|
|
2263
|
+
recordOfferBinding = (binding) => ({
|
|
2264
|
+
version: binding.version,
|
|
2265
|
+
receiverPkScript: import_base5.hex.encode(binding.receiverPkScript),
|
|
2266
|
+
amount: binding.amount.toString(),
|
|
2267
|
+
...binding.wantAsset && { wantAsset: binding.wantAsset.toString() },
|
|
2268
|
+
...binding.offerAsset && { offerAsset: binding.offerAsset.toString() },
|
|
2269
|
+
userPublicKey: import_base5.hex.encode(binding.userPublicKey),
|
|
2270
|
+
serverPublicKey: import_base5.hex.encode(binding.serverPublicKey),
|
|
2271
|
+
emulatorPublicKey: import_base5.hex.encode(binding.emulatorPublicKey),
|
|
2272
|
+
...binding.exitDelay && {
|
|
2273
|
+
exitDelay: { type: binding.exitDelay.type, value: binding.exitDelay.value.toString() }
|
|
2274
|
+
},
|
|
2275
|
+
...binding.taker && { taker: import_base5.hex.encode(binding.taker) }
|
|
2276
|
+
});
|
|
2277
|
+
decimal = (value, name) => {
|
|
2278
|
+
if (!/^\d+$/.test(value)) throw new Error(`recorded binding ${name} is not a decimal amount`);
|
|
2279
|
+
return BigInt(value);
|
|
2280
|
+
};
|
|
2281
|
+
offerBindingOf = (recorded) => {
|
|
2282
|
+
if (typeof recorded.version !== "string" || !Object.hasOwn(ASSET_SWAP_CONTRACTS, recorded.version)) {
|
|
2283
|
+
throw new Error(`recorded binding names no known contract version (${recorded.version})`);
|
|
2284
|
+
}
|
|
2285
|
+
const { exitDelay, wantAsset, offerAsset, taker } = recorded;
|
|
2286
|
+
return {
|
|
2287
|
+
version: recorded.version,
|
|
2288
|
+
receiverPkScript: import_base5.hex.decode(recorded.receiverPkScript),
|
|
2289
|
+
amount: decimal(recorded.amount, "amount"),
|
|
2290
|
+
...wantAsset !== void 0 && { wantAsset: import_sdk6.asset.AssetId.fromString(wantAsset) },
|
|
2291
|
+
...offerAsset !== void 0 && { offerAsset: import_sdk6.asset.AssetId.fromString(offerAsset) },
|
|
2292
|
+
userPublicKey: import_base5.hex.decode(recorded.userPublicKey),
|
|
2293
|
+
serverPublicKey: import_base5.hex.decode(recorded.serverPublicKey),
|
|
2294
|
+
emulatorPublicKey: import_base5.hex.decode(recorded.emulatorPublicKey),
|
|
2295
|
+
...exitDelay && {
|
|
2296
|
+
exitDelay: { type: exitDelay.type, value: decimal(exitDelay.value, "exitDelay") }
|
|
2297
|
+
},
|
|
2298
|
+
...taker !== void 0 && { taker: import_base5.hex.decode(taker) }
|
|
2299
|
+
};
|
|
2300
|
+
};
|
|
2301
|
+
storedOffer = (swap) => {
|
|
2302
|
+
if (swap.binding !== void 0) return offerBindingOf(swap.binding);
|
|
2303
|
+
if (typeof swap.offerHex === "string") return decodeOffer(import_base5.hex.decode(swap.offerHex));
|
|
2304
|
+
throw new Error("this offer swap carries neither a binding nor an offerHex to rebuild from");
|
|
2305
|
+
};
|
|
1926
2306
|
OFFER_PACKET_TYPE = 3;
|
|
1927
2307
|
FIELDS = {
|
|
1928
2308
|
swapPkScript: { tag: 1, width: 34 },
|
|
1929
2309
|
wantAmount: { tag: 2, width: 8 },
|
|
1930
2310
|
wantAsset: { tag: 3, width: void 0 },
|
|
2311
|
+
taker: { tag: 4, width: 32 },
|
|
1931
2312
|
makerPkScript: { tag: 5, width: 34 },
|
|
1932
2313
|
makerPublicKey: { tag: 7, width: 32 },
|
|
1933
2314
|
emulatorPubkey: { tag: 8, width: 32 },
|
|
@@ -1983,6 +2364,439 @@ var init_offer = __esm({
|
|
|
1983
2364
|
}
|
|
1984
2365
|
});
|
|
1985
2366
|
|
|
2367
|
+
// src/client/errors.ts
|
|
2368
|
+
var AmbiguousDestination, UnsupportedRoute, DiscoverySnapshotUnavailable, AmountMismatch, AmountEncodingUnsupported, QuoteVerificationFailed, QuoteExpired, MaxFeeExceeded, InsufficientFunds, AcceptConflict, ClientDisposed, NotCancellable, InconsistentRoute, OperatorUnreachable, MissingCorridorDep, SWAP_ERRORS, SWAP_ERROR_NAMES;
|
|
2369
|
+
var init_errors = __esm({
|
|
2370
|
+
"src/client/errors.ts"() {
|
|
2371
|
+
"use strict";
|
|
2372
|
+
init_rfq();
|
|
2373
|
+
AmbiguousDestination = class extends Error {
|
|
2374
|
+
constructor(destination, detail) {
|
|
2375
|
+
super(`cannot route ${JSON.stringify(destination)}: ${detail}`);
|
|
2376
|
+
this.destination = destination;
|
|
2377
|
+
}
|
|
2378
|
+
destination;
|
|
2379
|
+
name = "AmbiguousDestination";
|
|
2380
|
+
};
|
|
2381
|
+
UnsupportedRoute = class extends Error {
|
|
2382
|
+
name = "UnsupportedRoute";
|
|
2383
|
+
give;
|
|
2384
|
+
take;
|
|
2385
|
+
constructor(detail, corridors = {}) {
|
|
2386
|
+
super(`unsupported route: ${detail}`);
|
|
2387
|
+
this.give = corridors.give;
|
|
2388
|
+
this.take = corridors.take;
|
|
2389
|
+
}
|
|
2390
|
+
};
|
|
2391
|
+
DiscoverySnapshotUnavailable = class extends Error {
|
|
2392
|
+
constructor(network, detail) {
|
|
2393
|
+
super(`cannot resolve on ${network} offline: ${detail}`);
|
|
2394
|
+
this.network = network;
|
|
2395
|
+
}
|
|
2396
|
+
network;
|
|
2397
|
+
name = "DiscoverySnapshotUnavailable";
|
|
2398
|
+
};
|
|
2399
|
+
AmountMismatch = class extends Error {
|
|
2400
|
+
constructor(sources) {
|
|
2401
|
+
super(`exactly one amount may be pinned; got ${sources[0]} and ${sources[1]}`);
|
|
2402
|
+
this.sources = sources;
|
|
2403
|
+
}
|
|
2404
|
+
sources;
|
|
2405
|
+
name = "AmountMismatch";
|
|
2406
|
+
};
|
|
2407
|
+
AmountEncodingUnsupported = class extends Error {
|
|
2408
|
+
constructor(field, value, detail, options) {
|
|
2409
|
+
super(`${field}: ${detail}`, options);
|
|
2410
|
+
this.field = field;
|
|
2411
|
+
this.value = value;
|
|
2412
|
+
}
|
|
2413
|
+
field;
|
|
2414
|
+
value;
|
|
2415
|
+
name = "AmountEncodingUnsupported";
|
|
2416
|
+
};
|
|
2417
|
+
QuoteVerificationFailed = class extends Error {
|
|
2418
|
+
constructor(check, expected, actual, options) {
|
|
2419
|
+
super(`quote failed the ${check} check \u2014 refusing to fund`, options);
|
|
2420
|
+
this.check = check;
|
|
2421
|
+
this.expected = expected;
|
|
2422
|
+
this.actual = actual;
|
|
2423
|
+
}
|
|
2424
|
+
check;
|
|
2425
|
+
name = "QuoteVerificationFailed";
|
|
2426
|
+
expected;
|
|
2427
|
+
actual;
|
|
2428
|
+
};
|
|
2429
|
+
QuoteExpired = class extends Error {
|
|
2430
|
+
constructor(quoteId, expiresAt, now) {
|
|
2431
|
+
super(`quote ${quoteId} expired at ${expiresAt}, ${now - expiresAt} ago`);
|
|
2432
|
+
this.quoteId = quoteId;
|
|
2433
|
+
this.expiresAt = expiresAt;
|
|
2434
|
+
this.now = now;
|
|
2435
|
+
}
|
|
2436
|
+
quoteId;
|
|
2437
|
+
expiresAt;
|
|
2438
|
+
now;
|
|
2439
|
+
name = "QuoteExpired";
|
|
2440
|
+
};
|
|
2441
|
+
MaxFeeExceeded = class extends Error {
|
|
2442
|
+
constructor(quoteId, asset4, fee, maxFee) {
|
|
2443
|
+
super(`fee ${fee} of ${asset4} exceeds the ${maxFee} ceiling`);
|
|
2444
|
+
this.quoteId = quoteId;
|
|
2445
|
+
this.asset = asset4;
|
|
2446
|
+
this.fee = fee;
|
|
2447
|
+
this.maxFee = maxFee;
|
|
2448
|
+
}
|
|
2449
|
+
quoteId;
|
|
2450
|
+
asset;
|
|
2451
|
+
fee;
|
|
2452
|
+
maxFee;
|
|
2453
|
+
name = "MaxFeeExceeded";
|
|
2454
|
+
};
|
|
2455
|
+
InsufficientFunds = class extends Error {
|
|
2456
|
+
constructor(asset4, required, available) {
|
|
2457
|
+
super(
|
|
2458
|
+
`funding needs ${required} of ${asset4}` + (available === void 0 ? "" : `, wallet holds ${available}`)
|
|
2459
|
+
);
|
|
2460
|
+
this.asset = asset4;
|
|
2461
|
+
this.required = required;
|
|
2462
|
+
this.available = available;
|
|
2463
|
+
}
|
|
2464
|
+
asset;
|
|
2465
|
+
required;
|
|
2466
|
+
name = "InsufficientFunds";
|
|
2467
|
+
available;
|
|
2468
|
+
};
|
|
2469
|
+
AcceptConflict = class extends Error {
|
|
2470
|
+
constructor(quoteId, swapId, fields) {
|
|
2471
|
+
super(`accept ${quoteId} conflicts with swap ${swapId} on ${fields.join(", ")}`);
|
|
2472
|
+
this.quoteId = quoteId;
|
|
2473
|
+
this.swapId = swapId;
|
|
2474
|
+
this.fields = fields;
|
|
2475
|
+
}
|
|
2476
|
+
quoteId;
|
|
2477
|
+
swapId;
|
|
2478
|
+
fields;
|
|
2479
|
+
name = "AcceptConflict";
|
|
2480
|
+
};
|
|
2481
|
+
ClientDisposed = class extends Error {
|
|
2482
|
+
constructor(method) {
|
|
2483
|
+
super(`${method}() called after the client was disposed`);
|
|
2484
|
+
this.method = method;
|
|
2485
|
+
}
|
|
2486
|
+
method;
|
|
2487
|
+
name = "ClientDisposed";
|
|
2488
|
+
};
|
|
2489
|
+
NotCancellable = class extends Error {
|
|
2490
|
+
constructor(swapId) {
|
|
2491
|
+
super(`swap ${swapId} is not a cancellable asset swap`);
|
|
2492
|
+
this.swapId = swapId;
|
|
2493
|
+
}
|
|
2494
|
+
swapId;
|
|
2495
|
+
name = "NotCancellable";
|
|
2496
|
+
};
|
|
2497
|
+
InconsistentRoute = class extends Error {
|
|
2498
|
+
constructor(asset4, destination) {
|
|
2499
|
+
super(`destination ${JSON.stringify(destination)} is not on ${asset4}'s chain`);
|
|
2500
|
+
this.asset = asset4;
|
|
2501
|
+
this.destination = destination;
|
|
2502
|
+
}
|
|
2503
|
+
asset;
|
|
2504
|
+
destination;
|
|
2505
|
+
name = "InconsistentRoute";
|
|
2506
|
+
};
|
|
2507
|
+
OperatorUnreachable = class extends Error {
|
|
2508
|
+
name = "OperatorUnreachable";
|
|
2509
|
+
constructor(detail, options) {
|
|
2510
|
+
super(`cannot derive a covenant: ${detail}`, options);
|
|
2511
|
+
}
|
|
2512
|
+
};
|
|
2513
|
+
MissingCorridorDep = class extends Error {
|
|
2514
|
+
constructor(corridor, dep) {
|
|
2515
|
+
super(`the ${corridor} corridor has no ${dep}`);
|
|
2516
|
+
this.corridor = corridor;
|
|
2517
|
+
this.dep = dep;
|
|
2518
|
+
}
|
|
2519
|
+
corridor;
|
|
2520
|
+
dep;
|
|
2521
|
+
name = "MissingCorridorDep";
|
|
2522
|
+
};
|
|
2523
|
+
SWAP_ERRORS = {
|
|
2524
|
+
AmbiguousDestination,
|
|
2525
|
+
UnsupportedRoute,
|
|
2526
|
+
DiscoverySnapshotUnavailable,
|
|
2527
|
+
AmountMismatch,
|
|
2528
|
+
AmountEncodingUnsupported,
|
|
2529
|
+
QuoteVerificationFailed,
|
|
2530
|
+
SwapRefusal,
|
|
2531
|
+
QuoteExpired,
|
|
2532
|
+
MaxFeeExceeded,
|
|
2533
|
+
InsufficientFunds,
|
|
2534
|
+
AcceptConflict,
|
|
2535
|
+
ClientDisposed,
|
|
2536
|
+
NotCancellable,
|
|
2537
|
+
InconsistentRoute,
|
|
2538
|
+
OperatorUnreachable,
|
|
2539
|
+
MissingCorridorDep
|
|
2540
|
+
};
|
|
2541
|
+
SWAP_ERROR_NAMES = Object.keys(SWAP_ERRORS);
|
|
2542
|
+
}
|
|
2543
|
+
});
|
|
2544
|
+
|
|
2545
|
+
// src/client/policy.ts
|
|
2546
|
+
var DEFAULT_MAX_REFUND_WINDOW_SECONDS;
|
|
2547
|
+
var init_policy = __esm({
|
|
2548
|
+
"src/client/policy.ts"() {
|
|
2549
|
+
"use strict";
|
|
2550
|
+
DEFAULT_MAX_REFUND_WINDOW_SECONDS = 30 * 24 * 3600;
|
|
2551
|
+
}
|
|
2552
|
+
});
|
|
2553
|
+
|
|
2554
|
+
// src/client/verify.ts
|
|
2555
|
+
var verify_exports = {};
|
|
2556
|
+
__export(verify_exports, {
|
|
2557
|
+
verifiedCarrierSats: () => verifiedCarrierSats,
|
|
2558
|
+
verifyCrossAssetAmount: () => verifyCrossAssetAmount,
|
|
2559
|
+
verifyPair: () => verifyPair,
|
|
2560
|
+
verifyQuoteTtl: () => verifyQuoteTtl,
|
|
2561
|
+
verifyQuotedAmount: () => verifyQuotedAmount,
|
|
2562
|
+
verifyReceiveInvoiceFacts: () => verifyReceiveInvoiceFacts,
|
|
2563
|
+
verifyReceiveWindow: () => verifyReceiveWindow,
|
|
2564
|
+
verifyRefundWindow: () => verifyRefundWindow,
|
|
2565
|
+
verifyResponder: () => verifyResponder,
|
|
2566
|
+
verifySendInvoice: () => verifySendInvoice,
|
|
2567
|
+
verifySendWindow: () => verifySendWindow,
|
|
2568
|
+
verifyTaker: () => verifyTaker,
|
|
2569
|
+
verifyingDerivation: () => verifyingDerivation
|
|
2570
|
+
});
|
|
2571
|
+
var import_base6, reasonOf, CHECK_BY_REASON, gated, verifyResponder, verifyTaker, verifyPair, verifyingDerivation, verifySendWindow, verifyReceiveWindow, verifySendInvoice, verifyReceiveInvoiceFacts, verifyQuoteTtl, CSV_GRANULARITY_SECONDS, verifyRefundWindow, verifyQuotedAmount, verifyCrossAssetAmount, verifiedCarrierSats, verifyPinnedAmount;
|
|
2572
|
+
var init_verify = __esm({
|
|
2573
|
+
"src/client/verify.ts"() {
|
|
2574
|
+
"use strict";
|
|
2575
|
+
import_base6 = require("@scure/base");
|
|
2576
|
+
init_rfq();
|
|
2577
|
+
init_errors();
|
|
2578
|
+
init_policy();
|
|
2579
|
+
reasonOf = (error) => error instanceof Error && typeof error.reason === "string" ? error.reason : void 0;
|
|
2580
|
+
CHECK_BY_REASON = {
|
|
2581
|
+
invoice_expired: "invoice",
|
|
2582
|
+
invoice_undecodable: "invoice",
|
|
2583
|
+
invoice_hash_mismatch: "invoice",
|
|
2584
|
+
invoice_amount_mismatch: "invoice",
|
|
2585
|
+
insufficient_headroom: "refund_window",
|
|
2586
|
+
missing_refund_locktime: "refund_window",
|
|
2587
|
+
claim_window_too_short: "refund_window",
|
|
2588
|
+
confirmations_out_of_range: "refund_window",
|
|
2589
|
+
timelock_order: "refund_window",
|
|
2590
|
+
quote_malformed: "refund_window"
|
|
2591
|
+
};
|
|
2592
|
+
gated = (run, quote) => {
|
|
2593
|
+
try {
|
|
2594
|
+
run();
|
|
2595
|
+
} catch (error) {
|
|
2596
|
+
const reason = reasonOf(error);
|
|
2597
|
+
if (reason === "quote_expired") {
|
|
2598
|
+
throw new QuoteExpired(quote.id, quote.expiresAt, quote.now);
|
|
2599
|
+
}
|
|
2600
|
+
const check = reason === void 0 ? void 0 : CHECK_BY_REASON[reason];
|
|
2601
|
+
if (check === void 0) throw error;
|
|
2602
|
+
throw new QuoteVerificationFailed(
|
|
2603
|
+
check,
|
|
2604
|
+
void 0,
|
|
2605
|
+
error instanceof Error ? error.message : String(error),
|
|
2606
|
+
{ cause: error }
|
|
2607
|
+
);
|
|
2608
|
+
}
|
|
2609
|
+
};
|
|
2610
|
+
verifyResponder = (input) => {
|
|
2611
|
+
if (!input.pinnable || input.expected === void 0) {
|
|
2612
|
+
throw new QuoteVerificationFailed(
|
|
2613
|
+
"responder",
|
|
2614
|
+
"a registry-served card naming the solver's discovery key",
|
|
2615
|
+
input.expected === void 0 ? "the card names no discovery key" : "the card came out of the local cache, which does not authenticate it"
|
|
2616
|
+
);
|
|
2617
|
+
}
|
|
2618
|
+
if (input.attested === void 0) {
|
|
2619
|
+
throw new QuoteVerificationFailed(
|
|
2620
|
+
"responder",
|
|
2621
|
+
input.expected,
|
|
2622
|
+
"the transport attests nobody"
|
|
2623
|
+
);
|
|
2624
|
+
}
|
|
2625
|
+
if (input.attested !== input.expected) {
|
|
2626
|
+
throw new QuoteVerificationFailed("responder", input.expected, input.attested);
|
|
2627
|
+
}
|
|
2628
|
+
};
|
|
2629
|
+
verifyTaker = (input) => {
|
|
2630
|
+
const xOnly = (key) => typeof key === "string" && /^[0-9a-f]{64}$/i.test(key) ? import_base6.hex.decode(key.toLowerCase()) : void 0;
|
|
2631
|
+
const taker = xOnly(input.solverPubkey);
|
|
2632
|
+
const attested = xOnly(input.attested);
|
|
2633
|
+
if (taker === void 0 || attested === void 0 || import_base6.hex.encode(taker) !== import_base6.hex.encode(attested)) {
|
|
2634
|
+
throw new QuoteVerificationFailed("responder", input.attested, String(input.solverPubkey));
|
|
2635
|
+
}
|
|
2636
|
+
return taker;
|
|
2637
|
+
};
|
|
2638
|
+
verifyPair = (quoted, requested) => {
|
|
2639
|
+
if (quoted !== requested) {
|
|
2640
|
+
throw new QuoteVerificationFailed("pair", requested, String(quoted));
|
|
2641
|
+
}
|
|
2642
|
+
};
|
|
2643
|
+
verifyingDerivation = (derive) => {
|
|
2644
|
+
try {
|
|
2645
|
+
return derive();
|
|
2646
|
+
} catch (error) {
|
|
2647
|
+
if (error instanceof AddressMismatch) {
|
|
2648
|
+
const derived = Array.isArray(error.derived) ? error.derived.join(", ") : error.derived;
|
|
2649
|
+
throw new QuoteVerificationFailed("lockup_address", derived, error.quoted, {
|
|
2650
|
+
cause: error
|
|
2651
|
+
});
|
|
2652
|
+
}
|
|
2653
|
+
if (error instanceof Error) {
|
|
2654
|
+
throw new QuoteVerificationFailed("lockup_address", void 0, error.message, {
|
|
2655
|
+
cause: error
|
|
2656
|
+
});
|
|
2657
|
+
}
|
|
2658
|
+
throw error;
|
|
2659
|
+
}
|
|
2660
|
+
};
|
|
2661
|
+
verifySendWindow = (input) => {
|
|
2662
|
+
gated(
|
|
2663
|
+
() => assertFundable({
|
|
2664
|
+
quote: input.quote,
|
|
2665
|
+
now: input.now,
|
|
2666
|
+
...input.invoiceExpiresAt === void 0 ? {} : { invoiceExpiresAt: input.invoiceExpiresAt },
|
|
2667
|
+
...input.onchain === void 0 ? {} : { onchain: input.onchain }
|
|
2668
|
+
}),
|
|
2669
|
+
{ id: input.quoteId, expiresAt: input.quote.valid_until, now: input.now }
|
|
2670
|
+
);
|
|
2671
|
+
};
|
|
2672
|
+
verifyReceiveWindow = (input) => {
|
|
2673
|
+
gated(
|
|
2674
|
+
() => assertReceivable({
|
|
2675
|
+
quote: input.quote,
|
|
2676
|
+
payDeadline: input.payDeadline,
|
|
2677
|
+
now: input.now
|
|
2678
|
+
}),
|
|
2679
|
+
{ id: input.quoteId, expiresAt: input.payDeadline, now: input.now }
|
|
2680
|
+
);
|
|
2681
|
+
};
|
|
2682
|
+
verifySendInvoice = (input) => {
|
|
2683
|
+
const invoiced = input.invoiced;
|
|
2684
|
+
if (input.take !== invoiced) {
|
|
2685
|
+
throw new QuoteVerificationFailed("invoice", `${invoiced}`, `${input.take}`);
|
|
2686
|
+
}
|
|
2687
|
+
if (input.give < input.take) {
|
|
2688
|
+
throw new QuoteVerificationFailed(
|
|
2689
|
+
"invoice",
|
|
2690
|
+
`at least the invoice's ${invoiced}`,
|
|
2691
|
+
`${input.give}, a negative spread`
|
|
2692
|
+
);
|
|
2693
|
+
}
|
|
2694
|
+
};
|
|
2695
|
+
verifyReceiveInvoiceFacts = (input) => {
|
|
2696
|
+
let decoded;
|
|
2697
|
+
try {
|
|
2698
|
+
decoded = input.decode(input.invoice);
|
|
2699
|
+
} catch (cause) {
|
|
2700
|
+
throw new QuoteVerificationFailed(
|
|
2701
|
+
"invoice",
|
|
2702
|
+
"a decodable BOLT11",
|
|
2703
|
+
cause instanceof Error ? cause.message : String(cause),
|
|
2704
|
+
{ cause }
|
|
2705
|
+
);
|
|
2706
|
+
}
|
|
2707
|
+
if (!Number.isFinite(decoded.expiresAt)) {
|
|
2708
|
+
throw new QuoteVerificationFailed("invoice", "a finite expiry", `${decoded.expiresAt}`);
|
|
2709
|
+
}
|
|
2710
|
+
if (!Number.isFinite(input.validUntil)) {
|
|
2711
|
+
throw new QuoteVerificationFailed(
|
|
2712
|
+
"refund_window",
|
|
2713
|
+
"a finite valid_until",
|
|
2714
|
+
`${input.validUntil}`
|
|
2715
|
+
);
|
|
2716
|
+
}
|
|
2717
|
+
if (decoded.paymentHash !== input.paymentHash) {
|
|
2718
|
+
throw new QuoteVerificationFailed("invoice", input.paymentHash, decoded.paymentHash);
|
|
2719
|
+
}
|
|
2720
|
+
if (!Number.isSafeInteger(decoded.amountSats) || decoded.amountSats <= 0) {
|
|
2721
|
+
throw new QuoteVerificationFailed(
|
|
2722
|
+
"invoice",
|
|
2723
|
+
`${input.payAmount}`,
|
|
2724
|
+
"the invoice names no amount"
|
|
2725
|
+
);
|
|
2726
|
+
}
|
|
2727
|
+
if (BigInt(decoded.amountSats) !== input.payAmount) {
|
|
2728
|
+
throw new QuoteVerificationFailed("invoice", `${input.payAmount}`, `${decoded.amountSats}`);
|
|
2729
|
+
}
|
|
2730
|
+
return { payDeadline: Math.min(decoded.expiresAt, input.validUntil) };
|
|
2731
|
+
};
|
|
2732
|
+
verifyQuoteTtl = (input) => {
|
|
2733
|
+
const floor = input.floorSeconds ?? 0;
|
|
2734
|
+
if (input.expiresAt - input.now <= floor) {
|
|
2735
|
+
throw new QuoteExpired(input.quoteId, input.expiresAt, input.now);
|
|
2736
|
+
}
|
|
2737
|
+
};
|
|
2738
|
+
CSV_GRANULARITY_SECONDS = 512;
|
|
2739
|
+
verifyRefundWindow = (input) => {
|
|
2740
|
+
const max = input.maxSeconds ?? DEFAULT_MAX_REFUND_WINDOW_SECONDS;
|
|
2741
|
+
const window = input.refundLocktime - input.now;
|
|
2742
|
+
if (!(window <= max)) {
|
|
2743
|
+
throw new QuoteVerificationFailed("refund_window", `at most ${max}s`, `${window}s`);
|
|
2744
|
+
}
|
|
2745
|
+
const delay = input.refundWithoutReceiverDelay;
|
|
2746
|
+
if (delay !== void 0 && !(delay < max + CSV_GRANULARITY_SECONDS)) {
|
|
2747
|
+
throw new QuoteVerificationFailed(
|
|
2748
|
+
"refund_window",
|
|
2749
|
+
`a solo-refund delay of at most ${max}s`,
|
|
2750
|
+
`${delay}s`
|
|
2751
|
+
);
|
|
2752
|
+
}
|
|
2753
|
+
};
|
|
2754
|
+
verifyQuotedAmount = (input) => {
|
|
2755
|
+
verifyPinnedAmount(input);
|
|
2756
|
+
if (input.take > input.give) {
|
|
2757
|
+
throw new QuoteVerificationFailed(
|
|
2758
|
+
"pair",
|
|
2759
|
+
`${input.pair} give >= take`,
|
|
2760
|
+
`give=${input.give} take=${input.take}`
|
|
2761
|
+
);
|
|
2762
|
+
}
|
|
2763
|
+
};
|
|
2764
|
+
verifyCrossAssetAmount = (input) => {
|
|
2765
|
+
verifyPinnedAmount(input);
|
|
2766
|
+
if (input.give <= 0n || input.take <= 0n) {
|
|
2767
|
+
throw new QuoteVerificationFailed(
|
|
2768
|
+
"pair",
|
|
2769
|
+
`${input.pair} give > 0 take > 0`,
|
|
2770
|
+
`give=${input.give} take=${input.take}`
|
|
2771
|
+
);
|
|
2772
|
+
}
|
|
2773
|
+
};
|
|
2774
|
+
verifiedCarrierSats = (quote) => {
|
|
2775
|
+
try {
|
|
2776
|
+
return quoteCarrierSats(quote);
|
|
2777
|
+
} catch (error) {
|
|
2778
|
+
if (reasonOf(error) !== "carrier_malformed") throw error;
|
|
2779
|
+
throw new QuoteVerificationFailed(
|
|
2780
|
+
"pair",
|
|
2781
|
+
"carrier_sats a non-negative integer",
|
|
2782
|
+
String(quote.carrier_sats),
|
|
2783
|
+
{ cause: error }
|
|
2784
|
+
);
|
|
2785
|
+
}
|
|
2786
|
+
};
|
|
2787
|
+
verifyPinnedAmount = (input) => {
|
|
2788
|
+
const quoted = input.pinned.on === "give" ? input.give : input.take;
|
|
2789
|
+
if (quoted !== input.pinned.value) {
|
|
2790
|
+
throw new QuoteVerificationFailed(
|
|
2791
|
+
"pair",
|
|
2792
|
+
`${input.pair} ${input.pinned.on}=${input.pinned.value}`,
|
|
2793
|
+
`${input.pair} ${input.pinned.on}=${quoted}`
|
|
2794
|
+
);
|
|
2795
|
+
}
|
|
2796
|
+
};
|
|
2797
|
+
}
|
|
2798
|
+
});
|
|
2799
|
+
|
|
1986
2800
|
// src/rfq.ts
|
|
1987
2801
|
function lightningSendContract(params) {
|
|
1988
2802
|
return suiteVhtlc(params, {
|
|
@@ -2014,7 +2828,7 @@ function deriveLightningSend(input) {
|
|
|
2014
2828
|
throw new Error("lightning-send quote is missing profile.receiver_pk_script");
|
|
2015
2829
|
}
|
|
2016
2830
|
const contractParams = {
|
|
2017
|
-
solverPubkey: (0, import_sdk7.toXOnly)(
|
|
2831
|
+
solverPubkey: (0, import_sdk7.toXOnly)(import_base7.hex.decode(quote.solver_pubkey), "solver key"),
|
|
2018
2832
|
refundLocktime: quote.refund_locktime,
|
|
2019
2833
|
operatorPubkey: input.operatorPubkey,
|
|
2020
2834
|
paymentHash: input.paymentHash,
|
|
@@ -2065,7 +2879,7 @@ async function requestLightningSend(wallet, transport, params) {
|
|
|
2065
2879
|
`quote from_amount ${quote.from_amount} is below the invoice amount \u2014 a negative spread is not a quote`
|
|
2066
2880
|
);
|
|
2067
2881
|
}
|
|
2068
|
-
const operatorPubkey = (0, import_sdk7.toXOnly)(
|
|
2882
|
+
const operatorPubkey = (0, import_sdk7.toXOnly)(import_base7.hex.decode(info.signerPubkey), "ark signer key");
|
|
2069
2883
|
const network = (0, import_sdk7.networkFromOperatorInfo)(info);
|
|
2070
2884
|
const derived = deriveLightningSend({
|
|
2071
2885
|
quote,
|
|
@@ -2074,7 +2888,7 @@ async function requestLightningSend(wallet, transport, params) {
|
|
|
2074
2888
|
refundPkScript: secrets.pkScript,
|
|
2075
2889
|
operatorPubkey,
|
|
2076
2890
|
emulatorPubkey: (0, import_sdk7.toXOnly)(
|
|
2077
|
-
|
|
2891
|
+
import_base7.hex.decode((0, import_sdk7.resolveEmulatorPubkey)(network, params.emulatorPubkey)),
|
|
2078
2892
|
"emulator signer key"
|
|
2079
2893
|
),
|
|
2080
2894
|
claimDelay,
|
|
@@ -2119,13 +2933,12 @@ async function requestArkadeSwap(wallet, transport, params) {
|
|
|
2119
2933
|
receiveAddress,
|
|
2120
2934
|
ownPkScript,
|
|
2121
2935
|
(0, import_sdk7.networkFromOperatorInfo)(info).hrp,
|
|
2122
|
-
(0, import_sdk7.toXOnly)(
|
|
2936
|
+
(0, import_sdk7.toXOnly)(import_base7.hex.decode(info.signerPubkey), "ark signer key")
|
|
2123
2937
|
);
|
|
2124
2938
|
const pair = rfqPair(
|
|
2125
2939
|
params.offerAsset ? arkadeAssetLeg(params.offerAsset) : ARKADE_BTC,
|
|
2126
2940
|
params.wantAsset ? arkadeAssetLeg(params.wantAsset) : ARKADE_BTC
|
|
2127
2941
|
);
|
|
2128
|
-
const contractVersions = [...params.contractVersions ?? ASSET_SWAP_CONTRACT_VERSIONS];
|
|
2129
2942
|
const { quote, rfqId, contractVersion } = await requestVersionedQuote(
|
|
2130
2943
|
transport,
|
|
2131
2944
|
arkadeSwapRequest({
|
|
@@ -2136,13 +2949,17 @@ async function requestArkadeSwap(wallet, transport, params) {
|
|
|
2136
2949
|
amountSide,
|
|
2137
2950
|
makerPkScript,
|
|
2138
2951
|
makerPublicKey,
|
|
2139
|
-
contractVersions
|
|
2952
|
+
contractVersions: ASSET_SWAP_CONTRACT_VERSIONS
|
|
2140
2953
|
}),
|
|
2141
|
-
|
|
2954
|
+
ASSET_SWAP_CONTRACT_VERSIONS
|
|
2142
2955
|
);
|
|
2143
2956
|
if (quote.pair !== pair) {
|
|
2144
2957
|
throw new Error(`solver quoted ${JSON.stringify(quote.pair)}, not the requested ${pair}`);
|
|
2145
2958
|
}
|
|
2959
|
+
const taker = contractVersion === ASSET_SWAP_V4 ? (await Promise.resolve().then(() => (init_verify(), verify_exports))).verifyTaker({
|
|
2960
|
+
attested: transport.attestedResponder,
|
|
2961
|
+
solverPubkey: quote.solver_pubkey
|
|
2962
|
+
}) : void 0;
|
|
2146
2963
|
assertArkadeFundable({ quote, ...params.now !== void 0 ? { now: params.now } : {} });
|
|
2147
2964
|
const terms = offerTermsFromQuote(quote, {
|
|
2148
2965
|
...params.offerAsset !== void 0 ? { offerAsset: params.offerAsset } : {},
|
|
@@ -2180,7 +2997,8 @@ async function requestArkadeSwap(wallet, transport, params) {
|
|
|
2180
2997
|
...terms.wantAsset !== void 0 ? { wantAsset: terms.wantAsset } : {},
|
|
2181
2998
|
...terms.offerAsset !== void 0 ? { offerAsset: terms.offerAsset } : {},
|
|
2182
2999
|
...params.emulatorPubkey !== void 0 ? { emulatorPubkey: params.emulatorPubkey } : {},
|
|
2183
|
-
contractVersion
|
|
3000
|
+
contractVersion,
|
|
3001
|
+
...taker === void 0 ? {} : { taker }
|
|
2184
3002
|
});
|
|
2185
3003
|
verifyOfferAddress(quote, offer);
|
|
2186
3004
|
const fundAmount = BigInt(quote.from_amount);
|
|
@@ -2214,7 +3032,7 @@ function deriveOnchainSend(input) {
|
|
|
2214
3032
|
"onchain-send"
|
|
2215
3033
|
);
|
|
2216
3034
|
const contractParams = {
|
|
2217
|
-
solverPubkey: (0, import_sdk7.toXOnly)(
|
|
3035
|
+
solverPubkey: (0, import_sdk7.toXOnly)(import_base7.hex.decode(quote.solver_pubkey), "solver key"),
|
|
2218
3036
|
refundLocktime,
|
|
2219
3037
|
operatorPubkey: input.operatorPubkey,
|
|
2220
3038
|
paymentHash: input.paymentHash,
|
|
@@ -2234,7 +3052,7 @@ function deriveOnchainSend(input) {
|
|
|
2234
3052
|
const htlcParams = {
|
|
2235
3053
|
paymentHash: input.paymentHash,
|
|
2236
3054
|
claimKey: input.payoutPubkey,
|
|
2237
|
-
refundKey: (0, import_sdk7.toXOnly)(
|
|
3055
|
+
refundKey: (0, import_sdk7.toXOnly)(import_base7.hex.decode(htlcPubkey), "solver L1 htlc key"),
|
|
2238
3056
|
refundLocktime: htlcLocktime
|
|
2239
3057
|
};
|
|
2240
3058
|
const htlc = onchainHtlcScript(htlcParams, input.l1Network);
|
|
@@ -2265,7 +3083,7 @@ async function requestOnchainSend(wallet, transport, params) {
|
|
|
2265
3083
|
"[swap] this swap's preimage cannot be re-derived from the seed and MUST be persisted with the record before funding"
|
|
2266
3084
|
);
|
|
2267
3085
|
}
|
|
2268
|
-
const paymentHash =
|
|
3086
|
+
const paymentHash = import_base7.hex.encode(secrets.paymentHash);
|
|
2269
3087
|
const senderPubkey = secrets.pubkey;
|
|
2270
3088
|
const quote = await transport.requestQuote(
|
|
2271
3089
|
onchainSendRequest({
|
|
@@ -2429,7 +3247,7 @@ function deriveOnchainReceive(input) {
|
|
|
2429
3247
|
).matched;
|
|
2430
3248
|
const htlcParams = {
|
|
2431
3249
|
paymentHash: input.paymentHash,
|
|
2432
|
-
claimKey: (0, import_sdk7.toXOnly)(
|
|
3250
|
+
claimKey: (0, import_sdk7.toXOnly)(import_base7.hex.decode(claimPubkey), "solver L1 claim key"),
|
|
2433
3251
|
refundKey: input.refundPubkey,
|
|
2434
3252
|
refundLocktime: htlcLocktime
|
|
2435
3253
|
};
|
|
@@ -2503,11 +3321,11 @@ async function requestOnchainReceive(wallet, transport, params) {
|
|
|
2503
3321
|
secrets
|
|
2504
3322
|
};
|
|
2505
3323
|
}
|
|
2506
|
-
var
|
|
3324
|
+
var import_base7, import_solver_discovery, import_legacy2, import_sdk7, import_sdk8, solverHex, quoteSats, quoteAmountSats, quoteExpectedSats, ARKADE_BTC, LIGHTNING_BTC, ONCHAIN_BTC, arkadeAssetLeg, rfqPair, LIGHTNING_SEND_PAIR, LIGHTNING_RECEIVE_PAIR, ONCHAIN_SEND_PAIR, ONCHAIN_RECEIVE_PAIR, RFQ_TERMINAL_STATES, RFQ_REFUSAL_ERROR_CODES, isRfqRefusalErrorCode, REFUSAL_FIELDS, REFUSAL_UNITS, safeInteger, safeRefusalDetail, refusalMessage, SwapRefusal, AddressMismatch, newRfqId, lightningSendRequest, arkadeSwapRequest, canonicalAssetAmount, normalizeHexBytes, normalizeMakerPkScript, normalizeMakerPublicKey, MIN_HEADROOM_SECONDS, assertFinite, MAX_PAIR_LENGTH, assertPairLength, verifyLockupAddress, LOCKUP_SHAPE_VARIANTS, matchQuotedLockup, assertFundable, expectQuote, requestVersionedQuote, pairOf, httpTransport, relayTransport, SEQUENCE_GRANULARITY_SECONDS, SOLO_REFUND_HEADROOM_SECONDS, unilateralClaimDelay, unilateralRefundDelay, unilateralRefundWithoutReceiverDelay, seconds, suiteVhtlc, quotedSoloRefundDelay, offerTermsFromQuote, verifyOfferAddress, assertArkadeFundable, quoteCarrierSats, l1NetworkFromArk, operatorTerms, onchainSendRequest, lightningReceiveRequest, onchainReceiveRequest, assertQuotedAmount, MIN_CLAIM_WINDOW_SECONDS, verifyReceiveInvoice, assertReceivable, matchReceiveLockup, provisionReceive, quoteReceive;
|
|
2507
3325
|
var init_rfq = __esm({
|
|
2508
3326
|
"src/rfq.ts"() {
|
|
2509
3327
|
"use strict";
|
|
2510
|
-
|
|
3328
|
+
import_base7 = require("@scure/base");
|
|
2511
3329
|
import_solver_discovery = require("@arkade-os/solver-discovery");
|
|
2512
3330
|
import_legacy2 = require("@noble/hashes/legacy.js");
|
|
2513
3331
|
import_sdk7 = require("@arkade-os/sdk");
|
|
@@ -2522,7 +3340,7 @@ var init_rfq = __esm({
|
|
|
2522
3340
|
init_rfq_contract();
|
|
2523
3341
|
solverHex = (value, field) => {
|
|
2524
3342
|
try {
|
|
2525
|
-
return
|
|
3343
|
+
return import_base7.hex.decode(value);
|
|
2526
3344
|
} catch {
|
|
2527
3345
|
throw new Error(`solver sent malformed hex for ${field}`);
|
|
2528
3346
|
}
|
|
@@ -2642,7 +3460,7 @@ var init_rfq = __esm({
|
|
|
2642
3460
|
this.quoted = quoted;
|
|
2643
3461
|
}
|
|
2644
3462
|
};
|
|
2645
|
-
newRfqId = () =>
|
|
3463
|
+
newRfqId = () => import_base7.hex.encode(crypto.getRandomValues(new Uint8Array(32)));
|
|
2646
3464
|
lightningSendRequest = (input) => ({
|
|
2647
3465
|
v: 1,
|
|
2648
3466
|
type: "rfq_request",
|
|
@@ -2652,7 +3470,7 @@ var init_rfq = __esm({
|
|
|
2652
3470
|
profile: {
|
|
2653
3471
|
invoice: input.invoice,
|
|
2654
3472
|
refund_address: input.refundAddress,
|
|
2655
|
-
client_refund_pubkey:
|
|
3473
|
+
client_refund_pubkey: import_base7.hex.encode(input.senderPubkey)
|
|
2656
3474
|
}
|
|
2657
3475
|
});
|
|
2658
3476
|
arkadeSwapRequest = (input) => {
|
|
@@ -2706,7 +3524,7 @@ var init_rfq = __esm({
|
|
|
2706
3524
|
const got = bytes instanceof Uint8Array ? bytes.length : typeof bytes;
|
|
2707
3525
|
throw new Error(`${label} must be ${expectedBytes} bytes, got ${got}`);
|
|
2708
3526
|
}
|
|
2709
|
-
return
|
|
3527
|
+
return import_base7.hex.encode(bytes);
|
|
2710
3528
|
};
|
|
2711
3529
|
normalizeMakerPkScript = (value) => {
|
|
2712
3530
|
const encoded = normalizeHexBytes(value, 34, "maker_pk_script");
|
|
@@ -2716,7 +3534,7 @@ var init_rfq = __esm({
|
|
|
2716
3534
|
return encoded;
|
|
2717
3535
|
};
|
|
2718
3536
|
normalizeMakerPublicKey = (value) => {
|
|
2719
|
-
const raw = typeof value === "string" ? value :
|
|
3537
|
+
const raw = typeof value === "string" ? value : import_base7.hex.encode(value);
|
|
2720
3538
|
const bytes = solverHex(raw, "maker_public_key");
|
|
2721
3539
|
if (bytes.length === 33) {
|
|
2722
3540
|
throw new Error("maker_public_key must be x-only (32 bytes), not compressed (33 bytes)");
|
|
@@ -2884,7 +3702,7 @@ var init_rfq = __esm({
|
|
|
2884
3702
|
const version = selected ?? ASSET_SWAP_BASELINE;
|
|
2885
3703
|
if (!advertised.includes(version)) {
|
|
2886
3704
|
throw new Error(
|
|
2887
|
-
`solver chose contract version ${version}, not one of ${advertised.join(", ")}`
|
|
3705
|
+
selected === void 0 ? `solver negotiated no contract version; advertised ${advertised.join(", ")}` : `solver chose contract version ${version}, not one of ${advertised.join(", ")}`
|
|
2888
3706
|
);
|
|
2889
3707
|
}
|
|
2890
3708
|
return { quote, rfqId: sent.rfq_id, contractVersion: assetSwapContractVersion(version) };
|
|
@@ -3035,7 +3853,7 @@ var init_rfq = __esm({
|
|
|
3035
3853
|
sender: roles.sender,
|
|
3036
3854
|
receiver: roles.receiver,
|
|
3037
3855
|
server: params.operatorPubkey,
|
|
3038
|
-
preimageHash: (0, import_legacy2.ripemd160)(
|
|
3856
|
+
preimageHash: (0, import_legacy2.ripemd160)(import_base7.hex.decode(params.paymentHash)),
|
|
3039
3857
|
refundLocktime: BigInt(params.refundLocktime),
|
|
3040
3858
|
unilateralClaimDelay: seconds(params.claimDelay),
|
|
3041
3859
|
unilateralRefundDelay: seconds(unilateralRefundDelay(params.claimDelay)),
|
|
@@ -3068,7 +3886,7 @@ var init_rfq = __esm({
|
|
|
3068
3886
|
verifyOfferAddress = (quote, derived) => {
|
|
3069
3887
|
const quotedAddress = quote.profile?.offer_address;
|
|
3070
3888
|
const quotedScript = quote.profile?.offer_pk_script;
|
|
3071
|
-
const derivedScript =
|
|
3889
|
+
const derivedScript = import_base7.hex.encode(derived.swapPkScript);
|
|
3072
3890
|
if (quotedAddress !== derived.address || quotedScript !== derivedScript) {
|
|
3073
3891
|
throw new AddressMismatch([derived.address], quotedAddress);
|
|
3074
3892
|
}
|
|
@@ -3103,9 +3921,9 @@ var init_rfq = __esm({
|
|
|
3103
3921
|
operatorTerms = (info, emulatorPubkey) => {
|
|
3104
3922
|
const network = (0, import_sdk7.networkFromOperatorInfo)(info);
|
|
3105
3923
|
return {
|
|
3106
|
-
operatorPubkey: (0, import_sdk7.toXOnly)(
|
|
3924
|
+
operatorPubkey: (0, import_sdk7.toXOnly)(import_base7.hex.decode(info.signerPubkey), "ark signer key"),
|
|
3107
3925
|
emulatorPubkey: (0, import_sdk7.toXOnly)(
|
|
3108
|
-
|
|
3926
|
+
import_base7.hex.decode((0, import_sdk7.resolveEmulatorPubkey)(network, emulatorPubkey)),
|
|
3109
3927
|
"emulator signer key"
|
|
3110
3928
|
),
|
|
3111
3929
|
claimDelay: unilateralClaimDelay(Number(info.unilateralExitDelay)),
|
|
@@ -3121,9 +3939,9 @@ var init_rfq = __esm({
|
|
|
3121
3939
|
amount: input.amount,
|
|
3122
3940
|
profile: {
|
|
3123
3941
|
payment_hash: input.paymentHash,
|
|
3124
|
-
payout_pubkey:
|
|
3942
|
+
payout_pubkey: import_base7.hex.encode(input.payoutPubkey),
|
|
3125
3943
|
refund_address: input.refundAddress,
|
|
3126
|
-
client_refund_pubkey:
|
|
3944
|
+
client_refund_pubkey: import_base7.hex.encode(input.senderPubkey)
|
|
3127
3945
|
}
|
|
3128
3946
|
});
|
|
3129
3947
|
lightningReceiveRequest = (input) => ({
|
|
@@ -3136,7 +3954,7 @@ var init_rfq = __esm({
|
|
|
3136
3954
|
profile: {
|
|
3137
3955
|
payment_hash: input.paymentHash,
|
|
3138
3956
|
payout_address: input.payoutAddress,
|
|
3139
|
-
payout_pubkey:
|
|
3957
|
+
payout_pubkey: import_base7.hex.encode(input.payoutPubkey),
|
|
3140
3958
|
...input.claimPacket === void 0 ? {} : { claim_packet: input.claimPacket }
|
|
3141
3959
|
}
|
|
3142
3960
|
});
|
|
@@ -3150,9 +3968,9 @@ var init_rfq = __esm({
|
|
|
3150
3968
|
profile: {
|
|
3151
3969
|
payment_hash: input.paymentHash,
|
|
3152
3970
|
...input.claimPacket === void 0 ? {} : { claim_packet: input.claimPacket },
|
|
3153
|
-
refund_pubkey:
|
|
3971
|
+
refund_pubkey: import_base7.hex.encode(input.refundPubkey),
|
|
3154
3972
|
payout_address: input.payoutAddress,
|
|
3155
|
-
payout_pubkey:
|
|
3973
|
+
payout_pubkey: import_base7.hex.encode(input.payoutPubkey)
|
|
3156
3974
|
}
|
|
3157
3975
|
});
|
|
3158
3976
|
assertQuotedAmount = (quote, amountSide, amount) => {
|
|
@@ -3205,6 +4023,9 @@ var init_rfq = __esm({
|
|
|
3205
4023
|
if (input.now >= input.payDeadline) {
|
|
3206
4024
|
throw gateError("quote_expired", "quote or invoice already expired \u2014 request a fresh one");
|
|
3207
4025
|
}
|
|
4026
|
+
if (quoteAmountSats(input.quote.from_amount, "from_amount") <= 0n || quoteAmountSats(input.quote.to_amount, "to_amount") <= 0n) {
|
|
4027
|
+
throw gateError("non_positive_amount", "quote carries a non-positive amount");
|
|
4028
|
+
}
|
|
3208
4029
|
if (input.quote.refund_locktime === void 0) {
|
|
3209
4030
|
throw gateError("missing_refund_locktime", "receive quote carries no refund_locktime");
|
|
3210
4031
|
}
|
|
@@ -3224,7 +4045,7 @@ var init_rfq = __esm({
|
|
|
3224
4045
|
};
|
|
3225
4046
|
matchReceiveLockup = (input, refundLocktime, solverRefundPkScriptHex) => {
|
|
3226
4047
|
const contractParams = {
|
|
3227
|
-
solverPubkey: (0, import_sdk7.toXOnly)(
|
|
4048
|
+
solverPubkey: (0, import_sdk7.toXOnly)(import_base7.hex.decode(input.quote.solver_pubkey), "solver key"),
|
|
3228
4049
|
refundLocktime,
|
|
3229
4050
|
operatorPubkey: input.operatorPubkey,
|
|
3230
4051
|
paymentHash: input.paymentHash,
|
|
@@ -3254,7 +4075,7 @@ var init_rfq = __esm({
|
|
|
3254
4075
|
);
|
|
3255
4076
|
}
|
|
3256
4077
|
const preimage = secrets.preimage;
|
|
3257
|
-
const paymentHash =
|
|
4078
|
+
const paymentHash = import_base7.hex.encode(secrets.paymentHash);
|
|
3258
4079
|
const payoutPubkey = secrets.pubkey;
|
|
3259
4080
|
const binds = bindsClaimAmount();
|
|
3260
4081
|
const claimPacket = params.covclaimdPubkey && (!binds || params.amountSide === "to") ? await sealClaimPacket({
|
|
@@ -3477,6 +4298,7 @@ var init_nostr = __esm({
|
|
|
3477
4298
|
{ kinds: [RFQ_DIRECTED_KIND], "#p": [pubkey], authors: [solverPubkey] },
|
|
3478
4299
|
{
|
|
3479
4300
|
onevent(event) {
|
|
4301
|
+
if (event.pubkey !== solverPubkey || !(0, import_nostr_tools2.verifyEvent)(event)) return;
|
|
3480
4302
|
let payload;
|
|
3481
4303
|
try {
|
|
3482
4304
|
payload = JSON.parse(import_nostr_tools2.nip44.v2.decrypt(event.content, conversationKey));
|
|
@@ -3657,8 +4479,10 @@ __export(protocol_exports, {
|
|
|
3657
4479
|
ASSET_CARRIER_SATS: () => ASSET_CARRIER_SATS,
|
|
3658
4480
|
ASSET_SWAP_BASELINE: () => ASSET_SWAP_BASELINE,
|
|
3659
4481
|
ASSET_SWAP_CONTRACT_VERSIONS: () => ASSET_SWAP_CONTRACT_VERSIONS,
|
|
4482
|
+
ASSET_SWAP_DERIVABLE_VERSIONS: () => ASSET_SWAP_DERIVABLE_VERSIONS,
|
|
3660
4483
|
ASSET_SWAP_V2: () => ASSET_SWAP_V2,
|
|
3661
4484
|
ASSET_SWAP_V3: () => ASSET_SWAP_V3,
|
|
4485
|
+
ASSET_SWAP_V4: () => ASSET_SWAP_V4,
|
|
3662
4486
|
AddressMismatch: () => AddressMismatch,
|
|
3663
4487
|
BTC_ASSET_ID: () => BTC_ASSET_ID,
|
|
3664
4488
|
CROSS_ASSET_RAIL: () => CROSS_ASSET_RAIL,
|
|
@@ -3702,6 +4526,8 @@ __export(protocol_exports, {
|
|
|
3702
4526
|
assetSwapContractVersion: () => assetSwapContractVersion,
|
|
3703
4527
|
awaitOnchainFill: () => awaitOnchainFill,
|
|
3704
4528
|
awaitRfqResolution: () => awaitRfqResolution,
|
|
4529
|
+
bindingFromOffer: () => bindingFromOffer,
|
|
4530
|
+
bindingProgram: () => bindingProgram,
|
|
3705
4531
|
buildHtlcClaim: () => buildHtlcClaim,
|
|
3706
4532
|
buildHtlcRefund: () => buildHtlcRefund,
|
|
3707
4533
|
cancelOffer: () => cancelOffer,
|
|
@@ -3741,12 +4567,14 @@ __export(protocol_exports, {
|
|
|
3741
4567
|
normalizeMakerPublicKey: () => normalizeMakerPublicKey,
|
|
3742
4568
|
normalizeRfqSwapRecord: () => normalizeRfqSwapRecord,
|
|
3743
4569
|
offerContract: () => offerContract,
|
|
4570
|
+
offerFromBinding: () => offerFromBinding,
|
|
3744
4571
|
offerVtxoScript: () => offerVtxoScript,
|
|
3745
4572
|
onchainHtlcScript: () => onchainHtlcScript,
|
|
3746
4573
|
onchainReceiveProfile: () => onchainReceiveProfile,
|
|
3747
4574
|
onchainReceiveRequest: () => onchainReceiveRequest,
|
|
3748
4575
|
onchainSendProfile: () => onchainSendProfile,
|
|
3749
4576
|
onchainSendRequest: () => onchainSendRequest,
|
|
4577
|
+
packetRecoverySource: () => packetRecoverySource,
|
|
3750
4578
|
paymentHashOf: () => paymentHashOf,
|
|
3751
4579
|
preimageForSwapRecord: () => preimageForSwapRecord,
|
|
3752
4580
|
pushClaim: () => pushClaim,
|
|
@@ -3794,15 +4622,15 @@ module.exports = __toCommonJS(protocol_exports);
|
|
|
3794
4622
|
|
|
3795
4623
|
// src/activity.ts
|
|
3796
4624
|
var import_sdk16 = require("@arkade-os/sdk");
|
|
3797
|
-
var
|
|
4625
|
+
var import_base12 = require("@scure/base");
|
|
3798
4626
|
|
|
3799
4627
|
// src/swapManager.ts
|
|
3800
|
-
var
|
|
4628
|
+
var import_base11 = require("@scure/base");
|
|
3801
4629
|
var import_sdk12 = require("@arkade-os/sdk");
|
|
3802
4630
|
init_onchainHtlc();
|
|
3803
4631
|
|
|
3804
4632
|
// src/refund.ts
|
|
3805
|
-
var
|
|
4633
|
+
var import_base8 = require("@scure/base");
|
|
3806
4634
|
var import_sha24 = require("@noble/hashes/sha2.js");
|
|
3807
4635
|
var import_sdk9 = require("@arkade-os/sdk");
|
|
3808
4636
|
init_onchainHtlc();
|
|
@@ -3839,7 +4667,7 @@ var LockupNeedsRecoveryError = class extends Error {
|
|
|
3839
4667
|
};
|
|
3840
4668
|
async function findLockupVtxos(contracts, swapPkScript) {
|
|
3841
4669
|
const [row] = await contracts.getContractsWithVtxos({
|
|
3842
|
-
script:
|
|
4670
|
+
script: import_base8.hex.encode(swapPkScript)
|
|
3843
4671
|
});
|
|
3844
4672
|
const seen = /* @__PURE__ */ new Set();
|
|
3845
4673
|
const out = [];
|
|
@@ -3859,7 +4687,7 @@ async function findLockupVtxos(contracts, swapPkScript) {
|
|
|
3859
4687
|
}
|
|
3860
4688
|
return out;
|
|
3861
4689
|
}
|
|
3862
|
-
var hashesTo = (candidate, paymentHash) =>
|
|
4690
|
+
var hashesTo = (candidate, paymentHash) => import_base8.hex.encode((0, import_sha24.sha256)(candidate)) === paymentHash;
|
|
3863
4691
|
var candidateWitnessItems = (tx, inputIndex) => [
|
|
3864
4692
|
...(0, import_sdk9.getArkPsbtFields)(tx, inputIndex, import_sdk9.ConditionWitness).flat(),
|
|
3865
4693
|
...tx.getInput(inputIndex).finalScriptWitness ?? []
|
|
@@ -3878,7 +4706,7 @@ var refundLeafScript = (tx, inputIndex) => {
|
|
|
3878
4706
|
}
|
|
3879
4707
|
};
|
|
3880
4708
|
async function readLockupFate(indexer, input) {
|
|
3881
|
-
const { vtxos } = await indexer.getVtxos({ scripts: [
|
|
4709
|
+
const { vtxos } = await indexer.getVtxos({ scripts: [import_base8.hex.encode(input.swapPkScript)] });
|
|
3882
4710
|
const all = vtxos ?? [];
|
|
3883
4711
|
if (all.length === 0) return { fate: "unknown" };
|
|
3884
4712
|
const exited = all.filter((vtxo) => vtxo.isUnrolled && !(0, import_sdk9.isVtxoSpent)(vtxo));
|
|
@@ -3920,7 +4748,7 @@ async function readLockupFate(indexer, input) {
|
|
|
3920
4748
|
for (const raw of txs) {
|
|
3921
4749
|
let tx;
|
|
3922
4750
|
try {
|
|
3923
|
-
tx = import_sdk9.Transaction.fromPSBT(
|
|
4751
|
+
tx = import_sdk9.Transaction.fromPSBT(import_base8.base64.decode(raw));
|
|
3924
4752
|
} catch {
|
|
3925
4753
|
continue;
|
|
3926
4754
|
}
|
|
@@ -3929,7 +4757,7 @@ async function readLockupFate(indexer, input) {
|
|
|
3929
4757
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
3930
4758
|
const spent = tx.getInput(i);
|
|
3931
4759
|
if (!spent.txid) continue;
|
|
3932
|
-
const txid =
|
|
4760
|
+
const txid = import_base8.hex.encode(spent.txid);
|
|
3933
4761
|
if (!checkpoint) {
|
|
3934
4762
|
if (spent.index !== 0 || !spentBy.has(txid)) continue;
|
|
3935
4763
|
const preimage = candidateWitnessItems(tx, i).find(
|
|
@@ -3952,7 +4780,7 @@ async function readLockupFate(indexer, input) {
|
|
|
3952
4780
|
const leafScript = refundLeafScript(tx, i);
|
|
3953
4781
|
if (leafScript) {
|
|
3954
4782
|
refunded.add(`${vtxo.txid}:${vtxo.vout}`);
|
|
3955
|
-
leafScripts.add(
|
|
4783
|
+
leafScripts.add(import_base8.hex.encode(leafScript));
|
|
3956
4784
|
}
|
|
3957
4785
|
}
|
|
3958
4786
|
}
|
|
@@ -3973,7 +4801,7 @@ var operatorUnrollScript = async (operator, network) => {
|
|
|
3973
4801
|
return (0, import_sdk9.assertValidServerUnrollScript)(
|
|
3974
4802
|
info.checkpointTapscript,
|
|
3975
4803
|
network ?? (0, import_sdk9.networkFromOperatorInfo)(info),
|
|
3976
|
-
(0, import_sdk9.toXOnly)(
|
|
4804
|
+
(0, import_sdk9.toXOnly)(import_base8.hex.decode(info.forfeitPubkey), "forfeit key")
|
|
3977
4805
|
);
|
|
3978
4806
|
};
|
|
3979
4807
|
var MAX_LOCKUP_SPEND_INPUTS = 16;
|
|
@@ -4041,7 +4869,7 @@ init_repository();
|
|
|
4041
4869
|
|
|
4042
4870
|
// src/rfqRecord.ts
|
|
4043
4871
|
var import_sdk10 = require("@arkade-os/sdk");
|
|
4044
|
-
var
|
|
4872
|
+
var import_base10 = require("@scure/base");
|
|
4045
4873
|
|
|
4046
4874
|
// src/rfqSwapState.ts
|
|
4047
4875
|
var RFQ_SWAP_TERMINAL_STATES = ["settled", "refunded", "failed"];
|
|
@@ -4058,7 +4886,7 @@ var isRecheckableRefundedSend = (record) => record.kind === "lightning_send" &&
|
|
|
4058
4886
|
init_rfqCorridor();
|
|
4059
4887
|
|
|
4060
4888
|
// src/rfqCorridors.ts
|
|
4061
|
-
var
|
|
4889
|
+
var import_base9 = require("@scure/base");
|
|
4062
4890
|
init_rfqCorridor();
|
|
4063
4891
|
init_rfqProfileParts();
|
|
4064
4892
|
init_onchainHtlc();
|
|
@@ -4097,14 +4925,14 @@ var LightningReceiveCorridor = {
|
|
|
4097
4925
|
};
|
|
4098
4926
|
function onchainSendProfile(result) {
|
|
4099
4927
|
return {
|
|
4100
|
-
claimKey:
|
|
4101
|
-
refundKey:
|
|
4928
|
+
claimKey: import_base9.hex.encode(result.htlcParams.claimKey),
|
|
4929
|
+
refundKey: import_base9.hex.encode(result.htlcParams.refundKey),
|
|
4102
4930
|
htlcLocktime: result.htlcParams.refundLocktime,
|
|
4103
4931
|
network: result.l1Network,
|
|
4104
4932
|
htlcAddress: result.htlc.address,
|
|
4105
4933
|
minConfirmations: result.minConfirmations,
|
|
4106
4934
|
expectedAmount: result.expectedAmount,
|
|
4107
|
-
payoutPkScript:
|
|
4935
|
+
payoutPkScript: import_base9.hex.encode(result.payoutPkScript)
|
|
4108
4936
|
};
|
|
4109
4937
|
}
|
|
4110
4938
|
var OnchainSendCorridor = {
|
|
@@ -4142,8 +4970,8 @@ var OnchainSendCorridor = {
|
|
|
4142
4970
|
// From the profile, not the covenant: the lockup commits to `hash160(P)`, the
|
|
4143
4971
|
// HTLC needs `sha256(P)`.
|
|
4144
4972
|
paymentHash,
|
|
4145
|
-
claimKey:
|
|
4146
|
-
refundKey:
|
|
4973
|
+
claimKey: import_base9.hex.decode(profile.claimKey),
|
|
4974
|
+
refundKey: import_base9.hex.decode(profile.refundKey),
|
|
4147
4975
|
refundLocktime: profile.htlcLocktime
|
|
4148
4976
|
},
|
|
4149
4977
|
profile.network
|
|
@@ -4160,7 +4988,7 @@ var OnchainSendCorridor = {
|
|
|
4160
4988
|
expectedAmount: profile.expectedAmount,
|
|
4161
4989
|
// Optional here, required at the write: throwing on an older
|
|
4162
4990
|
// record would strand the refund it is still owed.
|
|
4163
|
-
...profile.payoutPkScript ? { payoutPkScript:
|
|
4991
|
+
...profile.payoutPkScript ? { payoutPkScript: import_base9.hex.decode(profile.payoutPkScript) } : {},
|
|
4164
4992
|
...profile.funding ? { funding: profile.funding } : {},
|
|
4165
4993
|
...profile.claimTxid ? { claimTxid: profile.claimTxid } : {},
|
|
4166
4994
|
...typeof profile.claimFeeRateSatVb === "number" ? { claimFeeRateSatVb: profile.claimFeeRateSatVb } : {},
|
|
@@ -4175,13 +5003,13 @@ var OnchainSendCorridor = {
|
|
|
4175
5003
|
};
|
|
4176
5004
|
function onchainReceiveProfile(result) {
|
|
4177
5005
|
return {
|
|
4178
|
-
claimKey:
|
|
4179
|
-
refundKey:
|
|
5006
|
+
claimKey: import_base9.hex.encode(result.htlcParams.claimKey),
|
|
5007
|
+
refundKey: import_base9.hex.encode(result.htlcParams.refundKey),
|
|
4180
5008
|
htlcLocktime: result.htlcParams.refundLocktime,
|
|
4181
5009
|
network: result.l1Network,
|
|
4182
5010
|
htlcAddress: result.htlc.address,
|
|
4183
5011
|
minConfirmations: result.minConfirmations,
|
|
4184
|
-
refundPkScript:
|
|
5012
|
+
refundPkScript: import_base9.hex.encode(result.refundPkScript),
|
|
4185
5013
|
...result.refundDescriptor === void 0 ? {} : { refundDescriptor: result.refundDescriptor }
|
|
4186
5014
|
};
|
|
4187
5015
|
}
|
|
@@ -4218,8 +5046,8 @@ var OnchainReceiveCorridor = {
|
|
|
4218
5046
|
const htlc = onchainHtlcScript(
|
|
4219
5047
|
{
|
|
4220
5048
|
paymentHash,
|
|
4221
|
-
claimKey:
|
|
4222
|
-
refundKey:
|
|
5049
|
+
claimKey: import_base9.hex.decode(profile.claimKey),
|
|
5050
|
+
refundKey: import_base9.hex.decode(profile.refundKey),
|
|
4223
5051
|
refundLocktime: profile.htlcLocktime
|
|
4224
5052
|
},
|
|
4225
5053
|
profile.network
|
|
@@ -4234,7 +5062,7 @@ var OnchainReceiveCorridor = {
|
|
|
4234
5062
|
htlc,
|
|
4235
5063
|
expectedAmount: profile.expectedAmount,
|
|
4236
5064
|
minConfirmations: profile.minConfirmations,
|
|
4237
|
-
refundPkScript:
|
|
5065
|
+
refundPkScript: import_base9.hex.decode(profile.refundPkScript),
|
|
4238
5066
|
...profile.claimTxid ? { claimTxid: profile.claimTxid } : {},
|
|
4239
5067
|
...profile.funding ? { funding: profile.funding } : {}
|
|
4240
5068
|
};
|
|
@@ -4290,8 +5118,8 @@ function assertSameSwap(origin, swap) {
|
|
|
4290
5118
|
`rfq swap record is a ${origin.kind} origin paired with a ${swap.kind} swap`
|
|
4291
5119
|
);
|
|
4292
5120
|
}
|
|
4293
|
-
const funded =
|
|
4294
|
-
const watched =
|
|
5121
|
+
const funded = import_base10.hex.encode(import_sdk10.ArkAddress.decode(origin.lockupAddress).pkScript);
|
|
5122
|
+
const watched = import_base10.hex.encode(swap.lockupPkScript);
|
|
4295
5123
|
if (funded !== watched) {
|
|
4296
5124
|
throw new Error(
|
|
4297
5125
|
`rfq swap record's lockup address holds ${funded}, but the swap watches ${watched} \u2014 these are not the same swap`
|
|
@@ -4339,9 +5167,9 @@ function rfqSwapOriginOf(record) {
|
|
|
4339
5167
|
function lockupScript(params, lockupAddress) {
|
|
4340
5168
|
const script = import_sdk10.VHTLCV2ContractHandler.createScript(params);
|
|
4341
5169
|
const funded = import_sdk10.ArkAddress.decode(lockupAddress).pkScript;
|
|
4342
|
-
if (
|
|
5170
|
+
if (import_base10.hex.encode(funded) !== import_base10.hex.encode(script.pkScript)) {
|
|
4343
5171
|
throw new Error(
|
|
4344
|
-
`rfq swap covenant params derive ${
|
|
5172
|
+
`rfq swap covenant params derive ${import_base10.hex.encode(script.pkScript)}, but the record's lockup address holds ${import_base10.hex.encode(funded)} \u2014 these params are not this swap's`
|
|
4345
5173
|
);
|
|
4346
5174
|
}
|
|
4347
5175
|
return script;
|
|
@@ -4893,13 +5721,13 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
4893
5721
|
// ── internals ────────────────────────────────────────────────────────────
|
|
4894
5722
|
track(swap) {
|
|
4895
5723
|
this.monitored.set(swap.rfqId, swap);
|
|
4896
|
-
this.byLockupScript.set(
|
|
5724
|
+
this.byLockupScript.set(import_base11.hex.encode(swap.lockupPkScript), swap);
|
|
4897
5725
|
}
|
|
4898
5726
|
/** Drops the swap from BOTH indexes. `pollSwap`'s `monitored` check also stops a late
|
|
4899
5727
|
* event, deliberately redundant so neither change alone re-drives a removed swap. */
|
|
4900
5728
|
untrack(rfqId) {
|
|
4901
5729
|
const swap = this.monitored.get(rfqId);
|
|
4902
|
-
if (swap) this.byLockupScript.delete(
|
|
5730
|
+
if (swap) this.byLockupScript.delete(import_base11.hex.encode(swap.lockupPkScript));
|
|
4903
5731
|
this.monitored.delete(rfqId);
|
|
4904
5732
|
this.refundRefused.delete(rfqId);
|
|
4905
5733
|
this.claimedOutpoints.delete(rfqId);
|
|
@@ -4945,7 +5773,7 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
4945
5773
|
if (!lockup) {
|
|
4946
5774
|
try {
|
|
4947
5775
|
const [existing] = await contracts.getContracts({
|
|
4948
|
-
script:
|
|
5776
|
+
script: import_base11.hex.encode(swap.lockupPkScript)
|
|
4949
5777
|
});
|
|
4950
5778
|
if (existing) {
|
|
4951
5779
|
this.registered.set(swap.rfqId, true);
|
|
@@ -4964,13 +5792,13 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
4964
5792
|
);
|
|
4965
5793
|
return;
|
|
4966
5794
|
}
|
|
4967
|
-
const script =
|
|
4968
|
-
if (script !==
|
|
5795
|
+
const script = import_base11.hex.encode(lockup.script.pkScript);
|
|
5796
|
+
if (script !== import_base11.hex.encode(swap.lockupPkScript)) {
|
|
4969
5797
|
this.registered.set(swap.rfqId, false);
|
|
4970
5798
|
this.emitFailed(
|
|
4971
5799
|
swap,
|
|
4972
5800
|
new Error(
|
|
4973
|
-
`swap ${swap.rfqId} lockup script ${script} does not match its lockupPkScript ${
|
|
5801
|
+
`swap ${swap.rfqId} lockup script ${script} does not match its lockupPkScript ${import_base11.hex.encode(swap.lockupPkScript)}`
|
|
4974
5802
|
)
|
|
4975
5803
|
);
|
|
4976
5804
|
return;
|
|
@@ -4987,7 +5815,7 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
4987
5815
|
retireContract(swap) {
|
|
4988
5816
|
if (!this.deps.contracts || !this.registered.get(swap.rfqId)) return;
|
|
4989
5817
|
if (!LOCKUP_RETIRABLE.includes(swap.state)) return;
|
|
4990
|
-
void this.deps.contracts.setContractWatchState(
|
|
5818
|
+
void this.deps.contracts.setContractWatchState(import_base11.hex.encode(swap.lockupPkScript), "retained").catch((error) => this.emitFailed(swap, error));
|
|
4991
5819
|
}
|
|
4992
5820
|
arm() {
|
|
4993
5821
|
if (!this.running) return;
|
|
@@ -5159,10 +5987,10 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
5159
5987
|
return;
|
|
5160
5988
|
}
|
|
5161
5989
|
if (!partiallyClaimed) {
|
|
5162
|
-
if (!Number.
|
|
5990
|
+
if (!Number.isSafeInteger(swap.expectedAmount) || swap.expectedAmount <= 0) {
|
|
5163
5991
|
return this.block(
|
|
5164
5992
|
swap,
|
|
5165
|
-
`expectedAmount is not a
|
|
5993
|
+
`expectedAmount is not a positive number of sats (${String(swap.expectedAmount)}), so the funded value cannot be checked \u2014 refusing to publish the preimage`
|
|
5166
5994
|
);
|
|
5167
5995
|
}
|
|
5168
5996
|
const locked = vtxos.reduce((sum, vtxo) => sum + vtxo.value, 0);
|
|
@@ -5423,6 +6251,9 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
5423
6251
|
utxo,
|
|
5424
6252
|
bump ? { bump } : void 0
|
|
5425
6253
|
);
|
|
6254
|
+
if (swap.funding?.txid !== utxo.txid || swap.funding.vout !== utxo.vout || swap.funding.amount === void 0) {
|
|
6255
|
+
swap.funding = { txid: utxo.txid, vout: utxo.vout, amount: Number(utxo.amount) };
|
|
6256
|
+
}
|
|
5426
6257
|
swap.claimTxid = txid;
|
|
5427
6258
|
swap.claimBroadcastAt = this.config.now();
|
|
5428
6259
|
delete swap.claimConfirmed;
|
|
@@ -5554,7 +6385,7 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
5554
6385
|
*/
|
|
5555
6386
|
stampSettlementPreimage(swap, preimage) {
|
|
5556
6387
|
if (swap.kind !== "lightning_send") return;
|
|
5557
|
-
swap.settlementPreimageHex =
|
|
6388
|
+
swap.settlementPreimageHex = import_base11.hex.encode(preimage);
|
|
5558
6389
|
this.touch(swap);
|
|
5559
6390
|
}
|
|
5560
6391
|
touch(swap) {
|
|
@@ -5947,7 +6778,7 @@ async function activityInputOf(stored, indexer) {
|
|
|
5947
6778
|
async function lockupTxids(indexer, record, wantFunding) {
|
|
5948
6779
|
let script;
|
|
5949
6780
|
try {
|
|
5950
|
-
script =
|
|
6781
|
+
script = import_base12.hex.encode(import_sdk16.ArkAddress.decode(record.lockupAddress).pkScript);
|
|
5951
6782
|
} catch {
|
|
5952
6783
|
return [];
|
|
5953
6784
|
}
|
|
@@ -6005,7 +6836,7 @@ function arkadeRefunder(deps) {
|
|
|
6005
6836
|
|
|
6006
6837
|
// src/chainSource.ts
|
|
6007
6838
|
var btc3 = __toESM(require("@scure/btc-signer"), 1);
|
|
6008
|
-
var
|
|
6839
|
+
var import_base13 = require("@scure/base");
|
|
6009
6840
|
init_onchainHtlc();
|
|
6010
6841
|
var addressOf = (pkScript, network) => btc3.Address(L1_NETWORKS[network]).encode(btc3.OutScript.decode(pkScript));
|
|
6011
6842
|
var chainSourceFrom = (provider, network) => {
|
|
@@ -6035,7 +6866,7 @@ var chainSourceFrom = (provider, network) => {
|
|
|
6035
6866
|
const spender = outspend.txid || await spenderFromHistory(txid, vout, pkScript);
|
|
6036
6867
|
if (!spender) return null;
|
|
6037
6868
|
const raw = await provider.getRawTransaction(spender);
|
|
6038
|
-
return { txHex:
|
|
6869
|
+
return { txHex: import_base13.hex.encode(raw) };
|
|
6039
6870
|
},
|
|
6040
6871
|
broadcast(txHex) {
|
|
6041
6872
|
return provider.broadcastTransaction(txHex);
|
|
@@ -6053,7 +6884,7 @@ var chainSourceFrom = (provider, network) => {
|
|
|
6053
6884
|
};
|
|
6054
6885
|
|
|
6055
6886
|
// src/claim.ts
|
|
6056
|
-
var
|
|
6887
|
+
var import_base14 = require("@scure/base");
|
|
6057
6888
|
var import_sdk17 = require("@arkade-os/sdk");
|
|
6058
6889
|
init_onchainHtlc();
|
|
6059
6890
|
var LockupAmountMismatchError = class extends Error {
|
|
@@ -6081,6 +6912,9 @@ async function pushClaim(operator, input) {
|
|
|
6081
6912
|
assertFiniteAmount(funded, "lockup_malformed", "the lockup's summed value");
|
|
6082
6913
|
if (!input.partiallyClaimed) {
|
|
6083
6914
|
assertFiniteAmount(input.expectedAmount, "invalid_gate_input", "expectedAmount");
|
|
6915
|
+
if (input.expectedAmount <= 0) {
|
|
6916
|
+
throw gateError("invalid_gate_input", "expectedAmount is not positive");
|
|
6917
|
+
}
|
|
6084
6918
|
if (funded < input.expectedAmount) {
|
|
6085
6919
|
throw new LockupAmountMismatchError(input.expectedAmount, funded);
|
|
6086
6920
|
}
|
|
@@ -6414,6 +7248,7 @@ init_program();
|
|
|
6414
7248
|
init_onchainHtlc();
|
|
6415
7249
|
|
|
6416
7250
|
// src/payment/crossAsset.ts
|
|
7251
|
+
var import_base15 = require("@scure/base");
|
|
6417
7252
|
var import_sdk20 = require("@arkade-os/sdk");
|
|
6418
7253
|
init_offer();
|
|
6419
7254
|
init_store();
|
|
@@ -6527,7 +7362,7 @@ function crossAssetRail(deps) {
|
|
|
6527
7362
|
const result = {
|
|
6528
7363
|
railId: CROSS_ASSET_RAIL,
|
|
6529
7364
|
txid,
|
|
6530
|
-
swapId: offer.
|
|
7365
|
+
swapId: import_base15.hex.encode(offer.swapPkScript)
|
|
6531
7366
|
};
|
|
6532
7367
|
emit({ status: "settled", result });
|
|
6533
7368
|
return result;
|
|
@@ -6539,7 +7374,7 @@ function crossAssetRail(deps) {
|
|
|
6539
7374
|
|
|
6540
7375
|
// src/payment/rendezvous.ts
|
|
6541
7376
|
var import_solver_discovery6 = require("@arkade-os/solver-discovery");
|
|
6542
|
-
var
|
|
7377
|
+
var import_base16 = require("@scure/base");
|
|
6543
7378
|
var XONLY_HEX = /^[0-9a-f]{64}$/;
|
|
6544
7379
|
var rendezvousOf = (market, pinned) => {
|
|
6545
7380
|
const transports = { nostr: { relays: market.transports?.nostr?.relays ?? [] } };
|
|
@@ -6558,7 +7393,7 @@ var rendezvousOf = (market, pinned) => {
|
|
|
6558
7393
|
};
|
|
6559
7394
|
};
|
|
6560
7395
|
var solverRendezvous = (markets, payoutCorridor, amountSats, fallbackEmulatorPubkey) => {
|
|
6561
|
-
const pinned = fallbackEmulatorPubkey ?
|
|
7396
|
+
const pinned = fallbackEmulatorPubkey ? import_base16.hex.encode(fallbackEmulatorPubkey) : void 0;
|
|
6562
7397
|
if (pinned !== void 0 && !XONLY_HEX.test(pinned)) return void 0;
|
|
6563
7398
|
const quoteCorridor = payoutCorridor === "lightning" ? "bolt11" : "bitcoin";
|
|
6564
7399
|
const isBtc = (id) => id === "btc" || /^(?:arkade|bolt11|bitcoin):[^/]+\/slip44:(?:0|1)$/.test(id ?? "");
|
|
@@ -6783,7 +7618,7 @@ function solverLightningRail(deps) {
|
|
|
6783
7618
|
}
|
|
6784
7619
|
|
|
6785
7620
|
// src/restore.ts
|
|
6786
|
-
var
|
|
7621
|
+
var import_base17 = require("@scure/base");
|
|
6787
7622
|
var import_sdk23 = require("@arkade-os/sdk");
|
|
6788
7623
|
init_offer();
|
|
6789
7624
|
init_store();
|
|
@@ -6802,7 +7637,7 @@ async function fetchParsedTxs(indexer, txids) {
|
|
|
6802
7637
|
if (result.status !== "fulfilled") continue;
|
|
6803
7638
|
for (const psbt of result.value) {
|
|
6804
7639
|
try {
|
|
6805
|
-
const parsed = import_sdk23.Transaction.fromPSBT(
|
|
7640
|
+
const parsed = import_sdk23.Transaction.fromPSBT(import_base17.base64.decode(psbt));
|
|
6806
7641
|
parsedByTxid.set(parsed.id, parsed);
|
|
6807
7642
|
} catch {
|
|
6808
7643
|
}
|
|
@@ -6816,8 +7651,16 @@ var unscannedSwapCandidates = (txs, existingIds, scanned) => txs.filter(
|
|
|
6816
7651
|
function classifySpend(offer, operatorPubkey, spendTx, deposit) {
|
|
6817
7652
|
let leaves;
|
|
6818
7653
|
try {
|
|
6819
|
-
|
|
6820
|
-
if (
|
|
7654
|
+
let script;
|
|
7655
|
+
if ("version" in offer) {
|
|
7656
|
+
const { program, args, keys } = bindingProgram(offer);
|
|
7657
|
+
script = new import_sdk23.arkade.ArkadeProgramScript(program, args, keys);
|
|
7658
|
+
} else {
|
|
7659
|
+
script = offerContract(offer, operatorPubkey);
|
|
7660
|
+
if (import_base17.hex.encode(script.pkScript) !== import_base17.hex.encode(offer.swapPkScript)) {
|
|
7661
|
+
return "indeterminate";
|
|
7662
|
+
}
|
|
7663
|
+
}
|
|
6821
7664
|
leaves = {
|
|
6822
7665
|
// `exit` is absent on an offer with no exit closure, and drops out here
|
|
6823
7666
|
returned: ["cancel", "exit"].map((name) => script.functionByName(name)?.leafScript).filter((leaf) => leaf !== void 0),
|
|
@@ -6829,11 +7672,11 @@ function classifySpend(offer, operatorPubkey, spendTx, deposit) {
|
|
|
6829
7672
|
for (let i = 0; i < spendTx.inputsLength; i++) {
|
|
6830
7673
|
const input = spendTx.getInput(i);
|
|
6831
7674
|
if (!input.txid || input.index !== deposit.vout) continue;
|
|
6832
|
-
if (
|
|
7675
|
+
if (import_base17.hex.encode(input.txid) !== deposit.txid) continue;
|
|
6833
7676
|
for (const leaf of input.tapLeafScript ?? []) {
|
|
6834
|
-
const spent =
|
|
6835
|
-
if (leaves.returned.some((back) => spent ===
|
|
6836
|
-
if (leaves.fulfill && spent ===
|
|
7677
|
+
const spent = import_base17.hex.encode((0, import_sdk23.scriptFromTapLeafScript)(leaf));
|
|
7678
|
+
if (leaves.returned.some((back) => spent === import_base17.hex.encode(back))) return "cancelled";
|
|
7679
|
+
if (leaves.fulfill && spent === import_base17.hex.encode(leaves.fulfill)) return "fulfilled";
|
|
6837
7680
|
}
|
|
6838
7681
|
}
|
|
6839
7682
|
return "indeterminate";
|
|
@@ -6846,21 +7689,56 @@ function classifyDepositSpend(offer, operatorPubkey, spendTxs, deposit) {
|
|
|
6846
7689
|
}
|
|
6847
7690
|
return "indeterminate";
|
|
6848
7691
|
}
|
|
7692
|
+
var encodesOffer = (offerHex, offer) => {
|
|
7693
|
+
try {
|
|
7694
|
+
const { ratioNum: _num, ratioDen: _den, ...terms } = decodeOffer(import_base17.hex.decode(offerHex));
|
|
7695
|
+
return import_base17.hex.encode(encodeOffer(terms)) === import_base17.hex.encode(encodeOffer(offer));
|
|
7696
|
+
} catch {
|
|
7697
|
+
return false;
|
|
7698
|
+
}
|
|
7699
|
+
};
|
|
7700
|
+
var packetRecoverySource = (indexer) => ({
|
|
7701
|
+
name: "packet",
|
|
7702
|
+
async discover({ candidateTxids, operatorPubkey }) {
|
|
7703
|
+
const found = [];
|
|
7704
|
+
const declined = [];
|
|
7705
|
+
for (const [txid, parsed] of await fetchParsedTxs(indexer, [...candidateTxids])) {
|
|
7706
|
+
let packet;
|
|
7707
|
+
try {
|
|
7708
|
+
packet = import_sdk23.Extension.fromTx(parsed).getPacketByType(OFFER_PACKET_TYPE);
|
|
7709
|
+
} catch {
|
|
7710
|
+
}
|
|
7711
|
+
if (!packet) {
|
|
7712
|
+
declined.push(txid);
|
|
7713
|
+
continue;
|
|
7714
|
+
}
|
|
7715
|
+
const payload = packet.serialize();
|
|
7716
|
+
try {
|
|
7717
|
+
const binding = bindingFromOffer(decodeOffer(payload), operatorPubkey);
|
|
7718
|
+
found.push({ fundingTxid: txid, binding, offerHex: import_base17.hex.encode(payload) });
|
|
7719
|
+
} catch {
|
|
7720
|
+
}
|
|
7721
|
+
}
|
|
7722
|
+
return { found, declined };
|
|
7723
|
+
}
|
|
7724
|
+
});
|
|
6849
7725
|
async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
6850
7726
|
const {
|
|
6851
7727
|
operatorPubkey,
|
|
6852
7728
|
scanned = /* @__PURE__ */ new Set(),
|
|
6853
7729
|
reopen = [],
|
|
6854
7730
|
hrp,
|
|
6855
|
-
recoveredIn = /* @__PURE__ */ new Set()
|
|
7731
|
+
recoveredIn = /* @__PURE__ */ new Set(),
|
|
7732
|
+
sources = [packetRecoverySource(indexer)]
|
|
6856
7733
|
} = opts;
|
|
6857
7734
|
const reopened = [];
|
|
6858
7735
|
for (const swap of reopen) {
|
|
6859
7736
|
try {
|
|
7737
|
+
const source = storedOffer(swap);
|
|
6860
7738
|
reopened.push({
|
|
6861
7739
|
fundingTx: { type: "sent", redeemTxid: swap.fundingTxid },
|
|
6862
|
-
offer:
|
|
6863
|
-
|
|
7740
|
+
offer: "version" in source ? offerFromBinding(source) : source,
|
|
7741
|
+
source,
|
|
6864
7742
|
existing: swap
|
|
6865
7743
|
});
|
|
6866
7744
|
} catch {
|
|
@@ -6874,30 +7752,41 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
6874
7752
|
return { restored: [], scannedTxids: [] };
|
|
6875
7753
|
}
|
|
6876
7754
|
const byTxid = new Map(candidates.map((tx) => [tx.redeemTxid, tx]));
|
|
6877
|
-
const
|
|
6878
|
-
indexer,
|
|
6879
|
-
candidates.map((tx) => tx.redeemTxid)
|
|
6880
|
-
);
|
|
6881
|
-
const fetchedTxids = [];
|
|
7755
|
+
const candidateTxids = candidates.map((tx) => tx.redeemTxid);
|
|
6882
7756
|
const found = [...reopened];
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
7757
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
7758
|
+
const declined = /* @__PURE__ */ new Set();
|
|
7759
|
+
for (const recovery of candidateTxids.length === 0 ? [] : sources) {
|
|
7760
|
+
let answer;
|
|
6887
7761
|
try {
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
7762
|
+
answer = await recovery.discover({ candidateTxids, operatorPubkey });
|
|
7763
|
+
} catch (error) {
|
|
7764
|
+
console.warn(`[swap] recovery source ${recovery.name} failed`, error);
|
|
7765
|
+
continue;
|
|
7766
|
+
}
|
|
7767
|
+
for (const txid of answer.declined) declined.add(txid);
|
|
7768
|
+
for (const { fundingTxid, binding, offerHex } of answer.found) {
|
|
7769
|
+
const fundingTx = byTxid.get(fundingTxid);
|
|
7770
|
+
if (!fundingTx || claimed.has(fundingTxid)) continue;
|
|
7771
|
+
let offer;
|
|
7772
|
+
try {
|
|
7773
|
+
offer = offerFromBinding(binding);
|
|
7774
|
+
} catch (error) {
|
|
7775
|
+
console.warn(`[swap] ${recovery.name} sent a binding that does not compile`, error);
|
|
7776
|
+
continue;
|
|
7777
|
+
}
|
|
7778
|
+
if (offerHex !== void 0 && !encodesOffer(offerHex, offer)) {
|
|
7779
|
+
console.warn(`[swap] ${recovery.name} sent a packet its binding does not match`);
|
|
7780
|
+
continue;
|
|
7781
|
+
}
|
|
7782
|
+
claimed.add(fundingTxid);
|
|
7783
|
+
const packet = offerHex ?? import_base17.hex.encode(encodeOffer(offer));
|
|
7784
|
+
found.push({ fundingTx, offer, source: binding, offerHex: packet });
|
|
6897
7785
|
}
|
|
6898
7786
|
}
|
|
6899
|
-
|
|
6900
|
-
|
|
7787
|
+
const answered = [...claimed, ...[...declined].filter((txid) => !claimed.has(txid))];
|
|
7788
|
+
if (found.length === 0) return { restored: [], scannedTxids: answered };
|
|
7789
|
+
const scripts = [...new Set(found.map((f) => import_base17.hex.encode(f.offer.swapPkScript)))];
|
|
6901
7790
|
const { vtxos } = await indexer.getVtxos({ scripts });
|
|
6902
7791
|
const vtxoByScriptAndTxid = new Map(vtxos.map((v) => [`${v.script}:${v.txid}`, v]));
|
|
6903
7792
|
const txByAnyId = /* @__PURE__ */ new Map();
|
|
@@ -6909,7 +7798,7 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
6909
7798
|
const spendTxids = /* @__PURE__ */ new Set();
|
|
6910
7799
|
for (const { fundingTx, offer } of found) {
|
|
6911
7800
|
const vtxo = vtxoByScriptAndTxid.get(
|
|
6912
|
-
`${
|
|
7801
|
+
`${import_base17.hex.encode(offer.swapPkScript)}:${fundingTx.redeemTxid}`
|
|
6913
7802
|
);
|
|
6914
7803
|
if (!vtxo?.isSpent) continue;
|
|
6915
7804
|
for (const txid of spendTxidsOf(vtxo)) spendTxids.add(txid);
|
|
@@ -6917,8 +7806,8 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
6917
7806
|
const spendTxByTxid = await fetchParsedTxs(indexer, [...spendTxids]);
|
|
6918
7807
|
const restored = [];
|
|
6919
7808
|
const unresolved = /* @__PURE__ */ new Set();
|
|
6920
|
-
for (const { fundingTx, offer, offerHex, existing } of found) {
|
|
6921
|
-
const swapPkScript =
|
|
7809
|
+
for (const { fundingTx, offer, source, offerHex, existing } of found) {
|
|
7810
|
+
const swapPkScript = import_base17.hex.encode(offer.swapPkScript);
|
|
6922
7811
|
const vtxo = vtxoByScriptAndTxid.get(`${swapPkScript}:${fundingTx.redeemTxid}`);
|
|
6923
7812
|
if (!vtxo) {
|
|
6924
7813
|
unresolved.add(fundingTx.redeemTxid);
|
|
@@ -6946,7 +7835,7 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
6946
7835
|
} else if (vtxo.isSwept && !vtxo.isSpent) status = "recoverable";
|
|
6947
7836
|
else if (vtxo.isSpent) {
|
|
6948
7837
|
const spendTxs = spendTxidsOf(vtxo).map((id) => spendTxByTxid.get(id)).filter((tx) => tx !== void 0);
|
|
6949
|
-
const kind = classifyDepositSpend(
|
|
7838
|
+
const kind = classifyDepositSpend(source, operatorPubkey, spendTxs, {
|
|
6950
7839
|
txid: vtxo.txid,
|
|
6951
7840
|
vout: vtxo.vout
|
|
6952
7841
|
});
|
|
@@ -6962,20 +7851,19 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
6962
7851
|
restored.push({ ...existing, status, spentTxid, ...completion });
|
|
6963
7852
|
continue;
|
|
6964
7853
|
}
|
|
7854
|
+
if (!("version" in source)) continue;
|
|
6965
7855
|
let swapAddress = "";
|
|
6966
7856
|
try {
|
|
6967
|
-
const compiled = offerContract(offer, operatorPubkey);
|
|
6968
|
-
if (import_base15.hex.encode(compiled.pkScript) !== swapPkScript) {
|
|
6969
|
-
unresolved.add(fundingTx.redeemTxid);
|
|
6970
|
-
continue;
|
|
6971
|
-
}
|
|
6972
7857
|
if (hrp !== void 0) {
|
|
6973
|
-
|
|
7858
|
+
const { program, args, keys } = bindingProgram(source);
|
|
7859
|
+
const compiled = new import_sdk23.arkade.ArkadeProgramScript(program, args, keys);
|
|
7860
|
+
swapAddress = compiled.address(hrp, source.serverPublicKey).encode();
|
|
6974
7861
|
}
|
|
6975
7862
|
} catch {
|
|
6976
7863
|
unresolved.add(fundingTx.redeemTxid);
|
|
6977
7864
|
continue;
|
|
6978
7865
|
}
|
|
7866
|
+
const covenant = source.taker === void 0 ? { offerHex: offerHex ?? import_base17.hex.encode(encodeOffer(offer)) } : { binding: recordOfferBinding(source) };
|
|
6979
7867
|
restored.push({
|
|
6980
7868
|
id: fundingTx.redeemTxid,
|
|
6981
7869
|
fromAsset,
|
|
@@ -6984,7 +7872,7 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
6984
7872
|
toAmount: offer.wantAmount.toString(),
|
|
6985
7873
|
swapAddress,
|
|
6986
7874
|
swapPkScript,
|
|
6987
|
-
|
|
7875
|
+
...covenant,
|
|
6988
7876
|
fundingTxid: fundingTx.redeemTxid,
|
|
6989
7877
|
spentTxid,
|
|
6990
7878
|
status,
|
|
@@ -6992,7 +7880,7 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
6992
7880
|
...completion
|
|
6993
7881
|
});
|
|
6994
7882
|
}
|
|
6995
|
-
return { restored, scannedTxids:
|
|
7883
|
+
return { restored, scannedTxids: answered.filter((id) => !unresolved.has(id)) };
|
|
6996
7884
|
}
|
|
6997
7885
|
|
|
6998
7886
|
// src/protocol.ts
|
|
@@ -7001,7 +7889,7 @@ init_rfqProfileParts();
|
|
|
7001
7889
|
init_store();
|
|
7002
7890
|
|
|
7003
7891
|
// src/watch.ts
|
|
7004
|
-
var
|
|
7892
|
+
var import_base18 = require("@scure/base");
|
|
7005
7893
|
var import_sdk24 = require("@arkade-os/sdk");
|
|
7006
7894
|
init_coverage();
|
|
7007
7895
|
init_offer();
|
|
@@ -7050,9 +7938,9 @@ async function watchOfferSwaps({
|
|
|
7050
7938
|
if (candidates.length === 0) return "indeterminate";
|
|
7051
7939
|
const { txs } = await indexer.getVirtualTxs(candidates);
|
|
7052
7940
|
return classifyDepositSpend(
|
|
7053
|
-
|
|
7941
|
+
storedOffer(swap),
|
|
7054
7942
|
operatorPubkey,
|
|
7055
|
-
txs.map((psbt) => import_sdk24.Transaction.fromPSBT(
|
|
7943
|
+
txs.map((psbt) => import_sdk24.Transaction.fromPSBT(import_base18.base64.decode(psbt))),
|
|
7056
7944
|
{ txid: vtxo.txid, vout: vtxo.vout }
|
|
7057
7945
|
);
|
|
7058
7946
|
} catch {
|
|
@@ -7094,8 +7982,10 @@ async function watchOfferSwaps({
|
|
|
7094
7982
|
ASSET_CARRIER_SATS,
|
|
7095
7983
|
ASSET_SWAP_BASELINE,
|
|
7096
7984
|
ASSET_SWAP_CONTRACT_VERSIONS,
|
|
7985
|
+
ASSET_SWAP_DERIVABLE_VERSIONS,
|
|
7097
7986
|
ASSET_SWAP_V2,
|
|
7098
7987
|
ASSET_SWAP_V3,
|
|
7988
|
+
ASSET_SWAP_V4,
|
|
7099
7989
|
AddressMismatch,
|
|
7100
7990
|
BTC_ASSET_ID,
|
|
7101
7991
|
CROSS_ASSET_RAIL,
|
|
@@ -7139,6 +8029,8 @@ async function watchOfferSwaps({
|
|
|
7139
8029
|
assetSwapContractVersion,
|
|
7140
8030
|
awaitOnchainFill,
|
|
7141
8031
|
awaitRfqResolution,
|
|
8032
|
+
bindingFromOffer,
|
|
8033
|
+
bindingProgram,
|
|
7142
8034
|
buildHtlcClaim,
|
|
7143
8035
|
buildHtlcRefund,
|
|
7144
8036
|
cancelOffer,
|
|
@@ -7178,12 +8070,14 @@ async function watchOfferSwaps({
|
|
|
7178
8070
|
normalizeMakerPublicKey,
|
|
7179
8071
|
normalizeRfqSwapRecord,
|
|
7180
8072
|
offerContract,
|
|
8073
|
+
offerFromBinding,
|
|
7181
8074
|
offerVtxoScript,
|
|
7182
8075
|
onchainHtlcScript,
|
|
7183
8076
|
onchainReceiveProfile,
|
|
7184
8077
|
onchainReceiveRequest,
|
|
7185
8078
|
onchainSendProfile,
|
|
7186
8079
|
onchainSendRequest,
|
|
8080
|
+
packetRecoverySource,
|
|
7187
8081
|
paymentHashOf,
|
|
7188
8082
|
preimageForSwapRecord,
|
|
7189
8083
|
pushClaim,
|