@arkade-os/swap 0.0.11 → 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 +42 -15
- package/dist/{chunk-RIC5ZTZK.js → chunk-AM3NNUMR.js} +59 -53
- package/dist/index.cjs +585 -202
- package/dist/index.d.cts +127 -36
- package/dist/index.d.ts +127 -36
- package/dist/index.js +528 -157
- 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-CfE18Fif.d.ts → repository-BWP1UstE.d.cts} +84 -56
- package/dist/{repository-B02vsgcV.d.cts → repository-DLpH41ZO.d.ts} +84 -56
- package/dist/{rfq-DkckzRKK.d.ts → rfq-CzCGjICq.d.cts} +42 -32
- package/dist/{rfq-DkckzRKK.d.cts → rfq-CzCGjICq.d.ts} +42 -32
- package/package.json +4 -3
package/dist/nostr.cjs
CHANGED
|
@@ -82,11 +82,14 @@ var LIGHTNING_RECEIVE_PAIR = rfqPair(LIGHTNING_BTC, ARKADE_BTC);
|
|
|
82
82
|
var ONCHAIN_SEND_PAIR = rfqPair(ARKADE_BTC, ONCHAIN_BTC);
|
|
83
83
|
var ONCHAIN_RECEIVE_PAIR = rfqPair(ONCHAIN_BTC, ARKADE_BTC);
|
|
84
84
|
var SwapRefusal = class extends Error {
|
|
85
|
+
/** Literal-typed so the v2 error taxonomy's union discriminates on `name`
|
|
86
|
+
* — a `string` here collapses the discriminant for every member. Same value
|
|
87
|
+
* the constructor has always set, moved to a field initializer. */
|
|
88
|
+
name = "SwapRefusal";
|
|
85
89
|
reason;
|
|
86
90
|
rfqId;
|
|
87
91
|
constructor(reason, rfqId) {
|
|
88
92
|
super(`solver refused: ${reason}`);
|
|
89
|
-
this.name = "SwapRefusal";
|
|
90
93
|
this.reason = reason;
|
|
91
94
|
this.rfqId = rfqId;
|
|
92
95
|
}
|
package/dist/nostr.d.cts
CHANGED
package/dist/nostr.d.ts
CHANGED
package/dist/nostr.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RealmLike } from '@arkade-os/sdk/repositories/realm';
|
|
2
|
-
import { A as AssetSwapRepository, a as AssetSwap, R as RfqSwapRecord, M as MarketsCacheEntry } from '../../repository-
|
|
2
|
+
import { A as AssetSwapRepository, a as AssetSwap, R as RfqSwapRecord, M as MarketsCacheEntry } from '../../repository-BWP1UstE.cjs';
|
|
3
3
|
import '@arkade-os/solver-discovery';
|
|
4
4
|
import '@arkade-os/sdk';
|
|
5
|
-
import '../../rfq-
|
|
5
|
+
import '../../rfq-CzCGjICq.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Realm backend for React Native.
|
|
@@ -49,8 +49,8 @@ declare class RealmAssetSwapRepository implements AssetSwapRepository {
|
|
|
49
49
|
* Realm object schemas for the asset-swap repository.
|
|
50
50
|
*
|
|
51
51
|
* The names land in the **consuming application's** schema namespace, next to
|
|
52
|
-
* its own models and the SDK's `Ark
|
|
53
|
-
*
|
|
52
|
+
* its own models and the SDK's `Ark*`, so they are prefixed with
|
|
53
|
+
* `ArkadeAssetSwap`. Unlike the SQLite backend there is no
|
|
54
54
|
* prefix option: a Realm schema name is baked into the schema objects the
|
|
55
55
|
* consumer registers and into every `realm.objects(…)` call here.
|
|
56
56
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RealmLike } from '@arkade-os/sdk/repositories/realm';
|
|
2
|
-
import { A as AssetSwapRepository, a as AssetSwap, R as RfqSwapRecord, M as MarketsCacheEntry } from '../../repository-
|
|
2
|
+
import { A as AssetSwapRepository, a as AssetSwap, R as RfqSwapRecord, M as MarketsCacheEntry } from '../../repository-DLpH41ZO.js';
|
|
3
3
|
import '@arkade-os/solver-discovery';
|
|
4
4
|
import '@arkade-os/sdk';
|
|
5
|
-
import '../../rfq-
|
|
5
|
+
import '../../rfq-CzCGjICq.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Realm backend for React Native.
|
|
@@ -49,8 +49,8 @@ declare class RealmAssetSwapRepository implements AssetSwapRepository {
|
|
|
49
49
|
* Realm object schemas for the asset-swap repository.
|
|
50
50
|
*
|
|
51
51
|
* The names land in the **consuming application's** schema namespace, next to
|
|
52
|
-
* its own models and the SDK's `Ark
|
|
53
|
-
*
|
|
52
|
+
* its own models and the SDK's `Ark*`, so they are prefixed with
|
|
53
|
+
* `ArkadeAssetSwap`. Unlike the SQLite backend there is no
|
|
54
54
|
* prefix option: a Realm schema name is baked into the schema objects the
|
|
55
55
|
* consumer registers and into every `realm.objects(…)` call here.
|
|
56
56
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SQLExecutor } from '@arkade-os/sdk/repositories/sqlite';
|
|
2
|
-
import { A as AssetSwapRepository, a as AssetSwap, R as RfqSwapRecord, M as MarketsCacheEntry } from '../../repository-
|
|
2
|
+
import { A as AssetSwapRepository, a as AssetSwap, R as RfqSwapRecord, M as MarketsCacheEntry } from '../../repository-BWP1UstE.cjs';
|
|
3
3
|
import '@arkade-os/solver-discovery';
|
|
4
4
|
import '@arkade-os/sdk';
|
|
5
|
-
import '../../rfq-
|
|
5
|
+
import '../../rfq-CzCGjICq.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
|
-
import { A as AssetSwapRepository, a as AssetSwap, R as RfqSwapRecord, M as MarketsCacheEntry } from '../../repository-
|
|
2
|
+
import { A as AssetSwapRepository, a as AssetSwap, R as RfqSwapRecord, M as MarketsCacheEntry } from '../../repository-DLpH41ZO.js';
|
|
3
3
|
import '@arkade-os/solver-discovery';
|
|
4
4
|
import '@arkade-os/sdk';
|
|
5
|
-
import '../../rfq-
|
|
5
|
+
import '../../rfq-CzCGjICq.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
|
-
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.cjs';
|
|
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
|
|
@@ -370,7 +367,7 @@ interface LockupSpend {
|
|
|
370
367
|
checkpointTxid: string;
|
|
371
368
|
/** The ark transaction that spent the above checkpoint output. What
|
|
372
369
|
* history correlation matches on; absent when the indexer omitted it. */
|
|
373
|
-
|
|
370
|
+
txid?: string;
|
|
374
371
|
}
|
|
375
372
|
type LockupFate =
|
|
376
373
|
/** At least one output at the lockup is still unspent. Not over. */
|
|
@@ -501,8 +498,8 @@ declare function readLockupFate(indexer: LockupSpendIndexer, input: {
|
|
|
501
498
|
* outpoints, rather than submitted and rejected. Filtering them out silently
|
|
502
499
|
* would be worse still: it would report success over money that never moved.
|
|
503
500
|
*/
|
|
504
|
-
declare function pushRefundWithoutReceiver(
|
|
505
|
-
|
|
501
|
+
declare function pushRefundWithoutReceiver(operator: SwapOperator, input: {
|
|
502
|
+
contract: InstanceType<typeof VHTLC.ScriptV2>;
|
|
506
503
|
/** The `sender` signer. Build it from the swap record with
|
|
507
504
|
* {@link senderIdentityForSwapRecord} — on an HD wallet that resolves
|
|
508
505
|
* from the seed, with no stored key bytes anywhere, and every way the
|
|
@@ -514,7 +511,7 @@ declare function pushRefundWithoutReceiver(ark: RefundArkProvider, input: {
|
|
|
514
511
|
/** Defaults to the contract's own committed refund destination. */
|
|
515
512
|
refundPkScript?: Uint8Array;
|
|
516
513
|
}): Promise<{
|
|
517
|
-
|
|
514
|
+
txid: string;
|
|
518
515
|
amount: number;
|
|
519
516
|
}>;
|
|
520
517
|
/**
|
|
@@ -536,7 +533,7 @@ type RefundOutcome =
|
|
|
536
533
|
/** The trader took it back via `refundWithoutReceiver`. */
|
|
537
534
|
| {
|
|
538
535
|
outcome: "refunded";
|
|
539
|
-
|
|
536
|
+
txid: string;
|
|
540
537
|
amount: number;
|
|
541
538
|
status: RfqStatus | null;
|
|
542
539
|
}
|
|
@@ -619,9 +616,9 @@ type RefundOutcome =
|
|
|
619
616
|
* well past the deadline skips straight to the push, and a lockup that is
|
|
620
617
|
* already empty comes back as `nothing_to_refund` instead of an error.
|
|
621
618
|
*/
|
|
622
|
-
declare function refundIfUnresolved(transport: RfqTransport,
|
|
619
|
+
declare function refundIfUnresolved(transport: RfqTransport, operator: SwapOperator, indexer: LockupSpendIndexer, input: {
|
|
623
620
|
rfqId: string;
|
|
624
|
-
|
|
621
|
+
contract: InstanceType<typeof VHTLC.ScriptV2>;
|
|
625
622
|
/** @see pushRefundWithoutReceiver */
|
|
626
623
|
sender: Identity;
|
|
627
624
|
/**
|
|
@@ -787,7 +784,7 @@ interface RfqSwapCommon {
|
|
|
787
784
|
createdAt: number;
|
|
788
785
|
updatedAt: number;
|
|
789
786
|
/** Set once the trader's own `refundWithoutReceiver` push landed. */
|
|
790
|
-
|
|
787
|
+
refundTxid?: string;
|
|
791
788
|
/**
|
|
792
789
|
* The ark transactions that SPENT the lockup, stamped from the chain read
|
|
793
790
|
* that ended the swap — `LockupFate.spends`, whichever verdict it reached.
|
|
@@ -796,8 +793,8 @@ interface RfqSwapCommon {
|
|
|
796
793
|
* a solver reclaim on a receive, and — the exception — the trader's own
|
|
797
794
|
* claim when a receive settles. What they have in common is that no local
|
|
798
795
|
* action produced them, so nothing else on this record can name them:
|
|
799
|
-
* {@link
|
|
800
|
-
* `
|
|
796
|
+
* {@link refundTxid} names only a push this wallet made, and
|
|
797
|
+
* `claimTxid` only a submission it made.
|
|
801
798
|
*
|
|
802
799
|
* Stamped so a terminal record answers "which transaction ended this" from
|
|
803
800
|
* storage. Without it the only source is another read of the lockup — a
|
|
@@ -805,10 +802,10 @@ interface RfqSwapCommon {
|
|
|
805
802
|
* has to pay on the offline-first path where it is least affordable.
|
|
806
803
|
*
|
|
807
804
|
* Absent when the swap ended without a chain verdict, or when the indexer
|
|
808
|
-
* named the checkpoint but not the ark transaction — the same `
|
|
805
|
+
* named the checkpoint but not the ark transaction — the same `txid`
|
|
809
806
|
* `LockupSpend` declares optional, for the same reason.
|
|
810
807
|
*/
|
|
811
|
-
|
|
808
|
+
lockupSpendTxids?: string[];
|
|
812
809
|
/** Why `state` is `failed`. */
|
|
813
810
|
failure?: string;
|
|
814
811
|
/** Why `state` is `needs_counterparty`. Distinct from {@link failure},
|
|
@@ -872,7 +869,7 @@ interface LightningReceiveSwap extends RfqSwapCommon {
|
|
|
872
869
|
expectedAmount: number;
|
|
873
870
|
/** Our Arkade claim's txid, once submitted. Set from the callback's return
|
|
874
871
|
* and never from a chain read — the chain's answer is `settled`. */
|
|
875
|
-
|
|
872
|
+
claimTxid?: string;
|
|
876
873
|
}
|
|
877
874
|
/**
|
|
878
875
|
* A monitored swap.
|
|
@@ -883,8 +880,8 @@ interface LightningReceiveSwap extends RfqSwapCommon {
|
|
|
883
880
|
* writes and rebuilds these itself, through
|
|
884
881
|
* {@link RfqSwapManager.restoreFromRepository}. A caller keeping its own store
|
|
885
882
|
* projects it in {@link RfqSwapManagerCallbacks.saveSwap} instead, rebuilds it
|
|
886
|
-
* on restart the way it was made — `
|
|
887
|
-
* `
|
|
883
|
+
* on restart the way it was made — `lightningSendContract` /
|
|
884
|
+
* `lightningReceiveContract` / `onchainHtlcScript` over the quote's binding fields —
|
|
888
885
|
* and hands the result to {@link RfqSwapManager.start}.
|
|
889
886
|
*
|
|
890
887
|
* **`onchain:BTC->arkade:BTC` is deliberately not a member yet.** Its Arkade
|
|
@@ -942,7 +939,7 @@ declare function nextOnchainAction(input: {
|
|
|
942
939
|
/** What the trader's own `refundWithoutReceiver` push returned, or `null` when
|
|
943
940
|
* the lockup held nothing to return. */
|
|
944
941
|
type ArkadeRefundResult = {
|
|
945
|
-
|
|
942
|
+
txid: string;
|
|
946
943
|
amount: number;
|
|
947
944
|
} | null;
|
|
948
945
|
/**
|
|
@@ -993,7 +990,7 @@ interface RfqSwapManagerCallbacks {
|
|
|
993
990
|
* funding that arrived piecemeal can still be swept. */
|
|
994
991
|
partiallyClaimed: boolean;
|
|
995
992
|
}) => Promise<{
|
|
996
|
-
|
|
993
|
+
txid: string;
|
|
997
994
|
amount: number;
|
|
998
995
|
}>;
|
|
999
996
|
/**
|
|
@@ -1107,7 +1104,7 @@ interface RfqSwapManagerConfig {
|
|
|
1107
1104
|
}
|
|
1108
1105
|
/** The contract-manager surface this needs, narrowed for injection — the same
|
|
1109
1106
|
* seam style as {@link LockupSpendIndexer} and `refund.ts`'s
|
|
1110
|
-
*
|
|
1107
|
+
* `RefundIndexer`, and satisfied structurally by a real
|
|
1111
1108
|
* `ContractManager` (`await wallet.getContractManager()`). */
|
|
1112
1109
|
type SwapContractRegistry = Pick<IContractManager, "createContract" | "getContracts" | "onContractEvent" | "setContractWatchState">;
|
|
1113
1110
|
/**
|
|
@@ -1487,6 +1484,17 @@ declare class RfqSwapManager {
|
|
|
1487
1484
|
removeSwap(rfqId: string): Promise<void>;
|
|
1488
1485
|
/** Every swap still being monitored. */
|
|
1489
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[]>;
|
|
1490
1498
|
hasSwap(rfqId: string): Promise<boolean>;
|
|
1491
1499
|
/** True while an action for this swap holds the per-swap lock. */
|
|
1492
1500
|
isProcessing(rfqId: string): Promise<boolean>;
|
|
@@ -1648,7 +1656,7 @@ declare class RfqSwapManager {
|
|
|
1648
1656
|
/**
|
|
1649
1657
|
* Record which ark transactions ended the lockup.
|
|
1650
1658
|
*
|
|
1651
|
-
* Only the ones the indexer actually named: `LockupSpend.
|
|
1659
|
+
* Only the ones the indexer actually named: `LockupSpend.txid` is
|
|
1652
1660
|
* optional, and a checkpoint txid is not what history correlates on — a
|
|
1653
1661
|
* record carrying one would name a transaction the wallet's own activity
|
|
1654
1662
|
* never shows. Fewer txids is the right failure here.
|
|
@@ -1692,10 +1700,9 @@ declare class RfqSwapManager {
|
|
|
1692
1700
|
/**
|
|
1693
1701
|
* Drop a terminal swap from monitoring and report it exactly once.
|
|
1694
1702
|
*
|
|
1695
|
-
* `onSwapCompleted` and `onSwapFailed` are mutually exclusive here
|
|
1696
|
-
*
|
|
1697
|
-
*
|
|
1698
|
-
* 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.
|
|
1699
1706
|
*/
|
|
1700
1707
|
private finalize;
|
|
1701
1708
|
private settleWaiters;
|
|
@@ -1795,7 +1802,7 @@ interface RfqSwapOrigin {
|
|
|
1795
1802
|
* learns it. So it is written once at record creation, like {@link amount},
|
|
1796
1803
|
* and no corridor `project` emits it.
|
|
1797
1804
|
*/
|
|
1798
|
-
|
|
1805
|
+
fundingTxid?: string;
|
|
1799
1806
|
}
|
|
1800
1807
|
/** The stored record: the origin plus the manager's mutable state. */
|
|
1801
1808
|
interface RfqSwapRecord extends RfqSwapOrigin {
|
|
@@ -1803,14 +1810,37 @@ interface RfqSwapRecord extends RfqSwapOrigin {
|
|
|
1803
1810
|
state: RfqSwapState;
|
|
1804
1811
|
createdAt: number;
|
|
1805
1812
|
updatedAt: number;
|
|
1806
|
-
|
|
1813
|
+
refundTxid?: string;
|
|
1807
1814
|
/** The ark transactions that spent the lockup, stamped by the manager from
|
|
1808
1815
|
* the chain read that ended the swap. See
|
|
1809
|
-
* `RfqSwapCommon.
|
|
1810
|
-
|
|
1816
|
+
* `RfqSwapCommon.lockupSpendTxids`. */
|
|
1817
|
+
lockupSpendTxids?: string[];
|
|
1811
1818
|
failure?: string;
|
|
1812
1819
|
blockedReason?: string;
|
|
1813
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;
|
|
1814
1844
|
/** First write, at the moment the caller hands the swap to the manager. */
|
|
1815
1845
|
declare function createRfqSwapRecord(origin: RfqSwapOrigin, swap: PersistableRfqSwap): RfqSwapRecord;
|
|
1816
1846
|
/**
|
|
@@ -1829,7 +1859,7 @@ declare function updateRfqSwapRecord(record: RfqSwapRecord, swap: PersistableRfq
|
|
|
1829
1859
|
* A record IS an origin plus manager state, so `record` where an
|
|
1830
1860
|
* {@link RfqSwapOrigin} is wanted type-checks — and is a bug. Spread into
|
|
1831
1861
|
* {@link createRfqSwapRecord} it carries the OLD state's `failure`,
|
|
1832
|
-
* `blockedReason` and `
|
|
1862
|
+
* `blockedReason` and `refundTxid` past `managerState`, which omits a field
|
|
1833
1863
|
* the live swap no longer has and therefore cannot clear one. That is the same
|
|
1834
1864
|
* trap {@link updateRfqSwapRecord} strips those three fields to avoid; this is
|
|
1835
1865
|
* how a caller holding only a record gets an origin that is safe to keep.
|
|
@@ -1875,9 +1905,8 @@ interface MarketsCacheEntry {
|
|
|
1875
1905
|
}
|
|
1876
1906
|
/**
|
|
1877
1907
|
* Everything the package persists, following the monorepo repository
|
|
1878
|
-
* convention
|
|
1879
|
-
*
|
|
1880
|
-
* 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.
|
|
1881
1910
|
*
|
|
1882
1911
|
* Durable records (swaps) and rebuildable state (the restore scan's txid
|
|
1883
1912
|
* cursor, the markets cache) live side by side because they share a
|
|
@@ -1885,8 +1914,7 @@ interface MarketsCacheEntry {
|
|
|
1885
1914
|
* that wipes one wants all three gone.
|
|
1886
1915
|
*
|
|
1887
1916
|
* ponytail: no query filters — every consumer reads all swaps and filters
|
|
1888
|
-
* in memory;
|
|
1889
|
-
* subset queries.
|
|
1917
|
+
* in memory; add a filter type when a consumer needs subset queries.
|
|
1890
1918
|
*/
|
|
1891
1919
|
interface AssetSwapRepository extends AsyncDisposable {
|
|
1892
1920
|
/** 4 adds `getRfqSwap`. 3 added the other RFQ methods below; 2 was the
|
|
@@ -1953,4 +1981,4 @@ declare class InMemoryAssetSwapRepository implements AssetSwapRepository {
|
|
|
1953
1981
|
[Symbol.asyncDispose](): Promise<void>;
|
|
1954
1982
|
}
|
|
1955
1983
|
|
|
1956
|
-
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 };
|