@arkade-os/swap 0.0.14 → 0.0.16

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, 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';
1
+ import { ProvisionedKey, ProvisionedClaimSecret, ArkTxInput, asset, RelativeTimelock, IWallet, EmulatorProvider, 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-rwU1Sv2-.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-rwU1Sv2-.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, 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';
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-DirJn_4k.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_REFUSAL_ERROR_CODES, x as RFQ_TERMINAL_STATES, y as RelaySocket, z as RfqQuote, B as RfqRefusalDetail, D as RfqRefusalErrorCode, E as RfqRefusalReason, F as RfqRefusalUnit, G as RfqStatus, S as SOLO_REFUND_HEADROOM_SECONDS, J as SwapRefusal, K as arkadeAssetLeg, N as arkadeSwapRequest, P as assertFundable, Q as assertReceivable, T as awaitOnchainFill, U as buildHtlcClaim, V as buildHtlcRefund, W as claimOnchainFill, X as classifyOnchainHtlc, Y as deriveLightningReceive, Z as deriveOnchainReceive, _ as deriveOnchainSend, $ as extractPreimage, a0 as httpTransport, a1 as isRfqRefusalErrorCode, a2 as l1ScriptForAddress, a3 as lightningReceiveRequest, a4 as lightningSendRequest, a5 as lightningSendVtxoScript, a6 as newPreimage, a7 as newRfqId, a8 as offerTermsFromQuote, a9 as onchainHtlcScript, aa as onchainReceiveRequest, ab as onchainSendRequest, ac as paymentHashOf, ad as receiveVtxoScript, ae as relayTransport, af as requestLightningReceive, ag as requestOnchainReceive, ah as rfqPair, ai as unilateralClaimDelay, aj as unilateralRefundDelay, ak as unilateralRefundWithoutReceiverDelay, al as verifyLockupAddress, am as verifyReceiveInvoice } from './rfq-DirJn_4k.cjs';
7
7
 
8
8
  /**
9
9
  * Which wallet key signs this leg. Stored at `profile.signer`.
@@ -235,6 +235,22 @@ declare const OFFER_PACKET_TYPE = 3;
235
235
  declare function encodeOffer(offer: Offer): Uint8Array;
236
236
  /** Parse TLV bytes into an offer. Throws on malformed or unknown records. */
237
237
  declare function decodeOffer(data: Uint8Array): Offer;
