@arkade-os/swap 0.1.0-rc.9 → 0.1.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.
Files changed (57) hide show
  1. package/README.md +261 -252
  2. package/dist/advanced.cjs +6376 -3097
  3. package/dist/advanced.d.cts +325 -282
  4. package/dist/advanced.d.ts +325 -282
  5. package/dist/advanced.js +343 -34
  6. package/dist/chunk-A3SHHRX4.js +104 -0
  7. package/dist/chunk-FMRAV77W.js +3065 -0
  8. package/dist/{chunk-NS3K6BZG.js → chunk-HRMWBULL.js} +1746 -628
  9. package/dist/chunk-WKJFXXSR.js +3382 -0
  10. package/dist/index.cjs +6809 -3915
  11. package/dist/index.d.cts +71 -243
  12. package/dist/index.d.ts +71 -243
  13. package/dist/index.js +131 -167
  14. package/dist/lockupContract-D7BNjksX.d.ts +148 -0
  15. package/dist/lockupContract-G-9CNRMq.d.cts +148 -0
  16. package/dist/node/index.cjs +61 -10
  17. package/dist/node/index.d.cts +307 -635
  18. package/dist/node/index.d.ts +307 -635
  19. package/dist/node/index.js +65 -10
  20. package/dist/nostr.cjs +427 -49
  21. package/dist/nostr.d.cts +59 -70
  22. package/dist/nostr.d.ts +59 -70
  23. package/dist/nostr.js +268 -36
  24. package/dist/offer-CcJfx5Fj.d.cts +269 -0
  25. package/dist/offer-DdB1M6FZ.d.ts +269 -0
  26. package/dist/offerFillPlan-BII0PW92.d.cts +1642 -0
  27. package/dist/offerFillPlan-CNTLVD7j.d.ts +1642 -0
  28. package/dist/protocol.cjs +5650 -4280
  29. package/dist/protocol.d.cts +258 -328
  30. package/dist/protocol.d.ts +258 -328
  31. package/dist/protocol.js +200 -224
  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-DmPzpbd7.d.ts +2342 -0
  41. package/dist/repository-DqdLVrVv.d.cts +2342 -0
  42. package/dist/{rfq-BO6o7NwS.d.ts → rfq-C0tHOvn6.d.cts} +323 -444
  43. package/dist/{rfq-BO6o7NwS.d.cts → rfq-C0tHOvn6.d.ts} +323 -444
  44. package/dist/watch-BonYT9af.d.cts +74 -0
  45. package/dist/watch-CmJQDtsy.d.ts +74 -0
  46. package/package.json +10 -10
  47. package/dist/chunk-JFKGMPMH.js +0 -3456
  48. package/dist/chunk-LLG7RD2T.js +0 -1499
  49. package/dist/chunk-U7VWWTL6.js +0 -66
  50. package/dist/errors-CNISbN0M.d.ts +0 -2218
  51. package/dist/errors-DwNhIP0N.d.cts +0 -2218
  52. package/dist/lockupContract-C8-Mcg69.d.ts +0 -664
  53. package/dist/lockupContract-mIt4syse.d.cts +0 -664
  54. package/dist/repository-CGPLbjBe.d.ts +0 -3489
  55. package/dist/repository-DSGGq0ct.d.cts +0 -3489
  56. package/dist/watch-DWyVqyEN.d.cts +0 -96
  57. package/dist/watch-DmvHNX6T.d.ts +0 -96
