@arkade-os/swap 0.1.0-rc.21 → 0.1.0-rc.23

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 (37) hide show
  1. package/README.md +7 -2
  2. package/dist/advanced.cjs +875 -129
  3. package/dist/advanced.d.cts +158 -14
  4. package/dist/advanced.d.ts +158 -14
  5. package/dist/advanced.js +255 -4
  6. package/dist/{chunk-ITFCQWPG.js → chunk-DQ2DY2L2.js} +223 -11
  7. package/dist/{chunk-HUQQVBC4.js → chunk-MZX62KMU.js} +220 -12
  8. package/dist/{chunk-PVB7EBAM.js → chunk-UFJEO4VV.js} +47 -21
  9. package/dist/{errors-hm7aqnRM.d.cts → errors-5q4e3PnH.d.cts} +48 -16
  10. package/dist/{errors-C3h8ANmE.d.ts → errors-DQ35FKJf.d.ts} +48 -16
  11. package/dist/index.cjs +670 -185
  12. package/dist/index.d.cts +5 -5
  13. package/dist/index.d.ts +5 -5
  14. package/dist/index.js +5 -3
  15. package/dist/node/index.d.cts +26 -4
  16. package/dist/node/index.d.ts +26 -4
  17. package/dist/nostr.cjs +12 -9
  18. package/dist/nostr.d.cts +1 -1
  19. package/dist/nostr.d.ts +1 -1
  20. package/dist/nostr.js +3 -1
  21. package/dist/{offer-Bd9Yvd8Z.d.ts → offer--IpfzhIm.d.ts} +1 -1
  22. package/dist/{offer-F88rtL_I.d.cts → offer-DqTXQeP1.d.cts} +1 -1
  23. package/dist/protocol.cjs +395 -156
  24. package/dist/protocol.d.cts +45 -8
  25. package/dist/protocol.d.ts +45 -8
  26. package/dist/protocol.js +10 -3
  27. package/dist/repositories/realm/index.d.cts +2 -2
  28. package/dist/repositories/realm/index.d.ts +2 -2
  29. package/dist/repositories/sqlite/index.d.cts +2 -2
  30. package/dist/repositories/sqlite/index.d.ts +2 -2
  31. package/dist/{repository-DYnRLPt-.d.ts → repository-B4rQWmS2.d.cts} +88 -20
  32. package/dist/{repository-BuYWGAKz.d.cts → repository-D_qvJk1S.d.ts} +88 -20
  33. package/dist/{rfq-60PGpQ_x.d.cts → rfq-BgdgO9OO.d.cts} +16 -7
  34. package/dist/{rfq-60PGpQ_x.d.ts → rfq-BgdgO9OO.d.ts} +16 -7
  35. package/dist/{watch-BTyiBLSd.d.ts → watch-BkPz0vf8.d.ts} +1 -1
  36. package/dist/{watch-M_KY-5ho.d.cts → watch-RRhKuBkh.d.cts} +1 -1
  37. package/package.json +3 -3
@@ -1,13 +1,13 @@
1
1
  import { ProvisionedKey, ProvisionedClaimSecret, RestIndexerProvider, Transaction, ActivityResolver, IWallet, Network, OnchainProvider, VHTLC, Identity, Asset, PaymentRail } from '@arkade-os/sdk';
