@arkade-os/swap 0.1.5 → 0.1.7

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.
Files changed (29) hide show
  1. package/dist/advanced.cjs +228 -63
  2. package/dist/advanced.d.cts +6 -6
  3. package/dist/advanced.d.ts +6 -6
  4. package/dist/advanced.js +2 -2
  5. package/dist/{chunk-GJKGPE3S.js → chunk-QFM55KP2.js} +175 -29
  6. package/dist/{chunk-HDCC3JZR.js → chunk-SDPNWPGY.js} +30 -2
  7. package/dist/index.cjs +219 -54
  8. package/dist/index.d.cts +5 -5
  9. package/dist/index.d.ts +5 -5
  10. package/dist/index.js +2 -2
  11. package/dist/{lockupContract-CdXh9yIr.d.ts → lockupContract-CKPFpIt9.d.ts} +1 -1
  12. package/dist/{lockupContract-QfbsjyXG.d.cts → lockupContract-CpJXTjX_.d.cts} +1 -1
  13. package/dist/{offer-BxzPQ6zh.d.cts → offer-Boxive2u.d.cts} +1 -1
  14. package/dist/{offer-Q1lVhrVX.d.ts → offer-Drw1k_jt.d.ts} +1 -1
  15. package/dist/{offerFillPlan-BfcxbVvw.d.cts → offerFillPlan-BxNkWLtw.d.cts} +2 -2
  16. package/dist/{offerFillPlan-C11P2ek2.d.ts → offerFillPlan-D2N4s7Xe.d.ts} +2 -2
  17. package/dist/protocol.cjs +83 -33
  18. package/dist/protocol.d.cts +11 -27
  19. package/dist/protocol.d.ts +11 -27
  20. package/dist/protocol.js +1 -1
  21. package/dist/repositories/realm/index.d.cts +1 -1
  22. package/dist/repositories/realm/index.d.ts +1 -1
  23. package/dist/repositories/sqlite/index.d.cts +1 -1
  24. package/dist/repositories/sqlite/index.d.ts +1 -1
  25. package/dist/{repository-Cut4eEkm.d.cts → repository-DFDNvcZ7.d.cts} +26 -4
  26. package/dist/{repository-BOQ1qYoj.d.ts → repository-Dn1V17T2.d.ts} +26 -4
  27. package/dist/{watch-D15U0QpD.d.ts → watch-D-mc_wfD.d.ts} +1 -1
  28. package/dist/{watch-D4PeBZ3H.d.cts → watch-DFNMY2K-.d.cts} +1 -1
  29. package/package.json +2 -2
@@ -1,14 +1,14 @@
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 './offerFillPlan-BfcxbVvw.cjs';
2
- export { e as AcceptConflict, f as AcceptInput, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, k as AssetRfqPreparation, l as AttestingRfqTransport, B as BuildOfferFillPlanOpts, m as CORRIDOR_FACTORIES, n as CancelInput, o as CancelOutcome, p as ClaimedDestination, q as ClientDisposed, r as CorridorBase, s as CorridorClaim, t as CorridorCovenant, u as CorridorDeadline, v as CorridorDeps, w as CorridorDepsByCorridor, x as CorridorDrive, y as CorridorLockup, z as CorridorModule, E as CorridorOverrides, F as CorridorPass, G as CorridorRfqPreparation, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, J as DiscoveryIndexInput, K as DiscoverySnapshotUnavailable, N as DriveMode, P as DriveRefusal, Q as ExchangeOptions, R as FEED_TTL_MS, T as FeeCeiling, U as FeedFetch, V as FeedQuoteInput, W as FillSponsor, X as FillSponsorFare, Y as INDEXED_NETWORKS, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a0 as LockupOwner, a1 as Market, a2 as MarketLeg, a3 as MaxFeeExceeded, a4 as MissingCorridorDep, a5 as NotCancellable, a6 as OFFER_FILL_OWNERS, a7 as OFFER_FILL_TEMPLATE, a8 as ONCHAIN_CLAIM_FEE_RATE_SATVB, a9 as ObservationSeam, aa as OfferPreparation, ab as OnchainClaim, ac as OnchainRefund, ad as OperatorUnreachable, ae as ParsedRfqQuote, af as PayOptions, ag as PayResult, ah as QuoteCheck, ai as QuoteExpired, aj as QuotePreparation, ak as QuoteVerificationFailed, al as REGISTRY_URL, am as ReceiveArtifact, an as ReceiveOptions, ao as ReceiveRequest, ap as RecoveryResult, aq as RegisteredAsset, ar as RfqAuctionPolicy, as as RfqPreparation, at as RfqQuoteInput, au as RfqRendezvous, av as RfqTransportFactory, aw as RouteSide, ax as SWAP_ERROR_NAMES, ay as SwapClient, az as SwapClientConfig, aA as SwapDrive, aB as SwapDriveConfig, aC as SwapDriveRefusedError, aD as SwapError, aE as SwapErrorName, aF as SwapFilter, aG as UnsupportedRoute, aH as VerbDeps, aI as acceptQuote, aJ as attesting, aK as buildOfferFillPlan, aL as cancelSwap, aM as canonicalAssetId, aN as cardMarketOf, aO as chooseMarket, aP as conflictingFields, aQ as corridorSet, aR as createNostrTransportFactory, aS as createSwapClient, aT as createSwapDrive, aU as deepFreeze, aV as digestJointGraph, aW as discoveryIndex, aX as eligibleMarkets, aY as enforceFeeCeiling, aZ as exchange, a_ as feedFetch, a$ as feedSpread, b0 as isAddressable, b1 as isCardMarket, b2 as isIndexedNetwork, b3 as isSwapError, b4 as isUsableCard, b5 as liveArkadeInfo, b6 as liveOperatorInfo, b7 as marketBackendOf, b8 as marketKeyOf, b9 as marketOf, ba as marketRefOf, bb as nostrTransportFactory, bc as parseRfqQuote, bd as pay, be as quoteFromFeed, bf as quoteViaRfq, bg as readableRecord, bh as receive, bi as resolveCorridorBase, bj as resolveCorridorDeps, bk as rfqLeg, bl as rfqPairFor, bm as swapRecordOf, bn as toDiscoveryLeg, bo as unsignedPsbtBytes, bp as usableMarkets, bq as verifyJointGraph, br as verifyOfferFillPlan, bs as verifyPlanLegs, bt as withCanonicalAmount } from './offerFillPlan-BfcxbVvw.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 './offerFillPlan-BxNkWLtw.cjs';
2
+ export { e as AcceptConflict, f as AcceptInput, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, k as AssetRfqPreparation, l as AttestingRfqTransport, B as BuildOfferFillPlanOpts, m as CORRIDOR_FACTORIES, n as CancelInput, o as CancelOutcome, p as ClaimedDestination, q as ClientDisposed, r as CorridorBase, s as CorridorClaim, t as CorridorCovenant, u as CorridorDeadline, v as CorridorDeps, w as CorridorDepsByCorridor, x as CorridorDrive, y as CorridorLockup, z as CorridorModule, E as CorridorOverrides, F as CorridorPass, G as CorridorRfqPreparation, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, J as DiscoveryIndexInput, K as DiscoverySnapshotUnavailable, N as DriveMode, P as DriveRefusal, Q as ExchangeOptions, R as FEED_TTL_MS, T as FeeCeiling, U as FeedFetch, V as FeedQuoteInput, W as FillSponsor, X as FillSponsorFare, Y as INDEXED_NETWORKS, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a0 as LockupOwner, a1 as Market, a2 as MarketLeg, a3 as MaxFeeExceeded, a4 as MissingCorridorDep, a5 as NotCancellable, a6 as OFFER_FILL_OWNERS, a7 as OFFER_FILL_TEMPLATE, a8 as ONCHAIN_CLAIM_FEE_RATE_SATVB, a9 as ObservationSeam, aa as OfferPreparation, ab as OnchainClaim, ac as OnchainRefund, ad as OperatorUnreachable, ae as ParsedRfqQuote, af as PayOptions, ag as PayResult, ah as QuoteCheck, ai as QuoteExpired, aj as QuotePreparation, ak as QuoteVerificationFailed, al as REGISTRY_URL, am as ReceiveArtifact, an as ReceiveOptions, ao as ReceiveRequest, ap as RecoveryResult, aq as RegisteredAsset, ar as RfqAuctionPolicy, as as RfqPreparation, at as RfqQuoteInput, au as RfqRendezvous, av as RfqTransportFactory, aw as RouteSide, ax as SWAP_ERROR_NAMES, ay as SwapClient, az as SwapClientConfig, aA as SwapDrive, aB as SwapDriveConfig, aC as SwapDriveRefusedError, aD as SwapError, aE as SwapErrorName, aF as SwapFilter, aG as UnsupportedRoute, aH as VerbDeps, aI as acceptQuote, aJ as attesting, aK as buildOfferFillPlan, aL as cancelSwap, aM as canonicalAssetId, aN as cardMarketOf, aO as chooseMarket, aP as conflictingFields, aQ as corridorSet, aR as createNostrTransportFactory, aS as createSwapClient, aT as createSwapDrive, aU as deepFreeze, aV as digestJointGraph, aW as discoveryIndex, aX as eligibleMarkets, aY as enforceFeeCeiling, aZ as exchange, a_ as feedFetch, a$ as feedSpread, b0 as isAddressable, b1 as isCardMarket, b2 as isIndexedNetwork, b3 as isSwapError, b4 as isUsableCard, b5 as liveArkadeInfo, b6 as liveOperatorInfo, b7 as marketBackendOf, b8 as marketKeyOf, b9 as marketOf, ba as marketRefOf, bb as nostrTransportFactory, bc as parseRfqQuote, bd as pay, be as quoteFromFeed, bf as quoteViaRfq, bg as readableRecord, bh as receive, bi as resolveCorridorBase, bj as resolveCorridorDeps, bk as rfqLeg, bl as rfqPairFor, bm as swapRecordOf, bn as toDiscoveryLeg, bo as unsignedPsbtBytes, bp as usableMarkets, bq as verifyJointGraph, br as verifyOfferFillPlan, bs as verifyPlanLegs, bt as withCanonicalAmount } from './offerFillPlan-BxNkWLtw.cjs';
3
3
  import { DiscoveredMarket, Side } from '@arkade-os/solver-discovery';
