@arkade-os/swap 0.1.0-rc.3 → 0.1.0-rc.5
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 +191 -31
- package/dist/advanced.d.cts +80 -9
- package/dist/advanced.d.ts +80 -9
- package/dist/advanced.js +131 -4
- package/dist/{chunk-LYCMM3VB.js → chunk-6HIU2LNP.js} +8 -8
- package/dist/{chunk-OROIHWXD.js → chunk-BQLGQ4WB.js} +30 -7
- package/dist/{chunk-H5KFNL5O.js → chunk-O3XMAZXS.js} +14 -5
- package/dist/{errors-Cwz3Xh72.d.ts → errors-BVhyWIM0.d.ts} +16 -3
- package/dist/{errors-CcvUMXEF.d.cts → errors-DUTOiyH2.d.cts} +16 -3
- package/dist/index.cjs +88 -59
- package/dist/index.d.cts +13 -11
- package/dist/index.d.ts +13 -11
- package/dist/index.js +5 -5
- package/dist/node/index.d.cts +30 -0
- package/dist/node/index.d.ts +30 -0
- package/dist/nostr.d.cts +1 -1
- package/dist/nostr.d.ts +1 -1
- package/dist/nostr.js +1 -1
- package/dist/protocol.cjs +142 -122
- package/dist/protocol.d.cts +21 -12
- package/dist/protocol.d.ts +21 -12
- package/dist/protocol.js +2 -2
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/{repository-BGlWfv3c.d.ts → repository-CDlK003C.d.cts} +40 -1
- package/dist/{repository-B8MJY64N.d.cts → repository-D3A1amV_.d.ts} +40 -1
- package/dist/{rfq-CSgBQkjl.d.ts → rfq-RONK76D7.d.cts} +17 -8
- package/dist/{rfq-CSgBQkjl.d.cts → rfq-RONK76D7.d.ts} +17 -8
- package/dist/{watch-DkbPNiqf.d.ts → watch-BJ-KKgwU.d.ts} +1 -1
- package/dist/{watch-BjMc3SFo.d.cts → watch-JawNDXBr.d.cts} +1 -1
- package/package.json +2 -2
package/dist/advanced.cjs
CHANGED
|
@@ -739,7 +739,7 @@ var init_rfq = __esm({
|
|
|
739
739
|
payment_hash: input.paymentHash,
|
|
740
740
|
payout_address: input.payoutAddress,
|
|
741
741
|
payout_pubkey: import_base7.hex.encode(input.payoutPubkey),
|
|
742
|
-
claim_packet: input.claimPacket
|
|
742
|
+
...input.claimPacket === void 0 ? {} : { claim_packet: input.claimPacket }
|
|
743
743
|
}
|
|
744
744
|
});
|
|
745
745
|
MIN_CLAIM_WINDOW_SECONDS = 30 * 60;
|
|
@@ -923,6 +923,7 @@ __export(advanced_exports, {
|
|
|
923
923
|
CORRIDOR_FACTORIES: () => CORRIDOR_FACTORIES,
|
|
924
924
|
CORRIDOR_PASS: () => CORRIDOR_PASS,
|
|
925
925
|
ClientDisposed: () => ClientDisposed,
|
|
926
|
+
CovclaimdRevealError: () => CovclaimdRevealError,
|
|
926
927
|
DEFAULT_INVOICE_EXPIRY_SECONDS: () => DEFAULT_INVOICE_EXPIRY_SECONDS,
|
|
927
928
|
DiscoverySnapshotUnavailable: () => DiscoverySnapshotUnavailable,
|
|
928
929
|
FEED_TTL_MS: () => FEED_TTL_MS,
|
|
@@ -970,6 +971,7 @@ __export(advanced_exports, {
|
|
|
970
971
|
corridorOutcome: () => corridorOutcome,
|
|
971
972
|
corridorRecordStore: () => corridorRecordStore,
|
|
972
973
|
corridorSet: () => corridorSet,
|
|
974
|
+
covclaimdClient: () => covclaimdClient,
|
|
973
975
|
createSwapClient: () => createSwapClient,
|
|
974
976
|
createSwapDrive: () => createSwapDrive,
|
|
975
977
|
decodeBolt11: () => decodeBolt11,
|
|
@@ -1029,6 +1031,8 @@ __export(advanced_exports, {
|
|
|
1029
1031
|
resolveCorridorBase: () => resolveCorridorBase,
|
|
1030
1032
|
resolveCorridorDeps: () => resolveCorridorDeps,
|
|
1031
1033
|
resolveRoute: () => resolveRoute,
|
|
1034
|
+
revealClaimPacket: () => revealClaimPacket,
|
|
1035
|
+
revealFieldsFromScript: () => revealFieldsFromScript,
|
|
1032
1036
|
rfqLeg: () => rfqLeg,
|
|
1033
1037
|
rfqPairFor: () => rfqPairFor,
|
|
1034
1038
|
rfqRecordOf: () => rfqRecordOf,
|
|
@@ -1145,6 +1149,7 @@ var swap_want_btc_program_default = {
|
|
|
1145
1149
|
|
|
1146
1150
|
// src/coverage.ts
|
|
1147
1151
|
var RETIRABLE = ["fulfilled", "cancelled"];
|
|
1152
|
+
var LOCKUP_RETIRABLE = ["settled", "refunded"];
|
|
1148
1153
|
var issuedAt = /* @__PURE__ */ new Map();
|
|
1149
1154
|
var inFlight = /* @__PURE__ */ new Map();
|
|
1150
1155
|
async function serialize(script, task) {
|
|
@@ -3824,7 +3829,7 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
3824
3829
|
const vtxo = vtxoByScriptAndTxid.get(
|
|
3825
3830
|
`${import_base11.hex.encode(offer.swapPkScript)}:${fundingTx.redeemTxid}`
|
|
3826
3831
|
);
|
|
3827
|
-
if (vtxo?.
|
|
3832
|
+
if (!vtxo?.isSpent) continue;
|
|
3828
3833
|
for (const txid of spendTxidsOf(vtxo)) spendTxids.add(txid);
|
|
3829
3834
|
}
|
|
3830
3835
|
const spendTxByTxid = await fetchParsedTxs(indexer, [...spendTxids]);
|
|
@@ -3846,11 +3851,10 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
3846
3851
|
continue;
|
|
3847
3852
|
}
|
|
3848
3853
|
const fromAmount = depositAmount.toString();
|
|
3849
|
-
const
|
|
3850
|
-
const spentTxid = state === "spent" ? vtxo.arkTxId || vtxo.spentBy : void 0;
|
|
3854
|
+
const spentTxid = vtxo.isSpent ? vtxo.arkTxId || vtxo.spentBy : void 0;
|
|
3851
3855
|
let status = "pending";
|
|
3852
|
-
if (
|
|
3853
|
-
else if (
|
|
3856
|
+
if (vtxo.isSwept) status = "recoverable";
|
|
3857
|
+
else if (vtxo.isSpent) {
|
|
3854
3858
|
const spendTxs = spendTxidsOf(vtxo).map((id) => spendTxByTxid.get(id)).filter((tx) => tx !== void 0);
|
|
3855
3859
|
const kind = classifyDepositSpend(offer, operatorPubkey, spendTxs, {
|
|
3856
3860
|
txid: vtxo.txid,
|
|
@@ -3908,6 +3912,7 @@ var rfqRecordOf = (record) => ({
|
|
|
3908
3912
|
updatedAt: record.updatedAt,
|
|
3909
3913
|
...record.refundTxid === void 0 ? {} : { refundTxid: record.refundTxid },
|
|
3910
3914
|
...record.lockupSpendTxids?.length ? { lockupSpendTxids: [...record.lockupSpendTxids] } : {},
|
|
3915
|
+
...record.settlementPreimageHex === void 0 ? {} : { settlementPreimageHex: record.settlementPreimageHex },
|
|
3911
3916
|
...record.failure === void 0 ? {} : { failure: record.failure },
|
|
3912
3917
|
...record.claimFailure === void 0 ? {} : { claimFailure: record.claimFailure },
|
|
3913
3918
|
...record.blockedReason === void 0 ? {} : { blockedReason: record.blockedReason }
|
|
@@ -3916,6 +3921,7 @@ var withRfqState = (record, state) => {
|
|
|
3916
3921
|
const {
|
|
3917
3922
|
refundTxid: _refundTxid,
|
|
3918
3923
|
lockupSpendTxids: _lockupSpendTxids,
|
|
3924
|
+
settlementPreimageHex: _settlementPreimageHex,
|
|
3919
3925
|
failure: _failure,
|
|
3920
3926
|
claimFailure: _claimFailure,
|
|
3921
3927
|
blockedReason: _blockedReason,
|
|
@@ -3928,6 +3934,7 @@ var withRfqState = (record, state) => {
|
|
|
3928
3934
|
updatedAt: state.updatedAt,
|
|
3929
3935
|
...state.refundTxid === void 0 ? {} : { refundTxid: state.refundTxid },
|
|
3930
3936
|
...state.lockupSpendTxids?.length ? { lockupSpendTxids: [...state.lockupSpendTxids] } : {},
|
|
3937
|
+
...state.settlementPreimageHex === void 0 ? {} : { settlementPreimageHex: state.settlementPreimageHex },
|
|
3931
3938
|
...state.failure === void 0 ? {} : { failure: state.failure },
|
|
3932
3939
|
...state.claimFailure === void 0 ? {} : { claimFailure: state.claimFailure },
|
|
3933
3940
|
...state.blockedReason === void 0 ? {} : { blockedReason: state.blockedReason }
|
|
@@ -4160,7 +4167,7 @@ var retireOfferScripts = async (wallet, repository, record) => {
|
|
|
4160
4167
|
var isMissingVtxo = (error) => error instanceof NoSpendableDepositError;
|
|
4161
4168
|
|
|
4162
4169
|
// src/client/drive.ts
|
|
4163
|
-
var
|
|
4170
|
+
var import_sdk23 = require("@arkade-os/sdk");
|
|
4164
4171
|
var import_base17 = require("@scure/base");
|
|
4165
4172
|
|
|
4166
4173
|
// src/claim.ts
|
|
@@ -4337,6 +4344,7 @@ var managerState = (swap) => ({
|
|
|
4337
4344
|
updatedAt: swap.updatedAt,
|
|
4338
4345
|
...swap.refundTxid ? { refundTxid: swap.refundTxid } : {},
|
|
4339
4346
|
...swap.lockupSpendTxids?.length ? { lockupSpendTxids: [...swap.lockupSpendTxids] } : {},
|
|
4347
|
+
...swap.settlementPreimageHex ? { settlementPreimageHex: swap.settlementPreimageHex } : {},
|
|
4340
4348
|
...swap.failure ? { failure: swap.failure } : {},
|
|
4341
4349
|
...swap.claimFailure ? { claimFailure: swap.claimFailure } : {},
|
|
4342
4350
|
...swap.blockedReason ? { blockedReason: swap.blockedReason } : {}
|
|
@@ -4372,6 +4380,7 @@ function updateRfqSwapRecord(record, swap) {
|
|
|
4372
4380
|
const {
|
|
4373
4381
|
refundTxid: _refundTxid,
|
|
4374
4382
|
lockupSpendTxids: _lockupSpendTxids,
|
|
4383
|
+
settlementPreimageHex: _settlementPreimageHex,
|
|
4375
4384
|
failure: _failure,
|
|
4376
4385
|
claimFailure: _claimFailure,
|
|
4377
4386
|
blockedReason: _blockedReason,
|
|
@@ -4419,6 +4428,7 @@ function rebuildRfqSwap(record, params) {
|
|
|
4419
4428
|
updatedAt: stored.updatedAt,
|
|
4420
4429
|
...stored.refundTxid ? { refundTxid: stored.refundTxid } : {},
|
|
4421
4430
|
...stored.lockupSpendTxids?.length ? { lockupSpendTxids: [...stored.lockupSpendTxids] } : {},
|
|
4431
|
+
...stored.settlementPreimageHex ? { settlementPreimageHex: stored.settlementPreimageHex } : {},
|
|
4422
4432
|
...stored.failure ? { failure: stored.failure } : {},
|
|
4423
4433
|
...stored.claimFailure ? { claimFailure: stored.claimFailure } : {},
|
|
4424
4434
|
...stored.blockedReason ? { blockedReason: stored.blockedReason } : {}
|
|
@@ -4437,6 +4447,7 @@ function shouldRetainRfqSwap(record, now) {
|
|
|
4437
4447
|
|
|
4438
4448
|
// src/swapManager.ts
|
|
4439
4449
|
var import_base15 = require("@scure/base");
|
|
4450
|
+
var import_sdk21 = require("@arkade-os/sdk");
|
|
4440
4451
|
init_onchainHtlc();
|
|
4441
4452
|
init_lockupContract();
|
|
4442
4453
|
function nextOnchainAction(input) {
|
|
@@ -4935,6 +4946,7 @@ var RfqSwapManager = class {
|
|
|
4935
4946
|
});
|
|
4936
4947
|
return;
|
|
4937
4948
|
}
|
|
4949
|
+
if (!(0, import_sdk21.isContractVtxoEvent)(event)) return;
|
|
4938
4950
|
const swap = this.byLockupScript.get(event.contractScript);
|
|
4939
4951
|
if (!swap) return;
|
|
4940
4952
|
void this.pollSwap(swap).catch(() => {
|
|
@@ -5008,6 +5020,7 @@ var RfqSwapManager = class {
|
|
|
5008
5020
|
* script for its whole life. Best-effort — the swap is over either way. */
|
|
5009
5021
|
retireContract(swap) {
|
|
5010
5022
|
if (!this.deps.contracts || !this.registered.get(swap.rfqId)) return;
|
|
5023
|
+
if (!LOCKUP_RETIRABLE.includes(swap.state)) return;
|
|
5011
5024
|
void this.deps.contracts.setContractWatchState(import_base15.hex.encode(swap.lockupPkScript), "retained").catch((error) => this.emitFailed(swap, error));
|
|
5012
5025
|
}
|
|
5013
5026
|
arm() {
|
|
@@ -5047,6 +5060,7 @@ var RfqSwapManager = class {
|
|
|
5047
5060
|
}
|
|
5048
5061
|
if (fate.fate === "claimed" || fate.fate === "returned") {
|
|
5049
5062
|
this.stampLockupSpends(swap, fate.spends);
|
|
5063
|
+
if (fate.fate === "claimed") this.stampSettlementPreimage(swap, fate.preimage);
|
|
5050
5064
|
this.setState(swap, fate.fate === "claimed" ? "settled" : "refunded");
|
|
5051
5065
|
return;
|
|
5052
5066
|
}
|
|
@@ -5345,6 +5359,19 @@ var RfqSwapManager = class {
|
|
|
5345
5359
|
swap.lockupSpendTxids = txids;
|
|
5346
5360
|
this.touch(swap);
|
|
5347
5361
|
}
|
|
5362
|
+
/**
|
|
5363
|
+
* Keep the preimage that settled a Lightning send.
|
|
5364
|
+
*
|
|
5365
|
+
* Only that leg. A receive's `claimed` verdict reveals the wallet's own
|
|
5366
|
+
* claim secret and an onchain send's reveals the one it minted — both
|
|
5367
|
+
* already recoverable from `profile`, so stamping either would be a second
|
|
5368
|
+
* home for a secret that has one.
|
|
5369
|
+
*/
|
|
5370
|
+
stampSettlementPreimage(swap, preimage) {
|
|
5371
|
+
if (swap.kind !== "lightning_send") return;
|
|
5372
|
+
swap.settlementPreimageHex = import_base15.hex.encode(preimage);
|
|
5373
|
+
this.touch(swap);
|
|
5374
|
+
}
|
|
5348
5375
|
touch(swap) {
|
|
5349
5376
|
swap.updatedAt = this.config.now();
|
|
5350
5377
|
this.dirty.add(swap.rfqId);
|
|
@@ -5480,7 +5507,7 @@ var outpointKey = (vtxo) => `${vtxo.txid}:${vtxo.vout}`;
|
|
|
5480
5507
|
|
|
5481
5508
|
// src/watch.ts
|
|
5482
5509
|
var import_base16 = require("@scure/base");
|
|
5483
|
-
var
|
|
5510
|
+
var import_sdk22 = require("@arkade-os/sdk");
|
|
5484
5511
|
var TERMINAL = ["fulfilled", "cancelled", "recoverable"];
|
|
5485
5512
|
var assetSwapSource = (repository) => ({
|
|
5486
5513
|
list: () => getAssetSwaps(repository),
|
|
@@ -5512,7 +5539,7 @@ async function watchOfferSwaps({
|
|
|
5512
5539
|
wallet.getAddress(),
|
|
5513
5540
|
wallet.getArkadeReader()
|
|
5514
5541
|
]);
|
|
5515
|
-
const operatorPubkey =
|
|
5542
|
+
const operatorPubkey = import_sdk22.ArkAddress.decode(address).serverPubKey;
|
|
5516
5543
|
let queue = Promise.resolve();
|
|
5517
5544
|
const enqueue = (task) => {
|
|
5518
5545
|
queue = queue.then(task).catch(() => {
|
|
@@ -5527,7 +5554,7 @@ async function watchOfferSwaps({
|
|
|
5527
5554
|
return classifyDepositSpend(
|
|
5528
5555
|
decodeOffer(import_base16.hex.decode(swap.offerHex)),
|
|
5529
5556
|
operatorPubkey,
|
|
5530
|
-
txs.map((psbt) =>
|
|
5557
|
+
txs.map((psbt) => import_sdk22.Transaction.fromPSBT(import_base16.base64.decode(psbt))),
|
|
5531
5558
|
{ txid: vtxo.txid, vout: vtxo.vout }
|
|
5532
5559
|
);
|
|
5533
5560
|
} catch {
|
|
@@ -5555,7 +5582,7 @@ async function watchOfferSwaps({
|
|
|
5555
5582
|
}
|
|
5556
5583
|
};
|
|
5557
5584
|
const unsubscribe = manager.onContractEvent((event) => {
|
|
5558
|
-
if (event.type !== "vtxo_spent") return;
|
|
5585
|
+
if (!(0, import_sdk22.isContractVtxoEvent)(event) || event.type !== "vtxo_spent") return;
|
|
5559
5586
|
enqueue(() => handleSpend(event));
|
|
5560
5587
|
});
|
|
5561
5588
|
return {
|
|
@@ -5738,7 +5765,7 @@ var createSwapDrive = (config) => {
|
|
|
5738
5765
|
const secret = rfqClaimSecretOf(record);
|
|
5739
5766
|
if (!secret) throw new Error(`rfq swap ${swap.rfqId} carries no claim secret`);
|
|
5740
5767
|
const preimage = await preimageForSwapRecord(wallet, secret);
|
|
5741
|
-
const signer = await (0,
|
|
5768
|
+
const signer = await (0, import_sdk23.contractSigner)(wallet, await (0, import_sdk23.identityDescriptor)(wallet.identity));
|
|
5742
5769
|
const claimKey = record.profile.claimKey;
|
|
5743
5770
|
if (typeof claimKey === "string") {
|
|
5744
5771
|
const held = import_base17.hex.encode(await signer.xOnlyPublicKey());
|
|
@@ -5796,10 +5823,10 @@ var createSwapDrive = (config) => {
|
|
|
5796
5823
|
return track(
|
|
5797
5824
|
pushClaim(operator, {
|
|
5798
5825
|
contract: script,
|
|
5799
|
-
receiver: await (0,
|
|
5826
|
+
receiver: await (0, import_sdk23.contractSigner)(wallet, secret.signingDescriptor),
|
|
5800
5827
|
preimage: await preimageForSwapRecord(wallet, secret),
|
|
5801
5828
|
vtxos,
|
|
5802
|
-
destinationPkScript:
|
|
5829
|
+
destinationPkScript: import_sdk23.ArkAddress.decode(payoutAddress).pkScript,
|
|
5803
5830
|
// Passed straight through, both of them: the manager's own value
|
|
5804
5831
|
// check decides WHEN to act, `pushClaim`'s decides whether `P` is
|
|
5805
5832
|
// published, and it is the one with nothing between it and the
|
|
@@ -5879,7 +5906,7 @@ var createSwapDrive = (config) => {
|
|
|
5879
5906
|
...tx.createdAt ? { createdAt: Math.floor(tx.createdAt / 1e3) } : {}
|
|
5880
5907
|
}));
|
|
5881
5908
|
const { restored, scannedTxids } = await restoreAssetSwaps(indexer, txs, /* @__PURE__ */ new Set(), {
|
|
5882
|
-
operatorPubkey:
|
|
5909
|
+
operatorPubkey: import_sdk23.ArkAddress.decode(address).serverPubKey,
|
|
5883
5910
|
scanned
|
|
5884
5911
|
});
|
|
5885
5912
|
const byDeposit = new Map(restored.map((s) => [`${s.swapPkScript}:${s.fundingTxid}`, s]));
|
|
@@ -6151,7 +6178,7 @@ var usableMarkets = (snapshot, policy) => {
|
|
|
6151
6178
|
const allowed = policy?.allowedRegistries;
|
|
6152
6179
|
return (allowed ? snapshot.markets.filter((card) => allowed.includes(card.source)) : snapshot.markets).filter(isAddressable);
|
|
6153
6180
|
};
|
|
6154
|
-
var eligibleMarkets = (snapshot, legs, policy) => {
|
|
6181
|
+
var eligibleMarkets = (snapshot, legs, policy, takeAmount) => {
|
|
6155
6182
|
const markets = usableMarkets(snapshot, policy);
|
|
6156
6183
|
const { give, take } = legs;
|
|
6157
6184
|
if (give.corridor === take.corridor && give.assetId === take.assetId) return [];
|
|
@@ -6165,7 +6192,8 @@ var eligibleMarkets = (snapshot, legs, policy) => {
|
|
|
6165
6192
|
quoteCorridor: quote.corridor,
|
|
6166
6193
|
// The trader receives the take leg, so that side must be one the
|
|
6167
6194
|
// solver can pay out; a direction nobody solves yields no market.
|
|
6168
|
-
wantSide: side === "base" ? "quote" : "base"
|
|
6195
|
+
wantSide: side === "base" ? "quote" : "base",
|
|
6196
|
+
...takeAmount === void 0 ? {} : { wantAmount: takeAmount }
|
|
6169
6197
|
}).map((card) => ({
|
|
6170
6198
|
card,
|
|
6171
6199
|
give: side,
|
|
@@ -6281,7 +6309,12 @@ var resolveRoute = async (input, deps) => {
|
|
|
6281
6309
|
claimed?.instrument ?? (takeLeg.corridor === "arkade" ? { kind: "wallet" } : void 0)
|
|
6282
6310
|
);
|
|
6283
6311
|
const amount = pinAmount(input, take.instrument);
|
|
6284
|
-
const candidates = eligibleMarkets(
|
|
6312
|
+
const candidates = eligibleMarkets(
|
|
6313
|
+
snapshot,
|
|
6314
|
+
{ give: giveLeg, take: takeLeg },
|
|
6315
|
+
deps.policy,
|
|
6316
|
+
amount?.on === "take" ? amount.value : void 0
|
|
6317
|
+
);
|
|
6285
6318
|
const market = chooseMarket(candidates, deps.policy);
|
|
6286
6319
|
const resolution = {
|
|
6287
6320
|
give,
|
|
@@ -6572,17 +6605,17 @@ var verifyPlanLegs = (plan, legs, give) => {
|
|
|
6572
6605
|
// src/client/quoteRfq.ts
|
|
6573
6606
|
var import_base18 = require("@scure/base");
|
|
6574
6607
|
var import_secp256k12 = require("@noble/curves/secp256k1.js");
|
|
6575
|
-
var
|
|
6608
|
+
var import_sdk26 = require("@arkade-os/sdk");
|
|
6576
6609
|
init_claimPacket();
|
|
6577
6610
|
init_onchainHtlc();
|
|
6578
6611
|
init_onchainHtlc();
|
|
6579
6612
|
|
|
6580
6613
|
// src/payment/onchainSwap.ts
|
|
6581
|
-
var
|
|
6614
|
+
var import_sdk25 = require("@arkade-os/sdk");
|
|
6582
6615
|
init_onchainHtlc();
|
|
6583
6616
|
|
|
6584
6617
|
// src/payment/swapRail.ts
|
|
6585
|
-
var
|
|
6618
|
+
var import_sdk24 = require("@arkade-os/sdk");
|
|
6586
6619
|
|
|
6587
6620
|
// src/client/sats.ts
|
|
6588
6621
|
var satsOf = (value, field) => {
|
|
@@ -6633,14 +6666,14 @@ var parseRfqQuote = (quote) => ({
|
|
|
6633
6666
|
|
|
6634
6667
|
// src/client/quoteRfq.ts
|
|
6635
6668
|
var covenantInputs = (input) => {
|
|
6636
|
-
const network = (0,
|
|
6669
|
+
const network = (0, import_sdk26.networkFromArkadeInfo)(input.info);
|
|
6637
6670
|
const arkade2 = input.corridors.get("arkade").deps;
|
|
6638
6671
|
return {
|
|
6639
|
-
operatorPubkey: (0,
|
|
6672
|
+
operatorPubkey: (0, import_sdk26.toXOnly)(import_base18.hex.decode(input.info.signerPubkey), "ark signer key"),
|
|
6640
6673
|
// The per-network pin the arkade module already resolved, never a key
|
|
6641
6674
|
// the operator reports about itself: this one ends up in a covenant leaf
|
|
6642
6675
|
// that decides who can move the funds.
|
|
6643
|
-
emulatorPubkey: (0,
|
|
6676
|
+
emulatorPubkey: (0, import_sdk26.toXOnly)(import_base18.hex.decode(arkade2.emulatorPubkey), "emulator signer key"),
|
|
6644
6677
|
claimDelay: unilateralClaimDelay(Number(input.info.unilateralExitDelay)),
|
|
6645
6678
|
hrp: network.hrp
|
|
6646
6679
|
};
|
|
@@ -6686,7 +6719,7 @@ var quoteLightningSend = async (input) => {
|
|
|
6686
6719
|
}
|
|
6687
6720
|
const pair = rfqPairFor(input.legs.give, input.legs.take);
|
|
6688
6721
|
const rfqId = newRfqId();
|
|
6689
|
-
const secrets = await (0,
|
|
6722
|
+
const secrets = await (0, import_sdk26.provisionRefundKey)(input.wallet);
|
|
6690
6723
|
const wire = await input.transport.requestQuote(
|
|
6691
6724
|
lightningSendRequest({
|
|
6692
6725
|
rfqId,
|
|
@@ -6758,7 +6791,7 @@ var quoteLightningReceive = async (input) => {
|
|
|
6758
6791
|
const pinned = pinnedFor(input);
|
|
6759
6792
|
const pair = rfqPairFor(input.legs.give, input.legs.take);
|
|
6760
6793
|
const rfqId = newRfqId();
|
|
6761
|
-
const secrets = await (0,
|
|
6794
|
+
const secrets = await (0, import_sdk26.provisionClaimSecret)(input.wallet);
|
|
6762
6795
|
const paymentHash = import_base18.hex.encode(secrets.paymentHash);
|
|
6763
6796
|
const payoutAddress = await input.wallet.getAddress();
|
|
6764
6797
|
const lightning = input.corridors.get("lightning").deps;
|
|
@@ -6883,8 +6916,8 @@ var quoteOnchainSend = async (input) => {
|
|
|
6883
6916
|
claimVsize: onchain.claimVsize
|
|
6884
6917
|
}) : void 0;
|
|
6885
6918
|
const quoted = claimFee === void 0 ? pinned : { on: pinned.on, value: pinned.value + claimFee, source: pinned.source };
|
|
6886
|
-
const secrets = await (0,
|
|
6887
|
-
const payoutKey = await (0,
|
|
6919
|
+
const secrets = await (0, import_sdk26.provisionClaimSecret)(input.wallet);
|
|
6920
|
+
const payoutKey = await (0, import_sdk26.provisionRefundKey)(input.wallet);
|
|
6888
6921
|
const paymentHash = import_base18.hex.encode(secrets.paymentHash);
|
|
6889
6922
|
const wire = await input.transport.requestQuote(
|
|
6890
6923
|
withCanonicalAmount(
|
|
@@ -6991,7 +7024,7 @@ var quoteOnchainSend = async (input) => {
|
|
|
6991
7024
|
};
|
|
6992
7025
|
|
|
6993
7026
|
// src/client/verbs.ts
|
|
6994
|
-
var
|
|
7027
|
+
var import_sdk27 = require("@arkade-os/sdk");
|
|
6995
7028
|
var enforceFeeCeiling = (quote, call, policy) => {
|
|
6996
7029
|
let ceiling;
|
|
6997
7030
|
for (const [source, limit] of [
|
|
@@ -7016,9 +7049,9 @@ var settle = async (deps, input, maxFee) => {
|
|
|
7016
7049
|
return deps.accept(quote);
|
|
7017
7050
|
};
|
|
7018
7051
|
var pay = async (deps, destination, options = {}) => {
|
|
7019
|
-
const arkade2 = (0,
|
|
7052
|
+
const arkade2 = (0, import_sdk27.arkTarget)(destination);
|
|
7020
7053
|
if (arkade2 !== void 0) {
|
|
7021
|
-
const amount = (0,
|
|
7054
|
+
const amount = (0, import_sdk27.resolveSendAmount)(
|
|
7022
7055
|
"ark",
|
|
7023
7056
|
destination,
|
|
7024
7057
|
options.amount === void 0 ? void 0 : satsOf(options.amount, "amount")
|
|
@@ -7333,6 +7366,129 @@ var createSwapClient = (config) => {
|
|
|
7333
7366
|
};
|
|
7334
7367
|
return client;
|
|
7335
7368
|
};
|
|
7369
|
+
|
|
7370
|
+
// src/reveal.ts
|
|
7371
|
+
var import_base20 = require("@scure/base");
|
|
7372
|
+
var import_legacy4 = require("@noble/hashes/legacy.js");
|
|
7373
|
+
var import_sha26 = require("@noble/hashes/sha2.js");
|
|
7374
|
+
var import_sdk28 = require("@arkade-os/sdk");
|
|
7375
|
+
init_claimPacket();
|
|
7376
|
+
var CovclaimdRevealError = class extends Error {
|
|
7377
|
+
name = "CovclaimdRevealError";
|
|
7378
|
+
status;
|
|
7379
|
+
detail;
|
|
7380
|
+
retryable;
|
|
7381
|
+
constructor(what, status, detail) {
|
|
7382
|
+
super(`covclaimd ${what} failed: ${status || "no response"} ${detail}`.trimEnd());
|
|
7383
|
+
this.status = status;
|
|
7384
|
+
this.detail = detail;
|
|
7385
|
+
this.retryable = status === 0 || status === 429 || status >= 500;
|
|
7386
|
+
}
|
|
7387
|
+
};
|
|
7388
|
+
var decodeKey = (value, field) => {
|
|
7389
|
+
if (typeof value !== "string") throw new Error(`covclaimd info: ${field} is not a string`);
|
|
7390
|
+
let bytes;
|
|
7391
|
+
try {
|
|
7392
|
+
bytes = import_base20.hex.decode(value);
|
|
7393
|
+
} catch {
|
|
7394
|
+
throw new Error(`covclaimd info: ${field} is not hex`);
|
|
7395
|
+
}
|
|
7396
|
+
if (bytes.length !== 33) {
|
|
7397
|
+
throw new Error(`covclaimd info: ${field} must be 33-byte compressed, got ${bytes.length}`);
|
|
7398
|
+
}
|
|
7399
|
+
return bytes;
|
|
7400
|
+
};
|
|
7401
|
+
var LOOPBACK = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
7402
|
+
var assertTransportSecure = (baseUrl, allowInsecureHttp) => {
|
|
7403
|
+
const { protocol, hostname } = new URL(baseUrl);
|
|
7404
|
+
if (protocol === "https:" || allowInsecureHttp) return;
|
|
7405
|
+
if (protocol === "http:" && LOOPBACK.has(hostname)) return;
|
|
7406
|
+
throw new Error(
|
|
7407
|
+
`covclaimd URL must be https (got ${protocol}//${hostname}): the key it serves is the one the preimage gets sealed to. Pass allowInsecureHttp to override.`
|
|
7408
|
+
);
|
|
7409
|
+
};
|
|
7410
|
+
var covclaimdClient = (baseUrl, options = {}) => {
|
|
7411
|
+
assertTransportSecure(baseUrl, options.allowInsecureHttp === true);
|
|
7412
|
+
const url = baseUrl.replace(/\/+$/, "");
|
|
7413
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
7414
|
+
const timeoutMs = options.timeoutMs ?? 3e4;
|
|
7415
|
+
const send = async (what, path, init) => {
|
|
7416
|
+
let response;
|
|
7417
|
+
try {
|
|
7418
|
+
response = await fetchImpl(`${url}${path}`, {
|
|
7419
|
+
...init,
|
|
7420
|
+
// a redirect would move the key fetch off the vetted origin
|
|
7421
|
+
redirect: "error",
|
|
7422
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
7423
|
+
});
|
|
7424
|
+
} catch (error) {
|
|
7425
|
+
throw new CovclaimdRevealError(what, 0, String(error));
|
|
7426
|
+
}
|
|
7427
|
+
if (!response.ok) {
|
|
7428
|
+
throw new CovclaimdRevealError(what, response.status, await response.text());
|
|
7429
|
+
}
|
|
7430
|
+
return response;
|
|
7431
|
+
};
|
|
7432
|
+
const readJson = async (what, response) => {
|
|
7433
|
+
const body = await response.text();
|
|
7434
|
+
try {
|
|
7435
|
+
return JSON.parse(body);
|
|
7436
|
+
} catch {
|
|
7437
|
+
throw new CovclaimdRevealError(
|
|
7438
|
+
what,
|
|
7439
|
+
response.status,
|
|
7440
|
+
`non-JSON body: ${body.slice(0, 200)}`
|
|
7441
|
+
);
|
|
7442
|
+
}
|
|
7443
|
+
};
|
|
7444
|
+
return {
|
|
7445
|
+
async info() {
|
|
7446
|
+
const response = await send("info", "/v1/preimage/covclaimd-pubkey", {
|
|
7447
|
+
method: "GET"
|
|
7448
|
+
});
|
|
7449
|
+
const body = await readJson("info", response);
|
|
7450
|
+
return {
|
|
7451
|
+
covclaimdPubkey: decodeKey(body?.covclaimd_pub_key, "covclaimd_pub_key"),
|
|
7452
|
+
emulatorPubkey: import_base20.hex.encode(decodeKey(body?.emulator_pub_key, "emulator_pub_key"))
|
|
7453
|
+
};
|
|
7454
|
+
},
|
|
7455
|
+
async reveal(params) {
|
|
7456
|
+
await send("reveal", "/v1/reveal", {
|
|
7457
|
+
method: "POST",
|
|
7458
|
+
headers: { "content-type": "application/json" },
|
|
7459
|
+
body: JSON.stringify({
|
|
7460
|
+
swap_address: params.swapAddress,
|
|
7461
|
+
packet: { ciphertext: params.ciphertext, arkade_script: params.arkadeScript },
|
|
7462
|
+
taptree: params.taptree
|
|
7463
|
+
})
|
|
7464
|
+
});
|
|
7465
|
+
}
|
|
7466
|
+
};
|
|
7467
|
+
};
|
|
7468
|
+
function revealFieldsFromScript(script) {
|
|
7469
|
+
if (!script.nonInteractiveClaimArkadeScript) {
|
|
7470
|
+
throw new Error("this covenant has no non-interactive claim leaf to reveal against");
|
|
7471
|
+
}
|
|
7472
|
+
return {
|
|
7473
|
+
arkadeScript: import_base20.base64.encode(script.nonInteractiveClaimArkadeScript),
|
|
7474
|
+
taptree: import_base20.hex.encode(script.encode())
|
|
7475
|
+
};
|
|
7476
|
+
}
|
|
7477
|
+
async function revealClaimPacket(client, input) {
|
|
7478
|
+
const fields = revealFieldsFromScript(input.script);
|
|
7479
|
+
if (import_base20.hex.encode(import_sdk28.ArkAddress.decode(input.address).pkScript) !== import_base20.hex.encode(input.script.pkScript)) {
|
|
7480
|
+
throw new Error("address does not belong to this covenant");
|
|
7481
|
+
}
|
|
7482
|
+
if (import_base20.hex.encode((0, import_legacy4.ripemd160)((0, import_sha26.sha256)(input.preimage))) !== import_base20.hex.encode(input.script.options.preimageHash)) {
|
|
7483
|
+
throw new Error("preimage does not match the covenant's payment hash");
|
|
7484
|
+
}
|
|
7485
|
+
const { ciphertext } = await sealClaimPacket({
|
|
7486
|
+
preimage: input.preimage,
|
|
7487
|
+
covclaimdPubkey: (await client.info()).covclaimdPubkey
|
|
7488
|
+
});
|
|
7489
|
+
await client.reveal({ swapAddress: input.address, ciphertext, ...fields });
|
|
7490
|
+
return { ciphertext };
|
|
7491
|
+
}
|
|
7336
7492
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7337
7493
|
0 && (module.exports = {
|
|
7338
7494
|
ACTIVITY_TOKEN,
|
|
@@ -7350,6 +7506,7 @@ var createSwapClient = (config) => {
|
|
|
7350
7506
|
CORRIDOR_FACTORIES,
|
|
7351
7507
|
CORRIDOR_PASS,
|
|
7352
7508
|
ClientDisposed,
|
|
7509
|
+
CovclaimdRevealError,
|
|
7353
7510
|
DEFAULT_INVOICE_EXPIRY_SECONDS,
|
|
7354
7511
|
DiscoverySnapshotUnavailable,
|
|
7355
7512
|
FEED_TTL_MS,
|
|
@@ -7397,6 +7554,7 @@ var createSwapClient = (config) => {
|
|
|
7397
7554
|
corridorOutcome,
|
|
7398
7555
|
corridorRecordStore,
|
|
7399
7556
|
corridorSet,
|
|
7557
|
+
covclaimdClient,
|
|
7400
7558
|
createSwapClient,
|
|
7401
7559
|
createSwapDrive,
|
|
7402
7560
|
decodeBolt11,
|
|
@@ -7456,6 +7614,8 @@ var createSwapClient = (config) => {
|
|
|
7456
7614
|
resolveCorridorBase,
|
|
7457
7615
|
resolveCorridorDeps,
|
|
7458
7616
|
resolveRoute,
|
|
7617
|
+
revealClaimPacket,
|
|
7618
|
+
revealFieldsFromScript,
|
|
7459
7619
|
rfqLeg,
|
|
7460
7620
|
rfqPairFor,
|
|
7461
7621
|
rfqRecordOf,
|
package/dist/advanced.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { A as AssetAliasTable, C as CorridorFactory, a as ArkadeCorridorDeps, L as LightningCorridorDeps, O as OnchainCorridorDeps, b as CorridorSet, D as DiscoveryIndex, S as SwapPolicy, c as DiscoveryLeg, M as MarketCandidate, d as DiscoverySnapshot } from './errors-
|
|
2
|
-
export { e as AcceptConflict, f as AcceptInput, g as AmbiguousDestination, h as AmountEncodingUnsupported, i as AmountMismatch, j as AttestingRfqTransport, k as CORRIDOR_FACTORIES, l as CancelInput, m as CancelOutcome, n as ClaimedDestination, o as ClientDisposed, p as CorridorBase, q as CorridorClaim, r as CorridorCovenant, s as CorridorDeadline, t as CorridorDeps, u as CorridorDepsByCorridor, v as CorridorDrive, w as CorridorLockup, x as CorridorModule, y as CorridorOverrides, z as CorridorPass, B as DiscoveryConfig, E as DiscoveryIndexInput, F as DiscoverySnapshotUnavailable, G as DriveMode, H as DriveRefusal, I as ExchangeOptions, J as FEED_TTL_MS, K as FeeCeiling, N as FeedFetch, P as FeedQuoteInput, Q as INDEXED_NETWORKS, R as InconsistentRoute, T as InsufficientFunds, U as LockupOwner, V as Market, W as MaxFeeExceeded, X as MissingCorridorDep, Y as NotCancellable, Z as ONCHAIN_CLAIM_FEE_RATE_SATVB, _ as ObservationSeam, $ as OfferPreparation, a0 as OnchainClaim, a1 as OperatorUnreachable, a2 as ParsedRfqQuote, a3 as PayOptions, a4 as PayResult, a5 as QuoteCheck, a6 as QuoteExpired, a7 as QuotePreparation, a8 as QuoteVerificationFailed, a9 as REGISTRY_URL, aa as ReceiveArtifact, ab as ReceiveOptions, ac as ReceiveRequest, ad as RecoveryResult, ae as RegisteredAsset, af as RfqAuctionPolicy, ag as RfqPreparation, ah as RfqQuoteInput, ai as RfqRendezvous, aj as RfqTransportFactory, ak as RouteSide, al as SWAP_ERROR_NAMES, am as SwapClient, an as SwapClientConfig, ao as SwapDrive, ap as SwapDriveConfig, aq as SwapDriveRefusedError, ar as SwapError, as as SwapErrorName, at as SwapFilter, au as UnsupportedRoute, av as VerbDeps, aw as acceptQuote, ax as attesting, ay as cancelSwap, az as canonicalAssetId, aA as cardMarketOf, aB as chooseMarket, aC as conflictingFields, aD as corridorSet, aE as createSwapClient, aF as createSwapDrive, aG as discoveryIndex, aH as eligibleMarkets, aI as enforceFeeCeiling, aJ as exchange, aK as feedFetch, aL as isAddressable, aM as isCardMarket, aN as isIndexedNetwork, aO as isSwapError, aP as isUsableCard, aQ as liveArkadeInfo, aR as marketBackendOf, aS as marketKeyOf, aT as marketRefOf, aU as nostrTransportFactory, aV as parseRfqQuote, aW as pay, aX as quoteFromFeed, aY as quoteViaRfq, aZ as readableRecord, a_ as receive, a$ as resolveCorridorBase, b0 as resolveCorridorDeps, b1 as rfqLeg, b2 as rfqPairFor, b3 as swapRecordOf, b4 as toDiscoveryLeg, b5 as usableMarkets, b6 as withCanonicalAmount } from './errors-
|
|
1
|
+
import { A as AssetAliasTable, C as CorridorFactory, a as ArkadeCorridorDeps, L as LightningCorridorDeps, O as OnchainCorridorDeps, b as CorridorSet, D as DiscoveryIndex, S as SwapPolicy, c as DiscoveryLeg, M as MarketCandidate, d as DiscoverySnapshot } from './errors-DUTOiyH2.cjs';
|
|
2
|
+
export { e as AcceptConflict, f as AcceptInput, g as AmbiguousDestination, h as AmountEncodingUnsupported, i as AmountMismatch, j as AttestingRfqTransport, k as CORRIDOR_FACTORIES, l as CancelInput, m as CancelOutcome, n as ClaimedDestination, o as ClientDisposed, p as CorridorBase, q as CorridorClaim, r as CorridorCovenant, s as CorridorDeadline, t as CorridorDeps, u as CorridorDepsByCorridor, v as CorridorDrive, w as CorridorLockup, x as CorridorModule, y as CorridorOverrides, z as CorridorPass, B as DiscoveryConfig, E as DiscoveryIndexInput, F as DiscoverySnapshotUnavailable, G as DriveMode, H as DriveRefusal, I as ExchangeOptions, J as FEED_TTL_MS, K as FeeCeiling, N as FeedFetch, P as FeedQuoteInput, Q as INDEXED_NETWORKS, R as InconsistentRoute, T as InsufficientFunds, U as LockupOwner, V as Market, W as MaxFeeExceeded, X as MissingCorridorDep, Y as NotCancellable, Z as ONCHAIN_CLAIM_FEE_RATE_SATVB, _ as ObservationSeam, $ as OfferPreparation, a0 as OnchainClaim, a1 as OperatorUnreachable, a2 as ParsedRfqQuote, a3 as PayOptions, a4 as PayResult, a5 as QuoteCheck, a6 as QuoteExpired, a7 as QuotePreparation, a8 as QuoteVerificationFailed, a9 as REGISTRY_URL, aa as ReceiveArtifact, ab as ReceiveOptions, ac as ReceiveRequest, ad as RecoveryResult, ae as RegisteredAsset, af as RfqAuctionPolicy, ag as RfqPreparation, ah as RfqQuoteInput, ai as RfqRendezvous, aj as RfqTransportFactory, ak as RouteSide, al as SWAP_ERROR_NAMES, am as SwapClient, an as SwapClientConfig, ao as SwapDrive, ap as SwapDriveConfig, aq as SwapDriveRefusedError, ar as SwapError, as as SwapErrorName, at as SwapFilter, au as UnsupportedRoute, av as VerbDeps, aw as acceptQuote, ax as attesting, ay as cancelSwap, az as canonicalAssetId, aA as cardMarketOf, aB as chooseMarket, aC as conflictingFields, aD as corridorSet, aE as createSwapClient, aF as createSwapDrive, aG as discoveryIndex, aH as eligibleMarkets, aI as enforceFeeCeiling, aJ as exchange, aK as feedFetch, aL as isAddressable, aM as isCardMarket, aN as isIndexedNetwork, aO as isSwapError, aP as isUsableCard, aQ as liveArkadeInfo, aR as marketBackendOf, aS as marketKeyOf, aT as marketRefOf, aU as nostrTransportFactory, aV as parseRfqQuote, aW as pay, aX as quoteFromFeed, aY as quoteViaRfq, aZ as readableRecord, a_ as receive, a$ as resolveCorridorBase, b0 as resolveCorridorDeps, b1 as rfqLeg, b2 as rfqPairFor, b3 as swapRecordOf, b4 as toDiscoveryLeg, b5 as usableMarkets, b6 as withCanonicalAmount } from './errors-DUTOiyH2.cjs';
|
|
3
3
|
import { DiscoveredMarket } from '@arkade-os/solver-discovery';
|
|
4
|
-
import { N as NetworkRef, C as Corridor, A as AssetId, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, S as SwapRecord, O as OfferSwapRecord, c as AssetSwapRepository, d as RfqSwapRecord, L as LockupSpendIndexer, e as AssetSwapStatus, f as RouteResolution, g as ResolvedEndpoint, P as PinnedAmount, I as Instrument, h as Route, i as QuoteInput, j as Pubkey } from './repository-
|
|
5
|
-
export { k as ACTIVITY_TOKEN, l as ARKADE_ASSET_NAMESPACE, m as Amount, n as AmountFormatError, o as AmountOn, p as AmountRefusal, q as Artifact, r as AssetIdError, s as AssetIdRefusal, t as AssetNamespace, u as AssetOn, v as AssetPart, w as AssetRef, x as AssetScale, y as AssetSwapId, z as AtomicDecimal, B as AuctionMarketRef, D as AuctionProvenance, E as BITCOIN_RAILS, F as BTC_ASSET_PART, G as BitcoinRail, H as CORRIDORS, J as CORRIDOR_PASS, K as CardMarketRef, M as CorridorId, T as CorridorKind, U as DepositArtifact, V as DisplayDecimal, W as Endpoint, X as Ep, Y as Hex, Z as LOCKUP_OWNER, _ as MarketBackend, $ as MarketRef, a0 as OFFER_SWAP_ID_PREFIX, a1 as Outcome, a2 as ParsedAssetId, a3 as Quote, a4 as QuoteLeg, a5 as RAILS, a6 as RFQ_SWAP_ID_PREFIX, a7 as RailOf, a8 as RankedBid, a9 as RawState, aa as RecordedArtifact, ab as RecordedEndpoint, ac as RecordedInstrument, ad as RecordedLeg, ae as RfqAmountSide, af as SnapshotRef, ag as Swap, ah as SwapFamily, ai as SwapRecordCommon, aj as SwapUpdate, ak as Unsubscribe, al as arkadeAsset, am as artifactOf, an as assetPartOf, ao as assetSwapIdOf, ap as bitcoinNetworkOf, aq as btcOn, ar as corridorOfRail, as as corridorOutcome, at as decodeRfqAmount, au as encodeRfqAmount, av as familyOfSwapId, aw as formatAssetId, ax as fromAtomicDecimal, ay as fromRfqAmountSide, az as fundsFromWallet, aA as instrumentOf, aB as isAssetId, aC as isAtomicDecimal, aD as isNetworkRef, aE as issuanceOf, aF as legOf, aG as offerOutcome, aH as parseAssetId, aI as quoteIdOfSwapId, aJ as railOf, aK as railOfCorridor, aL as readsChain, aM as recordArtifact, aN as recordEndpoint, aO as recordInstrument, aP as recordLeg, aQ as recordOutcome, aR as sameAsset, aS as swapOf, aT as toAtomicDecimal, aU as toRfqAmountSide, aV as toSafeNumber } from './repository-
|
|
6
|
-
import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-
|
|
7
|
-
export { S as SwapRefusal } from './rfq-
|
|
4
|
+
import { N as NetworkRef, C as Corridor, A as AssetId, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, S as SwapRecord, O as OfferSwapRecord, c as AssetSwapRepository, d as RfqSwapRecord, L as LockupSpendIndexer, e as AssetSwapStatus, f as RouteResolution, g as ResolvedEndpoint, P as PinnedAmount, I as Instrument, h as Route, i as QuoteInput, j as Pubkey } from './repository-CDlK003C.cjs';
|
|
5
|
+
export { k as ACTIVITY_TOKEN, l as ARKADE_ASSET_NAMESPACE, m as Amount, n as AmountFormatError, o as AmountOn, p as AmountRefusal, q as Artifact, r as AssetIdError, s as AssetIdRefusal, t as AssetNamespace, u as AssetOn, v as AssetPart, w as AssetRef, x as AssetScale, y as AssetSwapId, z as AtomicDecimal, B as AuctionMarketRef, D as AuctionProvenance, E as BITCOIN_RAILS, F as BTC_ASSET_PART, G as BitcoinRail, H as CORRIDORS, J as CORRIDOR_PASS, K as CardMarketRef, M as CorridorId, T as CorridorKind, U as DepositArtifact, V as DisplayDecimal, W as Endpoint, X as Ep, Y as Hex, Z as LOCKUP_OWNER, _ as MarketBackend, $ as MarketRef, a0 as OFFER_SWAP_ID_PREFIX, a1 as Outcome, a2 as ParsedAssetId, a3 as Quote, a4 as QuoteLeg, a5 as RAILS, a6 as RFQ_SWAP_ID_PREFIX, a7 as RailOf, a8 as RankedBid, a9 as RawState, aa as RecordedArtifact, ab as RecordedEndpoint, ac as RecordedInstrument, ad as RecordedLeg, ae as RfqAmountSide, af as SnapshotRef, ag as Swap, ah as SwapFamily, ai as SwapRecordCommon, aj as SwapUpdate, ak as Unsubscribe, al as arkadeAsset, am as artifactOf, an as assetPartOf, ao as assetSwapIdOf, ap as bitcoinNetworkOf, aq as btcOn, ar as corridorOfRail, as as corridorOutcome, at as decodeRfqAmount, au as encodeRfqAmount, av as familyOfSwapId, aw as formatAssetId, ax as fromAtomicDecimal, ay as fromRfqAmountSide, az as fundsFromWallet, aA as instrumentOf, aB as isAssetId, aC as isAtomicDecimal, aD as isNetworkRef, aE as issuanceOf, aF as legOf, aG as offerOutcome, aH as parseAssetId, aI as quoteIdOfSwapId, aJ as railOf, aK as railOfCorridor, aL as readsChain, aM as recordArtifact, aN as recordEndpoint, aO as recordInstrument, aP as recordLeg, aQ as recordOutcome, aR as sameAsset, aS as swapOf, aT as toAtomicDecimal, aU as toRfqAmountSide, aV as toSafeNumber } from './repository-CDlK003C.cjs';
|
|
6
|
+
import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-RONK76D7.cjs';
|
|
7
|
+
export { S as SwapRefusal } from './rfq-RONK76D7.cjs';
|
|
8
8
|
import * as btc from '@scure/btc-signer';
|
|
9
|
-
import { OnchainProvider, NetworkName, IWallet } from '@arkade-os/sdk';
|
|
10
|
-
import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-
|
|
9
|
+
import { OnchainProvider, NetworkName, IWallet, VHTLC } from '@arkade-os/sdk';
|
|
10
|
+
import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-JawNDXBr.cjs';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* The alias table, filled from discovery.
|
|
@@ -583,4 +583,75 @@ declare const verifyQuotedAmount: (input: {
|
|
|
583
583
|
readonly take: bigint;
|
|
584
584
|
}) => void;
|
|
585
585
|
|
|
586
|
-
|
|
586
|
+
/**
|
|
587
|
+
* `retryable` is the point of the type: a 400 says the packet does not bind to
|
|
588
|
+
* this address at this daemon — wrong key, script or taptree — and retrying
|
|
589
|
+
* changes none of them. Only a full registry (429) and a transport fault (5xx,
|
|
590
|
+
* or `status` 0 for a throwing `fetch`) are worth trying again.
|
|
591
|
+
*/
|
|
592
|
+
declare class CovclaimdRevealError extends Error {
|
|
593
|
+
readonly name = "CovclaimdRevealError";
|
|
594
|
+
readonly status: number;
|
|
595
|
+
readonly detail: string;
|
|
596
|
+
readonly retryable: boolean;
|
|
597
|
+
constructor(what: string, status: number, detail: string);
|
|
598
|
+
}
|
|
599
|
+
interface CovclaimdInfo {
|
|
600
|
+
/** 33-byte compressed — feeds {@link sealClaimPacket} unchanged. */
|
|
601
|
+
covclaimdPubkey: Uint8Array;
|
|
602
|
+
/** Compressed hex — feeds `requestLightningReceive`'s `emulatorPubkey`. */
|
|
603
|
+
emulatorPubkey: string;
|
|
604
|
+
}
|
|
605
|
+
/** The four fields `POST /v1/reveal` takes. */
|
|
606
|
+
interface RevealParams {
|
|
607
|
+
/** The funded lockup's Arkade address, bech32m. */
|
|
608
|
+
swapAddress: string;
|
|
609
|
+
/** `sealClaimPacket(...).ciphertext`, base64. */
|
|
610
|
+
ciphertext: string;
|
|
611
|
+
/** The covenant's `enforcePayTo` ArkadeScript, base64. */
|
|
612
|
+
arkadeScript: string;
|
|
613
|
+
/** The lockup's serialized taptree, hex. */
|
|
614
|
+
taptree: string;
|
|
615
|
+
}
|
|
616
|
+
interface CovclaimdClient {
|
|
617
|
+
info(): Promise<CovclaimdInfo>;
|
|
618
|
+
reveal(params: RevealParams): Promise<void>;
|
|
619
|
+
}
|
|
620
|
+
/** `fetchImpl` is injectable, matching `httpTransport` in `rfq.ts`. */
|
|
621
|
+
declare const covclaimdClient: (baseUrl: string, options?: {
|
|
622
|
+
fetchImpl?: typeof fetch;
|
|
623
|
+
timeoutMs?: number;
|
|
624
|
+
/** Opt out of the TLS requirement — a private network you trust. */
|
|
625
|
+
allowInsecureHttp?: boolean;
|
|
626
|
+
}) => CovclaimdClient;
|
|
627
|
+
/**
|
|
628
|
+
* The two wire fields that are functions of the covenant alone.
|
|
629
|
+
*
|
|
630
|
+
* A client-derived `arkadeScript` can differ from the funder's only if the
|
|
631
|
+
* covenants differ: the script is tweaked into the non-interactive claim leaf's
|
|
632
|
+
* co-signer key, so a different one is a different leaf, root, and lockup
|
|
633
|
+
* address — already covered by the address check made before funding.
|
|
634
|
+
*/
|
|
635
|
+
declare function revealFieldsFromScript(script: InstanceType<typeof VHTLC.ScriptV2>): {
|
|
636
|
+
arkadeScript: string;
|
|
637
|
+
taptree: string;
|
|
638
|
+
};
|
|
639
|
+
/**
|
|
640
|
+
* Seal `P` to the daemon `client` speaks to and register it there, so covclaimd
|
|
641
|
+
* claims the lockup once the solver funds it and the trader can go offline.
|
|
642
|
+
*
|
|
643
|
+
* Registration EXPIRES — covclaimd drops it 15 minutes after the last reveal —
|
|
644
|
+
* and re-revealing refreshes rather than duplicates it, so a caller waiting on
|
|
645
|
+
* a slow funding should reveal again, not once. The two gates below name a
|
|
646
|
+
* cause covclaimd would otherwise report as an opaque 400.
|
|
647
|
+
*/
|
|
648
|
+
declare function revealClaimPacket(client: CovclaimdClient, input: {
|
|
649
|
+
script: InstanceType<typeof VHTLC.ScriptV2>;
|
|
650
|
+
address: string;
|
|
651
|
+
/** `P`, 32 bytes, from the swap's `secrets`. */
|
|
652
|
+
preimage: Uint8Array;
|
|
653
|
+
}): Promise<{
|
|
654
|
+
ciphertext: string;
|
|
655
|
+
}>;
|
|
656
|
+
|
|
657
|
+
export { type AddressParams, ArkadeCorridorDeps, AssetAliasTable, AssetId, type ChainSourceBackend, Corridor, CorridorFactory, type CorridorRecordStore, CorridorSet, CorridorSwapRecord, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, DEFAULT_INVOICE_EXPIRY_SECONDS, DiscoveryIndex, DiscoveryLeg, DiscoverySnapshot, INVOICE_HRPS, Instrument, type L1Tip, LIGHTNING_DRIVE, LightningCorridorDeps, MarketCandidate, NetworkRef, ONCHAIN_DRIVE, OfferSwapRecord, OnchainCorridorDeps, PinnedAmount, Pubkey, QuoteId, QuoteInput, Rail, type RecordSink, type ResolveDeps, ResolvedEndpoint, type ResolvedRoute, type RevealParams, Route, RouteResolution, SwapPolicy, SwapRecord, aliasTableFrom, applyOfferSpend, arkadeCorridor, assembleRoute, chainSourceOver, corridorRecordStore, covclaimdClient, decodeBolt11, esploraChainSource, esploraTip, lightningCorridor, networksOfInvoiceHrp, offerFactsOf, offerRecordSource, onchainCorridor, publicAssetId, resolveRoute, revealClaimPacket, revealFieldsFromScript, rfqRecordOf, satsOf, scopedToRail, splitRecords, verifyPair, verifyQuoteTtl, verifyQuotedAmount, verifyReceiveInvoiceFacts, verifyReceiveWindow, verifyResponder, verifySendInvoice, verifySendWindow, verifyingDerivation, walletLockupIndexer, withOfferStatus, withRfqState };
|