@arkade-os/boltz-swap 0.3.32 → 0.3.34
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 +22 -26
- package/dist/{arkade-swaps-CS8FZSVL.d.cts → arkade-swaps-BXAD1s8j.d.ts} +69 -8
- package/dist/{arkade-swaps-WiKCanCL.d.ts → arkade-swaps-CfMets16.d.cts} +69 -8
- package/dist/{chunk-NHBWNN6H.js → chunk-5K2FS2FE.js} +8 -27
- package/dist/chunk-SJQJQO7P.js +25 -0
- package/dist/{chunk-B3Q4TFWT.js → chunk-TDBUZE4N.js} +817 -866
- package/dist/expo/background.cjs +840 -892
- package/dist/expo/background.d.cts +3 -3
- package/dist/expo/background.d.ts +3 -3
- package/dist/expo/background.js +9 -20
- package/dist/expo/index.cjs +840 -870
- package/dist/expo/index.d.cts +8 -6
- package/dist/expo/index.d.ts +8 -6
- package/dist/expo/index.js +17 -20
- package/dist/index.cjs +1034 -1022
- package/dist/index.d.cts +95 -11
- package/dist/index.d.ts +95 -11
- package/dist/index.js +164 -119
- package/dist/repositories/realm/index.cjs +10 -22
- package/dist/repositories/realm/index.d.cts +7 -5
- package/dist/repositories/realm/index.d.ts +7 -5
- package/dist/repositories/realm/index.js +8 -22
- package/dist/repositories/sqlite/index.cjs +12 -23
- package/dist/repositories/sqlite/index.d.cts +1 -1
- package/dist/repositories/sqlite/index.d.ts +1 -1
- package/dist/repositories/sqlite/index.js +10 -23
- package/dist/{swapsPollProcessor-BF3uTFae.d.cts → swapsPollProcessor-BpAqG0V6.d.cts} +3 -3
- package/dist/{swapsPollProcessor-wYOMzldd.d.ts → swapsPollProcessor-DFVOAy_-.d.ts} +3 -3
- package/dist/{types-BBI7-KJ0.d.cts → types--axEWA8c.d.cts} +42 -4
- package/dist/{types-BBI7-KJ0.d.ts → types--axEWA8c.d.ts} +42 -4
- package/package.json +10 -25
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-
|
|
2
|
-
export { A as ArkadeSwaps } from './arkade-swaps-
|
|
3
|
-
import { B as BoltzSwap, D as DecodedInvoice, a as BoltzChainSwap, b as BoltzReverseSwap, c as BoltzSubmarineSwap, A as ArkadeSwapsConfig, N as Network, C as CreateLightningInvoiceRequest, S as SendLightningPaymentRequest, F as FeesResponse, d as Chain, e as CreateLightningInvoiceResponse, f as SendLightningPaymentResponse, g as SubmarineRefundOutcome, h as SubmarineRecoveryInfo, i as SubmarineRecoveryResult, j as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, k as ArkToBtcResponse, l as BtcToArkResponse, m as
|
|
4
|
-
export {
|
|
1
|
+
import { Q as QuoteSwapOptions, I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-CfMets16.cjs';
|
|
2
|
+
export { A as ArkadeSwaps } from './arkade-swaps-CfMets16.cjs';
|
|
3
|
+
import { B as BoltzSwap, D as DecodedInvoice, a as BoltzChainSwap, b as BoltzReverseSwap, c as BoltzSubmarineSwap, A as ArkadeSwapsConfig, N as Network, C as CreateLightningInvoiceRequest, S as SendLightningPaymentRequest, F as FeesResponse, d as Chain, e as CreateLightningInvoiceResponse, f as SendLightningPaymentResponse, g as SubmarineRefundOutcome, h as SubmarineRecoveryInfo, i as SubmarineRecoveryResult, j as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, k as ArkToBtcResponse, l as BtcToArkResponse, m as ChainArkRefundOutcome, n as SwapRepository, o as SwapManagerClient, p as GetSwapsFilter } from './types--axEWA8c.cjs';
|
|
4
|
+
export { q as ArkadeSwapsCreateConfig, r as BoltzSwapProvider, s as BoltzSwapStatus, I as IncomingPaymentSubscription, P as PendingChainSwap, t as PendingReverseSwap, u as PendingSubmarineSwap, v as PendingSwap, w as SubmarineRecoveryStatus, x as SwapManager, y as SwapManagerCallbacks, z as SwapManagerConfig, E as SwapManagerEvents, V as Vtxo, H as isChainClaimableStatus, J as isChainFailedStatus, K as isChainFinalStatus, M as isChainPendingStatus, O as isChainRefundableStatus, Q as isChainSignableStatus, R as isChainSuccessStatus, T as isChainSwapClaimable, U as isChainSwapRefundable, W as isPendingChainSwap, X as isPendingReverseSwap, Y as isPendingSubmarineSwap, Z as isReverseClaimableStatus, _ as isReverseFailedStatus, $ as isReverseFinalStatus, a0 as isReversePendingStatus, a1 as isReverseSuccessStatus, a2 as isReverseSwapClaimable, a3 as isSubmarineFailedStatus, a4 as isSubmarineFinalStatus, a5 as isSubmarinePendingStatus, a6 as isSubmarineRefundableStatus, a7 as isSubmarineSuccessStatus, a8 as isSubmarineSwapRefundable } from './types--axEWA8c.cjs';
|
|
5
5
|
import { Transaction } from '@scure/btc-signer';
|
|
6
6
|
import { MessageHandler, RequestEnvelope, ArkInfo, ResponseEnvelope, IWallet, IReadonlyWallet, VHTLC, Identity, ArkTxInput } from '@arkade-os/sdk';
|
|
7
7
|
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
|
@@ -16,6 +16,12 @@ interface ErrorOptions {
|
|
|
16
16
|
isRefundable?: boolean;
|
|
17
17
|
/** The associated pending swap, if available. */
|
|
18
18
|
pendingSwap?: BoltzSwap;
|
|
19
|
+
/**
|
|
20
|
+
* Underlying cause. Preserved on the resulting `Error.cause`, so callers
|
|
21
|
+
* that wrap a typed error (e.g. autopilot wrapping `QuoteRejectedError`)
|
|
22
|
+
* can still recover the inner instance for programmatic branching.
|
|
23
|
+
*/
|
|
24
|
+
cause?: unknown;
|
|
19
25
|
}
|
|
20
26
|
/**
|
|
21
27
|
* Base error class for all swap-related errors.
|
|
@@ -86,6 +92,46 @@ declare class TransactionFailedError extends SwapError {
|
|
|
86
92
|
declare class PreimageFetchError extends SwapError {
|
|
87
93
|
constructor(options?: ErrorOptions);
|
|
88
94
|
}
|
|
95
|
+
/** Reason a `quoteSwap` was rejected before being posted to Boltz. */
|
|
96
|
+
type QuoteRejectionReason = "below_floor" | "non_positive" | "non_safe_integer" | "no_baseline";
|
|
97
|
+
type QuoteRejectedOptions = ErrorOptions & ({
|
|
98
|
+
reason: "below_floor";
|
|
99
|
+
quotedAmount: number;
|
|
100
|
+
floor: number;
|
|
101
|
+
} | {
|
|
102
|
+
reason: "non_positive";
|
|
103
|
+
quotedAmount: number;
|
|
104
|
+
} | {
|
|
105
|
+
reason: "non_safe_integer";
|
|
106
|
+
quotedAmount: number;
|
|
107
|
+
} | {
|
|
108
|
+
reason: "no_baseline";
|
|
109
|
+
});
|
|
110
|
+
/**
|
|
111
|
+
* Thrown when a Boltz-returned chain-swap quote fails local validation
|
|
112
|
+
* (below the acceptable floor, non-positive, or missing a baseline to
|
|
113
|
+
* compare against). The acceptance is never posted on failure.
|
|
114
|
+
*/
|
|
115
|
+
declare class QuoteRejectedError extends SwapError {
|
|
116
|
+
readonly reason: QuoteRejectionReason;
|
|
117
|
+
readonly quotedAmount?: number;
|
|
118
|
+
readonly floor?: number;
|
|
119
|
+
constructor(options: QuoteRejectedOptions);
|
|
120
|
+
private static defaultMessage;
|
|
121
|
+
/**
|
|
122
|
+
* Serialize into a plain `Error` whose `.message` carries the full
|
|
123
|
+
* rejection payload as JSON behind a marker prefix. Structured clone
|
|
124
|
+
* (used by `postMessage` between page and service worker) preserves
|
|
125
|
+
* `Error.message` reliably but strips custom `.name` and own properties,
|
|
126
|
+
* so we move the typed data into the message field for transport.
|
|
127
|
+
*/
|
|
128
|
+
toTransportError(): Error;
|
|
129
|
+
/**
|
|
130
|
+
* Inverse of `toTransportError`. Returns a real `QuoteRejectedError` if
|
|
131
|
+
* `error` carries the transport prefix, else `null`.
|
|
132
|
+
*/
|
|
133
|
+
static fromTransportError(error: unknown): QuoteRejectedError | null;
|
|
134
|
+
}
|
|
89
135
|
/**
|
|
90
136
|
* Thrown when the Boltz API rejects a refund request
|
|
91
137
|
* (e.g. outpoint mismatch after an Ark round).
|
|
@@ -453,6 +499,7 @@ type RequestRefundArk = RequestEnvelope & {
|
|
|
453
499
|
};
|
|
454
500
|
type ResponseRefundArk = ResponseEnvelope & {
|
|
455
501
|
type: "ARK_REFUND_EXECUTED";
|
|
502
|
+
payload: ChainArkRefundOutcome;
|
|
456
503
|
};
|
|
457
504
|
type RequestSignServerClaim = RequestEnvelope & {
|
|
458
505
|
type: "SIGN_SERVER_CLAIM";
|
|
@@ -480,6 +527,7 @@ type RequestQuoteSwap = RequestEnvelope & {
|
|
|
480
527
|
type: "QUOTE_SWAP";
|
|
481
528
|
payload: {
|
|
482
529
|
swapId: string;
|
|
530
|
+
options?: QuoteSwapOptions;
|
|
483
531
|
};
|
|
484
532
|
};
|
|
485
533
|
type ResponseQuoteSwap = ResponseEnvelope & {
|
|
@@ -488,6 +536,32 @@ type ResponseQuoteSwap = ResponseEnvelope & {
|
|
|
488
536
|
amount: number;
|
|
489
537
|
};
|
|
490
538
|
};
|
|
539
|
+
type RequestGetSwapQuote = RequestEnvelope & {
|
|
540
|
+
type: "GET_SWAP_QUOTE";
|
|
541
|
+
payload: {
|
|
542
|
+
swapId: string;
|
|
543
|
+
};
|
|
544
|
+
};
|
|
545
|
+
type ResponseGetSwapQuote = ResponseEnvelope & {
|
|
546
|
+
type: "SWAP_QUOTE_RETRIEVED";
|
|
547
|
+
payload: {
|
|
548
|
+
amount: number;
|
|
549
|
+
};
|
|
550
|
+
};
|
|
551
|
+
type RequestAcceptSwapQuote = RequestEnvelope & {
|
|
552
|
+
type: "ACCEPT_SWAP_QUOTE";
|
|
553
|
+
payload: {
|
|
554
|
+
swapId: string;
|
|
555
|
+
amount: number;
|
|
556
|
+
options?: QuoteSwapOptions;
|
|
557
|
+
};
|
|
558
|
+
};
|
|
559
|
+
type ResponseAcceptSwapQuote = ResponseEnvelope & {
|
|
560
|
+
type: "SWAP_QUOTE_ACCEPTED";
|
|
561
|
+
payload: {
|
|
562
|
+
amount: number;
|
|
563
|
+
};
|
|
564
|
+
};
|
|
491
565
|
type RequestSwapManagerStart = RequestEnvelope & {
|
|
492
566
|
type: "SM-START";
|
|
493
567
|
};
|
|
@@ -573,8 +647,8 @@ type ResponseSwapManagerWaitForCompletion = ResponseEnvelope & {
|
|
|
573
647
|
txid: string;
|
|
574
648
|
};
|
|
575
649
|
};
|
|
576
|
-
type ArkadeSwapsUpdaterRequest = RequestInitArkSwaps | RequestCreateLightningInvoice | RequestSendLightningPayment | RequestCreateSubmarineSwap | RequestCreateReverseSwap | RequestClaimVhtlc | RequestRefundVhtlc | RequestInspectSubmarineRecovery | RequestScanRecoverableSubmarineSwaps | RequestRecoverSubmarineFunds | RequestRecoverAllSubmarineFunds | RequestWaitAndClaim | RequestWaitForSwapSettlement | RequestRestoreSwaps | RequestEnrichReverseSwapPreimage | RequestEnrichSubmarineSwapInvoice | RequestGetFees | RequestGetLimits | RequestGetSwapStatus | RequestGetPendingSubmarineSwaps | RequestGetPendingReverseSwaps | RequestGetPendingChainSwaps | RequestGetSwapHistory | RequestRefreshSwapsStatus | RequestArkToBtc | RequestBtcToArk | RequestCreateChainSwap | RequestWaitAndClaimChain | RequestWaitAndClaimArk | RequestWaitAndClaimBtc | RequestClaimArk | RequestClaimBtc | RequestRefundArk | RequestSignServerClaim | RequestVerifyChainSwap | RequestQuoteSwap | RequestSwapManagerStart | RequestSwapManagerStop | RequestSwapManagerAddSwap | RequestSwapManagerRemoveSwap | RequestSwapManagerGetPending | RequestSwapManagerHasSwap | RequestSwapManagerIsProcessing | RequestSwapManagerGetStats | RequestSwapManagerWaitForCompletion;
|
|
577
|
-
type ArkadeSwapsUpdaterResponse = ResponseInitArkSwaps | ResponseCreateLightningInvoice | ResponseSendLightningPayment | ResponseCreateSubmarineSwap | ResponseCreateReverseSwap | ResponseClaimVhtlc | ResponseRefundVhtlc | ResponseInspectSubmarineRecovery | ResponseScanRecoverableSubmarineSwaps | ResponseRecoverSubmarineFunds | ResponseRecoverAllSubmarineFunds | ResponseWaitAndClaim | ResponseWaitForSwapSettlement | ResponseRestoreSwaps | ResponseEnrichReverseSwapPreimage | ResponseEnrichSubmarineSwapInvoice | ResponseGetFees | ResponseGetLimits | ResponseGetSwapStatus | ResponseGetPendingSubmarineSwaps | ResponseGetPendingReverseSwaps | ResponseGetPendingChainSwaps | ResponseGetSwapHistory | ResponseRefreshSwapsStatus | ResponseArkToBtc | ResponseBtcToArk | ResponseCreateChainSwap | ResponseWaitAndClaimChain | ResponseWaitAndClaimArk | ResponseWaitAndClaimBtc | ResponseClaimArk | ResponseClaimBtc | ResponseRefundArk | ResponseSignServerClaim | ResponseVerifyChainSwap | ResponseQuoteSwap | ResponseSwapManagerStart | ResponseSwapManagerStop | ResponseSwapManagerAddSwap | ResponseSwapManagerRemoveSwap | ResponseSwapManagerGetPending | ResponseSwapManagerHasSwap | ResponseSwapManagerIsProcessing | ResponseSwapManagerGetStats | ResponseSwapManagerWaitForCompletion;
|
|
650
|
+
type ArkadeSwapsUpdaterRequest = RequestInitArkSwaps | RequestCreateLightningInvoice | RequestSendLightningPayment | RequestCreateSubmarineSwap | RequestCreateReverseSwap | RequestClaimVhtlc | RequestRefundVhtlc | RequestInspectSubmarineRecovery | RequestScanRecoverableSubmarineSwaps | RequestRecoverSubmarineFunds | RequestRecoverAllSubmarineFunds | RequestWaitAndClaim | RequestWaitForSwapSettlement | RequestRestoreSwaps | RequestEnrichReverseSwapPreimage | RequestEnrichSubmarineSwapInvoice | RequestGetFees | RequestGetLimits | RequestGetSwapStatus | RequestGetPendingSubmarineSwaps | RequestGetPendingReverseSwaps | RequestGetPendingChainSwaps | RequestGetSwapHistory | RequestRefreshSwapsStatus | RequestArkToBtc | RequestBtcToArk | RequestCreateChainSwap | RequestWaitAndClaimChain | RequestWaitAndClaimArk | RequestWaitAndClaimBtc | RequestClaimArk | RequestClaimBtc | RequestRefundArk | RequestSignServerClaim | RequestVerifyChainSwap | RequestQuoteSwap | RequestGetSwapQuote | RequestAcceptSwapQuote | RequestSwapManagerStart | RequestSwapManagerStop | RequestSwapManagerAddSwap | RequestSwapManagerRemoveSwap | RequestSwapManagerGetPending | RequestSwapManagerHasSwap | RequestSwapManagerIsProcessing | RequestSwapManagerGetStats | RequestSwapManagerWaitForCompletion;
|
|
651
|
+
type ArkadeSwapsUpdaterResponse = ResponseInitArkSwaps | ResponseCreateLightningInvoice | ResponseSendLightningPayment | ResponseCreateSubmarineSwap | ResponseCreateReverseSwap | ResponseClaimVhtlc | ResponseRefundVhtlc | ResponseInspectSubmarineRecovery | ResponseScanRecoverableSubmarineSwaps | ResponseRecoverSubmarineFunds | ResponseRecoverAllSubmarineFunds | ResponseWaitAndClaim | ResponseWaitForSwapSettlement | ResponseRestoreSwaps | ResponseEnrichReverseSwapPreimage | ResponseEnrichSubmarineSwapInvoice | ResponseGetFees | ResponseGetLimits | ResponseGetSwapStatus | ResponseGetPendingSubmarineSwaps | ResponseGetPendingReverseSwaps | ResponseGetPendingChainSwaps | ResponseGetSwapHistory | ResponseRefreshSwapsStatus | ResponseArkToBtc | ResponseBtcToArk | ResponseCreateChainSwap | ResponseWaitAndClaimChain | ResponseWaitAndClaimArk | ResponseWaitAndClaimBtc | ResponseClaimArk | ResponseClaimBtc | ResponseRefundArk | ResponseSignServerClaim | ResponseVerifyChainSwap | ResponseQuoteSwap | ResponseGetSwapQuote | ResponseAcceptSwapQuote | ResponseSwapManagerStart | ResponseSwapManagerStop | ResponseSwapManagerAddSwap | ResponseSwapManagerRemoveSwap | ResponseSwapManagerGetPending | ResponseSwapManagerHasSwap | ResponseSwapManagerIsProcessing | ResponseSwapManagerGetStats | ResponseSwapManagerWaitForCompletion;
|
|
578
652
|
declare class ArkadeSwapsMessageHandler implements MessageHandler<ArkadeSwapsUpdaterRequest, ArkadeSwapsUpdaterResponse> {
|
|
579
653
|
private readonly swapRepository;
|
|
580
654
|
static messageTag: string;
|
|
@@ -679,7 +753,7 @@ declare class ServiceWorkerArkadeSwaps implements IArkadeSwaps {
|
|
|
679
753
|
}>;
|
|
680
754
|
claimArk(pendingSwap: BoltzChainSwap): Promise<void>;
|
|
681
755
|
claimBtc(pendingSwap: BoltzChainSwap): Promise<void>;
|
|
682
|
-
refundArk(pendingSwap: BoltzChainSwap): Promise<
|
|
756
|
+
refundArk(pendingSwap: BoltzChainSwap): Promise<ChainArkRefundOutcome>;
|
|
683
757
|
signCooperativeClaimForServer(pendingSwap: BoltzChainSwap): Promise<void>;
|
|
684
758
|
verifyChainSwap(args: {
|
|
685
759
|
to: Chain;
|
|
@@ -687,7 +761,9 @@ declare class ServiceWorkerArkadeSwaps implements IArkadeSwaps {
|
|
|
687
761
|
swap: BoltzChainSwap;
|
|
688
762
|
arkInfo: ArkInfo;
|
|
689
763
|
}): Promise<boolean>;
|
|
690
|
-
quoteSwap(swapId: string): Promise<number>;
|
|
764
|
+
quoteSwap(swapId: string, options?: QuoteSwapOptions): Promise<number>;
|
|
765
|
+
getSwapQuote(swapId: string): Promise<number>;
|
|
766
|
+
acceptSwapQuote(swapId: string, amount: number, options?: QuoteSwapOptions): Promise<number>;
|
|
691
767
|
enrichReverseSwapPreimage(swap: BoltzReverseSwap, preimage: string): BoltzReverseSwap;
|
|
692
768
|
enrichSubmarineSwapInvoice(swap: BoltzSubmarineSwap, invoice: string): BoltzSubmarineSwap;
|
|
693
769
|
createVHTLCScript(_args: {
|
|
@@ -779,10 +855,18 @@ declare class IndexedDbSwapRepository implements SwapRepository {
|
|
|
779
855
|
clear(): Promise<void>;
|
|
780
856
|
private getSwapsByIndexValues;
|
|
781
857
|
private getAllSwapsFromStore;
|
|
782
|
-
private applySwapsFilter;
|
|
783
858
|
private getAllSwapsByCreatedAt;
|
|
784
|
-
private sortIfNeeded;
|
|
785
859
|
[Symbol.asyncDispose](): Promise<void>;
|
|
786
860
|
}
|
|
787
861
|
|
|
788
|
-
|
|
862
|
+
declare class InMemorySwapRepository implements SwapRepository {
|
|
863
|
+
readonly version: 1;
|
|
864
|
+
private readonly swaps;
|
|
865
|
+
saveSwap<T extends BoltzSwap>(swap: T): Promise<void>;
|
|
866
|
+
deleteSwap(id: string): Promise<void>;
|
|
867
|
+
getAllSwaps<T extends BoltzSwap>(filter?: GetSwapsFilter): Promise<T[]>;
|
|
868
|
+
clear(): Promise<void>;
|
|
869
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
export { ArkToBtcResponse, ArkadeSwapsMessageHandler as ArkadeLightningMessageHandler, ArkadeSwapsConfig, ArkadeSwapsMessageHandler, BoltzChainSwap, BoltzRefundError, BoltzReverseSwap, BoltzSubmarineSwap, BoltzSwap, BtcToArkResponse, Chain, ChainFeesResponse, CreateLightningInvoiceRequest, CreateLightningInvoiceResponse, DecodedInvoice, FeesResponse, InMemorySwapRepository, IndexedDbSwapRepository, InsufficientFundsError, InvoiceExpiredError, InvoiceFailedToPayError, LimitsResponse, type Logger, Network, NetworkError, PreimageFetchError, QuoteRejectedError, type QuoteRejectionReason, QuoteSwapOptions, SchemaError, SendLightningPaymentRequest, SendLightningPaymentResponse, ServiceWorkerArkadeSwaps as ServiceWorkerArkadeLightning, ServiceWorkerArkadeSwaps, SubmarineRecoveryInfo, SubmarineRecoveryResult, SubmarineRefundOutcome, SwapError, SwapExpiredError, SwapManagerClient, SwapNotFoundError, SwapRepository, type SwapSaver, TransactionFailedError, decodeInvoice, enrichReverseSwapPreimage, enrichSubmarineSwapInvoice, getInvoicePaymentHash, getInvoiceSatoshis, isValidArkAddress, logger, migrateToSwapRepository, saveSwap, setLogger, updateChainSwapStatus, updateReverseSwapStatus, updateSubmarineSwapStatus, verifySignatures };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-
|
|
2
|
-
export { A as ArkadeSwaps } from './arkade-swaps-
|
|
3
|
-
import { B as BoltzSwap, D as DecodedInvoice, a as BoltzChainSwap, b as BoltzReverseSwap, c as BoltzSubmarineSwap, A as ArkadeSwapsConfig, N as Network, C as CreateLightningInvoiceRequest, S as SendLightningPaymentRequest, F as FeesResponse, d as Chain, e as CreateLightningInvoiceResponse, f as SendLightningPaymentResponse, g as SubmarineRefundOutcome, h as SubmarineRecoveryInfo, i as SubmarineRecoveryResult, j as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, k as ArkToBtcResponse, l as BtcToArkResponse, m as
|
|
4
|
-
export {
|
|
1
|
+
import { Q as QuoteSwapOptions, I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-BXAD1s8j.js';
|
|
2
|
+
export { A as ArkadeSwaps } from './arkade-swaps-BXAD1s8j.js';
|
|
3
|
+
import { B as BoltzSwap, D as DecodedInvoice, a as BoltzChainSwap, b as BoltzReverseSwap, c as BoltzSubmarineSwap, A as ArkadeSwapsConfig, N as Network, C as CreateLightningInvoiceRequest, S as SendLightningPaymentRequest, F as FeesResponse, d as Chain, e as CreateLightningInvoiceResponse, f as SendLightningPaymentResponse, g as SubmarineRefundOutcome, h as SubmarineRecoveryInfo, i as SubmarineRecoveryResult, j as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, k as ArkToBtcResponse, l as BtcToArkResponse, m as ChainArkRefundOutcome, n as SwapRepository, o as SwapManagerClient, p as GetSwapsFilter } from './types--axEWA8c.js';
|
|
4
|
+
export { q as ArkadeSwapsCreateConfig, r as BoltzSwapProvider, s as BoltzSwapStatus, I as IncomingPaymentSubscription, P as PendingChainSwap, t as PendingReverseSwap, u as PendingSubmarineSwap, v as PendingSwap, w as SubmarineRecoveryStatus, x as SwapManager, y as SwapManagerCallbacks, z as SwapManagerConfig, E as SwapManagerEvents, V as Vtxo, H as isChainClaimableStatus, J as isChainFailedStatus, K as isChainFinalStatus, M as isChainPendingStatus, O as isChainRefundableStatus, Q as isChainSignableStatus, R as isChainSuccessStatus, T as isChainSwapClaimable, U as isChainSwapRefundable, W as isPendingChainSwap, X as isPendingReverseSwap, Y as isPendingSubmarineSwap, Z as isReverseClaimableStatus, _ as isReverseFailedStatus, $ as isReverseFinalStatus, a0 as isReversePendingStatus, a1 as isReverseSuccessStatus, a2 as isReverseSwapClaimable, a3 as isSubmarineFailedStatus, a4 as isSubmarineFinalStatus, a5 as isSubmarinePendingStatus, a6 as isSubmarineRefundableStatus, a7 as isSubmarineSuccessStatus, a8 as isSubmarineSwapRefundable } from './types--axEWA8c.js';
|
|
5
5
|
import { Transaction } from '@scure/btc-signer';
|
|
6
6
|
import { MessageHandler, RequestEnvelope, ArkInfo, ResponseEnvelope, IWallet, IReadonlyWallet, VHTLC, Identity, ArkTxInput } from '@arkade-os/sdk';
|
|
7
7
|
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
|
@@ -16,6 +16,12 @@ interface ErrorOptions {
|
|
|
16
16
|
isRefundable?: boolean;
|
|
17
17
|
/** The associated pending swap, if available. */
|
|
18
18
|
pendingSwap?: BoltzSwap;
|
|
19
|
+
/**
|
|
20
|
+
* Underlying cause. Preserved on the resulting `Error.cause`, so callers
|
|
21
|
+
* that wrap a typed error (e.g. autopilot wrapping `QuoteRejectedError`)
|
|
22
|
+
* can still recover the inner instance for programmatic branching.
|
|
23
|
+
*/
|
|
24
|
+
cause?: unknown;
|
|
19
25
|
}
|
|
20
26
|
/**
|
|
21
27
|
* Base error class for all swap-related errors.
|
|
@@ -86,6 +92,46 @@ declare class TransactionFailedError extends SwapError {
|
|
|
86
92
|
declare class PreimageFetchError extends SwapError {
|
|
87
93
|
constructor(options?: ErrorOptions);
|
|
88
94
|
}
|
|
95
|
+
/** Reason a `quoteSwap` was rejected before being posted to Boltz. */
|
|
96
|
+
type QuoteRejectionReason = "below_floor" | "non_positive" | "non_safe_integer" | "no_baseline";
|
|
97
|
+
type QuoteRejectedOptions = ErrorOptions & ({
|
|
98
|
+
reason: "below_floor";
|
|
99
|
+
quotedAmount: number;
|
|
100
|
+
floor: number;
|
|
101
|
+
} | {
|
|
102
|
+
reason: "non_positive";
|
|
103
|
+
quotedAmount: number;
|
|
104
|
+
} | {
|
|
105
|
+
reason: "non_safe_integer";
|
|
106
|
+
quotedAmount: number;
|
|
107
|
+
} | {
|
|
108
|
+
reason: "no_baseline";
|
|
109
|
+
});
|
|
110
|
+
/**
|
|
111
|
+
* Thrown when a Boltz-returned chain-swap quote fails local validation
|
|
112
|
+
* (below the acceptable floor, non-positive, or missing a baseline to
|
|
113
|
+
* compare against). The acceptance is never posted on failure.
|
|
114
|
+
*/
|
|
115
|
+
declare class QuoteRejectedError extends SwapError {
|
|
116
|
+
readonly reason: QuoteRejectionReason;
|
|
117
|
+
readonly quotedAmount?: number;
|
|
118
|
+
readonly floor?: number;
|
|
119
|
+
constructor(options: QuoteRejectedOptions);
|
|
120
|
+
private static defaultMessage;
|
|
121
|
+
/**
|
|
122
|
+
* Serialize into a plain `Error` whose `.message` carries the full
|
|
123
|
+
* rejection payload as JSON behind a marker prefix. Structured clone
|
|
124
|
+
* (used by `postMessage` between page and service worker) preserves
|
|
125
|
+
* `Error.message` reliably but strips custom `.name` and own properties,
|
|
126
|
+
* so we move the typed data into the message field for transport.
|
|
127
|
+
*/
|
|
128
|
+
toTransportError(): Error;
|
|
129
|
+
/**
|
|
130
|
+
* Inverse of `toTransportError`. Returns a real `QuoteRejectedError` if
|
|
131
|
+
* `error` carries the transport prefix, else `null`.
|
|
132
|
+
*/
|
|
133
|
+
static fromTransportError(error: unknown): QuoteRejectedError | null;
|
|
134
|
+
}
|
|
89
135
|
/**
|
|
90
136
|
* Thrown when the Boltz API rejects a refund request
|
|
91
137
|
* (e.g. outpoint mismatch after an Ark round).
|
|
@@ -453,6 +499,7 @@ type RequestRefundArk = RequestEnvelope & {
|
|
|
453
499
|
};
|
|
454
500
|
type ResponseRefundArk = ResponseEnvelope & {
|
|
455
501
|
type: "ARK_REFUND_EXECUTED";
|
|
502
|
+
payload: ChainArkRefundOutcome;
|
|
456
503
|
};
|
|
457
504
|
type RequestSignServerClaim = RequestEnvelope & {
|
|
458
505
|
type: "SIGN_SERVER_CLAIM";
|
|
@@ -480,6 +527,7 @@ type RequestQuoteSwap = RequestEnvelope & {
|
|
|
480
527
|
type: "QUOTE_SWAP";
|
|
481
528
|
payload: {
|
|
482
529
|
swapId: string;
|
|
530
|
+
options?: QuoteSwapOptions;
|
|
483
531
|
};
|
|
484
532
|
};
|
|
485
533
|
type ResponseQuoteSwap = ResponseEnvelope & {
|
|
@@ -488,6 +536,32 @@ type ResponseQuoteSwap = ResponseEnvelope & {
|
|
|
488
536
|
amount: number;
|
|
489
537
|
};
|
|
490
538
|
};
|
|
539
|
+
type RequestGetSwapQuote = RequestEnvelope & {
|
|
540
|
+
type: "GET_SWAP_QUOTE";
|
|
541
|
+
payload: {
|
|
542
|
+
swapId: string;
|
|
543
|
+
};
|
|
544
|
+
};
|
|
545
|
+
type ResponseGetSwapQuote = ResponseEnvelope & {
|
|
546
|
+
type: "SWAP_QUOTE_RETRIEVED";
|
|
547
|
+
payload: {
|
|
548
|
+
amount: number;
|
|
549
|
+
};
|
|
550
|
+
};
|
|
551
|
+
type RequestAcceptSwapQuote = RequestEnvelope & {
|
|
552
|
+
type: "ACCEPT_SWAP_QUOTE";
|
|
553
|
+
payload: {
|
|
554
|
+
swapId: string;
|
|
555
|
+
amount: number;
|
|
556
|
+
options?: QuoteSwapOptions;
|
|
557
|
+
};
|
|
558
|
+
};
|
|
559
|
+
type ResponseAcceptSwapQuote = ResponseEnvelope & {
|
|
560
|
+
type: "SWAP_QUOTE_ACCEPTED";
|
|
561
|
+
payload: {
|
|
562
|
+
amount: number;
|
|
563
|
+
};
|
|
564
|
+
};
|
|
491
565
|
type RequestSwapManagerStart = RequestEnvelope & {
|
|
492
566
|
type: "SM-START";
|
|
493
567
|
};
|
|
@@ -573,8 +647,8 @@ type ResponseSwapManagerWaitForCompletion = ResponseEnvelope & {
|
|
|
573
647
|
txid: string;
|
|
574
648
|
};
|
|
575
649
|
};
|
|
576
|
-
type ArkadeSwapsUpdaterRequest = RequestInitArkSwaps | RequestCreateLightningInvoice | RequestSendLightningPayment | RequestCreateSubmarineSwap | RequestCreateReverseSwap | RequestClaimVhtlc | RequestRefundVhtlc | RequestInspectSubmarineRecovery | RequestScanRecoverableSubmarineSwaps | RequestRecoverSubmarineFunds | RequestRecoverAllSubmarineFunds | RequestWaitAndClaim | RequestWaitForSwapSettlement | RequestRestoreSwaps | RequestEnrichReverseSwapPreimage | RequestEnrichSubmarineSwapInvoice | RequestGetFees | RequestGetLimits | RequestGetSwapStatus | RequestGetPendingSubmarineSwaps | RequestGetPendingReverseSwaps | RequestGetPendingChainSwaps | RequestGetSwapHistory | RequestRefreshSwapsStatus | RequestArkToBtc | RequestBtcToArk | RequestCreateChainSwap | RequestWaitAndClaimChain | RequestWaitAndClaimArk | RequestWaitAndClaimBtc | RequestClaimArk | RequestClaimBtc | RequestRefundArk | RequestSignServerClaim | RequestVerifyChainSwap | RequestQuoteSwap | RequestSwapManagerStart | RequestSwapManagerStop | RequestSwapManagerAddSwap | RequestSwapManagerRemoveSwap | RequestSwapManagerGetPending | RequestSwapManagerHasSwap | RequestSwapManagerIsProcessing | RequestSwapManagerGetStats | RequestSwapManagerWaitForCompletion;
|
|
577
|
-
type ArkadeSwapsUpdaterResponse = ResponseInitArkSwaps | ResponseCreateLightningInvoice | ResponseSendLightningPayment | ResponseCreateSubmarineSwap | ResponseCreateReverseSwap | ResponseClaimVhtlc | ResponseRefundVhtlc | ResponseInspectSubmarineRecovery | ResponseScanRecoverableSubmarineSwaps | ResponseRecoverSubmarineFunds | ResponseRecoverAllSubmarineFunds | ResponseWaitAndClaim | ResponseWaitForSwapSettlement | ResponseRestoreSwaps | ResponseEnrichReverseSwapPreimage | ResponseEnrichSubmarineSwapInvoice | ResponseGetFees | ResponseGetLimits | ResponseGetSwapStatus | ResponseGetPendingSubmarineSwaps | ResponseGetPendingReverseSwaps | ResponseGetPendingChainSwaps | ResponseGetSwapHistory | ResponseRefreshSwapsStatus | ResponseArkToBtc | ResponseBtcToArk | ResponseCreateChainSwap | ResponseWaitAndClaimChain | ResponseWaitAndClaimArk | ResponseWaitAndClaimBtc | ResponseClaimArk | ResponseClaimBtc | ResponseRefundArk | ResponseSignServerClaim | ResponseVerifyChainSwap | ResponseQuoteSwap | ResponseSwapManagerStart | ResponseSwapManagerStop | ResponseSwapManagerAddSwap | ResponseSwapManagerRemoveSwap | ResponseSwapManagerGetPending | ResponseSwapManagerHasSwap | ResponseSwapManagerIsProcessing | ResponseSwapManagerGetStats | ResponseSwapManagerWaitForCompletion;
|
|
650
|
+
type ArkadeSwapsUpdaterRequest = RequestInitArkSwaps | RequestCreateLightningInvoice | RequestSendLightningPayment | RequestCreateSubmarineSwap | RequestCreateReverseSwap | RequestClaimVhtlc | RequestRefundVhtlc | RequestInspectSubmarineRecovery | RequestScanRecoverableSubmarineSwaps | RequestRecoverSubmarineFunds | RequestRecoverAllSubmarineFunds | RequestWaitAndClaim | RequestWaitForSwapSettlement | RequestRestoreSwaps | RequestEnrichReverseSwapPreimage | RequestEnrichSubmarineSwapInvoice | RequestGetFees | RequestGetLimits | RequestGetSwapStatus | RequestGetPendingSubmarineSwaps | RequestGetPendingReverseSwaps | RequestGetPendingChainSwaps | RequestGetSwapHistory | RequestRefreshSwapsStatus | RequestArkToBtc | RequestBtcToArk | RequestCreateChainSwap | RequestWaitAndClaimChain | RequestWaitAndClaimArk | RequestWaitAndClaimBtc | RequestClaimArk | RequestClaimBtc | RequestRefundArk | RequestSignServerClaim | RequestVerifyChainSwap | RequestQuoteSwap | RequestGetSwapQuote | RequestAcceptSwapQuote | RequestSwapManagerStart | RequestSwapManagerStop | RequestSwapManagerAddSwap | RequestSwapManagerRemoveSwap | RequestSwapManagerGetPending | RequestSwapManagerHasSwap | RequestSwapManagerIsProcessing | RequestSwapManagerGetStats | RequestSwapManagerWaitForCompletion;
|
|
651
|
+
type ArkadeSwapsUpdaterResponse = ResponseInitArkSwaps | ResponseCreateLightningInvoice | ResponseSendLightningPayment | ResponseCreateSubmarineSwap | ResponseCreateReverseSwap | ResponseClaimVhtlc | ResponseRefundVhtlc | ResponseInspectSubmarineRecovery | ResponseScanRecoverableSubmarineSwaps | ResponseRecoverSubmarineFunds | ResponseRecoverAllSubmarineFunds | ResponseWaitAndClaim | ResponseWaitForSwapSettlement | ResponseRestoreSwaps | ResponseEnrichReverseSwapPreimage | ResponseEnrichSubmarineSwapInvoice | ResponseGetFees | ResponseGetLimits | ResponseGetSwapStatus | ResponseGetPendingSubmarineSwaps | ResponseGetPendingReverseSwaps | ResponseGetPendingChainSwaps | ResponseGetSwapHistory | ResponseRefreshSwapsStatus | ResponseArkToBtc | ResponseBtcToArk | ResponseCreateChainSwap | ResponseWaitAndClaimChain | ResponseWaitAndClaimArk | ResponseWaitAndClaimBtc | ResponseClaimArk | ResponseClaimBtc | ResponseRefundArk | ResponseSignServerClaim | ResponseVerifyChainSwap | ResponseQuoteSwap | ResponseGetSwapQuote | ResponseAcceptSwapQuote | ResponseSwapManagerStart | ResponseSwapManagerStop | ResponseSwapManagerAddSwap | ResponseSwapManagerRemoveSwap | ResponseSwapManagerGetPending | ResponseSwapManagerHasSwap | ResponseSwapManagerIsProcessing | ResponseSwapManagerGetStats | ResponseSwapManagerWaitForCompletion;
|
|
578
652
|
declare class ArkadeSwapsMessageHandler implements MessageHandler<ArkadeSwapsUpdaterRequest, ArkadeSwapsUpdaterResponse> {
|
|
579
653
|
private readonly swapRepository;
|
|
580
654
|
static messageTag: string;
|
|
@@ -679,7 +753,7 @@ declare class ServiceWorkerArkadeSwaps implements IArkadeSwaps {
|
|
|
679
753
|
}>;
|
|
680
754
|
claimArk(pendingSwap: BoltzChainSwap): Promise<void>;
|
|
681
755
|
claimBtc(pendingSwap: BoltzChainSwap): Promise<void>;
|
|
682
|
-
refundArk(pendingSwap: BoltzChainSwap): Promise<
|
|
756
|
+
refundArk(pendingSwap: BoltzChainSwap): Promise<ChainArkRefundOutcome>;
|
|
683
757
|
signCooperativeClaimForServer(pendingSwap: BoltzChainSwap): Promise<void>;
|
|
684
758
|
verifyChainSwap(args: {
|
|
685
759
|
to: Chain;
|
|
@@ -687,7 +761,9 @@ declare class ServiceWorkerArkadeSwaps implements IArkadeSwaps {
|
|
|
687
761
|
swap: BoltzChainSwap;
|
|
688
762
|
arkInfo: ArkInfo;
|
|
689
763
|
}): Promise<boolean>;
|
|
690
|
-
quoteSwap(swapId: string): Promise<number>;
|
|
764
|
+
quoteSwap(swapId: string, options?: QuoteSwapOptions): Promise<number>;
|
|
765
|
+
getSwapQuote(swapId: string): Promise<number>;
|
|
766
|
+
acceptSwapQuote(swapId: string, amount: number, options?: QuoteSwapOptions): Promise<number>;
|
|
691
767
|
enrichReverseSwapPreimage(swap: BoltzReverseSwap, preimage: string): BoltzReverseSwap;
|
|
692
768
|
enrichSubmarineSwapInvoice(swap: BoltzSubmarineSwap, invoice: string): BoltzSubmarineSwap;
|
|
693
769
|
createVHTLCScript(_args: {
|
|
@@ -779,10 +855,18 @@ declare class IndexedDbSwapRepository implements SwapRepository {
|
|
|
779
855
|
clear(): Promise<void>;
|
|
780
856
|
private getSwapsByIndexValues;
|
|
781
857
|
private getAllSwapsFromStore;
|
|
782
|
-
private applySwapsFilter;
|
|
783
858
|
private getAllSwapsByCreatedAt;
|
|
784
|
-
private sortIfNeeded;
|
|
785
859
|
[Symbol.asyncDispose](): Promise<void>;
|
|
786
860
|
}
|
|
787
861
|
|
|
788
|
-
|
|
862
|
+
declare class InMemorySwapRepository implements SwapRepository {
|
|
863
|
+
readonly version: 1;
|
|
864
|
+
private readonly swaps;
|
|
865
|
+
saveSwap<T extends BoltzSwap>(swap: T): Promise<void>;
|
|
866
|
+
deleteSwap(id: string): Promise<void>;
|
|
867
|
+
getAllSwaps<T extends BoltzSwap>(filter?: GetSwapsFilter): Promise<T[]>;
|
|
868
|
+
clear(): Promise<void>;
|
|
869
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
export { ArkToBtcResponse, ArkadeSwapsMessageHandler as ArkadeLightningMessageHandler, ArkadeSwapsConfig, ArkadeSwapsMessageHandler, BoltzChainSwap, BoltzRefundError, BoltzReverseSwap, BoltzSubmarineSwap, BoltzSwap, BtcToArkResponse, Chain, ChainFeesResponse, CreateLightningInvoiceRequest, CreateLightningInvoiceResponse, DecodedInvoice, FeesResponse, InMemorySwapRepository, IndexedDbSwapRepository, InsufficientFundsError, InvoiceExpiredError, InvoiceFailedToPayError, LimitsResponse, type Logger, Network, NetworkError, PreimageFetchError, QuoteRejectedError, type QuoteRejectionReason, QuoteSwapOptions, SchemaError, SendLightningPaymentRequest, SendLightningPaymentResponse, ServiceWorkerArkadeSwaps as ServiceWorkerArkadeLightning, ServiceWorkerArkadeSwaps, SubmarineRecoveryInfo, SubmarineRecoveryResult, SubmarineRefundOutcome, SwapError, SwapExpiredError, SwapManagerClient, SwapNotFoundError, SwapRepository, type SwapSaver, TransactionFailedError, decodeInvoice, enrichReverseSwapPreimage, enrichSubmarineSwapInvoice, getInvoicePaymentHash, getInvoiceSatoshis, isValidArkAddress, logger, migrateToSwapRepository, saveSwap, setLogger, updateChainSwapStatus, updateReverseSwapStatus, updateSubmarineSwapStatus, verifySignatures };
|