4
- import { N as NetworkRef, A as AssetId, C as Corridor, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, c as AssetSwapStatus, S as SwapRecord, O as OfferSwapRecord, d as AssetSwapRepository, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, h as AssetSwap, L as LockupSpendIndexer, i as RouteResolution, j as ResolvedEndpoint, P as PinnedAmount, I as Instrument, k as Route, l as QuoteInput, m as Pubkey } from './repository-Cut4eEkm.cjs';
5
- export { n as ACTIVITY_TOKEN, o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, r as AmountOn, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, v as AssetIdError, w as AssetIdRefusal, x as AssetNamespace, y as AssetOn, z as AssetPart, B as AssetPaymentInput, D as AssetPaymentTerms, E as AssetRef, F as AssetScale, G as AssetSwapId, H as AtomicDecimal, J as AuctionMarketRef, K as AuctionProvenance, M as BITCOIN_RAILS, T as BTC_ASSET_PART, U as BitcoinRail, V as CORRIDORS, W as CORRIDOR_PASS, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, a2 as Hex, a3 as LOCKUP_OWNER, a4 as MarketBackend, a5 as MarketRef, a6 as OFFER_SWAP_ID_PREFIX, a7 as Outcome, a8 as ParsedAssetId, a9 as Quote, aa as QuoteLeg, ab as RAILS, ac as RFQ_SWAP_ID_PREFIX, ad as RailOf, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, am as RestoredMarketRef, an as RfqAmountSide, ao as SnapshotRef, ap as Swap, aq as SwapFamily, ar as SwapRecordCommon, as as SwapUpdate, at as TaxiIdentity, au as Unsubscribe, av as VerifiedCarrierTerms, aw as arkadeAsset, ax as artifactOf, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aD as corridorOfRail, aE as corridorOutcome, aF as decodeRfqAmount, aG as encodeRfqAmount, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aK as fromRfqAmountSide, aL as fundingWasNotSubmitted, aM as fundsFromWallet, aN as instrumentOf, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, aT as issuanceOf, aU as legOf, aV as offerOutcome, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, aZ as railOfCorridor, a_ as readsChain, a$ as recordArtifact, b0 as recordEndpoint, b1 as recordInstrument, b2 as recordLeg, b3 as recordOutcome, b4 as sameAsset, b5 as swapOf, b6 as toAtomicDecimal, b7 as toRfqAmountSide, b8 as toSafeNumber } from './repository-Cut4eEkm.cjs';
4
+ import { N as NetworkRef, A as AssetId, C as Corridor, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, c as AssetSwapStatus, S as SwapRecord, O as OfferSwapRecord, d as AssetSwapRepository, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, h as AssetSwap, L as LockupSpendIndexer, i as RouteResolution, j as ResolvedEndpoint, P as PinnedAmount, I as Instrument, k as Route, l as QuoteInput, m as Pubkey } from './repository-DFDNvcZ7.cjs';
5
+ export { n as ACTIVITY_TOKEN, o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, r as AmountOn, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, v as AssetIdError, w as AssetIdRefusal, x as AssetNamespace, y as AssetOn, z as AssetPart, B as AssetPaymentInput, D as AssetPaymentTerms, E as AssetRef, F as AssetScale, G as AssetSwapId, H as AtomicDecimal, J as AuctionMarketRef, K as AuctionProvenance, M as BITCOIN_RAILS, T as BTC_ASSET_PART, U as BitcoinRail, V as CORRIDORS, W as CORRIDOR_PASS, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, a2 as Hex, a3 as LOCKUP_OWNER, a4 as MarketBackend, a5 as MarketRef, a6 as OFFER_SWAP_ID_PREFIX, a7 as Outcome, a8 as ParsedAssetId, a9 as Quote, aa as QuoteLeg, ab as RAILS, ac as RFQ_SWAP_ID_PREFIX, ad as RailOf, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, am as RestoredMarketRef, an as RfqAmountSide, ao as SnapshotRef, ap as Swap, aq as SwapFamily, ar as SwapRecordCommon, as as SwapUpdate, at as TaxiIdentity, au as Unsubscribe, av as VerifiedCarrierTerms, aw as arkadeAsset, ax as artifactOf, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aD as corridorOfRail, aE as corridorOutcome, aF as decodeRfqAmount, aG as encodeRfqAmount, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aK as fromRfqAmountSide, aL as fundingWasNotSubmitted, aM as fundsFromWallet, aN as instrumentOf, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, aT as issuanceOf, aU as legOf, aV as offerOutcome, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, aZ as railOfCorridor, a_ as readsChain, a$ as recordArtifact, b0 as recordEndpoint, b1 as recordInstrument, b2 as recordLeg, b3 as recordOutcome, b4 as sameAsset, b5 as swapOf, b6 as toAtomicDecimal, b7 as toRfqAmountSide, b8 as toSafeNumber } from './repository-DFDNvcZ7.cjs';
6
6
  import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-CP-P0PSL.cjs';
