@arkade-os/swap 0.0.2 → 0.0.4
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 +115 -83
- package/dist/{chunk-C5P7R7JT.js → chunk-DLM6BVTB.js} +80 -252
- package/dist/index.cjs +163 -303
- package/dist/index.d.cts +207 -22
- package/dist/index.d.ts +207 -22
- package/dist/index.js +95 -76
- package/dist/nostr.cjs +10 -14
- package/dist/nostr.d.cts +1 -2
- package/dist/nostr.d.ts +1 -2
- package/dist/nostr.js +2 -2
- package/dist/{rfq-CRgIOQ_y.d.cts → rfq-DjZlesr4.d.cts} +32 -352
- package/dist/{rfq-CRgIOQ_y.d.ts → rfq-DjZlesr4.d.ts} +32 -352
- package/package.json +2 -2
|
@@ -1,150 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DiscoveredMarket } from '@arkade-os/solver-discovery';
|
|
3
|
-
|
|
4
|
-
type AssetSwapStatus = "pending" | "cancelling" | "fulfilled" | "cancelled" | "recoverable" | "awaiting_fill" | "claimable" | "claimed" | "refunded_l1";
|
|
5
|
-
/** The sentinel asset id for BTC itself, as opposed to a 68-hex asset id.
|
|
6
|
-
* Lives here with the {@link AssetSwap} fields it describes so the market and
|
|
7
|
-
* restore layers share one spelling instead of re-typing the literal. */
|
|
8
|
-
declare const BTC_ASSET_ID = "btc";
|
|
9
|
-
interface AssetSwapFallbackSecretsV1 {
|
|
10
|
-
version: 1;
|
|
11
|
-
type: "stored";
|
|
12
|
-
senderPrivateKeyHex: string;
|
|
13
|
-
/** Onchain-send only. A lightning send's preimage belongs to the payee. */
|
|
14
|
-
preimageHex?: string;
|
|
15
|
-
}
|
|
16
|
-
type AssetSwapFallbackSecrets = AssetSwapFallbackSecretsV1;
|
|
17
|
-
interface AssetSwap {
|
|
18
|
-
/** Funding txid — the swap's identity. */
|
|
19
|
-
id: string;
|
|
20
|
-
/** 'btc' or a 68-hex asset id. */
|
|
21
|
-
fromAsset: string;
|
|
22
|
-
toAsset: string;
|
|
23
|
-
/** Atomic amounts as strings (bigint is not JSON-safe). */
|
|
24
|
-
fromAmount: string;
|
|
25
|
-
/** The covenant wantAmount — a floor, the fill pays >= this. */
|
|
26
|
-
toAmount: string;
|
|
27
|
-
swapAddress: string;
|
|
28
|
-
/** Hex pkScript of the swap contract — the indexer monitoring key. */
|
|
29
|
-
swapPkScript: string;
|
|
30
|
-
/** TLV offer — needed to rebuild the contract for cancel. */
|
|
31
|
-
offerHex: string;
|
|
32
|
-
fundingTxid: string;
|
|
33
|
-
spentTxid?: string;
|
|
34
|
-
status: AssetSwapStatus;
|
|
35
|
-
createdAt: number;
|
|
36
|
-
completedAt?: number;
|
|
37
|
-
/** RFQ pair string, e.g. `arkade:BTC->onchain:BTC`. */
|
|
38
|
-
pair?: string;
|
|
39
|
-
/** `sha256(P)`, hex. Public, and how a restore confirms a candidate
|
|
40
|
-
* derivation is the right one. */
|
|
41
|
-
paymentHash?: string;
|
|
42
|
-
/**
|
|
43
|
-
* The HD descriptor this swap's secrets derive from. Public — it is what
|
|
44
|
-
* lets the record carry no secrets at all. Present iff the swap was
|
|
45
|
-
* created on a wallet that can allocate.
|
|
46
|
-
*/
|
|
47
|
-
signingDescriptor?: string;
|
|
48
|
-
/** P, hex, when the user supplied a preimage that is not seed-derived. */
|
|
49
|
-
preimageHex?: string;
|
|
50
|
-
/**
|
|
51
|
-
* Complete stored-arm secrets for wallets that cannot derive. Versioned
|
|
52
|
-
* and discriminated so restore can rebuild both the sender identity and,
|
|
53
|
-
* for onchain sends, P.
|
|
54
|
-
*/
|
|
55
|
-
fallbackSecrets?: AssetSwapFallbackSecrets;
|
|
56
|
-
/** The L1 HTLC's pkScript, hex — the chain-watch key. */
|
|
57
|
-
htlcPkScriptHex?: string;
|
|
58
|
-
htlcLocktime?: number;
|
|
59
|
-
/** The L1 funding txid, once observed. */
|
|
60
|
-
l1Txid?: string;
|
|
61
|
-
}
|
|
62
|
-
/** All swaps, newest-first. Insertion order is not chronological — the restore
|
|
63
|
-
* scan rebuilds records in tx-scan order — so sort at read to keep
|
|
64
|
-
* newest-first canonical for every consumer. */
|
|
65
|
-
declare const getAssetSwapsOrThrow: (repository: AssetSwapRepository) => Promise<AssetSwap[]>;
|
|
66
|
-
/** The consumer read: a broken backend reads as no swaps rather than crashing
|
|
67
|
-
* a history view. Mutations must use {@link getAssetSwapsOrThrow} instead —
|
|
68
|
-
* swallowing the read there would let "the backend is gone" masquerade as "no
|
|
69
|
-
* such swap" and skip the write silently. */
|
|
70
|
-
declare const getAssetSwaps: (repository: AssetSwapRepository) => Promise<AssetSwap[]>;
|
|
71
|
-
/** Add a swap; no-op if the id is already stored. Returns the updated list.
|
|
72
|
-
* THROWS on a failed write — nothing irreversible may happen until this record
|
|
73
|
-
* is durable, so the caller must not fund on a failure. */
|
|
74
|
-
declare const addAssetSwap: (repository: AssetSwapRepository, swap: AssetSwap) => Promise<AssetSwap[]>;
|
|
75
|
-
/** Merge changes into a swap by id. Returns the updated list.
|
|
76
|
-
* THROWS on a failed read or write, like {@link addAssetSwap} — use this for a
|
|
77
|
-
* write that gates something irreversible. Transitions written *after* the
|
|
78
|
-
* irreversible act belong on {@link updateAssetSwapBestEffort}. */
|
|
79
|
-
declare const updateAssetSwap: (repository: AssetSwapRepository, id: string, changes: Partial<Omit<AssetSwap, "id">>) => Promise<AssetSwap[]>;
|
|
80
|
-
/**
|
|
81
|
-
* {@link updateAssetSwap} for transitions that follow an irreversible action (a
|
|
82
|
-
* broadcast claim, a spent lockup): failing the caller there would report as
|
|
83
|
-
* failed a swap whose funds already moved, and a stale status is recoverable —
|
|
84
|
-
* crash recovery re-derives the true state from the chain
|
|
85
|
-
* (`classifyOnchainHtlc`).
|
|
86
|
-
*
|
|
87
|
-
* `persisted` is the part that must not be hidden: a caller that notifies on a
|
|
88
|
-
* change, or treats one as terminal, has to know the store did not agree.
|
|
89
|
-
*/
|
|
90
|
-
declare const updateAssetSwapBestEffort: (repository: AssetSwapRepository, id: string, changes: Partial<Omit<AssetSwap, "id">>) => Promise<{
|
|
91
|
-
swaps: AssetSwap[];
|
|
92
|
-
persisted: boolean;
|
|
93
|
-
}>;
|
|
94
|
-
|
|
95
|
-
/** A registry discovery result held for reuse. Refetchable — unlike a swap
|
|
96
|
-
* record, losing it costs one network round trip — but it must survive a cold
|
|
97
|
-
* boot: serving it stale is what keeps quoting alive while a registry is down. */
|
|
98
|
-
interface MarketsCacheEntry {
|
|
99
|
-
markets: DiscoveredMarket[];
|
|
100
|
-
fetchedAt: number;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Everything the package persists, following the monorepo repository
|
|
104
|
-
* convention (versioned interface, AsyncDisposable, one backend per
|
|
105
|
-
* platform — see the Boltz plugin's SwapRepository). Consumers construct
|
|
106
|
-
* exactly one of these; there is no second storage seam.
|
|
107
|
-
*
|
|
108
|
-
* Durable records (swaps) and rebuildable state (the restore scan's txid
|
|
109
|
-
* cursor, the markets cache) live side by side because they share a
|
|
110
|
-
* lifetime: all three belong to one wallet on one device, and a consumer
|
|
111
|
-
* that wipes one wants all three gone.
|
|
112
|
-
*
|
|
113
|
-
* ponytail: no query filters — every consumer reads all swaps and filters
|
|
114
|
-
* in memory; mirror the Boltz plugin's GetSwapsFilter when a consumer needs
|
|
115
|
-
* subset queries.
|
|
116
|
-
*/
|
|
117
|
-
interface AssetSwapRepository extends AsyncDisposable {
|
|
118
|
-
readonly version: 1;
|
|
119
|
-
/** Insert or replace a swap by id. Store the record whole: `fallbackSecrets`
|
|
120
|
-
* is secret-bearing, and a field-mapped backend that drops it loses the
|
|
121
|
-
* stored arm's claim and refund keys. */
|
|
122
|
-
saveSwap(swap: AssetSwap): Promise<void>;
|
|
123
|
-
/** All stored swaps, in no particular order — `getAssetSwaps` is the
|
|
124
|
-
* canonical newest-first read. */
|
|
125
|
-
getAllSwaps(): Promise<AssetSwap[]>;
|
|
126
|
-
/** Sent txids already checked for offer packets (see restore.ts). */
|
|
127
|
-
getScannedTxids(): Promise<Set<string>>;
|
|
128
|
-
markTxidsScanned(txids: Iterable<string>): Promise<void>;
|
|
129
|
-
/** Cached registry markets, or undefined on a miss. */
|
|
130
|
-
getCachedMarkets(network: string, registry: string): Promise<MarketsCacheEntry | undefined>;
|
|
131
|
-
saveCachedMarkets(network: string, registry: string, entry: MarketsCacheEntry): Promise<void>;
|
|
132
|
-
clear(): Promise<void>;
|
|
133
|
-
}
|
|
134
|
-
declare class InMemoryAssetSwapRepository implements AssetSwapRepository {
|
|
135
|
-
readonly version: 1;
|
|
136
|
-
private readonly swaps;
|
|
137
|
-
private readonly scanned;
|
|
138
|
-
private readonly markets;
|
|
139
|
-
saveSwap(swap: AssetSwap): Promise<void>;
|
|
140
|
-
getAllSwaps(): Promise<AssetSwap[]>;
|
|
141
|
-
getScannedTxids(): Promise<Set<string>>;
|
|
142
|
-
markTxidsScanned(txids: Iterable<string>): Promise<void>;
|
|
143
|
-
getCachedMarkets(network: string, registry: string): Promise<MarketsCacheEntry | undefined>;
|
|
144
|
-
saveCachedMarkets(network: string, registry: string, entry: MarketsCacheEntry): Promise<void>;
|
|
145
|
-
clear(): Promise<void>;
|
|
146
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
147
|
-
}
|
|
1
|
+
import { asset, VHTLC, IWallet, ProvisionedClaimSecret, ProvisionedKey } from '@arkade-os/sdk';
|
|
148
2
|
|
|
149
3
|
/** L1 confirmation-depth and reorg margin between dependent timelocks. */
|
|
150
4
|
declare const ONCHAIN_ORDER_MARGIN_SECONDS: number;
|
|
@@ -356,168 +210,6 @@ declare function classifyOnchainHtlc(chain: ChainSource, input: {
|
|
|
356
210
|
};
|
|
357
211
|
}): Promise<OnchainHtlcPhase>;
|
|
358
212
|
|
|
359
|
-
/**
|
|
360
|
-
* Domain separator for the preimage derivation.
|
|
361
|
-
*
|
|
362
|
-
* NArk scopes its tag by protocol+provider (`Arkade-Boltz-Preimage-v1`,
|
|
363
|
-
* `SwapsManagementService.cs:128`) so any Arkade SDK reproduces the same
|
|
364
|
-
* preimage. NArk has no RFQ corridor yet, so this tag defines the scheme
|
|
365
|
-
* rather than mirroring one; it is deliberately distinct from the Boltz tag,
|
|
366
|
-
* or the same wallet key would derive one preimage for both corridors.
|
|
367
|
-
*/
|
|
368
|
-
declare const RFQ_PREIMAGE_TAG = "Arkade-RFQ-Preimage-v1";
|
|
369
|
-
/**
|
|
370
|
-
* `TAG ‖ xonly(32) ‖ u32le(index)` — the message that gets BIP-340 signed.
|
|
371
|
-
*
|
|
372
|
-
* Anchored on the canonical x-only key rather than the descriptor string:
|
|
373
|
-
* restore reconstructs a bare descriptor that serialises differently from the
|
|
374
|
-
* signing descriptor used at create time, and only the key agrees across both.
|
|
375
|
-
*/
|
|
376
|
-
declare function buildPreimageMessage(xonly: Uint8Array, index: number): Uint8Array;
|
|
377
|
-
/** No secrets at rest: everything re-derives from the seed plus this. */
|
|
378
|
-
interface DerivedSwapSecrets {
|
|
379
|
-
derivable: true;
|
|
380
|
-
/** Public. Persist it on the swap record; it is what restore keys off. */
|
|
381
|
-
signingDescriptor: string;
|
|
382
|
-
/** Onchain-send only, when the caller supplied P instead of deriving it. */
|
|
383
|
-
preimage?: Uint8Array;
|
|
384
|
-
}
|
|
385
|
-
/** The wallet could not allocate. These are real secrets — persist them. */
|
|
386
|
-
interface StoredSwapSecrets {
|
|
387
|
-
derivable: false;
|
|
388
|
-
senderPrivateKey: Uint8Array;
|
|
389
|
-
/** Onchain-send only. A lightning send's preimage belongs to the payee. */
|
|
390
|
-
preimage?: Uint8Array;
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Which arm a swap got. The discriminant makes the persistence obligation a
|
|
394
|
-
* type-level fact: a consumer written against {@link DerivedSwapSecrets} alone
|
|
395
|
-
* fails to compile when handed the stored arm.
|
|
396
|
-
*/
|
|
397
|
-
type SwapSecrets = DerivedSwapSecrets | StoredSwapSecrets;
|
|
398
|
-
/**
|
|
399
|
-
* Allocate a descriptor for one swap, or `undefined` when the wallet cannot.
|
|
400
|
-
*
|
|
401
|
-
* Allocates — never peeks. `getCurrentSigningDescriptor` returns the same
|
|
402
|
-
* descriptor until the wallet rotates, and two swaps sharing a descriptor
|
|
403
|
-
* derive the *identical* preimage, so one solver learning its own preimage
|
|
404
|
-
* would learn the other swap's.
|
|
405
|
-
*
|
|
406
|
-
* Cost of allocating: the index is consumed even when the quote is later
|
|
407
|
-
* refused, and a swap index never turns into a funded receive contract, so a
|
|
408
|
-
* long run of swaps widens the "unused" gap a seed-only `restore()` scan sees
|
|
409
|
-
* (see the README's gap-limit note). Restores that keep the swap repository
|
|
410
|
-
* are unaffected — `adoptSwapDescriptor` re-claims each record's index.
|
|
411
|
-
*/
|
|
412
|
-
declare function deriveSwapSecrets(wallet: IWallet): Promise<DerivedSwapSecrets | undefined>;
|
|
413
|
-
/**
|
|
414
|
-
* The fallback arm. Separate from {@link deriveSwapSecrets} so nothing can
|
|
415
|
-
* fabricate a preimage while probing for a derived one.
|
|
416
|
-
*/
|
|
417
|
-
declare function randomSwapSecrets(opts?: {
|
|
418
|
-
preimage?: boolean | Uint8Array;
|
|
419
|
-
}): StoredSwapSecrets;
|
|
420
|
-
/**
|
|
421
|
-
* Serialize or restore the secrets arm a persisted record describes. Normal
|
|
422
|
-
* HD swaps store only `signingDescriptor`; caller-supplied preimages add
|
|
423
|
-
* `preimageHex`; fallback swaps use `fallbackSecrets` so both P and the
|
|
424
|
-
* sender identity survive a restart.
|
|
425
|
-
*/
|
|
426
|
-
declare function rfqSecretsToRecord(secrets: SwapSecrets): {
|
|
427
|
-
signingDescriptor?: string;
|
|
428
|
-
preimageHex?: string;
|
|
429
|
-
fallbackSecrets?: AssetSwapFallbackSecrets;
|
|
430
|
-
};
|
|
431
|
-
declare function rfqSecretsOfRecord(record: {
|
|
432
|
-
signingDescriptor?: string;
|
|
433
|
-
preimageHex?: string;
|
|
434
|
-
fallbackSecrets?: AssetSwapFallbackSecrets;
|
|
435
|
-
}): SwapSecrets | undefined;
|
|
436
|
-
/**
|
|
437
|
-
* Claim a restored swap's index so a later allocation cannot reissue it —
|
|
438
|
-
* which would derive that swap's preimage a second time, for a different swap.
|
|
439
|
-
* Monotonic; a no-op on a wallet that cannot allocate.
|
|
440
|
-
*/
|
|
441
|
-
declare function adoptSwapDescriptor(wallet: IWallet, signingDescriptor: string): Promise<void>;
|
|
442
|
-
/** Why a wallet cannot produce a swap's sender key. Different instructions to
|
|
443
|
-
* a user: restore the other wallet, or accept that this record never carried
|
|
444
|
-
* the secrets at all. */
|
|
445
|
-
type RefundBlockedReason =
|
|
446
|
-
/** The record names no arm: neither `signingDescriptor` nor `fallbackSecrets`. */
|
|
447
|
-
"no-secrets"
|
|
448
|
-
/** It names an arm this version cannot read. */
|
|
449
|
-
| "unreadable-secrets"
|
|
450
|
-
/** The descriptor belongs to another seed, or this wallet is static. */
|
|
451
|
-
| "foreign-descriptor";
|
|
452
|
-
/**
|
|
453
|
-
* The wallet cannot produce this swap's sender key, so no local refund is
|
|
454
|
-
* possible: not a failure to retry, a capability this wallet does not have.
|
|
455
|
-
*
|
|
456
|
-
* Thrown where the cause is discovered rather than translated at the edge, so
|
|
457
|
-
* a `refundArkade` wired through {@link senderIdentityForSwapRecord} reports it
|
|
458
|
-
* to `RfqSwapManager` unwrapped — which is what stops the manager grinding
|
|
459
|
-
* against a push that can never work for the whole refund window.
|
|
460
|
-
*/
|
|
461
|
-
declare class RefundNotLocallyPossibleError extends Error {
|
|
462
|
-
readonly reason: RefundBlockedReason;
|
|
463
|
-
readonly name = "RefundNotLocallyPossibleError";
|
|
464
|
-
constructor(reason: RefundBlockedReason, message: string, options?: {
|
|
465
|
-
cause?: unknown;
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* The VHTLC `sender` identity — the signer for every interactive refund.
|
|
470
|
-
*
|
|
471
|
-
* The capability probe is not the check that matters: `signerForDescriptor`
|
|
472
|
-
* falls back to the plain wallet identity for a descriptor it cannot derive —
|
|
473
|
-
* a different seed, a static wallet — and that identity signs happily with the
|
|
474
|
-
* wrong key, which surfaces only as a solver rejection or a dead claim script.
|
|
475
|
-
* So the check is on what comes back: only a descriptor-bound signer carries
|
|
476
|
-
* `signSchnorrDeterministic`.
|
|
477
|
-
*/
|
|
478
|
-
declare function senderIdentityForRfqSecrets(wallet: IWallet, secrets: SwapSecrets): Promise<Identity>;
|
|
479
|
-
/**
|
|
480
|
-
* The VHTLC `sender` identity for a stored swap record, or a typed refusal.
|
|
481
|
-
*
|
|
482
|
-
* The record→identity composition {@link rfqSecretsOfRecord} deliberately does
|
|
483
|
-
* not do: it stays total so history iteration can call it, so *this* is where
|
|
484
|
-
* "no secrets on the record" becomes a refusal rather than an `undefined` the
|
|
485
|
-
* caller has to remember to check.
|
|
486
|
-
*
|
|
487
|
-
* **Wire `refundArkade` here, not to {@link senderIdentityForRfqSecrets}.**
|
|
488
|
-
* Only two of the three causes are throws; a caller one level down would skip
|
|
489
|
-
* the third silently and turn it into a `TypeError` at the push site, which
|
|
490
|
-
* `RfqSwapManager` then treats as retryable and grinds against for the whole
|
|
491
|
-
* refund window.
|
|
492
|
-
*
|
|
493
|
-
* Takes the record shape structurally, matching {@link rfqSecretsOfRecord}, so
|
|
494
|
-
* either record type can be passed.
|
|
495
|
-
*/
|
|
496
|
-
declare function senderIdentityForSwapRecord(wallet: IWallet, record: {
|
|
497
|
-
signingDescriptor?: string;
|
|
498
|
-
preimageHex?: string;
|
|
499
|
-
fallbackSecrets?: AssetSwapFallbackSecrets;
|
|
500
|
-
}): Promise<Identity>;
|
|
501
|
-
/** The `sender` x-only pubkey, the only half the request flow needs. */
|
|
502
|
-
declare function senderPubkeyForRfqSecrets(wallet: IWallet, secrets: SwapSecrets): Promise<Uint8Array>;
|
|
503
|
-
/**
|
|
504
|
-
* An identity that signs with `aux_rand = 0`, which is what makes the
|
|
505
|
-
* derivation reproducible. `DescriptorIdentity` satisfies it and throws rather
|
|
506
|
-
* than degrading to a random-aux signer.
|
|
507
|
-
*/
|
|
508
|
-
interface DeterministicSigner extends ReadonlyIdentity {
|
|
509
|
-
signSchnorrDeterministic(messageHash: Uint8Array): Promise<Uint8Array>;
|
|
510
|
-
}
|
|
511
|
-
declare function isDeterministicSigner(value: unknown): value is DeterministicSigner;
|
|
512
|
-
/**
|
|
513
|
-
* `sha256(sign(sha256(msg)))`, with the signing key and the message key being
|
|
514
|
-
* the same identity — passing a key in separately is how this silently derives
|
|
515
|
-
* an unrecoverable preimage.
|
|
516
|
-
*/
|
|
517
|
-
declare function derivePreimage(signer: DeterministicSigner): Promise<Uint8Array>;
|
|
518
|
-
/** The onchain-send preimage, re-derived or read back off the stored arm. */
|
|
519
|
-
declare function preimageForRfqSecrets(wallet: IWallet, secrets: SwapSecrets): Promise<Uint8Array>;
|
|
520
|
-
|
|
521
213
|
/** Legs are `<corridor>:<asset>`; a pair is directional, `from->to`. Arkade
|
|
522
214
|
* asset legs stay coarse (`arkade:ASSET`) — the exact asset ids ride the
|
|
523
215
|
* request profile, mirroring how the offer TLV identifies assets. */
|
|
@@ -706,10 +398,7 @@ declare function lightningSendVtxoScript(params: {
|
|
|
706
398
|
* {@link unilateralRefundDelay} and {@link unilateralRefundWithoutReceiverDelay}
|
|
707
399
|
* derive from this same value — one rounding, shared across all three tiers. */
|
|
708
400
|
claimDelay: number;
|
|
709
|
-
/** Emulator x-only key
|
|
710
|
-
* Not fetched here or anywhere in this package; see {@link
|
|
711
|
-
* requestLightningSend}'s `emulatorPubkey` parameter for where it comes
|
|
712
|
-
* from and why. */
|
|
401
|
+
/** Emulator x-only key (32 bytes). */
|
|
713
402
|
emulatorPubkey: Uint8Array;
|
|
714
403
|
/** Where a refund must pay: the trader's P2TR pkScript (34 bytes). Also
|
|
715
404
|
* `nonInteractiveRefund`'s covenant destination. */
|
|
@@ -757,29 +446,20 @@ interface InvoiceFacts {
|
|
|
757
446
|
* throws while nothing is funded. `RfqSwapManager` re-registers as a backstop
|
|
758
447
|
* for older records; a repeat write is a no-op.
|
|
759
448
|
*
|
|
760
|
-
*
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
*
|
|
766
|
-
*
|
|
449
|
+
* The `sender` key comes from the wallet — a fresh HD descriptor per call, or
|
|
450
|
+
* the wallet's static key — and is returned as `senderPubkey` plus `secrets`.
|
|
451
|
+
* `secrets` holds only a public descriptor; the signer re-derives from the
|
|
452
|
+
* wallet, so nothing secret is at rest. Persist `secrets` with the record
|
|
453
|
+
* anyway: it is how the refund signer is found again. `nonInteractiveRefund`
|
|
454
|
+
* recovers the funds even without it — but it needs the SOLVER's active
|
|
455
|
+
* cooperation, not just infrastructure uptime.
|
|
767
456
|
*/
|
|
768
|
-
declare function requestLightningSend(wallet: IWallet, arkServerUrl: string,
|
|
769
|
-
/** Covenant co-signer (emulator) x-only key — the SOLVER's deployment,
|
|
770
|
-
* not the trader's. This library does NOT fetch or verify it: clients
|
|
771
|
-
* have no network path to the emulator, only the solver and covclaimd
|
|
772
|
-
* do. The caller must obtain this out-of-band, before calling this
|
|
773
|
-
* function, from the solver's signed registry/corridor card (its
|
|
774
|
-
* `emulator_pubkey`, added in arkade-os/solver-registry#18) or an
|
|
775
|
-
* equivalent source it
|
|
776
|
-
* independently trusts, and is responsible for having checked it against
|
|
777
|
-
* that trusted value itself — the same never-trust-only-compare rule as
|
|
778
|
-
* {@link verifyLockupAddress}, just applied by the caller instead of
|
|
779
|
-
* here, because there is nothing in this module to derive it against. */
|
|
780
|
-
emulatorPubkey: Uint8Array, transport: RfqTransport, params: {
|
|
457
|
+
declare function requestLightningSend(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
|
|
781
458
|
invoice: InvoiceFacts;
|
|
782
459
|
rfqId?: string;
|
|
460
|
+
/** Co-signer key override (33-byte compressed hex); see
|
|
461
|
+
* {@link resolveEmulatorPubkey}. */
|
|
462
|
+
emulatorPubkey?: string;
|
|
783
463
|
}): Promise<{
|
|
784
464
|
rfqId: string;
|
|
785
465
|
quote: RfqQuote;
|
|
@@ -798,9 +478,9 @@ emulatorPubkey: Uint8Array, transport: RfqTransport, params: {
|
|
|
798
478
|
refundAddress: string;
|
|
799
479
|
/** The VHTLC `sender` x-only key, bound into the covenant. Public. */
|
|
800
480
|
senderPubkey: Uint8Array;
|
|
801
|
-
/** How the `sender` key is recovered later. Persist it with the record
|
|
802
|
-
*
|
|
803
|
-
secrets:
|
|
481
|
+
/** How the `sender` key is recovered later. Persist it with the record;
|
|
482
|
+
* it holds nothing secret. */
|
|
483
|
+
secrets: ProvisionedKey;
|
|
804
484
|
}>;
|
|
805
485
|
/**
|
|
806
486
|
* Map an arkade↔arkade quote onto `createOffer` terms. The trader takes the
|
|
@@ -925,10 +605,7 @@ declare function deriveOnchainSend(input: {
|
|
|
925
605
|
* `claimOnchainFill`) before `htlc.refundLocktime`. Missing that window
|
|
926
606
|
* forfeits the fill and falls back to the Arkade covenant refund.
|
|
927
607
|
*/
|
|
928
|
-
declare function requestOnchainSend(wallet: IWallet, arkServerUrl: string,
|
|
929
|
-
/** Covenant co-signer (emulator) x-only key — same parameter, same
|
|
930
|
-
* caller obligation, as {@link requestLightningSend}'s. */
|
|
931
|
-
emulatorPubkey: Uint8Array, transport: RfqTransport, params: {
|
|
608
|
+
declare function requestOnchainSend(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
|
|
932
609
|
amount: number;
|
|
933
610
|
amountSide: "from" | "to";
|
|
934
611
|
/** User's x-only L1 key that will claim the HTLC. */
|
|
@@ -936,6 +613,9 @@ emulatorPubkey: Uint8Array, transport: RfqTransport, params: {
|
|
|
936
613
|
/** Optional caller-owned P. Persist it with the returned secrets before funding. */
|
|
937
614
|
preimage?: Uint8Array;
|
|
938
615
|
rfqId?: string;
|
|
616
|
+
/** Co-signer key override (33-byte compressed hex); see
|
|
617
|
+
* {@link resolveEmulatorPubkey}. */
|
|
618
|
+
emulatorPubkey?: string;
|
|
939
619
|
}): Promise<{
|
|
940
620
|
rfqId: string;
|
|
941
621
|
quote: RfqQuote;
|
|
@@ -953,7 +633,7 @@ emulatorPubkey: Uint8Array, transport: RfqTransport, params: {
|
|
|
953
633
|
senderPubkey: Uint8Array;
|
|
954
634
|
/** How the preimage and the `sender` key are recovered later. Persist it
|
|
955
635
|
* with the record BEFORE funding. */
|
|
956
|
-
secrets:
|
|
636
|
+
secrets: ProvisionedClaimSecret;
|
|
957
637
|
}>;
|
|
958
638
|
/** Default floor for the window between the last moment the hold invoice can
|
|
959
639
|
* be paid and the solver's refund leaf opening. */
|
|
@@ -1101,12 +781,12 @@ declare function deriveLightningReceive(input: {
|
|
|
1101
781
|
* Pay before `invoiceExpiresAt`: the hold-invoice window is minutes, not the
|
|
1102
782
|
* quote's `valid_until`.
|
|
1103
783
|
*/
|
|
1104
|
-
declare function requestLightningReceive(wallet: IWallet, arkServerUrl: string,
|
|
1105
|
-
/** Covenant co-signer (emulator) x-only key — same parameter, same
|
|
1106
|
-
* caller obligation, as {@link requestLightningSend}'s. */
|
|
1107
|
-
emulatorPubkey: Uint8Array, transport: RfqTransport, params: {
|
|
784
|
+
declare function requestLightningReceive(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
|
|
1108
785
|
amount: number;
|
|
1109
786
|
amountSide: "from" | "to";
|
|
787
|
+
/** Co-signer key override (33-byte compressed hex); see
|
|
788
|
+
* {@link resolveEmulatorPubkey}. */
|
|
789
|
+
emulatorPubkey?: string;
|
|
1110
790
|
/** covclaimd's 33-byte compressed pubkey (from its own info endpoint)
|
|
1111
791
|
* — the claim packet seals to it and only it can ever read `P` early. */
|
|
1112
792
|
covclaimdPubkey: Uint8Array;
|
|
@@ -1142,7 +822,7 @@ emulatorPubkey: Uint8Array, transport: RfqTransport, params: {
|
|
|
1142
822
|
payoutPubkey: Uint8Array;
|
|
1143
823
|
/** How the preimage and the payout key are recovered later. Persist it
|
|
1144
824
|
* with the record BEFORE paying the invoice. */
|
|
1145
|
-
secrets:
|
|
825
|
+
secrets: ProvisionedClaimSecret;
|
|
1146
826
|
}>;
|
|
1147
827
|
/**
|
|
1148
828
|
* The pure core of {@link requestOnchainReceive}: derive BOTH contracts
|
|
@@ -1186,12 +866,12 @@ declare function deriveOnchainReceive(input: {
|
|
|
1186
866
|
* `refundPubkey`) opens at `htlc.refundLocktime` — `buildHtlcRefund` takes it
|
|
1187
867
|
* back from there.
|
|
1188
868
|
*/
|
|
1189
|
-
declare function requestOnchainReceive(wallet: IWallet, arkServerUrl: string,
|
|
1190
|
-
/** Covenant co-signer (emulator) x-only key — same parameter, same
|
|
1191
|
-
* caller obligation, as {@link requestLightningSend}'s. */
|
|
1192
|
-
emulatorPubkey: Uint8Array, transport: RfqTransport, params: {
|
|
869
|
+
declare function requestOnchainReceive(wallet: IWallet, arkServerUrl: string, transport: RfqTransport, params: {
|
|
1193
870
|
amount: number;
|
|
1194
871
|
amountSide: "from" | "to";
|
|
872
|
+
/** Co-signer key override (33-byte compressed hex); see
|
|
873
|
+
* {@link resolveEmulatorPubkey}. */
|
|
874
|
+
emulatorPubkey?: string;
|
|
1195
875
|
/** Trader's x-only L1 key for the HTLC's refund leaf. */
|
|
1196
876
|
refundPubkey: Uint8Array;
|
|
1197
877
|
/** covclaimd's 33-byte compressed pubkey — see {@link requestLightningReceive}. */
|
|
@@ -1213,7 +893,7 @@ emulatorPubkey: Uint8Array, transport: RfqTransport, params: {
|
|
|
1213
893
|
htlc: OnchainHtlc;
|
|
1214
894
|
payoutAddress: string;
|
|
1215
895
|
payoutPubkey: Uint8Array;
|
|
1216
|
-
secrets:
|
|
896
|
+
secrets: ProvisionedClaimSecret;
|
|
1217
897
|
}>;
|
|
1218
898
|
|
|
1219
|
-
export {
|
|
899
|
+
export { paymentHashOf as $, ARKADE_ASSET as A, buildHtlcClaim as B, type ChainSource as C, buildHtlcRefund as D, claimOnchainFill as E, classifyOnchainHtlc as F, deriveLightningReceive as G, type HtlcUtxo as H, type InvoiceFacts as I, deriveOnchainReceive as J, deriveOnchainSend as K, LIGHTNING_BTC as L, MAX_MIN_CONFIRMATIONS as M, extractPreimage as N, type OnchainHtlc as O, httpTransport as P, lightningReceiveRequest as Q, type RfqStatus as R, SwapRefusal as S, lightningSendRequest as T, lightningSendVtxoScript as U, newPreimage as V, newRfqId as W, offerTermsFromQuote as X, onchainHtlcScript as Y, onchainReceiveRequest as Z, onchainSendRequest as _, type RfqTransport as a, receiveVtxoScript as a0, relayTransport as a1, requestLightningReceive as a2, requestLightningSend as a3, requestOnchainReceive as a4, requestOnchainSend as a5, rfqPair as a6, unilateralClaimDelay as a7, unilateralRefundDelay as a8, unilateralRefundWithoutReceiverDelay as a9, verifyLockupAddress as aa, verifyReceiveInvoice as ab, type ChainUtxo as b, type OnchainHtlcPhase as c, ARKADE_BTC as d, AddressMismatch as e, LIGHTNING_RECEIVE_PAIR as f, LIGHTNING_SEND_PAIR as g, MIN_CLAIM_WINDOW_SECONDS as h, MIN_HEADROOM_SECONDS as i, ONCHAIN_BTC as j, ONCHAIN_CLAIM_MARGIN_SECONDS as k, ONCHAIN_DUST_SATS as l, ONCHAIN_ORDER_MARGIN_SECONDS as m, ONCHAIN_RECEIVE_PAIR as n, ONCHAIN_SECONDS_PER_BLOCK as o, ONCHAIN_SEND_PAIR as p, type OnchainHtlcParams as q, type OnchainNetwork as r, RFQ_TERMINAL_STATES as s, type RelaySocket as t, type RfqQuote as u, type RfqRefusalReason as v, arkadeSwapRequest as w, assertFundable as x, assertReceivable as y, awaitOnchainFill as z };
|