238
+ /**
239
+ * Put the covenants of restored swap records back in the watched set.
240
+ *
241
+ * {@link restoreAssetSwaps} rebuilds the *record* and nothing else, so a
242
+ * restored wallet holds swaps with no contract row behind them — never
243
+ * subscribed, never emitting `vtxo_spent`, unresolvable by the watcher. The
244
+ * restore-scan backstop three modules lean on restores records, not coverage.
245
+ * Separate from that scan, which is indexer-only and whose records must survive
246
+ * a coverage failure. A script whose every record is {@link RETIRABLE} is
247
+ * skipped, or this undoes {@link retireSettledOfferContracts}. One client, one
248
+ * manager and one `createContracts` for the batch, so N covenants cost one
249
+ * indexer round trip. A covenant that no longer derives is skipped; a dead
250
+ * server or store is not — it covered nothing, and saying otherwise stops the
251
+ * caller retrying.
252
+ */
253
+ declare function restoreOfferCoverage(wallet: IWallet, arkServerUrl: string, swaps: AssetSwap[]): Promise<void>;
238
254
  /**
239
255
  * Build a new offer for `wallet` (the user). Fund `address` with the side
240
256
  * you deposit, embedding the returned extension, and the solver does the rest:
@@ -360,6 +376,95 @@ declare function cancelOffer(wallet: IWallet, arkServerUrl: string, offerHex: st
360
376
  fundingTxid?: string;
361
377
  swapAddress?: string;
362
378
  }): Promise<string>;
379
+ /** Sats output 0 carries when the maker is paid in an ASSET rather than sats:
380
+ * the covenant checks the asset there, and the output still needs a carrier of
381
+ * its own. Overridable per fill via `assetCarrierSats`.
382
+ *
383
+ * Derived from the SDK's constant rather than restated, so the two spellings of
384
+ * one dust threshold cannot drift apart; `bigint` only because this package's
385
+ * amounts are. */
386
+ declare const ASSET_CARRIER_SATS: bigint;
387
+ /**
388
+ * A coin the taker supplies, plus whatever assets it carries.
389
+ *
390
+ * `ArkTxInput` describes sats only, so the assets have to be declared — this is
391
+ * the one thing a fill cannot discover for itself, and omitting it is not
392
+ * cosmetic. **arkd refuses a spend whose asset packet omits an asset one of its
393
+ * inputs owns** (`ASSET_NOT_FOUND`), so a coin picked for its sats that happens
394
+ * to carry an asset takes the whole fill down unless it is named here. A
395
+ * wallet's own coins already carry `assets` in this shape.
396
+ */
397
+ type FillFunding = ArkTxInput & {
398
+ assets?: readonly {
399
+ assetId: string;
400
+ amount: bigint | number;
401
+ }[];
402
+ };
403
+ /**
404
+ * Fill an offer — the TAKER's side, and the counterpart to {@link createOffer}.
405
+ *
406
+ * The covenant's `fulfill` leaf is signed by the server alone and constrains the
407
+ * spend to pay output 0 at least `wantAmount` to the maker's witness program, so
408
+ * a taker cannot take the deposit without delivering. This composes that spend;
409
+ * it does not weaken or reinterpret the covenant.
410
+ *
411
+ * **Both want sides.** For a BTC want output 0 pays `wantAmount` sats. For an
412
+ * ASSET want the covenant reads output 0 through `OP_INSPECTOUTASSETLOOKUP` with
413
+ * `lookup_index = 0`, so the wanted asset must be the FIRST group in the packet
414
+ * and output 0 carries only a dust sat carrier ({@link ASSET_CARRIER_SATS}).
415
+ * Group order follows the order the groups are added, which is why the wanted
416
+ * asset is added first — reordering it silently breaks the covenant.
417
+ *
418
+ * Every other asset in the spend — the deposit's own, and any the taker's
419
+ * funding coins carry — is routed to the taker's payout. Declaring those is not
420
+ * optional; see {@link FillFunding}.
421
+ *
422
+ * Unlike {@link cancelOffer} this writes NO local swap record. A taker filling
423
+ * someone else's offer has no row to update — the repository dance there belongs
424
+ * to the funder, whose swap it is. The maker learns the outcome from the chain
425
+ * (`classifySpend`), which is the design § 7.2 of the RFQ protocol describes.
426
+ *
427
+ * `fund` is required and explicit rather than selected here. Coin selection is
428
+ * the caller's: only they know which coins are reserved for other flows, and a
429
+ * helper that picked for them would spend a corridor's float out from under it.
430
+ * The coins become inputs 1..n and are signed with the wallet's identity.
431
+ *
432
+ * `payoutScript` is where the taker's proceeds land — the deposit it just took,
433
+ * plus any surplus over `wantAmount`. Defaults to the wallet's own address.
434
+ *
435
+ * Racing a cancel is a NORMAL outcome, not a failure: cancel is a 2-of-2 of the
436
+ * funder and the server and does not involve the taker, so a funder may cancel
437
+ * between this reading the deposit and broadcasting. That surfaces the same way
438
+ * cancel's own race does — "no spendable VTXO at the swap address" — and a
439
+ * caller should treat it as "the offer is gone", not as an error to retry.
440
+ */
441
+ declare function fillOffer(wallet: IWallet, arkServerUrl: string, offerHex: string, opts: {
442
+ /** Coins the taker supplies to pay `wantAmount`, with any assets they
443
+ * carry. Become inputs 1..n. @see FillFunding */
444
+ fund: FillFunding[];
445
+ /** Where the taker's proceeds land. Defaults to the wallet's own address. */
446
+ payoutScript?: Uint8Array;
447
+ /** Selects the deposit when the swap address holds more than one. */
448
+ fundingTxid?: string;
449
+ /** The funded address, to pin the server key the covenant was built with. */
450
+ swapAddress?: string;
451
+ /** Sats at output 0 on an asset want. Defaults to {@link ASSET_CARRIER_SATS};
452
+ * raise it for a server whose dust threshold is higher. */
453
+ assetCarrierSats?: bigint;
454
+ /**
455
+ * The co-signing service — a base URL, or a provider of your own.
456
+ *
457
+ * Required, with no default: `fulfill` is a covenant path, so the
458
+ * emulator is what executes the arkade script and finalizes the spend
459
+ * with arkd. A client without one builds the transaction and then
460
+ * refuses to submit it.
461
+ */
462
+ emulator: EmulatorProvider | string;
463
+ /** Co-signer key override (33-byte compressed hex), as `createOffer`
464
+ * takes. Needed on a network the SDK pins no emulator key for, where
465
+ * connecting with an emulator otherwise throws. */
466
+ emulatorPubkey?: string;
467
+ }): Promise<string>;
363
468
 
