@arkade-os/swap 0.0.11 → 0.1.0-rc.0

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.
@@ -1,6 +1,6 @@
1
1
  import { DiscoveredMarket } from '@arkade-os/solver-discovery';
2
- import { IWallet, ProvisionedKey, ProvisionedClaimSecret, RestArkProvider, RestIndexerProvider, VHTLC, Identity, IContractManager } from '@arkade-os/sdk';
3
- import { x as RfqStatus, y as RfqTransport, a as OnchainHtlc, e as ChainUtxo, C as ChainSource, t as OnchainHtlcPhase } from './rfq-DkckzRKK.cjs';
2
+ import { IWallet, ProvisionedKey, ProvisionedClaimSecret, ArkProvider, RestIndexerProvider, VHTLC, Identity, IContractManager } from '@arkade-os/sdk';
3
+ import { D as RfqStatus, R as RfqTransport, a as OnchainHtlc, g as ChainUtxo, C as ChainSource, w as OnchainHtlcPhase } from './rfq-CzCGjICq.js';
4
4
 
5
5
  type AssetSwapStatus = "pending" | "cancelling" | "fulfilled" | "cancelled" | "recoverable" | "awaiting_fill" | "claimable" | "claimed" | "refunded_l1";
6
6
  /** The sentinel asset id for BTC itself, as opposed to a 68-hex asset id.
@@ -210,10 +210,17 @@ declare function awaitRfqResolution(transport: RfqTransport, rfqId: string, opti
210
210
  pollMs?: number;
211
211
  deadline?: number;
212
212
  }): Promise<RfqStatus>;
213
- /** The Ark surface the refund push needs — narrower than a full provider, and
214
- * satisfied by {@link RestArkProvider}. Same seam style as `RestoreIndexer`. */
215
- type RefundArkProvider = Pick<RestArkProvider, "getInfo" | "submitTx" | "finalizeTx">;
216
213
  /** The indexer surface the lockup lookup needs. */
214
+ /**
215
+ * What a push needs from the operator: the broadcast pair, plus the info read
216
+ * that supplies `checkpointTapscript`.
217
+ *
218
+ * Narrow on purpose. A wallet's own connection satisfies it —
219
+ * `getArkadeBroadcaster()` for the pair and `getArkadeInfo()` for the read — so
220
+ * a plugin composes one from the wallet it already has and never opens a second
221
+ * connection of its own (#734). A full `ArkProvider` still fits, structurally.
222
+ */
223
+ type SwapOperator = Pick<ArkProvider, "getInfo" | "submitTx" | "finalizeTx">;
217
224
  type RefundIndexer = Pick<RestIndexerProvider, "getVtxos">;
218
225
  /** A still-refundable virtual output sitting at the swap lockup. */
