@arkade-os/swap 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advanced.cjs +1097 -541
- package/dist/advanced.d.cts +19 -21
- package/dist/advanced.d.ts +19 -21
- package/dist/advanced.js +40 -34
- package/dist/{chunk-FQNG4XMF.js → chunk-2HQZLIVX.js} +98 -37
- package/dist/{chunk-5QPJWOCN.js → chunk-6RJVT65W.js} +2 -0
- package/dist/chunk-AUJDREZN.js +445 -0
- package/dist/{chunk-I7WEXXZX.js → chunk-FWRDAL73.js} +157 -477
- package/dist/{chunk-552GDPBU.js → chunk-LCO6AJOS.js} +433 -59
- package/dist/index.cjs +1083 -530
- package/dist/index.d.cts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/index.js +24 -22
- package/dist/{lockupContract-DguuT7NK.d.cts → lockupContract-BTTRVwOt.d.cts} +1 -1
- package/dist/{lockupContract-BUOsghl1.d.ts → lockupContract-aFarhlxj.d.ts} +1 -1
- package/dist/node/index.d.cts +97 -67
- package/dist/node/index.d.ts +97 -67
- package/dist/nostr.cjs +925 -516
- package/dist/nostr.d.cts +1 -1
- package/dist/nostr.d.ts +1 -1
- package/dist/nostr.js +3 -2
- package/dist/{offerFillPlan-_AOLo6kh.d.ts → offerFillPlan-CJC5tnEd.d.ts} +10 -42
- package/dist/{offerFillPlan-Bp6-z6dS.d.cts → offerFillPlan-FmyaQoYT.d.cts} +10 -42
- package/dist/protocol.cjs +1054 -175
- package/dist/protocol.d.cts +42 -23
- package/dist/protocol.d.ts +42 -23
- package/dist/protocol.js +20 -7
- package/dist/repositories/realm/index.d.cts +3 -2
- package/dist/repositories/realm/index.d.ts +3 -2
- package/dist/repositories/sqlite/index.d.cts +3 -2
- package/dist/repositories/sqlite/index.d.ts +3 -2
- package/dist/{repository-CkKK0dGO.d.ts → repository-CwwhIAEd.d.cts} +406 -74
- package/dist/{repository--pfikw2R.d.cts → repository-DO6QKxBx.d.ts} +406 -74
- package/dist/{rfq-IzhOCG02.d.ts → rfq-CYxOyniL.d.ts} +52 -11
- package/dist/rfq-contract.cjs +3 -0
- package/dist/rfq-contract.d.cts +3 -1
- package/dist/rfq-contract.d.ts +3 -1
- package/dist/rfq-contract.js +3 -1
- package/dist/{rfq-BRpo5uWU.d.cts → rfq-nMGywkqI.d.cts} +52 -11
- package/dist/verify-ENO36VPK.js +33 -0
- package/dist/{watch-pvTVFp6-.d.cts → watch-DpDSP2tu.d.cts} +4 -3
- package/dist/{watch-DDNycuUa.d.ts → watch-_fZSgx_l.d.ts} +4 -3
- package/package.json +2 -2
- package/dist/offer-BhonWuKR.d.ts +0 -274
- package/dist/offer-D_qHpWo2.d.cts +0 -274
package/dist/advanced.d.cts
CHANGED
|
@@ -1,14 +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 './offerFillPlan-
|
|
2
|
-
export { e as AcceptConflict, f as AcceptInput, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, k as AssetRfqPreparation,
|
|
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-FmyaQoYT.cjs';
|
|
2
|
+
export { e as AcceptConflict, f as AcceptInput, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, k as AssetRfqPreparation, B as BuildOfferFillPlanOpts, l as CORRIDOR_FACTORIES, m as CancelInput, n as CancelOutcome, o as ClaimedDestination, p as ClientDisposed, q as CorridorBase, r as CorridorClaim, s as CorridorCovenant, t as CorridorDeadline, u as CorridorDeps, v as CorridorDepsByCorridor, w as CorridorDrive, x as CorridorLockup, y as CorridorModule, z as CorridorOverrides, E as CorridorPass, F as CorridorRfqPreparation, G as DEFAULT_MAX_REFUND_WINDOW_SECONDS, H as DiscoveryConfig, I as DiscoveryIndexInput, J as DiscoverySnapshotUnavailable, K as DriveMode, N as DriveRefusal, P as ExchangeOptions, Q as FEED_TTL_MS, R as FeeCeiling, T as FeedFetch, U as FeedQuoteInput, V as FillSponsor, W as FillSponsorFare, X as INDEXED_NETWORKS, Y as InconsistentRoute, Z as InsufficientFunds, _ as JointGraph, $ as LockupOwner, a0 as Market, a1 as MarketLeg, a2 as MaxFeeExceeded, a3 as MissingCorridorDep, a4 as NotCancellable, a5 as OFFER_FILL_OWNERS, a6 as OFFER_FILL_TEMPLATE, a7 as ONCHAIN_CLAIM_FEE_RATE_SATVB, a8 as ObservationSeam, a9 as OfferPreparation, aa as OnchainClaim, ab as OnchainRefund, ac as OperatorUnreachable, ad as ParsedRfqQuote, ae as PayOptions, af as PayResult, ag as QuoteCheck, ah as QuoteExpired, ai as QuotePreparation, aj as QuoteVerificationFailed, ak as REGISTRY_URL, al as ReceiveArtifact, am as ReceiveOptions, an as ReceiveRequest, ao as RecoveryResult, ap as RegisteredAsset, aq as RfqAuctionPolicy, ar as RfqPreparation, as as RfqQuoteInput, at as RouteSide, au as SWAP_ERROR_NAMES, av as SwapClient, aw as SwapClientConfig, ax as SwapDrive, ay as SwapDriveConfig, az as SwapDriveRefusedError, aA as SwapError, aB as SwapErrorName, aC as SwapFilter, aD as UnsupportedRoute, aE as VerbDeps, aF as acceptQuote, aG as buildOfferFillPlan, aH as cancelSwap, aI as canonicalAssetId, aJ as cardMarketOf, aK as chooseMarket, aL as conflictingFields, aM as corridorSet, aN as createSwapClient, aO as createSwapDrive, aP as deepFreeze, aQ as digestJointGraph, aR as discoveryIndex, aS as eligibleMarkets, aT as enforceFeeCeiling, aU as exchange, aV as feedFetch, aW as feedSpread, aX as isAddressable, aY as isCardMarket, aZ as isIndexedNetwork, a_ as isSwapError, a$ as isUsableCard, b0 as liveArkadeInfo, b1 as liveOperatorInfo, b2 as marketBackendOf, b3 as marketKeyOf, b4 as marketOf, b5 as marketRefOf, b6 as parseRfqQuote, b7 as pay, b8 as quoteFromFeed, b9 as quoteViaRfq, ba as readableRecord, bb as receive, bc as resolveCorridorBase, bd as resolveCorridorDeps, be as rfqLeg, bf as rfqPairFor, bg as swapRecordOf, bh as toDiscoveryLeg, bi as unsignedPsbtBytes, bj as usableMarkets, bk as verifyJointGraph, bl as verifyOfferFillPlan, bm as verifyPlanLegs, bn as withCanonicalAmount } from './offerFillPlan-FmyaQoYT.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
|
|
5
|
-
export {
|
|
6
|
-
import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-
|
|
7
|
-
export { S as SwapRefusal } from './rfq-
|
|
4
|
+
import { N as NetworkRef, 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 } from './repository-CwwhIAEd.cjs';
|
|
5
|
+
export { m as ACTIVITY_TOKEN, n as ARKADE_ASSET_NAMESPACE, o as Amount, p as AmountFormatError, q as AmountOn, r as AmountRefusal, s as ArkadeCarrierChoice, t as Artifact, u as AssetIdError, v as AssetIdRefusal, w as AssetNamespace, x as AssetOn, y as AssetPart, z as AssetPaymentInput, B as AssetPaymentTerms, D as AssetRef, E as AssetScale, F as AssetSwapId, G as AtomicDecimal, H as AuctionMarketRef, J as AuctionProvenance, K as BITCOIN_RAILS, M as BTC_ASSET_PART, T as BitcoinRail, U as CORRIDORS, V as CORRIDOR_PASS, W as CardMarketRef, X as CorridorId, Y as CorridorKind, Z as DepositArtifact, _ as DisplayDecimal, $ as Endpoint, a0 as Ep, a1 as LOCKUP_OWNER, a2 as MarketBackend, a3 as MarketRef, a4 as OFFER_SWAP_ID_PREFIX, a5 as Outcome, a6 as ParsedAssetId, a7 as Quote, a8 as QuoteLeg, a9 as RAILS, aa as RFQ_SWAP_ID_PREFIX, ab as RailOf, ac as RankedBid, ad as RawState, ae as ReceiverPaidCarrierQuote, af as RecordedArtifact, ag as RecordedAssetPayment, ah as RecordedEndpoint, ai as RecordedInstrument, aj as RecordedLeg, ak as RestoredMarketRef, al as RfqAmountSide, am as SnapshotRef, an as Swap, ao as SwapFamily, ap as SwapRecordCommon, aq as SwapUpdate, ar as TaxiIdentity, as as Unsubscribe, at as VerifiedCarrierTerms, au as arkadeAsset, av as artifactOf, aw as assetPartOf, ax as assetSwapIdOf, ay as bitcoinNetworkOf, az as btcAssetPart, aA as btcOn, aB as corridorOfRail, aC as corridorOutcome, aD as decodeRfqAmount, aE as encodeRfqAmount, aF as familyOfSwapId, aG as formatAssetId, aH as fromAtomicDecimal, aI as fromRfqAmountSide, aJ as fundingWasNotSubmitted, aK as fundsFromWallet, aL as instrumentOf, aM as isAssetId, aN as isAtomicDecimal, aO as isBtcAsset, aP as isBtcAssetLenient, aQ as isNetworkRef, aR as issuanceOf, aS as legOf, aT as offerOutcome, aU as parseAssetId, aV as quoteIdOfSwapId, aW as railOf, aX as railOfCorridor, aY as readsChain, aZ as recordArtifact, a_ as recordEndpoint, a$ as recordInstrument, b0 as recordLeg, b1 as recordOutcome, b2 as sameAsset, b3 as swapOf, b4 as toAtomicDecimal, b5 as toRfqAmountSide, b6 as toSafeNumber } from './repository-CwwhIAEd.cjs';
|
|
6
|
+
import { I as InvoiceFacts, C as ChainSource, R as RfqQuote, P as Pubkey } from './rfq-nMGywkqI.cjs';
|
|
7
|
+
export { A as AttestingRfqTransport, H as Hex, a as RfqRendezvous, b as RfqTransportFactory, S as SwapRefusal, c as attesting, d as createNostrTransportFactory, n as nostrTransportFactory } from './rfq-nMGywkqI.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-
|
|
11
|
-
import './offer-D_qHpWo2.cjs';
|
|
10
|
+
import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-DpDSP2tu.cjs';
|
|
12
11
|
import './rfq-contract.cjs';
|
|
13
12
|
import 'nostr-tools';
|
|
14
13
|
|
|
@@ -383,6 +382,8 @@ declare const fateMoved: (record: OfferSwapRecord, fate: DepositFate) => boolean
|
|
|
383
382
|
* deadline, hence `market.kind: "restored"` and a zero fee.
|
|
384
383
|
*/
|
|
385
384
|
declare const restoredOfferRecord: (swap: AssetSwap, network: NetworkRef, now: number) => OfferSwapRecord;
|
|
385
|
+
/** A funded record as the restore scan's `reopen` reads it: its deposit and covenant, re-asked. */
|
|
386
|
+
declare const reopenedDeposit: (record: OfferSwapRecord, fundingTxid: string) => AssetSwap;
|
|
386
387
|
/**
|
|
387
388
|
* A corridor record for a v1 `rfqSwaps` row. v1 kept one display `amount` and no quote, invoice or
|
|
388
389
|
* solver key, so both legs carry that amount, the fee is zero, Lightning legs stand in as
|
|
@@ -459,18 +460,6 @@ declare const resolveRoute: (input: QuoteInput, deps: ResolveDeps) => Promise<Re
|
|
|
459
460
|
/** A `number` of sats from atomic units, or {@link AmountEncodingUnsupported}. */
|
|
460
461
|
declare const satsOf: (value: bigint, field: string) => number;
|
|
461
462
|
|
|
462
|
-
/**
|
|
463
|
-
* Quote verification as one invariant: every check runs once, on both backends, before any quote
|
|
464
|
-
* is returned, and every failure is one error class naming the check.
|
|
465
|
-
*
|
|
466
|
-
* The gates themselves stay `rfq.ts`'s (audited, and carrying the covenant-mirroring timing
|
|
467
|
-
* constants); this only maps a gate's stable `reason` to a {@link QuoteCheck}.
|
|
468
|
-
*
|
|
469
|
-
* Two failures are deliberately NOT verification failures: a solver declining is `SwapRefusal`,
|
|
470
|
-
* and an expired or expiring quote is `QuoteExpired` (the remedy is a fresh quote, not a
|
|
471
|
-
* different solver).
|
|
472
|
-
*/
|
|
473
|
-
|
|
474
463
|
/**
|
|
475
464
|
* The fifth check: who answered.
|
|
476
465
|
*
|
|
@@ -488,6 +477,15 @@ declare const verifyResponder: (input: {
|
|
|
488
477
|
/** Whether `expected` came from a source that can be trusted to name it. */
|
|
489
478
|
readonly pinnable: boolean;
|
|
490
479
|
}) => void;
|
|
480
|
+
/**
|
|
481
|
+
* A directed covenant binds `solver_pubkey` into `fulfill`, so it must be the key the transport
|
|
482
|
+
* proved answered: a key nobody behind this quote holds would strand the deposit until cancelled.
|
|
483
|
+
* Folded into the `responder` check. Returns the key, decoded.
|
|
484
|
+
*/
|
|
485
|
+
declare const verifyTaker: (input: {
|
|
486
|
+
readonly attested?: Pubkey;
|
|
487
|
+
readonly solverPubkey: unknown;
|
|
488
|
+
}) => Uint8Array;
|
|
491
489
|
/**
|
|
492
490
|
* The pair check, run here as well as in the transport's `expectQuote`, so a transport that skips
|
|
493
491
|
* it (or one a caller injected) cannot make the quote path skip it too.
|
|
@@ -700,4 +698,4 @@ declare function revealClaimPacket(client: CovclaimdClient, input: {
|
|
|
700
698
|
ciphertext: string;
|
|
701
699
|
}>;
|
|
702
700
|
|
|
703
|
-
export { type AddressParams, ArkadeCorridorDeps, AssetAliasTable, AssetId, type ChainSourceBackend, Corridor, CorridorFactory, type CorridorRecordStore, CorridorSet, CorridorSwapRecord, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, DEFAULT_INVOICE_EXPIRY_SECONDS, type DepositFate, DiscoveryIndex, DiscoveryLeg, DiscoverySnapshot, EVM_CHAIN, type EvmReceiveQuote, type EvmReceiveQuoteProfile, type EvmRfqQuote, type EvmSendQuote, type EvmSendQuoteProfile, INVOICE_HRPS, Instrument, type L1Tip, LIGHTNING_DRIVE, LightningCorridorDeps, MarketCandidate, NetworkRef, ONCHAIN_DRIVE, OfferSwapRecord, OnchainCorridorDeps, PinnedAmount, Pubkey, QuoteId, QuoteInput, Rail, type RecordSink, type ResolveDeps, ResolvedEndpoint, type ResolvedRoute, type RevealParams, Route, RouteResolution, SwapPolicy, SwapRecord, aliasTableFrom, applyOfferSpend, arkadeCorridor, assembleRoute, cardLegAssetId, chainSourceOver, corridorRecordStore, covclaimdClient, decodeBolt11, esploraChainSource, esploraTip, evmAmountFromWire, evmAmountToWire, evmDirectionOf, evmQuoteSats, evmQuoteTokenAmount, evmReceivePair, evmReceiveRequest, evmSendPair, evmSendRequest, evmTokenLeg, evmTokenOf, fateMoved, lightningCorridor, networksOfInvoiceHrp, offerFactsOf, offerRecordSource, onchainCorridor, pageRfqRecords, publicAssetId, readEvmReceiveQuote, readEvmSendQuote, resolveRoute, restoredCorridorRecord, restoredOfferRecord, revealClaimPacket, revealFieldsFromScript, rfqRecordOf, satsOf, scopedToRail, splitRecords, verifiedCarrierSats, verifyCrossAssetAmount, verifyPair, verifyQuoteTtl, verifyQuotedAmount, verifyReceiveInvoiceFacts, verifyReceiveWindow, verifyRefundWindow, verifyResponder, verifySendInvoice, verifySendWindow, verifyingDerivation, walletLockupIndexer, withDepositFate, withRfqState };
|
|
701
|
+
export { type AddressParams, ArkadeCorridorDeps, AssetAliasTable, AssetId, type ChainSourceBackend, Corridor, CorridorFactory, type CorridorRecordStore, CorridorSet, CorridorSwapRecord, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, DEFAULT_INVOICE_EXPIRY_SECONDS, type DepositFate, DiscoveryIndex, DiscoveryLeg, DiscoverySnapshot, EVM_CHAIN, type EvmReceiveQuote, type EvmReceiveQuoteProfile, type EvmRfqQuote, type EvmSendQuote, type EvmSendQuoteProfile, INVOICE_HRPS, Instrument, type L1Tip, LIGHTNING_DRIVE, LightningCorridorDeps, MarketCandidate, NetworkRef, ONCHAIN_DRIVE, OfferSwapRecord, OnchainCorridorDeps, PinnedAmount, Pubkey, QuoteId, QuoteInput, Rail, type RecordSink, type ResolveDeps, ResolvedEndpoint, type ResolvedRoute, type RevealParams, Route, RouteResolution, SwapPolicy, SwapRecord, aliasTableFrom, applyOfferSpend, arkadeCorridor, assembleRoute, cardLegAssetId, chainSourceOver, corridorRecordStore, covclaimdClient, decodeBolt11, esploraChainSource, esploraTip, evmAmountFromWire, evmAmountToWire, evmDirectionOf, evmQuoteSats, evmQuoteTokenAmount, evmReceivePair, evmReceiveRequest, evmSendPair, evmSendRequest, evmTokenLeg, evmTokenOf, fateMoved, lightningCorridor, networksOfInvoiceHrp, offerFactsOf, offerRecordSource, onchainCorridor, pageRfqRecords, publicAssetId, readEvmReceiveQuote, readEvmSendQuote, reopenedDeposit, resolveRoute, restoredCorridorRecord, restoredOfferRecord, revealClaimPacket, revealFieldsFromScript, rfqRecordOf, satsOf, scopedToRail, splitRecords, verifiedCarrierSats, verifyCrossAssetAmount, verifyPair, verifyQuoteTtl, verifyQuotedAmount, verifyReceiveInvoiceFacts, verifyReceiveWindow, verifyRefundWindow, verifyResponder, verifySendInvoice, verifySendWindow, verifyTaker, verifyingDerivation, walletLockupIndexer, withDepositFate, withRfqState };
|
package/dist/advanced.d.ts
CHANGED
|
@@ -1,14 +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 './offerFillPlan-
|
|
2
|
-
export { e as AcceptConflict, f as AcceptInput, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, k as AssetRfqPreparation,
|
|
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-CJC5tnEd.js';
|
|
2
|
+
export { e as AcceptConflict, f as AcceptInput, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, k as AssetRfqPreparation, B as BuildOfferFillPlanOpts, l as CORRIDOR_FACTORIES, m as CancelInput, n as CancelOutcome, o as ClaimedDestination, p as ClientDisposed, q as CorridorBase, r as CorridorClaim, s as CorridorCovenant, t as CorridorDeadline, u as CorridorDeps, v as CorridorDepsByCorridor, w as CorridorDrive, x as CorridorLockup, y as CorridorModule, z as CorridorOverrides, E as CorridorPass, F as CorridorRfqPreparation, G as DEFAULT_MAX_REFUND_WINDOW_SECONDS, H as DiscoveryConfig, I as DiscoveryIndexInput, J as DiscoverySnapshotUnavailable, K as DriveMode, N as DriveRefusal, P as ExchangeOptions, Q as FEED_TTL_MS, R as FeeCeiling, T as FeedFetch, U as FeedQuoteInput, V as FillSponsor, W as FillSponsorFare, X as INDEXED_NETWORKS, Y as InconsistentRoute, Z as InsufficientFunds, _ as JointGraph, $ as LockupOwner, a0 as Market, a1 as MarketLeg, a2 as MaxFeeExceeded, a3 as MissingCorridorDep, a4 as NotCancellable, a5 as OFFER_FILL_OWNERS, a6 as OFFER_FILL_TEMPLATE, a7 as ONCHAIN_CLAIM_FEE_RATE_SATVB, a8 as ObservationSeam, a9 as OfferPreparation, aa as OnchainClaim, ab as OnchainRefund, ac as OperatorUnreachable, ad as ParsedRfqQuote, ae as PayOptions, af as PayResult, ag as QuoteCheck, ah as QuoteExpired, ai as QuotePreparation, aj as QuoteVerificationFailed, ak as REGISTRY_URL, al as ReceiveArtifact, am as ReceiveOptions, an as ReceiveRequest, ao as RecoveryResult, ap as RegisteredAsset, aq as RfqAuctionPolicy, ar as RfqPreparation, as as RfqQuoteInput, at as RouteSide, au as SWAP_ERROR_NAMES, av as SwapClient, aw as SwapClientConfig, ax as SwapDrive, ay as SwapDriveConfig, az as SwapDriveRefusedError, aA as SwapError, aB as SwapErrorName, aC as SwapFilter, aD as UnsupportedRoute, aE as VerbDeps, aF as acceptQuote, aG as buildOfferFillPlan, aH as cancelSwap, aI as canonicalAssetId, aJ as cardMarketOf, aK as chooseMarket, aL as conflictingFields, aM as corridorSet, aN as createSwapClient, aO as createSwapDrive, aP as deepFreeze, aQ as digestJointGraph, aR as discoveryIndex, aS as eligibleMarkets, aT as enforceFeeCeiling, aU as exchange, aV as feedFetch, aW as feedSpread, aX as isAddressable, aY as isCardMarket, aZ as isIndexedNetwork, a_ as isSwapError, a$ as isUsableCard, b0 as liveArkadeInfo, b1 as liveOperatorInfo, b2 as marketBackendOf, b3 as marketKeyOf, b4 as marketOf, b5 as marketRefOf, b6 as parseRfqQuote, b7 as pay, b8 as quoteFromFeed, b9 as quoteViaRfq, ba as readableRecord, bb as receive, bc as resolveCorridorBase, bd as resolveCorridorDeps, be as rfqLeg, bf as rfqPairFor, bg as swapRecordOf, bh as toDiscoveryLeg, bi as unsignedPsbtBytes, bj as usableMarkets, bk as verifyJointGraph, bl as verifyOfferFillPlan, bm as verifyPlanLegs, bn as withCanonicalAmount } from './offerFillPlan-CJC5tnEd.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
|
|
5
|
-
export {
|
|
6
|
-
import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-
|
|
7
|
-
export { S as SwapRefusal } from './rfq-
|
|
4
|
+
import { N as NetworkRef, 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 } from './repository-DO6QKxBx.js';
|
|
5
|
+
export { m as ACTIVITY_TOKEN, n as ARKADE_ASSET_NAMESPACE, o as Amount, p as AmountFormatError, q as AmountOn, r as AmountRefusal, s as ArkadeCarrierChoice, t as Artifact, u as AssetIdError, v as AssetIdRefusal, w as AssetNamespace, x as AssetOn, y as AssetPart, z as AssetPaymentInput, B as AssetPaymentTerms, D as AssetRef, E as AssetScale, F as AssetSwapId, G as AtomicDecimal, H as AuctionMarketRef, J as AuctionProvenance, K as BITCOIN_RAILS, M as BTC_ASSET_PART, T as BitcoinRail, U as CORRIDORS, V as CORRIDOR_PASS, W as CardMarketRef, X as CorridorId, Y as CorridorKind, Z as DepositArtifact, _ as DisplayDecimal, $ as Endpoint, a0 as Ep, a1 as LOCKUP_OWNER, a2 as MarketBackend, a3 as MarketRef, a4 as OFFER_SWAP_ID_PREFIX, a5 as Outcome, a6 as ParsedAssetId, a7 as Quote, a8 as QuoteLeg, a9 as RAILS, aa as RFQ_SWAP_ID_PREFIX, ab as RailOf, ac as RankedBid, ad as RawState, ae as ReceiverPaidCarrierQuote, af as RecordedArtifact, ag as RecordedAssetPayment, ah as RecordedEndpoint, ai as RecordedInstrument, aj as RecordedLeg, ak as RestoredMarketRef, al as RfqAmountSide, am as SnapshotRef, an as Swap, ao as SwapFamily, ap as SwapRecordCommon, aq as SwapUpdate, ar as TaxiIdentity, as as Unsubscribe, at as VerifiedCarrierTerms, au as arkadeAsset, av as artifactOf, aw as assetPartOf, ax as assetSwapIdOf, ay as bitcoinNetworkOf, az as btcAssetPart, aA as btcOn, aB as corridorOfRail, aC as corridorOutcome, aD as decodeRfqAmount, aE as encodeRfqAmount, aF as familyOfSwapId, aG as formatAssetId, aH as fromAtomicDecimal, aI as fromRfqAmountSide, aJ as fundingWasNotSubmitted, aK as fundsFromWallet, aL as instrumentOf, aM as isAssetId, aN as isAtomicDecimal, aO as isBtcAsset, aP as isBtcAssetLenient, aQ as isNetworkRef, aR as issuanceOf, aS as legOf, aT as offerOutcome, aU as parseAssetId, aV as quoteIdOfSwapId, aW as railOf, aX as railOfCorridor, aY as readsChain, aZ as recordArtifact, a_ as recordEndpoint, a$ as recordInstrument, b0 as recordLeg, b1 as recordOutcome, b2 as sameAsset, b3 as swapOf, b4 as toAtomicDecimal, b5 as toRfqAmountSide, b6 as toSafeNumber } from './repository-DO6QKxBx.js';
|
|
6
|
+
import { I as InvoiceFacts, C as ChainSource, R as RfqQuote, P as Pubkey } from './rfq-CYxOyniL.js';
|
|
7
|
+
export { A as AttestingRfqTransport, H as Hex, a as RfqRendezvous, b as RfqTransportFactory, S as SwapRefusal, c as attesting, d as createNostrTransportFactory, n as nostrTransportFactory } from './rfq-CYxOyniL.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-
|
|
11
|
-
import './offer-BhonWuKR.js';
|
|
10
|
+
import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-_fZSgx_l.js';
|
|
12
11
|
import './rfq-contract.js';
|
|
13
12
|
import 'nostr-tools';
|
|
14
13
|
|
|
@@ -383,6 +382,8 @@ declare const fateMoved: (record: OfferSwapRecord, fate: DepositFate) => boolean
|
|
|
383
382
|
* deadline, hence `market.kind: "restored"` and a zero fee.
|
|
384
383
|
*/
|
|
385
384
|
declare const restoredOfferRecord: (swap: AssetSwap, network: NetworkRef, now: number) => OfferSwapRecord;
|
|
385
|
+
/** A funded record as the restore scan's `reopen` reads it: its deposit and covenant, re-asked. */
|
|
386
|
+
declare const reopenedDeposit: (record: OfferSwapRecord, fundingTxid: string) => AssetSwap;
|
|
386
387
|
/**
|
|
387
388
|
* A corridor record for a v1 `rfqSwaps` row. v1 kept one display `amount` and no quote, invoice or
|
|
388
389
|
* solver key, so both legs carry that amount, the fee is zero, Lightning legs stand in as
|
|
@@ -459,18 +460,6 @@ declare const resolveRoute: (input: QuoteInput, deps: ResolveDeps) => Promise<Re
|
|
|
459
460
|
/** A `number` of sats from atomic units, or {@link AmountEncodingUnsupported}. */
|
|
460
461
|
declare const satsOf: (value: bigint, field: string) => number;
|
|
461
462
|
|
|
462
|
-
/**
|
|
463
|
-
* Quote verification as one invariant: every check runs once, on both backends, before any quote
|
|
464
|
-
* is returned, and every failure is one error class naming the check.
|
|
465
|
-
*
|
|
466
|
-
* The gates themselves stay `rfq.ts`'s (audited, and carrying the covenant-mirroring timing
|
|
467
|
-
* constants); this only maps a gate's stable `reason` to a {@link QuoteCheck}.
|
|
468
|
-
*
|
|
469
|
-
* Two failures are deliberately NOT verification failures: a solver declining is `SwapRefusal`,
|
|
470
|
-
* and an expired or expiring quote is `QuoteExpired` (the remedy is a fresh quote, not a
|
|
471
|
-
* different solver).
|
|
472
|
-
*/
|
|
473
|
-
|
|
474
463
|
/**
|
|
475
464
|
* The fifth check: who answered.
|
|
476
465
|
*
|
|
@@ -488,6 +477,15 @@ declare const verifyResponder: (input: {
|
|
|
488
477
|
/** Whether `expected` came from a source that can be trusted to name it. */
|
|
489
478
|
readonly pinnable: boolean;
|
|
490
479
|
}) => void;
|
|
480
|
+
/**
|
|
481
|
+
* A directed covenant binds `solver_pubkey` into `fulfill`, so it must be the key the transport
|
|
482
|
+
* proved answered: a key nobody behind this quote holds would strand the deposit until cancelled.
|
|
483
|
+
* Folded into the `responder` check. Returns the key, decoded.
|
|
484
|
+
*/
|
|
485
|
+
declare const verifyTaker: (input: {
|
|
486
|
+
readonly attested?: Pubkey;
|
|
487
|
+
readonly solverPubkey: unknown;
|
|
488
|
+
}) => Uint8Array;
|
|
491
489
|
/**
|
|
492
490
|
* The pair check, run here as well as in the transport's `expectQuote`, so a transport that skips
|
|
493
491
|
* it (or one a caller injected) cannot make the quote path skip it too.
|
|
@@ -700,4 +698,4 @@ declare function revealClaimPacket(client: CovclaimdClient, input: {
|
|
|
700
698
|
ciphertext: string;
|
|
701
699
|
}>;
|
|
702
700
|
|
|
703
|
-
export { type AddressParams, ArkadeCorridorDeps, AssetAliasTable, AssetId, type ChainSourceBackend, Corridor, CorridorFactory, type CorridorRecordStore, CorridorSet, CorridorSwapRecord, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, DEFAULT_INVOICE_EXPIRY_SECONDS, type DepositFate, DiscoveryIndex, DiscoveryLeg, DiscoverySnapshot, EVM_CHAIN, type EvmReceiveQuote, type EvmReceiveQuoteProfile, type EvmRfqQuote, type EvmSendQuote, type EvmSendQuoteProfile, INVOICE_HRPS, Instrument, type L1Tip, LIGHTNING_DRIVE, LightningCorridorDeps, MarketCandidate, NetworkRef, ONCHAIN_DRIVE, OfferSwapRecord, OnchainCorridorDeps, PinnedAmount, Pubkey, QuoteId, QuoteInput, Rail, type RecordSink, type ResolveDeps, ResolvedEndpoint, type ResolvedRoute, type RevealParams, Route, RouteResolution, SwapPolicy, SwapRecord, aliasTableFrom, applyOfferSpend, arkadeCorridor, assembleRoute, cardLegAssetId, chainSourceOver, corridorRecordStore, covclaimdClient, decodeBolt11, esploraChainSource, esploraTip, evmAmountFromWire, evmAmountToWire, evmDirectionOf, evmQuoteSats, evmQuoteTokenAmount, evmReceivePair, evmReceiveRequest, evmSendPair, evmSendRequest, evmTokenLeg, evmTokenOf, fateMoved, lightningCorridor, networksOfInvoiceHrp, offerFactsOf, offerRecordSource, onchainCorridor, pageRfqRecords, publicAssetId, readEvmReceiveQuote, readEvmSendQuote, resolveRoute, restoredCorridorRecord, restoredOfferRecord, revealClaimPacket, revealFieldsFromScript, rfqRecordOf, satsOf, scopedToRail, splitRecords, verifiedCarrierSats, verifyCrossAssetAmount, verifyPair, verifyQuoteTtl, verifyQuotedAmount, verifyReceiveInvoiceFacts, verifyReceiveWindow, verifyRefundWindow, verifyResponder, verifySendInvoice, verifySendWindow, verifyingDerivation, walletLockupIndexer, withDepositFate, withRfqState };
|
|
701
|
+
export { type AddressParams, ArkadeCorridorDeps, AssetAliasTable, AssetId, type ChainSourceBackend, Corridor, CorridorFactory, type CorridorRecordStore, CorridorSet, CorridorSwapRecord, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, DEFAULT_INVOICE_EXPIRY_SECONDS, type DepositFate, DiscoveryIndex, DiscoveryLeg, DiscoverySnapshot, EVM_CHAIN, type EvmReceiveQuote, type EvmReceiveQuoteProfile, type EvmRfqQuote, type EvmSendQuote, type EvmSendQuoteProfile, INVOICE_HRPS, Instrument, type L1Tip, LIGHTNING_DRIVE, LightningCorridorDeps, MarketCandidate, NetworkRef, ONCHAIN_DRIVE, OfferSwapRecord, OnchainCorridorDeps, PinnedAmount, Pubkey, QuoteId, QuoteInput, Rail, type RecordSink, type ResolveDeps, ResolvedEndpoint, type ResolvedRoute, type RevealParams, Route, RouteResolution, SwapPolicy, SwapRecord, aliasTableFrom, applyOfferSpend, arkadeCorridor, assembleRoute, cardLegAssetId, chainSourceOver, corridorRecordStore, covclaimdClient, decodeBolt11, esploraChainSource, esploraTip, evmAmountFromWire, evmAmountToWire, evmDirectionOf, evmQuoteSats, evmQuoteTokenAmount, evmReceivePair, evmReceiveRequest, evmSendPair, evmSendRequest, evmTokenLeg, evmTokenOf, fateMoved, lightningCorridor, networksOfInvoiceHrp, offerFactsOf, offerRecordSource, onchainCorridor, pageRfqRecords, publicAssetId, readEvmReceiveQuote, readEvmSendQuote, reopenedDeposit, resolveRoute, restoredCorridorRecord, restoredOfferRecord, revealClaimPacket, revealFieldsFromScript, rfqRecordOf, satsOf, scopedToRail, splitRecords, verifiedCarrierSats, verifyCrossAssetAmount, verifyPair, verifyQuoteTtl, verifyQuotedAmount, verifyReceiveInvoiceFacts, verifyReceiveWindow, verifyRefundWindow, verifyResponder, verifySendInvoice, verifySendWindow, verifyTaker, verifyingDerivation, walletLockupIndexer, withDepositFate, withRfqState };
|
package/dist/advanced.js
CHANGED
|
@@ -1,36 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ARKADE_ASSET_NAMESPACE,
|
|
3
|
-
AcceptConflict,
|
|
4
|
-
AmbiguousDestination,
|
|
5
|
-
AmountEncodingUnsupported,
|
|
6
|
-
AmountMismatch,
|
|
7
3
|
AssetIdError,
|
|
8
4
|
BITCOIN_RAILS,
|
|
9
5
|
BTC_ASSET_PART,
|
|
10
6
|
CORRIDORS,
|
|
11
7
|
CORRIDOR_FACTORIES,
|
|
12
|
-
ClientDisposed,
|
|
13
8
|
DEFAULT_INVOICE_EXPIRY_SECONDS,
|
|
14
|
-
DEFAULT_MAX_REFUND_WINDOW_SECONDS,
|
|
15
|
-
DiscoverySnapshotUnavailable,
|
|
16
9
|
FEED_TTL_MS,
|
|
17
10
|
INDEXED_NETWORKS,
|
|
18
|
-
InconsistentRoute,
|
|
19
|
-
InsufficientFunds,
|
|
20
|
-
MaxFeeExceeded,
|
|
21
|
-
MissingCorridorDep,
|
|
22
|
-
NotCancellable,
|
|
23
11
|
OFFER_FILL_OWNERS,
|
|
24
12
|
OFFER_FILL_TEMPLATE,
|
|
25
13
|
ONCHAIN_CLAIM_FEE_RATE_SATVB,
|
|
26
|
-
OperatorUnreachable,
|
|
27
|
-
QuoteExpired,
|
|
28
|
-
QuoteVerificationFailed,
|
|
29
14
|
RAILS,
|
|
30
15
|
REGISTRY_URL,
|
|
31
|
-
SWAP_ERROR_NAMES,
|
|
32
16
|
SwapDriveRefusedError,
|
|
33
|
-
UnsupportedRoute,
|
|
34
17
|
acceptQuote,
|
|
35
18
|
aliasTableFrom,
|
|
36
19
|
applyOfferSpend,
|
|
@@ -79,7 +62,6 @@ import {
|
|
|
79
62
|
isCardMarket,
|
|
80
63
|
isIndexedNetwork,
|
|
81
64
|
isNetworkRef,
|
|
82
|
-
isSwapError,
|
|
83
65
|
isUsableCard,
|
|
84
66
|
issuanceOf,
|
|
85
67
|
liveArkadeInfo,
|
|
@@ -102,6 +84,7 @@ import {
|
|
|
102
84
|
railOfCorridor,
|
|
103
85
|
readableRecord,
|
|
104
86
|
receive,
|
|
87
|
+
reopenedDeposit,
|
|
105
88
|
resolveCorridorBase,
|
|
106
89
|
resolveCorridorDeps,
|
|
107
90
|
resolveRoute,
|
|
@@ -120,26 +103,14 @@ import {
|
|
|
120
103
|
toSafeNumber,
|
|
121
104
|
unsignedPsbtBytes,
|
|
122
105
|
usableMarkets,
|
|
123
|
-
verifiedCarrierSats,
|
|
124
|
-
verifyCrossAssetAmount,
|
|
125
106
|
verifyJointGraph,
|
|
126
107
|
verifyOfferFillPlan,
|
|
127
|
-
verifyPair,
|
|
128
108
|
verifyPlanLegs,
|
|
129
|
-
verifyQuoteTtl,
|
|
130
|
-
verifyQuotedAmount,
|
|
131
|
-
verifyReceiveInvoiceFacts,
|
|
132
|
-
verifyReceiveWindow,
|
|
133
|
-
verifyRefundWindow,
|
|
134
|
-
verifyResponder,
|
|
135
|
-
verifySendInvoice,
|
|
136
|
-
verifySendWindow,
|
|
137
|
-
verifyingDerivation,
|
|
138
109
|
walletLockupIndexer,
|
|
139
110
|
withCanonicalAmount,
|
|
140
111
|
withDepositFate,
|
|
141
112
|
withRfqState
|
|
142
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-FWRDAL73.js";
|
|
143
114
|
import {
|
|
144
115
|
ACTIVITY_TOKEN,
|
|
145
116
|
Amount,
|
|
@@ -174,7 +145,40 @@ import {
|
|
|
174
145
|
recordOutcome,
|
|
175
146
|
swapOf,
|
|
176
147
|
toAtomicDecimal
|
|
177
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-2HQZLIVX.js";
|
|
149
|
+
import {
|
|
150
|
+
AcceptConflict,
|
|
151
|
+
AmbiguousDestination,
|
|
152
|
+
AmountEncodingUnsupported,
|
|
153
|
+
AmountMismatch,
|
|
154
|
+
ClientDisposed,
|
|
155
|
+
DEFAULT_MAX_REFUND_WINDOW_SECONDS,
|
|
156
|
+
DiscoverySnapshotUnavailable,
|
|
157
|
+
InconsistentRoute,
|
|
158
|
+
InsufficientFunds,
|
|
159
|
+
MaxFeeExceeded,
|
|
160
|
+
MissingCorridorDep,
|
|
161
|
+
NotCancellable,
|
|
162
|
+
OperatorUnreachable,
|
|
163
|
+
QuoteExpired,
|
|
164
|
+
QuoteVerificationFailed,
|
|
165
|
+
SWAP_ERROR_NAMES,
|
|
166
|
+
UnsupportedRoute,
|
|
167
|
+
isSwapError,
|
|
168
|
+
verifiedCarrierSats,
|
|
169
|
+
verifyCrossAssetAmount,
|
|
170
|
+
verifyPair,
|
|
171
|
+
verifyQuoteTtl,
|
|
172
|
+
verifyQuotedAmount,
|
|
173
|
+
verifyReceiveInvoiceFacts,
|
|
174
|
+
verifyReceiveWindow,
|
|
175
|
+
verifyRefundWindow,
|
|
176
|
+
verifyResponder,
|
|
177
|
+
verifySendInvoice,
|
|
178
|
+
verifySendWindow,
|
|
179
|
+
verifyTaker,
|
|
180
|
+
verifyingDerivation
|
|
181
|
+
} from "./chunk-AUJDREZN.js";
|
|
178
182
|
import {
|
|
179
183
|
ARKADE_BTC,
|
|
180
184
|
SwapRefusal,
|
|
@@ -183,8 +187,8 @@ import {
|
|
|
183
187
|
bindsClaimAmount,
|
|
184
188
|
rfqPair,
|
|
185
189
|
sealClaimPacket
|
|
186
|
-
} from "./chunk-
|
|
187
|
-
import "./chunk-
|
|
190
|
+
} from "./chunk-LCO6AJOS.js";
|
|
191
|
+
import "./chunk-6RJVT65W.js";
|
|
188
192
|
import "./chunk-A3SHHRX4.js";
|
|
189
193
|
|
|
190
194
|
// src/reveal.ts
|
|
@@ -703,6 +707,7 @@ export {
|
|
|
703
707
|
recordInstrument,
|
|
704
708
|
recordLeg,
|
|
705
709
|
recordOutcome,
|
|
710
|
+
reopenedDeposit,
|
|
706
711
|
resolveCorridorBase,
|
|
707
712
|
resolveCorridorDeps,
|
|
708
713
|
resolveRoute,
|
|
@@ -739,6 +744,7 @@ export {
|
|
|
739
744
|
verifyResponder,
|
|
740
745
|
verifySendInvoice,
|
|
741
746
|
verifySendWindow,
|
|
747
|
+
verifyTaker,
|
|
742
748
|
verifyingDerivation,
|
|
743
749
|
walletLockupIndexer,
|
|
744
750
|
withCanonicalAmount,
|
|
@@ -9,22 +9,28 @@ import {
|
|
|
9
9
|
RETIRABLE,
|
|
10
10
|
RFQ_TERMINAL_STATES,
|
|
11
11
|
assertPreimageMatches,
|
|
12
|
+
bindingFromOffer,
|
|
13
|
+
bindingProgram,
|
|
12
14
|
classifyOnchainHtlc,
|
|
13
15
|
decodeOffer,
|
|
16
|
+
encodeOffer,
|
|
14
17
|
gateError,
|
|
15
18
|
getAssetSwaps,
|
|
16
19
|
hydrateHashlock,
|
|
17
20
|
l1NetworkFromArk,
|
|
18
21
|
lockupContractParams,
|
|
19
22
|
offerContract,
|
|
23
|
+
offerFromBinding,
|
|
20
24
|
onchainHtlcScript,
|
|
21
25
|
pollUntil,
|
|
26
|
+
recordOfferBinding,
|
|
22
27
|
registerLockupContract,
|
|
23
28
|
retireOfferContract,
|
|
24
29
|
rfqCorridorHandlers,
|
|
25
30
|
rfqSignerOf,
|
|
31
|
+
storedOffer,
|
|
26
32
|
updateAssetSwapBestEffort
|
|
27
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-LCO6AJOS.js";
|
|
28
34
|
import {
|
|
29
35
|
collectRfqSwaps
|
|
30
36
|
} from "./chunk-A3SHHRX4.js";
|
|
@@ -1540,6 +1546,7 @@ import { base64 as base642, hex as hex4 } from "@scure/base";
|
|
|
1540
1546
|
import {
|
|
1541
1547
|
Extension as Extension2,
|
|
1542
1548
|
Transaction as Transaction2,
|
|
1549
|
+
arkade,
|
|
1543
1550
|
scriptFromTapLeafScript as scriptFromTapLeafScript2
|
|
1544
1551
|
} from "@arkade-os/sdk";
|
|
1545
1552
|
var TXS_PER_REQUEST = 50;
|
|
@@ -1578,8 +1585,16 @@ var unscannedSwapCandidates = (txs, existingIds, scanned) => txs.filter(
|
|
|
1578
1585
|
function classifySpend(offer, operatorPubkey, spendTx, deposit) {
|
|
1579
1586
|
let leaves;
|
|
1580
1587
|
try {
|
|
1581
|
-
|
|
1582
|
-
if (
|
|
1588
|
+
let script;
|
|
1589
|
+
if ("version" in offer) {
|
|
1590
|
+
const { program, args, keys } = bindingProgram(offer);
|
|
1591
|
+
script = new arkade.ArkadeProgramScript(program, args, keys);
|
|
1592
|
+
} else {
|
|
1593
|
+
script = offerContract(offer, operatorPubkey);
|
|
1594
|
+
if (hex4.encode(script.pkScript) !== hex4.encode(offer.swapPkScript)) {
|
|
1595
|
+
return "indeterminate";
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1583
1598
|
leaves = {
|
|
1584
1599
|
// `exit` is absent on an offer with no exit closure, and drops out here
|
|
1585
1600
|
returned: ["cancel", "exit"].map((name) => script.functionByName(name)?.leafScript).filter((leaf) => leaf !== void 0),
|
|
@@ -1608,21 +1623,56 @@ function classifyDepositSpend(offer, operatorPubkey, spendTxs, deposit) {
|
|
|
1608
1623
|
}
|
|
1609
1624
|
return "indeterminate";
|
|
1610
1625
|
}
|
|
1626
|
+
var encodesOffer = (offerHex, offer) => {
|
|
1627
|
+
try {
|
|
1628
|
+
const { ratioNum: _num, ratioDen: _den, ...terms } = decodeOffer(hex4.decode(offerHex));
|
|
1629
|
+
return hex4.encode(encodeOffer(terms)) === hex4.encode(encodeOffer(offer));
|
|
1630
|
+
} catch {
|
|
1631
|
+
return false;
|
|
1632
|
+
}
|
|
1633
|
+
};
|
|
1634
|
+
var packetRecoverySource = (indexer) => ({
|
|
1635
|
+
name: "packet",
|
|
1636
|
+
async discover({ candidateTxids, operatorPubkey }) {
|
|
1637
|
+
const found = [];
|
|
1638
|
+
const declined = [];
|
|
1639
|
+
for (const [txid, parsed] of await fetchParsedTxs(indexer, [...candidateTxids])) {
|
|
1640
|
+
let packet;
|
|
1641
|
+
try {
|
|
1642
|
+
packet = Extension2.fromTx(parsed).getPacketByType(OFFER_PACKET_TYPE);
|
|
1643
|
+
} catch {
|
|
1644
|
+
}
|
|
1645
|
+
if (!packet) {
|
|
1646
|
+
declined.push(txid);
|
|
1647
|
+
continue;
|
|
1648
|
+
}
|
|
1649
|
+
const payload = packet.serialize();
|
|
1650
|
+
try {
|
|
1651
|
+
const binding = bindingFromOffer(decodeOffer(payload), operatorPubkey);
|
|
1652
|
+
found.push({ fundingTxid: txid, binding, offerHex: hex4.encode(payload) });
|
|
1653
|
+
} catch {
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
return { found, declined };
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1611
1659
|
async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
1612
1660
|
const {
|
|
1613
1661
|
operatorPubkey,
|
|
1614
1662
|
scanned = /* @__PURE__ */ new Set(),
|
|
1615
1663
|
reopen = [],
|
|
1616
1664
|
hrp,
|
|
1617
|
-
recoveredIn = /* @__PURE__ */ new Set()
|
|
1665
|
+
recoveredIn = /* @__PURE__ */ new Set(),
|
|
1666
|
+
sources = [packetRecoverySource(indexer)]
|
|
1618
1667
|
} = opts;
|
|
1619
1668
|
const reopened = [];
|
|
1620
1669
|
for (const swap of reopen) {
|
|
1621
1670
|
try {
|
|
1671
|
+
const source = storedOffer(swap);
|
|
1622
1672
|
reopened.push({
|
|
1623
1673
|
fundingTx: { type: "sent", redeemTxid: swap.fundingTxid },
|
|
1624
|
-
offer:
|
|
1625
|
-
|
|
1674
|
+
offer: "version" in source ? offerFromBinding(source) : source,
|
|
1675
|
+
source,
|
|
1626
1676
|
existing: swap
|
|
1627
1677
|
});
|
|
1628
1678
|
} catch {
|
|
@@ -1636,29 +1686,40 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
1636
1686
|
return { restored: [], scannedTxids: [] };
|
|
1637
1687
|
}
|
|
1638
1688
|
const byTxid = new Map(candidates.map((tx) => [tx.redeemTxid, tx]));
|
|
1639
|
-
const
|
|
1640
|
-
indexer,
|
|
1641
|
-
candidates.map((tx) => tx.redeemTxid)
|
|
1642
|
-
);
|
|
1643
|
-
const fetchedTxids = [];
|
|
1689
|
+
const candidateTxids = candidates.map((tx) => tx.redeemTxid);
|
|
1644
1690
|
const found = [...reopened];
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1691
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
1692
|
+
const declined = /* @__PURE__ */ new Set();
|
|
1693
|
+
for (const recovery of candidateTxids.length === 0 ? [] : sources) {
|
|
1694
|
+
let answer;
|
|
1649
1695
|
try {
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1696
|
+
answer = await recovery.discover({ candidateTxids, operatorPubkey });
|
|
1697
|
+
} catch (error) {
|
|
1698
|
+
console.warn(`[swap] recovery source ${recovery.name} failed`, error);
|
|
1699
|
+
continue;
|
|
1700
|
+
}
|
|
1701
|
+
for (const txid of answer.declined) declined.add(txid);
|
|
1702
|
+
for (const { fundingTxid, binding, offerHex } of answer.found) {
|
|
1703
|
+
const fundingTx = byTxid.get(fundingTxid);
|
|
1704
|
+
if (!fundingTx || claimed.has(fundingTxid)) continue;
|
|
1705
|
+
let offer;
|
|
1706
|
+
try {
|
|
1707
|
+
offer = offerFromBinding(binding);
|
|
1708
|
+
} catch (error) {
|
|
1709
|
+
console.warn(`[swap] ${recovery.name} sent a binding that does not compile`, error);
|
|
1710
|
+
continue;
|
|
1711
|
+
}
|
|
1712
|
+
if (offerHex !== void 0 && !encodesOffer(offerHex, offer)) {
|
|
1713
|
+
console.warn(`[swap] ${recovery.name} sent a packet its binding does not match`);
|
|
1714
|
+
continue;
|
|
1715
|
+
}
|
|
1716
|
+
claimed.add(fundingTxid);
|
|
1717
|
+
const packet = offerHex ?? hex4.encode(encodeOffer(offer));
|
|
1718
|
+
found.push({ fundingTx, offer, source: binding, offerHex: packet });
|
|
1659
1719
|
}
|
|
1660
1720
|
}
|
|
1661
|
-
|
|
1721
|
+
const answered = [...claimed, ...[...declined].filter((txid) => !claimed.has(txid))];
|
|
1722
|
+
if (found.length === 0) return { restored: [], scannedTxids: answered };
|
|
1662
1723
|
const scripts = [...new Set(found.map((f) => hex4.encode(f.offer.swapPkScript)))];
|
|
1663
1724
|
const { vtxos } = await indexer.getVtxos({ scripts });
|
|
1664
1725
|
const vtxoByScriptAndTxid = new Map(vtxos.map((v) => [`${v.script}:${v.txid}`, v]));
|
|
@@ -1679,7 +1740,7 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
1679
1740
|
const spendTxByTxid = await fetchParsedTxs(indexer, [...spendTxids]);
|
|
1680
1741
|
const restored = [];
|
|
1681
1742
|
const unresolved = /* @__PURE__ */ new Set();
|
|
1682
|
-
for (const { fundingTx, offer, offerHex, existing } of found) {
|
|
1743
|
+
for (const { fundingTx, offer, source, offerHex, existing } of found) {
|
|
1683
1744
|
const swapPkScript = hex4.encode(offer.swapPkScript);
|
|
1684
1745
|
const vtxo = vtxoByScriptAndTxid.get(`${swapPkScript}:${fundingTx.redeemTxid}`);
|
|
1685
1746
|
if (!vtxo) {
|
|
@@ -1708,7 +1769,7 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
1708
1769
|
} else if (vtxo.isSwept && !vtxo.isSpent) status = "recoverable";
|
|
1709
1770
|
else if (vtxo.isSpent) {
|
|
1710
1771
|
const spendTxs = spendTxidsOf(vtxo).map((id) => spendTxByTxid.get(id)).filter((tx) => tx !== void 0);
|
|
1711
|
-
const kind = classifyDepositSpend(
|
|
1772
|
+
const kind = classifyDepositSpend(source, operatorPubkey, spendTxs, {
|
|
1712
1773
|
txid: vtxo.txid,
|
|
1713
1774
|
vout: vtxo.vout
|
|
1714
1775
|
});
|
|
@@ -1724,20 +1785,19 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
1724
1785
|
restored.push({ ...existing, status, spentTxid, ...completion });
|
|
1725
1786
|
continue;
|
|
1726
1787
|
}
|
|
1788
|
+
if (!("version" in source)) continue;
|
|
1727
1789
|
let swapAddress = "";
|
|
1728
1790
|
try {
|
|
1729
|
-
const compiled = offerContract(offer, operatorPubkey);
|
|
1730
|
-
if (hex4.encode(compiled.pkScript) !== swapPkScript) {
|
|
1731
|
-
unresolved.add(fundingTx.redeemTxid);
|
|
1732
|
-
continue;
|
|
1733
|
-
}
|
|
1734
1791
|
if (hrp !== void 0) {
|
|
1735
|
-
|
|
1792
|
+
const { program, args, keys } = bindingProgram(source);
|
|
1793
|
+
const compiled = new arkade.ArkadeProgramScript(program, args, keys);
|
|
1794
|
+
swapAddress = compiled.address(hrp, source.serverPublicKey).encode();
|
|
1736
1795
|
}
|
|
1737
1796
|
} catch {
|
|
1738
1797
|
unresolved.add(fundingTx.redeemTxid);
|
|
1739
1798
|
continue;
|
|
1740
1799
|
}
|
|
1800
|
+
const covenant = source.taker === void 0 ? { offerHex: offerHex ?? hex4.encode(encodeOffer(offer)) } : { binding: recordOfferBinding(source) };
|
|
1741
1801
|
restored.push({
|
|
1742
1802
|
id: fundingTx.redeemTxid,
|
|
1743
1803
|
fromAsset,
|
|
@@ -1746,7 +1806,7 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
1746
1806
|
toAmount: offer.wantAmount.toString(),
|
|
1747
1807
|
swapAddress,
|
|
1748
1808
|
swapPkScript,
|
|
1749
|
-
|
|
1809
|
+
...covenant,
|
|
1750
1810
|
fundingTxid: fundingTx.redeemTxid,
|
|
1751
1811
|
spentTxid,
|
|
1752
1812
|
status,
|
|
@@ -1754,7 +1814,7 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
1754
1814
|
...completion
|
|
1755
1815
|
});
|
|
1756
1816
|
}
|
|
1757
|
-
return { restored, scannedTxids:
|
|
1817
|
+
return { restored, scannedTxids: answered.filter((id) => !unresolved.has(id)) };
|
|
1758
1818
|
}
|
|
1759
1819
|
|
|
1760
1820
|
// src/rfqSwapState.ts
|
|
@@ -3406,7 +3466,7 @@ var errorMessage = (error) => error instanceof Error ? error.message : String(er
|
|
|
3406
3466
|
var outpointKey = (vtxo) => `${vtxo.txid}:${vtxo.vout}`;
|
|
3407
3467
|
|
|
3408
3468
|
// src/watch.ts
|
|
3409
|
-
import { base64 as base644
|
|
3469
|
+
import { base64 as base644 } from "@scure/base";
|
|
3410
3470
|
import {
|
|
3411
3471
|
ArkAddress as ArkAddress2,
|
|
3412
3472
|
isContractVtxoEvent as isContractVtxoEvent2,
|
|
@@ -3456,7 +3516,7 @@ async function watchOfferSwaps({
|
|
|
3456
3516
|
if (candidates.length === 0) return "indeterminate";
|
|
3457
3517
|
const { txs } = await indexer.getVirtualTxs(candidates);
|
|
3458
3518
|
return classifyDepositSpend(
|
|
3459
|
-
|
|
3519
|
+
storedOffer(swap),
|
|
3460
3520
|
operatorPubkey,
|
|
3461
3521
|
txs.map((psbt) => Transaction4.fromPSBT(base644.decode(psbt))),
|
|
3462
3522
|
{ txid: vtxo.txid, vout: vtxo.vout }
|
|
@@ -3569,6 +3629,7 @@ export {
|
|
|
3569
3629
|
classifySpend,
|
|
3570
3630
|
spendTxidsOf,
|
|
3571
3631
|
classifyDepositSpend,
|
|
3632
|
+
packetRecoverySource,
|
|
3572
3633
|
restoreAssetSwaps,
|
|
3573
3634
|
isRfqSwapTerminal,
|
|
3574
3635
|
isRecheckableRefundedSend,
|
|
@@ -4,6 +4,7 @@ var RFQ_CONTRACT_VERSION_KEY = "contract_version";
|
|
|
4
4
|
var RFQ_CONTRACT_VERSION_UNSUPPORTED = "contract_version_unsupported";
|
|
5
5
|
var ASSET_SWAP_V2 = "asset-swap-v2";
|
|
6
6
|
var ASSET_SWAP_V3 = "asset-swap-v3";
|
|
7
|
+
var ASSET_SWAP_V4 = "asset-swap-v4";
|
|
7
8
|
var ASSET_SWAP_BASELINE = ASSET_SWAP_V2;
|
|
8
9
|
|
|
9
10
|
export {
|
|
@@ -12,5 +13,6 @@ export {
|
|
|
12
13
|
RFQ_CONTRACT_VERSION_UNSUPPORTED,
|
|
13
14
|
ASSET_SWAP_V2,
|
|
14
15
|
ASSET_SWAP_V3,
|
|
16
|
+
ASSET_SWAP_V4,
|
|
15
17
|
ASSET_SWAP_BASELINE
|
|
16
18
|
};
|