@arkade-os/swap 0.1.0-rc.4 → 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 CHANGED
@@ -1149,6 +1149,7 @@ var swap_want_btc_program_default = {
1149
1149
 
1150
1150
  // src/coverage.ts
1151
1151
  var RETIRABLE = ["fulfilled", "cancelled"];
1152
+ var LOCKUP_RETIRABLE = ["settled", "refunded"];
1152
1153
  var issuedAt = /* @__PURE__ */ new Map();
1153
1154
  var inFlight = /* @__PURE__ */ new Map();
1154
1155
  async function serialize(script, task) {
@@ -3911,6 +3912,7 @@ var rfqRecordOf = (record) => ({
3911
3912
  updatedAt: record.updatedAt,
3912
3913
  ...record.refundTxid === void 0 ? {} : { refundTxid: record.refundTxid },
3913
3914
  ...record.lockupSpendTxids?.length ? { lockupSpendTxids: [...record.lockupSpendTxids] } : {},
3915
+ ...record.settlementPreimageHex === void 0 ? {} : { settlementPreimageHex: record.settlementPreimageHex },
3914
3916
  ...record.failure === void 0 ? {} : { failure: record.failure },
3915
3917
  ...record.claimFailure === void 0 ? {} : { claimFailure: record.claimFailure },
3916
3918
  ...record.blockedReason === void 0 ? {} : { blockedReason: record.blockedReason }
@@ -3919,6 +3921,7 @@ var withRfqState = (record, state) => {
3919
3921
  const {
3920
3922
  refundTxid: _refundTxid,
3921
3923
  lockupSpendTxids: _lockupSpendTxids,
3924
+ settlementPreimageHex: _settlementPreimageHex,
3922
3925
  failure: _failure,
3923
3926
  claimFailure: _claimFailure,
3924
3927
  blockedReason: _blockedReason,
@@ -3931,6 +3934,7 @@ var withRfqState = (record, state) => {
3931
3934
  updatedAt: state.updatedAt,
3932
3935
  ...state.refundTxid === void 0 ? {} : { refundTxid: state.refundTxid },
3933
3936
  ...state.lockupSpendTxids?.length ? { lockupSpendTxids: [...state.lockupSpendTxids] } : {},
3937
+ ...state.settlementPreimageHex === void 0 ? {} : { settlementPreimageHex: state.settlementPreimageHex },
3934
3938
  ...state.failure === void 0 ? {} : { failure: state.failure },
3935
3939
  ...state.claimFailure === void 0 ? {} : { claimFailure: state.claimFailure },
3936
3940
  ...state.blockedReason === void 0 ? {} : { blockedReason: state.blockedReason }
@@ -4163,7 +4167,7 @@ var retireOfferScripts = async (wallet, repository, record) => {
4163
4167
  var isMissingVtxo = (error) => error instanceof NoSpendableDepositError;
4164
4168
 
4165
4169
  // src/client/drive.ts
4166
- var import_sdk22 = require("@arkade-os/sdk");
4170
+ var import_sdk23 = require("@arkade-os/sdk");
4167
4171
  var import_base17 = require("@scure/base");
4168
4172
 
4169
4173
  // src/claim.ts
@@ -4340,6 +4344,7 @@ var managerState = (swap) => ({
4340
4344
  updatedAt: swap.updatedAt,
4341
4345
  ...swap.refundTxid ? { refundTxid: swap.refundTxid } : {},
4342
4346
  ...swap.lockupSpendTxids?.length ? { lockupSpendTxids: [...swap.lockupSpendTxids] } : {},
4347
+ ...swap.settlementPreimageHex ? { settlementPreimageHex: swap.settlementPreimageHex } : {},
4343
4348
  ...swap.failure ? { failure: swap.failure } : {},
4344
4349
  ...swap.claimFailure ? { claimFailure: swap.claimFailure } : {},
4345
4350
  ...swap.blockedReason ? { blockedReason: swap.blockedReason } : {}
@@ -4375,6 +4380,7 @@ function updateRfqSwapRecord(record, swap) {
4375
4380
  const {
4376
4381
  refundTxid: _refundTxid,
4377
4382
  lockupSpendTxids: _lockupSpendTxids,
4383
+ settlementPreimageHex: _settlementPreimageHex,
4378
4384
  failure: _failure,
4379
4385
  claimFailure: _claimFailure,
4380
4386
  blockedReason: _blockedReason,
@@ -4422,6 +4428,7 @@ function rebuildRfqSwap(record, params) {
4422
4428
  updatedAt: stored.updatedAt,
4423
4429
  ...stored.refundTxid ? { refundTxid: stored.refundTxid } : {},
4424
4430
  ...stored.lockupSpendTxids?.length ? { lockupSpendTxids: [...stored.lockupSpendTxids] } : {},
4431
+ ...stored.settlementPreimageHex ? { settlementPreimageHex: stored.settlementPreimageHex } : {},
4425
4432
  ...stored.failure ? { failure: stored.failure } : {},
4426
4433
  ...stored.claimFailure ? { claimFailure: stored.claimFailure } : {},
4427
4434
  ...stored.blockedReason ? { blockedReason: stored.blockedReason } : {}
@@ -4440,6 +4447,7 @@ function shouldRetainRfqSwap(record, now) {
4440
4447
 
4441
4448
  // src/swapManager.ts
4442
4449
  var import_base15 = require("@scure/base");
4450
+ var import_sdk21 = require("@arkade-os/sdk");
4443
4451
  init_onchainHtlc();
4444
4452
  init_lockupContract();
4445
4453
  function nextOnchainAction(input) {
@@ -4938,6 +4946,7 @@ var RfqSwapManager = class {
4938
4946
  });
4939
4947
  return;
4940
4948
  }
4949
+ if (!(0, import_sdk21.isContractVtxoEvent)(event)) return;
4941
4950
  const swap = this.byLockupScript.get(event.contractScript);
4942
4951
  if (!swap) return;
4943
4952
  void this.pollSwap(swap).catch(() => {
@@ -5011,6 +5020,7 @@ var RfqSwapManager = class {
5011
5020
  * script for its whole life. Best-effort — the swap is over either way. */
5012
5021
  retireContract(swap) {
5013
5022
  if (!this.deps.contracts || !this.registered.get(swap.rfqId)) return;
5023
+ if (!LOCKUP_RETIRABLE.includes(swap.state)) return;
5014
5024
  void this.deps.contracts.setContractWatchState(import_base15.hex.encode(swap.lockupPkScript), "retained").catch((error) => this.emitFailed(swap, error));
5015
5025
  }
5016
5026
  arm() {
@@ -5050,6 +5060,7 @@ var RfqSwapManager = class {
5050
5060
  }
5051
5061
  if (fate.fate === "claimed" || fate.fate === "returned") {
5052
5062
  this.stampLockupSpends(swap, fate.spends);
5063
+ if (fate.fate === "claimed") this.stampSettlementPreimage(swap, fate.preimage);
5053
5064
  this.setState(swap, fate.fate === "claimed" ? "settled" : "refunded");
5054
5065
  return;
5055
5066
  }
@@ -5348,6 +5359,19 @@ var RfqSwapManager = class {
5348
5359
  swap.lockupSpendTxids = txids;
5349
5360
  this.touch(swap);
5350
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
+ }
5351
5375
  touch(swap) {
5352
5376
  swap.updatedAt = this.config.now();
5353
5377
  this.dirty.add(swap.rfqId);
@@ -5483,7 +5507,7 @@ var outpointKey = (vtxo) => `${vtxo.txid}:${vtxo.vout}`;
5483
5507
 
5484
5508
  // src/watch.ts
5485
5509
  var import_base16 = require("@scure/base");
5486
- var import_sdk21 = require("@arkade-os/sdk");
5510
+ var import_sdk22 = require("@arkade-os/sdk");
5487
5511
  var TERMINAL = ["fulfilled", "cancelled", "recoverable"];
5488
5512
  var assetSwapSource = (repository) => ({
5489
5513
  list: () => getAssetSwaps(repository),
@@ -5515,7 +5539,7 @@ async function watchOfferSwaps({
5515
5539
  wallet.getAddress(),
5516
5540
  wallet.getArkadeReader()
5517
5541
  ]);
5518
- const operatorPubkey = import_sdk21.ArkAddress.decode(address).serverPubKey;
5542
+ const operatorPubkey = import_sdk22.ArkAddress.decode(address).serverPubKey;
5519
5543
  let queue = Promise.resolve();
5520
5544
  const enqueue = (task) => {
5521
5545
  queue = queue.then(task).catch(() => {
@@ -5530,7 +5554,7 @@ async function watchOfferSwaps({
5530
5554
  return classifyDepositSpend(
5531
5555
  decodeOffer(import_base16.hex.decode(swap.offerHex)),
5532
5556
  operatorPubkey,
5533
- txs.map((psbt) => import_sdk21.Transaction.fromPSBT(import_base16.base64.decode(psbt))),
5557
+ txs.map((psbt) => import_sdk22.Transaction.fromPSBT(import_base16.base64.decode(psbt))),
5534
5558
  { txid: vtxo.txid, vout: vtxo.vout }
5535
5559
  );
5536
5560
  } catch {
@@ -5558,7 +5582,7 @@ async function watchOfferSwaps({
5558
5582
  }
5559
5583
  };
5560
5584
  const unsubscribe = manager.onContractEvent((event) => {
5561
- if (event.type !== "vtxo_spent") return;
5585
+ if (!(0, import_sdk22.isContractVtxoEvent)(event) || event.type !== "vtxo_spent") return;
5562
5586
  enqueue(() => handleSpend(event));
5563
5587
  });
5564
5588
  return {
@@ -5741,7 +5765,7 @@ var createSwapDrive = (config) => {
5741
5765
  const secret = rfqClaimSecretOf(record);
5742
5766
  if (!secret) throw new Error(`rfq swap ${swap.rfqId} carries no claim secret`);
5743
5767
  const preimage = await preimageForSwapRecord(wallet, secret);
5744
- const signer = await (0, import_sdk22.contractSigner)(wallet, await (0, import_sdk22.identityDescriptor)(wallet.identity));
5768
+ const signer = await (0, import_sdk23.contractSigner)(wallet, await (0, import_sdk23.identityDescriptor)(wallet.identity));
5745
5769
  const claimKey = record.profile.claimKey;
5746
5770
  if (typeof claimKey === "string") {
5747
5771
  const held = import_base17.hex.encode(await signer.xOnlyPublicKey());
@@ -5799,10 +5823,10 @@ var createSwapDrive = (config) => {
5799
5823
  return track(
5800
5824
  pushClaim(operator, {
5801
5825
  contract: script,
5802
- receiver: await (0, import_sdk22.contractSigner)(wallet, secret.signingDescriptor),
5826
+ receiver: await (0, import_sdk23.contractSigner)(wallet, secret.signingDescriptor),
5803
5827
  preimage: await preimageForSwapRecord(wallet, secret),
5804
5828
  vtxos,
5805
- destinationPkScript: import_sdk22.ArkAddress.decode(payoutAddress).pkScript,
5829
+ destinationPkScript: import_sdk23.ArkAddress.decode(payoutAddress).pkScript,
5806
5830
  // Passed straight through, both of them: the manager's own value
5807
5831
  // check decides WHEN to act, `pushClaim`'s decides whether `P` is
5808
5832
  // published, and it is the one with nothing between it and the
@@ -5882,7 +5906,7 @@ var createSwapDrive = (config) => {
5882
5906
  ...tx.createdAt ? { createdAt: Math.floor(tx.createdAt / 1e3) } : {}
5883
5907
  }));
5884
5908
  const { restored, scannedTxids } = await restoreAssetSwaps(indexer, txs, /* @__PURE__ */ new Set(), {
5885
- operatorPubkey: import_sdk22.ArkAddress.decode(address).serverPubKey,
5909
+ operatorPubkey: import_sdk23.ArkAddress.decode(address).serverPubKey,
5886
5910
  scanned
5887
5911
  });
5888
5912
  const byDeposit = new Map(restored.map((s) => [`${s.swapPkScript}:${s.fundingTxid}`, s]));
@@ -6581,17 +6605,17 @@ var verifyPlanLegs = (plan, legs, give) => {
6581
6605
  // src/client/quoteRfq.ts
6582
6606
  var import_base18 = require("@scure/base");
6583
6607
  var import_secp256k12 = require("@noble/curves/secp256k1.js");
6584
- var import_sdk25 = require("@arkade-os/sdk");
6608
+ var import_sdk26 = require("@arkade-os/sdk");
6585
6609
  init_claimPacket();
6586
6610
  init_onchainHtlc();
6587
6611
  init_onchainHtlc();
6588
6612
 
6589
6613
  // src/payment/onchainSwap.ts
6590
- var import_sdk24 = require("@arkade-os/sdk");
6614
+ var import_sdk25 = require("@arkade-os/sdk");
6591
6615
  init_onchainHtlc();
6592
6616
 
6593
6617
  // src/payment/swapRail.ts
6594
- var import_sdk23 = require("@arkade-os/sdk");
6618
+ var import_sdk24 = require("@arkade-os/sdk");
6595
6619
 
6596
6620
  // src/client/sats.ts
6597
6621
  var satsOf = (value, field) => {
@@ -6642,14 +6666,14 @@ var parseRfqQuote = (quote) => ({
6642
6666
 
6643
6667
  // src/client/quoteRfq.ts
6644
6668
  var covenantInputs = (input) => {
6645
- const network = (0, import_sdk25.networkFromArkadeInfo)(input.info);
6669
+ const network = (0, import_sdk26.networkFromArkadeInfo)(input.info);
6646
6670
  const arkade2 = input.corridors.get("arkade").deps;
6647
6671
  return {
6648
- operatorPubkey: (0, import_sdk25.toXOnly)(import_base18.hex.decode(input.info.signerPubkey), "ark signer key"),
6672
+ operatorPubkey: (0, import_sdk26.toXOnly)(import_base18.hex.decode(input.info.signerPubkey), "ark signer key"),
6649
6673
  // The per-network pin the arkade module already resolved, never a key
6650
6674
  // the operator reports about itself: this one ends up in a covenant leaf
6651
6675
  // that decides who can move the funds.
6652
- emulatorPubkey: (0, import_sdk25.toXOnly)(import_base18.hex.decode(arkade2.emulatorPubkey), "emulator signer key"),
6676
+ emulatorPubkey: (0, import_sdk26.toXOnly)(import_base18.hex.decode(arkade2.emulatorPubkey), "emulator signer key"),
6653
6677
  claimDelay: unilateralClaimDelay(Number(input.info.unilateralExitDelay)),
6654
6678
  hrp: network.hrp
6655
6679
  };
@@ -6695,7 +6719,7 @@ var quoteLightningSend = async (input) => {
6695
6719
  }
6696
6720
  const pair = rfqPairFor(input.legs.give, input.legs.take);
6697
6721
  const rfqId = newRfqId();
6698
- const secrets = await (0, import_sdk25.provisionRefundKey)(input.wallet);
6722
+ const secrets = await (0, import_sdk26.provisionRefundKey)(input.wallet);
6699
6723
  const wire = await input.transport.requestQuote(
6700
6724
  lightningSendRequest({
6701
6725
  rfqId,
@@ -6767,7 +6791,7 @@ var quoteLightningReceive = async (input) => {
6767
6791
  const pinned = pinnedFor(input);
6768
6792
  const pair = rfqPairFor(input.legs.give, input.legs.take);
6769
6793
  const rfqId = newRfqId();
6770
- const secrets = await (0, import_sdk25.provisionClaimSecret)(input.wallet);
6794
+ const secrets = await (0, import_sdk26.provisionClaimSecret)(input.wallet);
6771
6795
  const paymentHash = import_base18.hex.encode(secrets.paymentHash);
6772
6796
  const payoutAddress = await input.wallet.getAddress();
6773
6797
  const lightning = input.corridors.get("lightning").deps;
@@ -6892,8 +6916,8 @@ var quoteOnchainSend = async (input) => {
6892
6916
  claimVsize: onchain.claimVsize
6893
6917
  }) : void 0;
6894
6918
  const quoted = claimFee === void 0 ? pinned : { on: pinned.on, value: pinned.value + claimFee, source: pinned.source };
6895
- const secrets = await (0, import_sdk25.provisionClaimSecret)(input.wallet);
6896
- const payoutKey = await (0, import_sdk25.provisionRefundKey)(input.wallet);
6919
+ const secrets = await (0, import_sdk26.provisionClaimSecret)(input.wallet);
6920
+ const payoutKey = await (0, import_sdk26.provisionRefundKey)(input.wallet);
6897
6921
  const paymentHash = import_base18.hex.encode(secrets.paymentHash);
6898
6922
  const wire = await input.transport.requestQuote(
6899
6923
  withCanonicalAmount(
@@ -7000,7 +7024,7 @@ var quoteOnchainSend = async (input) => {
7000
7024
  };
7001
7025
 
7002
7026
  // src/client/verbs.ts
7003
- var import_sdk26 = require("@arkade-os/sdk");
7027
+ var import_sdk27 = require("@arkade-os/sdk");
7004
7028
  var enforceFeeCeiling = (quote, call, policy) => {
7005
7029
  let ceiling;
7006
7030
  for (const [source, limit] of [
@@ -7025,9 +7049,9 @@ var settle = async (deps, input, maxFee) => {
7025
7049
  return deps.accept(quote);
7026
7050
  };
7027
7051
  var pay = async (deps, destination, options = {}) => {
7028
- const arkade2 = (0, import_sdk26.arkTarget)(destination);
7052
+ const arkade2 = (0, import_sdk27.arkTarget)(destination);
7029
7053
  if (arkade2 !== void 0) {
7030
- const amount = (0, import_sdk26.resolveSendAmount)(
7054
+ const amount = (0, import_sdk27.resolveSendAmount)(
7031
7055
  "ark",
7032
7056
  destination,
7033
7057
  options.amount === void 0 ? void 0 : satsOf(options.amount, "amount")
@@ -7347,7 +7371,7 @@ var createSwapClient = (config) => {
7347
7371
  var import_base20 = require("@scure/base");
7348
7372
  var import_legacy4 = require("@noble/hashes/legacy.js");
7349
7373
  var import_sha26 = require("@noble/hashes/sha2.js");
7350
- var import_sdk27 = require("@arkade-os/sdk");
7374
+ var import_sdk28 = require("@arkade-os/sdk");
7351
7375
  init_claimPacket();
7352
7376
  var CovclaimdRevealError = class extends Error {
7353
7377
  name = "CovclaimdRevealError";
@@ -7452,7 +7476,7 @@ function revealFieldsFromScript(script) {
7452
7476
  }
7453
7477
  async function revealClaimPacket(client, input) {
7454
7478
  const fields = revealFieldsFromScript(input.script);
7455
- if (import_base20.hex.encode(import_sdk27.ArkAddress.decode(input.address).pkScript) !== import_base20.hex.encode(input.script.pkScript)) {
7479
+ if (import_base20.hex.encode(import_sdk28.ArkAddress.decode(input.address).pkScript) !== import_base20.hex.encode(input.script.pkScript)) {
7456
7480
  throw new Error("address does not belong to this covenant");
7457
7481
  }
7458
7482
  if (import_base20.hex.encode((0, import_legacy4.ripemd160)((0, import_sha26.sha256)(input.preimage))) !== import_base20.hex.encode(input.script.options.preimageHash)) {
@@ -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-DwF4nDkm.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-DwF4nDkm.cjs';
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-C7wOrIpV.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-C7wOrIpV.cjs';
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
6
  import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-RONK76D7.cjs';
7
7
  export { S as SwapRefusal } from './rfq-RONK76D7.cjs';
8
8
  import * as btc from '@scure/btc-signer';
9
9
  import { OnchainProvider, NetworkName, IWallet, VHTLC } from '@arkade-os/sdk';
10
- import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-C3hv5rOW.cjs';
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.
@@ -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-C-jdh0_4.js';
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-C-jdh0_4.js';
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-BVhyWIM0.js';
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-BVhyWIM0.js';
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-CToRX7Gj.js';
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-CToRX7Gj.js';
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-D3A1amV_.js';
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-D3A1amV_.js';
6
6
  import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-RONK76D7.js';
7
7
  export { S as SwapRefusal } from './rfq-RONK76D7.js';
8
8
  import * as btc from '@scure/btc-signer';
9
9
  import { OnchainProvider, NetworkName, IWallet, VHTLC } from '@arkade-os/sdk';
10
- import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-mIKau97G.js';
10
+ import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-BJ-KKgwU.js';
11
11
 
12
12
  /**
13
13
  * The alias table, filled from discovery.
package/dist/advanced.js CHANGED
@@ -133,7 +133,7 @@ import {
133
133
  withCanonicalAmount,
134
134
  withOfferStatus,
135
135
  withRfqState
136
- } from "./chunk-2QQYOW46.js";
136
+ } from "./chunk-O3XMAZXS.js";
137
137
  import {
138
138
  ACTIVITY_TOKEN,
139
139
  CORRIDOR_PASS,
@@ -148,7 +148,7 @@ import {
148
148
  onchainCorridor,
149
149
  readsChain,
150
150
  recordOutcome
151
- } from "./chunk-4L2CNVXB.js";
151
+ } from "./chunk-BQLGQ4WB.js";
152
152
  import {
153
153
  SwapRefusal,
154
154
  sealClaimPacket
@@ -212,6 +212,7 @@ var swap_want_btc_program_default = {
212
212
 
213
213
  // src/coverage.ts
214
214
  var RETIRABLE = ["fulfilled", "cancelled"];
215
+ var LOCKUP_RETIRABLE = ["settled", "refunded"];
215
216
  var issuedAt = /* @__PURE__ */ new Map();
216
217
  var inFlight = /* @__PURE__ */ new Map();
217
218
  async function serialize(script, task) {
@@ -1852,6 +1853,7 @@ var managerState = (swap) => ({
1852
1853
  updatedAt: swap.updatedAt,
1853
1854
  ...swap.refundTxid ? { refundTxid: swap.refundTxid } : {},
1854
1855
  ...swap.lockupSpendTxids?.length ? { lockupSpendTxids: [...swap.lockupSpendTxids] } : {},
1856
+ ...swap.settlementPreimageHex ? { settlementPreimageHex: swap.settlementPreimageHex } : {},
1855
1857
  ...swap.failure ? { failure: swap.failure } : {},
1856
1858
  ...swap.claimFailure ? { claimFailure: swap.claimFailure } : {},
1857
1859
  ...swap.blockedReason ? { blockedReason: swap.blockedReason } : {}
@@ -1887,6 +1889,7 @@ function updateRfqSwapRecord(record, swap) {
1887
1889
  const {
1888
1890
  refundTxid: _refundTxid,
1889
1891
  lockupSpendTxids: _lockupSpendTxids,
1892
+ settlementPreimageHex: _settlementPreimageHex,
1890
1893
  failure: _failure,
1891
1894
  claimFailure: _claimFailure,
1892
1895
  blockedReason: _blockedReason,
@@ -1934,6 +1937,7 @@ function rebuildRfqSwap(record, params) {
1934
1937
  updatedAt: stored.updatedAt,
1935
1938
  ...stored.refundTxid ? { refundTxid: stored.refundTxid } : {},
1936
1939
  ...stored.lockupSpendTxids?.length ? { lockupSpendTxids: [...stored.lockupSpendTxids] } : {},
1940
+ ...stored.settlementPreimageHex ? { settlementPreimageHex: stored.settlementPreimageHex } : {},
1937
1941
  ...stored.failure ? { failure: stored.failure } : {},
1938
1942
  ...stored.claimFailure ? { claimFailure: stored.claimFailure } : {},
1939
1943
  ...stored.blockedReason ? { blockedReason: stored.blockedReason } : {}
@@ -1952,6 +1956,9 @@ function shouldRetainRfqSwap(record, now) {
1952
1956
 
1953
1957
  // src/swapManager.ts
1954
1958
  import { hex as hex8 } from "@scure/base";
1959
+ import {
1960
+ isContractVtxoEvent
1961
+ } from "@arkade-os/sdk";
1955
1962
  function nextOnchainAction(input) {
1956
1963
  switch (input.phase.phase) {
1957
1964
  case "unfunded":
@@ -2448,6 +2455,7 @@ var RfqSwapManager = class {
2448
2455
  });
2449
2456
  return;
2450
2457
  }
2458
+ if (!isContractVtxoEvent(event)) return;
2451
2459
  const swap = this.byLockupScript.get(event.contractScript);
2452
2460
  if (!swap) return;
2453
2461
  void this.pollSwap(swap).catch(() => {
@@ -2521,6 +2529,7 @@ var RfqSwapManager = class {
2521
2529
  * script for its whole life. Best-effort — the swap is over either way. */
2522
2530
  retireContract(swap) {
2523
2531
  if (!this.deps.contracts || !this.registered.get(swap.rfqId)) return;
2532
+ if (!LOCKUP_RETIRABLE.includes(swap.state)) return;
2524
2533
  void this.deps.contracts.setContractWatchState(hex8.encode(swap.lockupPkScript), "retained").catch((error) => this.emitFailed(swap, error));
2525
2534
  }
2526
2535
  arm() {
@@ -2560,6 +2569,7 @@ var RfqSwapManager = class {
2560
2569
  }
2561
2570
  if (fate.fate === "claimed" || fate.fate === "returned") {
2562
2571
  this.stampLockupSpends(swap, fate.spends);
2572
+ if (fate.fate === "claimed") this.stampSettlementPreimage(swap, fate.preimage);
2563
2573
  this.setState(swap, fate.fate === "claimed" ? "settled" : "refunded");
2564
2574
  return;
2565
2575
  }
@@ -2858,6 +2868,19 @@ var RfqSwapManager = class {
2858
2868
  swap.lockupSpendTxids = txids;
2859
2869
  this.touch(swap);
2860
2870
  }
2871
+ /**
2872
+ * Keep the preimage that settled a Lightning send.
2873
+ *
2874
+ * Only that leg. A receive's `claimed` verdict reveals the wallet's own
2875
+ * claim secret and an onchain send's reveals the one it minted — both
2876
+ * already recoverable from `profile`, so stamping either would be a second
2877
+ * home for a secret that has one.
2878
+ */
2879
+ stampSettlementPreimage(swap, preimage) {
2880
+ if (swap.kind !== "lightning_send") return;
2881
+ swap.settlementPreimageHex = hex8.encode(preimage);
2882
+ this.touch(swap);
2883
+ }
2861
2884
  touch(swap) {
2862
2885
  swap.updatedAt = this.config.now();
2863
2886
  this.dirty.add(swap.rfqId);
@@ -2995,6 +3018,7 @@ var outpointKey = (vtxo) => `${vtxo.txid}:${vtxo.vout}`;
2995
3018
  import { base64 as base643, hex as hex9 } from "@scure/base";
2996
3019
  import {
2997
3020
  ArkAddress as ArkAddress3,
3021
+ isContractVtxoEvent as isContractVtxoEvent2,
2998
3022
  Transaction as Transaction3
2999
3023
  } from "@arkade-os/sdk";
3000
3024
  var TERMINAL = ["fulfilled", "cancelled", "recoverable"];
@@ -3071,7 +3095,7 @@ async function watchOfferSwaps({
3071
3095
  }
3072
3096
  };
3073
3097
  const unsubscribe = manager.onContractEvent((event) => {
3074
- if (event.type !== "vtxo_spent") return;
3098
+ if (!isContractVtxoEvent2(event) || event.type !== "vtxo_spent") return;
3075
3099
  enqueue(() => handleSpend(event));
3076
3100
  });
3077
3101
  return {
@@ -41,7 +41,7 @@ import {
41
41
  spendTxidsOf,
42
42
  walletOperator,
43
43
  watchOfferSwaps
44
- } from "./chunk-4L2CNVXB.js";
44
+ } from "./chunk-BQLGQ4WB.js";
45
45
  import {
46
46
  ARKADE_BTC,
47
47
  AddressMismatch,
@@ -1469,6 +1469,7 @@ var rfqRecordOf = (record) => ({
1469
1469
  updatedAt: record.updatedAt,
1470
1470
  ...record.refundTxid === void 0 ? {} : { refundTxid: record.refundTxid },
1471
1471
  ...record.lockupSpendTxids?.length ? { lockupSpendTxids: [...record.lockupSpendTxids] } : {},
1472
+ ...record.settlementPreimageHex === void 0 ? {} : { settlementPreimageHex: record.settlementPreimageHex },
1472
1473
  ...record.failure === void 0 ? {} : { failure: record.failure },
1473
1474
  ...record.claimFailure === void 0 ? {} : { claimFailure: record.claimFailure },
1474
1475
  ...record.blockedReason === void 0 ? {} : { blockedReason: record.blockedReason }
@@ -1477,6 +1478,7 @@ var withRfqState = (record, state) => {
1477
1478
  const {
1478
1479
  refundTxid: _refundTxid,
1479
1480
  lockupSpendTxids: _lockupSpendTxids,
1481
+ settlementPreimageHex: _settlementPreimageHex,
1480
1482
  failure: _failure,
1481
1483
  claimFailure: _claimFailure,
1482
1484
  blockedReason: _blockedReason,
@@ -1489,6 +1491,7 @@ var withRfqState = (record, state) => {
1489
1491
  updatedAt: state.updatedAt,
1490
1492
  ...state.refundTxid === void 0 ? {} : { refundTxid: state.refundTxid },
1491
1493
  ...state.lockupSpendTxids?.length ? { lockupSpendTxids: [...state.lockupSpendTxids] } : {},
1494
+ ...state.settlementPreimageHex === void 0 ? {} : { settlementPreimageHex: state.settlementPreimageHex },
1492
1495
  ...state.failure === void 0 ? {} : { failure: state.failure },
1493
1496
  ...state.claimFailure === void 0 ? {} : { claimFailure: state.claimFailure },
1494
1497
  ...state.blockedReason === void 0 ? {} : { blockedReason: state.blockedReason }
@@ -1,5 +1,5 @@
1
1
  import { IWallet, NetworkName, Network, SignerSet, ArkadeInfo, VHTLC, ProvisionedKey, ProvisionedClaimSecret } from '@arkade-os/sdk';
2
- import { a$ as SwapOperator, c as AssetSwapRepository, j as Pubkey, b1 as RfqSwapManagerCallbacks, C as Corridor, I as Instrument, b2 as RfqSwapActionName, N as NetworkRef, A as AssetId, af as SnapshotRef, _ as MarketBackend, K as CardMarketRef, $ as MarketRef, w as AssetRef, o as AmountOn, ag as Swap, M as CorridorId, U as DepositArtifact, i as QuoteInput, a3 as Quote, a8 as RankedBid, aj as SwapUpdate, ak as Unsubscribe, S as SwapRecord, Q as QuoteId, a1 as Outcome, L as LockupSpendIndexer, a_ as SwapContractRegistry, g as ResolvedEndpoint, P as PinnedAmount, O as OfferSwapRecord, y as AssetSwapId, ah as SwapFamily, f as RouteResolution } from './repository-CToRX7Gj.js';
2
+ import { a$ as SwapOperator, c as AssetSwapRepository, j as Pubkey, b1 as RfqSwapManagerCallbacks, C as Corridor, I as Instrument, b2 as RfqSwapActionName, N as NetworkRef, A as AssetId, af as SnapshotRef, _ as MarketBackend, K as CardMarketRef, $ as MarketRef, w as AssetRef, o as AmountOn, ag as Swap, M as CorridorId, U as DepositArtifact, i as QuoteInput, a3 as Quote, a8 as RankedBid, aj as SwapUpdate, ak as Unsubscribe, S as SwapRecord, Q as QuoteId, a1 as Outcome, L as LockupSpendIndexer, a_ as SwapContractRegistry, g as ResolvedEndpoint, P as PinnedAmount, O as OfferSwapRecord, y as AssetSwapId, ah as SwapFamily, f as RouteResolution } from './repository-D3A1amV_.js';
3
3
  import { I as InvoiceFacts, C as ChainSource, R as RfqQuote, a as RfqTransport, L as LightningSendContractParams, b as LightningReceiveContractParams, O as OnchainHtlc, c as OnchainHtlcParams, d as OnchainNetwork, S as SwapRefusal } from './rfq-RONK76D7.js';
4
4
  import { Network as Network$1, LocalCardInput, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { IWallet, NetworkName, Network, SignerSet, ArkadeInfo, VHTLC, ProvisionedKey, ProvisionedClaimSecret } from '@arkade-os/sdk';
2
- import { a$ as SwapOperator, c as AssetSwapRepository, j as Pubkey, b1 as RfqSwapManagerCallbacks, C as Corridor, I as Instrument, b2 as RfqSwapActionName, N as NetworkRef, A as AssetId, af as SnapshotRef, _ as MarketBackend, K as CardMarketRef, $ as MarketRef, w as AssetRef, o as AmountOn, ag as Swap, M as CorridorId, U as DepositArtifact, i as QuoteInput, a3 as Quote, a8 as RankedBid, aj as SwapUpdate, ak as Unsubscribe, S as SwapRecord, Q as QuoteId, a1 as Outcome, L as LockupSpendIndexer, a_ as SwapContractRegistry, g as ResolvedEndpoint, P as PinnedAmount, O as OfferSwapRecord, y as AssetSwapId, ah as SwapFamily, f as RouteResolution } from './repository-C7wOrIpV.cjs';
2
+ import { a$ as SwapOperator, c as AssetSwapRepository, j as Pubkey, b1 as RfqSwapManagerCallbacks, C as Corridor, I as Instrument, b2 as RfqSwapActionName, N as NetworkRef, A as AssetId, af as SnapshotRef, _ as MarketBackend, K as CardMarketRef, $ as MarketRef, w as AssetRef, o as AmountOn, ag as Swap, M as CorridorId, U as DepositArtifact, i as QuoteInput, a3 as Quote, a8 as RankedBid, aj as SwapUpdate, ak as Unsubscribe, S as SwapRecord, Q as QuoteId, a1 as Outcome, L as LockupSpendIndexer, a_ as SwapContractRegistry, g as ResolvedEndpoint, P as PinnedAmount, O as OfferSwapRecord, y as AssetSwapId, ah as SwapFamily, f as RouteResolution } from './repository-CDlK003C.cjs';
3
3
  import { I as InvoiceFacts, C as ChainSource, R as RfqQuote, a as RfqTransport, L as LightningSendContractParams, b as LightningReceiveContractParams, O as OnchainHtlc, c as OnchainHtlcParams, d as OnchainNetwork, S as SwapRefusal } from './rfq-RONK76D7.cjs';
4
4
  import { Network as Network$1, LocalCardInput, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
5
5