219
226
  interface LockupVtxo {
@@ -237,12 +244,6 @@ interface LockupVtxo {
237
244
  * Opposite, but not exhaustive: an unrolled output satisfies neither, and
238
245
  * {@link findLockupVtxos} drops those before they reach this type at all.
239
246
  *
240
- * `packages/boltz-swap` splits on exactly this fact rather than working
241
- * around it: `settleRefundWithoutReceiver` sends a live VTXO through an
242
- * offchain tx and a recoverable one through `joinBatch` — "a swept
243
- * (recoverable) VTXO is no longer a live leaf, so it can only be reclaimed
244
- * by re-registering it into a batch".
245
- *
246
247
  * So the remedy is recovery (renewing the output into a fresh batch),
247
248
  * after which the ordinary CLTV refund works again. This package does not
248
249
  * build that round — see {@link pushRefundWithoutReceiver}, which refuses
@@ -260,8 +261,7 @@ interface LockupVtxo {
260
261
  *
261
262
  * **The remedy already exists; this package does not reimplement it.** The SDK
262
263
  * recovers swept outputs by re-registering them into a fresh batch, through
263
- * `IVtxoManager.recoverVtxos()` — the same batch round `packages/boltz-swap`
264
- * reaches via its own `joinBatch`. It reads the wallet's registered-contract
264
+ * `IVtxoManager.recoverVtxos()`. It reads the wallet's registered-contract
265
265
  * snapshot (`recoverVtxos` → `wallet.getVtxos({ withRecoverable: true })` →
266
266
  * `contractSnapshot()` → `contractManager.getContractsWithVtxos()`), so it
267
267
  * covers a swap lockup as soon as that lockup is registered as a contract —
@@ -278,8 +278,7 @@ interface LockupVtxo {
278
278
  * recovery round including this VTXO earlier is rejected. `recoverVtxos`
279
279
  * sweeps every recoverable output in ONE settlement and has no CLTV
280
280
  * awareness, so recovering early can fail the whole batch rather than just
281
- * this output. `packages/boltz-swap` encodes the same rule as "pre-CLTV
282
- * recoverable → skipped".
281
+ * this output.
283
282
  */
284
283
  declare class LockupNeedsRecoveryError extends Error {
285
284
  readonly name = "LockupNeedsRecoveryError";
@@ -292,11 +291,10 @@ declare class LockupNeedsRecoveryError extends Error {
292
291
  * into one settlement with no CLTV awareness, so an early attempt can fail
293
292
  * the whole batch — including unrelated outputs that were otherwise fine.
294
293
  *
295
- * Exposed as a value, not only inside the message, so a caller can encode
296
- * `packages/boltz-swap`'s "pre-CLTV recoverable → skipped" rule without
297
- * parsing prose. Seconds-based locktimes mature against the chain tip's
298
- * timestamp rather than wall clock, so treat this as a floor to wait past,
299
- * not an exact alarm.
294
+ * Exposed as a value, not only inside the message, so a caller can skip
295
+ * pre-CLTV recoverable outputs without parsing prose. Seconds-based
296
+ * locktimes mature against the chain tip's timestamp rather than wall
297
+ * clock, so treat this as a floor to wait past, not an exact alarm.
300
298
  */
301
299
  readonly recoverableAfter: bigint;
302
300
  constructor(outpoints: string[], recoverableAfter: bigint);
@@ -315,8 +313,7 @@ declare class LockupNeedsRecoveryError extends Error {
315
313
  * sat unresolved — which are precisely the ones most likely to have got there.
316
314
  * Reading only the spendable set would report `nothing_to_refund` over money
317
315
  * that is still sitting at the script, which is worse than an error: it looks
318
- * like a resolved swap. `packages/boltz-swap` merges the same two queries for
319
- * the same reason (`arkade-swaps.ts`'s `refundableVtxos`).
316
+ * like a resolved swap.
320
317
  *
321
318
  * **Visible is not the same as refundable.** A `recoverable` output cannot be
322
319
  * spent offchain at all — see {@link LockupVtxo.recoverable} — so this set is
@@ -370,7 +367,7 @@ interface LockupSpend {
370
367
  checkpointTxid: string;
371
368
  /** The ark transaction that spent the above checkpoint output. What
372
369
  * history correlation matches on; absent when the indexer omitted it. */
373
- arkTxid?: string;
370
+ txid?: string;
374
371
  }
375
372
  type LockupFate =
376
373
  /** At least one output at the lockup is still unspent. Not over. */
@@ -501,8 +498,8 @@ declare function readLockupFate(indexer: LockupSpendIndexer, input: {
501
498
  * outpoints, rather than submitted and rejected. Filtering them out silently
502
499
  * would be worse still: it would report success over money that never moved.
503
500
  */
504
- declare function pushRefundWithoutReceiver(ark: RefundArkProvider, input: {
505
- script: InstanceType<typeof VHTLC.ScriptV2>;
501
+ declare function pushRefundWithoutReceiver(operator: SwapOperator, input: {
502
+ contract: InstanceType<typeof VHTLC.ScriptV2>;
506
503
  /** The `sender` signer. Build it from the swap record with
507
504
  * {@link senderIdentityForSwapRecord} — on an HD wallet that resolves
508
505
  * from the seed, with no stored key bytes anywhere, and every way the
@@ -514,7 +511,7 @@ declare function pushRefundWithoutReceiver(ark: RefundArkProvider, input: {
514
511
  /** Defaults to the contract's own committed refund destination. */
515
512
  refundPkScript?: Uint8Array;
516
513
  }): Promise<{
517
- arkTxid: string;
514
+ txid: string;
518
515
  amount: number;
519
516
  }>;
520
517
  /**
@@ -536,7 +533,7 @@ type RefundOutcome =
536
533
  /** The trader took it back via `refundWithoutReceiver`. */
537
534
  | {
538
535
  outcome: "refunded";
539
- arkTxid: string;
536
+ txid: string;
540
537
  amount: number;
541
538
  status: RfqStatus | null;
542
539
  }
@@ -619,9 +616,9 @@ type RefundOutcome =
619
616
  * well past the deadline skips straight to the push, and a lockup that is
620
617
  * already empty comes back as `nothing_to_refund` instead of an error.
621
618
  */
622
- declare function refundIfUnresolved(transport: RfqTransport, ark: RefundArkProvider, indexer: LockupSpendIndexer, input: {
619
+ declare function refundIfUnresolved(transport: RfqTransport, operator: SwapOperator, indexer: LockupSpendIndexer, input: {
623
620
  rfqId: string;
624
- script: InstanceType<typeof VHTLC.ScriptV2>;
621
+ contract: InstanceType<typeof VHTLC.ScriptV2>;
625
622
  /** @see pushRefundWithoutReceiver */
626
623
  sender: Identity;
627
624
  /**
@@ -787,7 +784,7 @@ interface RfqSwapCommon {
787
784
  createdAt: number;
788
785
  updatedAt: number;
789
786
  /** Set once the trader's own `refundWithoutReceiver` push landed. */
790
- refundArkTxid?: string;
787
+ refundTxid?: string;
791
788
  /**
792
789
  * The ark transactions that SPENT the lockup, stamped from the chain read
793
790
  * that ended the swap — `LockupFate.spends`, whichever verdict it reached.
@@ -796,8 +793,8 @@ interface RfqSwapCommon {
796
793
  * a solver reclaim on a receive, and — the exception — the trader's own
797
794
  * claim when a receive settles. What they have in common is that no local
798
795
  * action produced them, so nothing else on this record can name them:
799
- * {@link refundArkTxid} names only a push this wallet made, and
800
- * `claimArkTxid` only a submission it made.
796
+ * {@link refundTxid} names only a push this wallet made, and
797
+ * `claimTxid` only a submission it made.
801
798
  *
802
799
  * Stamped so a terminal record answers "which transaction ended this" from
803
800
  * storage. Without it the only source is another read of the lockup — a
@@ -805,10 +802,10 @@ interface RfqSwapCommon {
805
802
  * has to pay on the offline-first path where it is least affordable.
806
803
  *
807
804
  * Absent when the swap ended without a chain verdict, or when the indexer
808
- * named the checkpoint but not the ark transaction — the same `arkTxid`
805
+ * named the checkpoint but not the ark transaction — the same `txid`
809
806
  * `LockupSpend` declares optional, for the same reason.
810
807
  */
811
- lockupSpendArkTxids?: string[];
808
+ lockupSpendTxids?: string[];
812
809
  /** Why `state` is `failed`. */
813
810
  failure?: string;
814
811
  /** Why `state` is `needs_counterparty`. Distinct from {@link failure},
@@ -872,7 +869,7 @@ interface LightningReceiveSwap extends RfqSwapCommon {
872
869
  expectedAmount: number;
873
870
  /** Our Arkade claim's txid, once submitted. Set from the callback's return
874
871
  * and never from a chain read — the chain's answer is `settled`. */
875
- claimArkTxid?: string;
872
+ claimTxid?: string;
876
873
  }
877
874
  /**
878
875
  * A monitored swap.
@@ -883,8 +880,8 @@ interface LightningReceiveSwap extends RfqSwapCommon {
883
880
  * writes and rebuilds these itself, through
884
881
  * {@link RfqSwapManager.restoreFromRepository}. A caller keeping its own store
885
882
  * projects it in {@link RfqSwapManagerCallbacks.saveSwap} instead, rebuilds it
886
- * on restart the way it was made — `lightningSendVtxoScript` /
887
- * `receiveVtxoScript` / `onchainHtlcScript` over the quote's binding fields —
883
+ * on restart the way it was made — `lightningSendContract` /
884
+ * `lightningReceiveContract` / `onchainHtlcScript` over the quote's binding fields —
888
885
  * and hands the result to {@link RfqSwapManager.start}.
889
886
  *
890
887
  * **`onchain:BTC->arkade:BTC` is deliberately not a member yet.** Its Arkade
@@ -942,7 +939,7 @@ declare function nextOnchainAction(input: {
942
939
  /** What the trader's own `refundWithoutReceiver` push returned, or `null` when
943
940
  * the lockup held nothing to return. */
944
941
  type ArkadeRefundResult = {
945
- arkTxid: string;
942
+ txid: string;
946
943
  amount: number;
947
944
  } | null;
948
945
  /**
@@ -993,7 +990,7 @@ interface RfqSwapManagerCallbacks {
993
990
  * funding that arrived piecemeal can still be swept. */
994
991
  partiallyClaimed: boolean;
995
992
  }) => Promise<{
996
- arkTxid: string;
993
+ txid: string;
997
994
  amount: number;
998
995
  }>;
999
996
  /**
@@ -1107,7 +1104,7 @@ interface RfqSwapManagerConfig {
1107
1104
  }
1108
1105
  /** The contract-manager surface this needs, narrowed for injection — the same
1109
1106
  * seam style as {@link LockupSpendIndexer} and `refund.ts`'s
1110
- * {@link RefundArkProvider}, and satisfied structurally by a real
1107
+ * `RefundIndexer`, and satisfied structurally by a real
1111
1108
  * `ContractManager` (`await wallet.getContractManager()`). */
1112
1109
  type SwapContractRegistry = Pick<IContractManager, "createContract" | "getContracts" | "onContractEvent" | "setContractWatchState">;
1113
1110
  /**
@@ -1487,6 +1484,17 @@ declare class RfqSwapManager {
1487
1484
  removeSwap(rfqId: string): Promise<void>;
1488
1485
  /** Every swap still being monitored. */
1489
1486
  getPendingSwaps(): Promise<RfqSwap[]>;
1487
+ /**
1488
+ * Every swap this manager holds — {@link getPendingSwaps} plus the ones
1489
+ * that already ended. The two sets are disjoint: a swap leaves `monitored`
1490
+ * as it enters `finished`.
1491
+ *
1492
+ * The finished half is what this process has seen, which after
1493
+ * {@link restoreFromRepository} is the stored history minus what retention
1494
+ * pruned. A manager that has restored nothing answers with the live swaps
1495
+ * alone.
1496
+ */
1497
+ getAllSwaps(): Promise<RfqSwap[]>;
1490
1498
  hasSwap(rfqId: string): Promise<boolean>;
1491
1499
  /** True while an action for this swap holds the per-swap lock. */
1492
1500
  isProcessing(rfqId: string): Promise<boolean>;
@@ -1648,7 +1656,7 @@ declare class RfqSwapManager {
1648
1656
  /**
1649
1657
  * Record which ark transactions ended the lockup.
1650
1658
  *
1651
- * Only the ones the indexer actually named: `LockupSpend.arkTxid` is
1659
+ * Only the ones the indexer actually named: `LockupSpend.txid` is
1652
1660
  * optional, and a checkpoint txid is not what history correlates on — a
1653
1661
  * record carrying one would name a transaction the wallet's own activity
1654
1662
  * never shows. Fewer txids is the right failure here.
@@ -1692,10 +1700,9 @@ declare class RfqSwapManager {
1692
1700
  /**
1693
1701
  * Drop a terminal swap from monitoring and report it exactly once.
1694
1702
  *
1695
- * `onSwapCompleted` and `onSwapFailed` are mutually exclusive here, unlike
1696
- * Boltz's manager, which fires completion for every swap that leaves
1697
- * monitoring including the failed ones — a listener named "completed" that
1698
- * also fires on failure is a trap worth not inheriting.
1703
+ * `onSwapCompleted` and `onSwapFailed` are mutually exclusive here: a
1704
+ * listener named "completed" that also fires on failure is a trap, so a
1705
+ * swap that leaves monitoring reports through exactly one of them.
1699
1706
  */
1700
1707
  private finalize;
1701
1708
  private settleWaiters;
@@ -1795,7 +1802,7 @@ interface RfqSwapOrigin {
1795
1802
  * learns it. So it is written once at record creation, like {@link amount},
1796
1803
  * and no corridor `project` emits it.
1797
1804
  */
1798
- fundingArkTxid?: string;
1805
+ fundingTxid?: string;
1799
1806
  }
1800
1807
  /** The stored record: the origin plus the manager's mutable state. */
1801
1808
  interface RfqSwapRecord extends RfqSwapOrigin {
@@ -1803,14 +1810,37 @@ interface RfqSwapRecord extends RfqSwapOrigin {
1803
1810
  state: RfqSwapState;
1804
1811
  createdAt: number;
1805
1812
  updatedAt: number;
1806
- refundArkTxid?: string;
1813
+ refundTxid?: string;
1807
1814
  /** The ark transactions that spent the lockup, stamped by the manager from
1808
1815
  * the chain read that ended the swap. See
1809
- * `RfqSwapCommon.lockupSpendArkTxids`. */
1810
- lockupSpendArkTxids?: string[];
1816
+ * `RfqSwapCommon.lockupSpendTxids`. */
1817
+ lockupSpendTxids?: string[];
1811
1818
  failure?: string;
1812
1819
  blockedReason?: string;
1813
1820
  }
1821
+ /**
1822
+ * A stored record read under the current field names.
1823
+ *
1824
+ * Four fields were renamed after `0.0.9`: `fundingArkTxid`, `refundArkTxid`,
1825
+ * `lockupSpendArkTxids`, and the receive corridor's `profile.claimArkTxid`. All
1826
+ * four arrived together with record persistence itself in `0.0.8`, so `0.0.8`
1827
+ * and `0.0.9` are the only versions that ever wrote them. Backends store the
1828
+ * record WHOLE, so such a store still holds the old names on disk and the
1829
+ * current code reads every one of them as `undefined`.
1830
+ *
1831
+ * Called by every function here that takes a record, so a consumer needs no
1832
+ * boot-time migration of its own; and because the old keys never reach the
1833
+ * object handed back, the next write persists the record without them.
1834
+ *
1835
+ * What it buys, in descending order of sharpness: a receive leg with a partial
1836
+ * claim already out keeps its `claimTxid`, so the value gate stays disarmed
1837
+ * rather than re-blocking the rest of a lockup whose preimage is public;
1838
+ * `refunded` swaps report an outcome txid again; and activity answers from the
1839
+ * record instead of falling back to a lockup read per query. It is NOT a
1840
+ * re-refund fix — `refunded` is terminal, and `restoreFromRepository` puts a
1841
+ * terminal record straight into `finished` without ever driving it.
1842
+ */
1843
+ declare function normalizeRfqSwapRecord(record: RfqSwapRecord): RfqSwapRecord;
1814
1844
  /** First write, at the moment the caller hands the swap to the manager. */
1815
1845
  declare function createRfqSwapRecord(origin: RfqSwapOrigin, swap: PersistableRfqSwap): RfqSwapRecord;
1816
1846
  /**
@@ -1829,7 +1859,7 @@ declare function updateRfqSwapRecord(record: RfqSwapRecord, swap: PersistableRfq
1829
1859
  * A record IS an origin plus manager state, so `record` where an
1830
1860
  * {@link RfqSwapOrigin} is wanted type-checks — and is a bug. Spread into
1831
1861
  * {@link createRfqSwapRecord} it carries the OLD state's `failure`,
1832
- * `blockedReason` and `refundArkTxid` past `managerState`, which omits a field
1862
+ * `blockedReason` and `refundTxid` past `managerState`, which omits a field
1833
1863
  * the live swap no longer has and therefore cannot clear one. That is the same
1834
1864
  * trap {@link updateRfqSwapRecord} strips those three fields to avoid; this is
1835
1865
  * how a caller holding only a record gets an origin that is safe to keep.
@@ -1875,9 +1905,8 @@ interface MarketsCacheEntry {
1875
1905
  }
1876
1906
  /**
1877
1907
  * Everything the package persists, following the monorepo repository
1878
- * convention (versioned interface, AsyncDisposable, one backend per
1879
- * platform — see the Boltz plugin's SwapRepository). Consumers construct
1880
- * exactly one of these; there is no second storage seam.
1908
+ * convention: versioned interface, AsyncDisposable, one backend per platform.
1909
+ * Consumers construct exactly one of these; there is no second storage seam.
1881
1910
  *
1882
1911
  * Durable records (swaps) and rebuildable state (the restore scan's txid
1883
1912
  * cursor, the markets cache) live side by side because they share a
@@ -1885,8 +1914,7 @@ interface MarketsCacheEntry {
1885
1914
  * that wipes one wants all three gone.
1886
1915
  *
1887
1916
  * ponytail: no query filters — every consumer reads all swaps and filters
1888
- * in memory; mirror the Boltz plugin's GetSwapsFilter when a consumer needs
1889
- * subset queries.
1917
+ * in memory; add a filter type when a consumer needs subset queries.
1890
1918
  */
1891
1919
  interface AssetSwapRepository extends AsyncDisposable {
1892
1920
  /** 4 adds `getRfqSwap`. 3 added the other RFQ methods below; 2 was the
@@ -1953,4 +1981,4 @@ declare class InMemoryAssetSwapRepository implements AssetSwapRepository {
1953
1981
  [Symbol.asyncDispose](): Promise<void>;
1954
1982
  }
1955
1983
 
1956
- export { isRfqSwapTerminal as $, type AssetSwapRepository as A, BTC_ASSET_ID as B, type RfqSwapActionName as C, type RfqSwapLockup as D, RfqSwapManager as E, type RfqSwapManagerCallbacks as F, type RfqSwapManagerConfig as G, type RfqSwapManagerDeps as H, InMemoryAssetSwapRepository as I, type RfqSwapManagerEvents as J, type RfqSwapOrigin as K, type LockupVtxo as L, type MarketsCacheEntry as M, RfqSwapOriginRequired as N, type OnchainSendAction as O, type PersistableRfqSwap as P, type RfqSwapOutcome as Q, type RfqSwapRecord as R, type SwapSecretsProjection as S, type RfqSwapRecordStore as T, type SwapContractRegistry as U, addAssetSwap as V, awaitRfqResolution as W, createRfqSwapRecord as X, findLockupVtxos as Y, getAssetSwaps as Z, getAssetSwapsOrThrow as _, type AssetSwap as a, isRfqTerminal as a0, nextOnchainAction as a1, preimageForSwapRecord as a2, pushRefundWithoutReceiver as a3, readLockupFate as a4, rebuildRfqSwap as a5, refundIfUnresolved as a6, rfqSwapOriginOf as a7, shouldRetainRfqSwap as a8, swapSecretsToRecord as a9, updateAssetSwap as aa, updateAssetSwapBestEffort as ab, updateRfqSwapRecord as ac, type RefundArkProvider as b, type RefundIndexer as c, type RfqSwap as d, type ArkadeRefundResult as e, type LockupSpendIndexer as f, type RfqSwapState as g, type AssetSwapStatus as h, type AvailableRfqSwapManagerCallbacks as i, type LightningReceiveSwap as j, type LightningSendSwap as k, type LockupFate as l, LockupNeedsRecoveryError as m, type LockupParams as n, type LockupSpend as o, type OnchainSendSwap as p, type PreimageBlockedReason as q, PreimageNotRecoverableError as r, REFUND_MTP_LAG_SECONDS as s, RFQ_RESOLVED_STATES as t, RFQ_SWAP_RETENTION_SECONDS as u, RFQ_SWAP_TERMINAL_STATES as v, type RefundOutcome as w, type RfqRestoreFailure as x, type RfqRestoreOptions as y, type RfqRestoreResult as z };
1984
+ export { isRfqSwapTerminal as $, type AssetSwapRepository as A, BTC_ASSET_ID as B, type RfqRestoreOptions as C, type RfqRestoreResult as D, type RfqSwapActionName as E, type RfqSwapLockup as F, type RfqSwapManagerConfig as G, type RfqSwapManagerDeps as H, InMemoryAssetSwapRepository as I, type RfqSwapManagerEvents as J, type RfqSwapOrigin as K, type LockupVtxo as L, type MarketsCacheEntry as M, RfqSwapOriginRequired as N, type OnchainSendAction as O, type PersistableRfqSwap as P, type RfqSwapOutcome as Q, type RfqSwapRecord as R, type SwapSecretsProjection as S, type RfqSwapRecordStore as T, type SwapContractRegistry as U, addAssetSwap as V, awaitRfqResolution as W, createRfqSwapRecord as X, findLockupVtxos as Y, getAssetSwaps as Z, getAssetSwapsOrThrow as _, type AssetSwap as a, isRfqTerminal as a0, nextOnchainAction as a1, normalizeRfqSwapRecord as a2, preimageForSwapRecord as a3, pushRefundWithoutReceiver as a4, readLockupFate as a5, rebuildRfqSwap as a6, refundIfUnresolved as a7, rfqSwapOriginOf as a8, shouldRetainRfqSwap as a9, swapSecretsToRecord as aa, updateAssetSwap as ab, updateAssetSwapBestEffort as ac, updateRfqSwapRecord as ad, type RefundIndexer as b, type SwapOperator as c, type RfqSwap as d, type ArkadeRefundResult as e, type LockupSpendIndexer as f, type RfqSwapState as g, RfqSwapManager as h, type RfqSwapManagerCallbacks as i, type AssetSwapStatus as j, type AvailableRfqSwapManagerCallbacks as k, type LightningReceiveSwap as l, type LightningSendSwap as m, type LockupFate as n, LockupNeedsRecoveryError as o, type LockupParams as p, type LockupSpend as q, type OnchainSendSwap as r, type PreimageBlockedReason as s, PreimageNotRecoverableError as t, REFUND_MTP_LAG_SECONDS as u, RFQ_RESOLVED_STATES as v, RFQ_SWAP_RETENTION_SECONDS as w, RFQ_SWAP_TERMINAL_STATES as x, type RefundOutcome as y, type RfqRestoreFailure as z };
@@ -1,4 +1,4 @@
1
- import { VHTLC, asset, IWallet, ProvisionedClaimSecret, ProvisionedKey } from '@arkade-os/sdk';
1
+ import { VHTLC, IWallet, ProvisionedClaimSecret, ProvisionedKey, asset } from '@arkade-os/sdk';
2
2
 
3
3
  /** L1 confirmation-depth and reorg margin between dependent timelocks. */
4
4
  declare const ONCHAIN_ORDER_MARGIN_SECONDS: number;
@@ -251,6 +251,10 @@ type RfqRefusalReason = "unsupported_pair" | "unsupported_payload" | "amount_out
251
251
  declare const RFQ_TERMINAL_STATES: readonly ["settled", "refused", "expired", "refunded", "stuck"];
252
252
  /** A refusal from the solver, carrying its closed-set reason. */
253
253
  declare class SwapRefusal extends Error {
254
+ /** Literal-typed so the v2 error taxonomy's union discriminates on `name`
255
+ * — a `string` here collapses the discriminant for every member. Same value
256
+ * the constructor has always set, moved to a field initializer. */
257
+ readonly name = "SwapRefusal";
254
258
  readonly reason: string;
255
259
  readonly rfqId: string | undefined;
256
260
  constructor(reason: string, rfqId?: string);
@@ -297,7 +301,7 @@ interface RfqStatus {
297
301
  /** The rfq_request for the lightning send profile. A BOLT11 profile is always
298
302
  * exact-out: the invoice fixes the amount, so none is restated here.
299
303
  * `senderPubkey` is the trader's own key for the VHTLC's sender-side leaves
300
- * (see {@link lightningSendVtxoScript}) — required, never sent anywhere else,
304
+ * (see {@link lightningSendContract}) — required, never sent anywhere else,
301
305
  * never trusted by the solver as anything but a pubkey to bind into the
302
306
  * script. On the wire it's `client_refund_pubkey` (the payload schemas are
303
307
  * public at https://docs.arkadeos.com/intents/reference/rfq — the solver's schema
@@ -416,7 +420,7 @@ declare const SOLO_REFUND_HEADROOM_SECONDS: number;
416
420
  * exit delay exactly as the reference solver derives it — both sides read the
417
421
  * SAME server, so the derivation (not a quote field) is what keeps the two
418
422
  * scripts identical. */
419
- declare const unilateralClaimDelay: (serverExitDelaySeconds: number) => number;
423
+ declare const unilateralClaimDelay: (operatorExitDelaySeconds: number) => number;
420
424
  /** VHTLC's `unilateralRefund` tier: sender + receiver, no server — LEVEL with
421
425
  * `claimDelay`, not above it. Neither party can spend a two-signature leaf
422
426
  * alone, so separating it buys no safety, and every second spent separating it
@@ -444,13 +448,13 @@ declare const unilateralRefundWithoutReceiverDelay: (claimDelay: number) => numb
444
448
  * needing no participant at all). Nine leaves in all, unless `legacy` says
445
449
  * otherwise.
446
450
  */
447
- declare function lightningSendVtxoScript(params: {
451
+ declare function lightningSendContract(params: {
448
452
  /** Binding field #1: the solver's x-only key, from the quote. */
449
453
  solverPubkey: Uint8Array;
450
454
  /** Binding field #2: when the trader's refund path opens, from the quote. */
451
455
  refundLocktime: number;
452
456
  /** The Ark server's x-only key — the trader's OWN connection. */
453
- serverPubkey: Uint8Array;
457
+ operatorPubkey: Uint8Array;
454
458
  /** BOLT11 payment hash, hex — from the trader's OWN invoice decode. */
455
459
  paymentHash: string;
456
460
  /** From {@link unilateralClaimDelay} over the trader's OWN server info.
@@ -477,9 +481,9 @@ declare function lightningSendVtxoScript(params: {
477
481
  * the quote's own address says the solver quoted that shape. */
478
482
  legacy?: "preTimelockedRefund";
479
483
  }): InstanceType<typeof VHTLC.ScriptV2>;
480
- /** Every input {@link lightningSendVtxoScript} builds from. Derived from the
484
+ /** Every input {@link lightningSendContract} builds from. Derived from the
481
485
  * builder rather than restated, so the two cannot drift. */
482
- type LightningSendTreeParams = Parameters<typeof lightningSendVtxoScript>[0];
486
+ type LightningSendContractParams = Parameters<typeof lightningSendContract>[0];
483
487
  /** The BOLT11 facts the trader read from its OWN decode — this module takes
484
488
  * the facts, not the decoder, so any wallet's existing decoder serves. */
485
489
  interface InvoiceFacts {
@@ -513,14 +517,15 @@ interface InvoiceFacts {
513
517
  * throws while nothing is funded. `RfqSwapManager` re-registers as a backstop
514
518
  * for older records; a repeat write is a no-op.
515
519
  *
516
- * The `sender` key is the wallet's identity key, reused by {@link
517
- * provisionRefundKey} — returned as `senderPubkey` plus `secrets`. `secrets`
518
- * holds only a public descriptor; the signer re-derives from the wallet, so
519
- * nothing secret is at rest. Persist `secrets` with the record anyway: it is
520
- * how the refund signer is found again. `nonInteractiveRefund` recovers the funds even without it — but it needs the SOLVER's active
521
- * cooperation, not just infrastructure uptime.
520
+ * The `sender` key is the wallet's identity key, as {@link provisionRefundKey}
521
+ * pins it — returned as `senderPubkey` plus `secrets`. `secrets` holds only a
522
+ * public descriptor; the signer re-derives from the wallet, so nothing secret
523
+ * is at rest. Persist `secrets` with the record anyway: it is how the refund
524
+ * signer is found again. `nonInteractiveRefund` recovers the funds even
525
+ * without it — but it needs the SOLVER's active cooperation, not just
526
+ * infrastructure uptime.
522
527
  */
523
- declare function requestLightningSend(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
528
+ declare function requestLightningSend(wallet: IWallet, transport: RfqTransport, params: {
524
529
  invoice: InvoiceFacts;
525
530
  rfqId?: string;
526
531
  /** Co-signer key override (33-byte compressed hex); see
@@ -553,7 +558,7 @@ declare function requestLightningSend(wallet: IWallet, arkServerUrl: string, tra
553
558
  *
554
559
  * Returned so a consumer can persist the swap without re-deriving any of
555
560
  * it. Half of these are not on the quote: `serverPubkey` and `claimDelay`
556
- * come from this wallet's own `getInfo()`, `emulatorPubkey` from a
561
+ * come from this wallet's own `getArkadeInfo()`, `emulatorPubkey` from a
557
562
  * per-network pin, `refundPkScript` from `secrets` — decoded from the
558
563
  * refund address at provisioning time, the same address this call returns
559
564
  * as `refundAddress`.
@@ -565,7 +570,7 @@ declare function requestLightningSend(wallet: IWallet, arkServerUrl: string, tra
565
570
  * `VHTLCV2ContractHandler.serializeParams(script.options)`, the shape the
566
571
  * rebuild accepts.
567
572
  */
568
- treeParams: LightningSendTreeParams;
573
+ contractParams: LightningSendContractParams;
569
574
  }>;
570
575
  /**
571
576
  * Map an arkade↔arkade quote onto `createOffer` terms. The trader takes the
@@ -648,7 +653,7 @@ declare function deriveOnchainSend(input: {
648
653
  quote: RfqQuote;
649
654
  paymentHash: string;
650
655
  payoutPubkey: Uint8Array;
651
- serverPubkey: Uint8Array;
656
+ operatorPubkey: Uint8Array;
652
657
  emulatorPubkey: Uint8Array;
653
658
  claimDelay: number;
654
659
  hrp: string;
@@ -699,7 +704,7 @@ declare function deriveOnchainSend(input: {
699
704
  * `claimOnchainFill`) before `htlc.refundLocktime`. Missing that window
700
705
  * forfeits the fill and falls back to the Arkade covenant refund.
701
706
  */
702
- declare function requestOnchainSend(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
707
+ declare function requestOnchainSend(wallet: IWallet, transport: RfqTransport, params: {
703
708
  amount: number;
704
709
  amountSide: "from" | "to";
705
710
  /** User's x-only L1 key that will claim the HTLC. */
@@ -747,6 +752,11 @@ declare function requestOnchainSend(wallet: IWallet, arkServerUrl: string, trans
747
752
  /** `profile.min_confirmations`; gates when the L1 fill becomes claimable,
748
753
  * and part of what a restored swap needs to drive its own claim. */
749
754
  minConfirmations: number;
755
+ /** The arkade lockup's refund deadline, as the covenant was built with it.
756
+ * Read this rather than `quote.refund_locktime`: that field is optional on
757
+ * the wire, a solver may carry the value in `profile` instead, and
758
+ * `deriveOnchainSend` is what settles which one this contract used. */
759
+ refundLocktime: number;
750
760
  /** The VHTLC `sender` x-only key, bound into the covenant. Public. */
751
761
  senderPubkey: Uint8Array;
752
762
  /** How the preimage and the `sender` key are recovered later — map it
@@ -813,12 +823,12 @@ declare const assertReceivable: (input: {
813
823
  maxPayAmount?: number;
814
824
  }) => void;
815
825
  /** Compile the RECEIVE-direction VHTLC: the same suite-carrying tree as {@link
816
- * lightningSendVtxoScript} with the roles inverted — the trader is the
826
+ * lightningSendContract} with the roles inverted — the trader is the
817
827
  * `receiver` (it generated `P` and claims the lockup with it), the solver is
818
828
  * the `sender` (it funds the lockup and holds the refund recourse). One
819
829
  * function shared by both receive corridors, mirroring the send legs' sharing
820
- * of `lightningSendVtxoScript`. */
821
- declare function receiveVtxoScript(params: {
830
+ * of `lightningSendContract`. */
831
+ declare function lightningReceiveContract(params: {
822
832
  /** Binding field #1: the solver's x-only key, from the quote — VHTLC's
823
833
  * `sender` role on the receive corridors. */
824
834
  solverPubkey: Uint8Array;
@@ -826,7 +836,7 @@ declare function receiveVtxoScript(params: {
826
836
  * the quote — after it the solver may reclaim an unclaimed lockup. */
827
837
  refundLocktime: number;
828
838
  /** The Ark server's x-only key — the trader's OWN connection. */
829
- serverPubkey: Uint8Array;
839
+ operatorPubkey: Uint8Array;
830
840
  /** `sha256(P)`, hex — the trader's OWN preimage hash. */
831
841
  paymentHash: string;
832
842
  /** From {@link unilateralClaimDelay} over the trader's OWN server info. */
@@ -846,9 +856,9 @@ declare function receiveVtxoScript(params: {
846
856
  /** LEGACY REBUILD ONLY — see {@link lightningSendVtxoScript}'s `legacy`. */
847
857
  legacy?: "preTimelockedRefund";
848
858
  }): InstanceType<typeof VHTLC.ScriptV2>;
849
- /** Every input {@link receiveVtxoScript} builds from; see
850
- * {@link LightningSendTreeParams}. */
851
- type LightningReceiveTreeParams = Parameters<typeof receiveVtxoScript>[0];
859
+ /** Every input {@link lightningReceiveContract} builds from; see
860
+ * {@link LightningSendContractParams}. */
861
+ type LightningReceiveContractParams = Parameters<typeof lightningReceiveContract>[0];
852
862
  /**
853
863
  * The pure core of {@link requestLightningReceive}: derive the solver-funded
854
864
  * covenant locally from the quote's binding fields plus the trader's own data
@@ -862,7 +872,7 @@ declare function deriveLightningReceive(input: {
862
872
  paymentHash: string;
863
873
  payoutPubkey: Uint8Array;
864
874
  payoutAddress: string;
865
- serverPubkey: Uint8Array;
875
+ operatorPubkey: Uint8Array;
866
876
  emulatorPubkey: Uint8Array;
867
877
  claimDelay: number;
868
878
  hrp: string;
@@ -875,7 +885,7 @@ declare function deriveLightningReceive(input: {
875
885
  refundLocktime: number;
876
886
  /** Every input the covenant was built from — see the same field on
877
887
  * `requestLightningSend`'s result for why a consumer needs them. */
878
- treeParams: LightningReceiveTreeParams;
888
+ contractParams: LightningReceiveContractParams;
879
889
  };
880
890
  /**
881
891
  * The `lightning:BTC->arkade:BTC` user flow: quote → derive the covenant
@@ -908,7 +918,7 @@ declare function deriveLightningReceive(input: {
908
918
  * Pay before `invoiceExpiresAt`: the hold-invoice window is minutes, not the
909
919
  * quote's `valid_until`.
910
920
  */
911
- declare function requestLightningReceive(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
921
+ declare function requestLightningReceive(wallet: IWallet, transport: RfqTransport, params: {
912
922
  amount: number;
913
923
  amountSide: "from" | "to";
914
924
  /** Co-signer key override (33-byte compressed hex); see
@@ -953,7 +963,7 @@ declare function requestLightningReceive(wallet: IWallet, arkServerUrl: string,
953
963
  secrets: ProvisionedClaimSecret;
954
964
  /** Every input the covenant was built from; see the same field on
955
965
  * `requestLightningSend`'s result. */
956
- treeParams: LightningReceiveTreeParams;
966
+ contractParams: LightningReceiveContractParams;
957
967
  }>;
958
968
  /**
959
969
  * The pure core of {@link requestOnchainReceive}: derive BOTH contracts
@@ -969,7 +979,7 @@ declare function deriveOnchainReceive(input: {
969
979
  payoutAddress: string;
970
980
  /** The trader's own x-only L1 key — the HTLC's refund role. */
971
981
  refundPubkey: Uint8Array;
972
- serverPubkey: Uint8Array;
982
+ operatorPubkey: Uint8Array;
973
983
  emulatorPubkey: Uint8Array;
974
984
  claimDelay: number;
975
985
  hrp: string;
@@ -997,7 +1007,7 @@ declare function deriveOnchainReceive(input: {
997
1007
  * `refundPubkey`) opens at `htlc.refundLocktime` — `buildHtlcRefund` takes it
998
1008
  * back from there.
999
1009
  */
1000
- declare function requestOnchainReceive(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
1010
+ declare function requestOnchainReceive(wallet: IWallet, transport: RfqTransport, params: {
1001
1011
  amount: number;
1002
1012
  amountSide: "from" | "to";
1003
1013
  /** Co-signer key override (33-byte compressed hex); see
@@ -1030,4 +1040,4 @@ declare function requestOnchainReceive(wallet: IWallet, arkServerUrl: string, tr
1030
1040
  secrets: ProvisionedClaimSecret;
1031
1041
  }>;
1032
1042
 
1033
- export { newRfqId as $, ARKADE_ASSET as A, arkadeAssetLeg as B, type ChainSource as C, arkadeSwapRequest as D, assertFundable as E, assertReceivable as F, awaitOnchainFill as G, type HtlcUtxo as H, type InvoiceFacts as I, buildHtlcClaim as J, buildHtlcRefund as K, LIGHTNING_BTC as L, MAX_MIN_CONFIRMATIONS as M, claimOnchainFill as N, type OnchainNetwork as O, classifyOnchainHtlc as P, deriveLightningReceive as Q, RFQ_TERMINAL_STATES as R, SOLO_REFUND_HEADROOM_SECONDS as S, deriveOnchainReceive as T, deriveOnchainSend as U, extractPreimage as V, httpTransport as W, lightningReceiveRequest as X, lightningSendRequest as Y, lightningSendVtxoScript as Z, newPreimage as _, type OnchainHtlc as a, offerTermsFromQuote as a0, onchainHtlcScript as a1, onchainReceiveRequest as a2, onchainSendRequest as a3, paymentHashOf as a4, receiveVtxoScript as a5, relayTransport as a6, requestLightningReceive as a7, requestLightningSend as a8, requestOnchainReceive as a9, requestOnchainSend as aa, rfqPair as ab, unilateralClaimDelay as ac, unilateralRefundDelay as ad, unilateralRefundWithoutReceiverDelay as ae, verifyLockupAddress as af, verifyReceiveInvoice as ag, type OnchainHtlcParams as b, ARKADE_BTC as c, AddressMismatch as d, type ChainUtxo as e, LIGHTNING_RECEIVE_PAIR as f, LIGHTNING_SEND_PAIR as g, LOCKTIME_THRESHOLD as h, type LightningReceiveTreeParams as i, type LightningSendTreeParams as j, MIN_CLAIM_WINDOW_SECONDS as k, MIN_HEADROOM_SECONDS as l, ONCHAIN_BTC as m, ONCHAIN_CLAIM_MARGIN_SECONDS as n, ONCHAIN_DUST_SATS as o, ONCHAIN_ORDER_MARGIN_SECONDS as p, ONCHAIN_RECEIVE_PAIR as q, ONCHAIN_SECONDS_PER_BLOCK as r, ONCHAIN_SEND_PAIR as s, type OnchainHtlcPhase as t, type RelaySocket as u, type RfqQuote as v, type RfqRefusalReason as w, type RfqStatus as x, type RfqTransport as y, SwapRefusal as z };
1043
+ export { lightningReceiveRequest as $, ARKADE_ASSET as A, type RfqRefusalReason as B, type ChainSource as C, type RfqStatus as D, SwapRefusal as E, arkadeAssetLeg as F, arkadeSwapRequest as G, type HtlcUtxo as H, type InvoiceFacts as I, assertFundable as J, assertReceivable as K, LIGHTNING_BTC as L, MAX_MIN_CONFIRMATIONS as M, awaitOnchainFill as N, type OnchainNetwork as O, buildHtlcClaim as P, buildHtlcRefund as Q, type RfqTransport as R, SOLO_REFUND_HEADROOM_SECONDS as S, claimOnchainFill as T, classifyOnchainHtlc as U, deriveLightningReceive as V, deriveOnchainReceive as W, deriveOnchainSend as X, extractPreimage as Y, httpTransport as Z, lightningReceiveContract as _, type OnchainHtlc as a, lightningSendContract as a0, lightningSendRequest as a1, newPreimage as a2, newRfqId as a3, offerTermsFromQuote as a4, onchainHtlcScript as a5, onchainReceiveRequest as a6, onchainSendRequest as a7, paymentHashOf as a8, relayTransport as a9, requestOnchainReceive as aa, rfqPair as ab, unilateralClaimDelay as ac, unilateralRefundDelay as ad, unilateralRefundWithoutReceiverDelay as ae, verifyLockupAddress as af, verifyReceiveInvoice as ag, type OnchainHtlcParams as b, requestLightningSend as c, requestOnchainSend as d, ARKADE_BTC as e, AddressMismatch as f, type ChainUtxo as g, LIGHTNING_RECEIVE_PAIR as h, LIGHTNING_SEND_PAIR as i, LOCKTIME_THRESHOLD as j, type LightningReceiveContractParams as k, type LightningSendContractParams as l, MIN_CLAIM_WINDOW_SECONDS as m, MIN_HEADROOM_SECONDS as n, ONCHAIN_BTC as o, ONCHAIN_CLAIM_MARGIN_SECONDS as p, ONCHAIN_DUST_SATS as q, requestLightningReceive as r, ONCHAIN_ORDER_MARGIN_SECONDS as s, ONCHAIN_RECEIVE_PAIR as t, ONCHAIN_SECONDS_PER_BLOCK as u, ONCHAIN_SEND_PAIR as v, type OnchainHtlcPhase as w, RFQ_TERMINAL_STATES as x, type RelaySocket as y, type RfqQuote as z };