@atomiqlabs/lp-lib 10.3.11
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 -0
- package/dist/fees/IBtcFeeEstimator.d.ts +3 -0
- package/dist/fees/IBtcFeeEstimator.js +2 -0
- package/dist/fees/OneDollarFeeEstimator.d.ts +16 -0
- package/dist/fees/OneDollarFeeEstimator.js +71 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +52 -0
- package/dist/info/InfoHandler.d.ts +17 -0
- package/dist/info/InfoHandler.js +70 -0
- package/dist/plugins/IPlugin.d.ts +118 -0
- package/dist/plugins/IPlugin.js +33 -0
- package/dist/plugins/PluginManager.d.ts +89 -0
- package/dist/plugins/PluginManager.js +263 -0
- package/dist/prices/BinanceSwapPrice.d.ts +27 -0
- package/dist/prices/BinanceSwapPrice.js +106 -0
- package/dist/prices/CoinGeckoSwapPrice.d.ts +31 -0
- package/dist/prices/CoinGeckoSwapPrice.js +76 -0
- package/dist/storage/IIntermediaryStorage.d.ts +15 -0
- package/dist/storage/IIntermediaryStorage.js +2 -0
- package/dist/storagemanager/IntermediaryStorageManager.d.ts +15 -0
- package/dist/storagemanager/IntermediaryStorageManager.js +113 -0
- package/dist/storagemanager/StorageManager.d.ts +12 -0
- package/dist/storagemanager/StorageManager.js +74 -0
- package/dist/swaps/FromBtcBaseSwap.d.ts +12 -0
- package/dist/swaps/FromBtcBaseSwap.js +16 -0
- package/dist/swaps/FromBtcBaseSwapHandler.d.ts +118 -0
- package/dist/swaps/FromBtcBaseSwapHandler.js +294 -0
- package/dist/swaps/FromBtcLnBaseSwapHandler.d.ts +25 -0
- package/dist/swaps/FromBtcLnBaseSwapHandler.js +55 -0
- package/dist/swaps/ISwapPrice.d.ts +44 -0
- package/dist/swaps/ISwapPrice.js +73 -0
- package/dist/swaps/SwapHandler.d.ts +186 -0
- package/dist/swaps/SwapHandler.js +292 -0
- package/dist/swaps/SwapHandlerSwap.d.ts +75 -0
- package/dist/swaps/SwapHandlerSwap.js +72 -0
- package/dist/swaps/ToBtcBaseSwap.d.ts +35 -0
- package/dist/swaps/ToBtcBaseSwap.js +61 -0
- package/dist/swaps/ToBtcBaseSwapHandler.d.ts +94 -0
- package/dist/swaps/ToBtcBaseSwapHandler.js +233 -0
- package/dist/swaps/frombtc_abstract/FromBtcAbs.d.ts +92 -0
- package/dist/swaps/frombtc_abstract/FromBtcAbs.js +386 -0
- package/dist/swaps/frombtc_abstract/FromBtcSwapAbs.d.ts +26 -0
- package/dist/swaps/frombtc_abstract/FromBtcSwapAbs.js +63 -0
- package/dist/swaps/frombtc_trusted/FromBtcTrusted.d.ts +55 -0
- package/dist/swaps/frombtc_trusted/FromBtcTrusted.js +586 -0
- package/dist/swaps/frombtc_trusted/FromBtcTrustedSwap.d.ts +43 -0
- package/dist/swaps/frombtc_trusted/FromBtcTrustedSwap.js +99 -0
- package/dist/swaps/frombtcln_abstract/FromBtcLnAbs.d.ts +105 -0
- package/dist/swaps/frombtcln_abstract/FromBtcLnAbs.js +731 -0
- package/dist/swaps/frombtcln_abstract/FromBtcLnSwapAbs.d.ts +29 -0
- package/dist/swaps/frombtcln_abstract/FromBtcLnSwapAbs.js +64 -0
- package/dist/swaps/frombtcln_trusted/FromBtcLnTrusted.d.ts +79 -0
- package/dist/swaps/frombtcln_trusted/FromBtcLnTrusted.js +514 -0
- package/dist/swaps/frombtcln_trusted/FromBtcLnTrustedSwap.d.ts +28 -0
- package/dist/swaps/frombtcln_trusted/FromBtcLnTrustedSwap.js +66 -0
- package/dist/swaps/tobtc_abstract/ToBtcAbs.d.ts +290 -0
- package/dist/swaps/tobtc_abstract/ToBtcAbs.js +1056 -0
- package/dist/swaps/tobtc_abstract/ToBtcSwapAbs.d.ts +29 -0
- package/dist/swaps/tobtc_abstract/ToBtcSwapAbs.js +70 -0
- package/dist/swaps/tobtcln_abstract/ToBtcLnAbs.d.ts +246 -0
- package/dist/swaps/tobtcln_abstract/ToBtcLnAbs.js +1169 -0
- package/dist/swaps/tobtcln_abstract/ToBtcLnSwapAbs.d.ts +27 -0
- package/dist/swaps/tobtcln_abstract/ToBtcLnSwapAbs.js +65 -0
- package/dist/utils/Utils.d.ts +32 -0
- package/dist/utils/Utils.js +109 -0
- package/dist/utils/coinselect2/accumulative.d.ts +6 -0
- package/dist/utils/coinselect2/accumulative.js +44 -0
- package/dist/utils/coinselect2/blackjack.d.ts +6 -0
- package/dist/utils/coinselect2/blackjack.js +41 -0
- package/dist/utils/coinselect2/index.d.ts +16 -0
- package/dist/utils/coinselect2/index.js +40 -0
- package/dist/utils/coinselect2/utils.d.ts +64 -0
- package/dist/utils/coinselect2/utils.js +121 -0
- package/dist/utils/paramcoders/IParamReader.d.ts +5 -0
- package/dist/utils/paramcoders/IParamReader.js +2 -0
- package/dist/utils/paramcoders/IParamWriter.d.ts +4 -0
- package/dist/utils/paramcoders/IParamWriter.js +2 -0
- package/dist/utils/paramcoders/LegacyParamEncoder.d.ts +10 -0
- package/dist/utils/paramcoders/LegacyParamEncoder.js +33 -0
- package/dist/utils/paramcoders/ParamDecoder.d.ts +25 -0
- package/dist/utils/paramcoders/ParamDecoder.js +234 -0
- package/dist/utils/paramcoders/ParamEncoder.d.ts +9 -0
- package/dist/utils/paramcoders/ParamEncoder.js +22 -0
- package/dist/utils/paramcoders/SchemaVerifier.d.ts +22 -0
- package/dist/utils/paramcoders/SchemaVerifier.js +85 -0
- package/dist/utils/paramcoders/server/ServerParamDecoder.d.ts +8 -0
- package/dist/utils/paramcoders/server/ServerParamDecoder.js +105 -0
- package/dist/utils/paramcoders/server/ServerParamEncoder.d.ts +11 -0
- package/dist/utils/paramcoders/server/ServerParamEncoder.js +76 -0
- package/package.json +43 -0
- package/src/fees/IBtcFeeEstimator.ts +7 -0
- package/src/fees/OneDollarFeeEstimator.ts +95 -0
- package/src/index.ts +46 -0
- package/src/info/InfoHandler.ts +106 -0
- package/src/plugins/IPlugin.ts +155 -0
- package/src/plugins/PluginManager.ts +310 -0
- package/src/prices/BinanceSwapPrice.ts +114 -0
- package/src/prices/CoinGeckoSwapPrice.ts +88 -0
- package/src/storage/IIntermediaryStorage.ts +21 -0
- package/src/storagemanager/IntermediaryStorageManager.ts +101 -0
- package/src/storagemanager/StorageManager.ts +68 -0
- package/src/swaps/FromBtcBaseSwap.ts +21 -0
- package/src/swaps/FromBtcBaseSwapHandler.ts +375 -0
- package/src/swaps/FromBtcLnBaseSwapHandler.ts +48 -0
- package/src/swaps/ISwapPrice.ts +94 -0
- package/src/swaps/SwapHandler.ts +404 -0
- package/src/swaps/SwapHandlerSwap.ts +133 -0
- package/src/swaps/ToBtcBaseSwap.ts +76 -0
- package/src/swaps/ToBtcBaseSwapHandler.ts +309 -0
- package/src/swaps/frombtc_abstract/FromBtcAbs.ts +484 -0
- package/src/swaps/frombtc_abstract/FromBtcSwapAbs.ts +77 -0
- package/src/swaps/frombtc_trusted/FromBtcTrusted.ts +661 -0
- package/src/swaps/frombtc_trusted/FromBtcTrustedSwap.ts +158 -0
- package/src/swaps/frombtcln_abstract/FromBtcLnAbs.ts +864 -0
- package/src/swaps/frombtcln_abstract/FromBtcLnSwapAbs.ts +82 -0
- package/src/swaps/frombtcln_trusted/FromBtcLnTrusted.ts +592 -0
- package/src/swaps/frombtcln_trusted/FromBtcLnTrustedSwap.ts +90 -0
- package/src/swaps/tobtc_abstract/ToBtcAbs.ts +1249 -0
- package/src/swaps/tobtc_abstract/ToBtcSwapAbs.ts +112 -0
- package/src/swaps/tobtcln_abstract/ToBtcLnAbs.ts +1422 -0
- package/src/swaps/tobtcln_abstract/ToBtcLnSwapAbs.ts +87 -0
- package/src/utils/Utils.ts +108 -0
- package/src/utils/coinselect2/accumulative.js +32 -0
- package/src/utils/coinselect2/accumulative.ts +58 -0
- package/src/utils/coinselect2/blackjack.js +29 -0
- package/src/utils/coinselect2/blackjack.ts +54 -0
- package/src/utils/coinselect2/index.js +16 -0
- package/src/utils/coinselect2/index.ts +50 -0
- package/src/utils/coinselect2/utils.js +110 -0
- package/src/utils/coinselect2/utils.ts +183 -0
- package/src/utils/paramcoders/IParamReader.ts +8 -0
- package/src/utils/paramcoders/IParamWriter.ts +8 -0
- package/src/utils/paramcoders/LegacyParamEncoder.ts +28 -0
- package/src/utils/paramcoders/ParamDecoder.ts +219 -0
- package/src/utils/paramcoders/ParamEncoder.ts +30 -0
- package/src/utils/paramcoders/SchemaVerifier.ts +97 -0
- package/src/utils/paramcoders/server/ServerParamDecoder.ts +115 -0
- package/src/utils/paramcoders/server/ServerParamEncoder.ts +76 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as BN from "bn.js";
|
|
2
|
+
import { SwapData } from "@atomiqlabs/base";
|
|
3
|
+
import { ToBtcBaseSwap } from "../ToBtcBaseSwap";
|
|
4
|
+
export declare enum ToBtcSwapState {
|
|
5
|
+
REFUNDED = -3,
|
|
6
|
+
CANCELED = -2,
|
|
7
|
+
NON_PAYABLE = -1,
|
|
8
|
+
SAVED = 0,
|
|
9
|
+
COMMITED = 1,
|
|
10
|
+
BTC_SENDING = 2,
|
|
11
|
+
BTC_SENT = 3,
|
|
12
|
+
CLAIMED = 4
|
|
13
|
+
}
|
|
14
|
+
export declare class ToBtcSwapAbs<T extends SwapData = SwapData> extends ToBtcBaseSwap<T, ToBtcSwapState> {
|
|
15
|
+
readonly address: string;
|
|
16
|
+
readonly amount: BN;
|
|
17
|
+
readonly satsPerVbyte: BN;
|
|
18
|
+
readonly nonce: BN;
|
|
19
|
+
readonly preferedConfirmationTarget: number;
|
|
20
|
+
readonly signatureExpiry: BN;
|
|
21
|
+
txId: string;
|
|
22
|
+
constructor(chainIdentifier: string, address: string, amount: BN, swapFee: BN, swapFeeInToken: BN, networkFee: BN, networkFeeInToken: BN, satsPerVbyte: BN, nonce: BN, preferedConfirmationTarget: number, signatureExpiry: BN);
|
|
23
|
+
constructor(obj: any);
|
|
24
|
+
serialize(): any;
|
|
25
|
+
isInitiated(): boolean;
|
|
26
|
+
isFailed(): boolean;
|
|
27
|
+
isSuccess(): boolean;
|
|
28
|
+
getOutputAmount(): BN;
|
|
29
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToBtcSwapAbs = exports.ToBtcSwapState = void 0;
|
|
4
|
+
const BN = require("bn.js");
|
|
5
|
+
const __1 = require("../..");
|
|
6
|
+
const ToBtcBaseSwap_1 = require("../ToBtcBaseSwap");
|
|
7
|
+
const Utils_1 = require("../../utils/Utils");
|
|
8
|
+
var ToBtcSwapState;
|
|
9
|
+
(function (ToBtcSwapState) {
|
|
10
|
+
ToBtcSwapState[ToBtcSwapState["REFUNDED"] = -3] = "REFUNDED";
|
|
11
|
+
ToBtcSwapState[ToBtcSwapState["CANCELED"] = -2] = "CANCELED";
|
|
12
|
+
ToBtcSwapState[ToBtcSwapState["NON_PAYABLE"] = -1] = "NON_PAYABLE";
|
|
13
|
+
ToBtcSwapState[ToBtcSwapState["SAVED"] = 0] = "SAVED";
|
|
14
|
+
ToBtcSwapState[ToBtcSwapState["COMMITED"] = 1] = "COMMITED";
|
|
15
|
+
ToBtcSwapState[ToBtcSwapState["BTC_SENDING"] = 2] = "BTC_SENDING";
|
|
16
|
+
ToBtcSwapState[ToBtcSwapState["BTC_SENT"] = 3] = "BTC_SENT";
|
|
17
|
+
ToBtcSwapState[ToBtcSwapState["CLAIMED"] = 4] = "CLAIMED";
|
|
18
|
+
})(ToBtcSwapState = exports.ToBtcSwapState || (exports.ToBtcSwapState = {}));
|
|
19
|
+
class ToBtcSwapAbs extends ToBtcBaseSwap_1.ToBtcBaseSwap {
|
|
20
|
+
constructor(chainIdOrObj, address, amount, swapFee, swapFeeInToken, networkFee, networkFeeInToken, satsPerVbyte, nonce, preferedConfirmationTarget, signatureExpiry) {
|
|
21
|
+
var _a;
|
|
22
|
+
if (typeof (chainIdOrObj) === "string") {
|
|
23
|
+
super(chainIdOrObj, swapFee, swapFeeInToken, networkFee, networkFeeInToken);
|
|
24
|
+
this.state = ToBtcSwapState.SAVED;
|
|
25
|
+
this.address = address;
|
|
26
|
+
this.amount = amount;
|
|
27
|
+
this.satsPerVbyte = satsPerVbyte;
|
|
28
|
+
this.nonce = nonce;
|
|
29
|
+
this.preferedConfirmationTarget = preferedConfirmationTarget;
|
|
30
|
+
this.signatureExpiry = signatureExpiry;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
super(chainIdOrObj);
|
|
34
|
+
this.address = chainIdOrObj.address;
|
|
35
|
+
this.amount = new BN(chainIdOrObj.amount);
|
|
36
|
+
this.satsPerVbyte = new BN(chainIdOrObj.satsPerVbyte);
|
|
37
|
+
this.nonce = new BN(chainIdOrObj.nonce);
|
|
38
|
+
this.preferedConfirmationTarget = chainIdOrObj.preferedConfirmationTarget;
|
|
39
|
+
this.signatureExpiry = (0, Utils_1.deserializeBN)(chainIdOrObj.signatureExpiry);
|
|
40
|
+
this.txId = chainIdOrObj.txId;
|
|
41
|
+
//Compatibility
|
|
42
|
+
(_a = this.quotedNetworkFee) !== null && _a !== void 0 ? _a : (this.quotedNetworkFee = (0, Utils_1.deserializeBN)(chainIdOrObj.networkFee));
|
|
43
|
+
}
|
|
44
|
+
this.type = __1.SwapHandlerType.TO_BTC;
|
|
45
|
+
}
|
|
46
|
+
serialize() {
|
|
47
|
+
const partialSerialized = super.serialize();
|
|
48
|
+
partialSerialized.address = this.address;
|
|
49
|
+
partialSerialized.amount = this.amount.toString(10);
|
|
50
|
+
partialSerialized.satsPerVbyte = this.satsPerVbyte.toString(10);
|
|
51
|
+
partialSerialized.nonce = this.nonce.toString(10);
|
|
52
|
+
partialSerialized.preferedConfirmationTarget = this.preferedConfirmationTarget;
|
|
53
|
+
partialSerialized.signatureExpiry = (0, Utils_1.serializeBN)(this.signatureExpiry);
|
|
54
|
+
partialSerialized.txId = this.txId;
|
|
55
|
+
return partialSerialized;
|
|
56
|
+
}
|
|
57
|
+
isInitiated() {
|
|
58
|
+
return this.state !== ToBtcSwapState.SAVED;
|
|
59
|
+
}
|
|
60
|
+
isFailed() {
|
|
61
|
+
return this.state === ToBtcSwapState.NON_PAYABLE || this.state === ToBtcSwapState.REFUNDED || this.state === ToBtcSwapState.CANCELED;
|
|
62
|
+
}
|
|
63
|
+
isSuccess() {
|
|
64
|
+
return this.state === ToBtcSwapState.CLAIMED;
|
|
65
|
+
}
|
|
66
|
+
getOutputAmount() {
|
|
67
|
+
return this.amount;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.ToBtcSwapAbs = ToBtcSwapAbs;
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import * as BN from "bn.js";
|
|
2
|
+
import { Express } from "express";
|
|
3
|
+
import { ToBtcLnSwapAbs, ToBtcLnSwapState } from "./ToBtcLnSwapAbs";
|
|
4
|
+
import { MultichainData, SwapHandlerType } from "../SwapHandler";
|
|
5
|
+
import { ISwapPrice } from "../ISwapPrice";
|
|
6
|
+
import { ClaimEvent, InitializeEvent, RefundEvent, SwapData } from "@atomiqlabs/base";
|
|
7
|
+
import { AuthenticatedLnd } from "lightning";
|
|
8
|
+
import { IIntermediaryStorage } from "../../storage/IIntermediaryStorage";
|
|
9
|
+
import { ToBtcBaseConfig, ToBtcBaseSwapHandler } from "../ToBtcBaseSwapHandler";
|
|
10
|
+
export type ToBtcLnConfig = ToBtcBaseConfig & {
|
|
11
|
+
routingFeeMultiplier: BN;
|
|
12
|
+
minSendCltv: BN;
|
|
13
|
+
allowProbeFailedSwaps: boolean;
|
|
14
|
+
allowShortExpiry: boolean;
|
|
15
|
+
minLnRoutingFeePPM?: BN;
|
|
16
|
+
minLnBaseFee?: BN;
|
|
17
|
+
exactInExpiry?: number;
|
|
18
|
+
};
|
|
19
|
+
type LNRoutes = {
|
|
20
|
+
public_key: string;
|
|
21
|
+
fee_rate?: number;
|
|
22
|
+
cltv_delta?: number;
|
|
23
|
+
channel?: string;
|
|
24
|
+
base_fee_mtokens?: string;
|
|
25
|
+
}[][];
|
|
26
|
+
type ExactInAuthorization = {
|
|
27
|
+
chainIdentifier: string;
|
|
28
|
+
reqId: string;
|
|
29
|
+
expiry: number;
|
|
30
|
+
amount: BN;
|
|
31
|
+
destination: string;
|
|
32
|
+
cltvDelta: number;
|
|
33
|
+
routes: LNRoutes;
|
|
34
|
+
quotedNetworkFeeInToken: BN;
|
|
35
|
+
swapFeeInToken: BN;
|
|
36
|
+
total: BN;
|
|
37
|
+
confidence: number;
|
|
38
|
+
quotedNetworkFee: BN;
|
|
39
|
+
swapFee: BN;
|
|
40
|
+
token: string;
|
|
41
|
+
swapExpiry: BN;
|
|
42
|
+
offerer: string;
|
|
43
|
+
preFetchSignData: any;
|
|
44
|
+
metadata: {
|
|
45
|
+
request: any;
|
|
46
|
+
probeRequest?: any;
|
|
47
|
+
probeResponse?: any;
|
|
48
|
+
routeResponse?: any;
|
|
49
|
+
times: {
|
|
50
|
+
[key: string]: number;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export type ToBtcLnRequestType = {
|
|
55
|
+
pr: string;
|
|
56
|
+
maxFee: BN;
|
|
57
|
+
expiryTimestamp: BN;
|
|
58
|
+
token: string;
|
|
59
|
+
offerer: string;
|
|
60
|
+
exactIn?: boolean;
|
|
61
|
+
amount?: BN;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Swap handler handling to BTCLN swaps using submarine swaps
|
|
65
|
+
*/
|
|
66
|
+
export declare class ToBtcLnAbs extends ToBtcBaseSwapHandler<ToBtcLnSwapAbs, ToBtcLnSwapState> {
|
|
67
|
+
protected readonly LIGHTNING_LIQUIDITY_CACHE_TIMEOUT: number;
|
|
68
|
+
activeSubscriptions: Set<string>;
|
|
69
|
+
lightningLiquidityCache: {
|
|
70
|
+
liquidityMTokens: BN;
|
|
71
|
+
timestamp: number;
|
|
72
|
+
};
|
|
73
|
+
readonly type = SwapHandlerType.TO_BTCLN;
|
|
74
|
+
readonly config: ToBtcLnConfig & {
|
|
75
|
+
minTsSendCltv: BN;
|
|
76
|
+
};
|
|
77
|
+
readonly exactInAuths: {
|
|
78
|
+
[reqId: string]: ExactInAuthorization;
|
|
79
|
+
};
|
|
80
|
+
constructor(storageDirectory: IIntermediaryStorage<ToBtcLnSwapAbs>, path: string, chainData: MultichainData, lnd: AuthenticatedLnd, swapPricing: ISwapPrice, config: ToBtcLnConfig);
|
|
81
|
+
/**
|
|
82
|
+
* Fetches the payment info, returns null if payment not found
|
|
83
|
+
*
|
|
84
|
+
* @param paymentHash
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
private getPayment;
|
|
88
|
+
/**
|
|
89
|
+
* Cleans up exactIn authorization that are already past their expiry
|
|
90
|
+
*
|
|
91
|
+
* @protected
|
|
92
|
+
*/
|
|
93
|
+
private cleanExpiredExactInAuthorizations;
|
|
94
|
+
protected processPastSwap(swap: ToBtcLnSwapAbs): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Checks past swaps, deletes ones that are already expired, and tries to process ones that are committed.
|
|
97
|
+
*/
|
|
98
|
+
protected processPastSwaps(): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Tries to claim the swap funds on the SC side, returns false if the swap is already locked (claim tx is already being sent)
|
|
101
|
+
*
|
|
102
|
+
* @param swap
|
|
103
|
+
* @private
|
|
104
|
+
* @returns Whether the transaction was successfully sent
|
|
105
|
+
*/
|
|
106
|
+
private tryClaimSwap;
|
|
107
|
+
/**
|
|
108
|
+
* Process the result of attempted lightning network payment
|
|
109
|
+
*
|
|
110
|
+
* @param swap
|
|
111
|
+
* @param lnPaymentStatus
|
|
112
|
+
*/
|
|
113
|
+
private processPaymentResult;
|
|
114
|
+
/**
|
|
115
|
+
* Subscribe to a pending lightning network payment attempt
|
|
116
|
+
*
|
|
117
|
+
* @param invoiceData
|
|
118
|
+
*/
|
|
119
|
+
private subscribeToPayment;
|
|
120
|
+
private sendLightningPayment;
|
|
121
|
+
/**
|
|
122
|
+
* Begins a lightning network payment attempt, if not attempted already
|
|
123
|
+
*
|
|
124
|
+
* @param swap
|
|
125
|
+
*/
|
|
126
|
+
private processInitialized;
|
|
127
|
+
protected processInitializeEvent(chainIdentifier: string, event: InitializeEvent<SwapData>): Promise<void>;
|
|
128
|
+
protected processClaimEvent(chainIdentifier: string, event: ClaimEvent<SwapData>): Promise<void>;
|
|
129
|
+
protected processRefundEvent(chainIdentifier: string, event: RefundEvent<SwapData>): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Checks if the amount was supplied in the exactIn request
|
|
132
|
+
*
|
|
133
|
+
* @param amount
|
|
134
|
+
* @param exactIn
|
|
135
|
+
* @throws {DefinedRuntimeError} will throw an error if the swap was exactIn, but amount not specified
|
|
136
|
+
*/
|
|
137
|
+
private checkAmount;
|
|
138
|
+
/**
|
|
139
|
+
* Checks if the maxFee parameter is in valid range (>0)
|
|
140
|
+
*
|
|
141
|
+
* @param maxFee
|
|
142
|
+
* @throws {DefinedRuntimeError} will throw an error if the maxFee is zero or negative
|
|
143
|
+
*/
|
|
144
|
+
private checkMaxFee;
|
|
145
|
+
/**
|
|
146
|
+
* Checks and parses a payment request (bolt11 invoice), additionally also checks expiration time of the invoice
|
|
147
|
+
*
|
|
148
|
+
* @param pr
|
|
149
|
+
* @throws {DefinedRuntimeError} will throw an error if the pr is invalid, without amount or expired
|
|
150
|
+
*/
|
|
151
|
+
private checkPaymentRequest;
|
|
152
|
+
/**
|
|
153
|
+
* Checks if the request specified too short of an expiry
|
|
154
|
+
*
|
|
155
|
+
* @param expiryTimestamp
|
|
156
|
+
* @param currentTimestamp
|
|
157
|
+
* @throws {DefinedRuntimeError} will throw an error if the expiry time is too short
|
|
158
|
+
*/
|
|
159
|
+
private checkExpiry;
|
|
160
|
+
/**
|
|
161
|
+
* Checks if the prior payment with the same paymentHash exists
|
|
162
|
+
*
|
|
163
|
+
* @param paymentHash
|
|
164
|
+
* @param abortSignal
|
|
165
|
+
* @throws {DefinedRuntimeError} will throw an error if payment already exists
|
|
166
|
+
*/
|
|
167
|
+
private checkPriorPayment;
|
|
168
|
+
/**
|
|
169
|
+
* Checks if the underlying LND backend has enough liquidity in channels to honor the swap
|
|
170
|
+
*
|
|
171
|
+
* @param amount
|
|
172
|
+
* @param abortSignal
|
|
173
|
+
* @param useCached Whether to use cached liquidity values
|
|
174
|
+
* @throws {DefinedRuntimeError} will throw an error if there isn't enough liquidity
|
|
175
|
+
*/
|
|
176
|
+
private checkLiquidity;
|
|
177
|
+
/**
|
|
178
|
+
* Computes the route paying to the specified bolt11 invoice, estimating the fee, uses bLIP-39 blinded paths
|
|
179
|
+
*
|
|
180
|
+
* @param amountSats
|
|
181
|
+
* @param maxFee
|
|
182
|
+
* @param parsedRequest
|
|
183
|
+
* @param maxTimeoutBlockheight
|
|
184
|
+
* @param metadata
|
|
185
|
+
* @param maxUsableCLTV
|
|
186
|
+
* @private
|
|
187
|
+
*/
|
|
188
|
+
private getRoutesInvoiceBLIP39;
|
|
189
|
+
/**
|
|
190
|
+
* Computes the route paying to the specified bolt11 invoice, estimating the fee
|
|
191
|
+
*
|
|
192
|
+
* @param amountSats
|
|
193
|
+
* @param maxFee
|
|
194
|
+
* @param parsedRequest
|
|
195
|
+
* @param maxTimeoutBlockheight
|
|
196
|
+
* @param metadata
|
|
197
|
+
* @param maxUsableCLTV
|
|
198
|
+
* @private
|
|
199
|
+
*/
|
|
200
|
+
private getRoutesInvoice;
|
|
201
|
+
/**
|
|
202
|
+
* Sends a probe payment to the specified bolt11 invoice to check if it is reachable
|
|
203
|
+
*
|
|
204
|
+
* @param amountSats
|
|
205
|
+
* @param maxFee
|
|
206
|
+
* @param parsedRequest
|
|
207
|
+
* @param maxTimeoutBlockheight
|
|
208
|
+
* @param metadata
|
|
209
|
+
* @private
|
|
210
|
+
*/
|
|
211
|
+
private probeInvoice;
|
|
212
|
+
/**
|
|
213
|
+
* Estimates the routing fee & confidence by either probing or routing (if probing fails), the fee is also adjusted
|
|
214
|
+
* according to routing fee multiplier, and subject to minimums set in config
|
|
215
|
+
*
|
|
216
|
+
* @param amountBD
|
|
217
|
+
* @param maxFee
|
|
218
|
+
* @param expiryTimestamp
|
|
219
|
+
* @param currentTimestamp
|
|
220
|
+
* @param pr
|
|
221
|
+
* @param metadata
|
|
222
|
+
* @param abortSignal
|
|
223
|
+
* @throws {DefinedRuntimeError} will throw an error if the destination is unreachable
|
|
224
|
+
*/
|
|
225
|
+
private checkAndGetNetworkFee;
|
|
226
|
+
/**
|
|
227
|
+
* Checks and consumes (deletes & returns) exactIn authorizaton with a specific reqId
|
|
228
|
+
*
|
|
229
|
+
* @param reqId
|
|
230
|
+
* @throws {DefinedRuntimeError} will throw an error if the authorization doesn't exist
|
|
231
|
+
*/
|
|
232
|
+
private checkExactInAuthorization;
|
|
233
|
+
/**
|
|
234
|
+
* Checks if the newly submitted PR has the same parameters (destination, cltv_delta, routes) as the initial dummy
|
|
235
|
+
* invoice sent for exactIn swap quote
|
|
236
|
+
*
|
|
237
|
+
* @param pr
|
|
238
|
+
* @param parsedAuth
|
|
239
|
+
* @throws {DefinedRuntimeError} will throw an error if the details don't match
|
|
240
|
+
*/
|
|
241
|
+
private checkPaymentRequestMatchesInitial;
|
|
242
|
+
startRestServer(restServer: Express): void;
|
|
243
|
+
init(): Promise<void>;
|
|
244
|
+
getInfoData(): any;
|
|
245
|
+
}
|
|
246
|
+
export {};
|