@arkade-os/boltz-swap 0.3.23 → 0.3.25
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 -0
- package/dist/{arkade-swaps-DEvf-2g2.d.ts → arkade-swaps-CZF9XoFR.d.cts} +101 -16
- package/dist/{arkade-swaps-CvA3RP7_.d.cts → arkade-swaps-pfAgQUMP.d.ts} +101 -16
- package/dist/{background-EHOJZDKT.js → background-GCBCKLGY.js} +2 -2
- package/dist/{chunk-EQK2BJQC.js → chunk-FEXQELYZ.js} +1 -1
- package/dist/{chunk-K3QEFL7D.js → chunk-XC2ARJZO.js} +390 -70
- package/dist/expo/index.cjs +408 -73
- package/dist/expo/index.d.cts +8 -9
- package/dist/expo/index.d.ts +8 -9
- package/dist/expo/index.js +16 -4
- package/dist/index.cjs +515 -79
- package/dist/index.d.cts +46 -14
- package/dist/index.d.ts +46 -14
- package/dist/index.js +126 -10
- package/dist/repositories/realm/index.d.cts +1 -1
- package/dist/repositories/realm/index.d.ts +1 -1
- package/dist/repositories/sqlite/index.d.cts +1 -1
- package/dist/repositories/sqlite/index.d.ts +1 -1
- package/dist/{types-OyAdK824.d.cts → types-LCXS1AVA.d.cts} +63 -1
- package/dist/{types-OyAdK824.d.ts → types-LCXS1AVA.d.ts} +63 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { I as IArkadeSwaps } 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 ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse,
|
|
4
|
-
export {
|
|
1
|
+
import { I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-CZF9XoFR.cjs';
|
|
2
|
+
export { A as ArkadeSwaps } from './arkade-swaps-CZF9XoFR.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 SwapRepository, n as SwapManagerClient, o as GetSwapsFilter } from './types-LCXS1AVA.cjs';
|
|
4
|
+
export { _ as ArkadeSwapsCreateConfig, p as BoltzSwapProvider, q as BoltzSwapStatus, Z as IncomingPaymentSubscription, a1 as PendingChainSwap, a0 as PendingReverseSwap, $ as PendingSubmarineSwap, a2 as PendingSwap, a4 as SubmarineRecoveryStatus, Y as SwapManager, a7 as SwapManagerCallbacks, a5 as SwapManagerConfig, a6 as SwapManagerEvents, a3 as Vtxo, r as isChainClaimableStatus, s as isChainFailedStatus, t as isChainFinalStatus, u as isChainPendingStatus, v as isChainRefundableStatus, w as isChainSignableStatus, x as isChainSuccessStatus, y as isChainSwapClaimable, z as isChainSwapRefundable, E as isPendingChainSwap, H as isPendingReverseSwap, I as isPendingSubmarineSwap, J as isReverseClaimableStatus, K as isReverseFailedStatus, M as isReverseFinalStatus, O as isReversePendingStatus, P as isReverseSuccessStatus, Q as isReverseSwapClaimable, R as isSubmarineFailedStatus, T as isSubmarineFinalStatus, U as isSubmarinePendingStatus, W as isSubmarineRefundableStatus, V as isSubmarineSuccessStatus, X as isSubmarineSwapRefundable } from './types-LCXS1AVA.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';
|
|
@@ -195,6 +195,38 @@ type RequestRefundVhtlc = RequestEnvelope & {
|
|
|
195
195
|
};
|
|
196
196
|
type ResponseRefundVhtlc = ResponseEnvelope & {
|
|
197
197
|
type: "VHTLC_REFUNDED";
|
|
198
|
+
payload: SubmarineRefundOutcome;
|
|
199
|
+
};
|
|
200
|
+
type RequestInspectSubmarineRecovery = RequestEnvelope & {
|
|
201
|
+
type: "INSPECT_SUBMARINE_RECOVERY";
|
|
202
|
+
payload: BoltzSubmarineSwap;
|
|
203
|
+
};
|
|
204
|
+
type ResponseInspectSubmarineRecovery = ResponseEnvelope & {
|
|
205
|
+
type: "SUBMARINE_RECOVERY_INSPECTED";
|
|
206
|
+
payload: SubmarineRecoveryInfo;
|
|
207
|
+
};
|
|
208
|
+
type RequestScanRecoverableSubmarineSwaps = RequestEnvelope & {
|
|
209
|
+
type: "SCAN_RECOVERABLE_SUBMARINE_SWAPS";
|
|
210
|
+
};
|
|
211
|
+
type ResponseScanRecoverableSubmarineSwaps = ResponseEnvelope & {
|
|
212
|
+
type: "RECOVERABLE_SUBMARINE_SWAPS_SCANNED";
|
|
213
|
+
payload: SubmarineRecoveryInfo[];
|
|
214
|
+
};
|
|
215
|
+
type RequestRecoverSubmarineFunds = RequestEnvelope & {
|
|
216
|
+
type: "RECOVER_SUBMARINE_FUNDS";
|
|
217
|
+
payload: BoltzSubmarineSwap;
|
|
218
|
+
};
|
|
219
|
+
type ResponseRecoverSubmarineFunds = ResponseEnvelope & {
|
|
220
|
+
type: "SUBMARINE_FUNDS_RECOVERED";
|
|
221
|
+
payload: SubmarineRefundOutcome;
|
|
222
|
+
};
|
|
223
|
+
type RequestRecoverAllSubmarineFunds = RequestEnvelope & {
|
|
224
|
+
type: "RECOVER_ALL_SUBMARINE_FUNDS";
|
|
225
|
+
payload: BoltzSubmarineSwap[];
|
|
226
|
+
};
|
|
227
|
+
type ResponseRecoverAllSubmarineFunds = ResponseEnvelope & {
|
|
228
|
+
type: "ALL_SUBMARINE_FUNDS_RECOVERED";
|
|
229
|
+
payload: SubmarineRecoveryResult[];
|
|
198
230
|
};
|
|
199
231
|
type RequestWaitAndClaim = RequestEnvelope & {
|
|
200
232
|
type: "WAIT_AND_CLAIM";
|
|
@@ -526,8 +558,8 @@ type ResponseSwapManagerWaitForCompletion = ResponseEnvelope & {
|
|
|
526
558
|
txid: string;
|
|
527
559
|
};
|
|
528
560
|
};
|
|
529
|
-
type ArkadeSwapsUpdaterRequest = RequestInitArkSwaps | RequestCreateLightningInvoice | RequestSendLightningPayment | RequestCreateSubmarineSwap | RequestCreateReverseSwap | RequestClaimVhtlc | RequestRefundVhtlc | 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;
|
|
530
|
-
type ArkadeSwapsUpdaterResponse = ResponseInitArkSwaps | ResponseCreateLightningInvoice | ResponseSendLightningPayment | ResponseCreateSubmarineSwap | ResponseCreateReverseSwap | ResponseClaimVhtlc | ResponseRefundVhtlc | 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;
|
|
561
|
+
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;
|
|
562
|
+
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;
|
|
531
563
|
declare class ArkadeSwapsMessageHandler implements MessageHandler<ArkadeSwapsUpdaterRequest, ArkadeSwapsUpdaterResponse> {
|
|
532
564
|
private readonly swapRepository;
|
|
533
565
|
static messageTag: string;
|
|
@@ -546,6 +578,7 @@ declare class ArkadeSwapsMessageHandler implements MessageHandler<ArkadeSwapsUpd
|
|
|
546
578
|
}): Promise<void>;
|
|
547
579
|
stop(): Promise<void>;
|
|
548
580
|
tick(_now: number): Promise<never[]>;
|
|
581
|
+
isLongRunning(message: ArkadeSwapsUpdaterRequest): boolean;
|
|
549
582
|
private tagged;
|
|
550
583
|
private broadcastEvent;
|
|
551
584
|
handleMessage(message: ArkadeSwapsUpdaterRequest): Promise<ArkadeSwapsUpdaterResponse>;
|
|
@@ -584,7 +617,11 @@ declare class ServiceWorkerArkadeSwaps implements IArkadeSwaps {
|
|
|
584
617
|
createSubmarineSwap(args: SendLightningPaymentRequest): Promise<BoltzSubmarineSwap>;
|
|
585
618
|
createReverseSwap(args: CreateLightningInvoiceRequest): Promise<BoltzReverseSwap>;
|
|
586
619
|
claimVHTLC(pendingSwap: BoltzReverseSwap): Promise<void>;
|
|
587
|
-
refundVHTLC(pendingSwap: BoltzSubmarineSwap): Promise<
|
|
620
|
+
refundVHTLC(pendingSwap: BoltzSubmarineSwap): Promise<SubmarineRefundOutcome>;
|
|
621
|
+
inspectSubmarineRecovery(swap: BoltzSubmarineSwap): Promise<SubmarineRecoveryInfo>;
|
|
622
|
+
scanRecoverableSubmarineSwaps(): Promise<SubmarineRecoveryInfo[]>;
|
|
623
|
+
recoverSubmarineFunds(swap: BoltzSubmarineSwap): Promise<SubmarineRefundOutcome>;
|
|
624
|
+
recoverAllSubmarineFunds(swaps: BoltzSubmarineSwap[]): Promise<SubmarineRecoveryResult[]>;
|
|
588
625
|
waitAndClaim(pendingSwap: BoltzReverseSwap): Promise<{
|
|
589
626
|
txid: string;
|
|
590
627
|
}>;
|
|
@@ -643,12 +680,7 @@ declare class ServiceWorkerArkadeSwaps implements IArkadeSwaps {
|
|
|
643
680
|
receiverPubkey: string;
|
|
644
681
|
senderPubkey: string;
|
|
645
682
|
serverPubkey: string;
|
|
646
|
-
timeoutBlockHeights:
|
|
647
|
-
refund: number;
|
|
648
|
-
unilateralClaim: number;
|
|
649
|
-
unilateralRefund: number;
|
|
650
|
-
unilateralRefundWithoutReceiver: number;
|
|
651
|
-
};
|
|
683
|
+
timeoutBlockHeights: VhtlcTimeouts;
|
|
652
684
|
}): {
|
|
653
685
|
vhtlcScript: VHTLC.Script;
|
|
654
686
|
vhtlcAddress: string;
|
|
@@ -737,4 +769,4 @@ declare class IndexedDbSwapRepository implements SwapRepository {
|
|
|
737
769
|
[Symbol.asyncDispose](): Promise<void>;
|
|
738
770
|
}
|
|
739
771
|
|
|
740
|
-
export { ArkToBtcResponse, ArkadeSwapsMessageHandler as ArkadeLightningMessageHandler, ArkadeSwapsConfig, ArkadeSwapsMessageHandler, BoltzChainSwap, BoltzRefundError, BoltzReverseSwap, BoltzSubmarineSwap, BoltzSwap, BtcToArkResponse, Chain, ChainFeesResponse, CreateLightningInvoiceRequest, CreateLightningInvoiceResponse, DecodedInvoice, FeesResponse, IndexedDbSwapRepository, InsufficientFundsError, InvoiceExpiredError, InvoiceFailedToPayError, LimitsResponse, type Logger, Network, NetworkError, PreimageFetchError, SchemaError, SendLightningPaymentRequest, SendLightningPaymentResponse, ServiceWorkerArkadeSwaps as ServiceWorkerArkadeLightning, ServiceWorkerArkadeSwaps, SwapError, SwapExpiredError, SwapManagerClient, SwapRepository, type SwapSaver, TransactionFailedError, decodeInvoice, enrichReverseSwapPreimage, enrichSubmarineSwapInvoice, getInvoicePaymentHash, getInvoiceSatoshis, isValidArkAddress, logger, migrateToSwapRepository, saveSwap, setLogger, updateChainSwapStatus, updateReverseSwapStatus, updateSubmarineSwapStatus, verifySignatures };
|
|
772
|
+
export { ArkToBtcResponse, ArkadeSwapsMessageHandler as ArkadeLightningMessageHandler, ArkadeSwapsConfig, ArkadeSwapsMessageHandler, BoltzChainSwap, BoltzRefundError, BoltzReverseSwap, BoltzSubmarineSwap, BoltzSwap, BtcToArkResponse, Chain, ChainFeesResponse, CreateLightningInvoiceRequest, CreateLightningInvoiceResponse, DecodedInvoice, FeesResponse, IndexedDbSwapRepository, InsufficientFundsError, InvoiceExpiredError, InvoiceFailedToPayError, LimitsResponse, type Logger, Network, NetworkError, PreimageFetchError, SchemaError, SendLightningPaymentRequest, SendLightningPaymentResponse, ServiceWorkerArkadeSwaps as ServiceWorkerArkadeLightning, ServiceWorkerArkadeSwaps, SubmarineRecoveryInfo, SubmarineRecoveryResult, SubmarineRefundOutcome, SwapError, SwapExpiredError, SwapManagerClient, 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 } 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 ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse,
|
|
4
|
-
export {
|
|
1
|
+
import { I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-pfAgQUMP.js';
|
|
2
|
+
export { A as ArkadeSwaps } from './arkade-swaps-pfAgQUMP.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 SwapRepository, n as SwapManagerClient, o as GetSwapsFilter } from './types-LCXS1AVA.js';
|
|
4
|
+
export { _ as ArkadeSwapsCreateConfig, p as BoltzSwapProvider, q as BoltzSwapStatus, Z as IncomingPaymentSubscription, a1 as PendingChainSwap, a0 as PendingReverseSwap, $ as PendingSubmarineSwap, a2 as PendingSwap, a4 as SubmarineRecoveryStatus, Y as SwapManager, a7 as SwapManagerCallbacks, a5 as SwapManagerConfig, a6 as SwapManagerEvents, a3 as Vtxo, r as isChainClaimableStatus, s as isChainFailedStatus, t as isChainFinalStatus, u as isChainPendingStatus, v as isChainRefundableStatus, w as isChainSignableStatus, x as isChainSuccessStatus, y as isChainSwapClaimable, z as isChainSwapRefundable, E as isPendingChainSwap, H as isPendingReverseSwap, I as isPendingSubmarineSwap, J as isReverseClaimableStatus, K as isReverseFailedStatus, M as isReverseFinalStatus, O as isReversePendingStatus, P as isReverseSuccessStatus, Q as isReverseSwapClaimable, R as isSubmarineFailedStatus, T as isSubmarineFinalStatus, U as isSubmarinePendingStatus, W as isSubmarineRefundableStatus, V as isSubmarineSuccessStatus, X as isSubmarineSwapRefundable } from './types-LCXS1AVA.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';
|
|
@@ -195,6 +195,38 @@ type RequestRefundVhtlc = RequestEnvelope & {
|
|
|
195
195
|
};
|
|
196
196
|
type ResponseRefundVhtlc = ResponseEnvelope & {
|
|
197
197
|
type: "VHTLC_REFUNDED";
|
|
198
|
+
payload: SubmarineRefundOutcome;
|
|
199
|
+
};
|
|
200
|
+
type RequestInspectSubmarineRecovery = RequestEnvelope & {
|
|
201
|
+
type: "INSPECT_SUBMARINE_RECOVERY";
|
|
202
|
+
payload: BoltzSubmarineSwap;
|
|
203
|
+
};
|
|
204
|
+
type ResponseInspectSubmarineRecovery = ResponseEnvelope & {
|
|
205
|
+
type: "SUBMARINE_RECOVERY_INSPECTED";
|
|
206
|
+
payload: SubmarineRecoveryInfo;
|
|
207
|
+
};
|
|
208
|
+
type RequestScanRecoverableSubmarineSwaps = RequestEnvelope & {
|
|
209
|
+
type: "SCAN_RECOVERABLE_SUBMARINE_SWAPS";
|
|
210
|
+
};
|
|
211
|
+
type ResponseScanRecoverableSubmarineSwaps = ResponseEnvelope & {
|
|
212
|
+
type: "RECOVERABLE_SUBMARINE_SWAPS_SCANNED";
|
|
213
|
+
payload: SubmarineRecoveryInfo[];
|
|
214
|
+
};
|
|
215
|
+
type RequestRecoverSubmarineFunds = RequestEnvelope & {
|
|
216
|
+
type: "RECOVER_SUBMARINE_FUNDS";
|
|
217
|
+
payload: BoltzSubmarineSwap;
|
|
218
|
+
};
|
|
219
|
+
type ResponseRecoverSubmarineFunds = ResponseEnvelope & {
|
|
220
|
+
type: "SUBMARINE_FUNDS_RECOVERED";
|
|
221
|
+
payload: SubmarineRefundOutcome;
|
|
222
|
+
};
|
|
223
|
+
type RequestRecoverAllSubmarineFunds = RequestEnvelope & {
|
|
224
|
+
type: "RECOVER_ALL_SUBMARINE_FUNDS";
|
|
225
|
+
payload: BoltzSubmarineSwap[];
|
|
226
|
+
};
|
|
227
|
+
type ResponseRecoverAllSubmarineFunds = ResponseEnvelope & {
|
|
228
|
+
type: "ALL_SUBMARINE_FUNDS_RECOVERED";
|
|
229
|
+
payload: SubmarineRecoveryResult[];
|
|
198
230
|
};
|
|
199
231
|
type RequestWaitAndClaim = RequestEnvelope & {
|
|
200
232
|
type: "WAIT_AND_CLAIM";
|
|
@@ -526,8 +558,8 @@ type ResponseSwapManagerWaitForCompletion = ResponseEnvelope & {
|
|
|
526
558
|
txid: string;
|
|
527
559
|
};
|
|
528
560
|
};
|
|
529
|
-
type ArkadeSwapsUpdaterRequest = RequestInitArkSwaps | RequestCreateLightningInvoice | RequestSendLightningPayment | RequestCreateSubmarineSwap | RequestCreateReverseSwap | RequestClaimVhtlc | RequestRefundVhtlc | 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;
|
|
530
|
-
type ArkadeSwapsUpdaterResponse = ResponseInitArkSwaps | ResponseCreateLightningInvoice | ResponseSendLightningPayment | ResponseCreateSubmarineSwap | ResponseCreateReverseSwap | ResponseClaimVhtlc | ResponseRefundVhtlc | 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;
|
|
561
|
+
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;
|
|
562
|
+
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;
|
|
531
563
|
declare class ArkadeSwapsMessageHandler implements MessageHandler<ArkadeSwapsUpdaterRequest, ArkadeSwapsUpdaterResponse> {
|
|
532
564
|
private readonly swapRepository;
|
|
533
565
|
static messageTag: string;
|
|
@@ -546,6 +578,7 @@ declare class ArkadeSwapsMessageHandler implements MessageHandler<ArkadeSwapsUpd
|
|
|
546
578
|
}): Promise<void>;
|
|
547
579
|
stop(): Promise<void>;
|
|
548
580
|
tick(_now: number): Promise<never[]>;
|
|
581
|
+
isLongRunning(message: ArkadeSwapsUpdaterRequest): boolean;
|
|
549
582
|
private tagged;
|
|
550
583
|
private broadcastEvent;
|
|
551
584
|
handleMessage(message: ArkadeSwapsUpdaterRequest): Promise<ArkadeSwapsUpdaterResponse>;
|
|
@@ -584,7 +617,11 @@ declare class ServiceWorkerArkadeSwaps implements IArkadeSwaps {
|
|
|
584
617
|
createSubmarineSwap(args: SendLightningPaymentRequest): Promise<BoltzSubmarineSwap>;
|
|
585
618
|
createReverseSwap(args: CreateLightningInvoiceRequest): Promise<BoltzReverseSwap>;
|
|
586
619
|
claimVHTLC(pendingSwap: BoltzReverseSwap): Promise<void>;
|
|
587
|
-
refundVHTLC(pendingSwap: BoltzSubmarineSwap): Promise<
|
|
620
|
+
refundVHTLC(pendingSwap: BoltzSubmarineSwap): Promise<SubmarineRefundOutcome>;
|
|
621
|
+
inspectSubmarineRecovery(swap: BoltzSubmarineSwap): Promise<SubmarineRecoveryInfo>;
|
|
622
|
+
scanRecoverableSubmarineSwaps(): Promise<SubmarineRecoveryInfo[]>;
|
|
623
|
+
recoverSubmarineFunds(swap: BoltzSubmarineSwap): Promise<SubmarineRefundOutcome>;
|
|
624
|
+
recoverAllSubmarineFunds(swaps: BoltzSubmarineSwap[]): Promise<SubmarineRecoveryResult[]>;
|
|
588
625
|
waitAndClaim(pendingSwap: BoltzReverseSwap): Promise<{
|
|
589
626
|
txid: string;
|
|
590
627
|
}>;
|
|
@@ -643,12 +680,7 @@ declare class ServiceWorkerArkadeSwaps implements IArkadeSwaps {
|
|
|
643
680
|
receiverPubkey: string;
|
|
644
681
|
senderPubkey: string;
|
|
645
682
|
serverPubkey: string;
|
|
646
|
-
timeoutBlockHeights:
|
|
647
|
-
refund: number;
|
|
648
|
-
unilateralClaim: number;
|
|
649
|
-
unilateralRefund: number;
|
|
650
|
-
unilateralRefundWithoutReceiver: number;
|
|
651
|
-
};
|
|
683
|
+
timeoutBlockHeights: VhtlcTimeouts;
|
|
652
684
|
}): {
|
|
653
685
|
vhtlcScript: VHTLC.Script;
|
|
654
686
|
vhtlcAddress: string;
|
|
@@ -737,4 +769,4 @@ declare class IndexedDbSwapRepository implements SwapRepository {
|
|
|
737
769
|
[Symbol.asyncDispose](): Promise<void>;
|
|
738
770
|
}
|
|
739
771
|
|
|
740
|
-
export { ArkToBtcResponse, ArkadeSwapsMessageHandler as ArkadeLightningMessageHandler, ArkadeSwapsConfig, ArkadeSwapsMessageHandler, BoltzChainSwap, BoltzRefundError, BoltzReverseSwap, BoltzSubmarineSwap, BoltzSwap, BtcToArkResponse, Chain, ChainFeesResponse, CreateLightningInvoiceRequest, CreateLightningInvoiceResponse, DecodedInvoice, FeesResponse, IndexedDbSwapRepository, InsufficientFundsError, InvoiceExpiredError, InvoiceFailedToPayError, LimitsResponse, type Logger, Network, NetworkError, PreimageFetchError, SchemaError, SendLightningPaymentRequest, SendLightningPaymentResponse, ServiceWorkerArkadeSwaps as ServiceWorkerArkadeLightning, ServiceWorkerArkadeSwaps, SwapError, SwapExpiredError, SwapManagerClient, SwapRepository, type SwapSaver, TransactionFailedError, decodeInvoice, enrichReverseSwapPreimage, enrichSubmarineSwapInvoice, getInvoicePaymentHash, getInvoiceSatoshis, isValidArkAddress, logger, migrateToSwapRepository, saveSwap, setLogger, updateChainSwapStatus, updateReverseSwapStatus, updateSubmarineSwapStatus, verifySignatures };
|
|
772
|
+
export { ArkToBtcResponse, ArkadeSwapsMessageHandler as ArkadeLightningMessageHandler, ArkadeSwapsConfig, ArkadeSwapsMessageHandler, BoltzChainSwap, BoltzRefundError, BoltzReverseSwap, BoltzSubmarineSwap, BoltzSwap, BtcToArkResponse, Chain, ChainFeesResponse, CreateLightningInvoiceRequest, CreateLightningInvoiceResponse, DecodedInvoice, FeesResponse, IndexedDbSwapRepository, InsufficientFundsError, InvoiceExpiredError, InvoiceFailedToPayError, LimitsResponse, type Logger, Network, NetworkError, PreimageFetchError, SchemaError, SendLightningPaymentRequest, SendLightningPaymentResponse, ServiceWorkerArkadeSwaps as ServiceWorkerArkadeLightning, ServiceWorkerArkadeSwaps, SubmarineRecoveryInfo, SubmarineRecoveryResult, SubmarineRefundOutcome, SwapError, SwapExpiredError, SwapManagerClient, SwapRepository, type SwapSaver, TransactionFailedError, decodeInvoice, enrichReverseSwapPreimage, enrichSubmarineSwapInvoice, getInvoicePaymentHash, getInvoiceSatoshis, isValidArkAddress, logger, migrateToSwapRepository, saveSwap, setLogger, updateChainSwapStatus, updateReverseSwapStatus, updateSubmarineSwapStatus, verifySignatures };
|
package/dist/index.js
CHANGED
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
updateReverseSwapStatus,
|
|
51
51
|
updateSubmarineSwapStatus,
|
|
52
52
|
verifySignatures
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-XC2ARJZO.js";
|
|
54
54
|
import "./chunk-3RG5ZIWI.js";
|
|
55
55
|
|
|
56
56
|
// src/serviceWorker/arkade-swaps-message-handler.ts
|
|
@@ -59,6 +59,25 @@ import {
|
|
|
59
59
|
RestIndexerProvider
|
|
60
60
|
} from "@arkade-os/sdk";
|
|
61
61
|
var DEFAULT_MESSAGE_TAG = "ARKADE_SWAPS_UPDATER";
|
|
62
|
+
var LONG_RUNNING_ARKADE_SWAPS_REQUEST_TYPES = /* @__PURE__ */ new Set([
|
|
63
|
+
"SEND_LIGHTNING_PAYMENT",
|
|
64
|
+
"CLAIM_VHTLC",
|
|
65
|
+
"REFUND_VHTLC",
|
|
66
|
+
"INSPECT_SUBMARINE_RECOVERY",
|
|
67
|
+
"SCAN_RECOVERABLE_SUBMARINE_SWAPS",
|
|
68
|
+
"RECOVER_SUBMARINE_FUNDS",
|
|
69
|
+
"RECOVER_ALL_SUBMARINE_FUNDS",
|
|
70
|
+
"WAIT_AND_CLAIM",
|
|
71
|
+
"WAIT_FOR_SWAP_SETTLEMENT",
|
|
72
|
+
"RESTORE_SWAPS",
|
|
73
|
+
"WAIT_AND_CLAIM_CHAIN",
|
|
74
|
+
"WAIT_AND_CLAIM_ARK",
|
|
75
|
+
"WAIT_AND_CLAIM_BTC",
|
|
76
|
+
"CLAIM_ARK",
|
|
77
|
+
"CLAIM_BTC",
|
|
78
|
+
"REFUND_ARK",
|
|
79
|
+
"SM-WAIT_FOR_COMPLETION"
|
|
80
|
+
]);
|
|
62
81
|
var ArkadeSwapsMessageHandler = class _ArkadeSwapsMessageHandler {
|
|
63
82
|
constructor(swapRepository) {
|
|
64
83
|
this.swapRepository = swapRepository;
|
|
@@ -100,6 +119,14 @@ var ArkadeSwapsMessageHandler = class _ArkadeSwapsMessageHandler {
|
|
|
100
119
|
async tick(_now) {
|
|
101
120
|
return [];
|
|
102
121
|
}
|
|
122
|
+
// Flows that surrender control to Boltz, the Ark server, or other
|
|
123
|
+
// participants in a batch round: quiet gaps between protocol events can
|
|
124
|
+
// easily exceed the bus-level messageTimeoutMs. Liveness is covered
|
|
125
|
+
// out-of-band by the page-side PING / MESSAGE_BUS_NOT_INITIALIZED path
|
|
126
|
+
// triggered by concurrent short requests (GET_FEES, GET_SWAP_STATUS, ...).
|
|
127
|
+
isLongRunning(message) {
|
|
128
|
+
return LONG_RUNNING_ARKADE_SWAPS_REQUEST_TYPES.has(message.type);
|
|
129
|
+
}
|
|
103
130
|
tagged(res) {
|
|
104
131
|
return {
|
|
105
132
|
...res,
|
|
@@ -181,9 +208,54 @@ var ArkadeSwapsMessageHandler = class _ArkadeSwapsMessageHandler {
|
|
|
181
208
|
case "CLAIM_VHTLC":
|
|
182
209
|
await this.handler.claimVHTLC(message.payload);
|
|
183
210
|
return this.tagged({ id, type: "VHTLC_CLAIMED" });
|
|
184
|
-
case "REFUND_VHTLC":
|
|
185
|
-
await this.handler.refundVHTLC(
|
|
186
|
-
|
|
211
|
+
case "REFUND_VHTLC": {
|
|
212
|
+
const outcome = await this.handler.refundVHTLC(
|
|
213
|
+
message.payload
|
|
214
|
+
);
|
|
215
|
+
return this.tagged({
|
|
216
|
+
id,
|
|
217
|
+
type: "VHTLC_REFUNDED",
|
|
218
|
+
payload: outcome
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
case "INSPECT_SUBMARINE_RECOVERY": {
|
|
222
|
+
const info = await this.handler.inspectSubmarineRecovery(
|
|
223
|
+
message.payload
|
|
224
|
+
);
|
|
225
|
+
return this.tagged({
|
|
226
|
+
id,
|
|
227
|
+
type: "SUBMARINE_RECOVERY_INSPECTED",
|
|
228
|
+
payload: info
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
case "SCAN_RECOVERABLE_SUBMARINE_SWAPS": {
|
|
232
|
+
const infos = await this.handler.scanRecoverableSubmarineSwaps();
|
|
233
|
+
return this.tagged({
|
|
234
|
+
id,
|
|
235
|
+
type: "RECOVERABLE_SUBMARINE_SWAPS_SCANNED",
|
|
236
|
+
payload: infos
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
case "RECOVER_SUBMARINE_FUNDS": {
|
|
240
|
+
const outcome = await this.handler.recoverSubmarineFunds(
|
|
241
|
+
message.payload
|
|
242
|
+
);
|
|
243
|
+
return this.tagged({
|
|
244
|
+
id,
|
|
245
|
+
type: "SUBMARINE_FUNDS_RECOVERED",
|
|
246
|
+
payload: outcome
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
case "RECOVER_ALL_SUBMARINE_FUNDS": {
|
|
250
|
+
const results = await this.handler.recoverAllSubmarineFunds(
|
|
251
|
+
message.payload
|
|
252
|
+
);
|
|
253
|
+
return this.tagged({
|
|
254
|
+
id,
|
|
255
|
+
type: "ALL_SUBMARINE_FUNDS_RECOVERED",
|
|
256
|
+
payload: results
|
|
257
|
+
});
|
|
258
|
+
}
|
|
187
259
|
case "WAIT_AND_CLAIM": {
|
|
188
260
|
const res = await this.handler.waitAndClaim(
|
|
189
261
|
message.payload
|
|
@@ -534,6 +606,8 @@ import {
|
|
|
534
606
|
function isMessageBusNotInitializedError(error) {
|
|
535
607
|
return error instanceof Error && error.message.includes(MESSAGE_BUS_NOT_INITIALIZED);
|
|
536
608
|
}
|
|
609
|
+
var DEFAULT_MESSAGE_TIMEOUT_MS = 3e4;
|
|
610
|
+
var NO_MESSAGE_TIMEOUT_MS = 0;
|
|
537
611
|
var DEDUPABLE_REQUEST_TYPES = /* @__PURE__ */ new Set([
|
|
538
612
|
"GET_FEES",
|
|
539
613
|
"GET_LIMITS",
|
|
@@ -809,12 +883,48 @@ var ServiceWorkerArkadeSwaps = class _ServiceWorkerArkadeSwaps {
|
|
|
809
883
|
});
|
|
810
884
|
}
|
|
811
885
|
async refundVHTLC(pendingSwap) {
|
|
812
|
-
await this.sendMessage({
|
|
886
|
+
const res = await this.sendMessage({
|
|
813
887
|
id: getRandomId(),
|
|
814
888
|
tag: this.messageTag,
|
|
815
889
|
type: "REFUND_VHTLC",
|
|
816
890
|
payload: pendingSwap
|
|
817
891
|
});
|
|
892
|
+
return res.payload;
|
|
893
|
+
}
|
|
894
|
+
async inspectSubmarineRecovery(swap) {
|
|
895
|
+
const res = await this.sendMessage({
|
|
896
|
+
id: getRandomId(),
|
|
897
|
+
tag: this.messageTag,
|
|
898
|
+
type: "INSPECT_SUBMARINE_RECOVERY",
|
|
899
|
+
payload: swap
|
|
900
|
+
});
|
|
901
|
+
return res.payload;
|
|
902
|
+
}
|
|
903
|
+
async scanRecoverableSubmarineSwaps() {
|
|
904
|
+
const res = await this.sendMessage({
|
|
905
|
+
id: getRandomId(),
|
|
906
|
+
tag: this.messageTag,
|
|
907
|
+
type: "SCAN_RECOVERABLE_SUBMARINE_SWAPS"
|
|
908
|
+
});
|
|
909
|
+
return res.payload;
|
|
910
|
+
}
|
|
911
|
+
async recoverSubmarineFunds(swap) {
|
|
912
|
+
const res = await this.sendMessage({
|
|
913
|
+
id: getRandomId(),
|
|
914
|
+
tag: this.messageTag,
|
|
915
|
+
type: "RECOVER_SUBMARINE_FUNDS",
|
|
916
|
+
payload: swap
|
|
917
|
+
});
|
|
918
|
+
return res.payload;
|
|
919
|
+
}
|
|
920
|
+
async recoverAllSubmarineFunds(swaps) {
|
|
921
|
+
const res = await this.sendMessage({
|
|
922
|
+
id: getRandomId(),
|
|
923
|
+
tag: this.messageTag,
|
|
924
|
+
type: "RECOVER_ALL_SUBMARINE_FUNDS",
|
|
925
|
+
payload: swaps
|
|
926
|
+
});
|
|
927
|
+
return res.payload;
|
|
818
928
|
}
|
|
819
929
|
async waitAndClaim(pendingSwap) {
|
|
820
930
|
try {
|
|
@@ -1143,7 +1253,7 @@ var ServiceWorkerArkadeSwaps = class _ServiceWorkerArkadeSwaps {
|
|
|
1143
1253
|
async [Symbol.asyncDispose]() {
|
|
1144
1254
|
return this.dispose();
|
|
1145
1255
|
}
|
|
1146
|
-
sendMessageDirect(request) {
|
|
1256
|
+
sendMessageDirect(request, timeoutMs) {
|
|
1147
1257
|
return new Promise((resolve, reject) => {
|
|
1148
1258
|
const cleanup = () => {
|
|
1149
1259
|
clearTimeout(timeoutId);
|
|
@@ -1152,14 +1262,14 @@ var ServiceWorkerArkadeSwaps = class _ServiceWorkerArkadeSwaps {
|
|
|
1152
1262
|
messageHandler
|
|
1153
1263
|
);
|
|
1154
1264
|
};
|
|
1155
|
-
const timeoutId = setTimeout(() => {
|
|
1265
|
+
const timeoutId = timeoutMs > 0 ? setTimeout(() => {
|
|
1156
1266
|
cleanup();
|
|
1157
1267
|
reject(
|
|
1158
1268
|
new ServiceWorkerTimeoutError(
|
|
1159
1269
|
`Service worker message timed out (${request.type})`
|
|
1160
1270
|
)
|
|
1161
1271
|
);
|
|
1162
|
-
},
|
|
1272
|
+
}, timeoutMs) : void 0;
|
|
1163
1273
|
const messageHandler = (event) => {
|
|
1164
1274
|
const response = event.data;
|
|
1165
1275
|
if (!response || response.tag !== this.messageTag || response.id !== request.id) {
|
|
@@ -1234,10 +1344,13 @@ var ServiceWorkerArkadeSwaps = class _ServiceWorkerArkadeSwaps {
|
|
|
1234
1344
|
await this.reinitialize();
|
|
1235
1345
|
}
|
|
1236
1346
|
}
|
|
1347
|
+
const timeoutMs = LONG_RUNNING_ARKADE_SWAPS_REQUEST_TYPES.has(
|
|
1348
|
+
request.type
|
|
1349
|
+
) ? NO_MESSAGE_TIMEOUT_MS : DEFAULT_MESSAGE_TIMEOUT_MS;
|
|
1237
1350
|
const maxRetries = 2;
|
|
1238
1351
|
for (let attempt = 0; ; attempt++) {
|
|
1239
1352
|
try {
|
|
1240
|
-
return await this.sendMessageDirect(request);
|
|
1353
|
+
return await this.sendMessageDirect(request, timeoutMs);
|
|
1241
1354
|
} catch (error) {
|
|
1242
1355
|
if (!isMessageBusNotInitializedError(error) || attempt >= maxRetries) {
|
|
1243
1356
|
throw error;
|
|
@@ -1258,7 +1371,10 @@ var ServiceWorkerArkadeSwaps = class _ServiceWorkerArkadeSwaps {
|
|
|
1258
1371
|
id: getRandomId(),
|
|
1259
1372
|
payload: this.initPayload
|
|
1260
1373
|
};
|
|
1261
|
-
await this.sendMessageDirect(
|
|
1374
|
+
await this.sendMessageDirect(
|
|
1375
|
+
initMessage,
|
|
1376
|
+
DEFAULT_MESSAGE_TIMEOUT_MS
|
|
1377
|
+
);
|
|
1262
1378
|
})().finally(() => {
|
|
1263
1379
|
this.reinitPromise = null;
|
|
1264
1380
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SQLExecutor } from '@arkade-os/sdk/repositories/sqlite';
|
|
2
|
-
import {
|
|
2
|
+
import { m as SwapRepository, B as BoltzSwap, o as GetSwapsFilter } from '../../types-LCXS1AVA.cjs';
|
|
3
3
|
import '@arkade-os/sdk';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SQLExecutor } from '@arkade-os/sdk/repositories/sqlite';
|
|
2
|
-
import {
|
|
2
|
+
import { m as SwapRepository, B as BoltzSwap, o as GetSwapsFilter } from '../../types-LCXS1AVA.js';
|
|
3
3
|
import '@arkade-os/sdk';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -856,6 +856,68 @@ interface BoltzSubmarineSwap {
|
|
|
856
856
|
/** Boltz API response with payment address and expected amount. */
|
|
857
857
|
response: CreateSubmarineSwapResponse;
|
|
858
858
|
}
|
|
859
|
+
/**
|
|
860
|
+
* Outcome of inspecting a submarine swap's lockup address for recoverable
|
|
861
|
+
* funds.
|
|
862
|
+
*
|
|
863
|
+
* - `recoverable` — unspent VTXOs exist and can be swept now, either because
|
|
864
|
+
* the refund CLTV has elapsed or because the Boltz 3-of-3 refund path is
|
|
865
|
+
* immediately available.
|
|
866
|
+
* - `pre_cltv` — unspent VTXOs exist but the refund locktime has not
|
|
867
|
+
* passed yet and no immediate Boltz 3-of-3 refund path was detected.
|
|
868
|
+
* - `none` — no unspent VTXOs at the address (never funded, fully
|
|
869
|
+
* pruned, or only preconfirmed-only state).
|
|
870
|
+
* - `already_spent` — the address has VTXOs but every one is spent
|
|
871
|
+
* (typical for a healthy completed swap).
|
|
872
|
+
* - `invalid_swap` — the swap is not a recovery candidate (pending
|
|
873
|
+
* status), the swap data is incomplete, or the reconstructed VHTLC
|
|
874
|
+
* address doesn't match the one Boltz returned.
|
|
875
|
+
*/
|
|
876
|
+
type SubmarineRecoveryStatus = "recoverable" | "pre_cltv" | "none" | "already_spent" | "invalid_swap";
|
|
877
|
+
/** Diagnostic snapshot of a submarine swap's recovery state. */
|
|
878
|
+
interface SubmarineRecoveryInfo {
|
|
879
|
+
/** The submarine swap this snapshot describes. */
|
|
880
|
+
swap: BoltzSubmarineSwap;
|
|
881
|
+
/** Classification of the lockup address state. */
|
|
882
|
+
status: SubmarineRecoveryStatus;
|
|
883
|
+
/** Number of unspent VTXOs at the lockup address. */
|
|
884
|
+
vtxoCount: number;
|
|
885
|
+
/** Total satoshis across the unspent VTXOs. */
|
|
886
|
+
amountSats: number;
|
|
887
|
+
/**
|
|
888
|
+
* Absolute Unix-timestamp CLTV from the swap's VHTLC, when available.
|
|
889
|
+
* Compared against wall-clock seconds for refund readiness.
|
|
890
|
+
*/
|
|
891
|
+
refundLocktime?: number;
|
|
892
|
+
/** Reason populated when `status === "invalid_swap"`. */
|
|
893
|
+
error?: string;
|
|
894
|
+
}
|
|
895
|
+
/** Outcome of a single `refundVHTLC` call: how many VTXOs were swept vs. deferred. */
|
|
896
|
+
interface SubmarineRefundOutcome {
|
|
897
|
+
/** Number of VTXOs successfully refunded (joined a batch or via Boltz co-sign). */
|
|
898
|
+
swept: number;
|
|
899
|
+
/**
|
|
900
|
+
* Number of VTXOs that could not be refunded yet (e.g. recoverable VTXO
|
|
901
|
+
* pre-CLTV, or Boltz rejected and CLTV still not satisfied). The caller
|
|
902
|
+
* is expected to retry these later.
|
|
903
|
+
*/
|
|
904
|
+
skipped: number;
|
|
905
|
+
}
|
|
906
|
+
/** Per-swap outcome of a bulk recovery call. */
|
|
907
|
+
interface SubmarineRecoveryResult {
|
|
908
|
+
/** ID of the swap whose VHTLC we attempted to refund. */
|
|
909
|
+
swapId: string;
|
|
910
|
+
/** True only when at least one VTXO was actually swept by `refundVHTLC`. */
|
|
911
|
+
recovered: boolean;
|
|
912
|
+
/**
|
|
913
|
+
* True when `refundVHTLC` returned without throwing but at least one
|
|
914
|
+
* VTXO was deferred — distinguishes a real sweep from a no-op skip
|
|
915
|
+
* path. Always false when `error` is set (the error supersedes).
|
|
916
|
+
*/
|
|
917
|
+
skipped: boolean;
|
|
918
|
+
/** Failure message when `refundVHTLC` threw. */
|
|
919
|
+
error?: string;
|
|
920
|
+
}
|
|
859
921
|
/** Tracks an in-progress chain swap (ARK ↔ BTC). */
|
|
860
922
|
interface BoltzChainSwap {
|
|
861
923
|
/** Unique swap ID from Boltz. */
|
|
@@ -999,4 +1061,4 @@ interface ChainFeesResponse {
|
|
|
999
1061
|
};
|
|
1000
1062
|
}
|
|
1001
1063
|
|
|
1002
|
-
export { type
|
|
1064
|
+
export { type PendingSubmarineSwap as $, type ArkadeSwapsConfig as A, type BoltzSwap as B, type CreateLightningInvoiceRequest as C, type DecodedInvoice as D, isPendingChainSwap as E, type FeesResponse as F, type GetSwapStatusResponse as G, isPendingReverseSwap as H, isPendingSubmarineSwap as I, isReverseClaimableStatus as J, isReverseFailedStatus as K, type LimitsResponse as L, isReverseFinalStatus as M, type Network as N, isReversePendingStatus as O, isReverseSuccessStatus as P, isReverseSwapClaimable as Q, isSubmarineFailedStatus as R, type SendLightningPaymentRequest as S, isSubmarineFinalStatus as T, isSubmarinePendingStatus as U, isSubmarineSuccessStatus as V, isSubmarineRefundableStatus as W, isSubmarineSwapRefundable as X, SwapManager as Y, type IncomingPaymentSubscription as Z, type ArkadeSwapsCreateConfig as _, type BoltzChainSwap as a, type PendingReverseSwap as a0, type PendingChainSwap as a1, type PendingSwap as a2, type Vtxo as a3, type SubmarineRecoveryStatus as a4, type SwapManagerConfig as a5, type SwapManagerEvents as a6, type SwapManagerCallbacks as a7, type BoltzReverseSwap as b, type BoltzSubmarineSwap as c, type Chain as d, type CreateLightningInvoiceResponse as e, type SendLightningPaymentResponse as f, type SubmarineRefundOutcome as g, type SubmarineRecoveryInfo as h, type SubmarineRecoveryResult as i, type ChainFeesResponse as j, type ArkToBtcResponse as k, type BtcToArkResponse as l, type SwapRepository as m, type SwapManagerClient as n, type GetSwapsFilter as o, BoltzSwapProvider as p, type BoltzSwapStatus as q, isChainClaimableStatus as r, isChainFailedStatus as s, isChainFinalStatus as t, isChainPendingStatus as u, isChainRefundableStatus as v, isChainSignableStatus as w, isChainSuccessStatus as x, isChainSwapClaimable as y, isChainSwapRefundable as z };
|
|
@@ -856,6 +856,68 @@ interface BoltzSubmarineSwap {
|
|
|
856
856
|
/** Boltz API response with payment address and expected amount. */
|
|
857
857
|
response: CreateSubmarineSwapResponse;
|
|
858
858
|
}
|
|
859
|
+
/**
|
|
860
|
+
* Outcome of inspecting a submarine swap's lockup address for recoverable
|
|
861
|
+
* funds.
|
|
862
|
+
*
|
|
863
|
+
* - `recoverable` — unspent VTXOs exist and can be swept now, either because
|
|
864
|
+
* the refund CLTV has elapsed or because the Boltz 3-of-3 refund path is
|
|
865
|
+
* immediately available.
|
|
866
|
+
* - `pre_cltv` — unspent VTXOs exist but the refund locktime has not
|
|
867
|
+
* passed yet and no immediate Boltz 3-of-3 refund path was detected.
|
|
868
|
+
* - `none` — no unspent VTXOs at the address (never funded, fully
|
|
869
|
+
* pruned, or only preconfirmed-only state).
|
|
870
|
+
* - `already_spent` — the address has VTXOs but every one is spent
|
|
871
|
+
* (typical for a healthy completed swap).
|
|
872
|
+
* - `invalid_swap` — the swap is not a recovery candidate (pending
|
|
873
|
+
* status), the swap data is incomplete, or the reconstructed VHTLC
|
|
874
|
+
* address doesn't match the one Boltz returned.
|
|
875
|
+
*/
|
|
876
|
+
type SubmarineRecoveryStatus = "recoverable" | "pre_cltv" | "none" | "already_spent" | "invalid_swap";
|
|
877
|
+
/** Diagnostic snapshot of a submarine swap's recovery state. */
|
|
878
|
+
interface SubmarineRecoveryInfo {
|
|
879
|
+
/** The submarine swap this snapshot describes. */
|
|
880
|
+
swap: BoltzSubmarineSwap;
|
|
881
|
+
/** Classification of the lockup address state. */
|
|
882
|
+
status: SubmarineRecoveryStatus;
|
|
883
|
+
/** Number of unspent VTXOs at the lockup address. */
|
|
884
|
+
vtxoCount: number;
|
|
885
|
+
/** Total satoshis across the unspent VTXOs. */
|
|
886
|
+
amountSats: number;
|
|
887
|
+
/**
|
|
888
|
+
* Absolute Unix-timestamp CLTV from the swap's VHTLC, when available.
|
|
889
|
+
* Compared against wall-clock seconds for refund readiness.
|
|
890
|
+
*/
|
|
891
|
+
refundLocktime?: number;
|
|
892
|
+
/** Reason populated when `status === "invalid_swap"`. */
|
|
893
|
+
error?: string;
|
|
894
|
+
}
|
|
895
|
+
/** Outcome of a single `refundVHTLC` call: how many VTXOs were swept vs. deferred. */
|
|
896
|
+
interface SubmarineRefundOutcome {
|
|
897
|
+
/** Number of VTXOs successfully refunded (joined a batch or via Boltz co-sign). */
|
|
898
|
+
swept: number;
|
|
899
|
+
/**
|
|
900
|
+
* Number of VTXOs that could not be refunded yet (e.g. recoverable VTXO
|
|
901
|
+
* pre-CLTV, or Boltz rejected and CLTV still not satisfied). The caller
|
|
902
|
+
* is expected to retry these later.
|
|
903
|
+
*/
|
|
904
|
+
skipped: number;
|
|
905
|
+
}
|
|
906
|
+
/** Per-swap outcome of a bulk recovery call. */
|
|
907
|
+
interface SubmarineRecoveryResult {
|
|
908
|
+
/** ID of the swap whose VHTLC we attempted to refund. */
|
|
909
|
+
swapId: string;
|
|
910
|
+
/** True only when at least one VTXO was actually swept by `refundVHTLC`. */
|
|
911
|
+
recovered: boolean;
|
|
912
|
+
/**
|
|
913
|
+
* True when `refundVHTLC` returned without throwing but at least one
|
|
914
|
+
* VTXO was deferred — distinguishes a real sweep from a no-op skip
|
|
915
|
+
* path. Always false when `error` is set (the error supersedes).
|
|
916
|
+
*/
|
|
917
|
+
skipped: boolean;
|
|
918
|
+
/** Failure message when `refundVHTLC` threw. */
|
|
919
|
+
error?: string;
|
|
920
|
+
}
|
|
859
921
|
/** Tracks an in-progress chain swap (ARK ↔ BTC). */
|
|
860
922
|
interface BoltzChainSwap {
|
|
861
923
|
/** Unique swap ID from Boltz. */
|
|
@@ -999,4 +1061,4 @@ interface ChainFeesResponse {
|
|
|
999
1061
|
};
|
|
1000
1062
|
}
|
|
1001
1063
|
|
|
1002
|
-
export { type
|
|
1064
|
+
export { type PendingSubmarineSwap as $, type ArkadeSwapsConfig as A, type BoltzSwap as B, type CreateLightningInvoiceRequest as C, type DecodedInvoice as D, isPendingChainSwap as E, type FeesResponse as F, type GetSwapStatusResponse as G, isPendingReverseSwap as H, isPendingSubmarineSwap as I, isReverseClaimableStatus as J, isReverseFailedStatus as K, type LimitsResponse as L, isReverseFinalStatus as M, type Network as N, isReversePendingStatus as O, isReverseSuccessStatus as P, isReverseSwapClaimable as Q, isSubmarineFailedStatus as R, type SendLightningPaymentRequest as S, isSubmarineFinalStatus as T, isSubmarinePendingStatus as U, isSubmarineSuccessStatus as V, isSubmarineRefundableStatus as W, isSubmarineSwapRefundable as X, SwapManager as Y, type IncomingPaymentSubscription as Z, type ArkadeSwapsCreateConfig as _, type BoltzChainSwap as a, type PendingReverseSwap as a0, type PendingChainSwap as a1, type PendingSwap as a2, type Vtxo as a3, type SubmarineRecoveryStatus as a4, type SwapManagerConfig as a5, type SwapManagerEvents as a6, type SwapManagerCallbacks as a7, type BoltzReverseSwap as b, type BoltzSubmarineSwap as c, type Chain as d, type CreateLightningInvoiceResponse as e, type SendLightningPaymentResponse as f, type SubmarineRefundOutcome as g, type SubmarineRecoveryInfo as h, type SubmarineRecoveryResult as i, type ChainFeesResponse as j, type ArkToBtcResponse as k, type BtcToArkResponse as l, type SwapRepository as m, type SwapManagerClient as n, type GetSwapsFilter as o, BoltzSwapProvider as p, type BoltzSwapStatus as q, isChainClaimableStatus as r, isChainFailedStatus as s, isChainFinalStatus as t, isChainPendingStatus as u, isChainRefundableStatus as v, isChainSignableStatus as w, isChainSuccessStatus as x, isChainSwapClaimable as y, isChainSwapRefundable as z };
|