@@ -1,64 +1,37 @@
1
- import { ProvisionedKey, ProvisionedClaimSecret, ActivityResolver, IWallet, OnchainProvider, VHTLC, Identity, Asset, PaymentRail } from '@arkade-os/sdk';
2
- import { b3 as SwapSecretsProjection, d as RfqSwapRecord, c as AssetSwapRepository, L as LockupSpendIndexer, aZ as RfqSwapState, a$ as SwapOperator, b4 as RefundIndexer, b5 as RfqSwap, b6 as ArkadeRefundResult, b7 as LockupVtxo } from './repository-DSGGq0ct.cjs';
3
- export { e as AssetSwapStatus, b8 as AvailableRfqSwapManagerCallbacks, b9 as BTC_ASSET_ID, ba as LightningReceiveSwap, bb as LightningSendSwap, bc as LockupFate, bd as LockupNeedsRecoveryError, be as LockupParams, bf as LockupSpend, bg as OnchainSendAction, bh as OnchainSendSwap, bi as PersistableRfqSwap, bj as PreimageBlockedReason, bk as PreimageNotRecoverableError, bl as RFQ_SWAP_RETENTION_SECONDS, bm as RefundOutcome, bn as RfqRestoreFailure, bo as RfqRestoreOptions, bp as RfqRestoreResult, b2 as RfqSwapActionName, bq as RfqSwapLockup, br as RfqSwapManager, b1 as RfqSwapManagerCallbacks, bs as RfqSwapManagerConfig, bt as RfqSwapManagerDeps, bu as RfqSwapManagerEvents, bv as RfqSwapOrigin, bw as RfqSwapOriginRequired, bx as RfqSwapOutcome, a as RfqSwapRecordStore, by as addAssetSwap, bz as awaitRfqResolution, bA as createRfqSwapRecord, bB as findLockupVtxos, bC as getAssetSwaps, bD as isRfqTerminal, bE as nextOnchainAction, bF as normalizeRfqSwapRecord, bG as preimageForSwapRecord, bH as pushRefundWithoutReceiver, bI as readLockupFate, bJ as rebuildRfqSwap, bK as refundIfUnresolved, bL as rfqSwapOriginOf, bM as shouldRetainRfqSwap, bN as swapSecretsToRecord, bO as updateAssetSwap, bP as updateRfqSwapRecord } from './repository-DSGGq0ct.cjs';
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-BO6o7NwS.cjs';
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 awaitOnchainFill, J as buildHtlcClaim, K as buildHtlcRefund, N as claimOnchainFill, P as classifyOnchainHtlc, Q as deriveLightningReceive, T as deriveOnchainReceive, U as deriveOnchainSend, V as extractPreimage, W as httpTransport, X as l1ScriptForAddress, Y as lightningReceiveContract, Z as lightningReceiveRequest, _ as lightningSendContract, $ as lightningSendRequest, a0 as newPreimage, a1 as onchainHtlcScript, a2 as onchainReceiveRequest, a3 as onchainSendRequest, a4 as paymentHashOf, a5 as relayTransport, a6 as requestLightningReceive, a7 as requestOnchainReceive, a8 as unilateralClaimDelay, a9 as unilateralRefundDelay, aa as unilateralRefundWithoutReceiverDelay, ab as verifyLockupAddress, ac as verifyReceiveInvoice } from './rfq-BO6o7NwS.cjs';
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-mIt4syse.cjs';
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-DWyVqyEN.cjs';
1
+ import { ProvisionedKey, ProvisionedClaimSecret, RestIndexerProvider, Transaction, ActivityResolver, IWallet, Network, OnchainProvider, VHTLC, Identity, Asset, PaymentRail } from '@arkade-os/sdk';
2
+ import { bh as SwapSecretsProjection, e as RfqSwapRecord, h as AssetSwap, d as AssetSwapRepository, L as LockupSpendIndexer, bb as RfqSwapState, bd as SwapOperator, bi as LockupContractSource, bj as RfqSwap, bk as ArkadeRefundResult, bl as LockupVtxo } from './repository-DqdLVrVv.cjs';
3
+ export { c as AssetSwapStatus, bm as AvailableRfqSwapManagerCallbacks, bn as BTC_ASSET_ID, bo as LightningReceiveSwap, bp as LightningSendSwap, bq as LockupFate, br as LockupNeedsRecoveryError, bs as LockupParams, bt as LockupSpend, bu as OnchainReceiveAction, bv as OnchainReceiveNeedsChainSource, bw as OnchainReceiveSwap, bx as OnchainSendAction, by as OnchainSendSwap, bz as PersistableRfqSwap, bA as PreimageBlockedReason, bB as PreimageNotRecoverableError, bC as REFUND_MTP_LAG_SECONDS, bD as RFQ_SWAP_RETENTION_SECONDS, bE as ReceiveLockupSwap, bF as RfqRestoreFailure, bG as RfqRestoreOptions, bH as RfqRestoreResult, bg as RfqSwapActionName, bI as RfqSwapLockup, bJ as RfqSwapManager, bf as RfqSwapManagerCallbacks, bK as RfqSwapManagerConfig, bL as RfqSwapManagerDeps, bM as RfqSwapManagerEvents, bN as RfqSwapOrigin, bO as RfqSwapOriginRequired, bP as RfqSwapOutcome, a as RfqSwapRecordStore, bQ as addAssetSwap, bR as awaitRfqResolution, bS as createRfqSwapRecord, bT as findLockupVtxos, bU as getAssetSwaps, bV as isRfqTerminal, bW as nextOnchainAction, bX as nextOnchainReceiveAction, bY as normalizeRfqSwapRecord, bZ as preimageForSwapRecord, b_ as pushRefundWithoutReceiver, b$ as readLockupFate, c0 as rebuildRfqSwap, c1 as rfqSwapOriginOf, c2 as shouldRetainRfqSwap, c3 as swapSecretsToRecord, c4 as updateAssetSwap, c5 as updateRfqSwapRecord } from './repository-DqdLVrVv.cjs';
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-C0tHOvn6.cjs';
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 MIN_CLAIM_WINDOW_SECONDS, s as ONCHAIN_BTC, t as ONCHAIN_CLAIM_MARGIN_SECONDS, u as ONCHAIN_DUST_SATS, v as ONCHAIN_ORDER_MARGIN_SECONDS, w as ONCHAIN_RECEIVE_PAIR, x as ONCHAIN_SECONDS_PER_BLOCK, y as ONCHAIN_SEND_PAIR, z as OnchainHtlcPhase, B as RelaySocket, R as RfqQuote, D as RfqRefusalReason, E as RfqStatus, F as arkadeAssetLeg, G as arkadeSwapRequest, J as assertArkadeFundable, K as awaitOnchainFill, N as buildHtlcClaim, P as buildHtlcRefund, Q as canonicalAssetAmount, U as claimOnchainFill, V as classifyOnchainHtlc, W as deriveLightningReceive, X as deriveOnchainReceive, Y as deriveOnchainSend, Z as extractPreimage, _ as httpTransport, $ as l1ScriptForAddress, a0 as lightningReceiveContract, a1 as lightningReceiveRequest, a2 as lightningSendContract, a3 as lightningSendRequest, a4 as newPreimage, a5 as normalizeMakerPkScript, a6 as normalizeMakerPublicKey, a7 as onchainHtlcScript, a8 as onchainReceiveRequest, a9 as onchainSendRequest, aa as paymentHashOf, ab as relayTransport, ac as requestArkadeSwap, ad as requestLightningReceive, ae as requestOnchainReceive, af as unilateralClaimDelay, ag as unilateralRefundDelay, ah as unilateralRefundWithoutReceiverDelay, ai as verifyLockupAddress, aj as verifyOfferAddress, ak as verifyReceiveInvoice } from './rfq-C0tHOvn6.cjs';
6
+ export { d as ClaimPacketInput, e as LockupContractMissing, f as LockupContractReader, g as LockupContractWriter, h as SWAP_LOCKUP_CONTRACT_KIND, i as SWAP_LOCKUP_CONTRACT_LABEL, j as SWAP_LOCKUP_CONTRACT_TYPE, k as SealedClaimPacket, l as lockupContractParams, r as registerLockupContract, s as sealClaimPacket } from './lockupContract-G-9CNRMq.cjs';
7
+ import { Network as Network$1, LocalCardInput, TransportCardFetcher, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
8
+ import { O as Offer } from './offer-CcJfx5Fj.cjs';
9
+ export { A as ASSET_CARRIER_SATS, F as FillFunding, a as FillOutpoint, N as NoSpendableDepositError, c as OFFER_PACKET_TYPE, d as OfferCovenantMismatchError, e as cancelOffer, f as createOffer, g as decodeOffer, h as encodeOffer, i as fillOffer, o as offerContract, j as offerVtxoScript, s as swapPrograms } from './offer-CcJfx5Fj.cjs';
10
+ export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-BonYT9af.cjs';
9
11
 
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
- *
18
- * @deprecated Internal to the corridor modules; no replacement. Moved off the package root to `@arkade-os/swap/protocol`.
19
- */
12
+ /** Which wallet key signs this leg, at `profile.signer`. Omitted entirely (not blank) by a corridor
13
+ * whose leg this wallet never signs. */
20
14
  interface RfqSignerProjection {
21
15
  /** Public. The wallet re-derives the signer from it; no key material is at
22
16
  * rest. */
23
17
  signingDescriptor: string;
24
18
  }
25
19
  /**
26
- * What a leg locked to a preimage records about the LOCK. Stored at
27
- * `profile.hashlock`, and absent entirely from a corridor that has none.
28
- *
29
- * `paymentHash` is identity, not capability — `lightning_send` carries one and
30
- * can never open it. The preimage fields are the capability, and only a corridor
31
- * where WE claim ever writes them: `provisionClaimSecret` produces that arm,
32
- * `provisionRefundKey` does not.
33
- *
34
- * @deprecated Internal to the corridor modules; no replacement. Moved off the package root to `@arkade-os/swap/protocol`.
20
+ * What a preimage-locked leg records about the LOCK, at `profile.hashlock`. `paymentHash` is
21
+ * identity, not capability; the preimage fields are the capability, written only where WE claim
22
+ * (`provisionClaimSecret` produces that arm, `provisionRefundKey` does not).
35
23
  */
36
24
  type RfqHashlockProjection = Omit<SwapSecretsProjection, "signingDescriptor"> & {
37
25
  /** `sha256(P)`, hex. Not recoverable from the covenant, which binds
38
26
  * `hash160(P)`. */
39
27
  paymentHash: string;
40
28
  };
41
- /**
42
- * The composed view `preimageForSwapRecord` reads — the signer's descriptor plus
43
- * the hashlock's. **Never a stored shape**: nothing writes this object,
44
- * {@link rfqClaimSecretOf} assembles it from the two keys above, which is what
45
- * keeps the descriptor stored once.
46
- *
47
- * Structurally `SwapSecretsProjection & { paymentHash }`, which is exactly that
48
- * helper's parameter.
49
- *
50
- * @deprecated Internal to the corridor modules; no replacement. Moved off the package root to `@arkade-os/swap/protocol`.
51
- */
29
+ /** The composed view `preimageForSwapRecord` reads. **Never a stored shape**: assembled by
30
+ * {@link rfqClaimSecretOf} from the two keys, so the descriptor is stored once. */
52
31
  type RfqClaimSecretProjection = RfqSignerProjection & RfqHashlockProjection;
53
32
  /**
54
- * The corridor-owned counterpart of `onchainSendProfile`: the one supported way
55
- * to turn a provisioned secret into stored profile keys.
56
- *
57
- * Writes what the provisioning result actually has. Omit `paymentHash` and you
58
- * get `signer` alone — which is what a non-hashlock corridor calls, and why it
59
- * never has to reach for `hashlock`.
60
- *
61
- * @deprecated Internal to the corridor modules; no replacement. Moved off the package root to `@arkade-os/swap/protocol`.
33
+ * The one supported way to turn a provisioned secret into stored profile keys (the corridor-owned
34
+ * counterpart of `onchainSendProfile`). Without `paymentHash` it writes `signer` alone.
62
35
  */
63
36
  declare const rfqSecretsProfile: (secrets: ProvisionedKey | ProvisionedClaimSecret, paymentHash?: string) => {
64
37
  signer: RfqSignerProjection;
@@ -67,51 +40,29 @@ declare const rfqSecretsProfile: (secrets: ProvisionedKey | ProvisionedClaimSecr
67
40
  /**
68
41
  * The stored signer projection, for `senderIdentityForSwapRecord`.
69
42
  *
70
- * `undefined` ONLY when the profile carries no `signer` key — a corridor whose
71
- * leg this wallet does not sign. A `signer` that is present and unusable throws:
72
- * "this corridor has no local signer" and "this record came back corrupt" are
73
- * different answers, and `senderIdentityForSwapRecord` turns the first into a
74
- * permanent `RefundNotLocallyPossibleError("no-secrets")` the manager acts on.
75
- * Handing it a silently-emptied projection would report "no local refund is
76
- * possible" for a storage bug.
77
- *
78
- * @deprecated Internal to the corridor modules; no replacement. Moved off the package root to `@arkade-os/swap/protocol`.
43
+ * `undefined` ONLY when no `signer` key exists (a leg this wallet does not sign). A present but
44
+ * unusable one throws: the caller turns "no local signer" into a permanent
45
+ * `RefundNotLocallyPossibleError("no-secrets")`, which must not be reported for a storage bug.
79
46
  */
80
47
  declare const rfqSignerOf: (record: RfqSwapRecord) => RfqSignerProjection | undefined;
81
48
  /**
82
- * The claim inputs, or `undefined` when this record's corridor cannot produce P
83
- * — no hashlock, or a leg we refund rather than claim.
84
- *
85
- * Answered by the corridor's handler (`claimSecret`), not by a kind list here:
86
- * whether a leg claims is the corridor's fact.
87
- *
88
- * When the handler DOES claim, this validates and throws
89
- * `PreimageNotRecoverableError("malformed-record")` rather than returning a
90
- * partial projection — which `preimageForSwapRecord` would claim with, its hash
91
- * check being conditional on the very field that went missing.
92
- *
93
- * @deprecated Internal to the corridor modules; no replacement. Moved off the package root to `@arkade-os/swap/protocol`.
49
+ * The claim inputs, or `undefined` when the corridor's handler has no `claimSecret` (no hashlock, or
50
+ * a leg we refund). When it does claim, a malformed projection throws
51
+ * `PreimageNotRecoverableError("malformed-record")` rather than returning a partial one that
52
+ * `preimageForSwapRecord` would claim with unverified.
94
53
  */
95
54
  declare const rfqClaimSecretOf: (record: RfqSwapRecord) => RfqClaimSecretProjection | undefined;
96
55
 
97
56
  /**
98
- * `arkade:BTC->lightning:BTC`. Nothing beyond its keys and the covenant: the
99
- * solver claims the lockup, the trader's only move is the refund, and the rest
100
- * of the leg is fully described by the contract row.
101
- *
102
- * The one leg with a hashlock it can never open — P belongs to the payee — so
103
- * `hashlock` here is `{ paymentHash }` alone and `signer` holds a REFUND key.
57
+ * `arkade:BTC->lightning:BTC`. The solver claims the lockup; the trader's only move is the refund.
104
58
  *
105
- * @deprecated Internal to the corridor modules; no replacement. Moved off the package root to `@arkade-os/swap/protocol`.
59
+ * P belongs to the payee, so `hashlock` is `{ paymentHash }` alone and `signer` holds a REFUND key.
106
60
  */
107
61
  interface LightningSendProfile extends Record<string, unknown> {
108
62
  signer: RfqSignerProjection;
109
63
  hashlock: RfqHashlockProjection;
110
64
  }
111
- /** `lightning:BTC->arkade:BTC`.
112
- *
113
- * @deprecated Internal to the corridor modules; no replacement. Moved off the package root to `@arkade-os/swap/protocol`.
114
- */
65
+ /** `lightning:BTC->arkade:BTC`. */
115
66
  interface LightningReceiveProfile extends Record<string, unknown> {
116
67
  signer: RfqSignerProjection;
117
68
  hashlock: RfqHashlockProjection;
@@ -122,20 +73,12 @@ interface LightningReceiveProfile extends Record<string, unknown> {
122
73
  /**
123
74
  * Our Arkade claim's txid, once submitted.
124
75
  *
125
- * Here rather than on the record's common half, which is for fields all
126
- * three legs carry: this one is the receive leg's alone, the counterpart of
127
- * the onchain leg's `claimTxid`. Restoring without it re-arms the value gate
128
- * against a lockup we have already partly claimed — `claimIfFunded` reads
129
- * `partiallyClaimed` off exactly this — so the remainder is refused over a
130
- * preimage that is already public, and a swap that did claim is relabelled
131
- * `needs_counterparty` once its window shuts.
76
+ * `claimIfFunded` derives `partiallyClaimed` from this. Restoring without it re-arms the value
77
+ * gate against a partly claimed lockup, refusing the remainder over an already-public preimage.
132
78
  */
133
79
  claimTxid?: string;
134
80
  }
135
- /** `arkade:BTC->onchain:BTC`.
136
- *
137
- * @deprecated Internal to the corridor modules; no replacement. Moved off the package root to `@arkade-os/swap/protocol`.
138
- */
81
+ /** `arkade:BTC->onchain:BTC`. */
139
82
  interface OnchainSendProfile extends Record<string, unknown> {
140
83
  signer: RfqSignerProjection;
141
84
  hashlock: RfqHashlockProjection;
@@ -148,78 +91,168 @@ interface OnchainSendProfile extends Record<string, unknown> {
148
91
  htlcLocktime: number;
149
92
  network: OnchainNetwork;
150
93
  /**
151
- * The L1 address the fill was expected at — `htlc.address` from
152
- * `requestOnchainSend`, which `deriveOnchainSend` has already checked
153
- * against the quote's own `profile.htlc_address`.
94
+ * The L1 address the fill was expected at (`htlc.address`, already checked against the quote's
95
+ * `profile.htlc_address`).
154
96
  *
155
- * The counterpart of the record's `lockupAddress`, and here for the same
156
- * reason: the inputs above and this address reach the record by independent
157
- * routes, so requiring the rebuild to reproduce it is what catches a
158
- * parameter that came back wrong. The arkade lockup gets that check from
159
- * `rebuildRfqSwap`; this leg, the one whose parameters have no second source
160
- * anywhere, would otherwise get none — and a swapped or corrupted key
161
- * derives another perfectly valid HTLC, at an address nobody funded.
97
+ * Stored independently of the keys so the rebuild must reproduce it: a swapped or corrupted
98
+ * key derives another valid HTLC at an address nobody funded, and this leg has no contract row
99
+ * to catch that.
162
100
  */
163
101
  htlcAddress: string;
164
102
  /** `profile.min_confirmations`; gates when the fill is claimable. */
165
103
  minConfirmations: number;
104
+ expectedAmount: number;
166
105
  /** Where the claim PAYS, hex. The spender's own choice, so nothing else
167
106
  * gives it back — and `buildHtlcClaim` needs it. */
168
107
  payoutPkScript: string;
169
- /** The fill's outpoint, learned on first sighting. Without it a SPENT htlc
170
- * reads as never funded — see `classifyOnchainHtlc`. */
108
+ /** The fill's outpoint and value, learned on first sighting. Without it a SPENT htlc
109
+ * reads as never funded, and no replacement claim can be signed — `classifyOnchainHtlc`. */
171
110
  funding?: {
172
111
  txid: string;
173
112
  vout: number;
113
+ amount?: number;
174
114
  };
175
115
  /** Our own L1 claim, so a restart does not re-broadcast it. */
176
116
  claimTxid?: string;
117
+ claimFeeRateSatVb?: number;
118
+ claimBroadcastAt?: number;
177
119
  }
178
120
  /**
179
- * Build the profile from what `requestOnchainSend` returned.
121
+ * Build the profile's L1 half from what `requestOnchainSend` returned.
180
122
  *
181
- * Pass the whole result: every field this needs is on it, so the mapping is
182
- * done here, once, instead of at each call site.
183
- *
184
- * That mapping is the reason this exists. `htlcParams.refundLocktime` becomes
185
- * `htlcLocktime` — the same value under a different name, because the record
186
- * already has a `refundLocktime` and it is the arkade lockup's, a different
187
- * deadline entirely. The keys go from bytes to hex. `htlcAddress` is not an
188
- * input to anything, it is the derived value the rebuild checks the inputs
189
- * against, so writing it is easy to skip and impossible to reconstruct later.
190
- * A caller copying fields across by hand gets all three right or restores a
191
- * swap that watches nothing.
192
- *
193
- * The other two corridors have no such builder, deliberately: their profiles
194
- * are the request result's own fields under their own names, with nothing
195
- * derived and nothing renamed.
196
- *
197
- * The L1 half ONLY. `signer` and `hashlock` come from `rfqSecretsProfile`, which
198
- * every corridor calls — folding them in here would give this leg a one-call
199
- * mapper the other two cannot have, and the uniform rule ("`rfqSecretsProfile`
200
- * first, then whatever the corridor adds") is what keeps the per-corridor
201
- * instructions short enough to follow.
202
- *
203
- * @deprecated Internal to the corridor modules; no replacement. Moved off the package root to `@arkade-os/swap/protocol`.
123
+ * Exists because the mapping is easy to get wrong by hand: `htlcParams.refundLocktime` becomes
124
+ * `htlcLocktime` (the record's `refundLocktime` is the arkade lockup's), keys go bytes to hex, and
125
+ * `htlcAddress` is a derived check value that is easy to skip and impossible to reconstruct.
126
+ * `signer` and `hashlock` still come from `rfqSecretsProfile`, as for every corridor.
204
127
  */
205
128
  declare function onchainSendProfile(result: {
206
129
  htlc: Pick<OnchainHtlc, "address">;
207
130
  htlcParams: OnchainHtlcParams;
208
131
  l1Network: OnchainNetwork;
209
132
  minConfirmations: number;
133
+ expectedAmount: number;
210
134
  payoutPkScript: Uint8Array;
211
135
  }): Omit<OnchainSendProfile, "signer" | "hashlock">;
136
+ /** `onchain:BTC->arkade:BTC`: a receive Arkade half and a send L1 half, L1 key roles swapped. */
137
+ interface OnchainReceiveProfile extends Record<string, unknown> {
138
+ signer: RfqSignerProjection;
139
+ hashlock: RfqHashlockProjection;
140
+ /** The quote's `to_amount`, captured at REQUEST time. */
141
+ expectedAmount: number;
142
+ payoutAddress: string;
143
+ claimTxid?: string;
144
+ /** The SOLVER's L1 key; `refundKey` is the TRADER's own. */
145
+ claimKey: string;
146
+ refundKey: string;
147
+ /** The wallet descriptor {@link refundKey} came from, when the wallet provisioned it; the
148
+ * client's default refund signs through it. */
149
+ refundDescriptor?: string;
150
+ /** The trader's L1 deadline, not the lockup's. */
151
+ htlcLocktime: number;
152
+ network: OnchainNetwork;
153
+ htlcAddress: string;
154
+ minConfirmations: number;
155
+ /** Where the L1 REFUND pays, hex — nothing else gives it back. */
156
+ refundPkScript: string;
157
+ funding?: {
158
+ txid: string;
159
+ vout: number;
160
+ };
161
+ }
162
+ /** The L1 half of what `requestOnchainReceive` returned. Exists for
163
+ * {@link onchainSendProfile}'s reason: `refundLocktime` becomes `htlcLocktime`,
164
+ * the record's own being the lockup's. */
165
+ declare function onchainReceiveProfile(result: {
166
+ htlc: Pick<OnchainHtlc, "address">;
167
+ htlcParams: OnchainHtlcParams;
168
+ l1Network: OnchainNetwork;
169
+ minConfirmations: number;
170
+ refundPkScript: Uint8Array;
171
+ refundDescriptor?: string;
172
+ }): Omit<OnchainReceiveProfile, "signer" | "hashlock" | "expectedAmount" | "payoutAddress" | "claimTxid">;
212
173
 
213
174
  /**
214
- * One swap, flattened to what grouping needs: an identity, a corridor, an
215
- * outcome, and every Arkade transaction that belongs to it.
175
+ * The subset of a wallet transaction record the swap scan reads. No `assets`: see
176
+ * {@link classifySpend} for why a net asset delta cannot classify a spend.
177
+ */
178
+ interface Tx {
179
+ type: string;
180
+ /** The virtual (ark) txid; the funding tx's identity. */
181
+ redeemTxid: string;
182
+ boardingTxid?: string;
183
+ roundTxid?: string;
184
+ /** Unix seconds. */
185
+ createdAt?: number;
186
+ }
187
+ /** The indexer surface the restore scan needs — narrower than a full provider. */
188
+ type RestoreIndexer = Pick<RestIndexerProvider, "getVirtualTxs" | "getVtxos">;
189
+ /**
190
+ * What became of a deposit, as the spending transaction reports it. `indeterminate` is
191
+ * the absence of an answer; the caller decides whether to retry.
192
+ */
193
+ type SpendKind = "cancelled" | "fulfilled" | "indeterminate";
194
+ /**
195
+ * Classify a spend by the covenant leaf it took (a submitted ark tx keeps each input's
196
+ * `tapLeafScript`). `fulfill` is the solver paying; every other leaf returns the deposit.
197
+ * Not by asset movement: once registered, the deposit is the wallet's own coin, so an
198
+ * asset offer's cancel nets to zero exactly like its fill. Leaves also survive batching.
216
199
  *
217
- * Deliberately not a stored swap record itself — resolution should stay
218
- * testable with plain data rather than a repository. {@link rfqSwapActivityInputs}
219
- * derives these from the record store and, where a record cannot answer, the
220
- * funding lockup's VTXOs.
200
+ * **`exit` reports `cancelled`, like `cancel`.** Reporting it `indeterminate` would leave
201
+ * the swap `pending` forever: re-queued every scan, and never retired.
221
202
  *
222
- * @deprecated Read swap history with `client.swaps()`. Moved off the package root to `@arkade-os/swap/protocol`.
203
+ * **Pass the checkpoint (`vtxo.spentBy`), not the ark tx.** Only the checkpoint spends the
204
+ * deposit outpoint; the ark tx spends the checkpoint's output, so it always yields
205
+ * `indeterminate`. {@link classifyDepositSpend} tries both.
206
+ *
207
+ * @param operatorPubkey - The key the covenant was *funded* against. A rotated key fails
208
+ * the script match and yields `indeterminate` rather than a guess.
209
+ */
210
+ declare function classifySpend(offer: Offer, operatorPubkey: Uint8Array, spendTx: Transaction, deposit: {
211
+ txid: string;
212
+ vout: number;
213
+ }): SpendKind;
214
+ /** The txids that may hold a deposit's spend, checkpoint first (it carries the outpoint). */
215
+ declare const spendTxidsOf: (vtxo: {
216
+ spentBy?: string;
217
+ arkTxId?: string;
218
+ }) => string[];
219
+ /**
220
+ * Classify a deposit's spend across both halves of it (`spentBy` and `arkTxId`, which
221
+ * may be the same id for a settlement), taking the first definite answer.
222
+ */
223
+ declare function classifyDepositSpend(offer: Offer, operatorPubkey: Uint8Array, spendTxs: Iterable<Transaction>, deposit: {
224
+ txid: string;
225
+ vout: number;
226
+ }): SpendKind;
227
+ /**
228
+ * Scan the given candidates for offer packets and rebuild the AssetSwap records the store
229
+ * lost. Returns the rebuilt swaps plus the txids that got an authoritative answer, which
230
+ * the caller persists so they are never fetched again.
231
+ *
232
+ * A spent deposit is classified from its spending tx's covenant leaf
233
+ * ({@link classifySpend}), fetched from the indexer. An unclassifiable spend leaves the
234
+ * funding txid unanswered for a later scan: nothing sticky is written on a guess.
235
+ *
236
+ * @param opts.operatorPubkey - The key the covenants were funded against. A rotated key
237
+ * leaves affected swaps unresolved rather than misclassified.
238
+ */
239
+ declare function restoreAssetSwaps(indexer: RestoreIndexer, txs: Tx[], existingIds: ReadonlySet<string>, opts: {
240
+ operatorPubkey: Uint8Array;
241
+ scanned?: ReadonlySet<string>;
242
+ reopen?: AssetSwap[];
243
+ /** Address prefix; given, a rebuilt record names the covenant's address (#680). */
244
+ hrp?: string;
245
+ /** Commitment txids of recovery rounds this wallet ran (`recoverVtxos()`'s return). */
246
+ recoveredIn?: ReadonlySet<string>;
247
+ }): Promise<{
248
+ restored: AssetSwap[];
249
+ scannedTxids: string[];
250
+ }>;
251
+
252
+ /**
253
+ * One swap, flattened to what grouping needs: an identity, a corridor, an
254
+ * outcome, and every Arkade transaction that belongs to it. Plain data, not a stored record, so
255
+ * resolution is testable without a repository.
223
256
  */
224
257
  interface SwapActivityInput {
225
258
  rfqId: string;
@@ -231,33 +264,24 @@ interface SwapActivityInput {
231
264
  /**
232
265
  * Group each RFQ swap's transactions into one activity carrying its outcome.
233
266
  *
234
- * Without this a failed swap renders as two unrelated rows: the send that
235
- * funded the lockup, and the receive when the covenant refunds. Grouping by
236
- * `rfqId` collapses them into one activity, and the amount comes out correct
237
- * by netting, not by `buildActivities`'s same-key change exclusion — that
238
- * rule only fires when one txid is both sent and received, and funding and
239
- * refund are different txids. Summing the signed amounts
240
- * (`-funding + refund ≈ -fees`) is what does the work here.
267
+ * Without this a failed swap renders as two unrelated rows (funding send, covenant refund). The
268
+ * amount comes out right by netting signed amounts (`-funding + refund ≈ -fees`), not by
269
+ * `buildActivities`'s same-txid change exclusion, since funding and refund are different txids.
241
270
  *
242
271
  * `prepare` loads once and `resolve` stays pure and synchronous, as the SDK's
243
272
  * `ActivityResolver` contract requires.
244
- *
245
- * @deprecated Read swap history with `client.swaps()`. Moved off the package root to `@arkade-os/swap/protocol`.
246
273
  */
247
274
  declare function swapActivityResolver(deps: {
248
275
  listSwaps(): Promise<readonly SwapActivityInput[]>;
249
276
  }): ActivityResolver;
250
277
  /** @deprecated Read swap history with `client.swaps()`. Moved off the package root to `@arkade-os/swap/protocol`. */
251
278
  interface RfqSwapActivityDeps {
252
- repository: Pick<AssetSwapRepository, "getAllRfqSwaps">;
279
+ repository: Pick<AssetSwapRepository, "getRfqSwapsPage">;
253
280
  /**
254
281
  * Consulted only for what a record cannot answer: a record written before
255
282
  * `fundingTxid` existed, and the counterparty's spend on a swap that
256
- * ended without a refund of ours.
257
- *
258
- * Optional because the stored fields are the primary source — cheaper, and
259
- * they work offline, which is the resolver's whole posture. An indexer that
260
- * throws costs that record its extra txids and nothing else.
283
+ * ended without a refund of ours. Optional because stored fields are the primary, offline
284
+ * source; an indexer that throws costs that record its extra txids and nothing else.
261
285
  */
262
286
  indexer?: LockupSpendIndexer;
263
287
  }
@@ -265,78 +289,77 @@ interface RfqSwapActivityDeps {
265
289
  * Every stored RFQ swap, flattened into what {@link swapActivityResolver}
266
290
  * groups on.
267
291
  *
268
- * The txids come from four places, in order of preference: the record's own
269
- * `fundingTxid` and `refundTxid`, the corridor's `activityTxids` (the
270
- * receive leg's Arkade claim, the onchain leg's L1 one), and — only when the
271
- * first two cannot answer — one read of the lockup's VTXOs.
272
- *
273
- * A missing txid costs an activity a row, never a wrong one: a swap that
274
- * contributes fewer txids simply leaves those transactions ungrouped, which is
275
- * what they already are.
276
- *
277
- * @deprecated Read swap history with `client.swaps()`. Moved off the package root to `@arkade-os/swap/protocol`.
292
+ * Txids come from the record's `fundingTxid`/`refundTxid`, the corridor's `activityTxids`, the
293
+ * manager's `lockupSpendTxids`, and only then one lockup VTXO read. A missing txid leaves that
294
+ * transaction ungrouped, never misgrouped.
278
295
  */
279
296
  declare function rfqSwapActivityInputs(deps: RfqSwapActivityDeps): Promise<SwapActivityInput[]>;
280
297
 
281
298
  /**
282
- * The `refundArkade` callback, assembled.
283
- *
284
- * The wiring this replaces was prose in two places — `swapManager.ts`'s
285
- * callback doc and the README — because it is the one callback whose obvious
286
- * implementation is wrong: `refundIfUnresolved` is the single-swap version of
287
- * `RfqSwapManager` itself and brings its own status polling and MTP retry loop,
288
- * which would nest inside the manager's. Composing the atomic push here makes
289
- * that mistake something a consumer has to go out of their way to make.
299
+ * The `refundArkade` callback, assembled: one push per pass, leaving status polling and the MTP
300
+ * retry to the manager.
290
301
  *
291
- * The three semantic rules the manager relies on are structural rather than
292
- * documented: an empty lockup returns `null`, and both
293
- * {@link RefundNotLocallyPossibleError} and {@link LockupNeedsRecoveryError}
294
- * propagate untouched — the manager reads the first as permanent and surfaces
295
- * the second as `needs_recovery`, and catching either here would turn a state
302
+ * An empty lockup returns `null`; {@link RefundNotLocallyPossibleError} and
303
+ * {@link LockupNeedsRecoveryError} propagate untouched, since catching either would turn a state
296
304
  * the trader must act on into a retry that grinds the window away.
297
305
  */
298
306
 
299
- /** @deprecated The drive refunds; `client.recover()` settles a swept lockup. Moved off the package root to `@arkade-os/swap/protocol`. */
300
307
  interface ArkadeRefunderDeps {
301
308
  operator: SwapOperator;
302
- indexer: RefundIndexer;
309
+ /**
310
+ * The wallet's contract manager (prefer `await wallet.getContractManager()`). The lockup must
311
+ * be registered in it before the funding is visible.
312
+ */
313
+ contracts: LockupContractSource;
303
314
  /** Asked for the descriptor's signer; never asked to mint a key. */
304
315
  wallet: IWallet;
305
316
  /**
306
- * The record store. The live `RfqSwap` the manager passes carries no
307
- * `signingDescriptor` — that lives in the record's `profile.signer` — so
308
- * the refund key is resolved by key, which is what `getRfqSwap` is for.
317
+ * The record store: the live `RfqSwap` carries no `signingDescriptor` (it lives in the
318
+ * record's `profile.signer`), so the refund key is resolved through `getRfqSwap`.
309
319
  */
310
320
  repository: Pick<AssetSwapRepository, "getRfqSwap">;
321
+ /** The caller's already-resolved network, pinning the checkpoint exit-delay floor. Lazy,
322
+ * like `SwapDriveConfig.network`. @see operatorUnrollScript */
323
+ network?: () => Promise<Network>;
311
324
  }
312
325
  /**
313
326
  * Build the `refundArkade` callback for `RfqSwapManager.setCallbacks`.
314
327
  *
315
328
  * @example
316
329
  * manager.setCallbacks({
317
- * refundArkade: arkadeRefunder({ operator, indexer, wallet, repository }),
330
+ * refundArkade: arkadeRefunder({ operator, contracts, wallet, repository }),
318
331
  * saveSwap,
319
332
  * });
320
- *
321
- * @deprecated The drive refunds; `client.recover()` settles a swept lockup. Moved off the package root to `@arkade-os/swap/protocol`.
322
333
  */
323
334
  declare function arkadeRefunder(deps: ArkadeRefunderDeps): (swap: RfqSwap) => Promise<ArkadeRefundResult>;
324
335
 
325
336
  /** `network` is `requestOnchainSend`'s `l1Network`, and only decodes scripts to
326
337
  * addresses — the provider decides which chain is read, so mismatching the two
327
338
  * yields addresses it knows nothing about rather than an error.
328
- *
329
- * @deprecated Internal to the onchain corridor; no replacement. Moved off the package root to `@arkade-os/swap/protocol`.
330
339
  */
331
340
  declare const chainSourceFrom: (provider: OnchainProvider, network: OnchainNetwork) => ChainSource;
332
341
 
342
+ /**
343
+ * The receive corridors' completion: the trader claims the solver-funded
344
+ * lockup with its own preimage.
345
+ *
346
+ * On `lightning:BTC->arkade:BTC` and `onchain:BTC->arkade:BTC` the trader is the covenant's
347
+ * `receiver` and generated `P`, so the collaborative claim leaf (preimage + receiver + server) is
348
+ * spendable the moment the lockup lands, with no covclaimd. Mirror of `pushRefundWithoutReceiver`,
349
+ * except:
350
+ *
351
+ * - The preimage rides the PSBT's `ConditionWitness`, attached AFTER signing on the ark tx and
352
+ * every checkpoint; attaching it first yields `INVALID_SIGNATURE` (`claimWithPreimageIdentity`
353
+ * owns that ordering).
354
+ * - The leaf is NOT covenant-pinned, so one aggregate output pays wherever the trader says; the
355
+ * destination is required, defaulting honestly to the swap's payout address.
356
+ */
357
+
333
358
  /**
334
359
  * The lockup is funded for less than the swap agreed.
335
360
  *
336
- * The attack this names: the solver funds the correctly derived script with
337
- * dust. Deriving the script locally — what protects every other corridor —
338
- * proves nothing here, because the script was never the lie. Claiming anyway
339
- * publishes `P`, which is what lets the solver settle the payer's Lightning
361
+ * The attack: the solver funds the correctly derived script with dust, so local script derivation
362
+ * proves nothing. Claiming anyway publishes `P`, letting the solver settle the payer's Lightning
340
363
  * HTLC in full.
341
364
  *
342
365
  * @deprecated The claim path is internal to the drive; watch it with `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
@@ -349,147 +372,82 @@ declare class LockupAmountMismatchError extends Error {
349
372
  constructor(expectedAmount: number, lockedAmount: number);
350
373
  }
351
374
  /**
352
- * Build, sign, and push the collaborative claim of a receive-corridor lockup:
353
- * move every funded output at the lockup to the trader's own destination,
354
- * revealing `P` in the witness — which is also what settles the trader's side
355
- * of the swap (the solver reads `P` off the public claim).
356
- *
357
- * The preimage is checked against the script's committed hash BEFORE anything
358
- * is signed: a wrong value can never open the leaf, and catching it here
359
- * beats learning it from the server's rejection.
375
+ * Build, sign, and push the collaborative claim of a receive-corridor lockup, moving the live
376
+ * outputs to the trader's destination and revealing `P` (the solver reads it off the claim).
360
377
  *
361
- * So is the funded VALUE, against `expectedAmount` — and for the same reason,
362
- * only more sharply: disclosure happens at SUBMIT, since `P` rides the PSBT to
363
- * the Ark server. A check that waits for the transaction to land has already
364
- * leaked the secret.
378
+ * Preimage and funded VALUE are checked BEFORE signing: `P` reaches the operator at SUBMIT, so a
379
+ * later check has already leaked it. Swept outputs are left out (one non-live input would sink
380
+ * the aggregate tx). The server countersignature is verified per input, so "reported claimed,
381
+ * nothing landed" fails immediately.
365
382
  *
366
- * Swept outputs are refused, not attempted, exactly as in
367
- * {@link pushRefundWithoutReceiver} — one aggregate transaction means a
368
- * single non-live input would take the live ones down with it. That refusal
369
- * comes first, which is what leaves the value gate a plain sum over live
370
- * outputs.
371
- *
372
- * The server's countersignature is verified before finalizing, per input and
373
- * against that input's own leaf. It does not protect `P` — that reached the
374
- * server at submit — but it turns "reported claimed, nothing landed, the
375
- * solver refunds hours later" into an immediate failure.
376
- *
377
- * @deprecated The claim path is internal to the drive; watch `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
383
+ * One push spends at most `MAX_LOCKUP_SPEND_INPUTS` live outputs, the largest. `left` counts the
384
+ * live outputs it did not take (swept ones never count: the receiver cannot spend them). Until it
385
+ * is zero, call again with the outputs not in `spent` and `partiallyClaimed: true`.
378
386
  */
379
387
  declare function pushClaim(operator: SwapOperator, input: {
380
388
  /** The receive-direction covenant (see `lightningReceiveContract`). */
381
389
  contract: InstanceType<typeof VHTLC.ScriptV2>;
382
- /** The trader's `receiver` signer. Build it from the swap's `secrets`
383
- * with `contractSigner` — on an HD wallet that resolves
384
- * from the seed, with no stored key bytes anywhere. */
390
+ /** The trader's `receiver` signer, built from the swap's `secrets` with `contractSigner`. */
385
391
  receiver: Identity;
386
392
  /** `P`, 32 bytes — the trader generated it at request time. */
387
393
  preimage: Uint8Array;
388
394
  vtxos: readonly LockupVtxo[];
389
395
  /** Where the claimed sats land — the swap's payout address, decoded. */
390
396
  destinationPkScript: Uint8Array;
391
- /** What the lockup must carry: the quote's `to_amount`, captured at
392
- * REQUEST time and persisted with the record. Required rather than
393
- * optional, so the guard cannot be skipped by the records that need
394
- * it most. */
397
+ /** What the lockup must carry: the quote's `to_amount`, captured at REQUEST time and
398
+ * persisted. Required so the guard cannot be skipped. */
395
399
  expectedAmount: number;
396
400
  /** Set when this lockup already carries a claim of ours: `P` is public
397
401
  * by then, so the value gate protects nothing and would only strand
398
402
  * the remainder. */
399
403
  partiallyClaimed?: boolean;
404
+ /** @see operatorUnrollScript */
405
+ network?: Network;
400
406
  }): Promise<{
401
407
  txid: string;
402
408
  amount: number;
403
- }>;
404
- /**
405
- * Wait for the solver-funded lockup to appear at the covenant script.
406
- *
407
- * Same conventions as `awaitRfqResolution`: a `pollMs` interval, an optional
408
- * unix-seconds `deadline`, and a thrown error carrying a stable `reason` when
409
- * the deadline passes.
410
- *
411
- * @deprecated The claim path is internal to the drive; watch `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
412
- */
413
- declare function awaitLockupFunding(indexer: RefundIndexer, swapPkScript: Uint8Array, options?: {
414
- pollMs?: number;
415
- deadline?: number;
416
- }): Promise<readonly LockupVtxo[]>;
417
- /**
418
- * The one-call composition: wait for the solver's funding, then push the
419
- * claim. The polling deadline gates the WAIT only — once the lockup is
420
- * funded, the claim itself is gated by nothing but the solver's own refund
421
- * deadline (`refund_locktime` from the quote), which is the number the
422
- * caller's deadline should be measured against.
423
- *
424
- * The wait returns on the first output seen, so a funding the indexer
425
- * surfaces piecemeal reaches {@link pushClaim}'s value gate short and throws
426
- * {@link LockupAmountMismatchError}. Nothing was signed, so retrying once the
427
- * rest lands is safe — and that is also the answer to a genuinely underfunded
428
- * lockup, which never gets past the gate at all.
429
- *
430
- * @deprecated The claim path is internal to the drive; watch it with `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
431
- */
432
- declare function claimReceiveLockup(indexer: RefundIndexer, operator: SwapOperator, input: Parameters<typeof pushClaim>[1] & {
433
- /** The covenant's scriptPubKey, from the request flow's `swapPkScript`. */
434
- swapPkScript: Uint8Array;
435
- pollMs?: number;
436
- deadline?: number;
437
- }): Promise<{
438
- txid: string;
439
- amount: number;
409
+ left: number;
410
+ spent: readonly LockupVtxo[];
440
411
  }>;
441
412
 
442
413
  /**
443
414
  * Quoting: solver discovery and the pricing guardrails around a plan.
444
415
  *
445
- * The user side of a swap — the layer that works out what one would cost
446
- * before `offer` commits to it. This is request-for-quote like every other
447
- * Arkade Intents corridor; what is specific here is that the quote resolves
448
- * client-side, from the market card the solver publishes (its price feed and
449
- * its fee) rather than over a relay roundtrip. The card commits a solver to a
450
- * price; only a fill commits it to this swap, so nothing here is signed and no
451
- * inventory is reserved.
452
- *
453
- * Relay-negotiated quotes are where every corridor converges, this one
454
- * included. What stays specific to intra-Arkade is the settlement covenant,
455
- * not the negotiation. See the README's Roles section for why this package
456
- * says user and solver rather than maker and taker.
416
+ * The quote resolves client-side from the solver's published market card (price feed
417
+ * and fee), not over a relay round trip. The card commits a solver to a price; only a
418
+ * fill commits it to this swap, so nothing here is signed and no inventory is reserved.
457
419
  */
458
420
 
459
421
  /** Shared quote options so every quote path agrees.
460
422
  * No safety margin on top of the market fee: pricing drift between quote
461
423
  * and fill is the solver's risk to manage, not the user's to prepay.
462
- *
463
- * @deprecated Internal to the pricing path behind `client.quote()`. Moved off the package root to `@arkade-os/swap/protocol`.
464
424
  */
465
425
  declare const QUOTE_OPTIONS: {
466
426
  readonly safetyBps: 0;
467
427
  };
468
- /** Feed fetcher with a short per-URL TTL cache. A quote UI refetches the
469
- * market's price feed on every debounced keystroke, and public feeds
470
- * (CoinGecko) rate-limit that burst hard enough that big amounts reliably die
471
- * as "Quote unavailable" mid-typing — one feed value per TTL window is fresh
472
- * enough for a preview whose rate is re-checked at fill anyway.
428
+ /** Feed fetcher with a short per-URL TTL cache: a quote UI refetches the feed on every
429
+ * debounced keystroke, and public feeds (CoinGecko) rate-limit that burst. The rate is
430
+ * re-checked at fill anyway.
473
431
  * ponytail: no stale-serve when the fetch itself fails; add one if feeds
474
432
  * flake beyond the TTL window (cap the staleness — the feed value becomes
475
433
  * the covenant floor, so an old price must never price a real offer).
476
- * Keyed on the request URL, so it assumes a market's feed URL is stable and
477
- * amount-invariant (true today); a cache-busting nonce would silently make it
478
- * a no-op — the flat-feedCalls swap test guards against that regressing.
479
- *
480
- * @deprecated Internal to the pricing path behind `client.quote()`. Moved off the package root to `@arkade-os/swap/protocol`.
434
+ * Assumes a market's feed URL is stable and amount-invariant; a cache-busting nonce
435
+ * would silently make this a no-op (guarded by the flat-feedCalls swap test).
481
436
  */
482
437
  declare const makeCachedFeedFetch: (ttlMs?: number, fetchImpl?: typeof fetch) => typeof fetch;
483
- /** @deprecated Use `client.markets()`; pricing is internal to `client.quote()`. Moved off the package root to `@arkade-os/swap/protocol`. */
484
438
  interface DiscoverMarketsOptions {
485
- network: Network;
486
- /** The network's solver registry index URL; no registry means no markets. */
439
+ network: Network$1;
440
+ /** Overrides the network's default registry. `undefined` follows
441
+ * `@arkade-os/solver-discovery`'s per-network default (never hardcoded here). */
487
442
  registryUrl: string | undefined;
488
- /** Backs the 1-hour markets cache and its stale fallback. Omit for a
443
+ /** Backs the 10-minute markets cache and its stale fallback. Omit for a
489
444
  * one-shot discovery that always hits the registry. */
490
445
  repository?: AssetSwapRepository;
491
446
  /** Locally pinned solver cards to merge with the registry's markets. */
492
447
  localCards?: LocalCardInput[];
448
+ /** Reads the cards listed solvers publish on their own transports. Omitted means Nostr
449
+ * (needs the optional `nostr-tools` peer); `null` reads registry cards only. */
450
+ transportCards?: TransportCardFetcher | null;
493
451
  /** Receives discovery warnings (stale index, skipped cards, …). */
494
452
  logger?: (...args: unknown[]) => void;
495
453
  /** Custom fetch (tests, mobile runtimes). Defaults to global fetch.
@@ -497,35 +455,33 @@ interface DiscoverMarketsOptions {
497
455
  * own fetchImpl with an AbortSignal; add one if a hung registry ever
498
456
  * strands discovery in practice. */
499
457
  fetchImpl?: typeof fetch;
500
- /** `false` forces a refetch past a fresh cache (a user-triggered reload).
501
- * It does not disable the stale-cache fallback: an unreachable registry
502
- * still serves the last known markets rather than none. */
458
+ /** `false` forces a refetch past a fresh cache. The stale-cache fallback for an
459
+ * unreachable registry still applies. */
503
460
  useCache?: boolean;
504
461
  }
505
462
  /**
506
- * Markets from the network's solver registry; [] when none is configured.
507
- * Registry content changes rarely, so results are cached for an hour and a
508
- * stale cache backstops an unreachable registry (quotes stay live either way).
509
- *
510
- * @deprecated Use `client.markets()`. Moved off the package root to `@arkade-os/swap/protocol`.
463
+ * Markets from this network's solver registry, cached for ten minutes, with a stale cache
464
+ * backstopping an unreachable registry. Only an unrecognised network yields [].
511
465
  */
512
466
  declare const discoverMarkets: (options: DiscoverMarketsOptions) => Promise<DiscoveredMarket[]>;
467
+ /**
468
+ * {@link discoverMarkets} kept current for a long-lived view: `onMarkets` gets the first read,
469
+ * then every read that changes the market set. Returns a stop function. Pass a `repository`
470
+ * so a failed read answers from the cache.
471
+ */
472
+ declare const watchMarkets: (options: DiscoverMarketsOptions & {
473
+ intervalMs?: number;
474
+ }, onMarkets: (markets: DiscoveredMarket[]) => void) => (() => void);
513
475
  /** Best market for a from/to pair, in either orientation. `give` is the side
514
476
  * the sender deposits; `wantSide` skips markets whose receive side is
515
477
  * disabled (max = "0").
516
- *
517
- * @deprecated Use `client.markets()`. Moved off the package root to `@arkade-os/swap/protocol`.
518
478
  */
519
479
  declare const findMarket: (markets: DiscoveredMarket[], fromId: string, toId: string) => {
520
480
  market: DiscoveredMarket | null;
521
481
  give: Side;
522
482
  } | undefined;
523
- /** @deprecated Use `client.markets()`; pricing is internal to `client.quote()`. Moved off the package root to `@arkade-os/swap/protocol`. */
524
483
  type PlanError = "insufficient-balance" | "side-disabled" | "below-min" | "above-max" | "below-dust";
525
- /** Validate a plan against the user's balance and the server dust limit.
526
- *
527
- * @deprecated Internal to the pricing path behind `client.quote()`. Moved off the package root to `@arkade-os/swap/protocol`.
528
- */
484
+ /** Validate a plan against the user's balance and the server dust limit.*/
529
485
  declare const validatePlan: (plan: OfferPlan, giveBalance: bigint, dust: bigint) => PlanError | undefined;
530
486
 
531
487
  /**
@@ -545,10 +501,8 @@ declare const CROSS_ASSET_RAIL = "cross-asset";
545
501
  * chain state, never by resending. Persisting only afterwards would leave a
546
502
  * crash between send and persist looking exactly like `filled`.
547
503
  *
548
- * @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`.
549
504
  */
550
505
  type CrossAssetPhase = "quoted" | "filled" | "paying" | "settled";
551
- /** @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`. */
552
506
  interface CrossAssetSwap {
553
507
  phase: CrossAssetPhase;
554
508
  offerHex: string;
@@ -561,7 +515,6 @@ interface CrossAssetSwap {
561
515
  /** The payout, once `settled` — the receipt a `paying` record looks for. */
562
516
  txid?: string;
563
517
  }
564
- /** @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`. */
565
518
  interface CrossAssetRailDeps {
566
519
  /** Called by `available()` and again by `quote()`; pass the caching
567
520
  * `discoverMarkets`, not a bare registry fetch. */
@@ -585,7 +538,6 @@ interface CrossAssetRailDeps {
585
538
  /** Rank after `ark-asset`, which pays from a balance already held. Both match,
586
539
  * so `options()` can offer "pay from your USDX" beside "buy USDX and pay".
587
540
  *
588
- * @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`.
589
541
  */
590
542
  declare function crossAssetRail(deps: CrossAssetRailDeps): PaymentRail;
591
543
 
@@ -599,7 +551,6 @@ declare function crossAssetRail(deps: CrossAssetRailDeps): PaymentRail;
599
551
  * No `emulatorPubkey`: the card's key only FILTERS here — the covenant is
600
552
  * built from `deps.emulatorPubkey` or the pinned default, never from it.
601
553
  *
602
- * @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`.
603
554
  */
604
555
  interface SolverRendezvous {
605
556
  solverPubkey: string;
@@ -616,7 +567,6 @@ interface SolverRendezvous {
616
567
  * is refused anyway. A card that serves the corridor but not the size is
617
568
  * skipped, not fatal — another may take it.
618
569
  *
619
- * @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`.
620
570
  */
621
571
  declare const solverRendezvous: (markets: DiscoveredMarket[], payoutCorridor: "onchain" | "lightning", amountSats: number, fallbackEmulatorPubkey?: Uint8Array) => SolverRendezvous | undefined;
622
572
 
@@ -630,14 +580,12 @@ declare const solverRendezvous: (markets: DiscoveredMarket[], payoutCorridor: "o
630
580
 
631
581
  /** @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`. */
632
582
  declare const SOLVER_LIGHTNING_RAIL = "solver-lightning";
633
- /** @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`. */
634
583
  type SolverLightningSend = Awaited<ReturnType<typeof requestLightningSend>> & {
635
584
  invoice: InvoiceFacts;
636
585
  rendezvous: SolverRendezvous;
637
586
  };
638
587
  /** Mirrors {@link SolverOnchainRailDeps}; see there for the shared seams.
639
588
  *
640
- * @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`.
641
589
  */
642
590
  interface SolverLightningRailDeps {
643
591
  /** A decoder that throws drops the rail rather than taking the router
@@ -653,9 +601,7 @@ interface SolverLightningRailDeps {
653
601
  emulatorPubkey?: string;
654
602
  fallbackEmulatorPubkey?: Uint8Array;
655
603
  }
656
- /** @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`. */
657
604
  declare const solverLightningRendezvous: (markets: DiscoveredMarket[], amountSats: number, fallbackEmulatorPubkey?: Uint8Array) => SolverRendezvous | undefined;
658
- /** @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`. */
659
605
  declare function solverLightningRail(deps: SolverLightningRailDeps): PaymentRail;
660
606
 
661
607
  /**
@@ -671,7 +617,6 @@ declare const SOLVER_ONCHAIN_RAIL = "solver-onchain";
671
617
  /** What a record needs. Pass the whole object to `onchainSendProfile()`: only
672
618
  * this carries `payoutPkScript`.
673
619
  *
674
- * @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`.
675
620
  */
676
621
  type SolverOnchainSend = Awaited<ReturnType<typeof requestOnchainSend>> & {
677
622
  rendezvous: SolverRendezvous;
@@ -680,7 +625,6 @@ type SolverOnchainSend = Awaited<ReturnType<typeof requestOnchainSend>> & {
680
625
  * these bytes raw returns an object with no `.length`. */
681
626
  payoutPkScript: Uint8Array;
682
627
  };
683
- /** @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`. */
684
628
  interface SolverOnchainRailDeps {
685
629
  l1Network: OnchainNetwork;
686
630
  /** x-only L1 key that AUTHORISES the claim — not where it pays. */
@@ -700,22 +644,16 @@ interface SolverOnchainRailDeps {
700
644
  emulatorPubkey?: string;
701
645
  fallbackEmulatorPubkey?: Uint8Array;
702
646
  }
703
- /** @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`. */
704
647
  declare const solverOnchainRendezvous: (markets: DiscoveredMarket[], amountSats: number, fallbackEmulatorPubkey?: Uint8Array) => SolverRendezvous | undefined;
705
648
  /** Register alongside the core `onchain` rail, ranked first:
706
649
  * `priority: ["ark", "solver-onchain", "onchain"]`. Both stay registered.
707
650
  *
708
- * @deprecated A v1 RFQ rail; use `lightningRail` / `onchainSwapRail` with `createSwapPaymentRouter`. Moved off the package root to `@arkade-os/swap/protocol`.
709
651
  */
710
652
  declare function solverOnchainRail(deps: SolverOnchainRailDeps): PaymentRail;
711
653
 
712
654
  /**
713
- * Why a wallet cannot produce a swap's spending key.
714
- *
715
- * A swap-lifecycle concern, not a key-provisioning one — which is why it
716
- * lives here and not in the SDK: `RfqSwapManager` reads it to decide a refund
717
- * is impossible rather than merely failing, and stops grinding against a push
718
- * that can never work for the whole refund window.
655
+ * Why a wallet cannot produce a swap's spending key. `RfqSwapManager` reads this to treat a
656
+ * refund as impossible rather than retryable, and stops pushing for the rest of the window.
719
657
  */
720
658
 
721
659
  /** @deprecated Recovery is internal to the drive; use `client.recover()`. Moved off the package root to `@arkade-os/swap/protocol`. */
@@ -725,17 +663,13 @@ type RefundBlockedReason =
725
663
  /** The descriptor belongs to another wallet's key. */
726
664
  | "foreign-descriptor"
727
665
  /**
728
- * This wallet holds the key but cannot sign with it — a watch-only
729
- * identity, or a remote signer that is not attached. Unlike the other two
730
- * this can stop being true without changing wallets, so it is worth
731
- * telling apart: "attach your signer", not "restore the other wallet".
666
+ * This wallet holds the key but cannot sign with it (watch-only, or remote signer not
667
+ * attached). Unlike the others it can clear without changing wallets: "attach your signer".
732
668
  */
733
669
  | "unsignable-wallet";
734
670
  /**
735
671
  * The wallet cannot produce this swap's spending key, so no local refund is
736
672
  * possible: not a failure to retry, a capability this wallet does not have.
737
- *
738
- * @deprecated Recovery is internal to the drive; use `client.recover()`. Moved off the package root to `@arkade-os/swap/protocol`.
739
673
  */
740
674
  declare class RefundNotLocallyPossibleError extends Error {
741
675
  readonly reason: RefundBlockedReason;
@@ -747,15 +681,11 @@ declare class RefundNotLocallyPossibleError extends Error {
747
681
  /**
748
682
  * The signer for a swap record's `signingDescriptor`, or a typed refusal.
749
683
  *
750
- * **Wire `refundArkade` here, not to `contractSigner` directly.** The SDK
751
- * answers about a descriptor; only this knows that a record without one is a
752
- * permanent refusal rather than a `TypeError` at the push site — which the
753
- * manager would treat as retryable.
754
- *
755
- * @deprecated Recovery is internal to the drive; use `client.recover()`. Moved off the package root to `@arkade-os/swap/protocol`.
684
+ * **Wire `refundArkade` here, not to `contractSigner` directly**: a record without a descriptor
685
+ * must be a permanent refusal, not a `TypeError` the manager would retry.
756
686
  */
757
687
  declare function senderIdentityForSwapRecord(wallet: IWallet, record: {
758
688
  signingDescriptor?: string;
759
689
  }): Promise<Identity>;
760
690
 
761
- export { ArkadeRefundResult, type ArkadeRefunderDeps, CROSS_ASSET_RAIL, type CrossAssetPhase, type CrossAssetRailDeps, type CrossAssetSwap, type DiscoverMarketsOptions, type LightningReceiveProfile, type LightningSendProfile, LockupAmountMismatchError, LockupVtxo, OnchainHtlc, OnchainHtlcParams, OnchainNetwork, type OnchainSendProfile, type PlanError, QUOTE_OPTIONS, type RefundBlockedReason, RefundIndexer, RefundNotLocallyPossibleError, type RfqClaimSecretProjection, type RfqHashlockProjection, type RfqSignerProjection, RfqSwap, type RfqSwapActivityDeps, RfqSwapRecord, RfqTransport, SOLVER_LIGHTNING_RAIL, SOLVER_ONCHAIN_RAIL, type SolverLightningRailDeps, type SolverLightningSend, type SolverOnchainRailDeps, type SolverOnchainSend, type SolverRendezvous, type SwapActivityInput, SwapSecretsProjection, arkadeRefunder, awaitLockupFunding, chainSourceFrom, claimReceiveLockup, crossAssetRail, discoverMarkets, findMarket, makeCachedFeedFetch, onchainSendProfile, pushClaim, requestLightningSend, requestOnchainSend, rfqClaimSecretOf, rfqSecretsProfile, rfqSignerOf, rfqSwapActivityInputs, senderIdentityForSwapRecord, solverLightningRail, solverLightningRendezvous, solverOnchainRail, solverOnchainRendezvous, solverRendezvous, swapActivityResolver, validatePlan };
691
+ export { ArkadeRefundResult, type ArkadeRefunderDeps, CROSS_ASSET_RAIL, type CrossAssetPhase, type CrossAssetRailDeps, type CrossAssetSwap, type DiscoverMarketsOptions, type LightningReceiveProfile, type LightningSendProfile, LockupAmountMismatchError, LockupContractSource, LockupVtxo, Offer, OnchainHtlc, OnchainHtlcParams, OnchainNetwork, type OnchainReceiveProfile, type OnchainSendProfile, type PlanError, QUOTE_OPTIONS, type RefundBlockedReason, RefundNotLocallyPossibleError, type RestoreIndexer, type RfqClaimSecretProjection, type RfqHashlockProjection, type RfqSignerProjection, RfqSwap, type RfqSwapActivityDeps, RfqSwapRecord, RfqTransport, SOLVER_LIGHTNING_RAIL, SOLVER_ONCHAIN_RAIL, type SolverLightningRailDeps, type SolverLightningSend, type SolverOnchainRailDeps, type SolverOnchainSend, type SolverRendezvous, type SpendKind, type SwapActivityInput, SwapSecretsProjection, type Tx, arkadeRefunder, chainSourceFrom, classifyDepositSpend, classifySpend, crossAssetRail, discoverMarkets, findMarket, makeCachedFeedFetch, onchainReceiveProfile, onchainSendProfile, pushClaim, requestLightningSend, requestOnchainSend, restoreAssetSwaps, rfqClaimSecretOf, rfqSecretsProfile, rfqSignerOf, rfqSwapActivityInputs, senderIdentityForSwapRecord, solverLightningRail, solverLightningRendezvous, solverOnchainRail, solverOnchainRendezvous, solverRendezvous, spendTxidsOf, swapActivityResolver, validatePlan, watchMarkets };