@arkade-os/swap 0.1.0-rc.12 → 0.1.0-rc.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/advanced.cjs +216 -134
- package/dist/advanced.d.cts +28 -10
- package/dist/advanced.d.ts +28 -10
- package/dist/advanced.js +9 -5
- package/dist/{chunk-EYSUBQFB.js → chunk-KRXPQQJ7.js} +29 -9
- package/dist/{chunk-RSUVIWT5.js → chunk-SC3SAY3X.js} +132 -63
- package/dist/{chunk-7DKKTLPB.js → chunk-ZDFMD4FA.js} +47 -38
- package/dist/{errors-Do2Y18da.d.ts → errors-LXMcNhNS.d.ts} +5 -3
- package/dist/{errors-Bg1bbSUK.d.cts → errors-XUs8r0LT.d.cts} +5 -3
- package/dist/index.cjs +241 -163
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +4 -4
- package/dist/{lockupContract-BL2D3js9.d.ts → lockupContract-BhMebZCb.d.cts} +7 -10
- package/dist/{lockupContract-rWaIvZ11.d.cts → lockupContract-CAiN97fX.d.ts} +7 -10
- package/dist/node/index.d.cts +8 -2
- package/dist/node/index.d.ts +8 -2
- package/dist/nostr.d.cts +1 -1
- package/dist/nostr.d.ts +1 -1
- package/dist/nostr.js +1 -1
- package/dist/protocol.cjs +75 -46
- package/dist/protocol.d.cts +18 -11
- package/dist/protocol.d.ts +18 -11
- 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-By-tSjDD.d.ts → repository-BJLuVFQ0.d.ts} +69 -51
- package/dist/{repository-DIZnasB7.d.cts → repository-DsR3b0JJ.d.cts} +69 -51
- package/dist/{rfq-CoGJB3_s.d.cts → rfq-BWE8qkV2.d.cts} +11 -6
- package/dist/{rfq-CoGJB3_s.d.ts → rfq-BWE8qkV2.d.ts} +11 -6
- package/dist/{watch-Coy0_YHu.d.ts → watch-C4ReJR5z.d.cts} +1 -1
- package/dist/{watch-DQaFg3Hd.d.cts → watch-D8Z78RAV.d.ts} +1 -1
- package/package.json +3 -3
package/dist/advanced.cjs
CHANGED
|
@@ -1739,6 +1739,7 @@ __export(advanced_exports, {
|
|
|
1739
1739
|
esploraTip: () => esploraTip,
|
|
1740
1740
|
exchange: () => exchange,
|
|
1741
1741
|
familyOfSwapId: () => familyOfSwapId,
|
|
1742
|
+
fateMoved: () => fateMoved,
|
|
1742
1743
|
feedFetch: () => feedFetch,
|
|
1743
1744
|
formatAssetId: () => formatAssetId,
|
|
1744
1745
|
fromAtomicDecimal: () => fromAtomicDecimal,
|
|
@@ -1786,6 +1787,7 @@ __export(advanced_exports, {
|
|
|
1786
1787
|
resolveCorridorBase: () => resolveCorridorBase,
|
|
1787
1788
|
resolveCorridorDeps: () => resolveCorridorDeps,
|
|
1788
1789
|
resolveRoute: () => resolveRoute,
|
|
1790
|
+
restoredOfferRecord: () => restoredOfferRecord,
|
|
1789
1791
|
revealClaimPacket: () => revealClaimPacket,
|
|
1790
1792
|
revealFieldsFromScript: () => revealFieldsFromScript,
|
|
1791
1793
|
rfqLeg: () => rfqLeg,
|
|
@@ -1813,7 +1815,7 @@ __export(advanced_exports, {
|
|
|
1813
1815
|
verifyingDerivation: () => verifyingDerivation,
|
|
1814
1816
|
walletLockupIndexer: () => walletLockupIndexer,
|
|
1815
1817
|
withCanonicalAmount: () => withCanonicalAmount,
|
|
1816
|
-
|
|
1818
|
+
withDepositFate: () => withDepositFate,
|
|
1817
1819
|
withRfqState: () => withRfqState
|
|
1818
1820
|
});
|
|
1819
1821
|
module.exports = __toCommonJS(advanced_exports);
|
|
@@ -2306,10 +2308,10 @@ var QuoteExpired = class extends Error {
|
|
|
2306
2308
|
name = "QuoteExpired";
|
|
2307
2309
|
};
|
|
2308
2310
|
var MaxFeeExceeded = class extends Error {
|
|
2309
|
-
constructor(quoteId,
|
|
2310
|
-
super(`fee ${fee} of ${
|
|
2311
|
+
constructor(quoteId, asset6, fee, maxFee) {
|
|
2312
|
+
super(`fee ${fee} of ${asset6} exceeds the ${maxFee} ceiling`);
|
|
2311
2313
|
this.quoteId = quoteId;
|
|
2312
|
-
this.asset =
|
|
2314
|
+
this.asset = asset6;
|
|
2313
2315
|
this.fee = fee;
|
|
2314
2316
|
this.maxFee = maxFee;
|
|
2315
2317
|
}
|
|
@@ -2320,11 +2322,11 @@ var MaxFeeExceeded = class extends Error {
|
|
|
2320
2322
|
name = "MaxFeeExceeded";
|
|
2321
2323
|
};
|
|
2322
2324
|
var InsufficientFunds = class extends Error {
|
|
2323
|
-
constructor(
|
|
2325
|
+
constructor(asset6, required, available) {
|
|
2324
2326
|
super(
|
|
2325
|
-
`funding needs ${required} of ${
|
|
2327
|
+
`funding needs ${required} of ${asset6}` + (available === void 0 ? "" : `, wallet holds ${available}`)
|
|
2326
2328
|
);
|
|
2327
|
-
this.asset =
|
|
2329
|
+
this.asset = asset6;
|
|
2328
2330
|
this.required = required;
|
|
2329
2331
|
this.available = available;
|
|
2330
2332
|
}
|
|
@@ -2362,9 +2364,9 @@ var NotCancellable = class extends Error {
|
|
|
2362
2364
|
name = "NotCancellable";
|
|
2363
2365
|
};
|
|
2364
2366
|
var InconsistentRoute = class extends Error {
|
|
2365
|
-
constructor(
|
|
2366
|
-
super(`destination ${JSON.stringify(destination)} is not on ${
|
|
2367
|
-
this.asset =
|
|
2367
|
+
constructor(asset6, destination) {
|
|
2368
|
+
super(`destination ${JSON.stringify(destination)} is not on ${asset6}'s chain`);
|
|
2369
|
+
this.asset = asset6;
|
|
2368
2370
|
this.destination = destination;
|
|
2369
2371
|
}
|
|
2370
2372
|
asset;
|
|
@@ -2417,24 +2419,24 @@ function isSwapError(e, name) {
|
|
|
2417
2419
|
// src/client/aliases.ts
|
|
2418
2420
|
var toDiscoveryLeg = (id) => {
|
|
2419
2421
|
const { rail, assetNamespace, assetReference } = parseAssetId(id);
|
|
2420
|
-
const
|
|
2422
|
+
const asset6 = `${assetNamespace}:${assetReference}`;
|
|
2421
2423
|
if (rail === "arkade") {
|
|
2422
|
-
if (
|
|
2424
|
+
if (asset6 === BTC_ASSET_PART)
|
|
2423
2425
|
return { corridor: "arkade", assetId: BTC_ASSET_ID, marketId: id };
|
|
2424
2426
|
if (assetNamespace === ARKADE_ASSET_NAMESPACE) {
|
|
2425
2427
|
return { corridor: "arkade", assetId: assetReference, marketId: id };
|
|
2426
2428
|
}
|
|
2427
|
-
throw new UnsupportedRoute(`the arkade corridor has no ${
|
|
2429
|
+
throw new UnsupportedRoute(`the arkade corridor has no ${asset6}`);
|
|
2428
2430
|
}
|
|
2429
2431
|
if (rail === "bolt11") {
|
|
2430
|
-
if (
|
|
2432
|
+
if (asset6 === BTC_ASSET_PART)
|
|
2431
2433
|
return { corridor: "lightning", assetId: BTC_ASSET_ID, marketId: id };
|
|
2432
|
-
throw new UnsupportedRoute(`the lightning corridor carries BTC only, not ${
|
|
2434
|
+
throw new UnsupportedRoute(`the lightning corridor carries BTC only, not ${asset6}`);
|
|
2433
2435
|
}
|
|
2434
2436
|
if (rail === "bitcoin") {
|
|
2435
|
-
if (
|
|
2437
|
+
if (asset6 === BTC_ASSET_PART)
|
|
2436
2438
|
return { corridor: "onchain", assetId: BTC_ASSET_ID, marketId: id };
|
|
2437
|
-
throw new UnsupportedRoute(`the onchain corridor carries BTC only, not ${
|
|
2439
|
+
throw new UnsupportedRoute(`the onchain corridor carries BTC only, not ${asset6}`);
|
|
2438
2440
|
}
|
|
2439
2441
|
throw new UnsupportedRoute(`no corridor serves ${id}`);
|
|
2440
2442
|
};
|
|
@@ -2715,8 +2717,8 @@ var Amount = {
|
|
|
2715
2717
|
* result would not survive the record boundary, so one law holds in both
|
|
2716
2718
|
* directions.
|
|
2717
2719
|
*/
|
|
2718
|
-
parse(display,
|
|
2719
|
-
assertDecimals(
|
|
2720
|
+
parse(display, asset6) {
|
|
2721
|
+
assertDecimals(asset6.decimals);
|
|
2720
2722
|
const parts = SCALED_DECIMAL.exec(display);
|
|
2721
2723
|
if (!parts) {
|
|
2722
2724
|
throw new AmountFormatError(
|
|
@@ -2725,17 +2727,17 @@ var Amount = {
|
|
|
2725
2727
|
);
|
|
2726
2728
|
}
|
|
2727
2729
|
const [, whole, fraction = ""] = parts;
|
|
2728
|
-
if (fraction.length >
|
|
2730
|
+
if (fraction.length > asset6.decimals) {
|
|
2729
2731
|
throw new AmountFormatError(
|
|
2730
2732
|
"too_precise",
|
|
2731
|
-
`${display} has more precision than ${
|
|
2733
|
+
`${display} has more precision than ${asset6.decimals} decimals allow`
|
|
2732
2734
|
);
|
|
2733
2735
|
}
|
|
2734
2736
|
if (whole.length + fraction.length > MAX_SIGNIFICANT_DIGITS) {
|
|
2735
2737
|
throw new AmountFormatError("too_large", `${display} has too many digits`);
|
|
2736
2738
|
}
|
|
2737
|
-
const value = (0, import_solver_discovery3.toAtomic)(display,
|
|
2738
|
-
assertRepresentable(value, `${display} at ${
|
|
2739
|
+
const value = (0, import_solver_discovery3.toAtomic)(display, asset6.decimals);
|
|
2740
|
+
assertRepresentable(value, `${display} at ${asset6.decimals} decimals`);
|
|
2739
2741
|
return value;
|
|
2740
2742
|
},
|
|
2741
2743
|
/**
|
|
@@ -2744,13 +2746,13 @@ var Amount = {
|
|
|
2744
2746
|
* Refuses a negative: every amount on this surface is an obligation, and a
|
|
2745
2747
|
* negative one is a defect upstream rather than a number to render.
|
|
2746
2748
|
*/
|
|
2747
|
-
format(value,
|
|
2748
|
-
assertDecimals(
|
|
2749
|
+
format(value, asset6) {
|
|
2750
|
+
assertDecimals(asset6.decimals);
|
|
2749
2751
|
if (value < 0n) {
|
|
2750
2752
|
throw new AmountFormatError("negative", `amount must be non-negative, got ${value}`);
|
|
2751
2753
|
}
|
|
2752
2754
|
assertRepresentable(value, `${value}`);
|
|
2753
|
-
return (0, import_solver_discovery3.fromAtomic)(value,
|
|
2755
|
+
return (0, import_solver_discovery3.fromAtomic)(value, asset6.decimals);
|
|
2754
2756
|
}
|
|
2755
2757
|
};
|
|
2756
2758
|
var toAtomicDecimal = (value) => {
|
|
@@ -3215,9 +3217,9 @@ var LEGACY_CORRIDORS = {
|
|
|
3215
3217
|
};
|
|
3216
3218
|
var assetOf = (market, side) => side === "base" ? market.base_asset : market.quote_asset;
|
|
3217
3219
|
var marketAssetId = (market, side) => {
|
|
3218
|
-
const
|
|
3219
|
-
if (typeof
|
|
3220
|
-
return typeof
|
|
3220
|
+
const asset6 = assetOf(market, side);
|
|
3221
|
+
if (typeof asset6?.caip19_id === "string") return asset6.caip19_id;
|
|
3222
|
+
return typeof asset6?.id === "string" ? asset6.id : void 0;
|
|
3221
3223
|
};
|
|
3222
3224
|
var chainNamespaceOf = (id) => {
|
|
3223
3225
|
if (id === void 0) return void 0;
|
|
@@ -3329,30 +3331,26 @@ var LockupNeedsRecoveryError = class extends Error {
|
|
|
3329
3331
|
this.recoverableAfter = recoverableAfter;
|
|
3330
3332
|
}
|
|
3331
3333
|
};
|
|
3332
|
-
async function findLockupVtxos(
|
|
3333
|
-
const
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
indexer.getVtxos({ scripts, recoverableOnly: true })
|
|
3337
|
-
]);
|
|
3334
|
+
async function findLockupVtxos(contracts, swapPkScript) {
|
|
3335
|
+
const [row] = await contracts.getContractsWithVtxos({
|
|
3336
|
+
script: import_base9.hex.encode(swapPkScript)
|
|
3337
|
+
});
|
|
3338
3338
|
const seen = /* @__PURE__ */ new Set();
|
|
3339
3339
|
const out = [];
|
|
3340
|
-
for (const
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
});
|
|
3355
|
-
}
|
|
3340
|
+
for (const vtxo of row?.vtxos ?? []) {
|
|
3341
|
+
if (vtxo.isUnrolled) continue;
|
|
3342
|
+
if ((0, import_sdk10.hasTerminalSpend)(vtxo)) continue;
|
|
3343
|
+
const key = `${vtxo.txid}:${vtxo.vout}`;
|
|
3344
|
+
if (seen.has(key)) continue;
|
|
3345
|
+
seen.add(key);
|
|
3346
|
+
out.push({
|
|
3347
|
+
txid: vtxo.txid,
|
|
3348
|
+
vout: vtxo.vout,
|
|
3349
|
+
value: Number(vtxo.value),
|
|
3350
|
+
// The manager's canonical `isSwept` fact; no coercion, because the
|
|
3351
|
+
// normalized row guarantees a boolean.
|
|
3352
|
+
recoverable: vtxo.isSwept
|
|
3353
|
+
});
|
|
3356
3354
|
}
|
|
3357
3355
|
return out;
|
|
3358
3356
|
}
|
|
@@ -3939,7 +3937,7 @@ var discoveryIndex = (input) => {
|
|
|
3939
3937
|
|
|
3940
3938
|
// src/client/cancel.ts
|
|
3941
3939
|
var import_base12 = require("@scure/base");
|
|
3942
|
-
var
|
|
3940
|
+
var import_sdk18 = require("@arkade-os/sdk");
|
|
3943
3941
|
init_coverage();
|
|
3944
3942
|
init_offer();
|
|
3945
3943
|
|
|
@@ -4009,7 +4007,7 @@ function classifyDepositSpend(offer, operatorPubkey, spendTxs, deposit) {
|
|
|
4009
4007
|
return "indeterminate";
|
|
4010
4008
|
}
|
|
4011
4009
|
async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
4012
|
-
const { operatorPubkey, scanned = /* @__PURE__ */ new Set(), reopen = [] } = opts;
|
|
4010
|
+
const { operatorPubkey, scanned = /* @__PURE__ */ new Set(), reopen = [], hrp } = opts;
|
|
4013
4011
|
const reopened = [];
|
|
4014
4012
|
for (const swap of reopen) {
|
|
4015
4013
|
try {
|
|
@@ -4110,17 +4108,27 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
4110
4108
|
restored.push({ ...existing, status, spentTxid, ...completion });
|
|
4111
4109
|
continue;
|
|
4112
4110
|
}
|
|
4111
|
+
let swapAddress = "";
|
|
4112
|
+
try {
|
|
4113
|
+
const compiled = offerContract(offer, operatorPubkey);
|
|
4114
|
+
if (import_base11.hex.encode(compiled.pkScript) !== swapPkScript) {
|
|
4115
|
+
unresolved.add(fundingTx.redeemTxid);
|
|
4116
|
+
continue;
|
|
4117
|
+
}
|
|
4118
|
+
if (hrp !== void 0) {
|
|
4119
|
+
swapAddress = compiled.address(hrp, operatorPubkey).encode();
|
|
4120
|
+
}
|
|
4121
|
+
} catch {
|
|
4122
|
+
unresolved.add(fundingTx.redeemTxid);
|
|
4123
|
+
continue;
|
|
4124
|
+
}
|
|
4113
4125
|
restored.push({
|
|
4114
4126
|
id: fundingTx.redeemTxid,
|
|
4115
4127
|
fromAsset,
|
|
4116
4128
|
toAsset,
|
|
4117
4129
|
fromAmount,
|
|
4118
4130
|
toAmount: offer.wantAmount.toString(),
|
|
4119
|
-
|
|
4120
|
-
// to the current operator key; store the funded address if operator-key
|
|
4121
|
-
// rotations become real (cancelOffer now at least diagnoses the
|
|
4122
|
-
// mismatch instead of reporting a missing VTXO)
|
|
4123
|
-
swapAddress: "",
|
|
4131
|
+
swapAddress,
|
|
4124
4132
|
swapPkScript,
|
|
4125
4133
|
offerHex,
|
|
4126
4134
|
fundingTxid: fundingTx.redeemTxid,
|
|
@@ -4136,6 +4144,8 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
4136
4144
|
}
|
|
4137
4145
|
|
|
4138
4146
|
// src/client/driveRecords.ts
|
|
4147
|
+
init_store();
|
|
4148
|
+
var import_sdk17 = require("@arkade-os/sdk");
|
|
4139
4149
|
var splitRecords = (records) => {
|
|
4140
4150
|
const corridor = [];
|
|
4141
4151
|
const offer = [];
|
|
@@ -4277,7 +4287,44 @@ var applyOfferSpend = (record, changes, now) => ({
|
|
|
4277
4287
|
...changes.completedAt === void 0 ? {} : { completedAt: Math.floor(changes.completedAt / 1e3) },
|
|
4278
4288
|
updatedAt: now
|
|
4279
4289
|
});
|
|
4280
|
-
var
|
|
4290
|
+
var withDepositFate = (record, fate, now) => ({
|
|
4291
|
+
...record,
|
|
4292
|
+
status: fate.status,
|
|
4293
|
+
...fate.spentTxid === void 0 ? {} : { spentTxid: fate.spentTxid },
|
|
4294
|
+
...fate.completedAt === void 0 ? {} : { completedAt: Math.floor(fate.completedAt / 1e3) },
|
|
4295
|
+
updatedAt: now
|
|
4296
|
+
});
|
|
4297
|
+
var fateMoved = (record, fate) => record.status !== fate.status || fate.spentTxid !== void 0 && record.spentTxid !== fate.spentTxid || fate.completedAt !== void 0 && record.completedAt !== Math.floor(fate.completedAt / 1e3);
|
|
4298
|
+
var restoredOfferRecord = (swap, network, now) => {
|
|
4299
|
+
const give = restoredAssetId(network, swap.fromAsset);
|
|
4300
|
+
const take = restoredAssetId(network, swap.toAsset);
|
|
4301
|
+
const createdAt = Math.floor(swap.createdAt / 1e3);
|
|
4302
|
+
return withDepositFate(
|
|
4303
|
+
{
|
|
4304
|
+
id: swap.fundingTxid,
|
|
4305
|
+
family: "offer",
|
|
4306
|
+
route: {
|
|
4307
|
+
give: { corridor: "arkade", asset: give, instrument: { kind: "wallet" } },
|
|
4308
|
+
take: { corridor: "arkade", asset: take, instrument: { kind: "wallet" } }
|
|
4309
|
+
},
|
|
4310
|
+
give: { asset: give, amount: toAtomicDecimal(BigInt(swap.fromAmount)) },
|
|
4311
|
+
take: { asset: take, amount: toAtomicDecimal(BigInt(swap.toAmount)) },
|
|
4312
|
+
fee: { asset: take, amount: toAtomicDecimal(BigInt(0)) },
|
|
4313
|
+
market: { kind: "restored", backend: "feed" },
|
|
4314
|
+
expiresAt: createdAt,
|
|
4315
|
+
status: swap.status,
|
|
4316
|
+
offerHex: swap.offerHex,
|
|
4317
|
+
swapAddress: swap.swapAddress,
|
|
4318
|
+
swapPkScript: swap.swapPkScript,
|
|
4319
|
+
fundingTxid: swap.fundingTxid,
|
|
4320
|
+
createdAt,
|
|
4321
|
+
updatedAt: now
|
|
4322
|
+
},
|
|
4323
|
+
swap,
|
|
4324
|
+
now
|
|
4325
|
+
);
|
|
4326
|
+
};
|
|
4327
|
+
var restoredAssetId = (network, id) => id === BTC_ASSET_ID ? btcOn("arkade", network) : arkadeAsset(network, import_sdk17.asset.AssetId.fromString(id));
|
|
4281
4328
|
var walletLockupIndexer = (wallet) => {
|
|
4282
4329
|
let reader;
|
|
4283
4330
|
const reading = () => reader ??= wallet.getArkadeReader();
|
|
@@ -4367,12 +4414,12 @@ var reconcileDepositSpend = async (record, indexer) => {
|
|
|
4367
4414
|
const { txs } = await indexer.getVirtualTxs(candidates);
|
|
4368
4415
|
const parsed = txs.map((psbt) => {
|
|
4369
4416
|
try {
|
|
4370
|
-
return
|
|
4417
|
+
return import_sdk18.Transaction.fromPSBT(import_base12.base64.decode(psbt));
|
|
4371
4418
|
} catch {
|
|
4372
4419
|
return void 0;
|
|
4373
4420
|
}
|
|
4374
4421
|
}).filter((tx) => tx !== void 0);
|
|
4375
|
-
const operatorPubkey =
|
|
4422
|
+
const operatorPubkey = import_sdk18.ArkAddress.decode(record.swapAddress).serverPubKey;
|
|
4376
4423
|
const kind = classifyDepositSpend(offer, operatorPubkey, parsed, {
|
|
4377
4424
|
txid: deposit.txid,
|
|
4378
4425
|
vout: deposit.vout
|
|
@@ -4411,14 +4458,14 @@ var retireOfferScripts = async (wallet, repository, record) => {
|
|
|
4411
4458
|
var isMissingVtxo = (error) => error instanceof NoSpendableDepositError;
|
|
4412
4459
|
|
|
4413
4460
|
// src/client/drive.ts
|
|
4414
|
-
var
|
|
4461
|
+
var import_sdk24 = require("@arkade-os/sdk");
|
|
4415
4462
|
var import_base17 = require("@scure/base");
|
|
4416
4463
|
|
|
4417
4464
|
// src/claim.ts
|
|
4418
4465
|
var import_base13 = require("@scure/base");
|
|
4419
4466
|
var import_legacy3 = require("@noble/hashes/legacy.js");
|
|
4420
4467
|
var import_sha25 = require("@noble/hashes/sha2.js");
|
|
4421
|
-
var
|
|
4468
|
+
var import_sdk19 = require("@arkade-os/sdk");
|
|
4422
4469
|
var LockupAmountMismatchError = class extends Error {
|
|
4423
4470
|
name = "LockupAmountMismatchError";
|
|
4424
4471
|
reason = "amount_mismatch";
|
|
@@ -4462,14 +4509,14 @@ async function pushClaim(operator, input) {
|
|
|
4462
4509
|
const info = await operator.getInfo();
|
|
4463
4510
|
let operatorUnrollScript;
|
|
4464
4511
|
try {
|
|
4465
|
-
operatorUnrollScript =
|
|
4512
|
+
operatorUnrollScript = import_sdk19.CSVMultisigTapscript.decode(import_base13.hex.decode(info.checkpointTapscript));
|
|
4466
4513
|
} catch {
|
|
4467
4514
|
throw new Error("invalid checkpointTapscript from the operator");
|
|
4468
4515
|
}
|
|
4469
4516
|
const leaf = input.contract.claim();
|
|
4470
4517
|
const tapTree = input.contract.encode();
|
|
4471
|
-
const txid = await (0,
|
|
4472
|
-
identity: (0,
|
|
4518
|
+
const txid = await (0, import_sdk19.signAndSubmitOffchainTx)({
|
|
4519
|
+
identity: (0, import_sdk19.claimWithPreimageIdentity)(input.receiver, input.preimage),
|
|
4473
4520
|
provider: operator,
|
|
4474
4521
|
inputs: input.vtxos.map((vtxo) => ({
|
|
4475
4522
|
txid: vtxo.txid,
|
|
@@ -4493,7 +4540,7 @@ init_coverage();
|
|
|
4493
4540
|
init_lockupContract();
|
|
4494
4541
|
|
|
4495
4542
|
// src/refundBlocked.ts
|
|
4496
|
-
var
|
|
4543
|
+
var import_sdk20 = require("@arkade-os/sdk");
|
|
4497
4544
|
var RefundNotLocallyPossibleError = class extends Error {
|
|
4498
4545
|
constructor(reason, message, options) {
|
|
4499
4546
|
super(message, options);
|
|
@@ -4510,16 +4557,16 @@ async function senderIdentityForSwapRecord(wallet, record) {
|
|
|
4510
4557
|
);
|
|
4511
4558
|
}
|
|
4512
4559
|
try {
|
|
4513
|
-
return await (0,
|
|
4560
|
+
return await (0, import_sdk20.contractSigner)(wallet, record.signingDescriptor);
|
|
4514
4561
|
} catch (cause) {
|
|
4515
|
-
if (cause instanceof
|
|
4562
|
+
if (cause instanceof import_sdk20.WalletCannotSignError) {
|
|
4516
4563
|
throw new RefundNotLocallyPossibleError(
|
|
4517
4564
|
"unsignable-wallet",
|
|
4518
4565
|
`this wallet holds ${record.signingDescriptor} but cannot sign with it; attach its signer`,
|
|
4519
4566
|
{ cause }
|
|
4520
4567
|
);
|
|
4521
4568
|
}
|
|
4522
|
-
if (cause instanceof
|
|
4569
|
+
if (cause instanceof import_sdk20.ForeignDescriptorError) {
|
|
4523
4570
|
throw new RefundNotLocallyPossibleError(
|
|
4524
4571
|
"foreign-descriptor",
|
|
4525
4572
|
`this wallet cannot derive ${record.signingDescriptor}; the swap was created on another wallet`,
|
|
@@ -4539,7 +4586,7 @@ function arkadeRefunder(deps) {
|
|
|
4539
4586
|
`swap ${swap.rfqId} carries no lockup covenant, so its refund cannot be built`
|
|
4540
4587
|
);
|
|
4541
4588
|
}
|
|
4542
|
-
const vtxos = await findLockupVtxos(deps.
|
|
4589
|
+
const vtxos = await findLockupVtxos(deps.contracts, swap.lockupPkScript);
|
|
4543
4590
|
if (vtxos.length === 0) return null;
|
|
4544
4591
|
const record = await deps.repository.getRfqSwap(swap.rfqId);
|
|
4545
4592
|
if (!record) {
|
|
@@ -4554,7 +4601,7 @@ function arkadeRefunder(deps) {
|
|
|
4554
4601
|
}
|
|
4555
4602
|
|
|
4556
4603
|
// src/rfqRecord.ts
|
|
4557
|
-
var
|
|
4604
|
+
var import_sdk21 = require("@arkade-os/sdk");
|
|
4558
4605
|
var import_base14 = require("@scure/base");
|
|
4559
4606
|
|
|
4560
4607
|
// src/rfqSwapState.ts
|
|
@@ -4600,7 +4647,7 @@ function assertSameSwap(origin, swap) {
|
|
|
4600
4647
|
`rfq swap record is a ${origin.kind} origin paired with a ${swap.kind} swap`
|
|
4601
4648
|
);
|
|
4602
4649
|
}
|
|
4603
|
-
const funded = import_base14.hex.encode(
|
|
4650
|
+
const funded = import_base14.hex.encode(import_sdk21.ArkAddress.decode(origin.lockupAddress).pkScript);
|
|
4604
4651
|
const watched = import_base14.hex.encode(swap.lockupPkScript);
|
|
4605
4652
|
if (funded !== watched) {
|
|
4606
4653
|
throw new Error(
|
|
@@ -4649,8 +4696,8 @@ function rfqSwapOriginOf(record) {
|
|
|
4649
4696
|
};
|
|
4650
4697
|
}
|
|
4651
4698
|
function lockupScript(params, lockupAddress) {
|
|
4652
|
-
const script =
|
|
4653
|
-
const funded =
|
|
4699
|
+
const script = import_sdk21.VHTLCV2ContractHandler.createScript(params);
|
|
4700
|
+
const funded = import_sdk21.ArkAddress.decode(lockupAddress).pkScript;
|
|
4654
4701
|
if (import_base14.hex.encode(funded) !== import_base14.hex.encode(script.pkScript)) {
|
|
4655
4702
|
throw new Error(
|
|
4656
4703
|
`rfq swap covenant params derive ${import_base14.hex.encode(script.pkScript)}, but the record's lockup address holds ${import_base14.hex.encode(funded)} \u2014 these params are not this swap's`
|
|
@@ -4695,7 +4742,7 @@ init_store();
|
|
|
4695
4742
|
|
|
4696
4743
|
// src/swapManager.ts
|
|
4697
4744
|
var import_base15 = require("@scure/base");
|
|
4698
|
-
var
|
|
4745
|
+
var import_sdk22 = require("@arkade-os/sdk");
|
|
4699
4746
|
init_onchainHtlc();
|
|
4700
4747
|
init_lockupContract();
|
|
4701
4748
|
init_coverage();
|
|
@@ -5195,7 +5242,7 @@ var RfqSwapManager = class {
|
|
|
5195
5242
|
});
|
|
5196
5243
|
return;
|
|
5197
5244
|
}
|
|
5198
|
-
if (!(0,
|
|
5245
|
+
if (!(0, import_sdk22.isContractVtxoEvent)(event)) return;
|
|
5199
5246
|
const swap = this.byLockupScript.get(event.contractScript);
|
|
5200
5247
|
if (!swap) return;
|
|
5201
5248
|
void this.pollSwap(swap).catch(() => {
|
|
@@ -5384,7 +5431,10 @@ var RfqSwapManager = class {
|
|
|
5384
5431
|
return;
|
|
5385
5432
|
}
|
|
5386
5433
|
if (swap.kind === "lightning_receive") {
|
|
5387
|
-
|
|
5434
|
+
if (fate.fate === "exited") return this.blockExitedLockup(swap, fate);
|
|
5435
|
+
if (fate.fate === "open") return this.driveReceiveClaim(swap);
|
|
5436
|
+
if (this.config.now() >= swap.refundLocktime) return this.driveReceiveClaim(swap);
|
|
5437
|
+
return;
|
|
5388
5438
|
}
|
|
5389
5439
|
if (swap.kind === "onchain_send" && swap.state !== "claimed") {
|
|
5390
5440
|
if (await this.driveOnchain(swap) === "handled") return;
|
|
@@ -5439,7 +5489,7 @@ var RfqSwapManager = class {
|
|
|
5439
5489
|
if (now < swap.refundLocktime) {
|
|
5440
5490
|
let vtxos;
|
|
5441
5491
|
try {
|
|
5442
|
-
vtxos = await findLockupVtxos(this.deps.
|
|
5492
|
+
vtxos = await findLockupVtxos(this.deps.contracts, swap.lockupPkScript);
|
|
5443
5493
|
} catch (error) {
|
|
5444
5494
|
this.emitFailed(swap, error);
|
|
5445
5495
|
return;
|
|
@@ -5843,7 +5893,7 @@ var outpointKey = (vtxo) => `${vtxo.txid}:${vtxo.vout}`;
|
|
|
5843
5893
|
|
|
5844
5894
|
// src/watch.ts
|
|
5845
5895
|
var import_base16 = require("@scure/base");
|
|
5846
|
-
var
|
|
5896
|
+
var import_sdk23 = require("@arkade-os/sdk");
|
|
5847
5897
|
init_coverage();
|
|
5848
5898
|
init_offer();
|
|
5849
5899
|
init_store();
|
|
@@ -5878,7 +5928,7 @@ async function watchOfferSwaps({
|
|
|
5878
5928
|
wallet.getAddress(),
|
|
5879
5929
|
wallet.getArkadeReader()
|
|
5880
5930
|
]);
|
|
5881
|
-
const operatorPubkey =
|
|
5931
|
+
const operatorPubkey = import_sdk23.ArkAddress.decode(address).serverPubKey;
|
|
5882
5932
|
let queue = Promise.resolve();
|
|
5883
5933
|
const enqueue = (task) => {
|
|
5884
5934
|
queue = queue.then(task).catch(() => {
|
|
@@ -5893,7 +5943,7 @@ async function watchOfferSwaps({
|
|
|
5893
5943
|
return classifyDepositSpend(
|
|
5894
5944
|
decodeOffer(import_base16.hex.decode(swap.offerHex)),
|
|
5895
5945
|
operatorPubkey,
|
|
5896
|
-
txs.map((psbt) =>
|
|
5946
|
+
txs.map((psbt) => import_sdk23.Transaction.fromPSBT(import_base16.base64.decode(psbt))),
|
|
5897
5947
|
{ txid: vtxo.txid, vout: vtxo.vout }
|
|
5898
5948
|
);
|
|
5899
5949
|
} catch {
|
|
@@ -5921,7 +5971,7 @@ async function watchOfferSwaps({
|
|
|
5921
5971
|
}
|
|
5922
5972
|
};
|
|
5923
5973
|
const unsubscribe = manager.onContractEvent((event) => {
|
|
5924
|
-
if (!(0,
|
|
5974
|
+
if (!(0, import_sdk23.isContractVtxoEvent)(event) || event.type !== "vtxo_spent") return;
|
|
5925
5975
|
enqueue(() => handleSpend(event));
|
|
5926
5976
|
});
|
|
5927
5977
|
return {
|
|
@@ -6104,7 +6154,7 @@ var createSwapDrive = (config) => {
|
|
|
6104
6154
|
const secret = rfqClaimSecretOf(record);
|
|
6105
6155
|
if (!secret) throw new Error(`rfq swap ${swap.rfqId} carries no claim secret`);
|
|
6106
6156
|
const preimage = await preimageForSwapRecord(wallet, secret);
|
|
6107
|
-
const signer = await (0,
|
|
6157
|
+
const signer = await (0, import_sdk24.contractSigner)(wallet, await (0, import_sdk24.identityDescriptor)(wallet.identity));
|
|
6108
6158
|
const claimKey = record.profile.claimKey;
|
|
6109
6159
|
if (typeof claimKey === "string") {
|
|
6110
6160
|
const held = import_base17.hex.encode(await signer.xOnlyPublicKey());
|
|
@@ -6162,10 +6212,10 @@ var createSwapDrive = (config) => {
|
|
|
6162
6212
|
return track(
|
|
6163
6213
|
pushClaim(operator, {
|
|
6164
6214
|
contract: script,
|
|
6165
|
-
receiver: await (0,
|
|
6215
|
+
receiver: await (0, import_sdk24.contractSigner)(wallet, secret.signingDescriptor),
|
|
6166
6216
|
preimage: await preimageForSwapRecord(wallet, secret),
|
|
6167
6217
|
vtxos,
|
|
6168
|
-
destinationPkScript:
|
|
6218
|
+
destinationPkScript: import_sdk24.ArkAddress.decode(payoutAddress).pkScript,
|
|
6169
6219
|
// Passed straight through, both of them: the manager's own value
|
|
6170
6220
|
// check decides WHEN to act, `pushClaim`'s decides whether `P` is
|
|
6171
6221
|
// published, and it is the one with nothing between it and the
|
|
@@ -6198,7 +6248,7 @@ var createSwapDrive = (config) => {
|
|
|
6198
6248
|
if (mode === "readonly") return;
|
|
6199
6249
|
const push = arkadeRefunder({
|
|
6200
6250
|
operator,
|
|
6201
|
-
|
|
6251
|
+
contracts: lockupSource,
|
|
6202
6252
|
wallet,
|
|
6203
6253
|
repository: corridorStore()
|
|
6204
6254
|
});
|
|
@@ -6224,16 +6274,13 @@ var createSwapDrive = (config) => {
|
|
|
6224
6274
|
};
|
|
6225
6275
|
let offerSource;
|
|
6226
6276
|
const offers = () => offerSource ??= offerRecordSource(storage(), remember, now);
|
|
6227
|
-
const
|
|
6228
|
-
const funded = offer.filter(
|
|
6229
|
-
(record) => record.fundingTxid !== void 0 && !RETIRABLE.includes(record.status)
|
|
6230
|
-
);
|
|
6231
|
-
if (funded.length === 0) return;
|
|
6277
|
+
const restoreOfferDeposits = async (reopen) => {
|
|
6232
6278
|
const store = storage();
|
|
6233
|
-
const [history, scanned, address] = await Promise.all([
|
|
6279
|
+
const [history, scanned, address, network] = await Promise.all([
|
|
6234
6280
|
wallet.getTransactionHistory(),
|
|
6235
6281
|
store.getScannedTxids(),
|
|
6236
|
-
wallet.getAddress()
|
|
6282
|
+
wallet.getAddress(),
|
|
6283
|
+
config.network()
|
|
6237
6284
|
]);
|
|
6238
6285
|
const txs = history.map((tx) => ({
|
|
6239
6286
|
// `TxType` is `"SENT"`/`"RECEIVED"`; the scan filters on `"sent"`.
|
|
@@ -6244,30 +6291,61 @@ var createSwapDrive = (config) => {
|
|
|
6244
6291
|
// The scan reads unix SECONDS; a wallet transaction carries ms.
|
|
6245
6292
|
...tx.createdAt ? { createdAt: Math.floor(tx.createdAt / 1e3) } : {}
|
|
6246
6293
|
}));
|
|
6294
|
+
const { hrp, serverPubKey: operatorPubkey } = import_sdk24.ArkAddress.decode(address);
|
|
6295
|
+
const cursor = reopen === void 0 ? scanned : new Set([...scanned].filter((txid) => txid !== reopen));
|
|
6247
6296
|
const { restored, scannedTxids } = await restoreAssetSwaps(indexer, txs, /* @__PURE__ */ new Set(), {
|
|
6248
|
-
operatorPubkey
|
|
6249
|
-
scanned
|
|
6297
|
+
operatorPubkey,
|
|
6298
|
+
scanned: cursor,
|
|
6299
|
+
hrp
|
|
6250
6300
|
});
|
|
6251
|
-
const
|
|
6252
|
-
const
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6301
|
+
const { offer } = splitRecords(await store.getAllSwapRecords());
|
|
6302
|
+
const current = new Map(offer.map((record) => [record.id, record]));
|
|
6303
|
+
const byDeposit = new Map(
|
|
6304
|
+
offer.filter((record) => record.fundingTxid !== void 0).map((record) => [`${record.swapPkScript}:${record.fundingTxid}`, record])
|
|
6305
|
+
);
|
|
6306
|
+
const unstamped = /* @__PURE__ */ new Map();
|
|
6307
|
+
for (const record of offer) {
|
|
6308
|
+
if (record.fundingTxid !== void 0 || !OFFER_LIVE(record.status)) continue;
|
|
6309
|
+
unstamped.set(record.swapPkScript, [
|
|
6310
|
+
...unstamped.get(record.swapPkScript) ?? [],
|
|
6311
|
+
record
|
|
6312
|
+
]);
|
|
6313
|
+
}
|
|
6314
|
+
const write = async (record) => {
|
|
6315
|
+
await store.saveSwapRecord(record);
|
|
6316
|
+
current.set(record.id, record);
|
|
6317
|
+
remember(record);
|
|
6318
|
+
};
|
|
6319
|
+
for (const found of restored) {
|
|
6320
|
+
const known = byDeposit.get(`${found.swapPkScript}:${found.fundingTxid}`);
|
|
6321
|
+
if (known !== void 0) {
|
|
6322
|
+
if (fateMoved(known, found)) await write(withDepositFate(known, found, now()));
|
|
6323
|
+
continue;
|
|
6324
|
+
}
|
|
6325
|
+
const orphan = unstamped.get(found.swapPkScript)?.shift();
|
|
6326
|
+
if (orphan !== void 0) {
|
|
6327
|
+
await write(
|
|
6328
|
+
withDepositFate({ ...orphan, fundingTxid: found.fundingTxid }, found, now())
|
|
6329
|
+
);
|
|
6330
|
+
continue;
|
|
6260
6331
|
}
|
|
6261
|
-
|
|
6332
|
+
await write(restoredOfferRecord(found, network, now()));
|
|
6333
|
+
}
|
|
6334
|
+
const stillLive = /* @__PURE__ */ new Set();
|
|
6335
|
+
for (const record of current.values()) {
|
|
6336
|
+
if (OFFER_LIVE(record.status) && record.fundingTxid) stillLive.add(record.fundingTxid);
|
|
6262
6337
|
}
|
|
6263
6338
|
await store.markTxidsScanned(scannedTxids.filter((txid) => !stillLive.has(txid)));
|
|
6264
6339
|
const registry = managerDeps.contracts;
|
|
6265
6340
|
if (registry) {
|
|
6266
|
-
|
|
6267
|
-
await retireSettledOfferContracts(registry, current.map(offerFactsOf));
|
|
6341
|
+
await retireSettledOfferContracts(registry, [...current.values()].map(offerFactsOf));
|
|
6268
6342
|
}
|
|
6343
|
+
return [...current.values()];
|
|
6269
6344
|
};
|
|
6270
6345
|
const contractsOf = async () => managerDeps.contracts ??= await wallet.getContractManager();
|
|
6346
|
+
const lockupSource = {
|
|
6347
|
+
getContractsWithVtxos: async (filter) => (await contractsOf()).getContractsWithVtxos(filter)
|
|
6348
|
+
};
|
|
6271
6349
|
const registerCorridorSwap = async (record) => {
|
|
6272
6350
|
if (mode === "readonly") return;
|
|
6273
6351
|
if (!await drivable(record)) {
|
|
@@ -6338,13 +6416,14 @@ var createSwapDrive = (config) => {
|
|
|
6338
6416
|
console.warn("[swap] the corridor restore could not drive", error);
|
|
6339
6417
|
}
|
|
6340
6418
|
}
|
|
6419
|
+
let offers2 = offer;
|
|
6341
6420
|
try {
|
|
6342
|
-
await
|
|
6421
|
+
offers2 = await restoreOfferDeposits();
|
|
6343
6422
|
} catch (error) {
|
|
6344
|
-
console.warn("[swap] the offer deposit
|
|
6423
|
+
console.warn("[swap] the offer deposit restore did not complete", error);
|
|
6345
6424
|
}
|
|
6346
6425
|
emitAll();
|
|
6347
|
-
if (mode === "auto" && await hasLiveWork(
|
|
6426
|
+
if (mode === "auto" && await hasLiveWork(offers2)) {
|
|
6348
6427
|
try {
|
|
6349
6428
|
await arm();
|
|
6350
6429
|
} catch (error) {
|
|
@@ -6372,7 +6451,7 @@ var createSwapDrive = (config) => {
|
|
|
6372
6451
|
}
|
|
6373
6452
|
return probe.call(wallet);
|
|
6374
6453
|
};
|
|
6375
|
-
const recoverableAt = async (script) => (await findLockupVtxos(
|
|
6454
|
+
const recoverableAt = async (script) => (await findLockupVtxos(lockupSource, script)).filter((vtxo) => vtxo.recoverable);
|
|
6376
6455
|
const recover = async (id) => {
|
|
6377
6456
|
if (disposed) throw new ClientDisposed("recover");
|
|
6378
6457
|
if (mode === "readonly") {
|
|
@@ -6422,7 +6501,7 @@ var createSwapDrive = (config) => {
|
|
|
6422
6501
|
);
|
|
6423
6502
|
}
|
|
6424
6503
|
const txid = await track((await recoverer()).recoverVtxos());
|
|
6425
|
-
await
|
|
6504
|
+
await restoreOfferDeposits(record.fundingTxid);
|
|
6426
6505
|
const after = records.get(id);
|
|
6427
6506
|
const recovered = after?.family === "offer" && after.status !== "recoverable";
|
|
6428
6507
|
return { recovered, txid, swap: swapView(id) };
|
|
@@ -6595,16 +6674,16 @@ var assembleRoute = (give, take) => {
|
|
|
6595
6674
|
}
|
|
6596
6675
|
return { give, take };
|
|
6597
6676
|
};
|
|
6598
|
-
var endpoint = (corridor,
|
|
6677
|
+
var endpoint = (corridor, asset6, instrument) => ({
|
|
6599
6678
|
corridor,
|
|
6600
|
-
asset:
|
|
6679
|
+
asset: asset6,
|
|
6601
6680
|
...instrument === void 0 ? {} : { instrument }
|
|
6602
6681
|
});
|
|
6603
|
-
var legFor = (
|
|
6604
|
-
const leg = toDiscoveryLeg(
|
|
6682
|
+
var legFor = (asset6, expected) => {
|
|
6683
|
+
const leg = toDiscoveryLeg(asset6);
|
|
6605
6684
|
if (expected !== void 0 && leg.corridor !== expected) {
|
|
6606
6685
|
throw new UnsupportedRoute(
|
|
6607
|
-
`${
|
|
6686
|
+
`${asset6} settles on ${leg.corridor}, and this leg is ${expected}`,
|
|
6608
6687
|
{ give: leg.corridor, take: expected }
|
|
6609
6688
|
);
|
|
6610
6689
|
}
|
|
@@ -6953,17 +7032,17 @@ var verifyPlanLegs = (plan, legs, give) => {
|
|
|
6953
7032
|
|
|
6954
7033
|
// src/client/quoteRfq.ts
|
|
6955
7034
|
var import_base18 = require("@scure/base");
|
|
6956
|
-
var
|
|
7035
|
+
var import_sdk27 = require("@arkade-os/sdk");
|
|
6957
7036
|
init_claimPacket();
|
|
6958
7037
|
init_onchainHtlc();
|
|
6959
7038
|
init_onchainHtlc();
|
|
6960
7039
|
|
|
6961
7040
|
// src/payment/onchainSwap.ts
|
|
6962
|
-
var
|
|
7041
|
+
var import_sdk26 = require("@arkade-os/sdk");
|
|
6963
7042
|
init_onchainHtlc();
|
|
6964
7043
|
|
|
6965
7044
|
// src/payment/swapRail.ts
|
|
6966
|
-
var
|
|
7045
|
+
var import_sdk25 = require("@arkade-os/sdk");
|
|
6967
7046
|
|
|
6968
7047
|
// src/client/sats.ts
|
|
6969
7048
|
var satsOf = (value, field) => {
|
|
@@ -7015,14 +7094,14 @@ var parseRfqQuote = (quote) => ({
|
|
|
7015
7094
|
|
|
7016
7095
|
// src/client/quoteRfq.ts
|
|
7017
7096
|
var covenantInputs = (input) => {
|
|
7018
|
-
const network = (0,
|
|
7097
|
+
const network = (0, import_sdk27.networkFromArkadeInfo)(input.info);
|
|
7019
7098
|
const arkade2 = input.corridors.get("arkade").deps;
|
|
7020
7099
|
return {
|
|
7021
|
-
operatorPubkey: (0,
|
|
7100
|
+
operatorPubkey: (0, import_sdk27.toXOnly)(import_base18.hex.decode(input.info.signerPubkey), "ark signer key"),
|
|
7022
7101
|
// The per-network pin the arkade module already resolved, never a key
|
|
7023
7102
|
// the operator reports about itself: this one ends up in a covenant leaf
|
|
7024
7103
|
// that decides who can move the funds.
|
|
7025
|
-
emulatorPubkey: (0,
|
|
7104
|
+
emulatorPubkey: (0, import_sdk27.toXOnly)(import_base18.hex.decode(arkade2.emulatorPubkey), "emulator signer key"),
|
|
7026
7105
|
claimDelay: unilateralClaimDelay(Number(input.info.unilateralExitDelay)),
|
|
7027
7106
|
hrp: network.hrp
|
|
7028
7107
|
};
|
|
@@ -7066,7 +7145,7 @@ var quoteLightningSend = async (input) => {
|
|
|
7066
7145
|
}
|
|
7067
7146
|
const pair = rfqPairFor(input.legs.give, input.legs.take);
|
|
7068
7147
|
const rfqId = newRfqId();
|
|
7069
|
-
const secrets = await (0,
|
|
7148
|
+
const secrets = await (0, import_sdk27.provisionRefundKey)(input.wallet);
|
|
7070
7149
|
const wire = await input.transport.requestQuote(
|
|
7071
7150
|
lightningSendRequest({
|
|
7072
7151
|
rfqId,
|
|
@@ -7139,7 +7218,7 @@ var quoteLightningReceive = async (input) => {
|
|
|
7139
7218
|
const pinned = pinnedFor(input);
|
|
7140
7219
|
const pair = rfqPairFor(input.legs.give, input.legs.take);
|
|
7141
7220
|
const rfqId = newRfqId();
|
|
7142
|
-
const secrets = await (0,
|
|
7221
|
+
const secrets = await (0, import_sdk27.provisionClaimSecret)(input.wallet);
|
|
7143
7222
|
const paymentHash = import_base18.hex.encode(secrets.paymentHash);
|
|
7144
7223
|
const payoutAddress = await input.wallet.getAddress();
|
|
7145
7224
|
const lightning = input.corridors.get("lightning").deps;
|
|
@@ -7262,8 +7341,8 @@ var quoteOnchainSend = async (input) => {
|
|
|
7262
7341
|
claimVsize: onchain.claimVsize
|
|
7263
7342
|
}) : void 0;
|
|
7264
7343
|
const quoted = claimFee === void 0 ? pinned : { on: pinned.on, value: pinned.value + claimFee, source: pinned.source };
|
|
7265
|
-
const secrets = await (0,
|
|
7266
|
-
const payoutKey = await (0,
|
|
7344
|
+
const secrets = await (0, import_sdk27.provisionClaimSecret)(input.wallet);
|
|
7345
|
+
const payoutKey = await (0, import_sdk27.provisionRefundKey)(input.wallet);
|
|
7267
7346
|
const paymentHash = import_base18.hex.encode(secrets.paymentHash);
|
|
7268
7347
|
const wire = await input.transport.requestQuote(
|
|
7269
7348
|
withCanonicalAmount(
|
|
@@ -7374,7 +7453,7 @@ var quoteOnchainSend = async (input) => {
|
|
|
7374
7453
|
};
|
|
7375
7454
|
|
|
7376
7455
|
// src/client/verbs.ts
|
|
7377
|
-
var
|
|
7456
|
+
var import_sdk28 = require("@arkade-os/sdk");
|
|
7378
7457
|
var enforceFeeCeiling = (quote, call, policy) => {
|
|
7379
7458
|
let ceiling;
|
|
7380
7459
|
for (const [source, limit] of [
|
|
@@ -7399,9 +7478,9 @@ var settle = async (deps, input, maxFee) => {
|
|
|
7399
7478
|
return deps.accept(quote);
|
|
7400
7479
|
};
|
|
7401
7480
|
var pay = async (deps, destination, options = {}) => {
|
|
7402
|
-
const arkade2 = (0,
|
|
7481
|
+
const arkade2 = (0, import_sdk28.arkTarget)(destination);
|
|
7403
7482
|
if (arkade2 !== void 0) {
|
|
7404
|
-
const amount = (0,
|
|
7483
|
+
const amount = (0, import_sdk28.resolveSendAmount)(
|
|
7405
7484
|
"ark",
|
|
7406
7485
|
destination,
|
|
7407
7486
|
options.amount === void 0 ? void 0 : satsOf(options.amount, "amount")
|
|
@@ -7484,6 +7563,7 @@ var createSwapClient = (config) => {
|
|
|
7484
7563
|
operator,
|
|
7485
7564
|
...config.repository === void 0 ? {} : { repository: config.repository },
|
|
7486
7565
|
corridors: async () => (await resolved()).corridors,
|
|
7566
|
+
network: async () => (await resolved()).base.networkName,
|
|
7487
7567
|
...config.policy?.drive === void 0 ? {} : { mode: config.policy.drive },
|
|
7488
7568
|
indexer
|
|
7489
7569
|
});
|
|
@@ -7721,7 +7801,7 @@ var createSwapClient = (config) => {
|
|
|
7721
7801
|
var import_base20 = require("@scure/base");
|
|
7722
7802
|
var import_legacy4 = require("@noble/hashes/legacy.js");
|
|
7723
7803
|
var import_sha26 = require("@noble/hashes/sha2.js");
|
|
7724
|
-
var
|
|
7804
|
+
var import_sdk29 = require("@arkade-os/sdk");
|
|
7725
7805
|
init_claimPacket();
|
|
7726
7806
|
var CovclaimdRevealError = class extends Error {
|
|
7727
7807
|
name = "CovclaimdRevealError";
|
|
@@ -7826,7 +7906,7 @@ function revealFieldsFromScript(script) {
|
|
|
7826
7906
|
}
|
|
7827
7907
|
async function revealClaimPacket(client, input) {
|
|
7828
7908
|
const fields = revealFieldsFromScript(input.script);
|
|
7829
|
-
if (import_base20.hex.encode(
|
|
7909
|
+
if (import_base20.hex.encode(import_sdk29.ArkAddress.decode(input.address).pkScript) !== import_base20.hex.encode(input.script.pkScript)) {
|
|
7830
7910
|
throw new Error("address does not belong to this covenant");
|
|
7831
7911
|
}
|
|
7832
7912
|
if (import_base20.hex.encode((0, import_legacy4.ripemd160)((0, import_sha26.sha256)(input.preimage))) !== import_base20.hex.encode(input.script.options.preimageHash)) {
|
|
@@ -7917,6 +7997,7 @@ async function revealClaimPacket(client, input) {
|
|
|
7917
7997
|
esploraTip,
|
|
7918
7998
|
exchange,
|
|
7919
7999
|
familyOfSwapId,
|
|
8000
|
+
fateMoved,
|
|
7920
8001
|
feedFetch,
|
|
7921
8002
|
formatAssetId,
|
|
7922
8003
|
fromAtomicDecimal,
|
|
@@ -7964,6 +8045,7 @@ async function revealClaimPacket(client, input) {
|
|
|
7964
8045
|
resolveCorridorBase,
|
|
7965
8046
|
resolveCorridorDeps,
|
|
7966
8047
|
resolveRoute,
|
|
8048
|
+
restoredOfferRecord,
|
|
7967
8049
|
revealClaimPacket,
|
|
7968
8050
|
revealFieldsFromScript,
|
|
7969
8051
|
rfqLeg,
|
|
@@ -7991,6 +8073,6 @@ async function revealClaimPacket(client, input) {
|
|
|
7991
8073
|
verifyingDerivation,
|
|
7992
8074
|
walletLockupIndexer,
|
|
7993
8075
|
withCanonicalAmount,
|
|
7994
|
-
|
|
8076
|
+
withDepositFate,
|
|
7995
8077
|
withRfqState
|
|
7996
8078
|
});
|