@atomiqlabs/lp-lib 14.0.0-dev.13 → 14.0.0-dev.16
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/LICENSE +201 -201
- package/dist/fees/IBtcFeeEstimator.d.ts +3 -3
- package/dist/fees/IBtcFeeEstimator.js +2 -2
- package/dist/index.d.ts +42 -42
- package/dist/index.js +58 -58
- package/dist/info/InfoHandler.d.ts +17 -17
- package/dist/info/InfoHandler.js +61 -61
- package/dist/plugins/IPlugin.d.ts +143 -143
- package/dist/plugins/IPlugin.js +34 -34
- package/dist/plugins/PluginManager.d.ts +112 -112
- package/dist/plugins/PluginManager.js +259 -259
- package/dist/prices/BinanceSwapPrice.d.ts +26 -26
- package/dist/prices/BinanceSwapPrice.js +92 -92
- package/dist/prices/CoinGeckoSwapPrice.d.ts +30 -30
- package/dist/prices/CoinGeckoSwapPrice.js +64 -64
- package/dist/prices/ISwapPrice.d.ts +43 -43
- package/dist/prices/ISwapPrice.js +55 -55
- package/dist/prices/OKXSwapPrice.d.ts +26 -26
- package/dist/prices/OKXSwapPrice.js +92 -92
- package/dist/storage/IIntermediaryStorage.d.ts +18 -18
- package/dist/storage/IIntermediaryStorage.js +2 -2
- package/dist/storagemanager/IntermediaryStorageManager.d.ts +19 -19
- package/dist/storagemanager/IntermediaryStorageManager.js +111 -111
- package/dist/storagemanager/StorageManager.d.ts +13 -13
- package/dist/storagemanager/StorageManager.js +64 -64
- package/dist/swaps/SwapHandler.d.ts +153 -153
- package/dist/swaps/SwapHandler.js +160 -160
- package/dist/swaps/SwapHandlerSwap.d.ts +79 -79
- package/dist/swaps/SwapHandlerSwap.js +78 -78
- package/dist/swaps/assertions/AmountAssertions.d.ts +28 -28
- package/dist/swaps/assertions/AmountAssertions.js +72 -72
- package/dist/swaps/assertions/FromBtcAmountAssertions.d.ts +76 -76
- package/dist/swaps/assertions/FromBtcAmountAssertions.js +180 -172
- package/dist/swaps/assertions/LightningAssertions.d.ts +44 -44
- package/dist/swaps/assertions/LightningAssertions.js +86 -86
- package/dist/swaps/assertions/ToBtcAmountAssertions.d.ts +53 -53
- package/dist/swaps/assertions/ToBtcAmountAssertions.js +150 -150
- package/dist/swaps/escrow/EscrowHandler.d.ts +51 -51
- package/dist/swaps/escrow/EscrowHandler.js +158 -158
- package/dist/swaps/escrow/EscrowHandlerSwap.d.ts +35 -35
- package/dist/swaps/escrow/EscrowHandlerSwap.js +69 -69
- package/dist/swaps/escrow/FromBtcBaseSwap.d.ts +14 -14
- package/dist/swaps/escrow/FromBtcBaseSwap.js +32 -32
- package/dist/swaps/escrow/FromBtcBaseSwapHandler.d.ts +102 -102
- package/dist/swaps/escrow/FromBtcBaseSwapHandler.js +210 -210
- package/dist/swaps/escrow/ToBtcBaseSwap.d.ts +36 -36
- package/dist/swaps/escrow/ToBtcBaseSwap.js +67 -67
- package/dist/swaps/escrow/ToBtcBaseSwapHandler.d.ts +53 -53
- package/dist/swaps/escrow/ToBtcBaseSwapHandler.js +81 -81
- package/dist/swaps/escrow/frombtc_abstract/FromBtcAbs.d.ts +83 -83
- package/dist/swaps/escrow/frombtc_abstract/FromBtcAbs.js +318 -318
- package/dist/swaps/escrow/frombtc_abstract/FromBtcSwapAbs.d.ts +21 -21
- package/dist/swaps/escrow/frombtc_abstract/FromBtcSwapAbs.js +50 -50
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.d.ts +107 -107
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.js +675 -675
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.d.ts +33 -33
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.js +91 -91
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.d.ts +104 -104
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.js +659 -659
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.d.ts +55 -55
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.js +120 -120
- package/dist/swaps/escrow/tobtc_abstract/ToBtcAbs.d.ts +171 -171
- package/dist/swaps/escrow/tobtc_abstract/ToBtcAbs.js +706 -706
- package/dist/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.d.ts +26 -26
- package/dist/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.js +62 -62
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.d.ts +177 -177
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.js +861 -861
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.d.ts +23 -23
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.js +56 -56
- package/dist/swaps/spv_vault_swap/SpvVault.d.ts +41 -41
- package/dist/swaps/spv_vault_swap/SpvVault.js +111 -111
- package/dist/swaps/spv_vault_swap/SpvVaultSwap.d.ts +67 -67
- package/dist/swaps/spv_vault_swap/SpvVaultSwap.js +158 -158
- package/dist/swaps/spv_vault_swap/SpvVaultSwapHandler.d.ts +68 -68
- package/dist/swaps/spv_vault_swap/SpvVaultSwapHandler.js +491 -491
- package/dist/swaps/spv_vault_swap/SpvVaults.d.ts +52 -52
- package/dist/swaps/spv_vault_swap/SpvVaults.js +364 -364
- package/dist/swaps/trusted/frombtc_trusted/FromBtcTrusted.d.ts +51 -51
- package/dist/swaps/trusted/frombtc_trusted/FromBtcTrusted.js +650 -650
- package/dist/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.d.ts +52 -52
- package/dist/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.js +118 -118
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.d.ts +76 -76
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.js +494 -494
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.d.ts +34 -34
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.js +81 -81
- package/dist/utils/Utils.d.ts +29 -29
- package/dist/utils/Utils.js +89 -89
- package/dist/utils/paramcoders/IParamReader.d.ts +5 -5
- package/dist/utils/paramcoders/IParamReader.js +2 -2
- package/dist/utils/paramcoders/IParamWriter.d.ts +4 -4
- package/dist/utils/paramcoders/IParamWriter.js +2 -2
- package/dist/utils/paramcoders/LegacyParamEncoder.d.ts +10 -10
- package/dist/utils/paramcoders/LegacyParamEncoder.js +22 -22
- package/dist/utils/paramcoders/ParamDecoder.d.ts +25 -25
- package/dist/utils/paramcoders/ParamDecoder.js +222 -222
- package/dist/utils/paramcoders/ParamEncoder.d.ts +9 -9
- package/dist/utils/paramcoders/ParamEncoder.js +22 -22
- package/dist/utils/paramcoders/SchemaVerifier.d.ts +21 -21
- package/dist/utils/paramcoders/SchemaVerifier.js +84 -84
- package/dist/utils/paramcoders/server/ServerParamDecoder.d.ts +8 -8
- package/dist/utils/paramcoders/server/ServerParamDecoder.js +107 -107
- package/dist/utils/paramcoders/server/ServerParamEncoder.d.ts +11 -11
- package/dist/utils/paramcoders/server/ServerParamEncoder.js +65 -65
- package/dist/wallets/IBitcoinWallet.d.ts +67 -67
- package/dist/wallets/IBitcoinWallet.js +2 -2
- package/dist/wallets/ILightningWallet.d.ts +117 -117
- package/dist/wallets/ILightningWallet.js +37 -37
- package/dist/wallets/ISpvVaultSigner.d.ts +7 -7
- package/dist/wallets/ISpvVaultSigner.js +2 -2
- package/package.json +36 -36
- package/src/fees/IBtcFeeEstimator.ts +6 -6
- package/src/index.ts +53 -53
- package/src/info/InfoHandler.ts +106 -106
- package/src/plugins/IPlugin.ts +168 -168
- package/src/plugins/PluginManager.ts +336 -336
- package/src/prices/BinanceSwapPrice.ts +113 -113
- package/src/prices/CoinGeckoSwapPrice.ts +87 -87
- package/src/prices/ISwapPrice.ts +88 -88
- package/src/prices/OKXSwapPrice.ts +113 -113
- package/src/storage/IIntermediaryStorage.ts +19 -19
- package/src/storagemanager/IntermediaryStorageManager.ts +118 -118
- package/src/storagemanager/StorageManager.ts +78 -78
- package/src/swaps/SwapHandler.ts +277 -277
- package/src/swaps/SwapHandlerSwap.ts +141 -141
- package/src/swaps/assertions/AmountAssertions.ts +76 -76
- package/src/swaps/assertions/FromBtcAmountAssertions.ts +246 -238
- package/src/swaps/assertions/LightningAssertions.ts +103 -103
- package/src/swaps/assertions/ToBtcAmountAssertions.ts +203 -203
- package/src/swaps/escrow/EscrowHandler.ts +179 -179
- package/src/swaps/escrow/EscrowHandlerSwap.ts +86 -86
- package/src/swaps/escrow/FromBtcBaseSwap.ts +38 -38
- package/src/swaps/escrow/FromBtcBaseSwapHandler.ts +286 -286
- package/src/swaps/escrow/ToBtcBaseSwap.ts +85 -85
- package/src/swaps/escrow/ToBtcBaseSwapHandler.ts +129 -129
- package/src/swaps/escrow/frombtc_abstract/FromBtcAbs.ts +452 -452
- package/src/swaps/escrow/frombtc_abstract/FromBtcSwapAbs.ts +61 -61
- package/src/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.ts +856 -856
- package/src/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.ts +141 -141
- package/src/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.ts +822 -822
- package/src/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.ts +196 -196
- package/src/swaps/escrow/tobtc_abstract/ToBtcAbs.ts +879 -879
- package/src/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.ts +102 -102
- package/src/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.ts +1110 -1110
- package/src/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.ts +77 -77
- package/src/swaps/spv_vault_swap/SpvVault.ts +143 -143
- package/src/swaps/spv_vault_swap/SpvVaultSwap.ts +225 -225
- package/src/swaps/spv_vault_swap/SpvVaultSwapHandler.ts +627 -627
- package/src/swaps/spv_vault_swap/SpvVaults.ts +435 -435
- package/src/swaps/trusted/frombtc_trusted/FromBtcTrusted.ts +747 -747
- package/src/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.ts +185 -185
- package/src/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.ts +590 -590
- package/src/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.ts +121 -121
- package/src/utils/Utils.ts +104 -104
- package/src/utils/paramcoders/IParamReader.ts +7 -7
- package/src/utils/paramcoders/IParamWriter.ts +8 -8
- package/src/utils/paramcoders/LegacyParamEncoder.ts +27 -27
- package/src/utils/paramcoders/ParamDecoder.ts +218 -218
- package/src/utils/paramcoders/ParamEncoder.ts +29 -29
- package/src/utils/paramcoders/SchemaVerifier.ts +96 -96
- package/src/utils/paramcoders/server/ServerParamDecoder.ts +118 -118
- package/src/utils/paramcoders/server/ServerParamEncoder.ts +75 -75
- package/src/wallets/IBitcoinWallet.ts +68 -68
- package/src/wallets/ILightningWallet.ts +178 -178
- package/src/wallets/ISpvVaultSigner.ts +10 -10
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { SwapData } from "@atomiqlabs/base";
|
|
2
|
-
import { FromBtcBaseSwap } from "../FromBtcBaseSwap";
|
|
3
|
-
export declare enum FromBtcSwapState {
|
|
4
|
-
REFUNDED = -2,
|
|
5
|
-
CANCELED = -1,
|
|
6
|
-
CREATED = 0,
|
|
7
|
-
COMMITED = 1,
|
|
8
|
-
CLAIMED = 2
|
|
9
|
-
}
|
|
10
|
-
export declare class FromBtcSwapAbs<T extends SwapData = SwapData> extends FromBtcBaseSwap<T, FromBtcSwapState> {
|
|
11
|
-
readonly address: string;
|
|
12
|
-
readonly confirmations: number;
|
|
13
|
-
txId: string;
|
|
14
|
-
constructor(chainIdentifier: string, address: string, confirmations: number, amount: bigint, swapFee: bigint, swapFeeInToken: bigint);
|
|
15
|
-
constructor(obj: any);
|
|
16
|
-
serialize(): any;
|
|
17
|
-
isInitiated(): boolean;
|
|
18
|
-
isFailed(): boolean;
|
|
19
|
-
isSuccess(): boolean;
|
|
20
|
-
getTotalInputAmount(): bigint;
|
|
21
|
-
}
|
|
1
|
+
import { SwapData } from "@atomiqlabs/base";
|
|
2
|
+
import { FromBtcBaseSwap } from "../FromBtcBaseSwap";
|
|
3
|
+
export declare enum FromBtcSwapState {
|
|
4
|
+
REFUNDED = -2,
|
|
5
|
+
CANCELED = -1,
|
|
6
|
+
CREATED = 0,
|
|
7
|
+
COMMITED = 1,
|
|
8
|
+
CLAIMED = 2
|
|
9
|
+
}
|
|
10
|
+
export declare class FromBtcSwapAbs<T extends SwapData = SwapData> extends FromBtcBaseSwap<T, FromBtcSwapState> {
|
|
11
|
+
readonly address: string;
|
|
12
|
+
readonly confirmations: number;
|
|
13
|
+
txId: string;
|
|
14
|
+
constructor(chainIdentifier: string, address: string, confirmations: number, amount: bigint, swapFee: bigint, swapFeeInToken: bigint);
|
|
15
|
+
constructor(obj: any);
|
|
16
|
+
serialize(): any;
|
|
17
|
+
isInitiated(): boolean;
|
|
18
|
+
isFailed(): boolean;
|
|
19
|
+
isSuccess(): boolean;
|
|
20
|
+
getTotalInputAmount(): bigint;
|
|
21
|
+
}
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FromBtcSwapAbs = exports.FromBtcSwapState = void 0;
|
|
4
|
-
const SwapHandler_1 = require("../../SwapHandler");
|
|
5
|
-
const FromBtcBaseSwap_1 = require("../FromBtcBaseSwap");
|
|
6
|
-
var FromBtcSwapState;
|
|
7
|
-
(function (FromBtcSwapState) {
|
|
8
|
-
FromBtcSwapState[FromBtcSwapState["REFUNDED"] = -2] = "REFUNDED";
|
|
9
|
-
FromBtcSwapState[FromBtcSwapState["CANCELED"] = -1] = "CANCELED";
|
|
10
|
-
FromBtcSwapState[FromBtcSwapState["CREATED"] = 0] = "CREATED";
|
|
11
|
-
FromBtcSwapState[FromBtcSwapState["COMMITED"] = 1] = "COMMITED";
|
|
12
|
-
FromBtcSwapState[FromBtcSwapState["CLAIMED"] = 2] = "CLAIMED";
|
|
13
|
-
})(FromBtcSwapState = exports.FromBtcSwapState || (exports.FromBtcSwapState = {}));
|
|
14
|
-
class FromBtcSwapAbs extends FromBtcBaseSwap_1.FromBtcBaseSwap {
|
|
15
|
-
constructor(prOrObj, address, confirmations, amount, swapFee, swapFeeInToken) {
|
|
16
|
-
if (typeof (prOrObj) === "string") {
|
|
17
|
-
super(prOrObj, amount, swapFee, swapFeeInToken);
|
|
18
|
-
this.state = FromBtcSwapState.CREATED;
|
|
19
|
-
this.address = address;
|
|
20
|
-
this.confirmations = confirmations;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
super(prOrObj);
|
|
24
|
-
this.address = prOrObj.address;
|
|
25
|
-
this.confirmations = prOrObj.confirmations;
|
|
26
|
-
this.txId = prOrObj.txId;
|
|
27
|
-
}
|
|
28
|
-
this.type = SwapHandler_1.SwapHandlerType.FROM_BTC;
|
|
29
|
-
}
|
|
30
|
-
serialize() {
|
|
31
|
-
const partialSerialized = super.serialize();
|
|
32
|
-
partialSerialized.address = this.address;
|
|
33
|
-
partialSerialized.confirmations = this.confirmations;
|
|
34
|
-
partialSerialized.txId = this.txId;
|
|
35
|
-
return partialSerialized;
|
|
36
|
-
}
|
|
37
|
-
isInitiated() {
|
|
38
|
-
return this.state !== FromBtcSwapState.CREATED;
|
|
39
|
-
}
|
|
40
|
-
isFailed() {
|
|
41
|
-
return this.state === FromBtcSwapState.CANCELED || this.state === FromBtcSwapState.REFUNDED;
|
|
42
|
-
}
|
|
43
|
-
isSuccess() {
|
|
44
|
-
return this.state === FromBtcSwapState.CLAIMED;
|
|
45
|
-
}
|
|
46
|
-
getTotalInputAmount() {
|
|
47
|
-
return this.amount;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.FromBtcSwapAbs = FromBtcSwapAbs;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FromBtcSwapAbs = exports.FromBtcSwapState = void 0;
|
|
4
|
+
const SwapHandler_1 = require("../../SwapHandler");
|
|
5
|
+
const FromBtcBaseSwap_1 = require("../FromBtcBaseSwap");
|
|
6
|
+
var FromBtcSwapState;
|
|
7
|
+
(function (FromBtcSwapState) {
|
|
8
|
+
FromBtcSwapState[FromBtcSwapState["REFUNDED"] = -2] = "REFUNDED";
|
|
9
|
+
FromBtcSwapState[FromBtcSwapState["CANCELED"] = -1] = "CANCELED";
|
|
10
|
+
FromBtcSwapState[FromBtcSwapState["CREATED"] = 0] = "CREATED";
|
|
11
|
+
FromBtcSwapState[FromBtcSwapState["COMMITED"] = 1] = "COMMITED";
|
|
12
|
+
FromBtcSwapState[FromBtcSwapState["CLAIMED"] = 2] = "CLAIMED";
|
|
13
|
+
})(FromBtcSwapState = exports.FromBtcSwapState || (exports.FromBtcSwapState = {}));
|
|
14
|
+
class FromBtcSwapAbs extends FromBtcBaseSwap_1.FromBtcBaseSwap {
|
|
15
|
+
constructor(prOrObj, address, confirmations, amount, swapFee, swapFeeInToken) {
|
|
16
|
+
if (typeof (prOrObj) === "string") {
|
|
17
|
+
super(prOrObj, amount, swapFee, swapFeeInToken);
|
|
18
|
+
this.state = FromBtcSwapState.CREATED;
|
|
19
|
+
this.address = address;
|
|
20
|
+
this.confirmations = confirmations;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
super(prOrObj);
|
|
24
|
+
this.address = prOrObj.address;
|
|
25
|
+
this.confirmations = prOrObj.confirmations;
|
|
26
|
+
this.txId = prOrObj.txId;
|
|
27
|
+
}
|
|
28
|
+
this.type = SwapHandler_1.SwapHandlerType.FROM_BTC;
|
|
29
|
+
}
|
|
30
|
+
serialize() {
|
|
31
|
+
const partialSerialized = super.serialize();
|
|
32
|
+
partialSerialized.address = this.address;
|
|
33
|
+
partialSerialized.confirmations = this.confirmations;
|
|
34
|
+
partialSerialized.txId = this.txId;
|
|
35
|
+
return partialSerialized;
|
|
36
|
+
}
|
|
37
|
+
isInitiated() {
|
|
38
|
+
return this.state !== FromBtcSwapState.CREATED;
|
|
39
|
+
}
|
|
40
|
+
isFailed() {
|
|
41
|
+
return this.state === FromBtcSwapState.CANCELED || this.state === FromBtcSwapState.REFUNDED;
|
|
42
|
+
}
|
|
43
|
+
isSuccess() {
|
|
44
|
+
return this.state === FromBtcSwapState.CLAIMED;
|
|
45
|
+
}
|
|
46
|
+
getTotalInputAmount() {
|
|
47
|
+
return this.amount;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.FromBtcSwapAbs = FromBtcSwapAbs;
|
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
import { Express } from "express";
|
|
2
|
-
import { FromBtcLnSwapAbs, FromBtcLnSwapState } from "./FromBtcLnSwapAbs";
|
|
3
|
-
import { MultichainData, SwapHandlerType } from "../../SwapHandler";
|
|
4
|
-
import { ISwapPrice } from "../../../prices/ISwapPrice";
|
|
5
|
-
import { ChainSwapType, ClaimEvent, InitializeEvent, RefundEvent, SwapData } from "@atomiqlabs/base";
|
|
6
|
-
import { IIntermediaryStorage } from "../../../storage/IIntermediaryStorage";
|
|
7
|
-
import { FromBtcBaseConfig, FromBtcBaseSwapHandler } from "../FromBtcBaseSwapHandler";
|
|
8
|
-
import { ILightningWallet } from "../../../wallets/ILightningWallet";
|
|
9
|
-
import { LightningAssertions } from "../../assertions/LightningAssertions";
|
|
10
|
-
export type FromBtcLnConfig = FromBtcBaseConfig & {
|
|
11
|
-
invoiceTimeoutSeconds?: number;
|
|
12
|
-
minCltv: bigint;
|
|
13
|
-
gracePeriod: bigint;
|
|
14
|
-
};
|
|
15
|
-
export type FromBtcLnRequestType = {
|
|
16
|
-
address: string;
|
|
17
|
-
paymentHash: string;
|
|
18
|
-
amount: bigint;
|
|
19
|
-
token: string;
|
|
20
|
-
descriptionHash?: string;
|
|
21
|
-
exactOut?: boolean;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Swap handler handling from BTCLN swaps using submarine swaps
|
|
25
|
-
*/
|
|
26
|
-
export declare class FromBtcLnAbs extends FromBtcBaseSwapHandler<FromBtcLnSwapAbs, FromBtcLnSwapState> {
|
|
27
|
-
readonly type = SwapHandlerType.FROM_BTCLN;
|
|
28
|
-
readonly swapType = ChainSwapType.HTLC;
|
|
29
|
-
readonly config: FromBtcLnConfig;
|
|
30
|
-
readonly lightning: ILightningWallet;
|
|
31
|
-
readonly LightningAssertions: LightningAssertions;
|
|
32
|
-
constructor(storageDirectory: IIntermediaryStorage<FromBtcLnSwapAbs>, path: string, chains: MultichainData, lightning: ILightningWallet, swapPricing: ISwapPrice, config: FromBtcLnConfig);
|
|
33
|
-
protected processPastSwap(swap: FromBtcLnSwapAbs): Promise<"REFUND" | "SETTLE" | "CANCEL" | null>;
|
|
34
|
-
protected refundSwaps(refundSwaps: FromBtcLnSwapAbs[]): Promise<void>;
|
|
35
|
-
protected cancelInvoices(swaps: FromBtcLnSwapAbs[]): Promise<void>;
|
|
36
|
-
protected settleInvoices(swaps: FromBtcLnSwapAbs[]): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Checks past swaps, refunds and deletes ones that are already expired.
|
|
39
|
-
*/
|
|
40
|
-
protected processPastSwaps(): Promise<void>;
|
|
41
|
-
protected processInitializeEvent(chainIdentifier: string, savedSwap: FromBtcLnSwapAbs, event: InitializeEvent<SwapData>): Promise<void>;
|
|
42
|
-
protected processClaimEvent(chainIdentifier: string, savedSwap: FromBtcLnSwapAbs, event: ClaimEvent<SwapData>): Promise<void>;
|
|
43
|
-
protected processRefundEvent(chainIdentifier: string, savedSwap: FromBtcLnSwapAbs, event: RefundEvent<SwapData>): Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Called when lightning HTLC is received, also signs an init transaction on the smart chain side, expiry of the
|
|
46
|
-
* smart chain authorization starts ticking as soon as this HTLC is received
|
|
47
|
-
*
|
|
48
|
-
* @param invoiceData
|
|
49
|
-
* @param invoice
|
|
50
|
-
*/
|
|
51
|
-
private htlcReceived;
|
|
52
|
-
/**
|
|
53
|
-
* Checks invoice description hash
|
|
54
|
-
*
|
|
55
|
-
* @param descriptionHash
|
|
56
|
-
* @throws {DefinedRuntimeError} will throw an error if the description hash is invalid
|
|
57
|
-
*/
|
|
58
|
-
private checkDescriptionHash;
|
|
59
|
-
/**
|
|
60
|
-
* Starts LN channels pre-fetch
|
|
61
|
-
*
|
|
62
|
-
* @param abortController
|
|
63
|
-
*/
|
|
64
|
-
private getBlockheightPrefetch;
|
|
65
|
-
/**
|
|
66
|
-
* Asynchronously sends the LN node's public key to the client, so he can pre-fetch the node's channels from 1ml api
|
|
67
|
-
*
|
|
68
|
-
* @param responseStream
|
|
69
|
-
*/
|
|
70
|
-
private sendPublicKeyAsync;
|
|
71
|
-
/**
|
|
72
|
-
* Returns the CLTV timeout (blockheight) of the received HTLC corresponding to the invoice. If multiple HTLCs are
|
|
73
|
-
* received (MPP) it returns the lowest of the timeouts
|
|
74
|
-
*
|
|
75
|
-
* @param invoice
|
|
76
|
-
*/
|
|
77
|
-
private getInvoicePaymentsTimeout;
|
|
78
|
-
/**
|
|
79
|
-
* Checks if the received HTLC's CLTV timeout is large enough to still process the swap
|
|
80
|
-
*
|
|
81
|
-
* @param invoice
|
|
82
|
-
* @param blockheightPrefetch
|
|
83
|
-
* @param signal
|
|
84
|
-
* @throws {DefinedRuntimeError} Will throw if HTLC expires too soon and therefore cannot be processed
|
|
85
|
-
* @returns expiry timeout in seconds
|
|
86
|
-
*/
|
|
87
|
-
private checkHtlcExpiry;
|
|
88
|
-
/**
|
|
89
|
-
* Cancels the swap (CANCELED state) & also cancels the LN invoice (including all pending HTLCs)
|
|
90
|
-
*
|
|
91
|
-
* @param invoiceData
|
|
92
|
-
*/
|
|
93
|
-
private cancelSwapAndInvoice;
|
|
94
|
-
private getDummySwapData;
|
|
95
|
-
/**
|
|
96
|
-
*
|
|
97
|
-
* Checks if the lightning invoice is in HELD state (htlcs received but yet unclaimed)
|
|
98
|
-
*
|
|
99
|
-
* @param paymentHash
|
|
100
|
-
* @throws {DefinedRuntimeError} Will throw if the lightning invoice is not found, or if it isn't in the HELD state
|
|
101
|
-
* @returns the fetched lightning invoice
|
|
102
|
-
*/
|
|
103
|
-
private checkInvoiceStatus;
|
|
104
|
-
startRestServer(restServer: Express): void;
|
|
105
|
-
init(): Promise<void>;
|
|
106
|
-
getInfoData(): any;
|
|
107
|
-
}
|
|
1
|
+
import { Express } from "express";
|
|
2
|
+
import { FromBtcLnSwapAbs, FromBtcLnSwapState } from "./FromBtcLnSwapAbs";
|
|
3
|
+
import { MultichainData, SwapHandlerType } from "../../SwapHandler";
|
|
4
|
+
import { ISwapPrice } from "../../../prices/ISwapPrice";
|
|
5
|
+
import { ChainSwapType, ClaimEvent, InitializeEvent, RefundEvent, SwapData } from "@atomiqlabs/base";
|
|
6
|
+
import { IIntermediaryStorage } from "../../../storage/IIntermediaryStorage";
|
|
7
|
+
import { FromBtcBaseConfig, FromBtcBaseSwapHandler } from "../FromBtcBaseSwapHandler";
|
|
8
|
+
import { ILightningWallet } from "../../../wallets/ILightningWallet";
|
|
9
|
+
import { LightningAssertions } from "../../assertions/LightningAssertions";
|
|
10
|
+
export type FromBtcLnConfig = FromBtcBaseConfig & {
|
|
11
|
+
invoiceTimeoutSeconds?: number;
|
|
12
|
+
minCltv: bigint;
|
|
13
|
+
gracePeriod: bigint;
|
|
14
|
+
};
|
|
15
|
+
export type FromBtcLnRequestType = {
|
|
16
|
+
address: string;
|
|
17
|
+
paymentHash: string;
|
|
18
|
+
amount: bigint;
|
|
19
|
+
token: string;
|
|
20
|
+
descriptionHash?: string;
|
|
21
|
+
exactOut?: boolean;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Swap handler handling from BTCLN swaps using submarine swaps
|
|
25
|
+
*/
|
|
26
|
+
export declare class FromBtcLnAbs extends FromBtcBaseSwapHandler<FromBtcLnSwapAbs, FromBtcLnSwapState> {
|
|
27
|
+
readonly type = SwapHandlerType.FROM_BTCLN;
|
|
28
|
+
readonly swapType = ChainSwapType.HTLC;
|
|
29
|
+
readonly config: FromBtcLnConfig;
|
|
30
|
+
readonly lightning: ILightningWallet;
|
|
31
|
+
readonly LightningAssertions: LightningAssertions;
|
|
32
|
+
constructor(storageDirectory: IIntermediaryStorage<FromBtcLnSwapAbs>, path: string, chains: MultichainData, lightning: ILightningWallet, swapPricing: ISwapPrice, config: FromBtcLnConfig);
|
|
33
|
+
protected processPastSwap(swap: FromBtcLnSwapAbs): Promise<"REFUND" | "SETTLE" | "CANCEL" | null>;
|
|
34
|
+
protected refundSwaps(refundSwaps: FromBtcLnSwapAbs[]): Promise<void>;
|
|
35
|
+
protected cancelInvoices(swaps: FromBtcLnSwapAbs[]): Promise<void>;
|
|
36
|
+
protected settleInvoices(swaps: FromBtcLnSwapAbs[]): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Checks past swaps, refunds and deletes ones that are already expired.
|
|
39
|
+
*/
|
|
40
|
+
protected processPastSwaps(): Promise<void>;
|
|
41
|
+
protected processInitializeEvent(chainIdentifier: string, savedSwap: FromBtcLnSwapAbs, event: InitializeEvent<SwapData>): Promise<void>;
|
|
42
|
+
protected processClaimEvent(chainIdentifier: string, savedSwap: FromBtcLnSwapAbs, event: ClaimEvent<SwapData>): Promise<void>;
|
|
43
|
+
protected processRefundEvent(chainIdentifier: string, savedSwap: FromBtcLnSwapAbs, event: RefundEvent<SwapData>): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Called when lightning HTLC is received, also signs an init transaction on the smart chain side, expiry of the
|
|
46
|
+
* smart chain authorization starts ticking as soon as this HTLC is received
|
|
47
|
+
*
|
|
48
|
+
* @param invoiceData
|
|
49
|
+
* @param invoice
|
|
50
|
+
*/
|
|
51
|
+
private htlcReceived;
|
|
52
|
+
/**
|
|
53
|
+
* Checks invoice description hash
|
|
54
|
+
*
|
|
55
|
+
* @param descriptionHash
|
|
56
|
+
* @throws {DefinedRuntimeError} will throw an error if the description hash is invalid
|
|
57
|
+
*/
|
|
58
|
+
private checkDescriptionHash;
|
|
59
|
+
/**
|
|
60
|
+
* Starts LN channels pre-fetch
|
|
61
|
+
*
|
|
62
|
+
* @param abortController
|
|
63
|
+
*/
|
|
64
|
+
private getBlockheightPrefetch;
|
|
65
|
+
/**
|
|
66
|
+
* Asynchronously sends the LN node's public key to the client, so he can pre-fetch the node's channels from 1ml api
|
|
67
|
+
*
|
|
68
|
+
* @param responseStream
|
|
69
|
+
*/
|
|
70
|
+
private sendPublicKeyAsync;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the CLTV timeout (blockheight) of the received HTLC corresponding to the invoice. If multiple HTLCs are
|
|
73
|
+
* received (MPP) it returns the lowest of the timeouts
|
|
74
|
+
*
|
|
75
|
+
* @param invoice
|
|
76
|
+
*/
|
|
77
|
+
private getInvoicePaymentsTimeout;
|
|
78
|
+
/**
|
|
79
|
+
* Checks if the received HTLC's CLTV timeout is large enough to still process the swap
|
|
80
|
+
*
|
|
81
|
+
* @param invoice
|
|
82
|
+
* @param blockheightPrefetch
|
|
83
|
+
* @param signal
|
|
84
|
+
* @throws {DefinedRuntimeError} Will throw if HTLC expires too soon and therefore cannot be processed
|
|
85
|
+
* @returns expiry timeout in seconds
|
|
86
|
+
*/
|
|
87
|
+
private checkHtlcExpiry;
|
|
88
|
+
/**
|
|
89
|
+
* Cancels the swap (CANCELED state) & also cancels the LN invoice (including all pending HTLCs)
|
|
90
|
+
*
|
|
91
|
+
* @param invoiceData
|
|
92
|
+
*/
|
|
93
|
+
private cancelSwapAndInvoice;
|
|
94
|
+
private getDummySwapData;
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* Checks if the lightning invoice is in HELD state (htlcs received but yet unclaimed)
|
|
98
|
+
*
|
|
99
|
+
* @param paymentHash
|
|
100
|
+
* @throws {DefinedRuntimeError} Will throw if the lightning invoice is not found, or if it isn't in the HELD state
|
|
101
|
+
* @returns the fetched lightning invoice
|
|
102
|
+
*/
|
|
103
|
+
private checkInvoiceStatus;
|
|
104
|
+
startRestServer(restServer: Express): void;
|
|
105
|
+
init(): Promise<void>;
|
|
106
|
+
getInfoData(): any;
|
|
107
|
+
}
|