@arkade-os/swap 0.0.10 → 0.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -15
- package/dist/{chunk-5NPYNQ5V.js → chunk-AM3NNUMR.js} +112 -66
- package/dist/index.cjs +763 -227
- package/dist/index.d.cts +184 -47
- package/dist/index.d.ts +184 -47
- package/dist/index.js +653 -169
- package/dist/nostr.cjs +4 -1
- package/dist/nostr.d.cts +1 -1
- package/dist/nostr.d.ts +1 -1
- package/dist/nostr.js +1 -1
- package/dist/repositories/realm/index.d.cts +4 -4
- package/dist/repositories/realm/index.d.ts +4 -4
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/{repository-C8FXlmHY.d.cts → repository-BWP1UstE.d.cts} +124 -59
- package/dist/{repository-Cw2EvvZG.d.ts → repository-DLpH41ZO.d.ts} +124 -59
- package/dist/{rfq-DglvHMNC.d.ts → rfq-CzCGjICq.d.cts} +86 -48
- package/dist/{rfq-DglvHMNC.d.cts → rfq-CzCGjICq.d.ts} +86 -48
- package/package.json +4 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DiscoveredMarket } from '@arkade-os/solver-discovery';
|
|
2
|
-
import { IWallet, ProvisionedKey, ProvisionedClaimSecret,
|
|
3
|
-
import {
|
|
2
|
+
import { IWallet, ProvisionedKey, ProvisionedClaimSecret, ArkProvider, RestIndexerProvider, VHTLC, Identity, IContractManager } from '@arkade-os/sdk';
|
|
3
|
+
import { D as RfqStatus, R as RfqTransport, a as OnchainHtlc, g as ChainUtxo, C as ChainSource, w as OnchainHtlcPhase } from './rfq-CzCGjICq.js';
|
|
4
4
|
|
|
5
5
|
type AssetSwapStatus = "pending" | "cancelling" | "fulfilled" | "cancelled" | "recoverable" | "awaiting_fill" | "claimable" | "claimed" | "refunded_l1";
|
|
6
6
|
/** The sentinel asset id for BTC itself, as opposed to a 68-hex asset id.
|
|
@@ -210,10 +210,17 @@ declare function awaitRfqResolution(transport: RfqTransport, rfqId: string, opti
|
|
|
210
210
|
pollMs?: number;
|
|
211
211
|
deadline?: number;
|
|
212
212
|
}): Promise<RfqStatus>;
|
|
213
|
-
/** The Ark surface the refund push needs — narrower than a full provider, and
|
|
214
|
-
* satisfied by {@link RestArkProvider}. Same seam style as `RestoreIndexer`. */
|
|
215
|
-
type RefundArkProvider = Pick<RestArkProvider, "getInfo" | "submitTx" | "finalizeTx">;
|
|
216
213
|
/** The indexer surface the lockup lookup needs. */
|
|
214
|
+
/**
|
|
215
|
+
* What a push needs from the operator: the broadcast pair, plus the info read
|
|
216
|
+
* that supplies `checkpointTapscript`.
|
|
217
|
+
*
|
|
218
|
+
* Narrow on purpose. A wallet's own connection satisfies it —
|
|
219
|
+
* `getArkadeBroadcaster()` for the pair and `getArkadeInfo()` for the read — so
|
|
220
|
+
* a plugin composes one from the wallet it already has and never opens a second
|
|
221
|
+
* connection of its own (#734). A full `ArkProvider` still fits, structurally.
|
|
222
|
+
*/
|
|
223
|
+
type SwapOperator = Pick<ArkProvider, "getInfo" | "submitTx" | "finalizeTx">;
|
|
217
224
|
type RefundIndexer = Pick<RestIndexerProvider, "getVtxos">;
|
|
218
225
|
/** A still-refundable virtual output sitting at the swap lockup. */
|
|
219
226
|
interface LockupVtxo {
|
|
@@ -237,12 +244,6 @@ interface LockupVtxo {
|
|
|
237
244
|
* Opposite, but not exhaustive: an unrolled output satisfies neither, and
|
|
238
245
|
* {@link findLockupVtxos} drops those before they reach this type at all.
|
|
239
246
|
*
|
|
240
|
-
* `packages/boltz-swap` splits on exactly this fact rather than working
|
|
241
|
-
* around it: `settleRefundWithoutReceiver` sends a live VTXO through an
|
|
242
|
-
* offchain tx and a recoverable one through `joinBatch` — "a swept
|
|
243
|
-
* (recoverable) VTXO is no longer a live leaf, so it can only be reclaimed
|
|
244
|
-
* by re-registering it into a batch".
|
|
245
|
-
*
|
|
246
247
|
* So the remedy is recovery (renewing the output into a fresh batch),
|
|
247
248
|
* after which the ordinary CLTV refund works again. This package does not
|
|
248
249
|
* build that round — see {@link pushRefundWithoutReceiver}, which refuses
|
|
@@ -260,8 +261,7 @@ interface LockupVtxo {
|
|
|
260
261
|
*
|
|
261
262
|
* **The remedy already exists; this package does not reimplement it.** The SDK
|
|
262
263
|
* recovers swept outputs by re-registering them into a fresh batch, through
|
|
263
|
-
* `IVtxoManager.recoverVtxos()
|
|
264
|
-
* reaches via its own `joinBatch`. It reads the wallet's registered-contract
|
|
264
|
+
* `IVtxoManager.recoverVtxos()`. It reads the wallet's registered-contract
|
|
265
265
|
* snapshot (`recoverVtxos` → `wallet.getVtxos({ withRecoverable: true })` →
|
|
266
266
|
* `contractSnapshot()` → `contractManager.getContractsWithVtxos()`), so it
|
|
267
267
|
* covers a swap lockup as soon as that lockup is registered as a contract —
|
|
@@ -278,8 +278,7 @@ interface LockupVtxo {
|
|
|
278
278
|
* recovery round including this VTXO earlier is rejected. `recoverVtxos`
|
|
279
279
|
* sweeps every recoverable output in ONE settlement and has no CLTV
|
|
280
280
|
* awareness, so recovering early can fail the whole batch rather than just
|
|
281
|
-
* this output.
|
|
282
|
-
* recoverable → skipped".
|
|
281
|
+
* this output.
|
|
283
282
|
*/
|
|
284
283
|
declare class LockupNeedsRecoveryError extends Error {
|
|
285
284
|
readonly name = "LockupNeedsRecoveryError";
|
|
@@ -292,11 +291,10 @@ declare class LockupNeedsRecoveryError extends Error {
|
|
|
292
291
|
* into one settlement with no CLTV awareness, so an early attempt can fail
|
|
293
292
|
* the whole batch — including unrelated outputs that were otherwise fine.
|
|
294
293
|
*
|
|
295
|
-
* Exposed as a value, not only inside the message, so a caller can
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
* not an exact alarm.
|
|
294
|
+
* Exposed as a value, not only inside the message, so a caller can skip
|
|
295
|
+
* pre-CLTV recoverable outputs without parsing prose. Seconds-based
|
|
296
|
+
* locktimes mature against the chain tip's timestamp rather than wall
|
|
297
|
+
* clock, so treat this as a floor to wait past, not an exact alarm.
|
|
300
298
|
*/
|
|
301
299
|
readonly recoverableAfter: bigint;
|
|
302
300
|
constructor(outpoints: string[], recoverableAfter: bigint);
|
|
@@ -315,8 +313,7 @@ declare class LockupNeedsRecoveryError extends Error {
|
|
|
315
313
|
* sat unresolved — which are precisely the ones most likely to have got there.
|
|
316
314
|
* Reading only the spendable set would report `nothing_to_refund` over money
|
|
317
315
|
* that is still sitting at the script, which is worse than an error: it looks
|
|
318
|
-
* like a resolved swap.
|
|
319
|
-
* the same reason (`arkade-swaps.ts`'s `refundableVtxos`).
|
|
316
|
+
* like a resolved swap.
|
|
320
317
|
*
|
|
321
318
|
* **Visible is not the same as refundable.** A `recoverable` output cannot be
|
|
322
319
|
* spent offchain at all — see {@link LockupVtxo.recoverable} — so this set is
|
|
@@ -332,9 +329,11 @@ declare class LockupNeedsRecoveryError extends Error {
|
|
|
332
329
|
* defensively rather than assumed. It costs the two waiting callers nothing
|
|
333
330
|
* they wanted: `awaitLockupFunding` keeps waiting for a claimable lockup
|
|
334
331
|
* instead of publishing `P` into a spend that cannot land, and
|
|
335
|
-
* `refundIfUnresolved` reports
|
|
336
|
-
*
|
|
337
|
-
* {@link readLockupFate}, which queries unfiltered and reports it as `exited
|
|
332
|
+
* `refundIfUnresolved` reports rather than grinding a doomed push to its
|
|
333
|
+
* deadline. Both that function and `RfqSwapManager` name the exit through
|
|
334
|
+
* {@link readLockupFate}, which queries unfiltered and reports it as `exited`;
|
|
335
|
+
* this drop is the second line, and what still refuses the push on a pass where
|
|
336
|
+
* the fate read learned nothing.
|
|
338
337
|
*
|
|
339
338
|
* This read — not the RFQ's reported state — is the authority on whether
|
|
340
339
|
* there is anything left at the lockup.
|
|
@@ -368,7 +367,7 @@ interface LockupSpend {
|
|
|
368
367
|
checkpointTxid: string;
|
|
369
368
|
/** The ark transaction that spent the above checkpoint output. What
|
|
370
369
|
* history correlation matches on; absent when the indexer omitted it. */
|
|
371
|
-
|
|
370
|
+
txid?: string;
|
|
372
371
|
}
|
|
373
372
|
type LockupFate =
|
|
374
373
|
/** At least one output at the lockup is still unspent. Not over. */
|
|
@@ -499,8 +498,8 @@ declare function readLockupFate(indexer: LockupSpendIndexer, input: {
|
|
|
499
498
|
* outpoints, rather than submitted and rejected. Filtering them out silently
|
|
500
499
|
* would be worse still: it would report success over money that never moved.
|
|
501
500
|
*/
|
|
502
|
-
declare function pushRefundWithoutReceiver(
|
|
503
|
-
|
|
501
|
+
declare function pushRefundWithoutReceiver(operator: SwapOperator, input: {
|
|
502
|
+
contract: InstanceType<typeof VHTLC.ScriptV2>;
|
|
504
503
|
/** The `sender` signer. Build it from the swap record with
|
|
505
504
|
* {@link senderIdentityForSwapRecord} — on an HD wallet that resolves
|
|
506
505
|
* from the seed, with no stored key bytes anywhere, and every way the
|
|
@@ -512,7 +511,7 @@ declare function pushRefundWithoutReceiver(ark: RefundArkProvider, input: {
|
|
|
512
511
|
/** Defaults to the contract's own committed refund destination. */
|
|
513
512
|
refundPkScript?: Uint8Array;
|
|
514
513
|
}): Promise<{
|
|
515
|
-
|
|
514
|
+
txid: string;
|
|
516
515
|
amount: number;
|
|
517
516
|
}>;
|
|
518
517
|
/**
|
|
@@ -534,7 +533,7 @@ type RefundOutcome =
|
|
|
534
533
|
/** The trader took it back via `refundWithoutReceiver`. */
|
|
535
534
|
| {
|
|
536
535
|
outcome: "refunded";
|
|
537
|
-
|
|
536
|
+
txid: string;
|
|
538
537
|
amount: number;
|
|
539
538
|
status: RfqStatus | null;
|
|
540
539
|
}
|
|
@@ -555,6 +554,21 @@ type RefundOutcome =
|
|
|
555
554
|
outpoints: string[];
|
|
556
555
|
vtxos: LockupVtxo[];
|
|
557
556
|
status: RfqStatus | null;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* The lockup was unilaterally exited: its outputs sit onchain under the VHTLC
|
|
560
|
+
* script, where no offchain refund can reach them. Returned rather than
|
|
561
|
+
* retried: no amount of waiting changes where the money lives. Complete the
|
|
562
|
+
* unroll and spend the outputs onchain — then there is nothing left to refund.
|
|
563
|
+
*
|
|
564
|
+
* Distinct from {@link RefundOutcome} `needs_recovery` on purpose: that
|
|
565
|
+
* variant's remedy is recovery into a fresh batch, which is a spend no batch
|
|
566
|
+
* can make for an output that is already onchain.
|
|
567
|
+
*/
|
|
568
|
+
| {
|
|
569
|
+
outcome: "exited";
|
|
570
|
+
outpoints: string[];
|
|
571
|
+
status: RfqStatus | null;
|
|
558
572
|
};
|
|
559
573
|
/**
|
|
560
574
|
* Ask first, then fall back: watch the swap for the solver to resolve it, and
|
|
@@ -583,16 +597,36 @@ type RefundOutcome =
|
|
|
583
597
|
* is gone the CLTV refund is not "not yet" but "not this way", so it returns
|
|
584
598
|
* `needs_recovery` naming the outpoints rather than retrying until the
|
|
585
599
|
* deadline. Recover them and call again.
|
|
600
|
+
* - **An exited lockup ends it the same way, and is checked first.** Each pass
|
|
601
|
+
* past the deadline asks {@link readLockupFate} before reading what is
|
|
602
|
+
* refundable, so an output that has been unilaterally exited returns `exited`
|
|
603
|
+
* instead of feeding a push that cannot land. It costs one extra `getVtxos`
|
|
604
|
+
* per such pass (three where there were two), plus a `getVirtualTxs` on a
|
|
605
|
+
* fully-spent lockup; only the pass that returns `exited` saves the other two.
|
|
606
|
+
* Paid to prevent a push that would otherwise be retried to the deadline and
|
|
607
|
+
* then rethrown. A failing fate read is swallowed, not raised: it is a
|
|
608
|
+
* shortcut, and losing it must not end a wait the ordinary path could answer.
|
|
609
|
+
*
|
|
610
|
+
* A lockup funded in two sends of which only one exited reports `exited` for
|
|
611
|
+
* the whole thing and leaves the live half unrefunded. That is deliberate:
|
|
612
|
+
* `RfqSwapManager` reports the same lockup `exited` on the same any-output
|
|
613
|
+
* rule, and the two must not disagree.
|
|
586
614
|
*
|
|
587
615
|
* Safe to call late, and safe to call again: a caller recovering from a crash
|
|
588
616
|
* well past the deadline skips straight to the push, and a lockup that is
|
|
589
617
|
* already empty comes back as `nothing_to_refund` instead of an error.
|
|
590
618
|
*/
|
|
591
|
-
declare function refundIfUnresolved(transport: RfqTransport,
|
|
619
|
+
declare function refundIfUnresolved(transport: RfqTransport, operator: SwapOperator, indexer: LockupSpendIndexer, input: {
|
|
592
620
|
rfqId: string;
|
|
593
|
-
|
|
621
|
+
contract: InstanceType<typeof VHTLC.ScriptV2>;
|
|
594
622
|
/** @see pushRefundWithoutReceiver */
|
|
595
623
|
sender: Identity;
|
|
624
|
+
/**
|
|
625
|
+
* `sha256(P)`, hex — the quote's `payment_hash`, as {@link readLockupFate}
|
|
626
|
+
* takes it. Not derivable from `script`, whose `preimageHash` is a
|
|
627
|
+
* `hash160` of the same secret.
|
|
628
|
+
*/
|
|
629
|
+
paymentHash: string;
|
|
596
630
|
/** `refund_locktime` from the quote, unix seconds. */
|
|
597
631
|
refundLocktime: number;
|
|
598
632
|
/** Defaults to the contract's own committed refund destination. */
|
|
@@ -750,7 +784,7 @@ interface RfqSwapCommon {
|
|
|
750
784
|
createdAt: number;
|
|
751
785
|
updatedAt: number;
|
|
752
786
|
/** Set once the trader's own `refundWithoutReceiver` push landed. */
|
|
753
|
-
|
|
787
|
+
refundTxid?: string;
|
|
754
788
|
/**
|
|
755
789
|
* The ark transactions that SPENT the lockup, stamped from the chain read
|
|
756
790
|
* that ended the swap — `LockupFate.spends`, whichever verdict it reached.
|
|
@@ -759,8 +793,8 @@ interface RfqSwapCommon {
|
|
|
759
793
|
* a solver reclaim on a receive, and — the exception — the trader's own
|
|
760
794
|
* claim when a receive settles. What they have in common is that no local
|
|
761
795
|
* action produced them, so nothing else on this record can name them:
|
|
762
|
-
* {@link
|
|
763
|
-
* `
|
|
796
|
+
* {@link refundTxid} names only a push this wallet made, and
|
|
797
|
+
* `claimTxid` only a submission it made.
|
|
764
798
|
*
|
|
765
799
|
* Stamped so a terminal record answers "which transaction ended this" from
|
|
766
800
|
* storage. Without it the only source is another read of the lockup — a
|
|
@@ -768,10 +802,10 @@ interface RfqSwapCommon {
|
|
|
768
802
|
* has to pay on the offline-first path where it is least affordable.
|
|
769
803
|
*
|
|
770
804
|
* Absent when the swap ended without a chain verdict, or when the indexer
|
|
771
|
-
* named the checkpoint but not the ark transaction — the same `
|
|
805
|
+
* named the checkpoint but not the ark transaction — the same `txid`
|
|
772
806
|
* `LockupSpend` declares optional, for the same reason.
|
|
773
807
|
*/
|
|
774
|
-
|
|
808
|
+
lockupSpendTxids?: string[];
|
|
775
809
|
/** Why `state` is `failed`. */
|
|
776
810
|
failure?: string;
|
|
777
811
|
/** Why `state` is `needs_counterparty`. Distinct from {@link failure},
|
|
@@ -835,7 +869,7 @@ interface LightningReceiveSwap extends RfqSwapCommon {
|
|
|
835
869
|
expectedAmount: number;
|
|
836
870
|
/** Our Arkade claim's txid, once submitted. Set from the callback's return
|
|
837
871
|
* and never from a chain read — the chain's answer is `settled`. */
|
|
838
|
-
|
|
872
|
+
claimTxid?: string;
|
|
839
873
|
}
|
|
840
874
|
/**
|
|
841
875
|
* A monitored swap.
|
|
@@ -846,8 +880,8 @@ interface LightningReceiveSwap extends RfqSwapCommon {
|
|
|
846
880
|
* writes and rebuilds these itself, through
|
|
847
881
|
* {@link RfqSwapManager.restoreFromRepository}. A caller keeping its own store
|
|
848
882
|
* projects it in {@link RfqSwapManagerCallbacks.saveSwap} instead, rebuilds it
|
|
849
|
-
* on restart the way it was made — `
|
|
850
|
-
* `
|
|
883
|
+
* on restart the way it was made — `lightningSendContract` /
|
|
884
|
+
* `lightningReceiveContract` / `onchainHtlcScript` over the quote's binding fields —
|
|
851
885
|
* and hands the result to {@link RfqSwapManager.start}.
|
|
852
886
|
*
|
|
853
887
|
* **`onchain:BTC->arkade:BTC` is deliberately not a member yet.** Its Arkade
|
|
@@ -905,7 +939,7 @@ declare function nextOnchainAction(input: {
|
|
|
905
939
|
/** What the trader's own `refundWithoutReceiver` push returned, or `null` when
|
|
906
940
|
* the lockup held nothing to return. */
|
|
907
941
|
type ArkadeRefundResult = {
|
|
908
|
-
|
|
942
|
+
txid: string;
|
|
909
943
|
amount: number;
|
|
910
944
|
} | null;
|
|
911
945
|
/**
|
|
@@ -956,7 +990,7 @@ interface RfqSwapManagerCallbacks {
|
|
|
956
990
|
* funding that arrived piecemeal can still be swept. */
|
|
957
991
|
partiallyClaimed: boolean;
|
|
958
992
|
}) => Promise<{
|
|
959
|
-
|
|
993
|
+
txid: string;
|
|
960
994
|
amount: number;
|
|
961
995
|
}>;
|
|
962
996
|
/**
|
|
@@ -1070,7 +1104,7 @@ interface RfqSwapManagerConfig {
|
|
|
1070
1104
|
}
|
|
1071
1105
|
/** The contract-manager surface this needs, narrowed for injection — the same
|
|
1072
1106
|
* seam style as {@link LockupSpendIndexer} and `refund.ts`'s
|
|
1073
|
-
*
|
|
1107
|
+
* `RefundIndexer`, and satisfied structurally by a real
|
|
1074
1108
|
* `ContractManager` (`await wallet.getContractManager()`). */
|
|
1075
1109
|
type SwapContractRegistry = Pick<IContractManager, "createContract" | "getContracts" | "onContractEvent" | "setContractWatchState">;
|
|
1076
1110
|
/**
|
|
@@ -1450,6 +1484,17 @@ declare class RfqSwapManager {
|
|
|
1450
1484
|
removeSwap(rfqId: string): Promise<void>;
|
|
1451
1485
|
/** Every swap still being monitored. */
|
|
1452
1486
|
getPendingSwaps(): Promise<RfqSwap[]>;
|
|
1487
|
+
/**
|
|
1488
|
+
* Every swap this manager holds — {@link getPendingSwaps} plus the ones
|
|
1489
|
+
* that already ended. The two sets are disjoint: a swap leaves `monitored`
|
|
1490
|
+
* as it enters `finished`.
|
|
1491
|
+
*
|
|
1492
|
+
* The finished half is what this process has seen, which after
|
|
1493
|
+
* {@link restoreFromRepository} is the stored history minus what retention
|
|
1494
|
+
* pruned. A manager that has restored nothing answers with the live swaps
|
|
1495
|
+
* alone.
|
|
1496
|
+
*/
|
|
1497
|
+
getAllSwaps(): Promise<RfqSwap[]>;
|
|
1453
1498
|
hasSwap(rfqId: string): Promise<boolean>;
|
|
1454
1499
|
/** True while an action for this swap holds the per-swap lock. */
|
|
1455
1500
|
isProcessing(rfqId: string): Promise<boolean>;
|
|
@@ -1611,7 +1656,7 @@ declare class RfqSwapManager {
|
|
|
1611
1656
|
/**
|
|
1612
1657
|
* Record which ark transactions ended the lockup.
|
|
1613
1658
|
*
|
|
1614
|
-
* Only the ones the indexer actually named: `LockupSpend.
|
|
1659
|
+
* Only the ones the indexer actually named: `LockupSpend.txid` is
|
|
1615
1660
|
* optional, and a checkpoint txid is not what history correlates on — a
|
|
1616
1661
|
* record carrying one would name a transaction the wallet's own activity
|
|
1617
1662
|
* never shows. Fewer txids is the right failure here.
|
|
@@ -1655,10 +1700,9 @@ declare class RfqSwapManager {
|
|
|
1655
1700
|
/**
|
|
1656
1701
|
* Drop a terminal swap from monitoring and report it exactly once.
|
|
1657
1702
|
*
|
|
1658
|
-
* `onSwapCompleted` and `onSwapFailed` are mutually exclusive here
|
|
1659
|
-
*
|
|
1660
|
-
*
|
|
1661
|
-
* also fires on failure is a trap worth not inheriting.
|
|
1703
|
+
* `onSwapCompleted` and `onSwapFailed` are mutually exclusive here: a
|
|
1704
|
+
* listener named "completed" that also fires on failure is a trap, so a
|
|
1705
|
+
* swap that leaves monitoring reports through exactly one of them.
|
|
1662
1706
|
*/
|
|
1663
1707
|
private finalize;
|
|
1664
1708
|
private settleWaiters;
|
|
@@ -1758,7 +1802,7 @@ interface RfqSwapOrigin {
|
|
|
1758
1802
|
* learns it. So it is written once at record creation, like {@link amount},
|
|
1759
1803
|
* and no corridor `project` emits it.
|
|
1760
1804
|
*/
|
|
1761
|
-
|
|
1805
|
+
fundingTxid?: string;
|
|
1762
1806
|
}
|
|
1763
1807
|
/** The stored record: the origin plus the manager's mutable state. */
|
|
1764
1808
|
interface RfqSwapRecord extends RfqSwapOrigin {
|
|
@@ -1766,14 +1810,37 @@ interface RfqSwapRecord extends RfqSwapOrigin {
|
|
|
1766
1810
|
state: RfqSwapState;
|
|
1767
1811
|
createdAt: number;
|
|
1768
1812
|
updatedAt: number;
|
|
1769
|
-
|
|
1813
|
+
refundTxid?: string;
|
|
1770
1814
|
/** The ark transactions that spent the lockup, stamped by the manager from
|
|
1771
1815
|
* the chain read that ended the swap. See
|
|
1772
|
-
* `RfqSwapCommon.
|
|
1773
|
-
|
|
1816
|
+
* `RfqSwapCommon.lockupSpendTxids`. */
|
|
1817
|
+
lockupSpendTxids?: string[];
|
|
1774
1818
|
failure?: string;
|
|
1775
1819
|
blockedReason?: string;
|
|
1776
1820
|
}
|
|
1821
|
+
/**
|
|
1822
|
+
* A stored record read under the current field names.
|
|
1823
|
+
*
|
|
1824
|
+
* Four fields were renamed after `0.0.9`: `fundingArkTxid`, `refundArkTxid`,
|
|
1825
|
+
* `lockupSpendArkTxids`, and the receive corridor's `profile.claimArkTxid`. All
|
|
1826
|
+
* four arrived together with record persistence itself in `0.0.8`, so `0.0.8`
|
|
1827
|
+
* and `0.0.9` are the only versions that ever wrote them. Backends store the
|
|
1828
|
+
* record WHOLE, so such a store still holds the old names on disk and the
|
|
1829
|
+
* current code reads every one of them as `undefined`.
|
|
1830
|
+
*
|
|
1831
|
+
* Called by every function here that takes a record, so a consumer needs no
|
|
1832
|
+
* boot-time migration of its own; and because the old keys never reach the
|
|
1833
|
+
* object handed back, the next write persists the record without them.
|
|
1834
|
+
*
|
|
1835
|
+
* What it buys, in descending order of sharpness: a receive leg with a partial
|
|
1836
|
+
* claim already out keeps its `claimTxid`, so the value gate stays disarmed
|
|
1837
|
+
* rather than re-blocking the rest of a lockup whose preimage is public;
|
|
1838
|
+
* `refunded` swaps report an outcome txid again; and activity answers from the
|
|
1839
|
+
* record instead of falling back to a lockup read per query. It is NOT a
|
|
1840
|
+
* re-refund fix — `refunded` is terminal, and `restoreFromRepository` puts a
|
|
1841
|
+
* terminal record straight into `finished` without ever driving it.
|
|
1842
|
+
*/
|
|
1843
|
+
declare function normalizeRfqSwapRecord(record: RfqSwapRecord): RfqSwapRecord;
|
|
1777
1844
|
/** First write, at the moment the caller hands the swap to the manager. */
|
|
1778
1845
|
declare function createRfqSwapRecord(origin: RfqSwapOrigin, swap: PersistableRfqSwap): RfqSwapRecord;
|
|
1779
1846
|
/**
|
|
@@ -1792,7 +1859,7 @@ declare function updateRfqSwapRecord(record: RfqSwapRecord, swap: PersistableRfq
|
|
|
1792
1859
|
* A record IS an origin plus manager state, so `record` where an
|
|
1793
1860
|
* {@link RfqSwapOrigin} is wanted type-checks — and is a bug. Spread into
|
|
1794
1861
|
* {@link createRfqSwapRecord} it carries the OLD state's `failure`,
|
|
1795
|
-
* `blockedReason` and `
|
|
1862
|
+
* `blockedReason` and `refundTxid` past `managerState`, which omits a field
|
|
1796
1863
|
* the live swap no longer has and therefore cannot clear one. That is the same
|
|
1797
1864
|
* trap {@link updateRfqSwapRecord} strips those three fields to avoid; this is
|
|
1798
1865
|
* how a caller holding only a record gets an origin that is safe to keep.
|
|
@@ -1838,9 +1905,8 @@ interface MarketsCacheEntry {
|
|
|
1838
1905
|
}
|
|
1839
1906
|
/**
|
|
1840
1907
|
* Everything the package persists, following the monorepo repository
|
|
1841
|
-
* convention
|
|
1842
|
-
*
|
|
1843
|
-
* exactly one of these; there is no second storage seam.
|
|
1908
|
+
* convention: versioned interface, AsyncDisposable, one backend per platform.
|
|
1909
|
+
* Consumers construct exactly one of these; there is no second storage seam.
|
|
1844
1910
|
*
|
|
1845
1911
|
* Durable records (swaps) and rebuildable state (the restore scan's txid
|
|
1846
1912
|
* cursor, the markets cache) live side by side because they share a
|
|
@@ -1848,8 +1914,7 @@ interface MarketsCacheEntry {
|
|
|
1848
1914
|
* that wipes one wants all three gone.
|
|
1849
1915
|
*
|
|
1850
1916
|
* ponytail: no query filters — every consumer reads all swaps and filters
|
|
1851
|
-
* in memory;
|
|
1852
|
-
* subset queries.
|
|
1917
|
+
* in memory; add a filter type when a consumer needs subset queries.
|
|
1853
1918
|
*/
|
|
1854
1919
|
interface AssetSwapRepository extends AsyncDisposable {
|
|
1855
1920
|
/** 4 adds `getRfqSwap`. 3 added the other RFQ methods below; 2 was the
|
|
@@ -1916,4 +1981,4 @@ declare class InMemoryAssetSwapRepository implements AssetSwapRepository {
|
|
|
1916
1981
|
[Symbol.asyncDispose](): Promise<void>;
|
|
1917
1982
|
}
|
|
1918
1983
|
|
|
1919
|
-
export { isRfqSwapTerminal as $, type AssetSwapRepository as A, BTC_ASSET_ID as B, type
|
|
1984
|
+
export { isRfqSwapTerminal as $, type AssetSwapRepository as A, BTC_ASSET_ID as B, type RfqRestoreOptions as C, type RfqRestoreResult as D, type RfqSwapActionName as E, type RfqSwapLockup as F, type RfqSwapManagerConfig as G, type RfqSwapManagerDeps as H, InMemoryAssetSwapRepository as I, type RfqSwapManagerEvents as J, type RfqSwapOrigin as K, type LockupVtxo as L, type MarketsCacheEntry as M, RfqSwapOriginRequired as N, type OnchainSendAction as O, type PersistableRfqSwap as P, type RfqSwapOutcome as Q, type RfqSwapRecord as R, type SwapSecretsProjection as S, type RfqSwapRecordStore as T, type SwapContractRegistry as U, addAssetSwap as V, awaitRfqResolution as W, createRfqSwapRecord as X, findLockupVtxos as Y, getAssetSwaps as Z, getAssetSwapsOrThrow as _, type AssetSwap as a, isRfqTerminal as a0, nextOnchainAction as a1, normalizeRfqSwapRecord as a2, preimageForSwapRecord as a3, pushRefundWithoutReceiver as a4, readLockupFate as a5, rebuildRfqSwap as a6, refundIfUnresolved as a7, rfqSwapOriginOf as a8, shouldRetainRfqSwap as a9, swapSecretsToRecord as aa, updateAssetSwap as ab, updateAssetSwapBestEffort as ac, updateRfqSwapRecord as ad, type RefundIndexer as b, type SwapOperator as c, type RfqSwap as d, type ArkadeRefundResult as e, type LockupSpendIndexer as f, type RfqSwapState as g, RfqSwapManager as h, type RfqSwapManagerCallbacks as i, type AssetSwapStatus as j, type AvailableRfqSwapManagerCallbacks as k, type LightningReceiveSwap as l, type LightningSendSwap as m, type LockupFate as n, LockupNeedsRecoveryError as o, type LockupParams as p, type LockupSpend as q, type OnchainSendSwap as r, type PreimageBlockedReason as s, PreimageNotRecoverableError as t, REFUND_MTP_LAG_SECONDS as u, RFQ_RESOLVED_STATES as v, RFQ_SWAP_RETENTION_SECONDS as w, RFQ_SWAP_TERMINAL_STATES as x, type RefundOutcome as y, type RfqRestoreFailure as z };
|