7
7
  export { S as SwapRefusal } from './rfq-CP-P0PSL.cjs';
8
8
  import * as btc from '@scure/btc-signer';
9
9
  import { OnchainProvider, NetworkName, PageRequest, PageResult, IWallet, VHTLC } from '@arkade-os/sdk';
10
- import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-D4PeBZ3H.cjs';
11
- import './offer-BxzPQ6zh.cjs';
10
+ import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-DFNMY2K-.cjs';
11
+ import './offer-Boxive2u.cjs';
12
12
  import 'nostr-tools';
13
13
 
14
14
  /** The EVM leg's namespace. Which chain is the quote's `evm_chain_id`, not the pair. */
@@ -1,14 +1,14 @@
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 './offerFillPlan-C11P2ek2.js';
2
- export { e as AcceptConflict, f as AcceptInput, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, k as AssetRfqPreparation, l as AttestingRfqTransport, B as BuildOfferFillPlanOpts, m as CORRIDOR_FACTORIES, n as CancelInput, o as CancelOutcome, p as ClaimedDestination, q as ClientDisposed, r as CorridorBase, s as CorridorClaim, t as CorridorCovenant, u as CorridorDeadline, v as CorridorDeps, w as CorridorDepsByCorridor, x as CorridorDrive, y as CorridorLockup, z as CorridorModule, E as CorridorOverrides, F as CorridorPass, G as CorridorRfqPreparation, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, J as DiscoveryIndexInput, K as DiscoverySnapshotUnavailable, N as DriveMode, P as DriveRefusal, Q as ExchangeOptions, R as FEED_TTL_MS, T as FeeCeiling, U as FeedFetch, V as FeedQuoteInput, W as FillSponsor, X as FillSponsorFare, Y as INDEXED_NETWORKS, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a0 as LockupOwner, a1 as Market, a2 as MarketLeg, a3 as MaxFeeExceeded, a4 as MissingCorridorDep, a5 as NotCancellable, a6 as OFFER_FILL_OWNERS, a7 as OFFER_FILL_TEMPLATE, a8 as ONCHAIN_CLAIM_FEE_RATE_SATVB, a9 as ObservationSeam, aa as OfferPreparation, ab as OnchainClaim, ac as OnchainRefund, ad as OperatorUnreachable, ae as ParsedRfqQuote, af as PayOptions, ag as PayResult, ah as QuoteCheck, ai as QuoteExpired, aj as QuotePreparation, ak as QuoteVerificationFailed, al as REGISTRY_URL, am as ReceiveArtifact, an as ReceiveOptions, ao as ReceiveRequest, ap as RecoveryResult, aq as RegisteredAsset, ar as RfqAuctionPolicy, as as RfqPreparation, at as RfqQuoteInput, au as RfqRendezvous, av as RfqTransportFactory, aw as RouteSide, ax as SWAP_ERROR_NAMES, ay as SwapClient, az as SwapClientConfig, aA as SwapDrive, aB as SwapDriveConfig, aC as SwapDriveRefusedError, aD as SwapError, aE as SwapErrorName, aF as SwapFilter, aG as UnsupportedRoute, aH as VerbDeps, aI as acceptQuote, aJ as attesting, aK as buildOfferFillPlan, aL as cancelSwap, aM as canonicalAssetId, aN as cardMarketOf, aO as chooseMarket, aP as conflictingFields, aQ as corridorSet, aR as createNostrTransportFactory, aS as createSwapClient, aT as createSwapDrive, aU as deepFreeze, aV as digestJointGraph, aW as discoveryIndex, aX as eligibleMarkets, aY as enforceFeeCeiling, aZ as exchange, a_ as feedFetch, a$ as feedSpread, b0 as isAddressable, b1 as isCardMarket, b2 as isIndexedNetwork, b3 as isSwapError, b4 as isUsableCard, b5 as liveArkadeInfo, b6 as liveOperatorInfo, b7 as marketBackendOf, b8 as marketKeyOf, b9 as marketOf, ba as marketRefOf, bb as nostrTransportFactory, bc as parseRfqQuote, bd as pay, be as quoteFromFeed, bf as quoteViaRfq, bg as readableRecord, bh as receive, bi as resolveCorridorBase, bj as resolveCorridorDeps, bk as rfqLeg, bl as rfqPairFor, bm as swapRecordOf, bn as toDiscoveryLeg, bo as unsignedPsbtBytes, bp as usableMarkets, bq as verifyJointGraph, br as verifyOfferFillPlan, bs as verifyPlanLegs, bt as withCanonicalAmount } from './offerFillPlan-C11P2ek2.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 './offerFillPlan-D2N4s7Xe.js';
2
+ export { e as AcceptConflict, f as AcceptInput, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, k as AssetRfqPreparation, l as AttestingRfqTransport, B as BuildOfferFillPlanOpts, m as CORRIDOR_FACTORIES, n as CancelInput, o as CancelOutcome, p as ClaimedDestination, q as ClientDisposed, r as CorridorBase, s as CorridorClaim, t as CorridorCovenant, u as CorridorDeadline, v as CorridorDeps, w as CorridorDepsByCorridor, x as CorridorDrive, y as CorridorLockup, z as CorridorModule, E as CorridorOverrides, F as CorridorPass, G as CorridorRfqPreparation, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, J as DiscoveryIndexInput, K as DiscoverySnapshotUnavailable, N as DriveMode, P as DriveRefusal, Q as ExchangeOptions, R as FEED_TTL_MS, T as FeeCeiling, U as FeedFetch, V as FeedQuoteInput, W as FillSponsor, X as FillSponsorFare, Y as INDEXED_NETWORKS, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a0 as LockupOwner, a1 as Market, a2 as MarketLeg, a3 as MaxFeeExceeded, a4 as MissingCorridorDep, a5 as NotCancellable, a6 as OFFER_FILL_OWNERS, a7 as OFFER_FILL_TEMPLATE, a8 as ONCHAIN_CLAIM_FEE_RATE_SATVB, a9 as ObservationSeam, aa as OfferPreparation, ab as OnchainClaim, ac as OnchainRefund, ad as OperatorUnreachable, ae as ParsedRfqQuote, af as PayOptions, ag as PayResult, ah as QuoteCheck, ai as QuoteExpired, aj as QuotePreparation, ak as QuoteVerificationFailed, al as REGISTRY_URL, am as ReceiveArtifact, an as ReceiveOptions, ao as ReceiveRequest, ap as RecoveryResult, aq as RegisteredAsset, ar as RfqAuctionPolicy, as as RfqPreparation, at as RfqQuoteInput, au as RfqRendezvous, av as RfqTransportFactory, aw as RouteSide, ax as SWAP_ERROR_NAMES, ay as SwapClient, az as SwapClientConfig, aA as SwapDrive, aB as SwapDriveConfig, aC as SwapDriveRefusedError, aD as SwapError, aE as SwapErrorName, aF as SwapFilter, aG as UnsupportedRoute, aH as VerbDeps, aI as acceptQuote, aJ as attesting, aK as buildOfferFillPlan, aL as cancelSwap, aM as canonicalAssetId, aN as cardMarketOf, aO as chooseMarket, aP as conflictingFields, aQ as corridorSet, aR as createNostrTransportFactory, aS as createSwapClient, aT as createSwapDrive, aU as deepFreeze, aV as digestJointGraph, aW as discoveryIndex, aX as eligibleMarkets, aY as enforceFeeCeiling, aZ as exchange, a_ as feedFetch, a$ as feedSpread, b0 as isAddressable, b1 as isCardMarket, b2 as isIndexedNetwork, b3 as isSwapError, b4 as isUsableCard, b5 as liveArkadeInfo, b6 as liveOperatorInfo, b7 as marketBackendOf, b8 as marketKeyOf, b9 as marketOf, ba as marketRefOf, bb as nostrTransportFactory, bc as parseRfqQuote, bd as pay, be as quoteFromFeed, bf as quoteViaRfq, bg as readableRecord, bh as receive, bi as resolveCorridorBase, bj as resolveCorridorDeps, bk as rfqLeg, bl as rfqPairFor, bm as swapRecordOf, bn as toDiscoveryLeg, bo as unsignedPsbtBytes, bp as usableMarkets, bq as verifyJointGraph, br as verifyOfferFillPlan, bs as verifyPlanLegs, bt as withCanonicalAmount } from './offerFillPlan-D2N4s7Xe.js';
3
3
  import { DiscoveredMarket, Side } from '@arkade-os/solver-discovery';
