@arkade-os/swap 0.0.10 → 0.0.11
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 +17 -0
- package/dist/{chunk-5NPYNQ5V.js → chunk-RIC5ZTZK.js} +68 -28
- package/dist/index.cjs +196 -43
- package/dist/index.d.cts +61 -15
- package/dist/index.d.ts +61 -15
- package/dist/index.js +129 -16
- 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 +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- 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-B02vsgcV.d.cts} +42 -5
- package/dist/{repository-Cw2EvvZG.d.ts → repository-CfE18Fif.d.ts} +42 -5
- package/dist/{rfq-DglvHMNC.d.ts → rfq-DkckzRKK.d.cts} +44 -16
- package/dist/{rfq-DglvHMNC.d.cts → rfq-DkckzRKK.d.ts} +44 -16
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DiscoveredMarket } from '@arkade-os/solver-discovery';
|
|
2
2
|
import { IWallet, ProvisionedKey, ProvisionedClaimSecret, RestArkProvider, RestIndexerProvider, VHTLC, Identity, IContractManager } from '@arkade-os/sdk';
|
|
3
|
-
import { x as RfqStatus, y as RfqTransport, a as OnchainHtlc, e as ChainUtxo, C as ChainSource, t as OnchainHtlcPhase } from './rfq-
|
|
3
|
+
import { x as RfqStatus, y as RfqTransport, a as OnchainHtlc, e as ChainUtxo, C as ChainSource, t as OnchainHtlcPhase } from './rfq-DkckzRKK.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.
|
|
@@ -332,9 +332,11 @@ declare class LockupNeedsRecoveryError extends Error {
|
|
|
332
332
|
* defensively rather than assumed. It costs the two waiting callers nothing
|
|
333
333
|
* they wanted: `awaitLockupFunding` keeps waiting for a claimable lockup
|
|
334
334
|
* 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
|
|
335
|
+
* `refundIfUnresolved` reports rather than grinding a doomed push to its
|
|
336
|
+
* deadline. Both that function and `RfqSwapManager` name the exit through
|
|
337
|
+
* {@link readLockupFate}, which queries unfiltered and reports it as `exited`;
|
|
338
|
+
* this drop is the second line, and what still refuses the push on a pass where
|
|
339
|
+
* the fate read learned nothing.
|
|
338
340
|
*
|
|
339
341
|
* This read — not the RFQ's reported state — is the authority on whether
|
|
340
342
|
* there is anything left at the lockup.
|
|
@@ -555,6 +557,21 @@ type RefundOutcome =
|
|
|
555
557
|
outpoints: string[];
|
|
556
558
|
vtxos: LockupVtxo[];
|
|
557
559
|
status: RfqStatus | null;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* The lockup was unilaterally exited: its outputs sit onchain under the VHTLC
|
|
563
|
+
* script, where no offchain refund can reach them. Returned rather than
|
|
564
|
+
* retried: no amount of waiting changes where the money lives. Complete the
|
|
565
|
+
* unroll and spend the outputs onchain — then there is nothing left to refund.
|
|
566
|
+
*
|
|
567
|
+
* Distinct from {@link RefundOutcome} `needs_recovery` on purpose: that
|
|
568
|
+
* variant's remedy is recovery into a fresh batch, which is a spend no batch
|
|
569
|
+
* can make for an output that is already onchain.
|
|
570
|
+
*/
|
|
571
|
+
| {
|
|
572
|
+
outcome: "exited";
|
|
573
|
+
outpoints: string[];
|
|
574
|
+
status: RfqStatus | null;
|
|
558
575
|
};
|
|
559
576
|
/**
|
|
560
577
|
* Ask first, then fall back: watch the swap for the solver to resolve it, and
|
|
@@ -583,16 +600,36 @@ type RefundOutcome =
|
|
|
583
600
|
* is gone the CLTV refund is not "not yet" but "not this way", so it returns
|
|
584
601
|
* `needs_recovery` naming the outpoints rather than retrying until the
|
|
585
602
|
* deadline. Recover them and call again.
|
|
603
|
+
* - **An exited lockup ends it the same way, and is checked first.** Each pass
|
|
604
|
+
* past the deadline asks {@link readLockupFate} before reading what is
|
|
605
|
+
* refundable, so an output that has been unilaterally exited returns `exited`
|
|
606
|
+
* instead of feeding a push that cannot land. It costs one extra `getVtxos`
|
|
607
|
+
* per such pass (three where there were two), plus a `getVirtualTxs` on a
|
|
608
|
+
* fully-spent lockup; only the pass that returns `exited` saves the other two.
|
|
609
|
+
* Paid to prevent a push that would otherwise be retried to the deadline and
|
|
610
|
+
* then rethrown. A failing fate read is swallowed, not raised: it is a
|
|
611
|
+
* shortcut, and losing it must not end a wait the ordinary path could answer.
|
|
612
|
+
*
|
|
613
|
+
* A lockup funded in two sends of which only one exited reports `exited` for
|
|
614
|
+
* the whole thing and leaves the live half unrefunded. That is deliberate:
|
|
615
|
+
* `RfqSwapManager` reports the same lockup `exited` on the same any-output
|
|
616
|
+
* rule, and the two must not disagree.
|
|
586
617
|
*
|
|
587
618
|
* Safe to call late, and safe to call again: a caller recovering from a crash
|
|
588
619
|
* well past the deadline skips straight to the push, and a lockup that is
|
|
589
620
|
* already empty comes back as `nothing_to_refund` instead of an error.
|
|
590
621
|
*/
|
|
591
|
-
declare function refundIfUnresolved(transport: RfqTransport, ark: RefundArkProvider, indexer:
|
|
622
|
+
declare function refundIfUnresolved(transport: RfqTransport, ark: RefundArkProvider, indexer: LockupSpendIndexer, input: {
|
|
592
623
|
rfqId: string;
|
|
593
624
|
script: InstanceType<typeof VHTLC.ScriptV2>;
|
|
594
625
|
/** @see pushRefundWithoutReceiver */
|
|
595
626
|
sender: Identity;
|
|
627
|
+
/**
|
|
628
|
+
* `sha256(P)`, hex — the quote's `payment_hash`, as {@link readLockupFate}
|
|
629
|
+
* takes it. Not derivable from `script`, whose `preimageHash` is a
|
|
630
|
+
* `hash160` of the same secret.
|
|
631
|
+
*/
|
|
632
|
+
paymentHash: string;
|
|
596
633
|
/** `refund_locktime` from the quote, unix seconds. */
|
|
597
634
|
refundLocktime: number;
|
|
598
635
|
/** Defaults to the contract's own committed refund destination. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DiscoveredMarket } from '@arkade-os/solver-discovery';
|
|
2
2
|
import { IWallet, ProvisionedKey, ProvisionedClaimSecret, RestArkProvider, RestIndexerProvider, VHTLC, Identity, IContractManager } from '@arkade-os/sdk';
|
|
3
|
-
import { x as RfqStatus, y as RfqTransport, a as OnchainHtlc, e as ChainUtxo, C as ChainSource, t as OnchainHtlcPhase } from './rfq-
|
|
3
|
+
import { x as RfqStatus, y as RfqTransport, a as OnchainHtlc, e as ChainUtxo, C as ChainSource, t as OnchainHtlcPhase } from './rfq-DkckzRKK.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.
|
|
@@ -332,9 +332,11 @@ declare class LockupNeedsRecoveryError extends Error {
|
|
|
332
332
|
* defensively rather than assumed. It costs the two waiting callers nothing
|
|
333
333
|
* they wanted: `awaitLockupFunding` keeps waiting for a claimable lockup
|
|
334
334
|
* 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
|
|
335
|
+
* `refundIfUnresolved` reports rather than grinding a doomed push to its
|
|
336
|
+
* deadline. Both that function and `RfqSwapManager` name the exit through
|
|
337
|
+
* {@link readLockupFate}, which queries unfiltered and reports it as `exited`;
|
|
338
|
+
* this drop is the second line, and what still refuses the push on a pass where
|
|
339
|
+
* the fate read learned nothing.
|
|
338
340
|
*
|
|
339
341
|
* This read — not the RFQ's reported state — is the authority on whether
|
|
340
342
|
* there is anything left at the lockup.
|
|
@@ -555,6 +557,21 @@ type RefundOutcome =
|
|
|
555
557
|
outpoints: string[];
|
|
556
558
|
vtxos: LockupVtxo[];
|
|
557
559
|
status: RfqStatus | null;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* The lockup was unilaterally exited: its outputs sit onchain under the VHTLC
|
|
563
|
+
* script, where no offchain refund can reach them. Returned rather than
|
|
564
|
+
* retried: no amount of waiting changes where the money lives. Complete the
|
|
565
|
+
* unroll and spend the outputs onchain — then there is nothing left to refund.
|
|
566
|
+
*
|
|
567
|
+
* Distinct from {@link RefundOutcome} `needs_recovery` on purpose: that
|
|
568
|
+
* variant's remedy is recovery into a fresh batch, which is a spend no batch
|
|
569
|
+
* can make for an output that is already onchain.
|
|
570
|
+
*/
|
|
571
|
+
| {
|
|
572
|
+
outcome: "exited";
|
|
573
|
+
outpoints: string[];
|
|
574
|
+
status: RfqStatus | null;
|
|
558
575
|
};
|
|
559
576
|
/**
|
|
560
577
|
* Ask first, then fall back: watch the swap for the solver to resolve it, and
|
|
@@ -583,16 +600,36 @@ type RefundOutcome =
|
|
|
583
600
|
* is gone the CLTV refund is not "not yet" but "not this way", so it returns
|
|
584
601
|
* `needs_recovery` naming the outpoints rather than retrying until the
|
|
585
602
|
* deadline. Recover them and call again.
|
|
603
|
+
* - **An exited lockup ends it the same way, and is checked first.** Each pass
|
|
604
|
+
* past the deadline asks {@link readLockupFate} before reading what is
|
|
605
|
+
* refundable, so an output that has been unilaterally exited returns `exited`
|
|
606
|
+
* instead of feeding a push that cannot land. It costs one extra `getVtxos`
|
|
607
|
+
* per such pass (three where there were two), plus a `getVirtualTxs` on a
|
|
608
|
+
* fully-spent lockup; only the pass that returns `exited` saves the other two.
|
|
609
|
+
* Paid to prevent a push that would otherwise be retried to the deadline and
|
|
610
|
+
* then rethrown. A failing fate read is swallowed, not raised: it is a
|
|
611
|
+
* shortcut, and losing it must not end a wait the ordinary path could answer.
|
|
612
|
+
*
|
|
613
|
+
* A lockup funded in two sends of which only one exited reports `exited` for
|
|
614
|
+
* the whole thing and leaves the live half unrefunded. That is deliberate:
|
|
615
|
+
* `RfqSwapManager` reports the same lockup `exited` on the same any-output
|
|
616
|
+
* rule, and the two must not disagree.
|
|
586
617
|
*
|
|
587
618
|
* Safe to call late, and safe to call again: a caller recovering from a crash
|
|
588
619
|
* well past the deadline skips straight to the push, and a lockup that is
|
|
589
620
|
* already empty comes back as `nothing_to_refund` instead of an error.
|
|
590
621
|
*/
|
|
591
|
-
declare function refundIfUnresolved(transport: RfqTransport, ark: RefundArkProvider, indexer:
|
|
622
|
+
declare function refundIfUnresolved(transport: RfqTransport, ark: RefundArkProvider, indexer: LockupSpendIndexer, input: {
|
|
592
623
|
rfqId: string;
|
|
593
624
|
script: InstanceType<typeof VHTLC.ScriptV2>;
|
|
594
625
|
/** @see pushRefundWithoutReceiver */
|
|
595
626
|
sender: Identity;
|
|
627
|
+
/**
|
|
628
|
+
* `sha256(P)`, hex — the quote's `payment_hash`, as {@link readLockupFate}
|
|
629
|
+
* takes it. Not derivable from `script`, whose `preimageHash` is a
|
|
630
|
+
* `hash160` of the same secret.
|
|
631
|
+
*/
|
|
632
|
+
paymentHash: string;
|
|
596
633
|
/** `refund_locktime` from the quote, unix seconds. */
|
|
597
634
|
refundLocktime: number;
|
|
598
635
|
/** Defaults to the contract's own committed refund destination. */
|
|
@@ -255,11 +255,15 @@ declare class SwapRefusal extends Error {
|
|
|
255
255
|
readonly rfqId: string | undefined;
|
|
256
256
|
constructor(reason: string, rfqId?: string);
|
|
257
257
|
}
|
|
258
|
-
/**
|
|
258
|
+
/**
|
|
259
|
+
* The solver's address does not match the local derivation. NEVER fund past
|
|
260
|
+
* this. `derived` is every candidate address tried — more than one when the
|
|
261
|
+
* derivation itself is ambiguous, see {@link verifyLockupAddress}.
|
|
262
|
+
*/
|
|
259
263
|
declare class AddressMismatch extends Error {
|
|
260
|
-
readonly derived: string;
|
|
264
|
+
readonly derived: string | string[];
|
|
261
265
|
readonly quoted: string | undefined;
|
|
262
|
-
constructor(derived: string, quoted?: string);
|
|
266
|
+
constructor(derived: string | string[], quoted?: string);
|
|
263
267
|
}
|
|
264
268
|
/** A fresh client-chosen negotiation id: 32 random bytes, lowercase hex. */
|
|
265
269
|
declare const newRfqId: () => string;
|
|
@@ -323,9 +327,24 @@ declare const arkadeSwapRequest: (input: {
|
|
|
323
327
|
* 90 because the refund CLTV matures against median-time-past (BIP-113),
|
|
324
328
|
* which lags wall clock by ~1h — a smaller wall-clock margin is no margin. */
|
|
325
329
|
declare const MIN_HEADROOM_SECONDS: number;
|
|
326
|
-
/**
|
|
327
|
-
*
|
|
328
|
-
|
|
330
|
+
/**
|
|
331
|
+
* Compare-only check of the solver's address against YOUR OWN derivation(s)
|
|
332
|
+
* — never extends trust, only narrows it.
|
|
333
|
+
*
|
|
334
|
+
* `derivedAddress` may be a single address or an array of candidates. Pass an
|
|
335
|
+
* array when your own derivation is ambiguous — as it is for the covenant
|
|
336
|
+
* lockups while solvers roll out the timelocked non-interactive refund leaf:
|
|
337
|
+
* nothing on the wire says whether a given quote's covenant carries it (the
|
|
338
|
+
* shape is fixed by the solver's own build, not negotiated per quote), so the
|
|
339
|
+
* only safe move is to derive BOTH shapes and accept whichever one the quote's
|
|
340
|
+
* own `lockup_address` matches. This loses no security: every candidate shape
|
|
341
|
+
* pins the refund to the trader's own refund destination, so a solver gains
|
|
342
|
+
* nothing by choosing which one to quote.
|
|
343
|
+
*
|
|
344
|
+
* Throws {@link AddressMismatch} only when NONE of the candidates match.
|
|
345
|
+
* Returns the address that matched, so calls chain exactly as before.
|
|
346
|
+
*/
|
|
347
|
+
declare const verifyLockupAddress: (quote: RfqQuote, derivedAddress: string | string[]) => string;
|
|
329
348
|
/** The user's gates, checked immediately before funding — never at quote
|
|
330
349
|
* time. Throws with a stable `reason` property. `invoiceExpiresAt` applies to
|
|
331
350
|
* BOLT11 profiles only; `onchain` adds the L1-HTLC gates (§ guardrails of the
|
|
@@ -413,15 +432,17 @@ declare const unilateralRefundWithoutReceiverDelay: (claimDelay: number) => numb
|
|
|
413
432
|
* hex); the script's HASH160 commitment is derived from it here, which is why
|
|
414
433
|
* the trader never needs to see `P`.
|
|
415
434
|
*
|
|
416
|
-
* Every quote gets the full
|
|
435
|
+
* Every quote gets the full emulator-covenant suite on top of VHTLC's own six
|
|
417
436
|
* (`claim`/`refund`/`refundWithoutReceiver`/`unilateralClaim`/
|
|
418
|
-
* `unilateralRefund`/`unilateralRefundWithoutReceiver`)
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
* own `
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
437
|
+
* `unilateralRefund`/`unilateralRefundWithoutReceiver`): `nonInteractiveClaim`
|
|
438
|
+
* (server + emulator, pays the solver's own `receiverPkScript`, no solver
|
|
439
|
+
* signature needed), `nonInteractiveRefund` (server + solver + emulator, pays
|
|
440
|
+
* the trader's own `refundPkScript`, no timelock and no trader signature
|
|
441
|
+
* needed — see {@link VHTLC.Options.nonInteractiveParameters}'s doc comment for why
|
|
442
|
+
* that matters), and its timelocked twin `nonInteractiveRefundWithoutReceiver`
|
|
443
|
+
* (server + emulator alone, after `refundLocktime` — the only refund tier
|
|
444
|
+
* needing no participant at all). Nine leaves in all, unless `legacy` says
|
|
445
|
+
* otherwise.
|
|
425
446
|
*/
|
|
426
447
|
declare function lightningSendVtxoScript(params: {
|
|
427
448
|
/** Binding field #1: the solver's x-only key, from the quote. */
|
|
@@ -439,7 +460,7 @@ declare function lightningSendVtxoScript(params: {
|
|
|
439
460
|
/** Emulator x-only key (32 bytes). */
|
|
440
461
|
emulatorPubkey: Uint8Array;
|
|
441
462
|
/** Where a refund must pay: the trader's P2TR pkScript (34 bytes). Also
|
|
442
|
-
*
|
|
463
|
+
* the refund covenants' destination. */
|
|
443
464
|
refundPkScript: Uint8Array;
|
|
444
465
|
/** The trader's own key — VHTLC's `sender` role. Required on every
|
|
445
466
|
* interactive refund-side leaf; the trader generates and persists it
|
|
@@ -450,6 +471,11 @@ declare function lightningSendVtxoScript(params: {
|
|
|
450
471
|
* covenant key can be derived; the trader does not otherwise use or trust
|
|
451
472
|
* this value. P2TR pkScript, 34 bytes. */
|
|
452
473
|
receiverPkScript: Uint8Array;
|
|
474
|
+
/** LEGACY REBUILD ONLY — see {@link VHTLC.Options.nonInteractiveParameters}'s
|
|
475
|
+
* `legacy` field. Set only to re-derive a lockup funded before the
|
|
476
|
+
* timelocked refund leaf shipped; {@link matchQuotedLockup} passes it when
|
|
477
|
+
* the quote's own address says the solver quoted that shape. */
|
|
478
|
+
legacy?: "preTimelockedRefund";
|
|
453
479
|
}): InstanceType<typeof VHTLC.ScriptV2>;
|
|
454
480
|
/** Every input {@link lightningSendVtxoScript} builds from. Derived from the
|
|
455
481
|
* builder rather than restated, so the two cannot drift. */
|
|
@@ -786,7 +812,7 @@ declare const assertReceivable: (input: {
|
|
|
786
812
|
/** Absolute sats ceiling on `from_amount`. */
|
|
787
813
|
maxPayAmount?: number;
|
|
788
814
|
}) => void;
|
|
789
|
-
/** Compile the RECEIVE-direction VHTLC: the same
|
|
815
|
+
/** Compile the RECEIVE-direction VHTLC: the same suite-carrying tree as {@link
|
|
790
816
|
* lightningSendVtxoScript} with the roles inverted — the trader is the
|
|
791
817
|
* `receiver` (it generated `P` and claims the lockup with it), the solver is
|
|
792
818
|
* the `sender` (it funds the lockup and holds the refund recourse). One
|
|
@@ -817,6 +843,8 @@ declare function receiveVtxoScript(params: {
|
|
|
817
843
|
/** The trader's own Arkade payout pkScript (decoded from its payout
|
|
818
844
|
* address) — `nonInteractiveClaim`'s pinned destination. */
|
|
819
845
|
payoutPkScript: Uint8Array;
|
|
846
|
+
/** LEGACY REBUILD ONLY — see {@link lightningSendVtxoScript}'s `legacy`. */
|
|
847
|
+
legacy?: "preTimelockedRefund";
|
|
820
848
|
}): InstanceType<typeof VHTLC.ScriptV2>;
|
|
821
849
|
/** Every input {@link receiveVtxoScript} builds from; see
|
|
822
850
|
* {@link LightningSendTreeParams}. */
|
|
@@ -255,11 +255,15 @@ declare class SwapRefusal extends Error {
|
|
|
255
255
|
readonly rfqId: string | undefined;
|
|
256
256
|
constructor(reason: string, rfqId?: string);
|
|
257
257
|
}
|
|
258
|
-
/**
|
|
258
|
+
/**
|
|
259
|
+
* The solver's address does not match the local derivation. NEVER fund past
|
|
260
|
+
* this. `derived` is every candidate address tried — more than one when the
|
|
261
|
+
* derivation itself is ambiguous, see {@link verifyLockupAddress}.
|
|
262
|
+
*/
|
|
259
263
|
declare class AddressMismatch extends Error {
|
|
260
|
-
readonly derived: string;
|
|
264
|
+
readonly derived: string | string[];
|
|
261
265
|
readonly quoted: string | undefined;
|
|
262
|
-
constructor(derived: string, quoted?: string);
|
|
266
|
+
constructor(derived: string | string[], quoted?: string);
|
|
263
267
|
}
|
|
264
268
|
/** A fresh client-chosen negotiation id: 32 random bytes, lowercase hex. */
|
|
265
269
|
declare const newRfqId: () => string;
|
|
@@ -323,9 +327,24 @@ declare const arkadeSwapRequest: (input: {
|
|
|
323
327
|
* 90 because the refund CLTV matures against median-time-past (BIP-113),
|
|
324
328
|
* which lags wall clock by ~1h — a smaller wall-clock margin is no margin. */
|
|
325
329
|
declare const MIN_HEADROOM_SECONDS: number;
|
|
326
|
-
/**
|
|
327
|
-
*
|
|
328
|
-
|
|
330
|
+
/**
|
|
331
|
+
* Compare-only check of the solver's address against YOUR OWN derivation(s)
|
|
332
|
+
* — never extends trust, only narrows it.
|
|
333
|
+
*
|
|
334
|
+
* `derivedAddress` may be a single address or an array of candidates. Pass an
|
|
335
|
+
* array when your own derivation is ambiguous — as it is for the covenant
|
|
336
|
+
* lockups while solvers roll out the timelocked non-interactive refund leaf:
|
|
337
|
+
* nothing on the wire says whether a given quote's covenant carries it (the
|
|
338
|
+
* shape is fixed by the solver's own build, not negotiated per quote), so the
|
|
339
|
+
* only safe move is to derive BOTH shapes and accept whichever one the quote's
|
|
340
|
+
* own `lockup_address` matches. This loses no security: every candidate shape
|
|
341
|
+
* pins the refund to the trader's own refund destination, so a solver gains
|
|
342
|
+
* nothing by choosing which one to quote.
|
|
343
|
+
*
|
|
344
|
+
* Throws {@link AddressMismatch} only when NONE of the candidates match.
|
|
345
|
+
* Returns the address that matched, so calls chain exactly as before.
|
|
346
|
+
*/
|
|
347
|
+
declare const verifyLockupAddress: (quote: RfqQuote, derivedAddress: string | string[]) => string;
|
|
329
348
|
/** The user's gates, checked immediately before funding — never at quote
|
|
330
349
|
* time. Throws with a stable `reason` property. `invoiceExpiresAt` applies to
|
|
331
350
|
* BOLT11 profiles only; `onchain` adds the L1-HTLC gates (§ guardrails of the
|
|
@@ -413,15 +432,17 @@ declare const unilateralRefundWithoutReceiverDelay: (claimDelay: number) => numb
|
|
|
413
432
|
* hex); the script's HASH160 commitment is derived from it here, which is why
|
|
414
433
|
* the trader never needs to see `P`.
|
|
415
434
|
*
|
|
416
|
-
* Every quote gets the full
|
|
435
|
+
* Every quote gets the full emulator-covenant suite on top of VHTLC's own six
|
|
417
436
|
* (`claim`/`refund`/`refundWithoutReceiver`/`unilateralClaim`/
|
|
418
|
-
* `unilateralRefund`/`unilateralRefundWithoutReceiver`)
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
* own `
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
437
|
+
* `unilateralRefund`/`unilateralRefundWithoutReceiver`): `nonInteractiveClaim`
|
|
438
|
+
* (server + emulator, pays the solver's own `receiverPkScript`, no solver
|
|
439
|
+
* signature needed), `nonInteractiveRefund` (server + solver + emulator, pays
|
|
440
|
+
* the trader's own `refundPkScript`, no timelock and no trader signature
|
|
441
|
+
* needed — see {@link VHTLC.Options.nonInteractiveParameters}'s doc comment for why
|
|
442
|
+
* that matters), and its timelocked twin `nonInteractiveRefundWithoutReceiver`
|
|
443
|
+
* (server + emulator alone, after `refundLocktime` — the only refund tier
|
|
444
|
+
* needing no participant at all). Nine leaves in all, unless `legacy` says
|
|
445
|
+
* otherwise.
|
|
425
446
|
*/
|
|
426
447
|
declare function lightningSendVtxoScript(params: {
|
|
427
448
|
/** Binding field #1: the solver's x-only key, from the quote. */
|
|
@@ -439,7 +460,7 @@ declare function lightningSendVtxoScript(params: {
|
|
|
439
460
|
/** Emulator x-only key (32 bytes). */
|
|
440
461
|
emulatorPubkey: Uint8Array;
|
|
441
462
|
/** Where a refund must pay: the trader's P2TR pkScript (34 bytes). Also
|
|
442
|
-
*
|
|
463
|
+
* the refund covenants' destination. */
|
|
443
464
|
refundPkScript: Uint8Array;
|
|
444
465
|
/** The trader's own key — VHTLC's `sender` role. Required on every
|
|
445
466
|
* interactive refund-side leaf; the trader generates and persists it
|
|
@@ -450,6 +471,11 @@ declare function lightningSendVtxoScript(params: {
|
|
|
450
471
|
* covenant key can be derived; the trader does not otherwise use or trust
|
|
451
472
|
* this value. P2TR pkScript, 34 bytes. */
|
|
452
473
|
receiverPkScript: Uint8Array;
|
|
474
|
+
/** LEGACY REBUILD ONLY — see {@link VHTLC.Options.nonInteractiveParameters}'s
|
|
475
|
+
* `legacy` field. Set only to re-derive a lockup funded before the
|
|
476
|
+
* timelocked refund leaf shipped; {@link matchQuotedLockup} passes it when
|
|
477
|
+
* the quote's own address says the solver quoted that shape. */
|
|
478
|
+
legacy?: "preTimelockedRefund";
|
|
453
479
|
}): InstanceType<typeof VHTLC.ScriptV2>;
|
|
454
480
|
/** Every input {@link lightningSendVtxoScript} builds from. Derived from the
|
|
455
481
|
* builder rather than restated, so the two cannot drift. */
|
|
@@ -786,7 +812,7 @@ declare const assertReceivable: (input: {
|
|
|
786
812
|
/** Absolute sats ceiling on `from_amount`. */
|
|
787
813
|
maxPayAmount?: number;
|
|
788
814
|
}) => void;
|
|
789
|
-
/** Compile the RECEIVE-direction VHTLC: the same
|
|
815
|
+
/** Compile the RECEIVE-direction VHTLC: the same suite-carrying tree as {@link
|
|
790
816
|
* lightningSendVtxoScript} with the roles inverted — the trader is the
|
|
791
817
|
* `receiver` (it generated `P` and claims the lockup with it), the solver is
|
|
792
818
|
* the `sender` (it funds the lockup and holds the refund recourse). One
|
|
@@ -817,6 +843,8 @@ declare function receiveVtxoScript(params: {
|
|
|
817
843
|
/** The trader's own Arkade payout pkScript (decoded from its payout
|
|
818
844
|
* address) — `nonInteractiveClaim`'s pinned destination. */
|
|
819
845
|
payoutPkScript: Uint8Array;
|
|
846
|
+
/** LEGACY REBUILD ONLY — see {@link lightningSendVtxoScript}'s `legacy`. */
|
|
847
|
+
legacy?: "preTimelockedRefund";
|
|
820
848
|
}): InstanceType<typeof VHTLC.ScriptV2>;
|
|
821
849
|
/** Every input {@link receiveVtxoScript} builds from; see
|
|
822
850
|
* {@link LightningSendTreeParams}. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkade-os/swap",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Client-side Arkade Intents asset swaps: discover markets, quote, create/track/cancel offers, restore from chain.",
|
|
6
6
|
"repository": {
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@noble/hashes": "2.0.1",
|
|
71
71
|
"@scure/base": "2.0.0",
|
|
72
72
|
"@scure/btc-signer": "2.0.1",
|
|
73
|
-
"@arkade-os/sdk": "0.4.
|
|
73
|
+
"@arkade-os/sdk": "0.4.68"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"nostr-tools": "^2.12.0"
|