@arkade-os/swap 0.1.0-rc.13 → 0.1.0-rc.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +11 -0
  2. package/dist/advanced.cjs +1028 -1006
  3. package/dist/advanced.d.cts +145 -279
  4. package/dist/advanced.d.ts +145 -279
  5. package/dist/advanced.js +14 -8
  6. package/dist/{chunk-SC3SAY3X.js → chunk-4WPDXLXH.js} +501 -271
  7. package/dist/chunk-A3SHHRX4.js +104 -0
  8. package/dist/{chunk-KRXPQQJ7.js → chunk-BBP25BWH.js} +198 -218
  9. package/dist/{chunk-ZDFMD4FA.js → chunk-RX3WPV5D.js} +356 -584
  10. package/dist/errors-BcOgFV-F.d.ts +1559 -0
  11. package/dist/errors-n6IHTG-Z.d.cts +1559 -0
  12. package/dist/index.cjs +1406 -1331
  13. package/dist/index.d.cts +69 -186
  14. package/dist/index.d.ts +69 -186
  15. package/dist/index.js +102 -158
  16. package/dist/lockupContract-B_jNbjrG.d.ts +215 -0
  17. package/dist/lockupContract-ZsftgqMc.d.cts +215 -0
  18. package/dist/node/index.cjs +61 -10
  19. package/dist/node/index.d.cts +227 -600
  20. package/dist/node/index.d.ts +227 -600
  21. package/dist/node/index.js +65 -10
  22. package/dist/nostr.cjs +11 -11
  23. package/dist/nostr.d.cts +23 -68
  24. package/dist/nostr.d.ts +23 -68
  25. package/dist/nostr.js +3 -4
  26. package/dist/offer--1zVkNsV.d.ts +261 -0
  27. package/dist/offer-DsP1q6GE.d.cts +261 -0
  28. package/dist/protocol.cjs +747 -1012
  29. package/dist/protocol.d.cts +120 -255
  30. package/dist/protocol.d.ts +120 -255
  31. package/dist/protocol.js +146 -149
  32. package/dist/repositories/realm/index.cjs +55 -11
  33. package/dist/repositories/realm/index.d.cts +18 -30
  34. package/dist/repositories/realm/index.d.ts +18 -30
  35. package/dist/repositories/realm/index.js +49 -12
  36. package/dist/repositories/sqlite/index.cjs +61 -10
  37. package/dist/repositories/sqlite/index.d.cts +7 -6
  38. package/dist/repositories/sqlite/index.d.ts +7 -6
  39. package/dist/repositories/sqlite/index.js +57 -11
  40. package/dist/repository-BY6GUQiW.d.ts +2233 -0
  41. package/dist/repository-C32GKpR5.d.cts +2233 -0
  42. package/dist/{rfq-BWE8qkV2.d.ts → rfq-60PGpQ_x.d.cts} +178 -408
  43. package/dist/{rfq-BWE8qkV2.d.cts → rfq-60PGpQ_x.d.ts} +178 -408
  44. package/dist/{watch-D8Z78RAV.d.ts → watch-Cejw5cNQ.d.cts} +12 -30
  45. package/dist/{watch-C4ReJR5z.d.cts → watch-D8uzWrHc.d.ts} +12 -30
  46. package/package.json +2 -2
  47. package/dist/chunk-U7VWWTL6.js +0 -66
  48. package/dist/errors-LXMcNhNS.d.ts +0 -2222
  49. package/dist/errors-XUs8r0LT.d.cts +0 -2222
  50. package/dist/lockupContract-BhMebZCb.d.cts +0 -650
  51. package/dist/lockupContract-CAiN97fX.d.ts +0 -650
  52. package/dist/repository-BJLuVFQ0.d.ts +0 -3436
  53. package/dist/repository-DsR3b0JJ.d.cts +0 -3436