4
- import { N as NetworkRef, A as AssetId, C as Corridor, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, c as AssetSwapStatus, S as SwapRecord, O as OfferSwapRecord, d as AssetSwapRepository, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, h as AssetSwap, L as LockupSpendIndexer, i as RouteResolution, j as ResolvedEndpoint, P as PinnedAmount, I as Instrument, k as Route, l as QuoteInput, m as Pubkey } from './repository-BOQ1qYoj.js';
5
- export { n as ACTIVITY_TOKEN, o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, r as AmountOn, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, v as AssetIdError, w as AssetIdRefusal, x as AssetNamespace, y as AssetOn, z as AssetPart, B as AssetPaymentInput, D as AssetPaymentTerms, E as AssetRef, F as AssetScale, G as AssetSwapId, H as AtomicDecimal, J as AuctionMarketRef, K as AuctionProvenance, M as BITCOIN_RAILS, T as BTC_ASSET_PART, U as BitcoinRail, V as CORRIDORS, W as CORRIDOR_PASS, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, a2 as Hex, a3 as LOCKUP_OWNER, a4 as MarketBackend, a5 as MarketRef, a6 as OFFER_SWAP_ID_PREFIX, a7 as Outcome, a8 as ParsedAssetId, a9 as Quote, aa as QuoteLeg, ab as RAILS, ac as RFQ_SWAP_ID_PREFIX, ad as RailOf, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, am as RestoredMarketRef, an as RfqAmountSide, ao as SnapshotRef, ap as Swap, aq as SwapFamily, ar as SwapRecordCommon, as as SwapUpdate, at as TaxiIdentity, au as Unsubscribe, av as VerifiedCarrierTerms, aw as arkadeAsset, ax as artifactOf, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aD as corridorOfRail, aE as corridorOutcome, aF as decodeRfqAmount, aG as encodeRfqAmount, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aK as fromRfqAmountSide, aL as fundingWasNotSubmitted, aM as fundsFromWallet, aN as instrumentOf, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, aT as issuanceOf, aU as legOf, aV as offerOutcome, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, aZ as railOfCorridor, a_ as readsChain, a$ as recordArtifact, b0 as recordEndpoint, b1 as recordInstrument, b2 as recordLeg, b3 as recordOutcome, b4 as sameAsset, b5 as swapOf, b6 as toAtomicDecimal, b7 as toRfqAmountSide, b8 as toSafeNumber } from './repository-BOQ1qYoj.js';
4
+ import { N as NetworkRef, A as AssetId, C as Corridor, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, c as AssetSwapStatus, S as SwapRecord, O as OfferSwapRecord, d as AssetSwapRepository, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, h as AssetSwap, L as LockupSpendIndexer, i as RouteResolution, j as ResolvedEndpoint, P as PinnedAmount, I as Instrument, k as Route, l as QuoteInput, m as Pubkey } from './repository-Dn1V17T2.js';
5
+ export { n as ACTIVITY_TOKEN, o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, r as AmountOn, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, v as AssetIdError, w as AssetIdRefusal, x as AssetNamespace, y as AssetOn, z as AssetPart, B as AssetPaymentInput, D as AssetPaymentTerms, E as AssetRef, F as AssetScale, G as AssetSwapId, H as AtomicDecimal, J as AuctionMarketRef, K as AuctionProvenance, M as BITCOIN_RAILS, T as BTC_ASSET_PART, U as BitcoinRail, V as CORRIDORS, W as CORRIDOR_PASS, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, a2 as Hex, a3 as LOCKUP_OWNER, a4 as MarketBackend, a5 as MarketRef, a6 as OFFER_SWAP_ID_PREFIX, a7 as Outcome, a8 as ParsedAssetId, a9 as Quote, aa as QuoteLeg, ab as RAILS, ac as RFQ_SWAP_ID_PREFIX, ad as RailOf, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, am as RestoredMarketRef, an as RfqAmountSide, ao as SnapshotRef, ap as Swap, aq as SwapFamily, ar as SwapRecordCommon, as as SwapUpdate, at as TaxiIdentity, au as Unsubscribe, av as VerifiedCarrierTerms, aw as arkadeAsset, ax as artifactOf, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aD as corridorOfRail, aE as corridorOutcome, aF as decodeRfqAmount, aG as encodeRfqAmount, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aK as fromRfqAmountSide, aL as fundingWasNotSubmitted, aM as fundsFromWallet, aN as instrumentOf, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, aT as issuanceOf, aU as legOf, aV as offerOutcome, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, aZ as railOfCorridor, a_ as readsChain, a$ as recordArtifact, b0 as recordEndpoint, b1 as recordInstrument, b2 as recordLeg, b3 as recordOutcome, b4 as sameAsset, b5 as swapOf, b6 as toAtomicDecimal, b7 as toRfqAmountSide, b8 as toSafeNumber } from './repository-Dn1V17T2.js';
6
6
  import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-CP-P0PSL.js';
