@arkade-os/swap 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advanced.cjs +228 -63
- package/dist/advanced.d.cts +6 -6
- package/dist/advanced.d.ts +6 -6
- package/dist/advanced.js +2 -2
- package/dist/{chunk-GJKGPE3S.js → chunk-QFM55KP2.js} +175 -29
- package/dist/{chunk-HDCC3JZR.js → chunk-SDPNWPGY.js} +30 -2
- package/dist/index.cjs +219 -54
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -2
- package/dist/{lockupContract-CdXh9yIr.d.ts → lockupContract-CKPFpIt9.d.ts} +1 -1
- package/dist/{lockupContract-QfbsjyXG.d.cts → lockupContract-CpJXTjX_.d.cts} +1 -1
- package/dist/{offer-BxzPQ6zh.d.cts → offer-Boxive2u.d.cts} +1 -1
- package/dist/{offer-Q1lVhrVX.d.ts → offer-Drw1k_jt.d.ts} +1 -1
- package/dist/{offerFillPlan-BfcxbVvw.d.cts → offerFillPlan-BxNkWLtw.d.cts} +2 -2
- package/dist/{offerFillPlan-C11P2ek2.d.ts → offerFillPlan-D2N4s7Xe.d.ts} +2 -2
- package/dist/protocol.cjs +83 -33
- package/dist/protocol.d.cts +11 -27
- package/dist/protocol.d.ts +11 -27
- package/dist/protocol.js +1 -1
- package/dist/repositories/realm/index.d.cts +1 -1
- package/dist/repositories/realm/index.d.ts +1 -1
- package/dist/repositories/sqlite/index.d.cts +1 -1
- package/dist/repositories/sqlite/index.d.ts +1 -1
- package/dist/{repository-Cut4eEkm.d.cts → repository-DFDNvcZ7.d.cts} +26 -4
- package/dist/{repository-BOQ1qYoj.d.ts → repository-Dn1V17T2.d.ts} +26 -4
- package/dist/{watch-D15U0QpD.d.ts → watch-D-mc_wfD.d.ts} +1 -1
- package/dist/{watch-D4PeBZ3H.d.cts → watch-DFNMY2K-.d.cts} +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { e as AcceptConflict, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, A as AssetAliasTable, B as BuildOfferFillPlanOpts, o as CancelOutcome, q as ClientDisposed, E as CorridorOverrides, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, d as DiscoverySnapshot, K as DiscoverySnapshotUnavailable, N as DriveMode, Q as ExchangeOptions, T as FeeCeiling, W as FillSponsor, X as FillSponsorFare, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a1 as Market, a2 as MarketLeg, a3 as MaxFeeExceeded, a4 as MissingCorridorDep, a5 as NotCancellable, a6 as OFFER_FILL_OWNERS, a7 as OFFER_FILL_TEMPLATE, ad as OperatorUnreachable, af as PayOptions, ag as PayResult, ah as QuoteCheck, ai as QuoteExpired, ak as QuoteVerificationFailed, al as REGISTRY_URL, am as ReceiveArtifact, an as ReceiveOptions, ao as ReceiveRequest, ap as RecoveryResult, aq as RegisteredAsset, ar as RfqAuctionPolicy, av as RfqTransportFactory, ax as SWAP_ERROR_NAMES, ay as SwapClient, az as SwapClientConfig, aC as SwapDriveRefusedError, aD as SwapError, aE as SwapErrorName, aF as SwapFilter, S as SwapPolicy, aG as UnsupportedRoute, aH as VerbDeps, aK as buildOfferFillPlan, aM as canonicalAssetId, aS as createSwapClient, aU as deepFreeze, aV as digestJointGraph, aZ as exchange, b3 as isSwapError, bd as pay, bh as receive, bo as unsignedPsbtBytes, bq as verifyJointGraph, br as verifyOfferFillPlan } from './offerFillPlan-
|
|
2
|
-
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry, a7 as Outcome, ap as Swap, l as QuoteInput, i as RouteResolution, a9 as Quote, as as SwapUpdate, au as Unsubscribe } from './repository-
|
|
3
|
-
export { o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, A as AssetId, v as AssetIdError, w as AssetIdRefusal, x as AssetNamespace, y as AssetOn, z as AssetPart, B as AssetPaymentInput, D as AssetPaymentTerms, E as AssetRef, F as AssetScale, G as AssetSwapId, H as AtomicDecimal, J as AuctionMarketRef, K as AuctionProvenance, M as BITCOIN_RAILS, T as BTC_ASSET_PART, U as BitcoinRail, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, b as CorridorSwapRecord, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, ba as InMemoryAssetSwapRepository, I as Instrument, L as LockupSpendIndexer, a4 as MarketBackend, a5 as MarketRef, N as NetworkRef, O as OfferSwapRecord, a8 as ParsedAssetId, P as PinnedAmount, Q as QuoteId, aa as QuoteLeg, ab as RAILS, R as Rail, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, j as ResolvedEndpoint, am as RestoredMarketRef, bb as RfqSwapState, k as Route, ao as SnapshotRef, bc as SwapContractRegistry, aq as SwapFamily, bd as SwapOperator, ar as SwapRecordCommon, at as TaxiIdentity, av as VerifiedCarrierTerms, aw as arkadeAsset, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, be as isRfqSwapTerminal, aT as issuanceOf, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, b4 as sameAsset, b6 as toAtomicDecimal } from './repository-
|
|
1
|
+
export { e as AcceptConflict, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, A as AssetAliasTable, B as BuildOfferFillPlanOpts, o as CancelOutcome, q as ClientDisposed, E as CorridorOverrides, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, d as DiscoverySnapshot, K as DiscoverySnapshotUnavailable, N as DriveMode, Q as ExchangeOptions, T as FeeCeiling, W as FillSponsor, X as FillSponsorFare, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a1 as Market, a2 as MarketLeg, a3 as MaxFeeExceeded, a4 as MissingCorridorDep, a5 as NotCancellable, a6 as OFFER_FILL_OWNERS, a7 as OFFER_FILL_TEMPLATE, ad as OperatorUnreachable, af as PayOptions, ag as PayResult, ah as QuoteCheck, ai as QuoteExpired, ak as QuoteVerificationFailed, al as REGISTRY_URL, am as ReceiveArtifact, an as ReceiveOptions, ao as ReceiveRequest, ap as RecoveryResult, aq as RegisteredAsset, ar as RfqAuctionPolicy, av as RfqTransportFactory, ax as SWAP_ERROR_NAMES, ay as SwapClient, az as SwapClientConfig, aC as SwapDriveRefusedError, aD as SwapError, aE as SwapErrorName, aF as SwapFilter, S as SwapPolicy, aG as UnsupportedRoute, aH as VerbDeps, aK as buildOfferFillPlan, aM as canonicalAssetId, aS as createSwapClient, aU as deepFreeze, aV as digestJointGraph, aZ as exchange, b3 as isSwapError, bd as pay, bh as receive, bo as unsignedPsbtBytes, bq as verifyJointGraph, br as verifyOfferFillPlan } from './offerFillPlan-D2N4s7Xe.js';
|
|
2
|
+
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry, a7 as Outcome, ap as Swap, l as QuoteInput, i as RouteResolution, a9 as Quote, as as SwapUpdate, au as Unsubscribe } from './repository-Dn1V17T2.js';
|
|
3
|
+
export { o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, A as AssetId, v as AssetIdError, w as AssetIdRefusal, x as AssetNamespace, y as AssetOn, z as AssetPart, B as AssetPaymentInput, D as AssetPaymentTerms, E as AssetRef, F as AssetScale, G as AssetSwapId, H as AtomicDecimal, J as AuctionMarketRef, K as AuctionProvenance, M as BITCOIN_RAILS, T as BTC_ASSET_PART, U as BitcoinRail, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, b as CorridorSwapRecord, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, ba as InMemoryAssetSwapRepository, I as Instrument, L as LockupSpendIndexer, a4 as MarketBackend, a5 as MarketRef, N as NetworkRef, O as OfferSwapRecord, a8 as ParsedAssetId, P as PinnedAmount, Q as QuoteId, aa as QuoteLeg, ab as RAILS, R as Rail, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, j as ResolvedEndpoint, am as RestoredMarketRef, bb as RfqSwapState, k as Route, ao as SnapshotRef, bc as SwapContractRegistry, aq as SwapFamily, bd as SwapOperator, ar as SwapRecordCommon, at as TaxiIdentity, av as VerifiedCarrierTerms, aw as arkadeAsset, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, be as isRfqSwapTerminal, aT as issuanceOf, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, b4 as sameAsset, b6 as toAtomicDecimal } from './repository-Dn1V17T2.js';
|
|
4
4
|
export { C as ChainSource, I as InvoiceFacts, a as RFQ_REFUSAL_ERROR_CODES, b as RfqRefusalDetail, c as RfqRefusalErrorCode, d as RfqRefusalUnit, S as SwapRefusal, T as TxStatus, i as isRfqRefusalErrorCode } from './rfq-CP-P0PSL.js';
|
|
5
5
|
import { PageRequest, PageResult, PaymentHandle, PaymentRail, RouterPreferences, Wallet, PaymentRouter, PaymentStatus } from '@arkade-os/sdk';
|
|
6
|
-
export { C as CLAIM_PACKET_TYPE, a as ClaimPacketShape, L as LockupRegistrationFailed, S as SEALED_CIPHERTEXT_LENGTH, b as appendArkadeScript, c as claimPacketShape } from './lockupContract-
|
|
6
|
+
export { C as CLAIM_PACKET_TYPE, a as ClaimPacketShape, L as LockupRegistrationFailed, S as SEALED_CIPHERTEXT_LENGTH, b as appendArkadeScript, c as claimPacketShape } from './lockupContract-CKPFpIt9.js';
|
|
7
7
|
import '@arkade-os/solver-discovery';
|
|
8
|
-
import './offer-
|
|
8
|
+
import './offer-Drw1k_jt.js';
|
|
9
9
|
import 'nostr-tools';
|
|
10
10
|
|
|
11
11
|
/** Browser backend over the SDK's shared IndexedDB manager. */
|
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
unsignedPsbtBytes,
|
|
63
63
|
verifyJointGraph,
|
|
64
64
|
verifyOfferFillPlan
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-SDPNWPGY.js";
|
|
66
66
|
import {
|
|
67
67
|
Amount,
|
|
68
68
|
AmountFormatError,
|
|
@@ -73,7 +73,7 @@ import {
|
|
|
73
73
|
isRfqSwapTerminal,
|
|
74
74
|
quoteIdOfSwapId,
|
|
75
75
|
toAtomicDecimal
|
|
76
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-QFM55KP2.js";
|
|
77
77
|
import {
|
|
78
78
|
CLAIM_PACKET_TYPE,
|
|
79
79
|
LockupRegistrationFailed,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { asset, RelativeTimelock, OperatorInfo, ArkTxInput, Outpoint, IWallet, EmulatorProvider, arkade } from '@arkade-os/sdk';
|
|
2
|
-
import { d as AssetSwapRepository } from './repository-
|
|
2
|
+
import { d as AssetSwapRepository } from './repository-DFDNvcZ7.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Coverage: whether an offer's script is in the wallet's watched set. `createOffer` promotes; the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { asset, RelativeTimelock, OperatorInfo, ArkTxInput, Outpoint, IWallet, EmulatorProvider, arkade } from '@arkade-os/sdk';
|
|
2
|
-
import { d as AssetSwapRepository } from './repository-
|
|
2
|
+
import { d as AssetSwapRepository } from './repository-Dn1V17T2.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Coverage: whether an offer's script is in the wallet's watched set. `createOffer` promotes; the
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IWallet, NetworkName, Network, SignerSet, OnchainProvider, OperatorInfo, VHTLC, ProvisionedKey, ProvisionedClaimSecret, Transaction } from '@arkade-os/sdk';
|
|
2
|
-
import { bd as SwapOperator, d as AssetSwapRepository, m as Pubkey, bf as RfqSwapManagerCallbacks, C as Corridor, I as Instrument, bg as RfqSwapActionName, N as NetworkRef, A as AssetId, ao as SnapshotRef, a4 as MarketBackend, X as CardMarketRef, a5 as MarketRef, E as AssetRef, r as AmountOn, ap as Swap, Y as CorridorId, _ as DepositArtifact, l as QuoteInput, a9 as Quote, ae as RankedBid, as as SwapUpdate, au as Unsubscribe, S as SwapRecord, Q as QuoteId, a7 as Outcome, L as LockupSpendIndexer, bc as SwapContractRegistry, j as ResolvedEndpoint, P as PinnedAmount, D as AssetPaymentTerms, B as AssetPaymentInput, O as OfferSwapRecord, G as AssetSwapId, aq as SwapFamily, i as RouteResolution } from './repository-
|
|
2
|
+
import { bd as SwapOperator, d as AssetSwapRepository, m as Pubkey, bf as RfqSwapManagerCallbacks, C as Corridor, I as Instrument, bg as RfqSwapActionName, N as NetworkRef, A as AssetId, ao as SnapshotRef, a4 as MarketBackend, X as CardMarketRef, a5 as MarketRef, E as AssetRef, r as AmountOn, ap as Swap, Y as CorridorId, _ as DepositArtifact, l as QuoteInput, a9 as Quote, ae as RankedBid, as as SwapUpdate, au as Unsubscribe, S as SwapRecord, Q as QuoteId, a7 as Outcome, L as LockupSpendIndexer, bc as SwapContractRegistry, j as ResolvedEndpoint, P as PinnedAmount, D as AssetPaymentTerms, B as AssetPaymentInput, O as OfferSwapRecord, G as AssetSwapId, aq as SwapFamily, i as RouteResolution } from './repository-DFDNvcZ7.cjs';
|
|
3
3
|
import { I as InvoiceFacts, C as ChainSource, R as RfqQuote, e as RfqTransport, L as LightningSendContractParams, f as LightningReceiveContractParams, O as OnchainHtlc, g as OnchainHtlcParams, h as OnchainNetwork, S as SwapRefusal } from './rfq-CP-P0PSL.cjs';
|
|
4
4
|
import { Network as Network$1, LocalCardInput, TransportCardFetcher, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
|
|
5
|
-
import { D as DerivedOffer, F as FillFunding, a as FillOutpoint, b as FillInputOwner } from './offer-
|
|
5
|
+
import { D as DerivedOffer, F as FillFunding, a as FillOutpoint, b as FillInputOwner } from './offer-Boxive2u.cjs';
|
|
6
6
|
import * as nostr_tools from 'nostr-tools';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IWallet, NetworkName, Network, SignerSet, OnchainProvider, OperatorInfo, VHTLC, ProvisionedKey, ProvisionedClaimSecret, Transaction } from '@arkade-os/sdk';
|
|
2
|
-
import { bd as SwapOperator, d as AssetSwapRepository, m as Pubkey, bf as RfqSwapManagerCallbacks, C as Corridor, I as Instrument, bg as RfqSwapActionName, N as NetworkRef, A as AssetId, ao as SnapshotRef, a4 as MarketBackend, X as CardMarketRef, a5 as MarketRef, E as AssetRef, r as AmountOn, ap as Swap, Y as CorridorId, _ as DepositArtifact, l as QuoteInput, a9 as Quote, ae as RankedBid, as as SwapUpdate, au as Unsubscribe, S as SwapRecord, Q as QuoteId, a7 as Outcome, L as LockupSpendIndexer, bc as SwapContractRegistry, j as ResolvedEndpoint, P as PinnedAmount, D as AssetPaymentTerms, B as AssetPaymentInput, O as OfferSwapRecord, G as AssetSwapId, aq as SwapFamily, i as RouteResolution } from './repository-
|
|
2
|
+
import { bd as SwapOperator, d as AssetSwapRepository, m as Pubkey, bf as RfqSwapManagerCallbacks, C as Corridor, I as Instrument, bg as RfqSwapActionName, N as NetworkRef, A as AssetId, ao as SnapshotRef, a4 as MarketBackend, X as CardMarketRef, a5 as MarketRef, E as AssetRef, r as AmountOn, ap as Swap, Y as CorridorId, _ as DepositArtifact, l as QuoteInput, a9 as Quote, ae as RankedBid, as as SwapUpdate, au as Unsubscribe, S as SwapRecord, Q as QuoteId, a7 as Outcome, L as LockupSpendIndexer, bc as SwapContractRegistry, j as ResolvedEndpoint, P as PinnedAmount, D as AssetPaymentTerms, B as AssetPaymentInput, O as OfferSwapRecord, G as AssetSwapId, aq as SwapFamily, i as RouteResolution } from './repository-Dn1V17T2.js';
|
|
3
3
|
import { I as InvoiceFacts, C as ChainSource, R as RfqQuote, e as RfqTransport, L as LightningSendContractParams, f as LightningReceiveContractParams, O as OnchainHtlc, g as OnchainHtlcParams, h as OnchainNetwork, S as SwapRefusal } from './rfq-CP-P0PSL.js';
|
|
4
4
|
import { Network as Network$1, LocalCardInput, TransportCardFetcher, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
|
|
5
|
-
import { D as DerivedOffer, F as FillFunding, a as FillOutpoint, b as FillInputOwner } from './offer-
|
|
5
|
+
import { D as DerivedOffer, F as FillFunding, a as FillOutpoint, b as FillInputOwner } from './offer-Drw1k_jt.js';
|
|
6
6
|
import * as nostr_tools from 'nostr-tools';
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/protocol.cjs
CHANGED
|
@@ -3516,10 +3516,11 @@ async function readLockupFate(indexer, input) {
|
|
|
3516
3516
|
const spentBy = /* @__PURE__ */ new Map();
|
|
3517
3517
|
let everySpendNamed = true;
|
|
3518
3518
|
let sweptLeft = false;
|
|
3519
|
+
let live = false;
|
|
3519
3520
|
for (const vtxo of all) {
|
|
3520
3521
|
if (!(0, import_sdk8.isVtxoSpent)(vtxo)) {
|
|
3521
|
-
if (
|
|
3522
|
-
|
|
3522
|
+
if (input.receiver && vtxo.isSwept) sweptLeft = true;
|
|
3523
|
+
else live = true;
|
|
3523
3524
|
continue;
|
|
3524
3525
|
}
|
|
3525
3526
|
if (vtxo.spentBy)
|
|
@@ -3529,8 +3530,16 @@ async function readLockupFate(indexer, input) {
|
|
|
3529
3530
|
});
|
|
3530
3531
|
else everySpendNamed = false;
|
|
3531
3532
|
}
|
|
3533
|
+
if (live && (!input.receiver || spentBy.size === 0)) return { fate: "open" };
|
|
3532
3534
|
const spends = [...spentBy.values()];
|
|
3533
|
-
const
|
|
3535
|
+
const arkTxids = new Set(spends.flatMap((spend) => spend.txid ? [spend.txid] : []));
|
|
3536
|
+
let txs;
|
|
3537
|
+
try {
|
|
3538
|
+
({ txs } = await indexer.getVirtualTxs([.../* @__PURE__ */ new Set([...spentBy.keys(), ...arkTxids])]));
|
|
3539
|
+
} catch (error) {
|
|
3540
|
+
if (live) return { fate: "open" };
|
|
3541
|
+
throw error;
|
|
3542
|
+
}
|
|
3534
3543
|
const refunded = /* @__PURE__ */ new Set();
|
|
3535
3544
|
const leafScripts = /* @__PURE__ */ new Set();
|
|
3536
3545
|
for (const raw of txs) {
|
|
@@ -3540,18 +3549,29 @@ async function readLockupFate(indexer, input) {
|
|
|
3540
3549
|
} catch {
|
|
3541
3550
|
continue;
|
|
3542
3551
|
}
|
|
3543
|
-
|
|
3552
|
+
const checkpoint = spentBy.has(tx.id);
|
|
3553
|
+
if (!checkpoint && !arkTxids.has(tx.id)) continue;
|
|
3544
3554
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
3545
3555
|
const spent = tx.getInput(i);
|
|
3546
3556
|
if (!spent.txid) continue;
|
|
3547
3557
|
const txid = import_base7.hex.encode(spent.txid);
|
|
3558
|
+
if (!checkpoint) {
|
|
3559
|
+
if (spent.index !== 0 || !spentBy.has(txid)) continue;
|
|
3560
|
+
const preimage = candidateWitnessItems(tx, i).find(
|
|
3561
|
+
(candidate) => hashesTo(candidate, input.paymentHash)
|
|
3562
|
+
);
|
|
3563
|
+
if (preimage) {
|
|
3564
|
+
return live ? { fate: "open", preimage } : { fate: "claimed", preimage, spends };
|
|
3565
|
+
}
|
|
3566
|
+
continue;
|
|
3567
|
+
}
|
|
3548
3568
|
const vtxo = all.find(
|
|
3549
3569
|
(vtxo2) => vtxo2.txid === txid && vtxo2.vout === spent.index && vtxo2.spentBy === tx.id
|
|
3550
3570
|
);
|
|
3551
3571
|
if (!vtxo) continue;
|
|
3552
3572
|
for (const candidate of candidateWitnessItems(tx, i)) {
|
|
3553
3573
|
if (hashesTo(candidate, input.paymentHash)) {
|
|
3554
|
-
return { fate: "claimed", preimage: candidate, spends };
|
|
3574
|
+
return live ? { fate: "open", preimage: candidate } : { fate: "claimed", preimage: candidate, spends };
|
|
3555
3575
|
}
|
|
3556
3576
|
}
|
|
3557
3577
|
const leafScript = refundLeafScript(tx, i);
|
|
@@ -3561,7 +3581,7 @@ async function readLockupFate(indexer, input) {
|
|
|
3561
3581
|
}
|
|
3562
3582
|
}
|
|
3563
3583
|
}
|
|
3564
|
-
if (sweptLeft) return { fate: "open" };
|
|
3584
|
+
if (live || sweptLeft) return { fate: "open" };
|
|
3565
3585
|
return everySpendNamed && all.every((vtxo) => refunded.has(`${vtxo.txid}:${vtxo.vout}`)) ? { fate: "returned", spends, leafScripts: [...leafScripts] } : { fate: "unknown" };
|
|
3566
3586
|
}
|
|
3567
3587
|
var assertNoneSwept = (vtxos, contract) => {
|
|
@@ -4652,6 +4672,11 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
4652
4672
|
)) {
|
|
4653
4673
|
fate = { fate: "unknown" };
|
|
4654
4674
|
}
|
|
4675
|
+
if (swap.kind === "lightning_receive" && fate.fate !== "exited" && fate.fate !== "returned") {
|
|
4676
|
+
const pending = await this.finalizeOwnClaim(swap);
|
|
4677
|
+
const windowOpen = fate.fate === "open" && this.config.now() < swap.refundLocktime;
|
|
4678
|
+
if (pending !== "none" && !windowOpen) return;
|
|
4679
|
+
}
|
|
4655
4680
|
if (swap.kind === "onchain_receive") return this.driveOnchainReceive(swap, fate);
|
|
4656
4681
|
if (fate.fate === "claimed" || fate.fate === "returned") {
|
|
4657
4682
|
this.stampLockupSpends(swap, fate.spends);
|
|
@@ -4664,8 +4689,13 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
4664
4689
|
}
|
|
4665
4690
|
if (swap.kind === "lightning_receive") {
|
|
4666
4691
|
if (fate.fate === "exited") return this.blockExitedLockup(swap, fate);
|
|
4667
|
-
if (fate.fate === "open")
|
|
4668
|
-
|
|
4692
|
+
if (fate.fate === "open") {
|
|
4693
|
+
return this.driveReceiveClaim(swap, fate.preimage !== void 0);
|
|
4694
|
+
}
|
|
4695
|
+
if (fate.fate === "unknown" && swap.claimTxid !== void 0) return;
|
|
4696
|
+
if (this.config.now() >= swap.refundLocktime) {
|
|
4697
|
+
return this.driveReceiveClaim(swap, false);
|
|
4698
|
+
}
|
|
4669
4699
|
return;
|
|
4670
4700
|
}
|
|
4671
4701
|
if (swap.kind === "onchain_send") {
|
|
@@ -4678,6 +4708,25 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
4678
4708
|
}
|
|
4679
4709
|
await this.driveArkadeRefund(swap);
|
|
4680
4710
|
}
|
|
4711
|
+
/** `none` when no claim of ours is pending; `failed` covers a pending read that failed too. */
|
|
4712
|
+
async finalizeOwnClaim(swap) {
|
|
4713
|
+
const pendingClaims = this.callbacks?.pendingClaims;
|
|
4714
|
+
const finalize = this.callbacks?.finalizeClaim;
|
|
4715
|
+
if (!pendingClaims || !finalize || !this.config.enableAutoActions) return "none";
|
|
4716
|
+
try {
|
|
4717
|
+
const pending = await pendingClaims(swap);
|
|
4718
|
+
if (pending.length === 0) return "none";
|
|
4719
|
+
if (swap.claimTxid === void 0) {
|
|
4720
|
+
swap.claimTxid = pending[0];
|
|
4721
|
+
this.touch(swap);
|
|
4722
|
+
}
|
|
4723
|
+
await finalize(swap);
|
|
4724
|
+
return "finalized";
|
|
4725
|
+
} catch (error) {
|
|
4726
|
+
this.emitFailed(swap, error);
|
|
4727
|
+
return "failed";
|
|
4728
|
+
}
|
|
4729
|
+
}
|
|
4681
4730
|
/**
|
|
4682
4731
|
* The lockup was unilaterally exited: its outputs sit onchain, beyond any offchain
|
|
4683
4732
|
* spend. `needs_counterparty`, not terminal: it can still end either way onchain. Set
|
|
@@ -4700,8 +4749,9 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
4700
4749
|
*
|
|
4701
4750
|
* After the window the trader has no move; the manager only watches.
|
|
4702
4751
|
*/
|
|
4703
|
-
async driveReceiveClaim(swap) {
|
|
4752
|
+
async driveReceiveClaim(swap, revealed) {
|
|
4704
4753
|
const now = this.config.now();
|
|
4754
|
+
const claimOut = swap.claimTxid !== void 0 || revealed;
|
|
4705
4755
|
if (now < swap.refundLocktime) {
|
|
4706
4756
|
let vtxos;
|
|
4707
4757
|
try {
|
|
@@ -4710,26 +4760,25 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
4710
4760
|
this.emitFailed(swap, error);
|
|
4711
4761
|
return;
|
|
4712
4762
|
}
|
|
4713
|
-
return this.claimIfFunded(swap, vtxos);
|
|
4763
|
+
return this.claimIfFunded(swap, vtxos, claimOut);
|
|
4714
4764
|
}
|
|
4715
4765
|
if (now < swap.refundLocktime + REFUND_MTP_LAG_SECONDS) {
|
|
4716
|
-
if (
|
|
4766
|
+
if (claimOut) return;
|
|
4717
4767
|
return this.block(
|
|
4718
4768
|
swap,
|
|
4719
4769
|
"the claim window closed with the lockup unclaimed \u2014 only the solver can act now"
|
|
4720
4770
|
);
|
|
4721
4771
|
}
|
|
4722
4772
|
const failure = swap.claimFailure;
|
|
4723
|
-
if (failure && !
|
|
4773
|
+
if (failure && !claimOut) {
|
|
4724
4774
|
return this.fail(swap, new Error(failure));
|
|
4725
4775
|
}
|
|
4726
4776
|
this.setState(swap, "refunded");
|
|
4727
4777
|
}
|
|
4728
4778
|
/** Claim what the solver funded, once it is enough (the inner gate that matters is
|
|
4729
4779
|
* `pushClaim`'s; see {@link RfqSwapManagerCallbacks.claimLockup}). */
|
|
4730
|
-
async claimIfFunded(swap, vtxos) {
|
|
4780
|
+
async claimIfFunded(swap, vtxos, partiallyClaimed) {
|
|
4731
4781
|
if (vtxos.length === 0) return this.unblock(swap);
|
|
4732
|
-
const partiallyClaimed = swap.claimTxid !== void 0;
|
|
4733
4782
|
const toClaim = partiallyClaimed ? this.unclaimed(swap.rfqId, vtxos) : vtxos;
|
|
4734
4783
|
if (toClaim.length === 0) {
|
|
4735
4784
|
return;
|
|
@@ -4809,7 +4858,7 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
4809
4858
|
"the L1 funding was refunded, so claiming the lockup too would take both sides of the trade \u2014 the solver's reclaim ends this swap"
|
|
4810
4859
|
);
|
|
4811
4860
|
}
|
|
4812
|
-
await this.driveReceiveClaim(swap);
|
|
4861
|
+
await this.driveReceiveClaim(swap, false);
|
|
4813
4862
|
if (l1.blocked && !isRfqSwapTerminal(swap.state)) this.block(swap, l1.blocked);
|
|
4814
4863
|
}
|
|
4815
4864
|
/** `resolved`: the HTLC can hold nothing more. `blocked` is a refusal the
|
|
@@ -5629,6 +5678,7 @@ var chainSourceFrom = (provider, network) => {
|
|
|
5629
5678
|
};
|
|
5630
5679
|
|
|
5631
5680
|
// src/claim.ts
|
|
5681
|
+
var import_base13 = require("@scure/base");
|
|
5632
5682
|
var import_sdk16 = require("@arkade-os/sdk");
|
|
5633
5683
|
init_onchainHtlc();
|
|
5634
5684
|
var LockupAmountMismatchError = class extends Error {
|
|
@@ -6113,7 +6163,7 @@ function crossAssetRail(deps) {
|
|
|
6113
6163
|
|
|
6114
6164
|
// src/payment/rendezvous.ts
|
|
6115
6165
|
var import_solver_discovery6 = require("@arkade-os/solver-discovery");
|
|
6116
|
-
var
|
|
6166
|
+
var import_base14 = require("@scure/base");
|
|
6117
6167
|
var XONLY_HEX = /^[0-9a-f]{64}$/;
|
|
6118
6168
|
var rendezvousOf = (market, pinned) => {
|
|
6119
6169
|
const transports = { nostr: { relays: market.transports?.nostr?.relays ?? [] } };
|
|
@@ -6132,7 +6182,7 @@ var rendezvousOf = (market, pinned) => {
|
|
|
6132
6182
|
};
|
|
6133
6183
|
};
|
|
6134
6184
|
var solverRendezvous = (markets, payoutCorridor, amountSats, fallbackEmulatorPubkey) => {
|
|
6135
|
-
const pinned = fallbackEmulatorPubkey ?
|
|
6185
|
+
const pinned = fallbackEmulatorPubkey ? import_base14.hex.encode(fallbackEmulatorPubkey) : void 0;
|
|
6136
6186
|
if (pinned !== void 0 && !XONLY_HEX.test(pinned)) return void 0;
|
|
6137
6187
|
const quoteCorridor = payoutCorridor === "lightning" ? "bolt11" : "bitcoin";
|
|
6138
6188
|
const isBtc = (id) => id === "btc" || /^(?:arkade|bolt11|bitcoin):[^/]+\/slip44:(?:0|1)$/.test(id ?? "");
|
|
@@ -6357,7 +6407,7 @@ function solverLightningRail(deps) {
|
|
|
6357
6407
|
}
|
|
6358
6408
|
|
|
6359
6409
|
// src/restore.ts
|
|
6360
|
-
var
|
|
6410
|
+
var import_base15 = require("@scure/base");
|
|
6361
6411
|
var import_sdk22 = require("@arkade-os/sdk");
|
|
6362
6412
|
init_offer();
|
|
6363
6413
|
init_store();
|
|
@@ -6376,7 +6426,7 @@ async function fetchParsedTxs(indexer, txids) {
|
|
|
6376
6426
|
if (result.status !== "fulfilled") continue;
|
|
6377
6427
|
for (const psbt of result.value) {
|
|
6378
6428
|
try {
|
|
6379
|
-
const parsed = import_sdk22.Transaction.fromPSBT(
|
|
6429
|
+
const parsed = import_sdk22.Transaction.fromPSBT(import_base15.base64.decode(psbt));
|
|
6380
6430
|
parsedByTxid.set(parsed.id, parsed);
|
|
6381
6431
|
} catch {
|
|
6382
6432
|
}
|
|
@@ -6391,7 +6441,7 @@ function classifySpend(offer, operatorPubkey, spendTx, deposit) {
|
|
|
6391
6441
|
let leaves;
|
|
6392
6442
|
try {
|
|
6393
6443
|
const script = offerContract(offer, operatorPubkey);
|
|
6394
|
-
if (
|
|
6444
|
+
if (import_base15.hex.encode(script.pkScript) !== import_base15.hex.encode(offer.swapPkScript)) return "indeterminate";
|
|
6395
6445
|
leaves = {
|
|
6396
6446
|
// `exit` is absent on an offer with no exit closure, and drops out here
|
|
6397
6447
|
returned: ["cancel", "exit"].map((name) => script.functionByName(name)?.leafScript).filter((leaf) => leaf !== void 0),
|
|
@@ -6403,11 +6453,11 @@ function classifySpend(offer, operatorPubkey, spendTx, deposit) {
|
|
|
6403
6453
|
for (let i = 0; i < spendTx.inputsLength; i++) {
|
|
6404
6454
|
const input = spendTx.getInput(i);
|
|
6405
6455
|
if (!input.txid || input.index !== deposit.vout) continue;
|
|
6406
|
-
if (
|
|
6456
|
+
if (import_base15.hex.encode(input.txid) !== deposit.txid) continue;
|
|
6407
6457
|
for (const leaf of input.tapLeafScript ?? []) {
|
|
6408
|
-
const spent =
|
|
6409
|
-
if (leaves.returned.some((back) => spent ===
|
|
6410
|
-
if (leaves.fulfill && spent ===
|
|
6458
|
+
const spent = import_base15.hex.encode((0, import_sdk22.scriptFromTapLeafScript)(leaf));
|
|
6459
|
+
if (leaves.returned.some((back) => spent === import_base15.hex.encode(back))) return "cancelled";
|
|
6460
|
+
if (leaves.fulfill && spent === import_base15.hex.encode(leaves.fulfill)) return "fulfilled";
|
|
6411
6461
|
}
|
|
6412
6462
|
}
|
|
6413
6463
|
return "indeterminate";
|
|
@@ -6433,7 +6483,7 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
6433
6483
|
try {
|
|
6434
6484
|
reopened.push({
|
|
6435
6485
|
fundingTx: { type: "sent", redeemTxid: swap.fundingTxid },
|
|
6436
|
-
offer: decodeOffer(
|
|
6486
|
+
offer: decodeOffer(import_base15.hex.decode(swap.offerHex)),
|
|
6437
6487
|
offerHex: swap.offerHex,
|
|
6438
6488
|
existing: swap
|
|
6439
6489
|
});
|
|
@@ -6465,13 +6515,13 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
6465
6515
|
found.push({
|
|
6466
6516
|
fundingTx,
|
|
6467
6517
|
offer: decodeOffer(payload),
|
|
6468
|
-
offerHex:
|
|
6518
|
+
offerHex: import_base15.hex.encode(payload)
|
|
6469
6519
|
});
|
|
6470
6520
|
} catch {
|
|
6471
6521
|
}
|
|
6472
6522
|
}
|
|
6473
6523
|
if (found.length === 0) return { restored: [], scannedTxids: fetchedTxids };
|
|
6474
|
-
const scripts = [...new Set(found.map((f) =>
|
|
6524
|
+
const scripts = [...new Set(found.map((f) => import_base15.hex.encode(f.offer.swapPkScript)))];
|
|
6475
6525
|
const { vtxos } = await indexer.getVtxos({ scripts });
|
|
6476
6526
|
const vtxoByScriptAndTxid = new Map(vtxos.map((v) => [`${v.script}:${v.txid}`, v]));
|
|
6477
6527
|
const txByAnyId = /* @__PURE__ */ new Map();
|
|
@@ -6483,7 +6533,7 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
6483
6533
|
const spendTxids = /* @__PURE__ */ new Set();
|
|
6484
6534
|
for (const { fundingTx, offer } of found) {
|
|
6485
6535
|
const vtxo = vtxoByScriptAndTxid.get(
|
|
6486
|
-
`${
|
|
6536
|
+
`${import_base15.hex.encode(offer.swapPkScript)}:${fundingTx.redeemTxid}`
|
|
6487
6537
|
);
|
|
6488
6538
|
if (!vtxo?.isSpent) continue;
|
|
6489
6539
|
for (const txid of spendTxidsOf(vtxo)) spendTxids.add(txid);
|
|
@@ -6492,7 +6542,7 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
6492
6542
|
const restored = [];
|
|
6493
6543
|
const unresolved = /* @__PURE__ */ new Set();
|
|
6494
6544
|
for (const { fundingTx, offer, offerHex, existing } of found) {
|
|
6495
|
-
const swapPkScript =
|
|
6545
|
+
const swapPkScript = import_base15.hex.encode(offer.swapPkScript);
|
|
6496
6546
|
const vtxo = vtxoByScriptAndTxid.get(`${swapPkScript}:${fundingTx.redeemTxid}`);
|
|
6497
6547
|
if (!vtxo) {
|
|
6498
6548
|
unresolved.add(fundingTx.redeemTxid);
|
|
@@ -6539,7 +6589,7 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
6539
6589
|
let swapAddress = "";
|
|
6540
6590
|
try {
|
|
6541
6591
|
const compiled = offerContract(offer, operatorPubkey);
|
|
6542
|
-
if (
|
|
6592
|
+
if (import_base15.hex.encode(compiled.pkScript) !== swapPkScript) {
|
|
6543
6593
|
unresolved.add(fundingTx.redeemTxid);
|
|
6544
6594
|
continue;
|
|
6545
6595
|
}
|
|
@@ -6575,7 +6625,7 @@ init_rfqProfileParts();
|
|
|
6575
6625
|
init_store();
|
|
6576
6626
|
|
|
6577
6627
|
// src/watch.ts
|
|
6578
|
-
var
|
|
6628
|
+
var import_base16 = require("@scure/base");
|
|
6579
6629
|
var import_sdk23 = require("@arkade-os/sdk");
|
|
6580
6630
|
init_coverage();
|
|
6581
6631
|
init_offer();
|
|
@@ -6624,9 +6674,9 @@ async function watchOfferSwaps({
|
|
|
6624
6674
|
if (candidates.length === 0) return "indeterminate";
|
|
6625
6675
|
const { txs } = await indexer.getVirtualTxs(candidates);
|
|
6626
6676
|
return classifyDepositSpend(
|
|
6627
|
-
decodeOffer(
|
|
6677
|
+
decodeOffer(import_base16.hex.decode(swap.offerHex)),
|
|
6628
6678
|
operatorPubkey,
|
|
6629
|
-
txs.map((psbt) => import_sdk23.Transaction.fromPSBT(
|
|
6679
|
+
txs.map((psbt) => import_sdk23.Transaction.fromPSBT(import_base16.base64.decode(psbt))),
|
|
6630
6680
|
{ txid: vtxo.txid, vout: vtxo.vout }
|
|
6631
6681
|
);
|
|
6632
6682
|
} catch {
|
package/dist/protocol.d.cts
CHANGED
|
@@ -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 { 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-
|
|
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-
|
|
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-DFDNvcZ7.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-DFDNvcZ7.cjs';
|
|
4
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-CP-P0PSL.cjs';
|
|
5
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-CP-P0PSL.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-
|
|
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-CpJXTjX_.cjs';
|
|
7
7
|
import { Network as Network$1, LocalCardInput, TransportCardFetcher, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
|
|
8
|
-
import { O as Offer } from './offer-
|
|
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-
|
|
10
|
-
export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-
|
|
8
|
+
import { O as Offer } from './offer-Boxive2u.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-Boxive2u.cjs';
|
|
10
|
+
export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-DFNMY2K-.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. */
|
|
@@ -73,8 +73,9 @@ interface LightningReceiveProfile extends Record<string, unknown> {
|
|
|
73
73
|
/**
|
|
74
74
|
* Our Arkade claim's txid, once submitted.
|
|
75
75
|
*
|
|
76
|
-
* `claimIfFunded`
|
|
77
|
-
*
|
|
76
|
+
* `claimIfFunded`'s `partiallyClaimed` comes from this, or from a spend of the lockup that
|
|
77
|
+
* reveals `P`. Restoring without it costs one pass that reads the lockup, and the value gate
|
|
78
|
+
* stays off as long as a spend carries `P`.
|
|
78
79
|
*/
|
|
79
80
|
claimTxid?: string;
|
|
80
81
|
}
|
|
@@ -339,22 +340,6 @@ declare function arkadeRefunder(deps: ArkadeRefunderDeps): (swap: RfqSwap) => Pr
|
|
|
339
340
|
*/
|
|
340
341
|
declare const chainSourceFrom: (provider: OnchainProvider, network: OnchainNetwork) => ChainSource;
|
|
341
342
|
|
|
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
|
-
|
|
358
343
|
/**
|
|
359
344
|
* The lockup is funded for less than the swap agreed.
|
|
360
345
|
*
|
|
@@ -397,9 +382,8 @@ declare function pushClaim(operator: SwapOperator, input: {
|
|
|
397
382
|
/** What the lockup must carry: the quote's `to_amount`, captured at REQUEST time and
|
|
398
383
|
* persisted. Required so the guard cannot be skipped. */
|
|
399
384
|
expectedAmount: number;
|
|
400
|
-
/** Set
|
|
401
|
-
* by then
|
|
402
|
-
* the remainder. */
|
|
385
|
+
/** Set once `P` is public on this lockup: the value gate protects
|
|
386
|
+
* nothing by then and would only strand the remainder. */
|
|
403
387
|
partiallyClaimed?: boolean;
|
|
404
388
|
/** @see operatorUnrollScript */
|
|
405
389
|
network?: Network;
|
package/dist/protocol.d.ts
CHANGED
|
@@ -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 { 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-
|
|
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-
|
|
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-Dn1V17T2.js';
|
|
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-Dn1V17T2.js';
|
|
4
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-CP-P0PSL.js';
|
|
5
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-CP-P0PSL.js';
|
|
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-
|
|
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-CKPFpIt9.js';
|
|
7
7
|
import { Network as Network$1, LocalCardInput, TransportCardFetcher, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
|
|
8
|
-
import { O as Offer } from './offer-
|
|
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-
|
|
10
|
-
export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-
|
|
8
|
+
import { O as Offer } from './offer-Drw1k_jt.js';
|
|
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-Drw1k_jt.js';
|
|
10
|
+
export { c as OfferSwapWatcher, W as WatchOfferSwapsParams, w as watchOfferSwaps } from './watch-D-mc_wfD.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. */
|
|
@@ -73,8 +73,9 @@ interface LightningReceiveProfile extends Record<string, unknown> {
|
|
|
73
73
|
/**
|
|
74
74
|
* Our Arkade claim's txid, once submitted.
|
|
75
75
|
*
|
|
76
|
-
* `claimIfFunded`
|
|
77
|
-
*
|
|
76
|
+
* `claimIfFunded`'s `partiallyClaimed` comes from this, or from a spend of the lockup that
|
|
77
|
+
* reveals `P`. Restoring without it costs one pass that reads the lockup, and the value gate
|
|
78
|
+
* stays off as long as a spend carries `P`.
|
|
78
79
|
*/
|
|
79
80
|
claimTxid?: string;
|
|
80
81
|
}
|
|
@@ -339,22 +340,6 @@ declare function arkadeRefunder(deps: ArkadeRefunderDeps): (swap: RfqSwap) => Pr
|
|
|
339
340
|
*/
|
|
340
341
|
declare const chainSourceFrom: (provider: OnchainProvider, network: OnchainNetwork) => ChainSource;
|
|
341
342
|
|
|
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
|
-
|
|
358
343
|
/**
|
|
359
344
|
* The lockup is funded for less than the swap agreed.
|
|
360
345
|
*
|
|
@@ -397,9 +382,8 @@ declare function pushClaim(operator: SwapOperator, input: {
|
|
|
397
382
|
/** What the lockup must carry: the quote's `to_amount`, captured at REQUEST time and
|
|
398
383
|
* persisted. Required so the guard cannot be skipped. */
|
|
399
384
|
expectedAmount: number;
|
|
400
|
-
/** Set
|
|
401
|
-
* by then
|
|
402
|
-
* the remainder. */
|
|
385
|
+
/** Set once `P` is public on this lockup: the value gate protects
|
|
386
|
+
* nothing by then and would only strand the remainder. */
|
|
403
387
|
partiallyClaimed?: boolean;
|
|
404
388
|
/** @see operatorUnrollScript */
|
|
405
389
|
network?: Network;
|
package/dist/protocol.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, b9 as MarketsCacheEntry } from '../../repository-
|
|
3
|
+
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry } from '../../repository-DFDNvcZ7.cjs';
|
|
4
4
|
import '@arkade-os/solver-discovery';
|
|
5
5
|
import '../../rfq-CP-P0PSL.cjs';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
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, b9 as MarketsCacheEntry } from '../../repository-
|
|
3
|
+
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry } from '../../repository-Dn1V17T2.js';
|
|
4
4
|
import '@arkade-os/solver-discovery';
|
|
5
5
|
import '../../rfq-CP-P0PSL.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
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, b9 as MarketsCacheEntry } from '../../repository-
|
|
3
|
+
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry } from '../../repository-DFDNvcZ7.cjs';
|
|
4
4
|
import '@arkade-os/solver-discovery';
|
|
5
5
|
import '../../rfq-CP-P0PSL.cjs';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
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, b9 as MarketsCacheEntry } from '../../repository-
|
|
3
|
+
import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry } from '../../repository-Dn1V17T2.js';
|
|
4
4
|
import '@arkade-os/solver-discovery';
|
|
5
5
|
import '../../rfq-CP-P0PSL.js';
|
|
6
6
|
|