@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.
Files changed (253) hide show
  1. package/dist/bitcoin/wallet/BitcoinWallet.d.ts +41 -5
  2. package/dist/bitcoin/wallet/BitcoinWallet.js +36 -1
  3. package/dist/bitcoin/wallet/IBitcoinWallet.d.ts +52 -2
  4. package/dist/bitcoin/wallet/IBitcoinWallet.js +2 -1
  5. package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.d.ts +42 -7
  6. package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.js +36 -1
  7. package/dist/enums/FeeType.d.ts +7 -0
  8. package/dist/enums/FeeType.js +7 -0
  9. package/dist/enums/SwapAmountType.d.ts +7 -0
  10. package/dist/enums/SwapAmountType.js +7 -0
  11. package/dist/enums/SwapDirection.d.ts +7 -0
  12. package/dist/enums/SwapDirection.js +7 -0
  13. package/dist/enums/SwapType.d.ts +62 -1
  14. package/dist/enums/SwapType.js +62 -1
  15. package/dist/errors/IntermediaryError.d.ts +4 -0
  16. package/dist/errors/IntermediaryError.js +1 -0
  17. package/dist/errors/RequestError.d.ts +15 -1
  18. package/dist/errors/RequestError.js +8 -0
  19. package/dist/errors/UserError.d.ts +1 -0
  20. package/dist/errors/UserError.js +1 -0
  21. package/dist/index.d.ts +4 -5
  22. package/dist/index.js +3 -4
  23. package/dist/intermediaries/Intermediary.d.ts +57 -10
  24. package/dist/intermediaries/Intermediary.js +37 -10
  25. package/dist/intermediaries/IntermediaryDiscovery.d.ts +55 -22
  26. package/dist/intermediaries/IntermediaryDiscovery.js +35 -22
  27. package/dist/prices/RedundantSwapPrice.d.ts +24 -3
  28. package/dist/prices/RedundantSwapPrice.js +21 -1
  29. package/dist/prices/SingleSwapPrice.d.ts +9 -6
  30. package/dist/prices/SingleSwapPrice.js +10 -7
  31. package/dist/prices/SwapPriceWithChain.d.ts +54 -16
  32. package/dist/prices/SwapPriceWithChain.js +58 -20
  33. package/dist/prices/abstract/ISwapPrice.d.ts +94 -45
  34. package/dist/prices/abstract/ISwapPrice.js +103 -55
  35. package/dist/prices/providers/BinancePriceProvider.d.ts +7 -0
  36. package/dist/prices/providers/BinancePriceProvider.js +7 -0
  37. package/dist/prices/providers/CoinGeckoPriceProvider.d.ts +6 -0
  38. package/dist/prices/providers/CoinGeckoPriceProvider.js +6 -0
  39. package/dist/prices/providers/CoinPaprikaPriceProvider.d.ts +6 -0
  40. package/dist/prices/providers/CoinPaprikaPriceProvider.js +6 -0
  41. package/dist/prices/providers/CustomPriceProvider.d.ts +11 -0
  42. package/dist/prices/providers/CustomPriceProvider.js +11 -0
  43. package/dist/prices/providers/KrakenPriceProvider.d.ts +9 -0
  44. package/dist/prices/providers/KrakenPriceProvider.js +9 -0
  45. package/dist/prices/providers/OKXPriceProvider.d.ts +6 -0
  46. package/dist/prices/providers/OKXPriceProvider.js +6 -0
  47. package/dist/prices/providers/abstract/ExchangePriceProvider.d.ts +3 -0
  48. package/dist/prices/providers/abstract/ExchangePriceProvider.js +3 -0
  49. package/dist/storage/IUnifiedStorage.d.ts +19 -7
  50. package/dist/storage/UnifiedSwapStorage.d.ts +33 -3
  51. package/dist/storage/UnifiedSwapStorage.js +29 -1
  52. package/dist/storage-browser/IndexedDBUnifiedStorage.d.ts +31 -7
  53. package/dist/storage-browser/IndexedDBUnifiedStorage.js +29 -6
  54. package/dist/storage-browser/LocalStorageManager.d.ts +25 -1
  55. package/dist/storage-browser/LocalStorageManager.js +25 -1
  56. package/dist/swapper/Swapper.d.ts +303 -222
  57. package/dist/swapper/Swapper.js +376 -344
  58. package/dist/swapper/SwapperFactory.d.ts +41 -17
  59. package/dist/swapper/SwapperFactory.js +23 -2
  60. package/dist/swapper/SwapperUtils.d.ts +75 -28
  61. package/dist/swapper/SwapperUtils.js +107 -60
  62. package/dist/swapper/SwapperWithChain.d.ts +286 -91
  63. package/dist/swapper/SwapperWithChain.js +218 -64
  64. package/dist/swapper/SwapperWithSigner.d.ts +229 -80
  65. package/dist/swapper/SwapperWithSigner.js +190 -44
  66. package/dist/swaps/IAddressSwap.d.ts +10 -1
  67. package/dist/swaps/IAddressSwap.js +2 -1
  68. package/dist/swaps/IBTCWalletSwap.d.ts +24 -6
  69. package/dist/swaps/IBTCWalletSwap.js +2 -1
  70. package/dist/swaps/IClaimableSwap.d.ts +36 -4
  71. package/dist/swaps/IClaimableSwap.js +2 -1
  72. package/dist/swaps/IClaimableSwapWrapper.d.ts +11 -1
  73. package/dist/swaps/IRefundableSwap.d.ts +29 -3
  74. package/dist/swaps/IRefundableSwap.js +2 -1
  75. package/dist/swaps/ISwap.d.ts +159 -21
  76. package/dist/swaps/ISwap.js +90 -33
  77. package/dist/swaps/ISwapWithGasDrop.d.ts +6 -0
  78. package/dist/swaps/ISwapWithGasDrop.js +1 -0
  79. package/dist/swaps/ISwapWrapper.d.ts +157 -48
  80. package/dist/swaps/ISwapWrapper.js +130 -72
  81. package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.d.ts +49 -6
  82. package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.js +22 -12
  83. package/dist/swaps/escrow_swaps/IEscrowSwap.d.ts +65 -12
  84. package/dist/swaps/escrow_swaps/IEscrowSwap.js +38 -19
  85. package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.d.ts +39 -9
  86. package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.js +30 -21
  87. package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.d.ts +31 -15
  88. package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.js +33 -18
  89. package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.d.ts +94 -29
  90. package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.js +90 -27
  91. package/dist/swaps/escrow_swaps/frombtc/IFromBTCWrapper.d.ts +22 -9
  92. package/dist/swaps/escrow_swaps/frombtc/IFromBTCWrapper.js +24 -11
  93. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.d.ts +275 -58
  94. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.js +516 -239
  95. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.d.ts +76 -25
  96. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.js +131 -49
  97. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.d.ts +311 -51
  98. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.js +542 -193
  99. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.d.ts +87 -26
  100. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.js +147 -58
  101. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.d.ts +209 -53
  102. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.js +449 -242
  103. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.d.ts +77 -23
  104. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.js +116 -46
  105. package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.d.ts +197 -56
  106. package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.js +326 -189
  107. package/dist/swaps/escrow_swaps/tobtc/IToBTCWrapper.d.ts +30 -5
  108. package/dist/swaps/escrow_swaps/tobtc/IToBTCWrapper.js +44 -19
  109. package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.d.ts +60 -19
  110. package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.js +74 -31
  111. package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.d.ts +76 -50
  112. package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.js +106 -101
  113. package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.d.ts +36 -13
  114. package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.js +65 -19
  115. package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.d.ts +46 -17
  116. package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.js +82 -27
  117. package/dist/swaps/spv_swaps/SpvFromBTCSwap.d.ts +328 -92
  118. package/dist/swaps/spv_swaps/SpvFromBTCSwap.js +460 -219
  119. package/dist/swaps/spv_swaps/SpvFromBTCWrapper.d.ts +76 -24
  120. package/dist/swaps/spv_swaps/SpvFromBTCWrapper.js +244 -124
  121. package/dist/swaps/trusted/ln/LnForGasSwap.d.ts +146 -18
  122. package/dist/swaps/trusted/ln/LnForGasSwap.js +173 -43
  123. package/dist/swaps/trusted/ln/LnForGasWrapper.d.ts +29 -10
  124. package/dist/swaps/trusted/ln/LnForGasWrapper.js +30 -11
  125. package/dist/swaps/trusted/onchain/OnchainForGasSwap.d.ts +200 -47
  126. package/dist/swaps/trusted/onchain/OnchainForGasSwap.js +230 -78
  127. package/dist/swaps/trusted/onchain/OnchainForGasWrapper.d.ts +34 -12
  128. package/dist/swaps/trusted/onchain/OnchainForGasWrapper.js +33 -14
  129. package/dist/types/AmountData.d.ts +2 -1
  130. package/dist/types/CustomPriceFunction.d.ts +7 -1
  131. package/dist/types/SwapExecutionAction.d.ts +74 -4
  132. package/dist/types/SwapWithSigner.d.ts +4 -1
  133. package/dist/types/SwapWithSigner.js +5 -2
  134. package/dist/types/Token.d.ts +11 -5
  135. package/dist/types/Token.js +6 -3
  136. package/dist/types/TokenAmount.d.ts +3 -0
  137. package/dist/types/TokenAmount.js +2 -0
  138. package/dist/types/fees/Fee.d.ts +2 -1
  139. package/dist/types/fees/FeeBreakdown.d.ts +2 -1
  140. package/dist/types/fees/PercentagePPM.d.ts +2 -0
  141. package/dist/types/fees/PercentagePPM.js +1 -0
  142. package/dist/types/lnurl/LNURLPay.d.ts +14 -6
  143. package/dist/types/lnurl/LNURLPay.js +6 -2
  144. package/dist/types/lnurl/LNURLWithdraw.d.ts +12 -5
  145. package/dist/types/lnurl/LNURLWithdraw.js +6 -2
  146. package/dist/types/wallets/LightningInvoiceCreateService.d.ts +20 -0
  147. package/dist/types/wallets/LightningInvoiceCreateService.js +15 -0
  148. package/dist/types/wallets/MinimalBitcoinWalletInterface.d.ts +3 -1
  149. package/dist/types/wallets/MinimalLightningNetworkWalletInterface.d.ts +3 -1
  150. package/dist/utils/BitcoinUtils.d.ts +1 -0
  151. package/dist/utils/BitcoinUtils.js +5 -1
  152. package/dist/utils/SwapUtils.d.ts +56 -1
  153. package/dist/utils/SwapUtils.js +53 -1
  154. package/dist/utils/TokenUtils.d.ts +10 -2
  155. package/dist/utils/TokenUtils.js +12 -4
  156. package/package.json +3 -3
  157. package/src/bitcoin/wallet/BitcoinWallet.ts +41 -5
  158. package/src/bitcoin/wallet/IBitcoinWallet.ts +57 -2
  159. package/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts +42 -6
  160. package/src/enums/FeeType.ts +7 -0
  161. package/src/enums/SwapAmountType.ts +7 -0
  162. package/src/enums/SwapDirection.ts +7 -0
  163. package/src/enums/SwapType.ts +62 -2
  164. package/src/errors/IntermediaryError.ts +4 -0
  165. package/src/errors/RequestError.ts +15 -1
  166. package/src/errors/UserError.ts +1 -0
  167. package/src/index.ts +6 -5
  168. package/src/intermediaries/Intermediary.ts +57 -10
  169. package/src/intermediaries/IntermediaryDiscovery.ts +60 -27
  170. package/src/prices/RedundantSwapPrice.ts +24 -4
  171. package/src/prices/SingleSwapPrice.ts +10 -7
  172. package/src/prices/SwapPriceWithChain.ts +59 -21
  173. package/src/prices/abstract/ISwapPrice.ts +114 -65
  174. package/src/prices/providers/BinancePriceProvider.ts +7 -0
  175. package/src/prices/providers/CoinGeckoPriceProvider.ts +6 -0
  176. package/src/prices/providers/CoinPaprikaPriceProvider.ts +6 -0
  177. package/src/prices/providers/CustomPriceProvider.ts +11 -0
  178. package/src/prices/providers/KrakenPriceProvider.ts +9 -0
  179. package/src/prices/providers/OKXPriceProvider.ts +6 -0
  180. package/src/prices/providers/abstract/ExchangePriceProvider.ts +3 -0
  181. package/src/storage/IUnifiedStorage.ts +19 -7
  182. package/src/storage/UnifiedSwapStorage.ts +33 -3
  183. package/src/storage-browser/IndexedDBUnifiedStorage.ts +31 -8
  184. package/src/storage-browser/LocalStorageManager.ts +25 -1
  185. package/src/swapper/Swapper.ts +513 -379
  186. package/src/swapper/SwapperFactory.ts +44 -21
  187. package/src/swapper/SwapperUtils.ts +107 -60
  188. package/src/swapper/SwapperWithChain.ts +320 -81
  189. package/src/swapper/SwapperWithSigner.ts +263 -56
  190. package/src/swaps/IAddressSwap.ts +11 -1
  191. package/src/swaps/IBTCWalletSwap.ts +24 -8
  192. package/src/swaps/IClaimableSwap.ts +39 -4
  193. package/src/swaps/IClaimableSwapWrapper.ts +11 -2
  194. package/src/swaps/IRefundableSwap.ts +32 -3
  195. package/src/swaps/ISwap.ts +221 -82
  196. package/src/swaps/ISwapWithGasDrop.ts +6 -0
  197. package/src/swaps/ISwapWrapper.ts +212 -94
  198. package/src/swaps/escrow_swaps/IEscrowSelfInitSwap.ts +62 -18
  199. package/src/swaps/escrow_swaps/IEscrowSwap.ts +83 -37
  200. package/src/swaps/escrow_swaps/IEscrowSwapWrapper.ts +61 -30
  201. package/src/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.ts +37 -19
  202. package/src/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.ts +120 -51
  203. package/src/swaps/escrow_swaps/frombtc/IFromBTCWrapper.ts +24 -11
  204. package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.ts +559 -256
  205. package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.ts +155 -61
  206. package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.ts +590 -226
  207. package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts +177 -74
  208. package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.ts +470 -243
  209. package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts +141 -59
  210. package/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts +352 -193
  211. package/src/swaps/escrow_swaps/tobtc/IToBTCWrapper.ts +48 -23
  212. package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.ts +86 -39
  213. package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts +110 -110
  214. package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.ts +88 -33
  215. package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts +101 -31
  216. package/src/swaps/spv_swaps/SpvFromBTCSwap.ts +534 -263
  217. package/src/swaps/spv_swaps/SpvFromBTCWrapper.ts +289 -148
  218. package/src/swaps/trusted/ln/LnForGasSwap.ts +184 -45
  219. package/src/swaps/trusted/ln/LnForGasWrapper.ts +34 -15
  220. package/src/swaps/trusted/onchain/OnchainForGasSwap.ts +260 -86
  221. package/src/swaps/trusted/onchain/OnchainForGasWrapper.ts +41 -19
  222. package/src/types/AmountData.ts +2 -1
  223. package/src/types/CustomPriceFunction.ts +7 -1
  224. package/src/types/SwapExecutionAction.ts +84 -5
  225. package/src/types/SwapWithSigner.ts +7 -3
  226. package/src/types/Token.ts +12 -5
  227. package/src/types/TokenAmount.ts +3 -0
  228. package/src/types/fees/Fee.ts +2 -1
  229. package/src/types/fees/FeeBreakdown.ts +2 -1
  230. package/src/types/fees/PercentagePPM.ts +2 -0
  231. package/src/types/lnurl/LNURLPay.ts +14 -6
  232. package/src/types/lnurl/LNURLWithdraw.ts +12 -5
  233. package/src/types/wallets/LightningInvoiceCreateService.ts +26 -0
  234. package/src/types/wallets/MinimalBitcoinWalletInterface.ts +3 -1
  235. package/src/types/wallets/MinimalLightningNetworkWalletInterface.ts +3 -1
  236. package/src/utils/BitcoinUtils.ts +5 -0
  237. package/src/utils/SwapUtils.ts +61 -1
  238. package/src/utils/TokenUtils.ts +12 -4
  239. package/dist/bitcoin/BitcoinRpcWithAddressIndex.d.ts +0 -68
  240. package/dist/bitcoin/BitcoinRpcWithAddressIndex.js +0 -2
  241. package/dist/bitcoin/LightningNetworkApi.d.ts +0 -12
  242. package/dist/bitcoin/LightningNetworkApi.js +0 -2
  243. package/dist/bitcoin/mempool/MempoolApi.d.ts +0 -350
  244. package/dist/bitcoin/mempool/MempoolApi.js +0 -311
  245. package/dist/bitcoin/mempool/MempoolBitcoinBlock.d.ts +0 -44
  246. package/dist/bitcoin/mempool/MempoolBitcoinBlock.js +0 -48
  247. package/dist/bitcoin/mempool/MempoolBitcoinRpc.d.ts +0 -119
  248. package/dist/bitcoin/mempool/MempoolBitcoinRpc.js +0 -361
  249. package/dist/bitcoin/mempool/synchronizer/MempoolBtcRelaySynchronizer.d.ts +0 -22
  250. package/dist/bitcoin/mempool/synchronizer/MempoolBtcRelaySynchronizer.js +0 -105
  251. package/dist/errors/PaymentAuthError.d.ts +0 -11
  252. package/dist/errors/PaymentAuthError.js +0 -23
  253. 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 claimableSwapStates: FromBTCSwapState[];