7
7
  export { S as SwapRefusal } from './rfq-CP-P0PSL.js';
8
8
  import * as btc from '@scure/btc-signer';
9
9
  import { OnchainProvider, NetworkName, PageRequest, PageResult, IWallet, VHTLC } from '@arkade-os/sdk';
10
- import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-D15U0QpD.js';
11
- import './offer-Q1lVhrVX.js';
10
+ import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-D-mc_wfD.js';
11
+ import './offer-Drw1k_jt.js';
12
12
  import 'nostr-tools';
13
13
 
14
14
  /** The EVM leg's namespace. Which chain is the quote's `evm_chain_id`, not the pair. */
package/dist/advanced.js CHANGED
@@ -139,7 +139,7 @@ import {
139
139
  withCanonicalAmount,
140
140
  withDepositFate,
141
141
  withRfqState
142
- } from "./chunk-HDCC3JZR.js";
142
+ } from "./chunk-SDPNWPGY.js";
143
143
  import {
144
144
  ACTIVITY_TOKEN,
145
145
  Amount,
@@ -174,7 +174,7 @@ import {
174
174
  recordOutcome,
175
175
  swapOf,
176
176
  toAtomicDecimal
177
- } from "./chunk-GJKGPE3S.js";
177
+ } from "./chunk-QFM55KP2.js";
178
178
  import {
179
179
  ARKADE_BTC,
180
180
  SwapRefusal,
@@ -1029,10 +1029,11 @@ async function readLockupFate(indexer, input) {
1029
1029
  const spentBy = /* @__PURE__ */ new Map();
1030
1030
  let everySpendNamed = true;
1031
1031
  let sweptLeft = false;
1032
+ let live = false;
1032
1033
  for (const vtxo of all) {
1033
1034
  if (!isVtxoSpent(vtxo)) {
1034
- if (!(input.receiver && vtxo.isSwept)) return { fate: "open" };
1035
- sweptLeft = true;
1035
+ if (input.receiver && vtxo.isSwept) sweptLeft = true;
1036
+ else live = true;
1036
1037
  continue;
1037
1038
  }
1038
1039
  if (vtxo.spentBy)
@@ -1042,8 +1043,16 @@ async function readLockupFate(indexer, input) {
1042
1043
  });
1043
1044
  else everySpendNamed = false;
1044
1045
  }
1046
+ if (live && (!input.receiver || spentBy.size === 0)) return { fate: "open" };
1045
1047
  const spends = [...spentBy.values()];
1046
- const { txs } = await indexer.getVirtualTxs([...spentBy.keys()]);
1048
+ const arkTxids = new Set(spends.flatMap((spend) => spend.txid ? [spend.txid] : []));
1049
+ let txs;
1050
+ try {
1051
+ ({ txs } = await indexer.getVirtualTxs([.../* @__PURE__ */ new Set([...spentBy.keys(), ...arkTxids])]));
1052
+ } catch (error) {
1053
+ if (live) return { fate: "open" };
1054
+ throw error;
1055
+ }
1047
1056
  const refunded = /* @__PURE__ */ new Set();
1048
1057
  const leafScripts = /* @__PURE__ */ new Set();
1049
1058
  for (const raw of txs) {
@@ -1053,18 +1062,29 @@ async function readLockupFate(indexer, input) {
1053
1062
  } catch {
1054
1063
  continue;
1055
1064
  }
1056
- if (!spentBy.has(tx.id)) continue;
1065
+ const checkpoint = spentBy.has(tx.id);
1066
+ if (!checkpoint && !arkTxids.has(tx.id)) continue;
1057
1067
  for (let i = 0; i < tx.inputsLength; i++) {
1058
1068
  const spent = tx.getInput(i);
1059
1069
  if (!spent.txid) continue;
1060
1070
  const txid = hex2.encode(spent.txid);
1071
+ if (!checkpoint) {
1072
+ if (spent.index !== 0 || !spentBy.has(txid)) continue;
1073
+ const preimage = candidateWitnessItems(tx, i).find(
1074
+ (candidate) => hashesTo(candidate, input.paymentHash)
1075
+ );
1076
+ if (preimage) {
1077
+ return live ? { fate: "open", preimage } : { fate: "claimed", preimage, spends };
1078
+ }
1079
+ continue;
1080
+ }
1061
1081
  const vtxo = all.find(
1062
1082
  (vtxo2) => vtxo2.txid === txid && vtxo2.vout === spent.index && vtxo2.spentBy === tx.id
1063
1083
  );
1064
1084
  if (!vtxo) continue;
1065
1085
  for (const candidate of candidateWitnessItems(tx, i)) {
1066
1086
  if (hashesTo(candidate, input.paymentHash)) {
1067
- return { fate: "claimed", preimage: candidate, spends };
1087
+ return live ? { fate: "open", preimage: candidate } : { fate: "claimed", preimage: candidate, spends };
1068
1088
  }
1069
1089
  }
1070
1090
  const leafScript = refundLeafScript(tx, i);
@@ -1074,7 +1094,7 @@ async function readLockupFate(indexer, input) {
1074
1094
  }
1075
1095
  }
1076
1096
  }
1077
- if (sweptLeft) return { fate: "open" };
1097
+ if (live || sweptLeft) return { fate: "open" };
1078
1098
  return everySpendNamed && all.every((vtxo) => refunded.has(`${vtxo.txid}:${vtxo.vout}`)) ? { fate: "returned", spends, leafScripts: [...leafScripts] } : { fate: "unknown" };
1079
1099
  }
1080
1100
  var assertNoneSwept = (vtxos, contract) => {
@@ -1877,9 +1897,15 @@ function shouldRetainRfqSwap(record, now) {
1877
1897
  }
1878
1898
 
1879
1899
  // src/claim.ts
1900
+ import { base64 as base643, hex as hex6 } from "@scure/base";
1880
1901
  import {
1902
+ CSVMultisigTapscript as CSVMultisigTapscript2,
1903
+ Transaction as Transaction3,
1904
+ buildOffchainTx,
1881
1905
  claimWithPreimageIdentity,
1882
- signAndSubmitOffchainTx as signAndSubmitOffchainTx2
1906
+ isVtxoSpent as isVtxoSpent2,
1907
+ signAndSubmitOffchainTx as signAndSubmitOffchainTx2,
1908
+ toXOnly as toXOnly2
1883
1909
  } from "@arkade-os/sdk";
1884
1910
  var LockupAmountMismatchError = class extends Error {
1885
1911
  name = "LockupAmountMismatchError";
@@ -1930,6 +1956,95 @@ async function pushClaim(operator, input) {
1930
1956
  });
1931
1957
  return { txid, amount: locked, left: live.length - vtxos.length, spent: vtxos };
1932
1958
  }
