@arkade-os/swap 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { ProvisionedKey, ProvisionedClaimSecret, asset, RelativeTimelock, IWallet, arkade, RestIndexerProvider, Transaction, IContractManager, VHTLC, Identity, ActivityResolver } from '@arkade-os/sdk';
2
- import { S as SwapSecretsProjection, R as RfqSwapRecord, A as AssetSwapRepository, a as AssetSwap, M as MarketsCacheEntry, b as RefundArkProvider, c as RefundIndexer, L as LockupVtxo, d as RfqSwap, e as ArkadeRefundResult, f as LockupSpendIndexer, g as RfqSwapState } from './repository-B02vsgcV.cjs';
3
- export { h as AssetSwapStatus, i as AvailableRfqSwapManagerCallbacks, B as BTC_ASSET_ID, I as InMemoryAssetSwapRepository, j as LightningReceiveSwap, k as LightningSendSwap, l as LockupFate, m as LockupNeedsRecoveryError, n as LockupParams, o as LockupSpend, O as OnchainSendAction, p as OnchainSendSwap, P as PersistableRfqSwap, q as PreimageBlockedReason, r as PreimageNotRecoverableError, s as REFUND_MTP_LAG_SECONDS, t as RFQ_RESOLVED_STATES, u as RFQ_SWAP_RETENTION_SECONDS, v as RFQ_SWAP_TERMINAL_STATES, w as RefundOutcome, x as RfqRestoreFailure, y as RfqRestoreOptions, z as RfqRestoreResult, C as RfqSwapActionName, D as RfqSwapLockup, E as RfqSwapManager, F as RfqSwapManagerCallbacks, G as RfqSwapManagerConfig, H as RfqSwapManagerDeps, J as RfqSwapManagerEvents, K as RfqSwapOrigin, N as RfqSwapOriginRequired, Q as RfqSwapOutcome, T as RfqSwapRecordStore, U as SwapContractRegistry, V as addAssetSwap, W as awaitRfqResolution, X as createRfqSwapRecord, Y as findLockupVtxos, Z as getAssetSwaps, _ as getAssetSwapsOrThrow, $ as isRfqSwapTerminal, a0 as isRfqTerminal, a1 as nextOnchainAction, a2 as preimageForSwapRecord, a3 as pushRefundWithoutReceiver, a4 as readLockupFate, a5 as rebuildRfqSwap, a6 as refundIfUnresolved, a7 as rfqSwapOriginOf, a8 as shouldRetainRfqSwap, a9 as swapSecretsToRecord, aa as updateAssetSwap, ab as updateAssetSwapBestEffort, ac as updateRfqSwapRecord } from './repository-B02vsgcV.cjs';
1
+ import { ProvisionedKey, ProvisionedClaimSecret, asset, RelativeTimelock, IWallet, arkade, RestIndexerProvider, Transaction, IContractManager, OnchainProvider, PaymentRail, Asset, VHTLC, Identity, ActivityResolver } from '@arkade-os/sdk';
2
+ import { S as SwapSecretsProjection, R as RfqSwapRecord, A as AssetSwapRepository, a as AssetSwap, M as MarketsCacheEntry, b as RefundArkProvider, c as RefundIndexer, L as LockupVtxo, d as RfqSwap, e as ArkadeRefundResult, f as LockupSpendIndexer, g as RfqSwapState } from './repository-Vfx65uF1.cjs';
3
+ export { h as AssetSwapStatus, i as AvailableRfqSwapManagerCallbacks, B as BTC_ASSET_ID, I as InMemoryAssetSwapRepository, j as LightningReceiveSwap, k as LightningSendSwap, l as LockupFate, m as LockupNeedsRecoveryError, n as LockupParams, o as LockupSpend, O as OnchainSendAction, p as OnchainSendSwap, P as PersistableRfqSwap, q as PreimageBlockedReason, r as PreimageNotRecoverableError, s as REFUND_MTP_LAG_SECONDS, t as RFQ_RESOLVED_STATES, u as RFQ_SWAP_RETENTION_SECONDS, v as RFQ_SWAP_TERMINAL_STATES, w as RefundOutcome, x as RfqRestoreFailure, y as RfqRestoreOptions, z as RfqRestoreResult, C as RfqSwapActionName, D as RfqSwapLockup, E as RfqSwapManager, F as RfqSwapManagerCallbacks, G as RfqSwapManagerConfig, H as RfqSwapManagerDeps, J as RfqSwapManagerEvents, K as RfqSwapOrigin, N as RfqSwapOriginRequired, Q as RfqSwapOutcome, T as RfqSwapRecordStore, U as SwapContractRegistry, V as addAssetSwap, W as awaitRfqResolution, X as createRfqSwapRecord, Y as findLockupVtxos, Z as getAssetSwaps, _ as getAssetSwapsOrThrow, $ as isRfqSwapTerminal, a0 as isRfqTerminal, a1 as nextOnchainAction, a2 as preimageForSwapRecord, a3 as pushRefundWithoutReceiver, a4 as readLockupFate, a5 as rebuildRfqSwap, a6 as refundIfUnresolved, a7 as rfqSwapOriginOf, a8 as shouldRetainRfqSwap, a9 as swapSecretsToRecord, aa as updateAssetSwap, ab as updateAssetSwapBestEffort, ac as updateRfqSwapRecord } from './repository-Vfx65uF1.cjs';
4
4
  import { Network, LocalCardInput, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
5
- import { O as OnchainNetwork, a as OnchainHtlc, b as OnchainHtlcParams } from './rfq-DkckzRKK.cjs';
6
- export { A as ARKADE_ASSET, c as ARKADE_BTC, d as AddressMismatch, C as ChainSource, e as ChainUtxo, H as HtlcUtxo, I as InvoiceFacts, L as LIGHTNING_BTC, f as LIGHTNING_RECEIVE_PAIR, g as LIGHTNING_SEND_PAIR, h as LOCKTIME_THRESHOLD, i as LightningReceiveTreeParams, j as LightningSendTreeParams, M as MAX_MIN_CONFIRMATIONS, k as MIN_CLAIM_WINDOW_SECONDS, l as MIN_HEADROOM_SECONDS, m as ONCHAIN_BTC, n as ONCHAIN_CLAIM_MARGIN_SECONDS, o as ONCHAIN_DUST_SATS, p as ONCHAIN_ORDER_MARGIN_SECONDS, q as ONCHAIN_RECEIVE_PAIR, r as ONCHAIN_SECONDS_PER_BLOCK, s as ONCHAIN_SEND_PAIR, t as OnchainHtlcPhase, R as RFQ_TERMINAL_STATES, u as RelaySocket, v as RfqQuote, w as RfqRefusalReason, x as RfqStatus, y as RfqTransport, S as SOLO_REFUND_HEADROOM_SECONDS, z as SwapRefusal, B as arkadeAssetLeg, D as arkadeSwapRequest, E as assertFundable, F as assertReceivable, G as awaitOnchainFill, J as buildHtlcClaim, K as buildHtlcRefund, N as claimOnchainFill, P as classifyOnchainHtlc, Q as deriveLightningReceive, T as deriveOnchainReceive, U as deriveOnchainSend, V as extractPreimage, W as httpTransport, X as lightningReceiveRequest, Y as lightningSendRequest, Z as lightningSendVtxoScript, _ as newPreimage, $ as newRfqId, a0 as offerTermsFromQuote, a1 as onchainHtlcScript, a2 as onchainReceiveRequest, a3 as onchainSendRequest, a4 as paymentHashOf, a5 as receiveVtxoScript, a6 as relayTransport, a7 as requestLightningReceive, a8 as requestLightningSend, a9 as requestOnchainReceive, aa as requestOnchainSend, ab as rfqPair, ac as unilateralClaimDelay, ad as unilateralRefundDelay, ae as unilateralRefundWithoutReceiverDelay, af as verifyLockupAddress, ag as verifyReceiveInvoice } from './rfq-DkckzRKK.cjs';
5
+ import { O as OnchainNetwork, a as OnchainHtlc, b as OnchainHtlcParams, C as ChainSource, R as RfqTransport, r as requestOnchainSend, I as InvoiceFacts, c as requestLightningSend } from './rfq-CYfKvAPp.cjs';
6
+ export { A as ARKADE_ASSET, d as ARKADE_BTC, e as AddressMismatch, f as ChainUtxo, H as HtlcUtxo, L as LIGHTNING_BTC, g as LIGHTNING_RECEIVE_PAIR, h as LIGHTNING_SEND_PAIR, i as LOCKTIME_THRESHOLD, j as LightningReceiveTreeParams, k as LightningSendTreeParams, M as MAX_MIN_CONFIRMATIONS, l as MIN_CLAIM_WINDOW_SECONDS, m as MIN_HEADROOM_SECONDS, n as ONCHAIN_BTC, o as ONCHAIN_CLAIM_MARGIN_SECONDS, p as ONCHAIN_DUST_SATS, q as ONCHAIN_ORDER_MARGIN_SECONDS, s as ONCHAIN_RECEIVE_PAIR, t as ONCHAIN_SECONDS_PER_BLOCK, u as ONCHAIN_SEND_PAIR, v as OnchainHtlcPhase, w as RFQ_TERMINAL_STATES, x as RelaySocket, y as RfqQuote, z as RfqRefusalReason, B as RfqStatus, S as SOLO_REFUND_HEADROOM_SECONDS, D as SwapRefusal, E as arkadeAssetLeg, F as arkadeSwapRequest, G as assertFundable, J as assertReceivable, K as awaitOnchainFill, N as buildHtlcClaim, P as buildHtlcRefund, Q as claimOnchainFill, T as classifyOnchainHtlc, U as deriveLightningReceive, V as deriveOnchainReceive, W as deriveOnchainSend, X as extractPreimage, Y as httpTransport, Z as l1ScriptForAddress, _ as lightningReceiveRequest, $ as lightningSendRequest, a0 as lightningSendVtxoScript, a1 as newPreimage, a2 as newRfqId, a3 as offerTermsFromQuote, a4 as onchainHtlcScript, a5 as onchainReceiveRequest, a6 as onchainSendRequest, a7 as paymentHashOf, a8 as receiveVtxoScript, a9 as relayTransport, aa as requestLightningReceive, ab as requestOnchainReceive, ac as rfqPair, ad as unilateralClaimDelay, ae as unilateralRefundDelay, af as unilateralRefundWithoutReceiverDelay, ag as verifyLockupAddress, ah as verifyReceiveInvoice } from './rfq-CYfKvAPp.cjs';
7
7
 
8
8
  /**
9
9
  * Which wallet key signs this leg. Stored at `profile.signer`.
@@ -141,6 +141,9 @@ interface OnchainSendProfile extends Record<string, unknown> {
141
141
  htlcAddress: string;
142
142
  /** `profile.min_confirmations`; gates when the fill is claimable. */
143
143
  minConfirmations: number;
144
+ /** Where the claim PAYS, hex. The spender's own choice, so nothing else
145
+ * gives it back — and `buildHtlcClaim` needs it. */
146
+ payoutPkScript: string;
144
147
  /** The fill's outpoint, learned on first sighting. Without it a SPENT htlc
145
148
  * reads as never funded — see `classifyOnchainHtlc`. */
146
149
  funding?: {
@@ -180,6 +183,7 @@ declare function onchainSendProfile(result: {
180
183
  htlcParams: OnchainHtlcParams;
181
184
  l1Network: OnchainNetwork;
182
185
  minConfirmations: number;
186
+ payoutPkScript: Uint8Array;
183
187
  }): Omit<OnchainSendProfile, "signer" | "hashlock">;
184
188
 
185
189
  /**
@@ -667,6 +671,165 @@ type OfferContractRetirer = Pick<IContractManager, "setContractWatchState">;
667
671
  */
668
672
  declare function retireSettledOfferContracts(manager: OfferContractRetirer, swaps: AssetSwap[]): Promise<void>;
669
673
 
674
+ /** `network` is `requestOnchainSend`'s `l1Network`, and only decodes scripts to
675
+ * addresses — the provider decides which chain is read, so mismatching the two
676
+ * yields addresses it knows nothing about rather than an error. */
677
+ declare const chainSourceFrom: (provider: OnchainProvider, network: OnchainNetwork) => ChainSource;
678
+
679
+ /**
680
+ * Choosing which solver to negotiate with. Both send corridors pick a card the
681
+ * same way and differ only in the payout-side corridor they look for.
682
+ */
683
+
684
+ /** Where to reach a solver. Bounds are indicative — the quote binds.
685
+ *
686
+ * No `emulatorPubkey`: the card's key only FILTERS here — the covenant is
687
+ * built from `deps.emulatorPubkey` or the pinned default, never from it. */
688
+ interface SolverRendezvous {
689
+ solverPubkey: string;
690
+ transports: {
691
+ nostr: {
692
+ relays: string[];
693
+ };
694
+ };
695
+ minSats: number;
696
+ maxSats: number;
697
+ }
698
+ /** The size check is not a courtesy: quoting outside a card's advertised range
699
+ * burns a negotiation, tells a third party what the user is about to do, and
700
+ * is refused anyway. A card that serves the corridor but not the size is
701
+ * skipped, not fatal — another may take it. */
702
+ declare const solverRendezvous: (markets: DiscoveredMarket[], payoutCorridor: "onchain" | "lightning", amountSats: number, fallbackEmulatorPubkey?: Uint8Array) => SolverRendezvous | undefined;
703
+
704
+ /**
705
+ * `solver-onchain` — pay an L1 address out of an Arkade balance through a
706
+ * solver. Registered by the app: the SDK does not depend on this package, and
707
+ * `RouterContext.swaps` is boltz-swap's. Every refusal is `available()`
708
+ * returning false, so the router drops the rail and the collaborative exit
709
+ * `onchain` wins by ranking.
710
+ */
711
+
712
+ declare const SOLVER_ONCHAIN_RAIL = "solver-onchain";
713
+ /** What a record needs. Pass the whole object to `onchainSendProfile()`: only
714
+ * this carries `payoutPkScript`. */
715
+ type SolverOnchainSend = Awaited<ReturnType<typeof requestOnchainSend>> & {
716
+ rendezvous: SolverRendezvous;
717
+ /** Where the claim pays. Named nowhere else — the claim's output is the
718
+ * spender's choice. `onchainSendProfile()` hex-encodes it; a store fed
719
+ * these bytes raw returns an object with no `.length`. */
720
+ payoutPkScript: Uint8Array;
721
+ };
722
+ interface SolverOnchainRailDeps {
723
+ arkServerUrl: string;
724
+ l1Network: OnchainNetwork;
725
+ /** x-only L1 key that AUTHORISES the claim — not where it pays. */
726
+ payoutPubkey: Uint8Array;
727
+ /** Called by `available()` and again by `quote()` — pass the caching
728
+ * `discoverMarkets`, not a bare registry fetch. */
729
+ discover(): Promise<DiscoveredMarket[]>;
730
+ connect<T>(rendezvous: SolverRendezvous, fn: (transport: RfqTransport) => Promise<T>): Promise<T>;
731
+ /** Runs BEFORE funding, and a rejection cancels the send: a funded lockup
732
+ * with no record cannot be refunded. */
733
+ persist(swap: SolverOnchainSend): Promise<void>;
734
+ /** Resolve once the L1 fill is claimed. Optional: without it the handle
735
+ * stops at `"sent"`. `RfqSwapManager` drives the swap either way. */
736
+ awaitSettlement?(swap: SolverOnchainSend): Promise<{
737
+ txid: string;
738
+ }>;
739
+ emulatorPubkey?: string;
740
+ fallbackEmulatorPubkey?: Uint8Array;
741
+ }
742
+ declare const solverOnchainRendezvous: (markets: DiscoveredMarket[], amountSats: number, fallbackEmulatorPubkey?: Uint8Array) => SolverRendezvous | undefined;
743
+ /** Register alongside the core `onchain` rail, ranked first:
744
+ * `priority: ["ark", "solver-onchain", "onchain"]`. Both stay registered. */
745
+ declare function solverOnchainRail(deps: SolverOnchainRailDeps): PaymentRail;
746
+
747
+ /**
748
+ * `solver-lightning` — the sibling of `solver-onchain` on the BOLT11 corridor.
749
+ * Boltz's `lightning` rail matches the same invoices and both stay registered.
750
+ * The invoice fixes the amount, so a `req.amount` that disagrees is refused
751
+ * rather than ignored; `decodeInvoice` is injected because this package
752
+ * carries no bolt11 dependency.
753
+ */
754
+
755
+ declare const SOLVER_LIGHTNING_RAIL = "solver-lightning";
756
+ type SolverLightningSend = Awaited<ReturnType<typeof requestLightningSend>> & {
757
+ invoice: InvoiceFacts;
758
+ rendezvous: SolverRendezvous;
759
+ };
760
+ /** Mirrors {@link SolverOnchainRailDeps}; see there for the shared seams. */
761
+ interface SolverLightningRailDeps {
762
+ arkServerUrl: string;
763
+ /** A decoder that throws drops the rail rather than taking the router
764
+ * down — correct, since an undecodable invoice cannot be paid. */
765
+ decodeInvoice(bolt11: string): InvoiceFacts;
766
+ discover(): Promise<DiscoveredMarket[]>;
767
+ connect<T>(rendezvous: SolverRendezvous, fn: (transport: RfqTransport) => Promise<T>): Promise<T>;
768
+ persist(swap: SolverLightningSend): Promise<void>;
769
+ /** Optional; without it the handle stops at `"sent"`. */
770
+ awaitSettlement?(swap: SolverLightningSend): Promise<{
771
+ preimage?: string;
772
+ }>;
773
+ emulatorPubkey?: string;
774
+ fallbackEmulatorPubkey?: Uint8Array;
775
+ }
776
+ declare const solverLightningRendezvous: (markets: DiscoveredMarket[], amountSats: number, fallbackEmulatorPubkey?: Uint8Array) => SolverRendezvous | undefined;
777
+ declare function solverLightningRail(deps: SolverLightningRailDeps): PaymentRail;
778
+
779
+ /**
780
+ * `cross-asset` — pay an asset the wallet does not hold, by swapping into it
781
+ * first. Both legs are quotable up front, so they price into one `RouteQuote`
782
+ * and the router needs no multi-hop primitive.
783
+ *
784
+ * BTC -> asset only: `createOffer` refuses anything but BTC<->asset, and
785
+ * keying `findMarket` on BTC is what enforces that.
786
+ */
787
+
788
+ declare const CROSS_ASSET_RAIL = "cross-asset";
789
+ /**
790
+ * Recovery branches on this. `filled` means the payout is NOT yet broadcast;
791
+ * `paying` means it WAS and the outcome is unknown — resolve that against
792
+ * chain state, never by resending. Persisting only afterwards would leave a
793
+ * crash between send and persist looking exactly like `filled`.
794
+ */
795
+ type CrossAssetPhase = "quoted" | "filled" | "paying" | "settled";
796
+ interface CrossAssetSwap {
797
+ phase: CrossAssetPhase;
798
+ offerHex: string;
799
+ address: string;
800
+ swapPkScript: Uint8Array;
801
+ depositSats: number;
802
+ asset: Asset;
803
+ payTo: string;
804
+ plan: OfferPlan;
805
+ /** The payout, once `settled` — the receipt a `paying` record looks for. */
806
+ txid?: string;
807
+ }
808
+ interface CrossAssetRailDeps {
809
+ arkServerUrl: string;
810
+ /** Called by `available()` and again by `quote()`; pass the caching
811
+ * `discoverMarkets`, not a bare registry fetch. */
812
+ discover(): Promise<DiscoveredMarket[]>;
813
+ quote(market: DiscoveredMarket, give: Side, wantAmount: bigint): Promise<OfferPlan>;
814
+ btcBalance(): Promise<bigint>;
815
+ dust(): Promise<bigint>;
816
+ /** Before every irreversible step and once after the last. See
817
+ * {@link CrossAssetPhase}. Keyed by `offerHex`. */
818
+ persist(swap: CrossAssetSwap): Promise<void>;
819
+ /** Resolve once a filler has delivered the asset to this wallet.
820
+ *
821
+ * OPEN QUESTION for review: is an injected promise the right seam, or
822
+ * should the rail take a `watchOfferSwaps` handle? No deadline is applied
823
+ * here, and resolving on a timeout rather than rejecting would make the
824
+ * rail pay from whatever the wallet then holds. */
825
+ awaitFill(swap: CrossAssetSwap): Promise<void>;
826
+ carrierSats?: number;
827
+ emulatorPubkey?: string;
828
+ }
829
+ /** Rank after `ark-asset`, which pays from a balance already held. Both match,
830
+ * so `options()` can offer "pay from your USDX" beside "buy USDX and pay". */
831
+ declare function crossAssetRail(deps: CrossAssetRailDeps): PaymentRail;
832
+
670
833
  interface SealedClaimPacket {
671
834
  /** `ephPub(33) ‖ nonce(12) ‖ ciphertext`, base64 — wire-ready. This is
672
835
  * the whole packet: the RFQ request's `claim_packet` field carries
@@ -690,6 +853,77 @@ interface ClaimPacketInput {
690
853
  */
691
854
  declare function sealClaimPacket(input: ClaimPacketInput): Promise<SealedClaimPacket>;
692
855
 
856
+ /**
857
+ * `retryable` is the point of the type: a 400 says the packet does not bind to
858
+ * this address at this daemon — wrong key, script or taptree — and retrying
859
+ * changes none of them. Only a full registry (429) and a transport fault (5xx,
860
+ * or `status` 0 for a throwing `fetch`) are worth trying again.
861
+ */
862
+ declare class CovclaimdRevealError extends Error {
863
+ readonly name = "CovclaimdRevealError";
864
+ readonly status: number;
865
+ readonly detail: string;
866
+ readonly retryable: boolean;
867
+ constructor(what: string, status: number, detail: string);
868
+ }
869
+ interface CovclaimdInfo {
870
+ /** 33-byte compressed — feeds {@link sealClaimPacket} unchanged. */
871
+ covclaimdPubkey: Uint8Array;
872
+ /** Compressed hex — feeds `requestLightningReceive`'s `emulatorPubkey`. */
873
+ emulatorPubkey: string;
874
+ }
875
+ /** The four fields `POST /v1/reveal` takes. */
876
+ interface RevealParams {
877
+ /** The funded lockup's Arkade address, bech32m. */
878
+ swapAddress: string;
879
+ /** `sealClaimPacket(...).ciphertext`, base64. */
880
+ ciphertext: string;
881
+ /** The covenant's `enforcePayTo` ArkadeScript, base64. */
882
+ arkadeScript: string;
883
+ /** The lockup's serialized taptree, hex. */
884
+ taptree: string;
885
+ }
886
+ interface CovclaimdClient {
887
+ info(): Promise<CovclaimdInfo>;
888
+ reveal(params: RevealParams): Promise<void>;
889
+ }
890
+ /** `fetchImpl` is injectable, matching `httpTransport` in `rfq.ts`. */
891
+ declare const covclaimdClient: (baseUrl: string, options?: {
892
+ fetchImpl?: typeof fetch;
893
+ timeoutMs?: number;
894
+ /** Opt out of the TLS requirement — a private network you trust. */
895
+ allowInsecureHttp?: boolean;
896
+ }) => CovclaimdClient;
897
+ /**
898
+ * The two wire fields that are functions of the covenant alone.
899
+ *
900
+ * A client-derived `arkadeScript` can differ from the funder's only if the
901
+ * covenants differ: the script is tweaked into the non-interactive claim leaf's
902
+ * co-signer key, so a different one is a different leaf, root, and lockup
903
+ * address — already covered by the address check made before funding.
904
+ */
905
+ declare function revealFieldsFromScript(script: InstanceType<typeof VHTLC.ScriptV2>): {
906
+ arkadeScript: string;
907
+ taptree: string;
908
+ };
909
+ /**
910
+ * Seal `P` to the daemon `client` speaks to and register it there, so covclaimd
911
+ * claims the lockup once the solver funds it and the trader can go offline.
912
+ *
913
+ * Registration EXPIRES — covclaimd drops it 15 minutes after the last reveal —
914
+ * and re-revealing refreshes rather than duplicates it, so a caller waiting on
915
+ * a slow funding should reveal again, not once. The two gates below name a
916
+ * cause covclaimd would otherwise report as an opaque 400.
917
+ */
918
+ declare function revealClaimPacket(client: CovclaimdClient, input: {
919
+ script: InstanceType<typeof VHTLC.ScriptV2>;
920
+ address: string;
921
+ /** `P`, 32 bytes, from the swap's `secrets`. */
922
+ preimage: Uint8Array;
923
+ }): Promise<{
924
+ ciphertext: string;
925
+ }>;
926
+
693
927
  /** The Ark surface the claim push needs — the same seam the refund push uses. */
694
928
  type ClaimArkProvider = RefundArkProvider;
695
929
  /**
@@ -1024,4 +1258,4 @@ interface RfqSwapActivityDeps {
1024
1258
  */
1025
1259
  declare function rfqSwapActivityInputs(deps: RfqSwapActivityDeps): Promise<SwapActivityInput[]>;
1026
1260
 
1027
- export { ArkadeRefundResult, type ArkadeRefunderDeps, AssetSwap, AssetSwapRepository, type ClaimArkProvider, type ClaimPacketInput, type DiscoverMarketsOptions, IndexedDbAssetSwapRepository, type LightningReceiveProfile, type LightningSendProfile, LockupAmountMismatchError, LockupContractMissing, type LockupContractReader, type LockupContractWriter, LockupRegistrationFailed, LockupSpendIndexer, LockupVtxo, MarketsCacheEntry, OFFER_PACKET_TYPE, type Offer, type OfferContractRetirer, type OfferSwapWatcher, OnchainHtlc, OnchainHtlcParams, OnchainNetwork, type OnchainSendProfile, type PlanError, QUOTE_OPTIONS, RefundArkProvider, type RefundBlockedReason, RefundIndexer, RefundNotLocallyPossibleError, type RestoreIndexer, type RfqClaimSecretProjection, type RfqHashlockProjection, type RfqSignerProjection, RfqSwap, type RfqSwapActivityDeps, RfqSwapRecord, RfqSwapState, SWAP_LOCKUP_CONTRACT_KIND, SWAP_LOCKUP_CONTRACT_LABEL, SWAP_LOCKUP_CONTRACT_TYPE, type SealedClaimPacket, type SpendKind, type SwapActivityInput, SwapSecretsProjection, type Tx, type WatchOfferSwapsParams, arkadeRefunder, awaitLockupFunding, cancelOffer, claimReceiveLockup, classifyDepositSpend, classifySpend, createOffer, decodeOffer, discoverMarkets, encodeOffer, findMarket, lockupContractParams, makeCachedFeedFetch, offerVtxoScript, onchainSendProfile, pushClaim, registerLockupContract, restoreAssetSwaps, retireSettledOfferContracts, rfqClaimSecretOf, rfqSecretsProfile, rfqSignerOf, rfqSwapActivityInputs, sealClaimPacket, senderIdentityForSwapRecord, spendTxidsOf, spendUpdate, swapActivityResolver, swapPrograms, validatePlan, watchOfferSwaps };
1261
+ export { ArkadeRefundResult, type ArkadeRefunderDeps, AssetSwap, AssetSwapRepository, CROSS_ASSET_RAIL, ChainSource, type ClaimArkProvider, type ClaimPacketInput, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, type CrossAssetPhase, type CrossAssetRailDeps, type CrossAssetSwap, type DiscoverMarketsOptions, IndexedDbAssetSwapRepository, InvoiceFacts, type LightningReceiveProfile, type LightningSendProfile, LockupAmountMismatchError, LockupContractMissing, type LockupContractReader, type LockupContractWriter, LockupRegistrationFailed, LockupSpendIndexer, LockupVtxo, MarketsCacheEntry, OFFER_PACKET_TYPE, type Offer, type OfferContractRetirer, type OfferSwapWatcher, OnchainHtlc, OnchainHtlcParams, OnchainNetwork, type OnchainSendProfile, type PlanError, QUOTE_OPTIONS, RefundArkProvider, type RefundBlockedReason, RefundIndexer, RefundNotLocallyPossibleError, type RestoreIndexer, type RevealParams, type RfqClaimSecretProjection, type RfqHashlockProjection, type RfqSignerProjection, RfqSwap, type RfqSwapActivityDeps, RfqSwapRecord, RfqSwapState, RfqTransport, SOLVER_LIGHTNING_RAIL, SOLVER_ONCHAIN_RAIL, SWAP_LOCKUP_CONTRACT_KIND, SWAP_LOCKUP_CONTRACT_LABEL, SWAP_LOCKUP_CONTRACT_TYPE, type SealedClaimPacket, type SolverLightningRailDeps, type SolverLightningSend, type SolverOnchainRailDeps, type SolverOnchainSend, type SolverRendezvous, type SpendKind, type SwapActivityInput, SwapSecretsProjection, type Tx, type WatchOfferSwapsParams, arkadeRefunder, awaitLockupFunding, cancelOffer, chainSourceFrom, claimReceiveLockup, classifyDepositSpend, classifySpend, covclaimdClient, createOffer, crossAssetRail, decodeOffer, discoverMarkets, encodeOffer, findMarket, lockupContractParams, makeCachedFeedFetch, offerVtxoScript, onchainSendProfile, pushClaim, registerLockupContract, requestLightningSend, requestOnchainSend, restoreAssetSwaps, retireSettledOfferContracts, revealClaimPacket, revealFieldsFromScript, rfqClaimSecretOf, rfqSecretsProfile, rfqSignerOf, rfqSwapActivityInputs, sealClaimPacket, senderIdentityForSwapRecord, solverLightningRail, solverLightningRendezvous, solverOnchainRail, solverOnchainRendezvous, solverRendezvous, spendTxidsOf, spendUpdate, swapActivityResolver, swapPrograms, validatePlan, watchOfferSwaps };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { ProvisionedKey, ProvisionedClaimSecret, asset, RelativeTimelock, IWallet, arkade, RestIndexerProvider, Transaction, IContractManager, VHTLC, Identity, ActivityResolver } from '@arkade-os/sdk';
2
- import { S as SwapSecretsProjection, R as RfqSwapRecord, A as AssetSwapRepository, a as AssetSwap, M as MarketsCacheEntry, b as RefundArkProvider, c as RefundIndexer, L as LockupVtxo, d as RfqSwap, e as ArkadeRefundResult, f as LockupSpendIndexer, g as RfqSwapState } from './repository-CfE18Fif.js';
3
- export { h as AssetSwapStatus, i as AvailableRfqSwapManagerCallbacks, B as BTC_ASSET_ID, I as InMemoryAssetSwapRepository, j as LightningReceiveSwap, k as LightningSendSwap, l as LockupFate, m as LockupNeedsRecoveryError, n as LockupParams, o as LockupSpend, O as OnchainSendAction, p as OnchainSendSwap, P as PersistableRfqSwap, q as PreimageBlockedReason, r as PreimageNotRecoverableError, s as REFUND_MTP_LAG_SECONDS, t as RFQ_RESOLVED_STATES, u as RFQ_SWAP_RETENTION_SECONDS, v as RFQ_SWAP_TERMINAL_STATES, w as RefundOutcome, x as RfqRestoreFailure, y as RfqRestoreOptions, z as RfqRestoreResult, C as RfqSwapActionName, D as RfqSwapLockup, E as RfqSwapManager, F as RfqSwapManagerCallbacks, G as RfqSwapManagerConfig, H as RfqSwapManagerDeps, J as RfqSwapManagerEvents, K as RfqSwapOrigin, N as RfqSwapOriginRequired, Q as RfqSwapOutcome, T as RfqSwapRecordStore, U as SwapContractRegistry, V as addAssetSwap, W as awaitRfqResolution, X as createRfqSwapRecord, Y as findLockupVtxos, Z as getAssetSwaps, _ as getAssetSwapsOrThrow, $ as isRfqSwapTerminal, a0 as isRfqTerminal, a1 as nextOnchainAction, a2 as preimageForSwapRecord, a3 as pushRefundWithoutReceiver, a4 as readLockupFate, a5 as rebuildRfqSwap, a6 as refundIfUnresolved, a7 as rfqSwapOriginOf, a8 as shouldRetainRfqSwap, a9 as swapSecretsToRecord, aa as updateAssetSwap, ab as updateAssetSwapBestEffort, ac as updateRfqSwapRecord } from './repository-CfE18Fif.js';
1
+ import { ProvisionedKey, ProvisionedClaimSecret, asset, RelativeTimelock, IWallet, arkade, RestIndexerProvider, Transaction, IContractManager, OnchainProvider, PaymentRail, Asset, VHTLC, Identity, ActivityResolver } from '@arkade-os/sdk';
2
+ import { S as SwapSecretsProjection, R as RfqSwapRecord, A as AssetSwapRepository, a as AssetSwap, M as MarketsCacheEntry, b as RefundArkProvider, c as RefundIndexer, L as LockupVtxo, d as RfqSwap, e as ArkadeRefundResult, f as LockupSpendIndexer, g as RfqSwapState } from './repository-D5JoeqwB.js';
3
+ export { h as AssetSwapStatus, i as AvailableRfqSwapManagerCallbacks, B as BTC_ASSET_ID, I as InMemoryAssetSwapRepository, j as LightningReceiveSwap, k as LightningSendSwap, l as LockupFate, m as LockupNeedsRecoveryError, n as LockupParams, o as LockupSpend, O as OnchainSendAction, p as OnchainSendSwap, P as PersistableRfqSwap, q as PreimageBlockedReason, r as PreimageNotRecoverableError, s as REFUND_MTP_LAG_SECONDS, t as RFQ_RESOLVED_STATES, u as RFQ_SWAP_RETENTION_SECONDS, v as RFQ_SWAP_TERMINAL_STATES, w as RefundOutcome, x as RfqRestoreFailure, y as RfqRestoreOptions, z as RfqRestoreResult, C as RfqSwapActionName, D as RfqSwapLockup, E as RfqSwapManager, F as RfqSwapManagerCallbacks, G as RfqSwapManagerConfig, H as RfqSwapManagerDeps, J as RfqSwapManagerEvents, K as RfqSwapOrigin, N as RfqSwapOriginRequired, Q as RfqSwapOutcome, T as RfqSwapRecordStore, U as SwapContractRegistry, V as addAssetSwap, W as awaitRfqResolution, X as createRfqSwapRecord, Y as findLockupVtxos, Z as getAssetSwaps, _ as getAssetSwapsOrThrow, $ as isRfqSwapTerminal, a0 as isRfqTerminal, a1 as nextOnchainAction, a2 as preimageForSwapRecord, a3 as pushRefundWithoutReceiver, a4 as readLockupFate, a5 as rebuildRfqSwap, a6 as refundIfUnresolved, a7 as rfqSwapOriginOf, a8 as shouldRetainRfqSwap, a9 as swapSecretsToRecord, aa as updateAssetSwap, ab as updateAssetSwapBestEffort, ac as updateRfqSwapRecord } from './repository-D5JoeqwB.js';
4
4
  import { Network, LocalCardInput, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
5
- import { O as OnchainNetwork, a as OnchainHtlc, b as OnchainHtlcParams } from './rfq-DkckzRKK.js';
6
- export { A as ARKADE_ASSET, c as ARKADE_BTC, d as AddressMismatch, C as ChainSource, e as ChainUtxo, H as HtlcUtxo, I as InvoiceFacts, L as LIGHTNING_BTC, f as LIGHTNING_RECEIVE_PAIR, g as LIGHTNING_SEND_PAIR, h as LOCKTIME_THRESHOLD, i as LightningReceiveTreeParams, j as LightningSendTreeParams, M as MAX_MIN_CONFIRMATIONS, k as MIN_CLAIM_WINDOW_SECONDS, l as MIN_HEADROOM_SECONDS, m as ONCHAIN_BTC, n as ONCHAIN_CLAIM_MARGIN_SECONDS, o as ONCHAIN_DUST_SATS, p as ONCHAIN_ORDER_MARGIN_SECONDS, q as ONCHAIN_RECEIVE_PAIR, r as ONCHAIN_SECONDS_PER_BLOCK, s as ONCHAIN_SEND_PAIR, t as OnchainHtlcPhase, R as RFQ_TERMINAL_STATES, u as RelaySocket, v as RfqQuote, w as RfqRefusalReason, x as RfqStatus, y as RfqTransport, S as SOLO_REFUND_HEADROOM_SECONDS, z as SwapRefusal, B as arkadeAssetLeg, D as arkadeSwapRequest, E as assertFundable, F as assertReceivable, G as awaitOnchainFill, J as buildHtlcClaim, K as buildHtlcRefund, N as claimOnchainFill, P as classifyOnchainHtlc, Q as deriveLightningReceive, T as deriveOnchainReceive, U as deriveOnchainSend, V as extractPreimage, W as httpTransport, X as lightningReceiveRequest, Y as lightningSendRequest, Z as lightningSendVtxoScript, _ as newPreimage, $ as newRfqId, a0 as offerTermsFromQuote, a1 as onchainHtlcScript, a2 as onchainReceiveRequest, a3 as onchainSendRequest, a4 as paymentHashOf, a5 as receiveVtxoScript, a6 as relayTransport, a7 as requestLightningReceive, a8 as requestLightningSend, a9 as requestOnchainReceive, aa as requestOnchainSend, ab as rfqPair, ac as unilateralClaimDelay, ad as unilateralRefundDelay, ae as unilateralRefundWithoutReceiverDelay, af as verifyLockupAddress, ag as verifyReceiveInvoice } from './rfq-DkckzRKK.js';
5
+ import { O as OnchainNetwork, a as OnchainHtlc, b as OnchainHtlcParams, C as ChainSource, R as RfqTransport, r as requestOnchainSend, I as InvoiceFacts, c as requestLightningSend } from './rfq-CYfKvAPp.js';
6
+ export { A as ARKADE_ASSET, d as ARKADE_BTC, e as AddressMismatch, f as ChainUtxo, H as HtlcUtxo, L as LIGHTNING_BTC, g as LIGHTNING_RECEIVE_PAIR, h as LIGHTNING_SEND_PAIR, i as LOCKTIME_THRESHOLD, j as LightningReceiveTreeParams, k as LightningSendTreeParams, M as MAX_MIN_CONFIRMATIONS, l as MIN_CLAIM_WINDOW_SECONDS, m as MIN_HEADROOM_SECONDS, n as ONCHAIN_BTC, o as ONCHAIN_CLAIM_MARGIN_SECONDS, p as ONCHAIN_DUST_SATS, q as ONCHAIN_ORDER_MARGIN_SECONDS, s as ONCHAIN_RECEIVE_PAIR, t as ONCHAIN_SECONDS_PER_BLOCK, u as ONCHAIN_SEND_PAIR, v as OnchainHtlcPhase, w as RFQ_TERMINAL_STATES, x as RelaySocket, y as RfqQuote, z as RfqRefusalReason, B as RfqStatus, S as SOLO_REFUND_HEADROOM_SECONDS, D as SwapRefusal, E as arkadeAssetLeg, F as arkadeSwapRequest, G as assertFundable, J as assertReceivable, K as awaitOnchainFill, N as buildHtlcClaim, P as buildHtlcRefund, Q as claimOnchainFill, T as classifyOnchainHtlc, U as deriveLightningReceive, V as deriveOnchainReceive, W as deriveOnchainSend, X as extractPreimage, Y as httpTransport, Z as l1ScriptForAddress, _ as lightningReceiveRequest, $ as lightningSendRequest, a0 as lightningSendVtxoScript, a1 as newPreimage, a2 as newRfqId, a3 as offerTermsFromQuote, a4 as onchainHtlcScript, a5 as onchainReceiveRequest, a6 as onchainSendRequest, a7 as paymentHashOf, a8 as receiveVtxoScript, a9 as relayTransport, aa as requestLightningReceive, ab as requestOnchainReceive, ac as rfqPair, ad as unilateralClaimDelay, ae as unilateralRefundDelay, af as unilateralRefundWithoutReceiverDelay, ag as verifyLockupAddress, ah as verifyReceiveInvoice } from './rfq-CYfKvAPp.js';
7
7
 
8
8
  /**
9
9
  * Which wallet key signs this leg. Stored at `profile.signer`.
@@ -141,6 +141,9 @@ interface OnchainSendProfile extends Record<string, unknown> {
141
141
  htlcAddress: string;
142
142
  /** `profile.min_confirmations`; gates when the fill is claimable. */
143
143
  minConfirmations: number;
144
+ /** Where the claim PAYS, hex. The spender's own choice, so nothing else
145
+ * gives it back — and `buildHtlcClaim` needs it. */
146
+ payoutPkScript: string;
144
147
  /** The fill's outpoint, learned on first sighting. Without it a SPENT htlc
145
148
  * reads as never funded — see `classifyOnchainHtlc`. */
146
149
  funding?: {
@@ -180,6 +183,7 @@ declare function onchainSendProfile(result: {
180
183
  htlcParams: OnchainHtlcParams;
181
184
  l1Network: OnchainNetwork;
182
185
  minConfirmations: number;
186
+ payoutPkScript: Uint8Array;
183
187
  }): Omit<OnchainSendProfile, "signer" | "hashlock">;
184
188
 
185
189
  /**
@@ -667,6 +671,165 @@ type OfferContractRetirer = Pick<IContractManager, "setContractWatchState">;
667
671
  */
668
672
  declare function retireSettledOfferContracts(manager: OfferContractRetirer, swaps: AssetSwap[]): Promise<void>;
669
673
 
674
+ /** `network` is `requestOnchainSend`'s `l1Network`, and only decodes scripts to
675
+ * addresses — the provider decides which chain is read, so mismatching the two
676
+ * yields addresses it knows nothing about rather than an error. */
677
+ declare const chainSourceFrom: (provider: OnchainProvider, network: OnchainNetwork) => ChainSource;
678
+
679
+ /**
680
+ * Choosing which solver to negotiate with. Both send corridors pick a card the
681
+ * same way and differ only in the payout-side corridor they look for.
682
+ */
683
+
684
+ /** Where to reach a solver. Bounds are indicative — the quote binds.
685
+ *
686
+ * No `emulatorPubkey`: the card's key only FILTERS here — the covenant is
687
+ * built from `deps.emulatorPubkey` or the pinned default, never from it. */
688
+ interface SolverRendezvous {
689
+ solverPubkey: string;
690
+ transports: {
691
+ nostr: {
692
+ relays: string[];
693
+ };
694
+ };
695
+ minSats: number;
696
+ maxSats: number;
697
+ }
698
+ /** The size check is not a courtesy: quoting outside a card's advertised range
699
+ * burns a negotiation, tells a third party what the user is about to do, and
700
+ * is refused anyway. A card that serves the corridor but not the size is
701
+ * skipped, not fatal — another may take it. */
702
+ declare const solverRendezvous: (markets: DiscoveredMarket[], payoutCorridor: "onchain" | "lightning", amountSats: number, fallbackEmulatorPubkey?: Uint8Array) => SolverRendezvous | undefined;
703
+
704
+ /**
705
+ * `solver-onchain` — pay an L1 address out of an Arkade balance through a
706
+ * solver. Registered by the app: the SDK does not depend on this package, and
707
+ * `RouterContext.swaps` is boltz-swap's. Every refusal is `available()`
708
+ * returning false, so the router drops the rail and the collaborative exit
709
+ * `onchain` wins by ranking.
710
+ */
711
+
712
+ declare const SOLVER_ONCHAIN_RAIL = "solver-onchain";
713
+ /** What a record needs. Pass the whole object to `onchainSendProfile()`: only
714
+ * this carries `payoutPkScript`. */
715
+ type SolverOnchainSend = Awaited<ReturnType<typeof requestOnchainSend>> & {
716
+ rendezvous: SolverRendezvous;
717
+ /** Where the claim pays. Named nowhere else — the claim's output is the
718
+ * spender's choice. `onchainSendProfile()` hex-encodes it; a store fed
719
+ * these bytes raw returns an object with no `.length`. */
720
+ payoutPkScript: Uint8Array;
721
+ };
722
+ interface SolverOnchainRailDeps {
723
+ arkServerUrl: string;
724
+ l1Network: OnchainNetwork;
725
+ /** x-only L1 key that AUTHORISES the claim — not where it pays. */
726
+ payoutPubkey: Uint8Array;
727
+ /** Called by `available()` and again by `quote()` — pass the caching
728
+ * `discoverMarkets`, not a bare registry fetch. */
729
+ discover(): Promise<DiscoveredMarket[]>;
730
+ connect<T>(rendezvous: SolverRendezvous, fn: (transport: RfqTransport) => Promise<T>): Promise<T>;
731
+ /** Runs BEFORE funding, and a rejection cancels the send: a funded lockup
732
+ * with no record cannot be refunded. */
733
+ persist(swap: SolverOnchainSend): Promise<void>;
734
+ /** Resolve once the L1 fill is claimed. Optional: without it the handle
735
+ * stops at `"sent"`. `RfqSwapManager` drives the swap either way. */
736
+ awaitSettlement?(swap: SolverOnchainSend): Promise<{
737
+ txid: string;
738
+ }>;
739
+ emulatorPubkey?: string;
740
+ fallbackEmulatorPubkey?: Uint8Array;
741
+ }
742
+ declare const solverOnchainRendezvous: (markets: DiscoveredMarket[], amountSats: number, fallbackEmulatorPubkey?: Uint8Array) => SolverRendezvous | undefined;
743
+ /** Register alongside the core `onchain` rail, ranked first:
744
+ * `priority: ["ark", "solver-onchain", "onchain"]`. Both stay registered. */
745
+ declare function solverOnchainRail(deps: SolverOnchainRailDeps): PaymentRail;
746
+
747
+ /**
748
+ * `solver-lightning` — the sibling of `solver-onchain` on the BOLT11 corridor.
749
+ * Boltz's `lightning` rail matches the same invoices and both stay registered.
750
+ * The invoice fixes the amount, so a `req.amount` that disagrees is refused
751
+ * rather than ignored; `decodeInvoice` is injected because this package
752
+ * carries no bolt11 dependency.
753
+ */
754
+
755
+ declare const SOLVER_LIGHTNING_RAIL = "solver-lightning";
756
+ type SolverLightningSend = Awaited<ReturnType<typeof requestLightningSend>> & {
757
+ invoice: InvoiceFacts;
758
+ rendezvous: SolverRendezvous;
759
+ };
760
+ /** Mirrors {@link SolverOnchainRailDeps}; see there for the shared seams. */
761
+ interface SolverLightningRailDeps {
762
+ arkServerUrl: string;
763
+ /** A decoder that throws drops the rail rather than taking the router
764
+ * down — correct, since an undecodable invoice cannot be paid. */
765
+ decodeInvoice(bolt11: string): InvoiceFacts;
766
+ discover(): Promise<DiscoveredMarket[]>;
767
+ connect<T>(rendezvous: SolverRendezvous, fn: (transport: RfqTransport) => Promise<T>): Promise<T>;
768
+ persist(swap: SolverLightningSend): Promise<void>;
769
+ /** Optional; without it the handle stops at `"sent"`. */
770
+ awaitSettlement?(swap: SolverLightningSend): Promise<{
771
+ preimage?: string;
772
+ }>;
773
+ emulatorPubkey?: string;
774
+ fallbackEmulatorPubkey?: Uint8Array;
775
+ }
776
+ declare const solverLightningRendezvous: (markets: DiscoveredMarket[], amountSats: number, fallbackEmulatorPubkey?: Uint8Array) => SolverRendezvous | undefined;
777
+ declare function solverLightningRail(deps: SolverLightningRailDeps): PaymentRail;
778
+
779
+ /**
780
+ * `cross-asset` — pay an asset the wallet does not hold, by swapping into it
781
+ * first. Both legs are quotable up front, so they price into one `RouteQuote`
782
+ * and the router needs no multi-hop primitive.
783
+ *
784
+ * BTC -> asset only: `createOffer` refuses anything but BTC<->asset, and
785
+ * keying `findMarket` on BTC is what enforces that.
786
+ */
787
+
788
+ declare const CROSS_ASSET_RAIL = "cross-asset";
789
+ /**
790
+ * Recovery branches on this. `filled` means the payout is NOT yet broadcast;
791
+ * `paying` means it WAS and the outcome is unknown — resolve that against
792
+ * chain state, never by resending. Persisting only afterwards would leave a
793
+ * crash between send and persist looking exactly like `filled`.
794
+ */
795
+ type CrossAssetPhase = "quoted" | "filled" | "paying" | "settled";
796
+ interface CrossAssetSwap {
797
+ phase: CrossAssetPhase;
798
+ offerHex: string;
799
+ address: string;
800
+ swapPkScript: Uint8Array;
801
+ depositSats: number;
802
+ asset: Asset;
803
+ payTo: string;
804
+ plan: OfferPlan;
805
+ /** The payout, once `settled` — the receipt a `paying` record looks for. */
806
+ txid?: string;
807
+ }
808
+ interface CrossAssetRailDeps {
809
+ arkServerUrl: string;
810
+ /** Called by `available()` and again by `quote()`; pass the caching
811
+ * `discoverMarkets`, not a bare registry fetch. */
812
+ discover(): Promise<DiscoveredMarket[]>;
813
+ quote(market: DiscoveredMarket, give: Side, wantAmount: bigint): Promise<OfferPlan>;
814
+ btcBalance(): Promise<bigint>;
815
+ dust(): Promise<bigint>;
816
+ /** Before every irreversible step and once after the last. See
817
+ * {@link CrossAssetPhase}. Keyed by `offerHex`. */
818
+ persist(swap: CrossAssetSwap): Promise<void>;
819
+ /** Resolve once a filler has delivered the asset to this wallet.
820
+ *
821
+ * OPEN QUESTION for review: is an injected promise the right seam, or
822
+ * should the rail take a `watchOfferSwaps` handle? No deadline is applied
823
+ * here, and resolving on a timeout rather than rejecting would make the
824
+ * rail pay from whatever the wallet then holds. */
825
+ awaitFill(swap: CrossAssetSwap): Promise<void>;
826
+ carrierSats?: number;
827
+ emulatorPubkey?: string;
828
+ }
829
+ /** Rank after `ark-asset`, which pays from a balance already held. Both match,
830
+ * so `options()` can offer "pay from your USDX" beside "buy USDX and pay". */
831
+ declare function crossAssetRail(deps: CrossAssetRailDeps): PaymentRail;
832
+
670
833
  interface SealedClaimPacket {
671
834
  /** `ephPub(33) ‖ nonce(12) ‖ ciphertext`, base64 — wire-ready. This is
672
835
  * the whole packet: the RFQ request's `claim_packet` field carries
@@ -690,6 +853,77 @@ interface ClaimPacketInput {
690
853
  */
691
854
  declare function sealClaimPacket(input: ClaimPacketInput): Promise<SealedClaimPacket>;
692
855
 
856
+ /**
857
+ * `retryable` is the point of the type: a 400 says the packet does not bind to
858
+ * this address at this daemon — wrong key, script or taptree — and retrying
859
+ * changes none of them. Only a full registry (429) and a transport fault (5xx,
860
+ * or `status` 0 for a throwing `fetch`) are worth trying again.
861
+ */
862
+ declare class CovclaimdRevealError extends Error {
863
+ readonly name = "CovclaimdRevealError";
864
+ readonly status: number;
865
+ readonly detail: string;
866
+ readonly retryable: boolean;
867
+ constructor(what: string, status: number, detail: string);
868
+ }
869
+ interface CovclaimdInfo {
870
+ /** 33-byte compressed — feeds {@link sealClaimPacket} unchanged. */
871
+ covclaimdPubkey: Uint8Array;
872
+ /** Compressed hex — feeds `requestLightningReceive`'s `emulatorPubkey`. */
873
+ emulatorPubkey: string;
874
+ }
875
+ /** The four fields `POST /v1/reveal` takes. */
876
+ interface RevealParams {
877
+ /** The funded lockup's Arkade address, bech32m. */
878
+ swapAddress: string;
879
+ /** `sealClaimPacket(...).ciphertext`, base64. */
880
+ ciphertext: string;
881
+ /** The covenant's `enforcePayTo` ArkadeScript, base64. */
882
+ arkadeScript: string;
883
+ /** The lockup's serialized taptree, hex. */
884
+ taptree: string;
885
+ }
886
+ interface CovclaimdClient {
887
+ info(): Promise<CovclaimdInfo>;
888
+ reveal(params: RevealParams): Promise<void>;
889
+ }
890
+ /** `fetchImpl` is injectable, matching `httpTransport` in `rfq.ts`. */
891
+ declare const covclaimdClient: (baseUrl: string, options?: {
892
+ fetchImpl?: typeof fetch;
893
+ timeoutMs?: number;
894
+ /** Opt out of the TLS requirement — a private network you trust. */
895
+ allowInsecureHttp?: boolean;
896
+ }) => CovclaimdClient;
897
+ /**
898
+ * The two wire fields that are functions of the covenant alone.
899
+ *
900
+ * A client-derived `arkadeScript` can differ from the funder's only if the
901
+ * covenants differ: the script is tweaked into the non-interactive claim leaf's
902
+ * co-signer key, so a different one is a different leaf, root, and lockup
903
+ * address — already covered by the address check made before funding.
904
+ */
905
+ declare function revealFieldsFromScript(script: InstanceType<typeof VHTLC.ScriptV2>): {
906
+ arkadeScript: string;
907
+ taptree: string;
908
+ };
909
+ /**
910
+ * Seal `P` to the daemon `client` speaks to and register it there, so covclaimd
911
+ * claims the lockup once the solver funds it and the trader can go offline.
912
+ *
913
+ * Registration EXPIRES — covclaimd drops it 15 minutes after the last reveal —
914
+ * and re-revealing refreshes rather than duplicates it, so a caller waiting on
915
+ * a slow funding should reveal again, not once. The two gates below name a
916
+ * cause covclaimd would otherwise report as an opaque 400.
917
+ */
918
+ declare function revealClaimPacket(client: CovclaimdClient, input: {
919
+ script: InstanceType<typeof VHTLC.ScriptV2>;
920
+ address: string;
921
+ /** `P`, 32 bytes, from the swap's `secrets`. */
922
+ preimage: Uint8Array;
923
+ }): Promise<{
924
+ ciphertext: string;
925
+ }>;
926
+
693
927
  /** The Ark surface the claim push needs — the same seam the refund push uses. */
694
928
  type ClaimArkProvider = RefundArkProvider;
695
929
  /**
@@ -1024,4 +1258,4 @@ interface RfqSwapActivityDeps {
1024
1258
  */
1025
1259
  declare function rfqSwapActivityInputs(deps: RfqSwapActivityDeps): Promise<SwapActivityInput[]>;
1026
1260
 
1027
- export { ArkadeRefundResult, type ArkadeRefunderDeps, AssetSwap, AssetSwapRepository, type ClaimArkProvider, type ClaimPacketInput, type DiscoverMarketsOptions, IndexedDbAssetSwapRepository, type LightningReceiveProfile, type LightningSendProfile, LockupAmountMismatchError, LockupContractMissing, type LockupContractReader, type LockupContractWriter, LockupRegistrationFailed, LockupSpendIndexer, LockupVtxo, MarketsCacheEntry, OFFER_PACKET_TYPE, type Offer, type OfferContractRetirer, type OfferSwapWatcher, OnchainHtlc, OnchainHtlcParams, OnchainNetwork, type OnchainSendProfile, type PlanError, QUOTE_OPTIONS, RefundArkProvider, type RefundBlockedReason, RefundIndexer, RefundNotLocallyPossibleError, type RestoreIndexer, type RfqClaimSecretProjection, type RfqHashlockProjection, type RfqSignerProjection, RfqSwap, type RfqSwapActivityDeps, RfqSwapRecord, RfqSwapState, SWAP_LOCKUP_CONTRACT_KIND, SWAP_LOCKUP_CONTRACT_LABEL, SWAP_LOCKUP_CONTRACT_TYPE, type SealedClaimPacket, type SpendKind, type SwapActivityInput, SwapSecretsProjection, type Tx, type WatchOfferSwapsParams, arkadeRefunder, awaitLockupFunding, cancelOffer, claimReceiveLockup, classifyDepositSpend, classifySpend, createOffer, decodeOffer, discoverMarkets, encodeOffer, findMarket, lockupContractParams, makeCachedFeedFetch, offerVtxoScript, onchainSendProfile, pushClaim, registerLockupContract, restoreAssetSwaps, retireSettledOfferContracts, rfqClaimSecretOf, rfqSecretsProfile, rfqSignerOf, rfqSwapActivityInputs, sealClaimPacket, senderIdentityForSwapRecord, spendTxidsOf, spendUpdate, swapActivityResolver, swapPrograms, validatePlan, watchOfferSwaps };
1261
+ export { ArkadeRefundResult, type ArkadeRefunderDeps, AssetSwap, AssetSwapRepository, CROSS_ASSET_RAIL, ChainSource, type ClaimArkProvider, type ClaimPacketInput, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, type CrossAssetPhase, type CrossAssetRailDeps, type CrossAssetSwap, type DiscoverMarketsOptions, IndexedDbAssetSwapRepository, InvoiceFacts, type LightningReceiveProfile, type LightningSendProfile, LockupAmountMismatchError, LockupContractMissing, type LockupContractReader, type LockupContractWriter, LockupRegistrationFailed, LockupSpendIndexer, LockupVtxo, MarketsCacheEntry, OFFER_PACKET_TYPE, type Offer, type OfferContractRetirer, type OfferSwapWatcher, OnchainHtlc, OnchainHtlcParams, OnchainNetwork, type OnchainSendProfile, type PlanError, QUOTE_OPTIONS, RefundArkProvider, type RefundBlockedReason, RefundIndexer, RefundNotLocallyPossibleError, type RestoreIndexer, type RevealParams, type RfqClaimSecretProjection, type RfqHashlockProjection, type RfqSignerProjection, RfqSwap, type RfqSwapActivityDeps, RfqSwapRecord, RfqSwapState, RfqTransport, SOLVER_LIGHTNING_RAIL, SOLVER_ONCHAIN_RAIL, SWAP_LOCKUP_CONTRACT_KIND, SWAP_LOCKUP_CONTRACT_LABEL, SWAP_LOCKUP_CONTRACT_TYPE, type SealedClaimPacket, type SolverLightningRailDeps, type SolverLightningSend, type SolverOnchainRailDeps, type SolverOnchainSend, type SolverRendezvous, type SpendKind, type SwapActivityInput, SwapSecretsProjection, type Tx, type WatchOfferSwapsParams, arkadeRefunder, awaitLockupFunding, cancelOffer, chainSourceFrom, claimReceiveLockup, classifyDepositSpend, classifySpend, covclaimdClient, createOffer, crossAssetRail, decodeOffer, discoverMarkets, encodeOffer, findMarket, lockupContractParams, makeCachedFeedFetch, offerVtxoScript, onchainSendProfile, pushClaim, registerLockupContract, requestLightningSend, requestOnchainSend, restoreAssetSwaps, retireSettledOfferContracts, revealClaimPacket, revealFieldsFromScript, rfqClaimSecretOf, rfqSecretsProfile, rfqSignerOf, rfqSwapActivityInputs, sealClaimPacket, senderIdentityForSwapRecord, solverLightningRail, solverLightningRendezvous, solverOnchainRail, solverOnchainRendezvous, solverRendezvous, spendTxidsOf, spendUpdate, swapActivityResolver, swapPrograms, validatePlan, watchOfferSwaps };