@atomiqlabs/sdk 8.1.7 → 8.3.1
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/dist/bitcoin/wallet/BitcoinWallet.d.ts +41 -5
- package/dist/bitcoin/wallet/BitcoinWallet.js +36 -1
- package/dist/bitcoin/wallet/IBitcoinWallet.d.ts +52 -2
- package/dist/bitcoin/wallet/IBitcoinWallet.js +2 -1
- package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.d.ts +42 -7
- package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.js +36 -1
- package/dist/enums/FeeType.d.ts +7 -0
- package/dist/enums/FeeType.js +7 -0
- package/dist/enums/SwapAmountType.d.ts +7 -0
- package/dist/enums/SwapAmountType.js +7 -0
- package/dist/enums/SwapDirection.d.ts +7 -0
- package/dist/enums/SwapDirection.js +7 -0
- package/dist/enums/SwapType.d.ts +62 -1
- package/dist/enums/SwapType.js +62 -1
- package/dist/errors/IntermediaryError.d.ts +4 -0
- package/dist/errors/IntermediaryError.js +1 -0
- package/dist/errors/RequestError.d.ts +15 -1
- package/dist/errors/RequestError.js +8 -0
- package/dist/errors/UserError.d.ts +1 -0
- package/dist/errors/UserError.js +1 -0
- package/dist/index.d.ts +4 -5
- package/dist/index.js +3 -4
- package/dist/intermediaries/Intermediary.d.ts +57 -10
- package/dist/intermediaries/Intermediary.js +37 -10
- package/dist/intermediaries/IntermediaryDiscovery.d.ts +55 -22
- package/dist/intermediaries/IntermediaryDiscovery.js +35 -22
- package/dist/prices/RedundantSwapPrice.d.ts +24 -3
- package/dist/prices/RedundantSwapPrice.js +21 -1
- package/dist/prices/SingleSwapPrice.d.ts +9 -6
- package/dist/prices/SingleSwapPrice.js +10 -7
- package/dist/prices/SwapPriceWithChain.d.ts +54 -16
- package/dist/prices/SwapPriceWithChain.js +58 -20
- package/dist/prices/abstract/ISwapPrice.d.ts +94 -45
- package/dist/prices/abstract/ISwapPrice.js +103 -55
- package/dist/prices/providers/BinancePriceProvider.d.ts +7 -0
- package/dist/prices/providers/BinancePriceProvider.js +7 -0
- package/dist/prices/providers/CoinGeckoPriceProvider.d.ts +6 -0
- package/dist/prices/providers/CoinGeckoPriceProvider.js +6 -0
- package/dist/prices/providers/CoinPaprikaPriceProvider.d.ts +6 -0
- package/dist/prices/providers/CoinPaprikaPriceProvider.js +6 -0
- package/dist/prices/providers/CustomPriceProvider.d.ts +11 -0
- package/dist/prices/providers/CustomPriceProvider.js +11 -0
- package/dist/prices/providers/KrakenPriceProvider.d.ts +9 -0
- package/dist/prices/providers/KrakenPriceProvider.js +9 -0
- package/dist/prices/providers/OKXPriceProvider.d.ts +6 -0
- package/dist/prices/providers/OKXPriceProvider.js +6 -0
- package/dist/prices/providers/abstract/ExchangePriceProvider.d.ts +3 -0
- package/dist/prices/providers/abstract/ExchangePriceProvider.js +3 -0
- package/dist/storage/IUnifiedStorage.d.ts +19 -7
- package/dist/storage/UnifiedSwapStorage.d.ts +33 -3
- package/dist/storage/UnifiedSwapStorage.js +29 -1
- package/dist/storage-browser/IndexedDBUnifiedStorage.d.ts +31 -7
- package/dist/storage-browser/IndexedDBUnifiedStorage.js +29 -6
- package/dist/storage-browser/LocalStorageManager.d.ts +25 -1
- package/dist/storage-browser/LocalStorageManager.js +25 -1
- package/dist/swapper/Swapper.d.ts +303 -222
- package/dist/swapper/Swapper.js +376 -344
- package/dist/swapper/SwapperFactory.d.ts +41 -17
- package/dist/swapper/SwapperFactory.js +23 -2
- package/dist/swapper/SwapperUtils.d.ts +75 -28
- package/dist/swapper/SwapperUtils.js +107 -60
- package/dist/swapper/SwapperWithChain.d.ts +286 -91
- package/dist/swapper/SwapperWithChain.js +218 -64
- package/dist/swapper/SwapperWithSigner.d.ts +229 -80
- package/dist/swapper/SwapperWithSigner.js +190 -44
- package/dist/swaps/IAddressSwap.d.ts +10 -1
- package/dist/swaps/IAddressSwap.js +2 -1
- package/dist/swaps/IBTCWalletSwap.d.ts +24 -6
- package/dist/swaps/IBTCWalletSwap.js +2 -1
- package/dist/swaps/IClaimableSwap.d.ts +36 -4
- package/dist/swaps/IClaimableSwap.js +2 -1
- package/dist/swaps/IClaimableSwapWrapper.d.ts +11 -1
- package/dist/swaps/IRefundableSwap.d.ts +29 -3
- package/dist/swaps/IRefundableSwap.js +2 -1
- package/dist/swaps/ISwap.d.ts +159 -21
- package/dist/swaps/ISwap.js +90 -33
- package/dist/swaps/ISwapWithGasDrop.d.ts +6 -0
- package/dist/swaps/ISwapWithGasDrop.js +1 -0
- package/dist/swaps/ISwapWrapper.d.ts +157 -48
- package/dist/swaps/ISwapWrapper.js +130 -72
- package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.d.ts +49 -6
- package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.js +22 -12
- package/dist/swaps/escrow_swaps/IEscrowSwap.d.ts +65 -12
- package/dist/swaps/escrow_swaps/IEscrowSwap.js +38 -19
- package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.d.ts +39 -9
- package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.js +30 -21
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.d.ts +31 -15
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.js +33 -18
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.d.ts +94 -29
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.js +90 -27
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCWrapper.d.ts +22 -9
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCWrapper.js +24 -11
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.d.ts +275 -58
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.js +516 -239
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.d.ts +76 -25
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.js +131 -49
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.d.ts +311 -51
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.js +542 -193
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.d.ts +87 -26
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.js +147 -58
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.d.ts +209 -53
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.js +449 -242
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.d.ts +77 -23
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.js +116 -46
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.d.ts +197 -56
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.js +326 -189
- package/dist/swaps/escrow_swaps/tobtc/IToBTCWrapper.d.ts +30 -5
- package/dist/swaps/escrow_swaps/tobtc/IToBTCWrapper.js +44 -19
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.d.ts +60 -19
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.js +74 -31
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.d.ts +76 -50
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.js +106 -101
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.d.ts +36 -13
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.js +65 -19
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.d.ts +46 -17
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.js +82 -27
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.d.ts +328 -92
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.js +460 -219
- package/dist/swaps/spv_swaps/SpvFromBTCWrapper.d.ts +76 -24
- package/dist/swaps/spv_swaps/SpvFromBTCWrapper.js +244 -124
- package/dist/swaps/trusted/ln/LnForGasSwap.d.ts +146 -18
- package/dist/swaps/trusted/ln/LnForGasSwap.js +173 -43
- package/dist/swaps/trusted/ln/LnForGasWrapper.d.ts +29 -10
- package/dist/swaps/trusted/ln/LnForGasWrapper.js +30 -11
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.d.ts +200 -47
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.js +230 -78
- package/dist/swaps/trusted/onchain/OnchainForGasWrapper.d.ts +34 -12
- package/dist/swaps/trusted/onchain/OnchainForGasWrapper.js +33 -14
- package/dist/types/AmountData.d.ts +2 -1
- package/dist/types/CustomPriceFunction.d.ts +7 -1
- package/dist/types/SwapExecutionAction.d.ts +74 -4
- package/dist/types/SwapWithSigner.d.ts +4 -1
- package/dist/types/SwapWithSigner.js +5 -2
- package/dist/types/Token.d.ts +11 -5
- package/dist/types/Token.js +6 -3
- package/dist/types/TokenAmount.d.ts +3 -0
- package/dist/types/TokenAmount.js +2 -0
- package/dist/types/fees/Fee.d.ts +2 -1
- package/dist/types/fees/FeeBreakdown.d.ts +2 -1
- package/dist/types/fees/PercentagePPM.d.ts +2 -0
- package/dist/types/fees/PercentagePPM.js +1 -0
- package/dist/types/lnurl/LNURLPay.d.ts +14 -6
- package/dist/types/lnurl/LNURLPay.js +6 -2
- package/dist/types/lnurl/LNURLWithdraw.d.ts +12 -5
- package/dist/types/lnurl/LNURLWithdraw.js +6 -2
- package/dist/types/wallets/LightningInvoiceCreateService.d.ts +20 -0
- package/dist/types/wallets/LightningInvoiceCreateService.js +15 -0
- package/dist/types/wallets/MinimalBitcoinWalletInterface.d.ts +3 -1
- package/dist/types/wallets/MinimalLightningNetworkWalletInterface.d.ts +3 -1
- package/dist/utils/BitcoinUtils.d.ts +1 -0
- package/dist/utils/BitcoinUtils.js +5 -1
- package/dist/utils/SwapUtils.d.ts +56 -1
- package/dist/utils/SwapUtils.js +53 -1
- package/dist/utils/TokenUtils.d.ts +10 -2
- package/dist/utils/TokenUtils.js +12 -4
- package/package.json +3 -3
- package/src/bitcoin/wallet/BitcoinWallet.ts +41 -5
- package/src/bitcoin/wallet/IBitcoinWallet.ts +57 -2
- package/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts +42 -6
- package/src/enums/FeeType.ts +7 -0
- package/src/enums/SwapAmountType.ts +7 -0
- package/src/enums/SwapDirection.ts +7 -0
- package/src/enums/SwapType.ts +62 -2
- package/src/errors/IntermediaryError.ts +4 -0
- package/src/errors/RequestError.ts +15 -1
- package/src/errors/UserError.ts +1 -0
- package/src/index.ts +6 -5
- package/src/intermediaries/Intermediary.ts +57 -10
- package/src/intermediaries/IntermediaryDiscovery.ts +60 -27
- package/src/prices/RedundantSwapPrice.ts +24 -4
- package/src/prices/SingleSwapPrice.ts +10 -7
- package/src/prices/SwapPriceWithChain.ts +59 -21
- package/src/prices/abstract/ISwapPrice.ts +114 -65
- package/src/prices/providers/BinancePriceProvider.ts +7 -0
- package/src/prices/providers/CoinGeckoPriceProvider.ts +6 -0
- package/src/prices/providers/CoinPaprikaPriceProvider.ts +6 -0
- package/src/prices/providers/CustomPriceProvider.ts +11 -0
- package/src/prices/providers/KrakenPriceProvider.ts +9 -0
- package/src/prices/providers/OKXPriceProvider.ts +6 -0
- package/src/prices/providers/abstract/ExchangePriceProvider.ts +3 -0
- package/src/storage/IUnifiedStorage.ts +19 -7
- package/src/storage/UnifiedSwapStorage.ts +33 -3
- package/src/storage-browser/IndexedDBUnifiedStorage.ts +31 -8
- package/src/storage-browser/LocalStorageManager.ts +25 -1
- package/src/swapper/Swapper.ts +513 -379
- package/src/swapper/SwapperFactory.ts +44 -21
- package/src/swapper/SwapperUtils.ts +107 -60
- package/src/swapper/SwapperWithChain.ts +320 -81
- package/src/swapper/SwapperWithSigner.ts +263 -56
- package/src/swaps/IAddressSwap.ts +11 -1
- package/src/swaps/IBTCWalletSwap.ts +24 -8
- package/src/swaps/IClaimableSwap.ts +39 -4
- package/src/swaps/IClaimableSwapWrapper.ts +11 -2
- package/src/swaps/IRefundableSwap.ts +32 -3
- package/src/swaps/ISwap.ts +221 -82
- package/src/swaps/ISwapWithGasDrop.ts +6 -0
- package/src/swaps/ISwapWrapper.ts +212 -94
- package/src/swaps/escrow_swaps/IEscrowSelfInitSwap.ts +62 -18
- package/src/swaps/escrow_swaps/IEscrowSwap.ts +83 -37
- package/src/swaps/escrow_swaps/IEscrowSwapWrapper.ts +61 -30
- package/src/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.ts +37 -19
- package/src/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.ts +120 -51
- package/src/swaps/escrow_swaps/frombtc/IFromBTCWrapper.ts +24 -11
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.ts +559 -256
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.ts +155 -61
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.ts +590 -226
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts +177 -74
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.ts +470 -243
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts +141 -59
- package/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts +352 -193
- package/src/swaps/escrow_swaps/tobtc/IToBTCWrapper.ts +48 -23
- package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.ts +86 -39
- package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts +110 -110
- package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.ts +88 -33
- package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts +101 -31
- package/src/swaps/spv_swaps/SpvFromBTCSwap.ts +534 -263
- package/src/swaps/spv_swaps/SpvFromBTCWrapper.ts +289 -148
- package/src/swaps/trusted/ln/LnForGasSwap.ts +184 -45
- package/src/swaps/trusted/ln/LnForGasWrapper.ts +34 -15
- package/src/swaps/trusted/onchain/OnchainForGasSwap.ts +260 -86
- package/src/swaps/trusted/onchain/OnchainForGasWrapper.ts +41 -19
- package/src/types/AmountData.ts +2 -1
- package/src/types/CustomPriceFunction.ts +7 -1
- package/src/types/SwapExecutionAction.ts +84 -5
- package/src/types/SwapWithSigner.ts +7 -3
- package/src/types/Token.ts +12 -5
- package/src/types/TokenAmount.ts +3 -0
- package/src/types/fees/Fee.ts +2 -1
- package/src/types/fees/FeeBreakdown.ts +2 -1
- package/src/types/fees/PercentagePPM.ts +2 -0
- package/src/types/lnurl/LNURLPay.ts +14 -6
- package/src/types/lnurl/LNURLWithdraw.ts +12 -5
- package/src/types/wallets/LightningInvoiceCreateService.ts +26 -0
- package/src/types/wallets/MinimalBitcoinWalletInterface.ts +3 -1
- package/src/types/wallets/MinimalLightningNetworkWalletInterface.ts +3 -1
- package/src/utils/BitcoinUtils.ts +5 -0
- package/src/utils/SwapUtils.ts +61 -1
- package/src/utils/TokenUtils.ts +12 -4
- package/dist/bitcoin/BitcoinRpcWithAddressIndex.d.ts +0 -68
- package/dist/bitcoin/BitcoinRpcWithAddressIndex.js +0 -2
- package/dist/bitcoin/LightningNetworkApi.d.ts +0 -12
- package/dist/bitcoin/LightningNetworkApi.js +0 -2
- package/dist/bitcoin/mempool/MempoolApi.d.ts +0 -350
- package/dist/bitcoin/mempool/MempoolApi.js +0 -311
- package/dist/bitcoin/mempool/MempoolBitcoinBlock.d.ts +0 -44
- package/dist/bitcoin/mempool/MempoolBitcoinBlock.js +0 -48
- package/dist/bitcoin/mempool/MempoolBitcoinRpc.d.ts +0 -119
- package/dist/bitcoin/mempool/MempoolBitcoinRpc.js +0 -361
- package/dist/bitcoin/mempool/synchronizer/MempoolBtcRelaySynchronizer.d.ts +0 -22
- package/dist/bitcoin/mempool/synchronizer/MempoolBtcRelaySynchronizer.js +0 -105
- package/dist/errors/PaymentAuthError.d.ts +0 -11
- package/dist/errors/PaymentAuthError.js +0 -23
- package/src/errors/PaymentAuthError.ts +0 -26
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IFromBTCWrapper } from "../IFromBTCWrapper";
|
|
3
3
|
import { FromBTCSwap, FromBTCSwapState } from "./FromBTCSwap";
|
|
4
|
-
import { ChainType, ClaimEvent, InitializeEvent, RefundEvent, RelaySynchronizer, SwapData, BtcRelay, BitcoinRpcWithAddressIndex } from "@atomiqlabs/base";
|
|
4
|
+
import { ChainType, ClaimEvent, InitializeEvent, RefundEvent, RelaySynchronizer, SwapData, BtcRelay, BitcoinRpcWithAddressIndex, SwapCommitState } from "@atomiqlabs/base";
|
|
5
5
|
import { EventEmitter } from "events";
|
|
6
6
|
import { Intermediary } from "../../../../intermediaries/Intermediary";
|
|
7
7
|
import { ISwapPrice } from "../../../../prices/abstract/ISwapPrice";
|
|
@@ -29,13 +29,39 @@ export type FromBTCWrapperOptions = ISwapWrapperOptions & {
|
|
|
29
29
|
bitcoinBlocktime: number;
|
|
30
30
|
};
|
|
31
31
|
export type FromBTCDefinition<T extends ChainType> = IFromBTCSelfInitDefinition<T, FromBTCWrapper<T>, FromBTCSwap<T>>;
|
|
32
|
+
/**
|
|
33
|
+
* Legacy escrow (PrTLC) based swap for Bitcoin -> Smart chains, requires manual initiation
|
|
34
|
+
* of the swap escrow on the destination chain.
|
|
35
|
+
*
|
|
36
|
+
* @category Swaps
|
|
37
|
+
*/
|
|
32
38
|
export declare class FromBTCWrapper<T extends ChainType> extends IFromBTCWrapper<T, FromBTCDefinition<T>, FromBTCWrapperOptions> implements IClaimableSwapWrapper<FromBTCSwap<T>> {
|
|
33
|
-
readonly
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
readonly
|
|
38
|
-
|
|
39
|
+
readonly TYPE: SwapType.FROM_BTC;
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
protected readonly tickSwapState: FromBTCSwapState[];
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
readonly _pendingSwapStates: FromBTCSwapState[];
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
readonly _claimableSwapStates: FromBTCSwapState[];
|
|
52
|
+
/**
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
readonly _swapDeserializer: typeof FromBTCSwap;
|
|
56
|
+
/**
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
readonly _synchronizer: RelaySynchronizer<any, T["TX"], any>;
|
|
60
|
+
/**
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
readonly _btcRpc: BitcoinRpcWithAddressIndex<any>;
|
|
64
|
+
private readonly btcRelay;
|
|
39
65
|
/**
|
|
40
66
|
* @param chainIdentifier
|
|
41
67
|
* @param unifiedStorage Storage interface for the current environment
|
|
@@ -54,18 +80,30 @@ export declare class FromBTCWrapper<T extends ChainType> extends IFromBTCWrapper
|
|
|
54
80
|
constructor(chainIdentifier: string, unifiedStorage: UnifiedSwapStorage<T>, unifiedChainEvents: UnifiedSwapEventListener<T>, chain: T["ChainInterface"], contract: T["Contract"], prices: ISwapPrice, tokens: WrapperCtorTokens, swapDataDeserializer: new (data: any) => T["Data"], btcRelay: BtcRelay<any, T["TX"], any>, synchronizer: RelaySynchronizer<any, T["TX"], any>, btcRpc: BitcoinRpcWithAddressIndex<any>, options?: AllOptional<FromBTCWrapperOptions>, events?: EventEmitter<{
|
|
55
81
|
swapState: [ISwap];
|
|
56
82
|
}>);
|
|
57
|
-
|
|
58
|
-
|
|
83
|
+
/**
|
|
84
|
+
* @inheritDoc
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
59
87
|
protected processEventInitialize(swap: FromBTCSwap<T>, event: InitializeEvent<T["Data"]>): Promise<boolean>;
|
|
88
|
+
/**
|
|
89
|
+
* @inheritDoc
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
60
92
|
protected processEventClaim(swap: FromBTCSwap<T>, event: ClaimEvent<T["Data"]>): Promise<boolean>;
|
|
93
|
+
/**
|
|
94
|
+
* @inheritDoc
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
61
97
|
protected processEventRefund(swap: FromBTCSwap<T>, event: RefundEvent<T["Data"]>): Promise<boolean>;
|
|
62
98
|
/**
|
|
63
99
|
* Returns the swap expiry, leaving enough time for the user to send a transaction and for it to confirm
|
|
64
100
|
*
|
|
65
|
-
* @param data
|
|
66
|
-
* @param requiredConfirmations Confirmations required to
|
|
101
|
+
* @param data Swap data
|
|
102
|
+
* @param requiredConfirmations Confirmations required on the bitcoin side to settle the swap
|
|
103
|
+
*
|
|
104
|
+
* @internal
|
|
67
105
|
*/
|
|
68
|
-
|
|
106
|
+
_getOnchainSendTimeout(data: SwapData, requiredConfirmations: number): bigint;
|
|
69
107
|
/**
|
|
70
108
|
* Pre-fetches claimer (watchtower) bounty data for the swap. Doesn't throw, instead returns null and aborts the
|
|
71
109
|
* provided abortController
|
|
@@ -74,6 +112,7 @@ export declare class FromBTCWrapper<T extends ChainType> extends IFromBTCWrapper
|
|
|
74
112
|
* @param amountData
|
|
75
113
|
* @param options Options as passed to the swap creation function
|
|
76
114
|
* @param abortController
|
|
115
|
+
*
|
|
77
116
|
* @private
|
|
78
117
|
*/
|
|
79
118
|
private preFetchClaimerBounty;
|
|
@@ -82,7 +121,8 @@ export declare class FromBTCWrapper<T extends ChainType> extends IFromBTCWrapper
|
|
|
82
121
|
*
|
|
83
122
|
* @param data Parsed swap data returned from the intermediary
|
|
84
123
|
* @param options Options as passed to the swap creation function
|
|
85
|
-
* @param claimerBounty Claimer bounty data as fetched from preFetchClaimerBounty
|
|
124
|
+
* @param claimerBounty Claimer bounty data as fetched from {@link preFetchClaimerBounty} function
|
|
125
|
+
*
|
|
86
126
|
* @private
|
|
87
127
|
*/
|
|
88
128
|
private getClaimerBounty;
|
|
@@ -98,22 +138,36 @@ export declare class FromBTCWrapper<T extends ChainType> extends IFromBTCWrapper
|
|
|
98
138
|
* @param sequence Required swap sequence
|
|
99
139
|
* @param claimerBounty Claimer bount data as returned from the preFetchClaimerBounty() pre-fetch promise
|
|
100
140
|
* @param depositToken
|
|
101
|
-
*
|
|
141
|
+
*
|
|
102
142
|
* @throws {IntermediaryError} in case the response is invalid
|
|
143
|
+
*
|
|
144
|
+
* @private
|
|
103
145
|
*/
|
|
104
146
|
private verifyReturnedData;
|
|
105
147
|
/**
|
|
106
|
-
* Returns a newly created swap
|
|
148
|
+
* Returns a newly created legacy Bitcoin -> Smart chain swap using the PrTLC based escrow swap protocol,
|
|
149
|
+
* with the passed amount.
|
|
107
150
|
*
|
|
108
|
-
* @param
|
|
109
|
-
* @param amountData
|
|
110
|
-
* @param lps
|
|
111
|
-
* @param options
|
|
112
|
-
* @param additionalParams
|
|
113
|
-
* @param abortSignal
|
|
114
|
-
*/
|
|
115
|
-
create(
|
|
151
|
+
* @param recipient Smart chain signer's address on the destination chain
|
|
152
|
+
* @param amountData Amount, token and exact input/output data for to swap
|
|
153
|
+
* @param lps An array of intermediaries (LPs) to get the quotes from
|
|
154
|
+
* @param options Optional additional quote options
|
|
155
|
+
* @param additionalParams Optional additional parameters sent to the LP when creating the swap
|
|
156
|
+
* @param abortSignal Abort signal
|
|
157
|
+
*/
|
|
158
|
+
create(recipient: string, amountData: AmountData, lps: Intermediary[], options?: FromBTCOptions, additionalParams?: Record<string, any>, abortSignal?: AbortSignal): {
|
|
116
159
|
quote: Promise<FromBTCSwap<T>>;
|
|
117
160
|
intermediary: Intermediary;
|
|
118
161
|
}[];
|
|
162
|
+
/**
|
|
163
|
+
* @inheritDoc
|
|
164
|
+
*/
|
|
165
|
+
recoverFromSwapDataAndState(init: {
|
|
166
|
+
data: T["Data"];
|
|
167
|
+
getInitTxId: () => Promise<string>;
|
|
168
|
+
getTxBlock: () => Promise<{
|
|
169
|
+
blockTime: number;
|
|
170
|
+
blockHeight: number;
|
|
171
|
+
}>;
|
|
172
|
+
}, state: SwapCommitState, lp?: Intermediary): Promise<FromBTCSwap<T> | null>;
|
|
119
173
|
}
|
|
@@ -13,6 +13,12 @@ const IntermediaryAPI_1 = require("../../../../intermediaries/apis/IntermediaryA
|
|
|
13
13
|
const RequestError_1 = require("../../../../errors/RequestError");
|
|
14
14
|
const utils_1 = require("@scure/btc-signer/utils");
|
|
15
15
|
const RetryUtils_1 = require("../../../../utils/RetryUtils");
|
|
16
|
+
/**
|
|
17
|
+
* Legacy escrow (PrTLC) based swap for Bitcoin -> Smart chains, requires manual initiation
|
|
18
|
+
* of the swap escrow on the destination chain.
|
|
19
|
+
*
|
|
20
|
+
* @category Swaps
|
|
21
|
+
*/
|
|
16
22
|
class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
17
23
|
/**
|
|
18
24
|
* @param chainIdentifier
|
|
@@ -38,41 +44,65 @@ class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
|
38
44
|
minSendWindow: options?.minSendWindow ?? 30 * 60,
|
|
39
45
|
bitcoinBlocktime: options?.bitcoinBlocktime ?? 10 * 60
|
|
40
46
|
}, events);
|
|
41
|
-
this.claimableSwapStates = [FromBTCSwap_1.FromBTCSwapState.BTC_TX_CONFIRMED];
|
|
42
47
|
this.TYPE = SwapType_1.SwapType.FROM_BTC;
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
this.tickSwapState = [FromBTCSwap_1.FromBTCSwapState.PR_CREATED, FromBTCSwap_1.FromBTCSwapState.CLAIM_COMMITED, FromBTCSwap_1.FromBTCSwapState.EXPIRED];
|
|
52
|
+
/**
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
this._pendingSwapStates = [
|
|
45
56
|
FromBTCSwap_1.FromBTCSwapState.PR_CREATED,
|
|
46
57
|
FromBTCSwap_1.FromBTCSwapState.QUOTE_SOFT_EXPIRED,
|
|
47
58
|
FromBTCSwap_1.FromBTCSwapState.CLAIM_COMMITED,
|
|
48
59
|
FromBTCSwap_1.FromBTCSwapState.BTC_TX_CONFIRMED,
|
|
49
60
|
FromBTCSwap_1.FromBTCSwapState.EXPIRED
|
|
50
61
|
];
|
|
51
|
-
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
this._claimableSwapStates = [FromBTCSwap_1.FromBTCSwapState.BTC_TX_CONFIRMED];
|
|
66
|
+
/**
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
this._swapDeserializer = FromBTCSwap_1.FromBTCSwap;
|
|
52
70
|
this.btcRelay = btcRelay;
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
71
|
+
this._synchronizer = synchronizer;
|
|
72
|
+
this._btcRpc = btcRpc;
|
|
55
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* @inheritDoc
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
56
78
|
processEventInitialize(swap, event) {
|
|
57
|
-
if (swap.
|
|
58
|
-
swap.
|
|
79
|
+
if (swap._state === FromBTCSwap_1.FromBTCSwapState.PR_CREATED || swap._state === FromBTCSwap_1.FromBTCSwapState.QUOTE_SOFT_EXPIRED) {
|
|
80
|
+
swap._state = FromBTCSwap_1.FromBTCSwapState.CLAIM_COMMITED;
|
|
59
81
|
return Promise.resolve(true);
|
|
60
82
|
}
|
|
61
83
|
return Promise.resolve(false);
|
|
62
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* @inheritDoc
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
63
89
|
async processEventClaim(swap, event) {
|
|
64
|
-
if (swap.
|
|
90
|
+
if (swap._state !== FromBTCSwap_1.FromBTCSwapState.FAILED && swap._state !== FromBTCSwap_1.FromBTCSwapState.CLAIM_CLAIMED) {
|
|
65
91
|
await swap._setBitcoinTxId(buffer_1.Buffer.from(event.result, "hex").reverse().toString("hex")).catch(e => {
|
|
66
92
|
this.logger.warn("processEventClaim(): Error setting bitcoin txId: ", e);
|
|
67
93
|
});
|
|
68
|
-
swap.
|
|
94
|
+
swap._state = FromBTCSwap_1.FromBTCSwapState.CLAIM_CLAIMED;
|
|
69
95
|
return true;
|
|
70
96
|
}
|
|
71
97
|
return false;
|
|
72
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* @inheritDoc
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
73
103
|
processEventRefund(swap, event) {
|
|
74
|
-
if (swap.
|
|
75
|
-
swap.
|
|
104
|
+
if (swap._state !== FromBTCSwap_1.FromBTCSwapState.CLAIM_CLAIMED && swap._state !== FromBTCSwap_1.FromBTCSwapState.FAILED) {
|
|
105
|
+
swap._state = FromBTCSwap_1.FromBTCSwapState.FAILED;
|
|
76
106
|
return Promise.resolve(true);
|
|
77
107
|
}
|
|
78
108
|
return Promise.resolve(false);
|
|
@@ -80,11 +110,13 @@ class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
|
80
110
|
/**
|
|
81
111
|
* Returns the swap expiry, leaving enough time for the user to send a transaction and for it to confirm
|
|
82
112
|
*
|
|
83
|
-
* @param data
|
|
84
|
-
* @param requiredConfirmations Confirmations required to
|
|
113
|
+
* @param data Swap data
|
|
114
|
+
* @param requiredConfirmations Confirmations required on the bitcoin side to settle the swap
|
|
115
|
+
*
|
|
116
|
+
* @internal
|
|
85
117
|
*/
|
|
86
|
-
|
|
87
|
-
const tsDelta = (this.
|
|
118
|
+
_getOnchainSendTimeout(data, requiredConfirmations) {
|
|
119
|
+
const tsDelta = (this._options.blocksTillTxConfirms + requiredConfirmations) * this._options.bitcoinBlocktime * this._options.safetyFactor;
|
|
88
120
|
return data.getExpiry() - BigInt(tsDelta);
|
|
89
121
|
}
|
|
90
122
|
/**
|
|
@@ -95,6 +127,7 @@ class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
|
95
127
|
* @param amountData
|
|
96
128
|
* @param options Options as passed to the swap creation function
|
|
97
129
|
* @param abortController
|
|
130
|
+
*
|
|
98
131
|
* @private
|
|
99
132
|
*/
|
|
100
133
|
async preFetchClaimerBounty(signer, amountData, options, abortController) {
|
|
@@ -109,13 +142,13 @@ class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
|
109
142
|
};
|
|
110
143
|
}
|
|
111
144
|
const dummyAmount = BigInt(Math.floor(Math.random() * 0x1000000));
|
|
112
|
-
const dummySwapData = await this.
|
|
145
|
+
const dummySwapData = await this._contract.createSwapData(base_1.ChainSwapType.CHAIN, signer, signer, amountData.token, dummyAmount, this._contract.getHashForOnchain((0, Utils_1.randomBytes)(20), dummyAmount, 3).toString("hex"), this.getRandomSequence(), startTimestamp, false, true, BigInt(Math.floor(Math.random() * 0x10000)), BigInt(Math.floor(Math.random() * 0x10000)));
|
|
113
146
|
try {
|
|
114
147
|
const [feePerBlock, btcRelayData, currentBtcBlock, claimFeeRate] = await Promise.all([
|
|
115
148
|
this.btcRelay.getFeePerBlock(),
|
|
116
149
|
this.btcRelay.getTipData(),
|
|
117
|
-
this.
|
|
118
|
-
this.
|
|
150
|
+
this._btcRpc.getTipHeight(),
|
|
151
|
+
this._contract.getClaimFee(signer, dummySwapData)
|
|
119
152
|
]);
|
|
120
153
|
if (btcRelayData == null)
|
|
121
154
|
throw new Error("Btc relay not initialized!");
|
|
@@ -139,12 +172,13 @@ class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
|
139
172
|
*
|
|
140
173
|
* @param data Parsed swap data returned from the intermediary
|
|
141
174
|
* @param options Options as passed to the swap creation function
|
|
142
|
-
* @param claimerBounty Claimer bounty data as fetched from preFetchClaimerBounty
|
|
175
|
+
* @param claimerBounty Claimer bounty data as fetched from {@link preFetchClaimerBounty} function
|
|
176
|
+
*
|
|
143
177
|
* @private
|
|
144
178
|
*/
|
|
145
179
|
getClaimerBounty(data, options, claimerBounty) {
|
|
146
180
|
const tsDelta = data.getExpiry() - claimerBounty.startTimestamp;
|
|
147
|
-
const blocksDelta = tsDelta / BigInt(this.
|
|
181
|
+
const blocksDelta = tsDelta / BigInt(this._options.bitcoinBlocktime) * BigInt(options.blockSafetyFactor);
|
|
148
182
|
const totalBlock = blocksDelta + BigInt(claimerBounty.addBlock);
|
|
149
183
|
return claimerBounty.addFee + (totalBlock * claimerBounty.feePerBlock);
|
|
150
184
|
}
|
|
@@ -160,8 +194,10 @@ class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
|
160
194
|
* @param sequence Required swap sequence
|
|
161
195
|
* @param claimerBounty Claimer bount data as returned from the preFetchClaimerBounty() pre-fetch promise
|
|
162
196
|
* @param depositToken
|
|
163
|
-
*
|
|
197
|
+
*
|
|
164
198
|
* @throws {IntermediaryError} in case the response is invalid
|
|
199
|
+
*
|
|
200
|
+
* @private
|
|
165
201
|
*/
|
|
166
202
|
verifyReturnedData(signer, resp, amountData, lp, options, data, sequence, claimerBounty, depositToken) {
|
|
167
203
|
if (amountData.exactIn) {
|
|
@@ -173,7 +209,7 @@ class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
|
173
209
|
throw new IntermediaryError_1.IntermediaryError("Invalid total returned");
|
|
174
210
|
}
|
|
175
211
|
const requiredConfirmations = resp.confirmations;
|
|
176
|
-
if (requiredConfirmations > this.
|
|
212
|
+
if (requiredConfirmations > this._options.maxConfirmations)
|
|
177
213
|
throw new IntermediaryError_1.IntermediaryError("Requires too many confirmations");
|
|
178
214
|
const totalClaimerBounty = this.getClaimerBounty(data, options, claimerBounty);
|
|
179
215
|
if (data.getClaimerBounty() !== totalClaimerBounty ||
|
|
@@ -189,14 +225,14 @@ class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
|
189
225
|
throw new IntermediaryError_1.IntermediaryError("Invalid data returned");
|
|
190
226
|
}
|
|
191
227
|
//Check that we have enough time to send the TX and for it to confirm
|
|
192
|
-
const expiry = this.
|
|
228
|
+
const expiry = this._getOnchainSendTimeout(data, requiredConfirmations);
|
|
193
229
|
const currentTimestamp = BigInt(Math.floor(Date.now() / 1000));
|
|
194
|
-
if ((expiry - currentTimestamp) < BigInt(this.
|
|
230
|
+
if ((expiry - currentTimestamp) < BigInt(this._options.minSendWindow)) {
|
|
195
231
|
throw new IntermediaryError_1.IntermediaryError("Send window too low");
|
|
196
232
|
}
|
|
197
|
-
const lockingScript = (0, BitcoinUtils_1.toOutputScript)(this.
|
|
198
|
-
const desiredExtraData = this.
|
|
199
|
-
const desiredClaimHash = this.
|
|
233
|
+
const lockingScript = (0, BitcoinUtils_1.toOutputScript)(this._options.bitcoinNetwork, resp.btcAddress);
|
|
234
|
+
const desiredExtraData = this._contract.getExtraData(lockingScript, resp.amount, requiredConfirmations);
|
|
235
|
+
const desiredClaimHash = this._contract.getHashForOnchain(lockingScript, resp.amount, requiredConfirmations);
|
|
200
236
|
if (!desiredClaimHash.equals(buffer_1.Buffer.from(data.getClaimHash(), "hex"))) {
|
|
201
237
|
throw new IntermediaryError_1.IntermediaryError("Invalid claim hash returned!");
|
|
202
238
|
}
|
|
@@ -206,16 +242,17 @@ class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
|
206
242
|
}
|
|
207
243
|
}
|
|
208
244
|
/**
|
|
209
|
-
* Returns a newly created swap
|
|
245
|
+
* Returns a newly created legacy Bitcoin -> Smart chain swap using the PrTLC based escrow swap protocol,
|
|
246
|
+
* with the passed amount.
|
|
210
247
|
*
|
|
211
|
-
* @param
|
|
212
|
-
* @param amountData
|
|
213
|
-
* @param lps
|
|
214
|
-
* @param options
|
|
215
|
-
* @param additionalParams
|
|
216
|
-
* @param abortSignal
|
|
248
|
+
* @param recipient Smart chain signer's address on the destination chain
|
|
249
|
+
* @param amountData Amount, token and exact input/output data for to swap
|
|
250
|
+
* @param lps An array of intermediaries (LPs) to get the quotes from
|
|
251
|
+
* @param options Optional additional quote options
|
|
252
|
+
* @param additionalParams Optional additional parameters sent to the LP when creating the swap
|
|
253
|
+
* @param abortSignal Abort signal
|
|
217
254
|
*/
|
|
218
|
-
create(
|
|
255
|
+
create(recipient, amountData, lps, options, additionalParams, abortSignal) {
|
|
219
256
|
const _options = {
|
|
220
257
|
blockSafetyFactor: options?.blockSafetyFactor ?? 1,
|
|
221
258
|
feeSafetyFactor: options?.feeSafetyFactor ?? 2n,
|
|
@@ -225,10 +262,10 @@ class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
|
225
262
|
const _abortController = (0, Utils_1.extendAbortController)(abortSignal);
|
|
226
263
|
const pricePrefetchPromise = this.preFetchPrice(amountData, _abortController.signal);
|
|
227
264
|
const usdPricePrefetchPromise = this.preFetchUsdPrice(_abortController.signal);
|
|
228
|
-
const claimerBountyPrefetchPromise = this.preFetchClaimerBounty(
|
|
229
|
-
const nativeTokenAddress = this.
|
|
230
|
-
const feeRatePromise = this.preFetchFeeRate(
|
|
231
|
-
const _signDataPromise = this.
|
|
265
|
+
const claimerBountyPrefetchPromise = this.preFetchClaimerBounty(recipient, amountData, _options, _abortController);
|
|
266
|
+
const nativeTokenAddress = this._chain.getNativeCurrencyAddress();
|
|
267
|
+
const feeRatePromise = this.preFetchFeeRate(recipient, amountData, undefined, _abortController);
|
|
268
|
+
const _signDataPromise = this._contract.preFetchBlockDataForSignatures == null ?
|
|
232
269
|
this.preFetchSignData(Promise.resolve(true)) :
|
|
233
270
|
undefined;
|
|
234
271
|
return lps.map(lp => {
|
|
@@ -242,7 +279,7 @@ class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
|
242
279
|
try {
|
|
243
280
|
const { signDataPromise, resp } = await (0, RetryUtils_1.tryWithRetries)(async (retryCount) => {
|
|
244
281
|
const { signDataPrefetch, response } = IntermediaryAPI_1.IntermediaryAPI.initFromBTC(this.chainIdentifier, lp.url, nativeTokenAddress, {
|
|
245
|
-
claimer:
|
|
282
|
+
claimer: recipient,
|
|
246
283
|
amount: amountData.amount,
|
|
247
284
|
token: amountData.token.toString(),
|
|
248
285
|
exactOut: !amountData.exactIn,
|
|
@@ -250,19 +287,19 @@ class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
|
250
287
|
claimerBounty: (0, Utils_1.throwIfUndefined)(claimerBountyPrefetchPromise),
|
|
251
288
|
feeRate: (0, Utils_1.throwIfUndefined)(feeRatePromise),
|
|
252
289
|
additionalParams
|
|
253
|
-
}, this.
|
|
290
|
+
}, this._options.postRequestTimeout, abortController.signal, retryCount > 0 ? false : undefined);
|
|
254
291
|
return {
|
|
255
292
|
signDataPromise: _signDataPromise ?? this.preFetchSignData(signDataPrefetch),
|
|
256
293
|
resp: await response
|
|
257
294
|
};
|
|
258
295
|
}, undefined, e => e instanceof RequestError_1.RequestError, abortController.signal);
|
|
259
|
-
const data = new this.
|
|
260
|
-
data.setClaimer(
|
|
261
|
-
this.verifyReturnedData(
|
|
296
|
+
const data = new this._swapDataDeserializer(resp.data);
|
|
297
|
+
data.setClaimer(recipient);
|
|
298
|
+
this.verifyReturnedData(recipient, resp, amountData, lp, _options, data, sequence, (await claimerBountyPrefetchPromise), nativeTokenAddress);
|
|
262
299
|
const [pricingInfo, signatureExpiry] = await Promise.all([
|
|
263
300
|
//Get intermediary's liquidity
|
|
264
301
|
this.verifyReturnedPrice(lp.services[SwapType_1.SwapType.FROM_BTC], false, resp.amount, resp.total, amountData.token, {}, pricePrefetchPromise, usdPricePrefetchPromise, abortController.signal),
|
|
265
|
-
this.verifyReturnedSignature(
|
|
302
|
+
this.verifyReturnedSignature(recipient, data, resp, feeRatePromise, signDataPromise, abortController.signal),
|
|
266
303
|
this.verifyIntermediaryLiquidity(data.getAmount(), (0, Utils_1.throwIfUndefined)(liquidityPromise)),
|
|
267
304
|
]);
|
|
268
305
|
const quote = new FromBTCSwap_1.FromBTCSwap(this, {
|
|
@@ -290,5 +327,38 @@ class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
|
290
327
|
};
|
|
291
328
|
});
|
|
292
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* @inheritDoc
|
|
332
|
+
*/
|
|
333
|
+
async recoverFromSwapDataAndState(init, state, lp) {
|
|
334
|
+
const data = init.data;
|
|
335
|
+
const swapInit = {
|
|
336
|
+
pricingInfo: {
|
|
337
|
+
isValid: true,
|
|
338
|
+
satsBaseFee: 0n,
|
|
339
|
+
swapPriceUSatPerToken: 100000000000000n,
|
|
340
|
+
realPriceUSatPerToken: 100000000000000n,
|
|
341
|
+
differencePPM: 0n,
|
|
342
|
+
feePPM: 0n,
|
|
343
|
+
},
|
|
344
|
+
url: lp?.url,
|
|
345
|
+
expiry: 0,
|
|
346
|
+
swapFee: 0n,
|
|
347
|
+
swapFeeBtc: 0n,
|
|
348
|
+
feeRate: "",
|
|
349
|
+
signatureData: undefined,
|
|
350
|
+
data,
|
|
351
|
+
exactIn: false
|
|
352
|
+
};
|
|
353
|
+
const swap = new FromBTCSwap_1.FromBTCSwap(this, swapInit);
|
|
354
|
+
swap._commitTxId = await init.getInitTxId();
|
|
355
|
+
const blockData = await init.getTxBlock();
|
|
356
|
+
swap.createdAt = blockData.blockTime * 1000;
|
|
357
|
+
swap._setInitiated();
|
|
358
|
+
swap._state = FromBTCSwap_1.FromBTCSwapState.CLAIM_COMMITED;
|
|
359
|
+
await swap._sync(false, false, state);
|
|
360
|
+
await swap._save();
|
|
361
|
+
return swap;
|
|
362
|
+
}
|
|
293
363
|
}
|
|
294
364
|
exports.FromBTCWrapper = FromBTCWrapper;
|