1959
+ async function findPendingClaims(operator, indexer, input) {
1960
+ const { vtxos } = await indexer.getVtxos({
1961
+ scripts: [hex6.encode(input.contract.pkScript)],
1962
+ pendingOnly: true
1963
+ });
1964
+ const byArkTx = /* @__PURE__ */ new Map();
1965
+ for (const vtxo of vtxos ?? []) {
1966
+ if (!isVtxoSpent2(vtxo) || !vtxo.spentBy || !vtxo.arkTxId) continue;
1967
+ byArkTx.set(vtxo.arkTxId, [...byArkTx.get(vtxo.arkTxId) ?? [], vtxo]);
1968
+ }
1969
+ if (byArkTx.size === 0) return [];
1970
+ const current = await operatorUnrollScript(operator, input.network);
1971
+ const { deprecatedSigners } = await operator.getInfo();
1972
+ const unrollScripts = [
1973
+ current,
1974
+ ...(deprecatedSigners ?? []).flatMap(
1975
+ ({ pubkey }) => pubkey ? [
1976
+ CSVMultisigTapscript2.encode({
1977
+ ...current.params,
1978
+ pubkeys: [toXOnly2(hex6.decode(pubkey), "deprecated signer")]
1979
+ })
1980
+ ] : []
1981
+ )
1982
+ ];
1983
+ const claims = [];
1984
+ for (const [arkTxid, spent] of byArkTx) {
1985
+ const live = spent.map(({ txid, vout, value }) => ({
1986
+ txid,
1987
+ vout,
1988
+ value: Number(value),
1989
+ recoverable: false
1990
+ }));
1991
+ const total = live.reduce((sum, vtxo) => sum + vtxo.value, 0);
1992
+ const checkpoints = unrollScripts.map(
1993
+ (unroll) => buildOffchainTx(
1994
+ lockupInputs(live, input.contract, input.contract.claim()),
1995
+ [{ script: input.contract.pkScript, amount: BigInt(total) }],
1996
+ unroll
1997
+ ).checkpoints
1998
+ ).find(
1999
+ (built) => built.length === spent.length && built.every((checkpoint, i) => checkpoint.id === spent[i].spentBy)
2000
+ );
2001
+ if (checkpoints) claims.push({ arkTxid, checkpoints });
2002
+ }
2003
+ return claims;
2004
+ }
2005
+ async function finalizePendingClaim(operator, indexer, input) {
2006
+ const claims = await findPendingClaims(operator, indexer, input);
2007
+ if (claims.length === 0) return [];
2008
+ assertPreimageMatches(input.preimage, input.contract.options.preimageHash);
2009
+ const signer = claimWithPreimageIdentity(input.receiver, input.preimage);
2010
+ const ours = hex6.encode(await input.receiver.xOnlyPublicKey());
2011
+ const finalized = [];
2012
+ for (const { arkTxid, checkpoints } of claims) {
2013
+ const { txs } = await indexer.getVirtualTxs(checkpoints.map((checkpoint) => checkpoint.id));
2014
+ const stored = new Map(
2015
+ txs.map((raw) => {
2016
+ const tx = Transaction3.fromPSBT(base643.decode(raw));
2017
+ return [tx.id, tx];
2018
+ })
2019
+ );
2020
+ const signed = await Promise.all(
2021
+ checkpoints.map(async (checkpoint) => {
2022
+ const theirs = stored.get(checkpoint.id);
2023
+ if (!theirs) {
2024
+ throw new Error(
2025
+ `pending claim ${arkTxid}: no stored checkpoint ${checkpoint.id}`
2026
+ );
2027
+ }
2028
+ const server = (theirs.getInput(0).tapScriptSig ?? []).filter(
2029
+ ([{ pubKey }]) => hex6.encode(pubKey) !== ours
2030
+ );
2031
+ if (server.length === 0) {
2032
+ throw new Error(
2033
+ `pending claim ${arkTxid}: the indexer served checkpoint ${checkpoint.id} without the operator's signature, so it cannot be finalized from here`
2034
+ );
2035
+ }
2036
+ const tx = await signer.sign(checkpoint, [0]);
2037
+ tx.updateInput(0, {
2038
+ tapScriptSig: [...tx.getInput(0).tapScriptSig ?? [], ...server]
2039
+ });
2040
+ return base643.encode(tx.toPSBT());
2041
+ })
2042
+ );
2043
+ await operator.finalizeTx(arkTxid, signed);
2044
+ finalized.push(arkTxid);
2045
+ }
2046
+ return finalized;
2047
+ }
1933
2048
 
1934
2049
  // src/refundBlocked.ts