34
- readonly TYPE = SwapType.FROM_BTC;
35
- readonly swapDeserializer: typeof FromBTCSwap;
36
- readonly synchronizer: RelaySynchronizer<any, T["TX"], any>;
37
- readonly btcRelay: BtcRelay<any, T["TX"], any>;
38
- readonly btcRpc: BitcoinRpcWithAddressIndex<any>;
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
- readonly pendingSwapStates: FromBTCSwapState[];
58
- readonly tickSwapState: FromBTCSwapState[];
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 Parsed swap data
66
- * @param requiredConfirmations Confirmations required to claim the tx
101
+ * @param data Swap data
102
+ * @param requiredConfirmations Confirmations required on the bitcoin side to settle the swap
103
+ *
104
+ * @internal
67
105
  */
68
- getOnchainSendTimeout(data: SwapData, requiredConfirmations: number): bigint;
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() function
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
- * @private
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, receiving 'amount' on chain
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 signer Smartchain signer's address intiating the swap
109
- * @param amountData Amount of token & amount to swap
110
- * @param lps LPs (liquidity providers) to get the quotes from
111
- * @param options Quote options
112
- * @param additionalParams Additional parameters sent to the LP when creating the swap
113
- * @param abortSignal Abort signal for aborting the process
114
- */
115
- create(signer: string, amountData: AmountData, lps: Intermediary[], options?: FromBTCOptions, additionalParams?: Record<string, any>, abortSignal?: AbortSignal): {
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
- this.swapDeserializer = FromBTCSwap_1.FromBTCSwap;
44
- this.pendingSwapStates = [
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
- this.tickSwapState = [FromBTCSwap_1.FromBTCSwapState.PR_CREATED, FromBTCSwap_1.FromBTCSwapState.CLAIM_COMMITED, FromBTCSwap_1.FromBTCSwapState.EXPIRED];
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.synchronizer = synchronizer;
54
- this.btcRpc = btcRpc;
71
+ this._synchronizer = synchronizer;
72
+ this._btcRpc = btcRpc;
55
73
  }
74
+ /**
75
+ * @inheritDoc
76
+ * @internal
77
+ */
56
78
  processEventInitialize(swap, event) {
57
- if (swap.state === FromBTCSwap_1.FromBTCSwapState.PR_CREATED || swap.state === FromBTCSwap_1.FromBTCSwapState.QUOTE_SOFT_EXPIRED) {
58
- swap.state = FromBTCSwap_1.FromBTCSwapState.CLAIM_COMMITED;
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.state !== FromBTCSwap_1.FromBTCSwapState.FAILED && swap.state !== FromBTCSwap_1.FromBTCSwapState.CLAIM_CLAIMED) {
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.state = FromBTCSwap_1.FromBTCSwapState.CLAIM_CLAIMED;
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.state !== FromBTCSwap_1.FromBTCSwapState.CLAIM_CLAIMED && swap.state !== FromBTCSwap_1.FromBTCSwapState.FAILED) {
75
- swap.state = FromBTCSwap_1.FromBTCSwapState.FAILED;
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 Parsed swap data
84
- * @param requiredConfirmations Confirmations required to claim the tx
113
+ * @param data Swap data
114
+ * @param requiredConfirmations Confirmations required on the bitcoin side to settle the swap
115
+ *
116
+ * @internal
85
117
  */
86
- getOnchainSendTimeout(data, requiredConfirmations) {
87
- const tsDelta = (this.options.blocksTillTxConfirms + requiredConfirmations) * this.options.bitcoinBlocktime * this.options.safetyFactor;
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.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)));
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.btcRpc.getTipHeight(),
118
- this.contract.getClaimFee(signer, dummySwapData)
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() function
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.options.bitcoinBlocktime) * BigInt(options.blockSafetyFactor);
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
- * @private
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.options.maxConfirmations)
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.getOnchainSendTimeout(data, requiredConfirmations);
228
+ const expiry = this._getOnchainSendTimeout(data, requiredConfirmations);
193
229
  const currentTimestamp = BigInt(Math.floor(Date.now() / 1000));