@@ -1,56 +1,36 @@
1
- import { ProvisionedKey, ProvisionedClaimSecret, ActivityResolver, IWallet, OnchainProvider, VHTLC, Identity, Asset, PaymentRail } from '@arkade-os/sdk';
2
- import { b4 as SwapSecretsProjection, f as RfqSwapRecord, d as AssetSwapRepository, L as LockupSpendIndexer, a_ as RfqSwapState, b0 as SwapOperator, b5 as LockupContractSource, b6 as RfqSwap, b7 as ArkadeRefundResult, b8 as LockupVtxo } from './repository-BJLuVFQ0.js';
3
- export { c as AssetSwapStatus, b9 as AvailableRfqSwapManagerCallbacks, ba as BTC_ASSET_ID, bb as LightningReceiveSwap, bc as LightningSendSwap, bd as LockupFate, be as LockupNeedsRecoveryError, bf as LockupParams, bg as LockupSpend, bh as OnchainSendAction, bi as OnchainSendSwap, bj as PersistableRfqSwap, bk as PreimageBlockedReason, bl as PreimageNotRecoverableError, bm as RFQ_SWAP_RETENTION_SECONDS, bn as RefundOutcome, bo as RfqRestoreFailure, bp as RfqRestoreOptions, bq as RfqRestoreResult, b3 as RfqSwapActionName, br as RfqSwapLockup, bs as RfqSwapManager, b2 as RfqSwapManagerCallbacks, bt as RfqSwapManagerConfig, bu as RfqSwapManagerDeps, bv as RfqSwapManagerEvents, bw as RfqSwapOrigin, bx as RfqSwapOriginRequired, by as RfqSwapOutcome, a as RfqSwapRecordStore, bz as addAssetSwap, bA as awaitRfqResolution, bB as createRfqSwapRecord, bC as findLockupVtxos, bD as getAssetSwaps, bE as isRfqTerminal, bF as nextOnchainAction, bG as normalizeRfqSwapRecord, bH as preimageForSwapRecord, bI as pushRefundWithoutReceiver, bJ as readLockupFate, bK as rebuildRfqSwap, bL as refundIfUnresolved, bM as rfqSwapOriginOf, bN as shouldRetainRfqSwap, bO as swapSecretsToRecord, bP as updateAssetSwap, bQ as updateRfqSwapRecord } from './repository-BJLuVFQ0.js';
4
- import { h as OnchainNetwork, O as OnchainHtlc, g as OnchainHtlcParams, C as ChainSource, I as InvoiceFacts, e as RfqTransport, r as requestLightningSend, j as requestOnchainSend } from './rfq-BWE8qkV2.js';
5
- export { A as ARKADE_BTC, k as AddressMismatch, l as ChainUtxo, H as HtlcUtxo, m as LIGHTNING_BTC, n as LIGHTNING_RECEIVE_PAIR, o as LIGHTNING_SEND_PAIR, p as LOCKTIME_THRESHOLD, f as LightningReceiveContractParams, L as LightningSendContractParams, M as MAX_MIN_CONFIRMATIONS, q as ONCHAIN_BTC, s as ONCHAIN_CLAIM_MARGIN_SECONDS, t as ONCHAIN_DUST_SATS, u as ONCHAIN_ORDER_MARGIN_SECONDS, v as ONCHAIN_RECEIVE_PAIR, w as ONCHAIN_SECONDS_PER_BLOCK, x as ONCHAIN_SEND_PAIR, y as OnchainHtlcPhase, z as RelaySocket, R as RfqQuote, B as RfqRefusalReason, D as RfqStatus, E as arkadeAssetLeg, F as arkadeSwapRequest, G as assertArkadeFundable, J as awaitOnchainFill, K as buildHtlcClaim, N as buildHtlcRefund, P as canonicalAssetAmount, 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 lightningReceiveContract, $ as lightningReceiveRequest, a0 as lightningSendContract, a1 as lightningSendRequest, a2 as newPreimage, a3 as normalizeMakerPkScript, a4 as normalizeMakerPublicKey, a5 as onchainHtlcScript, a6 as onchainReceiveRequest, a7 as onchainSendRequest, a8 as paymentHashOf, a9 as relayTransport, aa as requestArkadeSwap, ab as requestLightningReceive, ac as requestOnchainReceive, ad as unilateralClaimDelay, ae as unilateralRefundDelay, af as unilateralRefundWithoutReceiverDelay, ag as verifyLockupAddress, ah as verifyOfferAddress, ai as verifyReceiveInvoice } from './rfq-BWE8qkV2.js';
6
- export { A as ASSET_CARRIER_SATS, d as ClaimPacketInput, F as FillFunding, e as LockupContractMissing, f as LockupContractReader, g as LockupContractWriter, N as NoSpendableDepositError, O as OFFER_PACKET_TYPE, h as Offer, i as OfferCovenantMismatchError, R as RestoreIndexer, j as SWAP_LOCKUP_CONTRACT_KIND, k as SWAP_LOCKUP_CONTRACT_LABEL, l as SWAP_LOCKUP_CONTRACT_TYPE, m as SealedClaimPacket, n as SpendKind, T as Tx, o as cancelOffer, p as classifyDepositSpend, q as classifySpend, r as createOffer, s as decodeOffer, t as encodeOffer, u as fillOffer, v as lockupContractParams, w as offerContract, x as registerLockupContract, y as restoreAssetSwaps, z as sealClaimPacket, B as spendTxidsOf, D as swapPrograms } from './lockupContract-CAiN97fX.js';
7
- import { Network, LocalCardInput, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
8
- export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-D8Z78RAV.js';
1
+ import { ProvisionedKey, ProvisionedClaimSecret, ActivityResolver, IWallet, Network, OnchainProvider, VHTLC, Identity, Asset, PaymentRail } from '@arkade-os/sdk';
2
+ import { b6 as SwapSecretsProjection, f as RfqSwapRecord, d as AssetSwapRepository, L as LockupSpendIndexer, b0 as RfqSwapState, b2 as SwapOperator, b7 as LockupContractSource, b8 as RfqSwap, b9 as ArkadeRefundResult, ba as LockupVtxo } from './repository-BY6GUQiW.js';
3
+ export { c as AssetSwapStatus, bb as AvailableRfqSwapManagerCallbacks, bc as BTC_ASSET_ID, bd as LightningReceiveSwap, be as LightningSendSwap, bf as LockupFate, bg as LockupNeedsRecoveryError, bh as LockupParams, bi as LockupSpend, bj as OnchainSendAction, bk as OnchainSendSwap, bl as PersistableRfqSwap, bm as PreimageBlockedReason, bn as PreimageNotRecoverableError, bo as RFQ_SWAP_RETENTION_SECONDS, bp as RefundOutcome, bq as RfqRestoreFailure, br as RfqRestoreOptions, bs as RfqRestoreResult, b5 as RfqSwapActionName, bt as RfqSwapLockup, bu as RfqSwapManager, b4 as RfqSwapManagerCallbacks, bv as RfqSwapManagerConfig, bw as RfqSwapManagerDeps, bx as RfqSwapManagerEvents, by as RfqSwapOrigin, bz as RfqSwapOriginRequired, bA as RfqSwapOutcome, a as RfqSwapRecordStore, bB as addAssetSwap, bC as awaitRfqResolution, bD as createRfqSwapRecord, bE as findLockupVtxos, bF as getAssetSwaps, bG as isRfqTerminal, bH as nextOnchainAction, bI as normalizeRfqSwapRecord, bJ as preimageForSwapRecord, bK as pushRefundWithoutReceiver, bL as readLockupFate, bM as rebuildRfqSwap, bN as refundIfUnresolved, bO as rfqSwapOriginOf, bP as shouldRetainRfqSwap, bQ as swapSecretsToRecord, bR as updateAssetSwap, bS as updateRfqSwapRecord } from './repository-BY6GUQiW.js';
4
+ import { h as OnchainNetwork, O as OnchainHtlc, g as OnchainHtlcParams, C as ChainSource, I as InvoiceFacts, e as RfqTransport, r as requestLightningSend, j as requestOnchainSend } from './rfq-60PGpQ_x.js';
5
+ export { A as ARKADE_BTC, k as AddressMismatch, l as ChainUtxo, H as HtlcUtxo, m as LIGHTNING_BTC, n as LIGHTNING_RECEIVE_PAIR, o as LIGHTNING_SEND_PAIR, p as LOCKTIME_THRESHOLD, f as LightningReceiveContractParams, L as LightningSendContractParams, M as MAX_MIN_CONFIRMATIONS, q as ONCHAIN_BTC, s as ONCHAIN_CLAIM_MARGIN_SECONDS, t as ONCHAIN_DUST_SATS, u as ONCHAIN_ORDER_MARGIN_SECONDS, v as ONCHAIN_RECEIVE_PAIR, w as ONCHAIN_SECONDS_PER_BLOCK, x as ONCHAIN_SEND_PAIR, y as OnchainHtlcPhase, z as RelaySocket, R as RfqQuote, B as RfqRefusalReason, D as RfqStatus, E as arkadeAssetLeg, F as arkadeSwapRequest, G as assertArkadeFundable, J as awaitOnchainFill, K as buildHtlcClaim, N as buildHtlcRefund, P as canonicalAssetAmount, 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 lightningReceiveContract, $ as lightningReceiveRequest, a0 as lightningSendContract, a1 as lightningSendRequest, a2 as newPreimage, a3 as normalizeMakerPkScript, a4 as normalizeMakerPublicKey, a5 as onchainHtlcScript, a6 as onchainReceiveRequest, a7 as onchainSendRequest, a8 as paymentHashOf, a9 as relayTransport, aa as requestArkadeSwap, ab as requestLightningReceive, ac as requestOnchainReceive, ad as unilateralClaimDelay, ae as unilateralRefundDelay, af as unilateralRefundWithoutReceiverDelay, ag as verifyLockupAddress, ah as verifyOfferAddress, ai as verifyReceiveInvoice } from './rfq-60PGpQ_x.js';
6
+ export { d as ClaimPacketInput, e as LockupContractMissing, f as LockupContractReader, g as LockupContractWriter, R as RestoreIndexer, h as SWAP_LOCKUP_CONTRACT_KIND, i as SWAP_LOCKUP_CONTRACT_LABEL, j as SWAP_LOCKUP_CONTRACT_TYPE, k as SealedClaimPacket, l as SpendKind, T as Tx, m as classifyDepositSpend, n as classifySpend, o as lockupContractParams, r as registerLockupContract, p as restoreAssetSwaps, s as sealClaimPacket, q as spendTxidsOf } from './lockupContract-B_jNbjrG.js';
7
+ import { Network as Network$1, LocalCardInput, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
8
+ export { A as ASSET_CARRIER_SATS, F as FillFunding, N as NoSpendableDepositError, O as OFFER_PACKET_TYPE, a as Offer, b as OfferCovenantMismatchError, c as cancelOffer, d as createOffer, e as decodeOffer, f as encodeOffer, g as fillOffer, o as offerContract, s as swapPrograms } from './offer--1zVkNsV.js';
9
+ export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-D8uzWrHc.js';
9
10
 
10
- /**
11
- * Which wallet key signs this leg. Stored at `profile.signer`.
12
- *
13
- * Independent of any hashlock: it feeds `senderIdentityForSwapRecord` on the
14
- * refund side, and a corridor that settles with no preimage at all still needs
15
- * it. A corridor whose leg this wallet never signs omits the key entirely — as
16
- * with everything else here, absent rather than blank.
17
- */
11
+ /** Which wallet key signs this leg, at `profile.signer`. Omitted entirely (not blank) by a corridor
12
+ * whose leg this wallet never signs. */
18
13
  interface RfqSignerProjection {
19
14
  /** Public. The wallet re-derives the signer from it; no key material is at
20
15
  * rest. */
21
16
  signingDescriptor: string;
22
17
  }
23
18
  /**
24
- * What a leg locked to a preimage records about the LOCK. Stored at
25
- * `profile.hashlock`, and absent entirely from a corridor that has none.
26
- *
27
- * `paymentHash` is identity, not capability — `lightning_send` carries one and
28
- * can never open it. The preimage fields are the capability, and only a corridor
29
- * where WE claim ever writes them: `provisionClaimSecret` produces that arm,
30
- * `provisionRefundKey` does not.
19
+ * What a preimage-locked leg records about the LOCK, at `profile.hashlock`. `paymentHash` is
20
+ * identity, not capability; the preimage fields are the capability, written only where WE claim
21
+ * (`provisionClaimSecret` produces that arm, `provisionRefundKey` does not).
31
22
  */
32
23
  type RfqHashlockProjection = Omit<SwapSecretsProjection, "signingDescriptor"> & {
33
24
  /** `sha256(P)`, hex. Not recoverable from the covenant, which binds
34
25
  * `hash160(P)`. */
35
26
  paymentHash: string;
36
27
  };
37
- /**
38
- * The composed view `preimageForSwapRecord` reads — the signer's descriptor plus
39
- * the hashlock's. **Never a stored shape**: nothing writes this object,
40
- * {@link rfqClaimSecretOf} assembles it from the two keys above, which is what
41
- * keeps the descriptor stored once.
42
- *
43
- * Structurally `SwapSecretsProjection & { paymentHash }`, which is exactly that
44
- * helper's parameter.
45
- */
28
+ /** The composed view `preimageForSwapRecord` reads. **Never a stored shape**: assembled by
29
+ * {@link rfqClaimSecretOf} from the two keys, so the descriptor is stored once. */
46
30
  type RfqClaimSecretProjection = RfqSignerProjection & RfqHashlockProjection;
47
31
  /**
48
- * The corridor-owned counterpart of `onchainSendProfile`: the one supported way
49
- * to turn a provisioned secret into stored profile keys.
50
- *
51
- * Writes what the provisioning result actually has. Omit `paymentHash` and you
52
- * get `signer` alone — which is what a non-hashlock corridor calls, and why it
53
- * never has to reach for `hashlock`.
32
+ * The one supported way to turn a provisioned secret into stored profile keys (the corridor-owned
33
+ * counterpart of `onchainSendProfile`). Without `paymentHash` it writes `signer` alone.
54
34
  */
55
35
  declare const rfqSecretsProfile: (secrets: ProvisionedKey | ProvisionedClaimSecret, paymentHash?: string) => {
56
36
  signer: RfqSignerProjection;
@@ -59,45 +39,29 @@ declare const rfqSecretsProfile: (secrets: ProvisionedKey | ProvisionedClaimSecr
59
39
  /**
60
40
  * The stored signer projection, for `senderIdentityForSwapRecord`.
61
41
  *
62
- * `undefined` ONLY when the profile carries no `signer` key — a corridor whose
63
- * leg this wallet does not sign. A `signer` that is present and unusable throws:
64
- * "this corridor has no local signer" and "this record came back corrupt" are
65
- * different answers, and `senderIdentityForSwapRecord` turns the first into a
66
- * permanent `RefundNotLocallyPossibleError("no-secrets")` the manager acts on.
67
- * Handing it a silently-emptied projection would report "no local refund is
68
- * possible" for a storage bug.
42
+ * `undefined` ONLY when no `signer` key exists (a leg this wallet does not sign). A present but
43
+ * unusable one throws: the caller turns "no local signer" into a permanent
44
+ * `RefundNotLocallyPossibleError("no-secrets")`, which must not be reported for a storage bug.
69
45
  */
70
46
  declare const rfqSignerOf: (record: RfqSwapRecord) => RfqSignerProjection | undefined;
71
47
  /**
72
- * The claim inputs, or `undefined` when this record's corridor cannot produce P
73
- * — no hashlock, or a leg we refund rather than claim.
74
- *
75
- * Answered by the corridor's handler (`claimSecret`), not by a kind list here:
76
- * whether a leg claims is the corridor's fact.
77
- *
78
- * When the handler DOES claim, this validates and throws
79
- * `PreimageNotRecoverableError("malformed-record")` rather than returning a
80
- * partial projection — which `preimageForSwapRecord` would claim with, its hash
81
- * check being conditional on the very field that went missing.
48
+ * The claim inputs, or `undefined` when the corridor's handler has no `claimSecret` (no hashlock, or
49
+ * a leg we refund). When it does claim, a malformed projection throws
50
+ * `PreimageNotRecoverableError("malformed-record")` rather than returning a partial one that
51
+ * `preimageForSwapRecord` would claim with unverified.
82
52
  */
83
53
  declare const rfqClaimSecretOf: (record: RfqSwapRecord) => RfqClaimSecretProjection | undefined;
84
54
 
85
55
  /**
86
- * `arkade:BTC->lightning:BTC`. Nothing beyond its keys and the covenant: the
87
- * solver claims the lockup, the trader's only move is the refund, and the rest
88
- * of the leg is fully described by the contract row.
89
- *
90
- * The one leg with a hashlock it can never open — P belongs to the payee — so
91
- * `hashlock` here is `{ paymentHash }` alone and `signer` holds a REFUND key.
56
+ * `arkade:BTC->lightning:BTC`. The solver claims the lockup; the trader's only move is the refund.
92
57
  *
58
+ * P belongs to the payee, so `hashlock` is `{ paymentHash }` alone and `signer` holds a REFUND key.
93
59
  */
94
60
  interface LightningSendProfile extends Record<string, unknown> {
95
61
  signer: RfqSignerProjection;
96
62
  hashlock: RfqHashlockProjection;
97
63
  }
98
- /** `lightning:BTC->arkade:BTC`.
99
- *
100
- */
64
+ /** `lightning:BTC->arkade:BTC`. */
101
65
  interface LightningReceiveProfile extends Record<string, unknown> {
102
66
  signer: RfqSignerProjection;
103
67
  hashlock: RfqHashlockProjection;
@@ -108,19 +72,12 @@ interface LightningReceiveProfile extends Record<string, unknown> {
108
72
  /**
109
73
  * Our Arkade claim's txid, once submitted.
110
74
  *
111
- * Here rather than on the record's common half, which is for fields all
112
- * three legs carry: this one is the receive leg's alone, the counterpart of
113
- * the onchain leg's `claimTxid`. Restoring without it re-arms the value gate
114
- * against a lockup we have already partly claimed — `claimIfFunded` reads
115
- * `partiallyClaimed` off exactly this — so the remainder is refused over a
116
- * preimage that is already public, and a swap that did claim is relabelled
117
- * `needs_counterparty` once its window shuts.
75
+ * `claimIfFunded` derives `partiallyClaimed` from this. Restoring without it re-arms the value
76
+ * gate against a partly claimed lockup, refusing the remainder over an already-public preimage.
118
77
  */
119
78
  claimTxid?: string;
120
79
  }
121
- /** `arkade:BTC->onchain:BTC`.
122
- *
123
- */
80
+ /** `arkade:BTC->onchain:BTC`. */
124
81
  interface OnchainSendProfile extends Record<string, unknown> {
125
82
  signer: RfqSignerProjection;
126
83
  hashlock: RfqHashlockProjection;
@@ -133,17 +90,12 @@ interface OnchainSendProfile extends Record<string, unknown> {
133
90
  htlcLocktime: number;
134
91
  network: OnchainNetwork;
135
92
  /**
136
- * The L1 address the fill was expected at — `htlc.address` from
137
- * `requestOnchainSend`, which `deriveOnchainSend` has already checked
138
- * against the quote's own `profile.htlc_address`.
93
+ * The L1 address the fill was expected at (`htlc.address`, already checked against the quote's
94
+ * `profile.htlc_address`).
139
95
  *
140
- * The counterpart of the record's `lockupAddress`, and here for the same
141
- * reason: the inputs above and this address reach the record by independent
142
- * routes, so requiring the rebuild to reproduce it is what catches a
143
- * parameter that came back wrong. The arkade lockup gets that check from
144
- * `rebuildRfqSwap`; this leg, the one whose parameters have no second source
145
- * anywhere, would otherwise get none — and a swapped or corrupted key
146
- * derives another perfectly valid HTLC, at an address nobody funded.
96
+ * Stored independently of the keys so the rebuild must reproduce it: a swapped or corrupted
97
+ * key derives another valid HTLC at an address nobody funded, and this leg has no contract row
98
+ * to catch that.
147
99
  */
148
100
  htlcAddress: string;
149
101
  /** `profile.min_confirmations`; gates when the fill is claimable. */
@@ -162,30 +114,12 @@ interface OnchainSendProfile extends Record<string, unknown> {
162
114
  claimTxid?: string;
163
115
  }
164
116
  /**
165
- * Build the profile from what `requestOnchainSend` returned.
166
- *
167
- * Pass the whole result: every field this needs is on it, so the mapping is
168
- * done here, once, instead of at each call site.
169
- *
170
- * That mapping is the reason this exists. `htlcParams.refundLocktime` becomes
171
- * `htlcLocktime` — the same value under a different name, because the record
172
- * already has a `refundLocktime` and it is the arkade lockup's, a different
173
- * deadline entirely. The keys go from bytes to hex. `htlcAddress` is not an
174
- * input to anything, it is the derived value the rebuild checks the inputs
175
- * against, so writing it is easy to skip and impossible to reconstruct later.
176
- * A caller copying fields across by hand gets all three right or restores a
177
- * swap that watches nothing.
178
- *
179
- * The other two corridors have no such builder, deliberately: their profiles
180
- * are the request result's own fields under their own names, with nothing
181
- * derived and nothing renamed.
182
- *
183
- * The L1 half ONLY. `signer` and `hashlock` come from `rfqSecretsProfile`, which
184
- * every corridor calls — folding them in here would give this leg a one-call
185
- * mapper the other two cannot have, and the uniform rule ("`rfqSecretsProfile`
186
- * first, then whatever the corridor adds") is what keeps the per-corridor
187
- * instructions short enough to follow.
117
+ * Build the profile's L1 half from what `requestOnchainSend` returned.
188
118
  *
119
+ * Exists because the mapping is easy to get wrong by hand: `htlcParams.refundLocktime` becomes
120
+ * `htlcLocktime` (the record's `refundLocktime` is the arkade lockup's), keys go bytes to hex, and
121
+ * `htlcAddress` is a derived check value that is easy to skip and impossible to reconstruct.
122
+ * `signer` and `hashlock` still come from `rfqSecretsProfile`, as for every corridor.
189
123
  */
190
124
  declare function onchainSendProfile(result: {
191
125
  htlc: Pick<OnchainHtlc, "address">;
@@ -198,12 +132,8 @@ declare function onchainSendProfile(result: {
198
132
 
199
133
  /**
200
134
  * One swap, flattened to what grouping needs: an identity, a corridor, an
201
- * outcome, and every Arkade transaction that belongs to it.
202
- *
203
- * Deliberately not a stored swap record itself — resolution should stay
204
- * testable with plain data rather than a repository. {@link rfqSwapActivityInputs}
205
- * derives these from the record store and, where a record cannot answer, the
206
- * funding lockup's VTXOs.
135
+ * outcome, and every Arkade transaction that belongs to it. Plain data, not a stored record, so
136
+ * resolution is testable without a repository.
207
137
  */
208
138
  interface SwapActivityInput {
209
139
  rfqId: string;
@@ -215,13 +145,9 @@ interface SwapActivityInput {
215
145
  /**
216
146
  * Group each RFQ swap's transactions into one activity carrying its outcome.
217
147
  *
218
- * Without this a failed swap renders as two unrelated rows: the send that
219
- * funded the lockup, and the receive when the covenant refunds. Grouping by
220
- * `rfqId` collapses them into one activity, and the amount comes out correct
221
- * by netting, not by `buildActivities`'s same-key change exclusion — that
222
- * rule only fires when one txid is both sent and received, and funding and
223
- * refund are different txids. Summing the signed amounts
224
- * (`-funding + refund ≈ -fees`) is what does the work here.
148
+ * Without this a failed swap renders as two unrelated rows (funding send, covenant refund). The
149
+ * amount comes out right by netting signed amounts (`-funding + refund ≈ -fees`), not by
150
+ * `buildActivities`'s same-txid change exclusion, since funding and refund are different txids.
225
151
  *
226
152
  * `prepare` loads once and `resolve` stays pure and synchronous, as the SDK's
227
153
  * `ActivityResolver` contract requires.
@@ -231,15 +157,12 @@ declare function swapActivityResolver(deps: {
231
157
  }): ActivityResolver;
232
158
  /** @deprecated Read swap history with `client.swaps()`. Moved off the package root to `@arkade-os/swap/protocol`. */
233
159
  interface RfqSwapActivityDeps {
234
- repository: Pick<AssetSwapRepository, "getAllRfqSwaps">;
160
+ repository: Pick<AssetSwapRepository, "getRfqSwapsPage">;
235
161
  /**
236
162
  * Consulted only for what a record cannot answer: a record written before
237
163
  * `fundingTxid` existed, and the counterparty's spend on a swap that
238
- * ended without a refund of ours.
239
- *
240
- * Optional because the stored fields are the primary source — cheaper, and
241
- * they work offline, which is the resolver's whole posture. An indexer that
242
- * throws costs that record its extra txids and nothing else.
164
+ * ended without a refund of ours. Optional because stored fields are the primary, offline
165
+ * source; an indexer that throws costs that record its extra txids and nothing else.
243
166
  */
244
167
  indexer?: LockupSpendIndexer;
245
168
  }
@@ -247,53 +170,39 @@ interface RfqSwapActivityDeps {
247
170
  * Every stored RFQ swap, flattened into what {@link swapActivityResolver}
248
171
  * groups on.
249
172
  *
250
- * The txids come from four places, in order of preference: the record's own
251
- * `fundingTxid` and `refundTxid`, the corridor's `activityTxids` (the
252
- * receive leg's Arkade claim, the onchain leg's L1 one), and — only when the
253
- * first two cannot answer — one read of the lockup's VTXOs.
254
- *
255
- * A missing txid costs an activity a row, never a wrong one: a swap that
256
- * contributes fewer txids simply leaves those transactions ungrouped, which is
257
- * what they already are.
173
+ * Txids come from the record's `fundingTxid`/`refundTxid`, the corridor's `activityTxids`, the
174
+ * manager's `lockupSpendTxids`, and only then one lockup VTXO read. A missing txid leaves that
175
+ * transaction ungrouped, never misgrouped.
258
176
  */
259
177
  declare function rfqSwapActivityInputs(deps: RfqSwapActivityDeps): Promise<SwapActivityInput[]>;
260
178
 
261
179
  /**
262
- * The `refundArkade` callback, assembled.
180
+ * The `refundArkade` callback, assembled. Its obvious implementation, `refundIfUnresolved`, is
181
+ * wrong here: it brings its own status polling and MTP retry loop, which would nest inside the
182
+ * manager's.
263
183
  *
264
- * The wiring this replaces was prose in two places — `swapManager.ts`'s
265
- * callback doc and the README — because it is the one callback whose obvious
266
- * implementation is wrong: `refundIfUnresolved` is the single-swap version of
267
- * `RfqSwapManager` itself and brings its own status polling and MTP retry loop,
268
- * which would nest inside the manager's. Composing the atomic push here makes
269
- * that mistake something a consumer has to go out of their way to make.
270
- *
271
- * The three semantic rules the manager relies on are structural rather than
272
- * documented: an empty lockup returns `null`, and both
273
- * {@link RefundNotLocallyPossibleError} and {@link LockupNeedsRecoveryError}
274
- * propagate untouched — the manager reads the first as permanent and surfaces
275
- * the second as `needs_recovery`, and catching either here would turn a state
184
+ * An empty lockup returns `null`; {@link RefundNotLocallyPossibleError} and
185
+ * {@link LockupNeedsRecoveryError} propagate untouched, since catching either would turn a state
276
186
  * the trader must act on into a retry that grinds the window away.
277
187
  */
278
188
 
279
189
  interface ArkadeRefunderDeps {
280
190
  operator: SwapOperator;
281
191
  /**
282
- * The wallet's contract manager. The lockup's row must be registered in
283
- * it before this can see the funding — which is what
284
- * `RfqSwapManager.ensureRegistered` does per pass, and what
285
- * `requestLightningSend` / `requestOnchainSend` do up front. Prefer
286
- * `await wallet.getContractManager()`.
192
+ * The wallet's contract manager (prefer `await wallet.getContractManager()`). The lockup must
193
+ * be registered in it before the funding is visible.
287
194
  */
288
195
  contracts: LockupContractSource;
289
196
  /** Asked for the descriptor's signer; never asked to mint a key. */
290
197
  wallet: IWallet;
291
198
  /**
292
- * The record store. The live `RfqSwap` the manager passes carries no
293
- * `signingDescriptor` — that lives in the record's `profile.signer` — so
294
- * the refund key is resolved by key, which is what `getRfqSwap` is for.
199
+ * The record store: the live `RfqSwap` carries no `signingDescriptor` (it lives in the
200
+ * record's `profile.signer`), so the refund key is resolved through `getRfqSwap`.
295
201
  */
296
202
  repository: Pick<AssetSwapRepository, "getRfqSwap">;
203
+ /** The caller's already-resolved network, pinning the checkpoint exit-delay floor. Lazy,
204
+ * like `SwapDriveConfig.network`. @see operatorUnrollScript */
205
+ network?: () => Promise<Network>;
297
206
  }
298
207
  /**
299
208
  * Build the `refundArkade` callback for `RfqSwapManager.setCallbacks`.
@@ -312,13 +221,27 @@ declare function arkadeRefunder(deps: ArkadeRefunderDeps): (swap: RfqSwap) => Pr
312
221
  */
313
222
  declare const chainSourceFrom: (provider: OnchainProvider, network: OnchainNetwork) => ChainSource;
314
223
 
224
+ /**
225
+ * The receive corridors' completion: the trader claims the solver-funded
226
+ * lockup with its own preimage.
227
+ *
228
+ * On `lightning:BTC->arkade:BTC` and `onchain:BTC->arkade:BTC` the trader is the covenant's
229
+ * `receiver` and generated `P`, so the collaborative claim leaf (preimage + receiver + server) is
230
+ * spendable the moment the lockup lands, with no covclaimd. Mirror of `pushRefundWithoutReceiver`,
231
+ * except:
232
+ *
233
+ * - The preimage rides the PSBT's `ConditionWitness`, attached AFTER signing on the ark tx and
234
+ * every checkpoint; attaching it first yields `INVALID_SIGNATURE` (`claimWithPreimageIdentity`
235
+ * owns that ordering).
236
+ * - The leaf is NOT covenant-pinned, so one aggregate output pays wherever the trader says; the
237
+ * destination is required, defaulting honestly to the swap's payout address.
238
+ */
239
+
315
240
  /**
316
241
  * The lockup is funded for less than the swap agreed.
317
242
  *
318
- * The attack this names: the solver funds the correctly derived script with
319
- * dust. Deriving the script locally — what protects every other corridor —
320
- * proves nothing here, because the script was never the lie. Claiming anyway
321
- * publishes `P`, which is what lets the solver settle the payer's Lightning
243
+ * The attack: the solver funds the correctly derived script with dust, so local script derivation
244
+ * proves nothing. Claiming anyway publishes `P`, letting the solver settle the payer's Lightning
322
245
  * HTLC in full.
323
246
  *
324
247
  * @deprecated The claim path is internal to the drive; watch it with `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
@@ -331,80 +254,49 @@ declare class LockupAmountMismatchError extends Error {
331
254
  constructor(expectedAmount: number, lockedAmount: number);
332
255
  }
333
256
  /**
334
- * Build, sign, and push the collaborative claim of a receive-corridor lockup:
335
- * move every funded output at the lockup to the trader's own destination,
336
- * revealing `P` in the witness — which is also what settles the trader's side
337
- * of the swap (the solver reads `P` off the public claim).
338
- *
339
- * The preimage is checked against the script's committed hash BEFORE anything
340
- * is signed: a wrong value can never open the leaf, and catching it here
341
- * beats learning it from the server's rejection.
342
- *
343
- * So is the funded VALUE, against `expectedAmount` — and for the same reason,
344
- * only more sharply: disclosure happens at SUBMIT, since `P` rides the PSBT to
345
- * the Ark server. A check that waits for the transaction to land has already
346
- * leaked the secret.
347
- *
348
- * Swept outputs are refused, not attempted, exactly as in
349
- * {@link pushRefundWithoutReceiver} — one aggregate transaction means a
350
- * single non-live input would take the live ones down with it. That refusal
351
- * comes first, which is what leaves the value gate a plain sum over live
352
- * outputs.
353
- *
354
- * The server's countersignature is verified before finalizing, per input and
355
- * against that input's own leaf. It does not protect `P` — that reached the
356
- * server at submit — but it turns "reported claimed, nothing landed, the
357
- * solver refunds hours later" into an immediate failure.
257
+ * Build, sign, and push the collaborative claim of a receive-corridor lockup, moving every funded
258
+ * output to the trader's destination and revealing `P` (the solver reads it off the claim).
358
259
  *
260
+ * Preimage and funded VALUE are checked BEFORE signing: `P` reaches the operator at SUBMIT, so a
261
+ * later check has already leaked it. Swept outputs are refused first (one non-live input would sink
262
+ * the aggregate tx). The server countersignature is verified per input, so "reported claimed,
263
+ * nothing landed" fails immediately.
359
264
  */
360
265
  declare function pushClaim(operator: SwapOperator, input: {
361
266
  /** The receive-direction covenant (see `lightningReceiveContract`). */
362
267
  contract: InstanceType<typeof VHTLC.ScriptV2>;
363
- /** The trader's `receiver` signer. Build it from the swap's `secrets`
364
- * with `contractSigner` — on an HD wallet that resolves
365
- * from the seed, with no stored key bytes anywhere. */
268
+ /** The trader's `receiver` signer, built from the swap's `secrets` with `contractSigner`. */
366
269
  receiver: Identity;
367
270
  /** `P`, 32 bytes — the trader generated it at request time. */
368
271
  preimage: Uint8Array;
369
272
  vtxos: readonly LockupVtxo[];
370
273
  /** Where the claimed sats land — the swap's payout address, decoded. */
371
274
  destinationPkScript: Uint8Array;
372
- /** What the lockup must carry: the quote's `to_amount`, captured at
373
- * REQUEST time and persisted with the record. Required rather than
374
- * optional, so the guard cannot be skipped by the records that need
375
- * it most. */
275
+ /** What the lockup must carry: the quote's `to_amount`, captured at REQUEST time and
276
+ * persisted. Required so the guard cannot be skipped. */
376
277
  expectedAmount: number;
377
278
  /** Set when this lockup already carries a claim of ours: `P` is public
378
279
  * by then, so the value gate protects nothing and would only strand
379
280
  * the remainder. */
380
281
  partiallyClaimed?: boolean;
282
+ /** @see operatorUnrollScript */
283
+ network?: Network;
381
284
  }): Promise<{
382
285
  txid: string;
383
286
  amount: number;
384
287
  }>;
385
- /**
386
- * Wait for the solver-funded lockup to appear at the covenant script.
387
- *
388
- * Same conventions as `awaitRfqResolution`: a `pollMs` interval, an optional
389
- * unix-seconds `deadline`, and a thrown error carrying a stable `reason` when
390
- * the deadline passes.
391
- */
288
+ /** Wait for the solver-funded lockup to appear at the covenant script; past the unix-seconds
289
+ * `deadline`, throws with reason `lockup_timeout`. */
392
290
  declare function awaitLockupFunding(contracts: LockupContractSource, swapPkScript: Uint8Array, options?: {
393
291
  pollMs?: number;
394
292
  deadline?: number;
395
293
  }): Promise<readonly LockupVtxo[]>;
396
294
  /**
397
- * The one-call composition: wait for the solver's funding, then push the
398
- * claim. The polling deadline gates the WAIT only — once the lockup is
399
- * funded, the claim itself is gated by nothing but the solver's own refund
400
- * deadline (`refund_locktime` from the quote), which is the number the
401
- * caller's deadline should be measured against.
295
+ * The one-call composition: wait for the solver's funding, then push the claim. The deadline gates
296
+ * the WAIT only; once funded, the claim is bounded by the quote's `refund_locktime`.
402
297
  *
403
- * The wait returns on the first output seen, so a funding the indexer
404
- * surfaces piecemeal reaches {@link pushClaim}'s value gate short and throws
405
- * {@link LockupAmountMismatchError}. Nothing was signed, so retrying once the
406
- * rest lands is safe — and that is also the answer to a genuinely underfunded
407
- * lockup, which never gets past the gate at all.
298
+ * The wait returns on the first output seen, so piecemeal funding can throw
299
+ * {@link LockupAmountMismatchError}. Nothing was signed, so retrying once the rest lands is safe.
408
300
  */
409
301
  declare function claimReceiveLockup(contracts: LockupContractSource, operator: SwapOperator, input: Parameters<typeof pushClaim>[1] & {
410
302
  /** The covenant's scriptPubKey, from the request flow's `swapPkScript`. */
@@ -419,18 +311,9 @@ declare function claimReceiveLockup(contracts: LockupContractSource, operator: S
419
311
  /**
420
312
  * Quoting: solver discovery and the pricing guardrails around a plan.
421
313
  *
422
- * The user side of a swap — the layer that works out what one would cost
423
- * before `offer` commits to it. This is request-for-quote like every other
424
- * Arkade Intents corridor; what is specific here is that the quote resolves
425
- * client-side, from the market card the solver publishes (its price feed and
426
- * its fee) rather than over a relay roundtrip. The card commits a solver to a
427
- * price; only a fill commits it to this swap, so nothing here is signed and no
428
- * inventory is reserved.
429
- *
430
- * Relay-negotiated quotes are where every corridor converges, this one
431
- * included. What stays specific to intra-Arkade is the settlement covenant,
432
- * not the negotiation. See the README's Roles section for why this package
433
- * says user and solver rather than maker and taker.
314
+ * The quote resolves client-side from the solver's published market card (price feed
315
+ * and fee), not over a relay round trip. The card commits a solver to a price; only a
316
+ * fill commits it to this swap, so nothing here is signed and no inventory is reserved.
434
317
  */
435
318
 
436
319
  /** Shared quote options so every quote path agrees.
@@ -440,26 +323,20 @@ declare function claimReceiveLockup(contracts: LockupContractSource, operator: S
440
323
  declare const QUOTE_OPTIONS: {
441
324
  readonly safetyBps: 0;
442
325
  };
443
- /** Feed fetcher with a short per-URL TTL cache. A quote UI refetches the
444
- * market's price feed on every debounced keystroke, and public feeds
445
- * (CoinGecko) rate-limit that burst hard enough that big amounts reliably die
446
- * as "Quote unavailable" mid-typing — one feed value per TTL window is fresh
447
- * enough for a preview whose rate is re-checked at fill anyway.
326
+ /** Feed fetcher with a short per-URL TTL cache: a quote UI refetches the feed on every
327
+ * debounced keystroke, and public feeds (CoinGecko) rate-limit that burst. The rate is
328
+ * re-checked at fill anyway.
448
329
  * ponytail: no stale-serve when the fetch itself fails; add one if feeds
449
330
  * flake beyond the TTL window (cap the staleness — the feed value becomes
450
331
  * the covenant floor, so an old price must never price a real offer).
451
- * Keyed on the request URL, so it assumes a market's feed URL is stable and
452
- * amount-invariant (true today); a cache-busting nonce would silently make it
453
- * a no-op — the flat-feedCalls swap test guards against that regressing.
332
+ * Assumes a market's feed URL is stable and amount-invariant; a cache-busting nonce
333
+ * would silently make this a no-op (guarded by the flat-feedCalls swap test).
454
334
  */
455
335
  declare const makeCachedFeedFetch: (ttlMs?: number, fetchImpl?: typeof fetch) => typeof fetch;
456
336
  interface DiscoverMarketsOptions {
457
- network: Network;
458
- /** Overrides the registry this network publishes by default. Omit (or pass
459
- * `undefined`) to follow `@arkade-os/solver-discovery`'s per-network
460
- * default index, which the library can move in a release without a client
461
- * change; this package never hardcodes the URL. The markets cache is keyed
462
- * by the URL actually followed, default included. */
337
+ network: Network$1;
338
+ /** Overrides the network's default registry. `undefined` follows
339
+ * `@arkade-os/solver-discovery`'s per-network default (never hardcoded here). */
463
340
  registryUrl: string | undefined;
464
341
  /** Backs the 1-hour markets cache and its stale fallback. Omit for a
465
342
  * one-shot discovery that always hits the registry. */
@@ -473,17 +350,13 @@ interface DiscoverMarketsOptions {
473
350
  * own fetchImpl with an AbortSignal; add one if a hung registry ever
474
351
  * strands discovery in practice. */
475
352
  fetchImpl?: typeof fetch;
476
- /** `false` forces a refetch past a fresh cache (a user-triggered reload).
477
- * It does not disable the stale-cache fallback: an unreachable registry
478
- * still serves the last known markets rather than none. */
353
+ /** `false` forces a refetch past a fresh cache. The stale-cache fallback for an
354
+ * unreachable registry still applies. */
479
355
  useCache?: boolean;
480
356
  }
481
357
  /**
482
- * Markets from this network's solver registry — the caller's `registryUrl` when
483
- * given, else the network's published default. Only an unrecognised network
484
- * yields []. Registry content changes rarely, so results are cached for an hour
485
- * and a stale cache backstops an unreachable registry (quotes stay live either
486
- * way).
358
+ * Markets from this network's solver registry, cached for an hour, with a stale cache
359
+ * backstopping an unreachable registry. Only an unrecognised network yields [].
487
360
  */
488
361
  declare const discoverMarkets: (options: DiscoverMarketsOptions) => Promise<DiscoveredMarket[]>;
489
362
  /** Best market for a from/to pair, in either orientation. `give` is the side
@@ -666,12 +539,8 @@ declare const solverOnchainRendezvous: (markets: DiscoveredMarket[], amountSats:
666
539
  declare function solverOnchainRail(deps: SolverOnchainRailDeps): PaymentRail;
667
540
 
668
541
  /**
669
- * Why a wallet cannot produce a swap's spending key.
670
- *
671
- * A swap-lifecycle concern, not a key-provisioning one — which is why it
672
- * lives here and not in the SDK: `RfqSwapManager` reads it to decide a refund
673
- * is impossible rather than merely failing, and stops grinding against a push
674
- * that can never work for the whole refund window.
542
+ * Why a wallet cannot produce a swap's spending key. `RfqSwapManager` reads this to treat a
543
+ * refund as impossible rather than retryable, and stops pushing for the rest of the window.
675
544
  */
676
545
 
677
546
  /** @deprecated Recovery is internal to the drive; use `client.recover()`. Moved off the package root to `@arkade-os/swap/protocol`. */
@@ -681,10 +550,8 @@ type RefundBlockedReason =
681
550
  /** The descriptor belongs to another wallet's key. */
682
551
  | "foreign-descriptor"
683
552
  /**
684
- * This wallet holds the key but cannot sign with it — a watch-only
685
- * identity, or a remote signer that is not attached. Unlike the other two
686
- * this can stop being true without changing wallets, so it is worth
687
- * telling apart: "attach your signer", not "restore the other wallet".
553
+ * This wallet holds the key but cannot sign with it (watch-only, or remote signer not
554
+ * attached). Unlike the others it can clear without changing wallets: "attach your signer".
688
555
  */
689
556
  | "unsignable-wallet";
690
557
  /**
@@ -701,10 +568,8 @@ declare class RefundNotLocallyPossibleError extends Error {
701
568
  /**
702
569
  * The signer for a swap record's `signingDescriptor`, or a typed refusal.
703
570
  *
704
- * **Wire `refundArkade` here, not to `contractSigner` directly.** The SDK
705
- * answers about a descriptor; only this knows that a record without one is a
706
- * permanent refusal rather than a `TypeError` at the push site — which the
707
- * manager would treat as retryable.
571
+ * **Wire `refundArkade` here, not to `contractSigner` directly**: a record without a descriptor
572
+ * must be a permanent refusal, not a `TypeError` the manager would retry.
708
573
  */
709
574
  declare function senderIdentityForSwapRecord(wallet: IWallet, record: {
710
575
  signingDescriptor?: string;