1935
2050
  import {
@@ -2012,7 +2127,7 @@ function arkadeRefunder(deps) {
2012
2127
  }
2013
2128
 
2014
2129
  // src/swapManager.ts
2015
- import { hex as hex6 } from "@scure/base";
2130
+ import { hex as hex7 } from "@scure/base";
2016
2131
  import {
2017
2132
  ArkErrorName,
2018
2133
  assertTimerMs as assertTimerMs2,
@@ -2501,13 +2616,13 @@ var RfqSwapManager = class _RfqSwapManager {
2501
2616
  // ── internals ────────────────────────────────────────────────────────────
2502
2617
  track(swap) {
2503
2618
  this.monitored.set(swap.rfqId, swap);
2504
- this.byLockupScript.set(hex6.encode(swap.lockupPkScript), swap);
2619
+ this.byLockupScript.set(hex7.encode(swap.lockupPkScript), swap);
2505
2620
  }
2506
2621
  /** Drops the swap from BOTH indexes. `pollSwap`'s `monitored` check also stops a late
2507
2622
  * event, deliberately redundant so neither change alone re-drives a removed swap. */
2508
2623
  untrack(rfqId) {
2509
2624
  const swap = this.monitored.get(rfqId);
2510
- if (swap) this.byLockupScript.delete(hex6.encode(swap.lockupPkScript));
2625
+ if (swap) this.byLockupScript.delete(hex7.encode(swap.lockupPkScript));
2511
2626
  this.monitored.delete(rfqId);
2512
2627
  this.refundRefused.delete(rfqId);
2513
2628
  this.claimedOutpoints.delete(rfqId);
@@ -2553,7 +2668,7 @@ var RfqSwapManager = class _RfqSwapManager {
2553
2668
  if (!lockup) {
2554
2669
  try {
2555
2670
  const [existing] = await contracts.getContracts({
2556
- script: hex6.encode(swap.lockupPkScript)
2671
+ script: hex7.encode(swap.lockupPkScript)
2557
2672
  });
2558
2673
  if (existing) {
2559
2674
  this.registered.set(swap.rfqId, true);
@@ -2572,13 +2687,13 @@ var RfqSwapManager = class _RfqSwapManager {
2572
2687
  );
2573
2688
  return;
2574
2689
  }
2575
- const script = hex6.encode(lockup.script.pkScript);
2576
- if (script !== hex6.encode(swap.lockupPkScript)) {
2690
+ const script = hex7.encode(lockup.script.pkScript);
2691
+ if (script !== hex7.encode(swap.lockupPkScript)) {
2577
2692
  this.registered.set(swap.rfqId, false);
2578
2693
  this.emitFailed(
2579
2694
  swap,
2580
2695
  new Error(
2581
- `swap ${swap.rfqId} lockup script ${script} does not match its lockupPkScript ${hex6.encode(swap.lockupPkScript)}`
2696
+ `swap ${swap.rfqId} lockup script ${script} does not match its lockupPkScript ${hex7.encode(swap.lockupPkScript)}`
2582
2697
  )
2583
2698
  );
2584
2699
  return;
@@ -2595,7 +2710,7 @@ var RfqSwapManager = class _RfqSwapManager {
2595
2710
  retireContract(swap) {
2596
2711
  if (!this.deps.contracts || !this.registered.get(swap.rfqId)) return;
2597
2712
  if (!LOCKUP_RETIRABLE.includes(swap.state)) return;
2598
- void this.deps.contracts.setContractWatchState(hex6.encode(swap.lockupPkScript), "retained").catch((error) => this.emitFailed(swap, error));
2713
+ void this.deps.contracts.setContractWatchState(hex7.encode(swap.lockupPkScript), "retained").catch((error) => this.emitFailed(swap, error));
2599
2714
  }
2600
2715
  arm() {
2601
2716
  if (!this.running) return;
@@ -2655,6 +2770,11 @@ var RfqSwapManager = class _RfqSwapManager {
2655
2770
  )) {
2656
2771
  fate = { fate: "unknown" };
2657
2772
  }
2773
+ if (swap.kind === "lightning_receive" && fate.fate !== "exited" && fate.fate !== "returned") {
2774
+ const pending = await this.finalizeOwnClaim(swap);
2775
+ const windowOpen = fate.fate === "open" && this.config.now() < swap.refundLocktime;
2776
+ if (pending !== "none" && !windowOpen) return;
2777
+ }
2658
2778
  if (swap.kind === "onchain_receive") return this.driveOnchainReceive(swap, fate);
2659
2779
  if (fate.fate === "claimed" || fate.fate === "returned") {
2660
2780
  this.stampLockupSpends(swap, fate.spends);
@@ -2667,8 +2787,13 @@ var RfqSwapManager = class _RfqSwapManager {
2667
2787
  }
2668
2788
  if (swap.kind === "lightning_receive") {
2669
2789
  if (fate.fate === "exited") return this.blockExitedLockup(swap, fate);
2670
- if (fate.fate === "open") return this.driveReceiveClaim(swap);
2671
- if (this.config.now() >= swap.refundLocktime) return this.driveReceiveClaim(swap);
2790
+ if (fate.fate === "open") {
2791
+ return this.driveReceiveClaim(swap, fate.preimage !== void 0);
2792
+ }
2793
+ if (fate.fate === "unknown" && swap.claimTxid !== void 0) return;
2794
+ if (this.config.now() >= swap.refundLocktime) {
2795
+ return this.driveReceiveClaim(swap, false);
2796
+ }
2672
2797
  return;
2673
2798
  }
2674
2799
  if (swap.kind === "onchain_send") {
@@ -2681,6 +2806,25 @@ var RfqSwapManager = class _RfqSwapManager {
2681
2806
  }
2682
2807
  await this.driveArkadeRefund(swap);
2683
2808
  }
2809
+ /** `none` when no claim of ours is pending; `failed` covers a pending read that failed too. */
2810
+ async finalizeOwnClaim(swap) {
2811
+ const pendingClaims = this.callbacks?.pendingClaims;
2812
+ const finalize = this.callbacks?.finalizeClaim;
2813
+ if (!pendingClaims || !finalize || !this.config.enableAutoActions) return "none";
2814
+ try {
2815
+ const pending = await pendingClaims(swap);
2816
+ if (pending.length === 0) return "none";
2817
+ if (swap.claimTxid === void 0) {
2818
+ swap.claimTxid = pending[0];
2819
+ this.touch(swap);
2820
+ }
2821
+ await finalize(swap);
2822
+ return "finalized";
2823
+ } catch (error) {
2824
+ this.emitFailed(swap, error);
2825
+ return "failed";
2826
+ }
2827
+ }
2684
2828
  /**
2685
2829
  * The lockup was unilaterally exited: its outputs sit onchain, beyond any offchain
2686
2830
  * spend. `needs_counterparty`, not terminal: it can still end either way onchain. Set
@@ -2703,8 +2847,9 @@ var RfqSwapManager = class _RfqSwapManager {
2703
2847
  *
2704
2848
  * After the window the trader has no move; the manager only watches.
2705
2849
  */
2706
- async driveReceiveClaim(swap) {
2850
+ async driveReceiveClaim(swap, revealed) {
2707
2851
  const now = this.config.now();
2852
+ const claimOut = swap.claimTxid !== void 0 || revealed;
2708
2853
  if (now < swap.refundLocktime) {
2709
2854
  let vtxos;
2710
2855
  try {
@@ -2713,26 +2858,25 @@ var RfqSwapManager = class _RfqSwapManager {
2713
2858
  this.emitFailed(swap, error);
2714
2859
  return;
2715
2860
  }
2716
- return this.claimIfFunded(swap, vtxos);
2861
+ return this.claimIfFunded(swap, vtxos, claimOut);
2717
2862
  }
2718
2863
  if (now < swap.refundLocktime + REFUND_MTP_LAG_SECONDS) {
2719
- if (swap.claimTxid) return;
2864
+ if (claimOut) return;
2720
2865
  return this.block(
2721
2866
  swap,
2722
2867
  "the claim window closed with the lockup unclaimed \u2014 only the solver can act now"
2723
2868
  );
2724
2869
  }
2725
2870
  const failure = swap.claimFailure;
2726
- if (failure && !swap.claimTxid) {
2871
+ if (failure && !claimOut) {
2727
2872
  return this.fail(swap, new Error(failure));
2728
2873
  }
2729
2874
  this.setState(swap, "refunded");
2730
2875
  }
2731
2876
  /** Claim what the solver funded, once it is enough (the inner gate that matters is
2732
2877
  * `pushClaim`'s; see {@link RfqSwapManagerCallbacks.claimLockup}). */
2733
- async claimIfFunded(swap, vtxos) {
2878
+ async claimIfFunded(swap, vtxos, partiallyClaimed) {
2734
2879
  if (vtxos.length === 0) return this.unblock(swap);
2735
- const partiallyClaimed = swap.claimTxid !== void 0;
2736
2880
  const toClaim = partiallyClaimed ? this.unclaimed(swap.rfqId, vtxos) : vtxos;
2737
2881
  if (toClaim.length === 0) {
2738
2882
  return;
@@ -2812,7 +2956,7 @@ var RfqSwapManager = class _RfqSwapManager {
2812
2956
  "the L1 funding was refunded, so claiming the lockup too would take both sides of the trade \u2014 the solver's reclaim ends this swap"
2813
2957
  );
2814
2958
  }
2815
- await this.driveReceiveClaim(swap);
2959
+ await this.driveReceiveClaim(swap, false);
2816
2960
  if (l1.blocked && !isRfqSwapTerminal(swap.state)) this.block(swap, l1.blocked);
2817
2961
  }
2818
2962
  /** `resolved`: the HTLC can hold nothing more. `blocked` is a refusal the
@@ -3133,7 +3277,7 @@ var RfqSwapManager = class _RfqSwapManager {
3133
3277
  */
3134
3278
  stampSettlementPreimage(swap, preimage) {
3135
3279
  if (swap.kind !== "lightning_send") return;
3136
- swap.settlementPreimageHex = hex6.encode(preimage);
3280
+ swap.settlementPreimageHex = hex7.encode(preimage);
3137
3281
  this.touch(swap);
3138
3282
  }
3139
3283
  touch(swap) {
@@ -3256,11 +3400,11 @@ var errorMessage = (error) => error instanceof Error ? error.message : String(er
3256
3400
  var outpointKey = (vtxo) => `${vtxo.txid}:${vtxo.vout}`;
3257
3401
 
3258
3402
  // src/watch.ts
3259
- import { base64 as base643, hex as hex7 } from "@scure/base";
3403
+ import { base64 as base644, hex as hex8 } from "@scure/base";
3260
3404
  import {
3261
3405
  ArkAddress as ArkAddress2,
3262
3406
  isContractVtxoEvent as isContractVtxoEvent2,
3263
- Transaction as Transaction3
3407
+ Transaction as Transaction4
3264
3408
  } from "@arkade-os/sdk";
3265
3409
  var TERMINAL = ["fulfilled", "cancelled", "recoverable"];
3266
3410
  var assetSwapSource = (repository) => ({
@@ -3306,9 +3450,9 @@ async function watchOfferSwaps({
3306
3450
  if (candidates.length === 0) return "indeterminate";
3307
3451
  const { txs } = await indexer.getVirtualTxs(candidates);
3308
3452
  return classifyDepositSpend(
3309
- decodeOffer(hex7.decode(swap.offerHex)),
3453
+ decodeOffer(hex8.decode(swap.offerHex)),
3310
3454
  operatorPubkey,
3311
- txs.map((psbt) => Transaction3.fromPSBT(base643.decode(psbt))),
3455
+ txs.map((psbt) => Transaction4.fromPSBT(base644.decode(psbt))),
3312
3456
  { txid: vtxo.txid, vout: vtxo.vout }
3313
3457
  );
3314
3458
  } catch {
@@ -3432,6 +3576,8 @@ export {
3432
3576
  shouldRetainRfqSwap,
3433
3577
  LockupAmountMismatchError,
3434
3578
  pushClaim,
3579
+ findPendingClaims,
3580
+ finalizePendingClaim,
3435
3581
  RefundNotLocallyPossibleError,
3436
3582
  senderIdentityForSwapRecord,
3437
3583
  arkadeRefunder,
@@ -17,7 +17,9 @@ import {
17
17
  corridorOutcome,
18
18
  encodeCarrierRequest,
19
19
  familyOfSwapId,
20
+ finalizePendingClaim,
20
21
  findLockupVtxos,
22
+ findPendingClaims,
21
23
  fromAtomicDecimal,
22
24
  fundingWasNotSubmitted,
23
25
  fundsFromWallet,
@@ -60,7 +62,7 @@ import {
60
62
  undeliveredCarry,
61
63
  walletOperator,
62
64
  watchOfferSwaps
63
- } from "./chunk-GJKGPE3S.js";
65
+ } from "./chunk-QFM55KP2.js";
64
66
  import {
65
67
  ARKADE_BTC,
66
68
  ASSET_CARRIER_SATS,
@@ -2373,13 +2375,37 @@ var createSwapDrive = (config) => {
2373
2375
  };
2374
2376
  const drivable = async (record) => !readsChain(record.kind) || await resolveOnchain();
2375
2377
  const pinnedNetwork = async () => getNetwork2(await config.network());
2376
- const claimLockup = async (swap, vtxos, { partiallyClaimed }) => {
2378
+ const claimSecretOf = async (swap) => {
2377
2379
  const record = await corridorStore().getRfqSwap(swap.rfqId);
2378
2380
  if (!record) throw new Error(`rfq swap ${swap.rfqId} has no stored record to claim from`);
2379
2381
  const secret = rfqClaimSecretOf(record);
2380
2382
  if (!secret) throw new Error(`rfq swap ${swap.rfqId} carries no claim secret`);
2381
2383
  const script = swap.lockup?.script;
2382
2384
  if (!script) throw new Error(`rfq swap ${swap.rfqId} carries no lockup covenant`);
2385
+ return { record, secret, script };
2386
+ };
2387
+ const pendingClaims = async (swap) => {
2388
+ const script = swap.lockup?.script;
2389
+ if (!script) throw new Error(`rfq swap ${swap.rfqId} carries no lockup covenant`);
2390
+ const claims = await findPendingClaims(operator, indexer, {
2391
+ contract: script,
2392
+ network: await pinnedNetwork()
2393
+ });
2394
+ return claims.map(({ arkTxid }) => arkTxid);
2395
+ };
2396
+ const finalizeClaim = async (swap) => {
2397
+ const { secret, script } = await claimSecretOf(swap);
2398
+ await track(
2399
+ finalizePendingClaim(operator, indexer, {
2400
+ contract: script,
2401
+ receiver: await contractSigner(wallet, secret.signingDescriptor),
2402
+ preimage: await preimageForSwapRecord(wallet, secret),
2403
+ network: await pinnedNetwork()
2404
+ })
2405
+ );
2406
+ };
2407
+ const claimLockup = async (swap, vtxos, { partiallyClaimed }) => {
2408
+ const { record, secret, script } = await claimSecretOf(swap);
2383
2409
  const payoutAddress = rfqClaimDestinationOf(record);
2384
2410
  if (!payoutAddress) {
2385
2411
  throw new Error(`rfq swap ${swap.rfqId} carries no claim destination`);
@@ -2444,6 +2470,8 @@ var createSwapDrive = (config) => {
2444
2470
  },
2445
2471
  canRefundArkade,
2446
2472
  claimLockup,
2473
+ pendingClaims,
2474
+ finalizeClaim,
2447
2475
  ...onchainSeams?.claim ? { claimOnchain: onchainSeams.claim } : {},
2448
2476
  ...onchainSeams?.refund ? { refundOnchain: onchainSeams.refund } : {}
2449
2477
  });