364
469
  /**
365
470
  * Quoting: solver discovery and the pricing guardrails around a plan.
@@ -434,6 +539,19 @@ type PlanError = "insufficient-balance" | "side-disabled" | "below-min" | "above
434
539
  /** Validate a plan against the user's balance and the server dust limit. */
435
540
  declare const validatePlan: (plan: OfferPlan, giveBalance: bigint, dust: bigint) => PlanError | undefined;
436
541
 
542
+ declare const MARKET_CORRIDORS: readonly ["arkade", "bolt11", "bitcoin", "eip155"];
543
+ type MarketCorridor = (typeof MARKET_CORRIDORS)[number];
544
+ type MarketLike = {
545
+ base_asset?: unknown;
546
+ quote_asset?: unknown;
547
+ base_corridor?: unknown;
548
+ quote_corridor?: unknown;
549
+ };
550
+ declare const marketAssetId: (market: MarketLike, side: Side) => string | undefined;
551
+ declare const marketCorridor: (market: MarketLike, side: Side) => MarketCorridor;
552
+ declare const isRfqMarket: (market: MarketLike) => boolean;
553
+ declare const marketPairLabel: (market: MarketLike) => string;
554
+
437
555
  /** Browser backend over the SDK's shared IndexedDB manager — the same
438
556
  * infrastructure the wallet already uses for its Boltz swap repository. */