194
- if ((expiry - currentTimestamp) < BigInt(this.options.minSendWindow)) {
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.options.bitcoinNetwork, resp.btcAddress);
198
- const desiredExtraData = this.contract.getExtraData(lockingScript, resp.amount, requiredConfirmations);
199
- const desiredClaimHash = this.contract.getHashForOnchain(lockingScript, resp.amount, requiredConfirmations);
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, receiving 'amount' on chain
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 signer Smartchain signer's address intiating the swap
212
- * @param amountData Amount of token & amount to swap
213
- * @param lps LPs (liquidity providers) to get the quotes from
214
- * @param options Quote options
215
- * @param additionalParams Additional parameters sent to the LP when creating the swap
216
- * @param abortSignal Abort signal for aborting the process
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(signer, amountData, lps, options, additionalParams, abortSignal) {
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(signer, amountData, _options, _abortController);
229
- const nativeTokenAddress = this.chain.getNativeCurrencyAddress();
230
- const feeRatePromise = this.preFetchFeeRate(signer, amountData, undefined, _abortController);
231
- const _signDataPromise = this.contract.preFetchBlockDataForSignatures == null ?
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: signer,
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.options.postRequestTimeout, abortController.signal, retryCount > 0 ? false : undefined);
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.swapDataDeserializer(resp.data);
260
- data.setClaimer(signer);
261
- this.verifyReturnedData(signer, resp, amountData, lp, _options, data, sequence, (await claimerBountyPrefetchPromise), nativeTokenAddress);
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(signer, data, resp, feeRatePromise, signDataPromise, abortController.signal),
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;