2
- import { b9 as SwapSecretsProjection, e as RfqSwapRecord, h as AssetSwap, d as AssetSwapRepository, L as LockupSpendIndexer, b3 as RfqSwapState, b5 as SwapOperator, ba as LockupContractSource, bb as RfqSwap, bc as ArkadeRefundResult, bd as LockupVtxo } from './repository-BuYWGAKz.cjs';
3
- export { c as AssetSwapStatus, be as AvailableRfqSwapManagerCallbacks, bf as BTC_ASSET_ID, bg as LightningReceiveSwap, bh as LightningSendSwap, bi as LockupFate, bj as LockupNeedsRecoveryError, bk as LockupParams, bl as LockupSpend, bm as OnchainSendAction, bn as OnchainSendSwap, bo as PersistableRfqSwap, bp as PreimageBlockedReason, bq as PreimageNotRecoverableError, br as RFQ_SWAP_RETENTION_SECONDS, bs as RefundOutcome, bt as RfqRestoreFailure, bu as RfqRestoreOptions, bv as RfqRestoreResult, b8 as RfqSwapActionName, bw as RfqSwapLockup, bx as RfqSwapManager, b7 as RfqSwapManagerCallbacks, by as RfqSwapManagerConfig, bz as RfqSwapManagerDeps, bA as RfqSwapManagerEvents, bB as RfqSwapOrigin, bC as RfqSwapOriginRequired, bD as RfqSwapOutcome, a as RfqSwapRecordStore, bE as addAssetSwap, bF as awaitRfqResolution, bG as createRfqSwapRecord, bH as findLockupVtxos, bI as getAssetSwaps, bJ as isRfqTerminal, bK as nextOnchainAction, bL as normalizeRfqSwapRecord, bM as preimageForSwapRecord, bN as pushRefundWithoutReceiver, bO as readLockupFate, bP as rebuildRfqSwap, bQ as refundIfUnresolved, bR as rfqSwapOriginOf, bS as shouldRetainRfqSwap, bT as swapSecretsToRecord, bU as updateAssetSwap, bV as updateRfqSwapRecord } from './repository-BuYWGAKz.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-60PGpQ_x.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 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.cjs';
2
+ import { b9 as SwapSecretsProjection, e as RfqSwapRecord, h as AssetSwap, d as AssetSwapRepository, L as LockupSpendIndexer, b3 as RfqSwapState, b5 as SwapOperator, ba as LockupContractSource, bb as RfqSwap, bc as ArkadeRefundResult, bd as LockupVtxo } from './repository-B4rQWmS2.cjs';
3
+ export { c as AssetSwapStatus, be as AvailableRfqSwapManagerCallbacks, bf as BTC_ASSET_ID, bg as LightningReceiveSwap, bh as LightningSendSwap, bi as LockupFate, bj as LockupNeedsRecoveryError, bk as LockupParams, bl as LockupSpend, bm as OnchainReceiveAction, bn as OnchainReceiveNeedsChainSource, bo as OnchainReceiveSwap, bp as OnchainSendAction, bq as OnchainSendSwap, br as PersistableRfqSwap, bs as PreimageBlockedReason, bt as PreimageNotRecoverableError, bu as RFQ_SWAP_RETENTION_SECONDS, bv as ReceiveLockupSwap, bw as RefundOutcome, bx as RfqRestoreFailure, by as RfqRestoreOptions, bz as RfqRestoreResult, b8 as RfqSwapActionName, bA as RfqSwapLockup, bB as RfqSwapManager, b7 as RfqSwapManagerCallbacks, bC as RfqSwapManagerConfig, bD as RfqSwapManagerDeps, bE as RfqSwapManagerEvents, bF as RfqSwapOrigin, bG as RfqSwapOriginRequired, bH as RfqSwapOutcome, a as RfqSwapRecordStore, bI as addAssetSwap, bJ as awaitRfqResolution, bK as createRfqSwapRecord, bL as findLockupVtxos, bM as getAssetSwaps, bN as isRfqTerminal, bO as nextOnchainAction, bP as nextOnchainReceiveAction, bQ as normalizeRfqSwapRecord, bR as preimageForSwapRecord, bS as pushRefundWithoutReceiver, bT as readLockupFate, bU as rebuildRfqSwap, bV as refundIfUnresolved, bW as rfqSwapOriginOf, bX as shouldRetainRfqSwap, bY as swapSecretsToRecord, bZ as updateAssetSwap, b_ as updateRfqSwapRecord } from './repository-B4rQWmS2.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-BgdgO9OO.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 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-BgdgO9OO.cjs';
6
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-5r5RlgOJ.cjs';
7
7
  import { Network as Network$1, LocalCardInput, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
8
- import { O as Offer } from './offer-F88rtL_I.cjs';
9
- export { A as ASSET_CARRIER_SATS, F as FillFunding, N as NoSpendableDepositError, a as OFFER_PACKET_TYPE, 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-F88rtL_I.cjs';
10
- export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-M_KY-5ho.cjs';
8
+ import { O as Offer } from './offer-DqTXQeP1.cjs';
9
+ export { A as ASSET_CARRIER_SATS, F as FillFunding, N as NoSpendableDepositError, a as OFFER_PACKET_TYPE, 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-DqTXQeP1.cjs';
10
+ export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-RRhKuBkh.cjs';
11
11
 
12
12
  /** Which wallet key signs this leg, at `profile.signer`. Omitted entirely (not blank) by a corridor
13
13
  * whose leg this wallet never signs. */
@@ -130,6 +130,43 @@ declare function onchainSendProfile(result: {
130
130
  expectedAmount: number;
131
131
  payoutPkScript: Uint8Array;
132
132
  }): Omit<OnchainSendProfile, "signer" | "hashlock">;
133
+ /** `onchain:BTC->arkade:BTC`: a receive Arkade half and a send L1 half, L1 key roles swapped. */
134
+ interface OnchainReceiveProfile extends Record<string, unknown> {
135
+ signer: RfqSignerProjection;
136
+ hashlock: RfqHashlockProjection;
137
+ /** The quote's `to_amount`, captured at REQUEST time. */
138
+ expectedAmount: number;
139
+ payoutAddress: string;
140
+ claimTxid?: string;
141
+ /** The SOLVER's L1 key; `refundKey` is the TRADER's own. */
142
+ claimKey: string;
143
+ refundKey: string;
144
+ /** The wallet descriptor {@link refundKey} came from, when the wallet provisioned it; the
145
+ * client's default refund signs through it. */
146
+ refundDescriptor?: string;
147
+ /** The trader's L1 deadline, not the lockup's. */
148
+ htlcLocktime: number;
149
+ network: OnchainNetwork;
150
+ htlcAddress: string;
151
+ minConfirmations: number;
152
+ /** Where the L1 REFUND pays, hex — nothing else gives it back. */
153
+ refundPkScript: string;
154
+ funding?: {
155
+ txid: string;
156
+ vout: number;
157
+ };
158
+ }
159
+ /** The L1 half of what `requestOnchainReceive` returned. Exists for
160
+ * {@link onchainSendProfile}'s reason: `refundLocktime` becomes `htlcLocktime`,
161
+ * the record's own being the lockup's. */
162
+ declare function onchainReceiveProfile(result: {
163
+ htlc: Pick<OnchainHtlc, "address">;
164
+ htlcParams: OnchainHtlcParams;
165
+ l1Network: OnchainNetwork;
166
+ minConfirmations: number;
167
+ refundPkScript: Uint8Array;
168
+ refundDescriptor?: string;
169
+ }): Omit<OnchainReceiveProfile, "signer" | "hashlock" | "expectedAmount" | "payoutAddress" | "claimTxid">;
133
170
 
134
171
  /**
135
172
  * The subset of a wallet transaction record the swap scan reads. No `assets`: see
@@ -654,4 +691,4 @@ declare function senderIdentityForSwapRecord(wallet: IWallet, record: {
654
691
  signingDescriptor?: string;
655
692
  }): Promise<Identity>;
656
693
 
657
- 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 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, awaitLockupFunding, chainSourceFrom, claimReceiveLockup, classifyDepositSpend, classifySpend, crossAssetRail, discoverMarkets, findMarket, makeCachedFeedFetch, onchainSendProfile, pushClaim, requestLightningSend, requestOnchainSend, restoreAssetSwaps, rfqClaimSecretOf, rfqSecretsProfile, rfqSignerOf, rfqSwapActivityInputs, senderIdentityForSwapRecord, solverLightningRail, solverLightningRendezvous, solverOnchainRail, solverOnchainRendezvous, solverRendezvous, spendTxidsOf, swapActivityResolver, validatePlan };
694
+ 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, awaitLockupFunding, chainSourceFrom, claimReceiveLockup, 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 };
@@ -1,13 +1,13 @@
1
1
  import { ProvisionedKey, ProvisionedClaimSecret, RestIndexerProvider, Transaction, ActivityResolver, IWallet, Network, OnchainProvider, VHTLC, Identity, Asset, PaymentRail } from '@arkade-os/sdk';
2
- import { b9 as SwapSecretsProjection, e as RfqSwapRecord, h as AssetSwap, d as AssetSwapRepository, L as LockupSpendIndexer, b3 as RfqSwapState, b5 as SwapOperator, ba as LockupContractSource, bb as RfqSwap, bc as ArkadeRefundResult, bd as LockupVtxo } from './repository-DYnRLPt-.js';
3
- export { c as AssetSwapStatus, be as AvailableRfqSwapManagerCallbacks, bf as BTC_ASSET_ID, bg as LightningReceiveSwap, bh as LightningSendSwap, bi as LockupFate, bj as LockupNeedsRecoveryError, bk as LockupParams, bl as LockupSpend, bm as OnchainSendAction, bn as OnchainSendSwap, bo as PersistableRfqSwap, bp as PreimageBlockedReason, bq as PreimageNotRecoverableError, br as RFQ_SWAP_RETENTION_SECONDS, bs as RefundOutcome, bt as RfqRestoreFailure, bu as RfqRestoreOptions, bv as RfqRestoreResult, b8 as RfqSwapActionName, bw as RfqSwapLockup, bx as RfqSwapManager, b7 as RfqSwapManagerCallbacks, by as RfqSwapManagerConfig, bz as RfqSwapManagerDeps, bA as RfqSwapManagerEvents, bB as RfqSwapOrigin, bC as RfqSwapOriginRequired, bD as RfqSwapOutcome, a as RfqSwapRecordStore, bE as addAssetSwap, bF as awaitRfqResolution, bG as createRfqSwapRecord, bH as findLockupVtxos, bI as getAssetSwaps, bJ as isRfqTerminal, bK as nextOnchainAction, bL as normalizeRfqSwapRecord, bM as preimageForSwapRecord, bN as pushRefundWithoutReceiver, bO as readLockupFate, bP as rebuildRfqSwap, bQ as refundIfUnresolved, bR as rfqSwapOriginOf, bS as shouldRetainRfqSwap, bT as swapSecretsToRecord, bU as updateAssetSwap, bV as updateRfqSwapRecord } from './repository-DYnRLPt-.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';
2
+ import { b9 as SwapSecretsProjection, e as RfqSwapRecord, h as AssetSwap, d as AssetSwapRepository, L as LockupSpendIndexer, b3 as RfqSwapState, b5 as SwapOperator, ba as LockupContractSource, bb as RfqSwap, bc as ArkadeRefundResult, bd as LockupVtxo } from './repository-D_qvJk1S.js';
3
+ export { c as AssetSwapStatus, be as AvailableRfqSwapManagerCallbacks, bf as BTC_ASSET_ID, bg as LightningReceiveSwap, bh as LightningSendSwap, bi as LockupFate, bj as LockupNeedsRecoveryError, bk as LockupParams, bl as LockupSpend, bm as OnchainReceiveAction, bn as OnchainReceiveNeedsChainSource, bo as OnchainReceiveSwap, bp as OnchainSendAction, bq as OnchainSendSwap, br as PersistableRfqSwap, bs as PreimageBlockedReason, bt as PreimageNotRecoverableError, bu as RFQ_SWAP_RETENTION_SECONDS, bv as ReceiveLockupSwap, bw as RefundOutcome, bx as RfqRestoreFailure, by as RfqRestoreOptions, bz as RfqRestoreResult, b8 as RfqSwapActionName, bA as RfqSwapLockup, bB as RfqSwapManager, b7 as RfqSwapManagerCallbacks, bC as RfqSwapManagerConfig, bD as RfqSwapManagerDeps, bE as RfqSwapManagerEvents, bF as RfqSwapOrigin, bG as RfqSwapOriginRequired, bH as RfqSwapOutcome, a as RfqSwapRecordStore, bI as addAssetSwap, bJ as awaitRfqResolution, bK as createRfqSwapRecord, bL as findLockupVtxos, bM as getAssetSwaps, bN as isRfqTerminal, bO as nextOnchainAction, bP as nextOnchainReceiveAction, bQ as normalizeRfqSwapRecord, bR as preimageForSwapRecord, bS as pushRefundWithoutReceiver, bT as readLockupFate, bU as rebuildRfqSwap, bV as refundIfUnresolved, bW as rfqSwapOriginOf, bX as shouldRetainRfqSwap, bY as swapSecretsToRecord, bZ as updateAssetSwap, b_ as updateRfqSwapRecord } from './repository-D_qvJk1S.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-BgdgO9OO.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-BgdgO9OO.js';
6
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-5r5RlgOJ.js';
7
7
  import { Network as Network$1, LocalCardInput, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
8
- import { O as Offer } from './offer-Bd9Yvd8Z.js';
9
- export { A as ASSET_CARRIER_SATS, F as FillFunding, N as NoSpendableDepositError, a as OFFER_PACKET_TYPE, 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-Bd9Yvd8Z.js';
10
- export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-BTyiBLSd.js';
8
+ import { O as Offer } from './offer--IpfzhIm.js';
9
+ export { A as ASSET_CARRIER_SATS, F as FillFunding, N as NoSpendableDepositError, a as OFFER_PACKET_TYPE, 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--IpfzhIm.js';
10
+ export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-BkPz0vf8.js';
11
11
 
12
12
  /** Which wallet key signs this leg, at `profile.signer`. Omitted entirely (not blank) by a corridor
13
13
  * whose leg this wallet never signs. */
@@ -130,6 +130,43 @@ declare function onchainSendProfile(result: {
130
130
  expectedAmount: number;
131
131
  payoutPkScript: Uint8Array;
132
132
  }): Omit<OnchainSendProfile, "signer" | "hashlock">;
133
+ /** `onchain:BTC->arkade:BTC`: a receive Arkade half and a send L1 half, L1 key roles swapped. */
134
+ interface OnchainReceiveProfile extends Record<string, unknown> {
135
+ signer: RfqSignerProjection;
136
+ hashlock: RfqHashlockProjection;
137
+ /** The quote's `to_amount`, captured at REQUEST time. */
138
+ expectedAmount: number;
139
+ payoutAddress: string;
140
+ claimTxid?: string;
141
+ /** The SOLVER's L1 key; `refundKey` is the TRADER's own. */
142
+ claimKey: string;
143
+ refundKey: string;
144
+ /** The wallet descriptor {@link refundKey} came from, when the wallet provisioned it; the
145
+ * client's default refund signs through it. */
146
+ refundDescriptor?: string;
147
+ /** The trader's L1 deadline, not the lockup's. */
148
+ htlcLocktime: number;
149
+ network: OnchainNetwork;
150
+ htlcAddress: string;
151
+ minConfirmations: number;
152
+ /** Where the L1 REFUND pays, hex — nothing else gives it back. */
153
+ refundPkScript: string;
154
+ funding?: {
155
+ txid: string;
156
+ vout: number;
157
+ };
158
+ }
159
+ /** The L1 half of what `requestOnchainReceive` returned. Exists for
160
+ * {@link onchainSendProfile}'s reason: `refundLocktime` becomes `htlcLocktime`,
161
+ * the record's own being the lockup's. */
162
+ declare function onchainReceiveProfile(result: {
163
+ htlc: Pick<OnchainHtlc, "address">;
164
+ htlcParams: OnchainHtlcParams;
165
+ l1Network: OnchainNetwork;
166
+ minConfirmations: number;
167
+ refundPkScript: Uint8Array;
168
+ refundDescriptor?: string;
169
+ }): Omit<OnchainReceiveProfile, "signer" | "hashlock" | "expectedAmount" | "payoutAddress" | "claimTxid">;
133
170
 
134
171
  /**
135
172
  * The subset of a wallet transaction record the swap scan reads. No `assets`: see
@@ -654,4 +691,4 @@ declare function senderIdentityForSwapRecord(wallet: IWallet, record: {
654
691
  signingDescriptor?: string;
655
692
  }): Promise<Identity>;
656
693
 
657
- 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 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, awaitLockupFunding, chainSourceFrom, claimReceiveLockup, classifyDepositSpend, classifySpend, crossAssetRail, discoverMarkets, findMarket, makeCachedFeedFetch, onchainSendProfile, pushClaim, requestLightningSend, requestOnchainSend, restoreAssetSwaps, rfqClaimSecretOf, rfqSecretsProfile, rfqSignerOf, rfqSwapActivityInputs, senderIdentityForSwapRecord, solverLightningRail, solverLightningRendezvous, solverOnchainRail, solverOnchainRendezvous, solverRendezvous, spendTxidsOf, swapActivityResolver, validatePlan };
694
+ 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, awaitLockupFunding, chainSourceFrom, claimReceiveLockup, 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 };
package/dist/protocol.js CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  ACTIVITY_TOKEN,
3
3
  LockupAmountMismatchError,
4
4
  LockupNeedsRecoveryError,
5
+ OnchainReceiveNeedsChainSource,
5
6
  QUOTE_OPTIONS,
6
7
  RFQ_SWAP_RETENTION_SECONDS,
7
8
  RefundNotLocallyPossibleError,
@@ -24,7 +25,9 @@ import {
24
25
  marketAssetId,
25
26
  marketCorridor,
26
27
  nextOnchainAction,
28
+ nextOnchainReceiveAction,
27
29
  normalizeRfqSwapRecord,
30
+ onchainReceiveProfile,
28
31
  onchainSendProfile,
29
32
  pushClaim,
30
33
  pushRefundWithoutReceiver,
@@ -43,7 +46,7 @@ import {
43
46
  updateRfqSwapRecord,
44
47
  validatePlan,
45
48
  watchOfferSwaps
46
- } from "./chunk-ITFCQWPG.js";
49
+ } from "./chunk-DQ2DY2L2.js";
47
50
  import {
48
51
  ARKADE_BTC,
49
52
  ASSET_CARRIER_SATS,
@@ -124,7 +127,7 @@ import {
124
127
  verifyLockupAddress,
125
128
  verifyOfferAddress,
126
129
  verifyReceiveInvoice
127
- } from "./chunk-PVB7EBAM.js";
130
+ } from "./chunk-UFJEO4VV.js";
128
131
  import {
129
132
  collectRfqSwaps
130
133
  } from "./chunk-A3SHHRX4.js";
@@ -137,7 +140,8 @@ import { hex } from "@scure/base";
137
140
  var LABELS = {
138
141
  lightning_send: "Lightning send",
139
142
  lightning_receive: "Lightning receive",
140
- onchain_send: "Onchain send"
143
+ onchain_send: "Onchain send",
144
+ onchain_receive: "Onchain receive"
141
145
  };
142
146
  var outcomeToken = (kind, state) => ACTIVITY_TOKEN[corridorOutcome(kind, state)];
143
147
  function swapActivityResolver(deps) {
@@ -662,6 +666,7 @@ export {
662
666
  ONCHAIN_SECONDS_PER_BLOCK,
663
667
  ONCHAIN_SEND_PAIR,
664
668
  OfferCovenantMismatchError,
669
+ OnchainReceiveNeedsChainSource,
665
670
  PreimageNotRecoverableError,
666
671
  QUOTE_OPTIONS,
667
672
  RFQ_SWAP_RETENTION_SECONDS,
@@ -716,11 +721,13 @@ export {
716
721
  makeCachedFeedFetch,
717
722
  newPreimage,
718
723
  nextOnchainAction,
724
+ nextOnchainReceiveAction,
719
725
  normalizeMakerPkScript,
720
726
  normalizeMakerPublicKey,
721
727
  normalizeRfqSwapRecord,
722
728
  offerContract,
723
729
  onchainHtlcScript,
730
+ onchainReceiveProfile,
724
731
  onchainReceiveRequest,
725
732
  onchainSendProfile,
726
733
  onchainSendRequest,
@@ -1,8 +1,8 @@
1
1
  import { RealmLike } from '@arkade-os/sdk/repositories/realm';
2
2
  import { PageRequest, PageResult } from '@arkade-os/sdk';
3
- import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b1 as MarketsCacheEntry } from '../../repository-BuYWGAKz.cjs';
3
+ import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b1 as MarketsCacheEntry } from '../../repository-B4rQWmS2.cjs';
4
4
  import '@arkade-os/solver-discovery';
5
- import '../../rfq-60PGpQ_x.cjs';
5
+ import '../../rfq-BgdgO9OO.cjs';
6
6
 
7
7
  /**
8
8
  * Realm backend for React Native.
@@ -1,8 +1,8 @@
1
1
  import { RealmLike } from '@arkade-os/sdk/repositories/realm';
2
2
  import { PageRequest, PageResult } from '@arkade-os/sdk';
3
- import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b1 as MarketsCacheEntry } from '../../repository-DYnRLPt-.js';
3
+ import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b1 as MarketsCacheEntry } from '../../repository-D_qvJk1S.js';
4
4
  import '@arkade-os/solver-discovery';
5
- import '../../rfq-60PGpQ_x.js';
5
+ import '../../rfq-BgdgO9OO.js';
6
6
 
7
7
  /**
8
8
  * Realm backend for React Native.
@@ -1,8 +1,8 @@
1
1
  import { SQLExecutor } from '@arkade-os/sdk/repositories/sqlite';
2
2
  import { PageRequest, PageResult } from '@arkade-os/sdk';
3
- import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b1 as MarketsCacheEntry } from '../../repository-BuYWGAKz.cjs';
3
+ import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b1 as MarketsCacheEntry } from '../../repository-B4rQWmS2.cjs';
4
4
  import '@arkade-os/solver-discovery';
5
- import '../../rfq-60PGpQ_x.cjs';
5
+ import '../../rfq-BgdgO9OO.cjs';
6
6
 
7
7
  /**
8
8
  * SQLite backend over the SDK's `SQLExecutor`, so any driver plugs in
@@ -1,8 +1,8 @@
1
1
  import { SQLExecutor } from '@arkade-os/sdk/repositories/sqlite';
2
2
  import { PageRequest, PageResult } from '@arkade-os/sdk';
3
- import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b1 as MarketsCacheEntry } from '../../repository-DYnRLPt-.js';
3
+ import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b1 as MarketsCacheEntry } from '../../repository-D_qvJk1S.js';
4
4
  import '@arkade-os/solver-discovery';
5
- import '../../rfq-60PGpQ_x.js';
5
+ import '../../rfq-BgdgO9OO.js';
6
6
 
7
7
  /**
8
8
  * SQLite backend over the SDK's `SQLExecutor`, so any driver plugs in
@@ -1,6 +1,6 @@
1
1
  import { DiscoveredMarket } from '@arkade-os/solver-discovery';
2
2
  import { IWallet, ProvisionedKey, ProvisionedClaimSecret, ArkProvider, RestIndexerProvider, IContractManager, VHTLC, Identity, Network, NetworkName, asset, PageRequest, PageResult } from '@arkade-os/sdk';
3
- import { D as RfqStatus, e as RfqTransport, O as OnchainHtlc, l as ChainUtxo, C as ChainSource, y as OnchainHtlcPhase } from './rfq-60PGpQ_x.js';
3
+ import { D as RfqStatus, e as RfqTransport, O as OnchainHtlc, l as ChainUtxo, C as ChainSource, y as OnchainHtlcPhase } from './rfq-BgdgO9OO.cjs';
4
4
 
5
5
  /** @deprecated Use `Outcome`. Moved off the package root to `@arkade-os/swap/protocol`. */
6
6
  type AssetSwapStatus = "pending" | "cancelling" | "fulfilled" | "cancelled" | "recoverable" | "awaiting_fill" | "claimable" | "claimed" | "refunded_l1";
@@ -482,7 +482,8 @@ interface RfqSwapCommon {
482
482
  refundLocktime: number;
483
483
  createdAt: number;
484
484
  updatedAt: number;
485
- /** Set once the trader's own `refundWithoutReceiver` push landed. */
485
+ /** The trader's own refund: the `refundWithoutReceiver` push that landed, or on
486
+ * `onchain_receive` the L1 HTLC refund. */
486
487
  refundTxid?: string;
487
488
  /**
488
489
  * The ark transactions that SPENT the lockup, from the chain read that ended the swap
@@ -567,10 +568,31 @@ interface LightningReceiveSwap extends RfqSwapCommon {
567
568
  * otherwise the caller persists via {@link RfqSwapManagerCallbacks.saveSwap} and hands
568
569
  * rebuilt swaps to {@link RfqSwapManager.start}.
569
570
  *
570
- * **`onchain:BTC->arkade:BTC` is deliberately not a member**: monitoring only its lockup
571
- * half would silently let the trader's own L1 refund window pass.
572
571
  */
573
- type RfqSwap = LightningSendSwap | OnchainSendSwap | LightningReceiveSwap;
572
+ type RfqSwap = LightningSendSwap | OnchainSendSwap | LightningReceiveSwap | OnchainReceiveSwap;
573
+ /**
574
+ * `onchain:BTC->arkade:BTC`. A {@link LightningReceiveSwap}'s lockup plus an L1
575
+ * HTLC the trader funds and must take back itself. That refund leaf does not
576
+ * expire, so the failure to drive against is the manager finishing the swap
577
+ * while the output still holds the trader's money.
578
+ */
579
+ interface OnchainReceiveSwap extends RfqSwapCommon {
580
+ kind: "onchain_receive";
581
+ expectedAmount: number;
582
+ /** Its `refundLocktime` is the trader's own, NOT {@link RfqSwapCommon}'s. */
583
+ htlc: OnchainHtlc;
584
+ minConfirmations: number;
585
+ /** Required, unlike the send leg's optional `payoutPkScript`: without it
586
+ * the refund cannot be built at all. */
587
+ refundPkScript: Uint8Array;
588
+ funding?: {
589
+ txid: string;
590
+ vout: number;
591
+ };
592
+ claimTxid?: string;
593
+ }
594
+ /** The two legs sharing one claim path, `expectedAmount` gate included. */
595
+ type ReceiveLockupSwap = LightningReceiveSwap | OnchainReceiveSwap;
574
596
  /** What the manager should do next about an onchain-send swap's L1 half.
575
597
  *
576
598
  * @deprecated Use `createSwapClient` and `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
@@ -606,6 +628,16 @@ declare function nextOnchainAction(input: {
606
628
  /** Unix seconds. */
607
629
  now: number;
608
630
  }): OnchainSendAction;
631
+ /** {@link OnchainSendAction}'s mirror, minus `refund_window_closed`: an
632
+ * `nLockTime` refund leaf does not close. */
633
+ type OnchainReceiveAction = "wait" | "refund" | "refunded" | "taken";
634
+ /**
635
+ * Off the SAME phases the send leg reads (see {@link OnchainHtlcPhase}); no
636
+ * clock or margin, `refundable` being the median-time-past verdict itself. */
637
+ declare function nextOnchainReceiveAction(input: {
638
+ phase: OnchainHtlcPhase;
639
+ settled: boolean;
640
+ }): OnchainReceiveAction;
609
641
  /** What the trader's own `refundWithoutReceiver` push returned, or `null` when
610
642
  * the lockup held nothing to return.
611
643
  */
@@ -627,6 +659,14 @@ interface RfqSwapManagerCallbacks {
627
659
  claimOnchain: (swap: OnchainSendSwap, utxo: ChainUtxo) => Promise<{
628
660
  txid: string;
629
661
  }>;
662
+ /**
663
+ * `buildHtlcRefund` over `swap.refundPkScript`, then `chain.broadcast`. Required for
664
+ * {@link claimOnchain}'s reason: monitoring one of these unwired strands the trader's
665
+ * funding. A throw is retried indefinitely.
666
+ */
667
+ refundOnchain: (swap: OnchainReceiveSwap, utxo: ChainUtxo) => Promise<{
668
+ txid: string;
669
+ }>;
630
670
  /**
631
671
  * Claim the solver-funded lockup on a receive leg, revealing `P`. Wire it to
632
672
  * `pushClaim` (the outputs are supplied, so `claimReceiveLockup`'s wait is redundant).
@@ -635,7 +675,7 @@ interface RfqSwapManagerCallbacks {
635
675
  * value check decides WHEN to act; `pushClaim`'s decides whether `P` is published and
636
676
  * is the load-bearing one. Do not drop it because the outer one exists.
637
677
  */
638
- claimLockup: (swap: LightningReceiveSwap, vtxos: readonly LockupVtxo[], options: {
678
+ claimLockup: (swap: ReceiveLockupSwap, vtxos: readonly LockupVtxo[], options: {
639
679
  /** A claim of ours is already out, so `P` is public and the value gate has
640
680
  * nothing left to protect; lets a piecemeal funding still be swept. */
641
681
  partiallyClaimed: boolean;
@@ -686,8 +726,8 @@ interface RfqSwapManagerCallbacks {
686
726
  * A kind whose claim is missing blocks at runtime instead: non-terminal, re-evaluated
687
727
  * every pass, lifted once `setCallbacks` supplies it.
688
728
  */
689
- type AvailableRfqSwapManagerCallbacks = Omit<RfqSwapManagerCallbacks, "claimOnchain" | "claimLockup" | "saveSwap"> & Partial<Pick<RfqSwapManagerCallbacks, "claimOnchain" | "claimLockup" | "saveSwap">>;
690
- type RfqSwapActionName = "claimOnchain" | "claimLockup" | "refundArkade";
729
+ type AvailableRfqSwapManagerCallbacks = Omit<RfqSwapManagerCallbacks, "claimOnchain" | "claimLockup" | "refundOnchain" | "saveSwap"> & Partial<Pick<RfqSwapManagerCallbacks, "claimOnchain" | "claimLockup" | "refundOnchain" | "saveSwap">>;
730
+ type RfqSwapActionName = "claimOnchain" | "claimLockup" | "refundArkade" | "refundOnchain";
691
731
  /** @deprecated Use `createSwapClient` and `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`. */
692
732
  interface RfqSwapManagerEvents {
693
733
  /** Every state change, including backwards ones: `claimed -> claimable` is expected on
@@ -747,6 +787,16 @@ declare class RfqSwapOriginRequired extends Error {
747
787
  readonly rfqId: string;
748
788
  constructor(rfqId: string);
749
789
  }
790
+ /** An `onchain_receive` swap reached a manager with no {@link RfqSwapManagerDeps.chain}, so it
791
+ * could watch only half the corridor. Thrown from `addSwap`, normally the last moment before the
792
+ * trader funds.
793
+ *
794
+ * @deprecated Use `createSwapClient` and `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
795
+ */
796
+ declare class OnchainReceiveNeedsChainSource extends Error {
797
+ readonly rfqId: string;
798
+ constructor(rfqId: string);
799
+ }
750
800
  /** One stored record that could not be turned back into a live swap.
751
801
  *
752
802
  * @deprecated Use `createSwapClient` and `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
@@ -1030,6 +1080,12 @@ declare class RfqSwapManager {
1030
1080
  /** Claim what the solver funded, once it is enough (the inner gate that matters is
1031
1081
  * `pushClaim`'s; see {@link RfqSwapManagerCallbacks.claimLockup}). */
1032
1082
  private claimIfFunded;
1083
+ /** `settled` ends the swap; `returned` does NOT, signalling their L1
1084
+ * funding is stranded. */
1085
+ private driveOnchainReceive;
1086
+ /** `resolved`: the HTLC can hold nothing more. `blocked` is a refusal the
1087
+ * caller applies once the Arkade arm has run. No give-up branch. */
1088
+ private driveOnchainRefund;
1033
1089
  /** `handled` ends the pass; `continue` falls through to the refund gate. */
1034
1090
  private driveOnchain;
1035
1091
  private driveArkadeRefund;
@@ -1095,10 +1151,10 @@ interface RfqSwapOutcome {
1095
1151
  }
1096
1152
 
1097
1153
  /**
1098
- * The swap kinds this projection covers — all three the manager monitors. `onchain_send`'s L1 keys
1099
- * ride in its profile, since no contract row or `OnchainHtlc` field can give them back.
1154
+ * The swap kinds this projection covers — all four the manager monitors. The onchain legs' L1 keys
1155
+ * ride in their profiles, since no contract row or `OnchainHtlc` field can give them back.
1100
1156
  */
1101
- type PersistableRfqSwap = LightningSendSwap | LightningReceiveSwap | OnchainSendSwap;
1157
+ type PersistableRfqSwap = LightningSendSwap | LightningReceiveSwap | OnchainSendSwap | OnchainReceiveSwap;
1102
1158
  /**
1103
1159
  * The serialized covenant parameters a rebuild is given: `VHTLCV2ContractHandler`'s own wire shape,
1104
1160
  * exactly what a lockup's contract row stores under `params`.
@@ -1486,7 +1542,7 @@ type Outcome =
1486
1542
  | "paid" | "cancelling" | "cancelled"
1487
1543
  /** A send leg past `refundLocktime` with a refund push in flight. */
1488
1544
  | "refunding"
1489
- /** The trader's value came back. Send legs only, ever. */
1545
+ /** The trader's value came back: a send leg, or `onchain_receive`'s L1 refund. */
1490
1546
  | "refunded"
1491
1547
  /** A receive leg the trader never claimed: the solver took the lockup back
1492
1548
  * and the incoming payment never arrived. */
@@ -1555,12 +1611,26 @@ declare const CORRIDOR_PASS: {
1555
1611
  readonly actions: readonly ["claimOnchain", "refundArkade"];
1556
1612
  readonly seams: readonly ["indexer", "chain"];
1557
1613
  };
1614
+ readonly onchain_receive: {
1615
+ readonly lockups: readonly [{
1616
+ readonly covenant: "arkade_lockup";
1617
+ readonly owner: "solver";
1618
+ readonly deadline: "refund_locktime";
1619
+ }, {
1620
+ readonly covenant: "onchain_htlc";
1621
+ readonly owner: "trader";
1622
+ readonly deadline: "htlc_refund_locktime";
1623
+ }];
1624
+ readonly actions: readonly ["claimLockup", "refundOnchain"];
1625
+ readonly seams: readonly ["indexer", "chain"];
1626
+ };
1558
1627
  };
1559
1628
  /** Whose the arkade lockup is, per corridor kind (`lockups[0]` on every pass). */
1560
1629
  declare const LOCKUP_OWNER: {
1561
1630
  readonly lightning_send: "trader";
1562
1631
  readonly lightning_receive: "solver";
1563
1632
  readonly onchain_send: "trader";
1633
+ readonly onchain_receive: "solver";
1564
1634
  };
1565
1635
  /** Whether this kind's drive pass reads L1, i.e. needs the onchain corridor's deps. */
1566
1636
  declare const readsChain: (kind: CorridorKind) => boolean;
@@ -1584,7 +1654,7 @@ declare const ACTIVITY_TOKEN: Record<Outcome, string>;
1584
1654
  * A route is two endpoints, each an asset on a corridor, plus the instrument that settles it.
1585
1655
  *
1586
1656
  * Two invariants live in the types: an {@link Endpoint}'s corridor and asset cannot disagree, and
1587
- * `onchain -> arkade` is not in {@link Route}, so a resolved misroute is a compile error (before
1657
+ * only the implemented pairs are in {@link Route}, so a resolved misroute is a compile error (before
1588
1658
  * resolution it is `UnsupportedRoute`, thrown ahead of RFQ disclosure, persistence and funding).
1589
1659
  */
1590
1660
 
@@ -1637,12 +1707,7 @@ type Endpoint<C extends CorridorId = CorridorId> = C extends CorridorId ? {
1637
1707
  } : never;
1638
1708
  /** Shorthand for one corridor's endpoint, as the route union spells it. */
1639
1709
  type Ep<C extends CorridorId> = Endpoint<C>;
1640
- /**
1641
- * The implemented routes, as a closed union.
1642
- *
1643
- * `onchain -> arkade` is deliberately absent until the manager owns the
1644
- * trader's L1 refund path end to end.
1645
- */
1710
+ /** The implemented routes, as a closed union. */
1646
1711
  type Route = {
1647
1712
  give: Ep<"arkade">;
1648
1713
  take: Ep<"arkade">;
@@ -1655,6 +1720,9 @@ type Route = {
1655
1720
  } | {
1656
1721
  give: Ep<"arkade">;
1657
1722
  take: Ep<"onchain">;
1723
+ } | {
1724
+ give: Ep<"onchain">;
1725
+ take: Ep<"arkade">;
1658
1726
  };
1659
1727
  /**
1660
1728
  * The one thing a counterparty must see, when a route has one.
@@ -2258,4 +2326,4 @@ declare class InMemoryAssetSwapRepository implements AssetSwapRepository {
2258
2326
  [Symbol.asyncDispose](): Promise<void>;
2259
2327
  }
2260
2328
 
2261
- export { type Hex as $, type AssetId as A, type AssetScale as B, type Corridor as C, type AssetSwapId as D, type AtomicDecimal as E, type AuctionMarketRef as F, type AuctionProvenance as G, BITCOIN_RAILS as H, type Instrument as I, BTC_ASSET_PART as J, type BitcoinRail as K, type LockupSpendIndexer as L, CORRIDORS as M, type NetworkRef as N, type OfferSwapRecord as O, type PinnedAmount as P, type QuoteId as Q, type Rail as R, type SwapRecord as S, CORRIDOR_PASS as T, type CardMarketRef as U, type CorridorId as V, type CorridorKind as W, type DepositArtifact as X, type DisplayDecimal as Y, type Endpoint as Z, type Ep as _, type RfqSwapRecordStore as a, toRfqAmountSide as a$, LOCKUP_OWNER as a0, type MarketBackend as a1, type MarketRef as a2, OFFER_SWAP_ID_PREFIX as a3, type Outcome as a4, type ParsedAssetId as a5, type Quote as a6, type QuoteLeg as a7, RAILS as a8, RFQ_SWAP_ID_PREFIX as a9, familyOfSwapId as aA, formatAssetId as aB, fromAtomicDecimal as aC, fromRfqAmountSide as aD, fundsFromWallet as aE, instrumentOf as aF, isAssetId as aG, isAtomicDecimal as aH, isBtcAsset as aI, isBtcAssetLenient as aJ, isNetworkRef as aK, issuanceOf as aL, legOf as aM, offerOutcome as aN, parseAssetId as aO, quoteIdOfSwapId as aP, railOf as aQ, railOfCorridor as aR, readsChain as aS, recordArtifact as aT, recordEndpoint as aU, recordInstrument as aV, recordLeg as aW, recordOutcome as aX, sameAsset as aY, swapOf as aZ, toAtomicDecimal as a_, type RailOf as aa, type RankedBid as ab, type RawState as ac, type RecordedArtifact as ad, type RecordedEndpoint as ae, type RecordedInstrument as af, type RecordedLeg as ag, type RestoredMarketRef as ah, type RfqAmountSide as ai, type SnapshotRef as aj, type Swap as ak, type SwapFamily as al, type SwapRecordCommon as am, type SwapUpdate as an, type Unsubscribe as ao, arkadeAsset as ap, artifactOf as aq, assetPartOf as ar, assetSwapIdOf as as, bitcoinNetworkOf as at, btcAssetPart as au, btcOn as av, corridorOfRail as aw, corridorOutcome as ax, decodeRfqAmount as ay, encodeRfqAmount as az, type CorridorSwapRecord as b, toSafeNumber as b0, type MarketsCacheEntry as b1, InMemoryAssetSwapRepository as b2, type RfqSwapState as b3, type SwapContractRegistry as b4, type SwapOperator as b5, isRfqSwapTerminal as b6, type RfqSwapManagerCallbacks as b7, type RfqSwapActionName as b8, type SwapSecretsProjection as b9, type RfqSwapManagerEvents as bA, type RfqSwapOrigin as bB, RfqSwapOriginRequired as bC, type RfqSwapOutcome as bD, addAssetSwap as bE, awaitRfqResolution as bF, createRfqSwapRecord as bG, findLockupVtxos as bH, getAssetSwaps as bI, isRfqTerminal as bJ, nextOnchainAction as bK, normalizeRfqSwapRecord as bL, preimageForSwapRecord as bM, pushRefundWithoutReceiver as bN, readLockupFate as bO, rebuildRfqSwap as bP, refundIfUnresolved as bQ, rfqSwapOriginOf as bR, shouldRetainRfqSwap as bS, swapSecretsToRecord as bT, updateAssetSwap as bU, updateRfqSwapRecord as bV, type LockupContractSource as ba, type RfqSwap as bb, type ArkadeRefundResult as bc, type LockupVtxo as bd, type AvailableRfqSwapManagerCallbacks as be, BTC_ASSET_ID as bf, type LightningReceiveSwap as bg, type LightningSendSwap as bh, type LockupFate as bi, LockupNeedsRecoveryError as bj, type LockupParams as bk, type LockupSpend as bl, type OnchainSendAction as bm, type OnchainSendSwap as bn, type PersistableRfqSwap as bo, type PreimageBlockedReason as bp, PreimageNotRecoverableError as bq, RFQ_SWAP_RETENTION_SECONDS as br, type RefundOutcome as bs, type RfqRestoreFailure as bt, type RfqRestoreOptions as bu, type RfqRestoreResult as bv, type RfqSwapLockup as bw, RfqSwapManager as bx, type RfqSwapManagerConfig as by, type RfqSwapManagerDeps as bz, type AssetSwapStatus as c, type AssetSwapRepository as d, type RfqSwapRecord as e, type RfqSwapPageFilter as f, type RfqSwapPageCursor as g, type AssetSwap as h, type RouteResolution as i, type ResolvedEndpoint as j, type Route as k, type QuoteInput as l, type Pubkey as m, ACTIVITY_TOKEN as n, ARKADE_ASSET_NAMESPACE as o, Amount as p, AmountFormatError as q, type AmountOn as r, type AmountRefusal as s, type Artifact as t, AssetIdError as u, type AssetIdRefusal as v, type AssetNamespace as w, type AssetOn as x, type AssetPart as y, type AssetRef as z };
2329
+ export { type Hex as $, type AssetId as A, type AssetScale as B, type Corridor as C, type AssetSwapId as D, type AtomicDecimal as E, type AuctionMarketRef as F, type AuctionProvenance as G, BITCOIN_RAILS as H, type Instrument as I, BTC_ASSET_PART as J, type BitcoinRail as K, type LockupSpendIndexer as L, CORRIDORS as M, type NetworkRef as N, type OfferSwapRecord as O, type PinnedAmount as P, type QuoteId as Q, type Rail as R, type SwapRecord as S, CORRIDOR_PASS as T, type CardMarketRef as U, type CorridorId as V, type CorridorKind as W, type DepositArtifact as X, type DisplayDecimal as Y, type Endpoint as Z, type Ep as _, type RfqSwapRecordStore as a, toRfqAmountSide as a$, LOCKUP_OWNER as a0, type MarketBackend as a1, type MarketRef as a2, OFFER_SWAP_ID_PREFIX as a3, type Outcome as a4, type ParsedAssetId as a5, type Quote as a6, type QuoteLeg as a7, RAILS as a8, RFQ_SWAP_ID_PREFIX as a9, familyOfSwapId as aA, formatAssetId as aB, fromAtomicDecimal as aC, fromRfqAmountSide as aD, fundsFromWallet as aE, instrumentOf as aF, isAssetId as aG, isAtomicDecimal as aH, isBtcAsset as aI, isBtcAssetLenient as aJ, isNetworkRef as aK, issuanceOf as aL, legOf as aM, offerOutcome as aN, parseAssetId as aO, quoteIdOfSwapId as aP, railOf as aQ, railOfCorridor as aR, readsChain as aS, recordArtifact as aT, recordEndpoint as aU, recordInstrument as aV, recordLeg as aW, recordOutcome as aX, sameAsset as aY, swapOf as aZ, toAtomicDecimal as a_, type RailOf as aa, type RankedBid as ab, type RawState as ac, type RecordedArtifact as ad, type RecordedEndpoint as ae, type RecordedInstrument as af, type RecordedLeg as ag, type RestoredMarketRef as ah, type RfqAmountSide as ai, type SnapshotRef as aj, type Swap as ak, type SwapFamily as al, type SwapRecordCommon as am, type SwapUpdate as an, type Unsubscribe as ao, arkadeAsset as ap, artifactOf as aq, assetPartOf as ar, assetSwapIdOf as as, bitcoinNetworkOf as at, btcAssetPart as au, btcOn as av, corridorOfRail as aw, corridorOutcome as ax, decodeRfqAmount as ay, encodeRfqAmount as az, type CorridorSwapRecord as b, toSafeNumber as b0, type MarketsCacheEntry as b1, InMemoryAssetSwapRepository as b2, type RfqSwapState as b3, type SwapContractRegistry as b4, type SwapOperator as b5, isRfqSwapTerminal as b6, type RfqSwapManagerCallbacks as b7, type RfqSwapActionName as b8, type SwapSecretsProjection as b9, type RfqSwapLockup as bA, RfqSwapManager as bB, type RfqSwapManagerConfig as bC, type RfqSwapManagerDeps as bD, type RfqSwapManagerEvents as bE, type RfqSwapOrigin as bF, RfqSwapOriginRequired as bG, type RfqSwapOutcome as bH, addAssetSwap as bI, awaitRfqResolution as bJ, createRfqSwapRecord as bK, findLockupVtxos as bL, getAssetSwaps as bM, isRfqTerminal as bN, nextOnchainAction as bO, nextOnchainReceiveAction as bP, normalizeRfqSwapRecord as bQ, preimageForSwapRecord as bR, pushRefundWithoutReceiver as bS, readLockupFate as bT, rebuildRfqSwap as bU, refundIfUnresolved as bV, rfqSwapOriginOf as bW, shouldRetainRfqSwap as bX, swapSecretsToRecord as bY, updateAssetSwap as bZ, updateRfqSwapRecord as b_, type LockupContractSource as ba, type RfqSwap as bb, type ArkadeRefundResult as bc, type LockupVtxo as bd, type AvailableRfqSwapManagerCallbacks as be, BTC_ASSET_ID as bf, type LightningReceiveSwap as bg, type LightningSendSwap as bh, type LockupFate as bi, LockupNeedsRecoveryError as bj, type LockupParams as bk, type LockupSpend as bl, type OnchainReceiveAction as bm, OnchainReceiveNeedsChainSource as bn, type OnchainReceiveSwap as bo, type OnchainSendAction as bp, type OnchainSendSwap as bq, type PersistableRfqSwap as br, type PreimageBlockedReason as bs, PreimageNotRecoverableError as bt, RFQ_SWAP_RETENTION_SECONDS as bu, type ReceiveLockupSwap as bv, type RefundOutcome as bw, type RfqRestoreFailure as bx, type RfqRestoreOptions as by, type RfqRestoreResult as bz, type AssetSwapStatus as c, type AssetSwapRepository as d, type RfqSwapRecord as e, type RfqSwapPageFilter as f, type RfqSwapPageCursor as g, type AssetSwap as h, type RouteResolution as i, type ResolvedEndpoint as j, type Route as k, type QuoteInput as l, type Pubkey as m, ACTIVITY_TOKEN as n, ARKADE_ASSET_NAMESPACE as o, Amount as p, AmountFormatError as q, type AmountOn as r, type AmountRefusal as s, type Artifact as t, AssetIdError as u, type AssetIdRefusal as v, type AssetNamespace as w, type AssetOn as x, type AssetPart as y, type AssetRef as z };