439
557
  declare class IndexedDbAssetSwapRepository implements AssetSwapRepository {
@@ -578,15 +696,80 @@ declare function classifyDepositSpend(offer: Offer, serverPubkey: Uint8Array, sp
578
696
  * `serverPubkey` must be the server key the covenants were funded against; a
579
697
  * key that has rotated since makes every affected swap unclassifiable rather
580
698
  * than misclassified.
699
+ *
700
+ * ## `reopen`: re-asking a record this left pending
701
+ *
702
+ * A run finding the deposit unspent returns `pending` *and* marks the funding
703
+ * txid scanned, so the natural call asks once and never again — `pending` is the
704
+ * absence of an answer. Pass those records as `reopen`: re-answered from stored
705
+ * `offerHex`, no funding fetch, skip lists unchanged, definite outcomes only.
581
706
  */
582
707
  declare function restoreAssetSwaps(indexer: RestoreIndexer, txs: Tx[], existingIds: ReadonlySet<string>, opts: {
583
708
  serverPubkey: Uint8Array;
584
709
  scanned?: ReadonlySet<string>;
710
+ reopen?: AssetSwap[];
585
711
  }): Promise<{
586
712
  restored: AssetSwap[];
587
713
  scannedTxids: string[];
588
714
  }>;
589
715
 
716
+ interface AssetSwapRestoreChange {
717
+ /** The stored record before this restore; absent for a rebuilt record. */
718
+ previous?: AssetSwap;
719
+ /** The record persisted by this restore. */
720
+ current: AssetSwap;
721
+ }
722
+ interface RestoreAssetSwapRepositoryOptions {
723
+ wallet: IWallet;
724
+ arkServerUrl: string;
725
+ indexer: RestoreIndexer;
726
+ repository: AssetSwapRepository;
727
+ txs: Tx[];
728
+ /** The server key the restored covenants were funded against, x-only. */
729
+ serverPubkey: Uint8Array;
730
+ /** Add consumer-owned metadata to a newly rebuilt record before it is saved. */
731
+ prepareNew?: (swap: AssetSwap) => AssetSwap | Promise<AssetSwap>;
732
+ /** Stops repository writes and coverage work after an in-flight scan returns. */
733
+ signal?: AbortSignal;
734
+ }
735
+ interface RestoreAssetSwapRepositoryResult {
736
+ /** The repository's newest-first state after this operation. */
737
+ swaps: AssetSwap[];
738
+ /** Every record this operation inserted or updated. */
739
+ changes: AssetSwapRestoreChange[];
740
+ /** Funding txids newly added to the durable scan cursor. */
741
+ scannedTxids: string[];
742
+ /** Set when the caller cancelled before the operation could commit. */
743
+ aborted: boolean;
744
+ /** Coverage setup failed after records were safely persisted. Retry is safe. */
745
+ coverageError?: unknown;
746
+ }
747
+ /**
748
+ * Restore the durable asset-swap state for one wallet.
749
+ *
750
+ * This is the consumer entry point above the two lower-level recovery
751
+ * primitives: it reads the repository, reopens every live record, persists
752
+ * rebuilt records and outcomes before advancing the scan cursor, then restores
753
+ * the wallet-contract coverage needed by the live watcher. Consumers keep only
754
+ * presentation work (for example decorating a new record or announcing a
755
+ * returned change).
756
+ *
757
+ * Scan and persistence failures reject. Coverage setup is different: records
758
+ * are already safe by then, so its error is returned as `coverageError` and a
759
+ * later call can retry without losing or duplicating anything.
760
+ */
761
+ declare function restoreAssetSwapRepository(opts: RestoreAssetSwapRepositoryOptions): Promise<RestoreAssetSwapRepositoryResult>;
762
+
763
+ interface RegisterAssetSwapRestoreOptions {
764
+ arkServerUrl: string;
765
+ repository: AssetSwapRepository;
766
+ indexer?: RestoreIndexer;
767
+ serverPubkey?: Uint8Array;
768
+ prepareNew?: RestoreAssetSwapRepositoryOptions["prepareNew"];
769
+ onResult?: (result: RestoreAssetSwapRepositoryResult) => void | Promise<void>;
770
+ }
771
+ declare function registerAssetSwapRestore(wallet: IWallet, options: RegisterAssetSwapRestoreOptions): () => void;
772
+
590
773
  /**
591
774
  * The record change a classified spend implies, or `undefined` when it implies
592
775
  * none — an already-resolved swap, or a spend nobody could classify.
@@ -622,9 +805,9 @@ interface WatchOfferSwapsParams {
622
805
  * registered covenant is watched, so only registered offers produce events.
623
806
  * Offers funded before registration existed stay on the restore scan.
624
807
  *
625
- * This depends on the wallet's contract event transport. In Node, callers must
626
- * provide an `EventSource` implementation or use a runtime where it is enabled;
627
- * otherwise live updates do not arrive and restore remains the fallback.
808
+ * *Live* updates depend on the wallet's contract event transport. In Node,
809
+ * callers must provide an `EventSource` implementation or use a runtime where
810
+ * it is enabled. The start-up pass needs none of it.
628
811
  */
629
812
  declare function watchOfferSwaps({ wallet, arkServerUrl, repository, onUpdate, }: WatchOfferSwapsParams): Promise<OfferSwapWatcher>;
630
813
 
@@ -1258,4 +1441,4 @@ interface RfqSwapActivityDeps {
1258
1441
  */
1259
1442
  declare function rfqSwapActivityInputs(deps: RfqSwapActivityDeps): Promise<SwapActivityInput[]>;
1260
1443
 
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 };
1444
+ export { ASSET_CARRIER_SATS, ArkadeRefundResult, type ArkadeRefunderDeps, AssetSwap, AssetSwapRepository, type AssetSwapRestoreChange, CROSS_ASSET_RAIL, ChainSource, type ClaimArkProvider, type ClaimPacketInput, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, type CrossAssetPhase, type CrossAssetRailDeps, type CrossAssetSwap, type DiscoverMarketsOptions, type FillFunding, IndexedDbAssetSwapRepository, InvoiceFacts, type LightningReceiveProfile, type LightningSendProfile, LockupAmountMismatchError, LockupContractMissing, type LockupContractReader, type LockupContractWriter, LockupRegistrationFailed, LockupSpendIndexer, LockupVtxo, MARKET_CORRIDORS, type MarketCorridor, type MarketLike, 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 RegisterAssetSwapRestoreOptions, type RestoreAssetSwapRepositoryOptions, type RestoreAssetSwapRepositoryResult, 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, fillOffer, findMarket, isRfqMarket, lockupContractParams, makeCachedFeedFetch, marketAssetId, marketCorridor, marketPairLabel, offerVtxoScript, onchainSendProfile, pushClaim, registerAssetSwapRestore, registerLockupContract, requestLightningSend, requestOnchainSend, restoreAssetSwapRepository, restoreAssetSwaps, restoreOfferCoverage, 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, 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';
1
+ import { ProvisionedKey, ProvisionedClaimSecret, ArkTxInput, asset, RelativeTimelock, IWallet, EmulatorProvider, 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-DH5zjdw4.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-DH5zjdw4.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, 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';
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-DirJn_4k.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_REFUSAL_ERROR_CODES, x as RFQ_TERMINAL_STATES, y as RelaySocket, z as RfqQuote, B as RfqRefusalDetail, D as RfqRefusalErrorCode, E as RfqRefusalReason, F as RfqRefusalUnit, G as RfqStatus, S as SOLO_REFUND_HEADROOM_SECONDS, J as SwapRefusal, K as arkadeAssetLeg, N as arkadeSwapRequest, P as assertFundable, Q as assertReceivable, T as awaitOnchainFill, U as buildHtlcClaim, V as buildHtlcRefund, W as claimOnchainFill, X as classifyOnchainHtlc, Y as deriveLightningReceive, Z as deriveOnchainReceive, _ as deriveOnchainSend, $ as extractPreimage, a0 as httpTransport, a1 as isRfqRefusalErrorCode, a2 as l1ScriptForAddress, a3 as lightningReceiveRequest, a4 as lightningSendRequest, a5 as lightningSendVtxoScript, a6 as newPreimage, a7 as newRfqId, a8 as offerTermsFromQuote, a9 as onchainHtlcScript, aa as onchainReceiveRequest, ab as onchainSendRequest, ac as paymentHashOf, ad as receiveVtxoScript, ae as relayTransport, af as requestLightningReceive, ag as requestOnchainReceive, ah as rfqPair, ai as unilateralClaimDelay, aj as unilateralRefundDelay, ak as unilateralRefundWithoutReceiverDelay, al as verifyLockupAddress, am as verifyReceiveInvoice } from './rfq-DirJn_4k.js';
7
7
 
8
8
  /**
9
9
  * Which wallet key signs this leg. Stored at `profile.signer`.
@@ -235,6 +235,22 @@ declare const OFFER_PACKET_TYPE = 3;
235
235
  declare function encodeOffer(offer: Offer): Uint8Array;
236
236
  /** Parse TLV bytes into an offer. Throws on malformed or unknown records. */
237
237
  declare function decodeOffer(data: Uint8Array): Offer;
238
+ /**
239
+ * Put the covenants of restored swap records back in the watched set.
240
+ *
241
+ * {@link restoreAssetSwaps} rebuilds the *record* and nothing else, so a
242
+ * restored wallet holds swaps with no contract row behind them — never
243
+ * subscribed, never emitting `vtxo_spent`, unresolvable by the watcher. The
244
+ * restore-scan backstop three modules lean on restores records, not coverage.
245
+ * Separate from that scan, which is indexer-only and whose records must survive
246
+ * a coverage failure. A script whose every record is {@link RETIRABLE} is
247
+ * skipped, or this undoes {@link retireSettledOfferContracts}. One client, one
248
+ * manager and one `createContracts` for the batch, so N covenants cost one
249
+ * indexer round trip. A covenant that no longer derives is skipped; a dead
250
+ * server or store is not — it covered nothing, and saying otherwise stops the
251
+ * caller retrying.
252
+ */
253
+ declare function restoreOfferCoverage(wallet: IWallet, arkServerUrl: string, swaps: AssetSwap[]): Promise<void>;
238
254
  /**
239
255
  * Build a new offer for `wallet` (the user). Fund `address` with the side
240
256
  * you deposit, embedding the returned extension, and the solver does the rest:
@@ -360,6 +376,95 @@ declare function cancelOffer(wallet: IWallet, arkServerUrl: string, offerHex: st
360
376
  fundingTxid?: string;
361
377
  swapAddress?: string;
362
378
  }): Promise<string>;
379
+ /** Sats output 0 carries when the maker is paid in an ASSET rather than sats:
380
+ * the covenant checks the asset there, and the output still needs a carrier of
381
+ * its own. Overridable per fill via `assetCarrierSats`.
382
+ *
383
+ * Derived from the SDK's constant rather than restated, so the two spellings of
384
+ * one dust threshold cannot drift apart; `bigint` only because this package's
385
+ * amounts are. */
386
+ declare const ASSET_CARRIER_SATS: bigint;
387
+ /**
388
+ * A coin the taker supplies, plus whatever assets it carries.
389
+ *
390
+ * `ArkTxInput` describes sats only, so the assets have to be declared — this is
391
+ * the one thing a fill cannot discover for itself, and omitting it is not
392
+ * cosmetic. **arkd refuses a spend whose asset packet omits an asset one of its
393
+ * inputs owns** (`ASSET_NOT_FOUND`), so a coin picked for its sats that happens
394
+ * to carry an asset takes the whole fill down unless it is named here. A
395
+ * wallet's own coins already carry `assets` in this shape.
396
+ */
397
+ type FillFunding = ArkTxInput & {
398
+ assets?: readonly {
399
+ assetId: string;
400
+ amount: bigint | number;
401
+ }[];
402
+ };
403
+ /**
404
+ * Fill an offer — the TAKER's side, and the counterpart to {@link createOffer}.
405
+ *
406
+ * The covenant's `fulfill` leaf is signed by the server alone and constrains the
407
+ * spend to pay output 0 at least `wantAmount` to the maker's witness program, so
408
+ * a taker cannot take the deposit without delivering. This composes that spend;
409
+ * it does not weaken or reinterpret the covenant.
410
+ *
411
+ * **Both want sides.** For a BTC want output 0 pays `wantAmount` sats. For an
412
+ * ASSET want the covenant reads output 0 through `OP_INSPECTOUTASSETLOOKUP` with
413
+ * `lookup_index = 0`, so the wanted asset must be the FIRST group in the packet
414
+ * and output 0 carries only a dust sat carrier ({@link ASSET_CARRIER_SATS}).
415
+ * Group order follows the order the groups are added, which is why the wanted
416
+ * asset is added first — reordering it silently breaks the covenant.
417
+ *
418
+ * Every other asset in the spend — the deposit's own, and any the taker's
419
+ * funding coins carry — is routed to the taker's payout. Declaring those is not
420
+ * optional; see {@link FillFunding}.
421
+ *
422
+ * Unlike {@link cancelOffer} this writes NO local swap record. A taker filling
423
+ * someone else's offer has no row to update — the repository dance there belongs
424
+ * to the funder, whose swap it is. The maker learns the outcome from the chain
425
+ * (`classifySpend`), which is the design § 7.2 of the RFQ protocol describes.
426
+ *
427
+ * `fund` is required and explicit rather than selected here. Coin selection is
428
+ * the caller's: only they know which coins are reserved for other flows, and a
429
+ * helper that picked for them would spend a corridor's float out from under it.
430
+ * The coins become inputs 1..n and are signed with the wallet's identity.
431
+ *
432
+ * `payoutScript` is where the taker's proceeds land — the deposit it just took,
433
+ * plus any surplus over `wantAmount`. Defaults to the wallet's own address.
434
+ *
435
+ * Racing a cancel is a NORMAL outcome, not a failure: cancel is a 2-of-2 of the
436
+ * funder and the server and does not involve the taker, so a funder may cancel
437
+ * between this reading the deposit and broadcasting. That surfaces the same way
438
+ * cancel's own race does — "no spendable VTXO at the swap address" — and a
439
+ * caller should treat it as "the offer is gone", not as an error to retry.
440
+ */
441
+ declare function fillOffer(wallet: IWallet, arkServerUrl: string, offerHex: string, opts: {
442
+ /** Coins the taker supplies to pay `wantAmount`, with any assets they
443
+ * carry. Become inputs 1..n. @see FillFunding */
444
+ fund: FillFunding[];
445
+ /** Where the taker's proceeds land. Defaults to the wallet's own address. */
446
+ payoutScript?: Uint8Array;
447
+ /** Selects the deposit when the swap address holds more than one. */
448
+ fundingTxid?: string;
449
+ /** The funded address, to pin the server key the covenant was built with. */
450
+ swapAddress?: string;
451
+ /** Sats at output 0 on an asset want. Defaults to {@link ASSET_CARRIER_SATS};
452
+ * raise it for a server whose dust threshold is higher. */
453
+ assetCarrierSats?: bigint;
454
+ /**
455
+ * The co-signing service — a base URL, or a provider of your own.
456
+ *
457
+ * Required, with no default: `fulfill` is a covenant path, so the
458
+ * emulator is what executes the arkade script and finalizes the spend
459
+ * with arkd. A client without one builds the transaction and then
460
+ * refuses to submit it.
461
+ */
462
+ emulator: EmulatorProvider | string;
463
+ /** Co-signer key override (33-byte compressed hex), as `createOffer`
464
+ * takes. Needed on a network the SDK pins no emulator key for, where
465
+ * connecting with an emulator otherwise throws. */
466
+ emulatorPubkey?: string;
467
+ }): Promise<string>;
363
468
 
364
469
  /**
365
470
  * Quoting: solver discovery and the pricing guardrails around a plan.
@@ -434,6 +539,19 @@ type PlanError = "insufficient-balance" | "side-disabled" | "below-min" | "above
434
539
  /** Validate a plan against the user's balance and the server dust limit. */
435
540
  declare const validatePlan: (plan: OfferPlan, giveBalance: bigint, dust: bigint) => PlanError | undefined;
436
541
 
542
+ declare const MARKET_CORRIDORS: readonly ["arkade", "bolt11", "bitcoin", "eip155"];
543
+ type MarketCorridor = (typeof MARKET_CORRIDORS)[number];
544
+ type MarketLike = {
545
+ base_asset?: unknown;
546
+ quote_asset?: unknown;
547
+ base_corridor?: unknown;
548
+ quote_corridor?: unknown;
549
+ };
550
+ declare const marketAssetId: (market: MarketLike, side: Side) => string | undefined;
551
+ declare const marketCorridor: (market: MarketLike, side: Side) => MarketCorridor;
552
+ declare const isRfqMarket: (market: MarketLike) => boolean;
553
+ declare const marketPairLabel: (market: MarketLike) => string;
554
+
437
555
  /** Browser backend over the SDK's shared IndexedDB manager — the same
438
556
  * infrastructure the wallet already uses for its Boltz swap repository. */
439
557
  declare class IndexedDbAssetSwapRepository implements AssetSwapRepository {
@@ -578,15 +696,80 @@ declare function classifyDepositSpend(offer: Offer, serverPubkey: Uint8Array, sp
578
696
  * `serverPubkey` must be the server key the covenants were funded against; a
579
697
  * key that has rotated since makes every affected swap unclassifiable rather
580
698
  * than misclassified.
699
+ *
700
+ * ## `reopen`: re-asking a record this left pending
701
+ *
702
+ * A run finding the deposit unspent returns `pending` *and* marks the funding
703
+ * txid scanned, so the natural call asks once and never again — `pending` is the
704
+ * absence of an answer. Pass those records as `reopen`: re-answered from stored
705
+ * `offerHex`, no funding fetch, skip lists unchanged, definite outcomes only.
581
706
  */
582
707
  declare function restoreAssetSwaps(indexer: RestoreIndexer, txs: Tx[], existingIds: ReadonlySet<string>, opts: {
583
708
  serverPubkey: Uint8Array;
584
709
  scanned?: ReadonlySet<string>;
710
+ reopen?: AssetSwap[];
585
711
  }): Promise<{
586
712
  restored: AssetSwap[];
587
713
  scannedTxids: string[];
588
714
  }>;
589
715
 
716
+ interface AssetSwapRestoreChange {
717
+ /** The stored record before this restore; absent for a rebuilt record. */
718
+ previous?: AssetSwap;
719
+ /** The record persisted by this restore. */
720
+ current: AssetSwap;
721
+ }
722
+ interface RestoreAssetSwapRepositoryOptions {
723
+ wallet: IWallet;
724
+ arkServerUrl: string;
725
+ indexer: RestoreIndexer;
726
+ repository: AssetSwapRepository;
727
+ txs: Tx[];
728
+ /** The server key the restored covenants were funded against, x-only. */
729
+ serverPubkey: Uint8Array;
730
+ /** Add consumer-owned metadata to a newly rebuilt record before it is saved. */
731
+ prepareNew?: (swap: AssetSwap) => AssetSwap | Promise<AssetSwap>;
732
+ /** Stops repository writes and coverage work after an in-flight scan returns. */
733
+ signal?: AbortSignal;
734
+ }
735
+ interface RestoreAssetSwapRepositoryResult {
736
+ /** The repository's newest-first state after this operation. */
737
+ swaps: AssetSwap[];
738
+ /** Every record this operation inserted or updated. */
739
+ changes: AssetSwapRestoreChange[];
740
+ /** Funding txids newly added to the durable scan cursor. */
741
+ scannedTxids: string[];
742
+ /** Set when the caller cancelled before the operation could commit. */
743
+ aborted: boolean;
744
+ /** Coverage setup failed after records were safely persisted. Retry is safe. */
745
+ coverageError?: unknown;
746
+ }
747
+ /**
748
+ * Restore the durable asset-swap state for one wallet.
749
+ *
750
+ * This is the consumer entry point above the two lower-level recovery
751
+ * primitives: it reads the repository, reopens every live record, persists
752
+ * rebuilt records and outcomes before advancing the scan cursor, then restores
753
+ * the wallet-contract coverage needed by the live watcher. Consumers keep only
754
+ * presentation work (for example decorating a new record or announcing a
755
+ * returned change).
756
+ *
757
+ * Scan and persistence failures reject. Coverage setup is different: records
758
+ * are already safe by then, so its error is returned as `coverageError` and a
759
+ * later call can retry without losing or duplicating anything.
760
+ */
761
+ declare function restoreAssetSwapRepository(opts: RestoreAssetSwapRepositoryOptions): Promise<RestoreAssetSwapRepositoryResult>;
762
+
763
+ interface RegisterAssetSwapRestoreOptions {
764
+ arkServerUrl: string;
765
+ repository: AssetSwapRepository;
766
+ indexer?: RestoreIndexer;
767
+ serverPubkey?: Uint8Array;
768
+ prepareNew?: RestoreAssetSwapRepositoryOptions["prepareNew"];
769
+ onResult?: (result: RestoreAssetSwapRepositoryResult) => void | Promise<void>;
770
+ }
771
+ declare function registerAssetSwapRestore(wallet: IWallet, options: RegisterAssetSwapRestoreOptions): () => void;
772
+
590
773
  /**
591
774
  * The record change a classified spend implies, or `undefined` when it implies
592
775
  * none — an already-resolved swap, or a spend nobody could classify.
@@ -622,9 +805,9 @@ interface WatchOfferSwapsParams {
622
805
  * registered covenant is watched, so only registered offers produce events.
623
806
  * Offers funded before registration existed stay on the restore scan.
624
807
  *
625
- * This depends on the wallet's contract event transport. In Node, callers must
626
- * provide an `EventSource` implementation or use a runtime where it is enabled;
627
- * otherwise live updates do not arrive and restore remains the fallback.
808
+ * *Live* updates depend on the wallet's contract event transport. In Node,
809
+ * callers must provide an `EventSource` implementation or use a runtime where
810
+ * it is enabled. The start-up pass needs none of it.
628
811
  */
629
812
  declare function watchOfferSwaps({ wallet, arkServerUrl, repository, onUpdate, }: WatchOfferSwapsParams): Promise<OfferSwapWatcher>;
630
813
 
@@ -1258,4 +1441,4 @@ interface RfqSwapActivityDeps {
1258
1441
  */
1259
1442
  declare function rfqSwapActivityInputs(deps: RfqSwapActivityDeps): Promise<SwapActivityInput[]>;
1260
1443
 
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 };
1444
+ export { ASSET_CARRIER_SATS, ArkadeRefundResult, type ArkadeRefunderDeps, AssetSwap, AssetSwapRepository, type AssetSwapRestoreChange, CROSS_ASSET_RAIL, ChainSource, type ClaimArkProvider, type ClaimPacketInput, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, type CrossAssetPhase, type CrossAssetRailDeps, type CrossAssetSwap, type DiscoverMarketsOptions, type FillFunding, IndexedDbAssetSwapRepository, InvoiceFacts, type LightningReceiveProfile, type LightningSendProfile, LockupAmountMismatchError, LockupContractMissing, type LockupContractReader, type LockupContractWriter, LockupRegistrationFailed, LockupSpendIndexer, LockupVtxo, MARKET_CORRIDORS, type MarketCorridor, type MarketLike, 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 RegisterAssetSwapRestoreOptions, type RestoreAssetSwapRepositoryOptions, type RestoreAssetSwapRepositoryResult, 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, fillOffer, findMarket, isRfqMarket, lockupContractParams, makeCachedFeedFetch, marketAssetId, marketCorridor, marketPairLabel, offerVtxoScript, onchainSendProfile, pushClaim, registerAssetSwapRestore, registerLockupContract, requestLightningSend, requestOnchainSend, restoreAssetSwapRepository, restoreAssetSwaps, restoreOfferCoverage, retireSettledOfferContracts, revealClaimPacket, revealFieldsFromScript, rfqClaimSecretOf, rfqSecretsProfile, rfqSignerOf, rfqSwapActivityInputs, sealClaimPacket, senderIdentityForSwapRecord, solverLightningRail, solverLightningRendezvous, solverOnchainRail, solverOnchainRendezvous, solverRendezvous, spendTxidsOf, spendUpdate, swapActivityResolver, swapPrograms, validatePlan, watchOfferSwaps };