@atomiqlabs/lp-lib 15.0.14 → 16.0.0
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 -40
- package/dist/index.js +58 -56
- package/dist/info/InfoHandler.d.ts +17 -17
- package/dist/info/InfoHandler.js +58 -58
- package/dist/plugins/IPlugin.d.ts +144 -144
- package/dist/plugins/IPlugin.js +34 -34
- package/dist/plugins/PluginManager.d.ts +113 -113
- package/dist/plugins/PluginManager.js +274 -274
- 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 -18
- package/dist/storagemanager/IntermediaryStorageManager.js +111 -104
- package/dist/storagemanager/StorageManager.d.ts +13 -12
- package/dist/storagemanager/StorageManager.js +64 -57
- package/dist/swaps/SwapHandler.d.ts +150 -153
- package/dist/swaps/SwapHandler.js +154 -157
- 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 +74 -74
- 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 -101
- package/dist/swaps/escrow/FromBtcBaseSwapHandler.js +210 -207
- 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 +673 -673
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.d.ts +33 -32
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.js +91 -88
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.d.ts +111 -0
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.js +682 -0
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.d.ts +55 -0
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.js +120 -0
- package/dist/swaps/escrow/tobtc_abstract/ToBtcAbs.d.ts +169 -171
- package/dist/swaps/escrow/tobtc_abstract/ToBtcAbs.js +735 -718
- package/dist/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.d.ts +28 -28
- package/dist/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.js +64 -64
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.d.ts +177 -177
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.js +865 -863
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.d.ts +24 -24
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.js +58 -58
- package/dist/swaps/spv_vault_swap/SpvVault.d.ts +44 -45
- package/dist/swaps/spv_vault_swap/SpvVault.js +145 -145
- package/dist/swaps/spv_vault_swap/SpvVaultSwap.d.ts +68 -68
- 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 +530 -528
- package/dist/swaps/spv_vault_swap/SpvVaults.d.ts +63 -68
- package/dist/swaps/spv_vault_swap/SpvVaults.js +488 -454
- 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 +492 -493
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.d.ts +34 -34
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.js +81 -81
- package/dist/utils/BitcoinUtils.d.ts +4 -4
- package/dist/utils/BitcoinUtils.js +61 -61
- package/dist/utils/Utils.d.ts +29 -29
- package/dist/utils/Utils.js +89 -88
- 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 -105
- 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 +74 -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 -51
- package/src/info/InfoHandler.ts +100 -100
- package/src/plugins/IPlugin.ts +174 -174
- package/src/plugins/PluginManager.ts +354 -354
- 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 -109
- package/src/storagemanager/StorageManager.ts +78 -68
- package/src/swaps/SwapHandler.ts +269 -272
- package/src/swaps/SwapHandlerSwap.ts +141 -141
- package/src/swaps/assertions/AmountAssertions.ts +77 -77
- 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 -283
- 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 +855 -855
- package/src/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.ts +141 -137
- package/src/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.ts +847 -0
- package/src/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.ts +196 -0
- package/src/swaps/escrow/tobtc_abstract/ToBtcAbs.ts +909 -890
- package/src/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.ts +108 -108
- package/src/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.ts +1116 -1112
- package/src/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.ts +80 -80
- package/src/swaps/spv_vault_swap/SpvVault.ts +178 -178
- package/src/swaps/spv_vault_swap/SpvVaultSwap.ts +228 -228
- package/src/swaps/spv_vault_swap/SpvVaultSwapHandler.ts +673 -671
- package/src/swaps/spv_vault_swap/SpvVaults.ts +565 -526
- 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 +589 -591
- package/src/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.ts +121 -121
- package/src/utils/BitcoinUtils.ts +59 -59
- package/src/utils/Utils.ts +104 -102
- 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 -115
- package/src/utils/paramcoders/server/ServerParamEncoder.ts +75 -75
- package/src/wallets/IBitcoinWallet.ts +76 -68
- package/src/wallets/ILightningWallet.ts +178 -178
- package/src/wallets/ISpvVaultSigner.ts +10 -10
- package/dist/wallets/ISpvVaultWallet.d.ts +0 -42
- package/dist/wallets/ISpvVaultWallet.js +0 -2
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { SwapData } from "@atomiqlabs/base";
|
|
2
|
-
import { ToBtcBaseSwap } from "../ToBtcBaseSwap";
|
|
3
|
-
export declare enum ToBtcLnSwapState {
|
|
4
|
-
REFUNDED = -3,
|
|
5
|
-
CANCELED = -2,
|
|
6
|
-
NON_PAYABLE = -1,
|
|
7
|
-
SAVED = 0,
|
|
8
|
-
COMMITED = 1,
|
|
9
|
-
PAID = 2,
|
|
10
|
-
CLAIMED = 3
|
|
11
|
-
}
|
|
12
|
-
export declare class ToBtcLnSwapAbs<T extends SwapData = SwapData> extends ToBtcBaseSwap<T, ToBtcLnSwapState> {
|
|
13
|
-
lnPaymentHash: string;
|
|
14
|
-
readonly pr: string;
|
|
15
|
-
payInitiated: boolean;
|
|
16
|
-
secret: string;
|
|
17
|
-
constructor(chainIdentifier: string, lnPaymentHash: string, pr: string, amountMtokens: bigint, swapFee: bigint, swapFeeInToken: bigint, quotedNetworkFee: bigint, quotedNetworkFeeInToken: bigint);
|
|
18
|
-
constructor(obj: any);
|
|
19
|
-
getIdentifierHash(): string;
|
|
20
|
-
serialize(): any;
|
|
21
|
-
isInitiated(): boolean;
|
|
22
|
-
isFailed(): boolean;
|
|
23
|
-
isSuccess(): boolean;
|
|
24
|
-
}
|
|
1
|
+
import { SwapData } from "@atomiqlabs/base";
|
|
2
|
+
import { ToBtcBaseSwap } from "../ToBtcBaseSwap";
|
|
3
|
+
export declare enum ToBtcLnSwapState {
|
|
4
|
+
REFUNDED = -3,
|
|
5
|
+
CANCELED = -2,
|
|
6
|
+
NON_PAYABLE = -1,
|
|
7
|
+
SAVED = 0,
|
|
8
|
+
COMMITED = 1,
|
|
9
|
+
PAID = 2,
|
|
10
|
+
CLAIMED = 3
|
|
11
|
+
}
|
|
12
|
+
export declare class ToBtcLnSwapAbs<T extends SwapData = SwapData> extends ToBtcBaseSwap<T, ToBtcLnSwapState> {
|
|
13
|
+
lnPaymentHash: string;
|
|
14
|
+
readonly pr: string;
|
|
15
|
+
payInitiated: boolean;
|
|
16
|
+
secret: string;
|
|
17
|
+
constructor(chainIdentifier: string, lnPaymentHash: string, pr: string, amountMtokens: bigint, swapFee: bigint, swapFeeInToken: bigint, quotedNetworkFee: bigint, quotedNetworkFeeInToken: bigint);
|
|
18
|
+
constructor(obj: any);
|
|
19
|
+
getIdentifierHash(): string;
|
|
20
|
+
serialize(): any;
|
|
21
|
+
isInitiated(): boolean;
|
|
22
|
+
isFailed(): boolean;
|
|
23
|
+
isSuccess(): boolean;
|
|
24
|
+
}
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ToBtcLnSwapAbs = exports.ToBtcLnSwapState = void 0;
|
|
4
|
-
const index_1 = require("../../../index");
|
|
5
|
-
const Utils_1 = require("../../../utils/Utils");
|
|
6
|
-
const ToBtcBaseSwap_1 = require("../ToBtcBaseSwap");
|
|
7
|
-
var ToBtcLnSwapState;
|
|
8
|
-
(function (ToBtcLnSwapState) {
|
|
9
|
-
ToBtcLnSwapState[ToBtcLnSwapState["REFUNDED"] = -3] = "REFUNDED";
|
|
10
|
-
ToBtcLnSwapState[ToBtcLnSwapState["CANCELED"] = -2] = "CANCELED";
|
|
11
|
-
ToBtcLnSwapState[ToBtcLnSwapState["NON_PAYABLE"] = -1] = "NON_PAYABLE";
|
|
12
|
-
ToBtcLnSwapState[ToBtcLnSwapState["SAVED"] = 0] = "SAVED";
|
|
13
|
-
ToBtcLnSwapState[ToBtcLnSwapState["COMMITED"] = 1] = "COMMITED";
|
|
14
|
-
ToBtcLnSwapState[ToBtcLnSwapState["PAID"] = 2] = "PAID";
|
|
15
|
-
ToBtcLnSwapState[ToBtcLnSwapState["CLAIMED"] = 3] = "CLAIMED";
|
|
16
|
-
})(ToBtcLnSwapState = exports.ToBtcLnSwapState || (exports.ToBtcLnSwapState = {}));
|
|
17
|
-
class ToBtcLnSwapAbs extends ToBtcBaseSwap_1.ToBtcBaseSwap {
|
|
18
|
-
constructor(chainIdOrObj, lnPaymentHash, pr, amount, swapFee, swapFeeInToken, quotedNetworkFee, quotedNetworkFeeInToken) {
|
|
19
|
-
if (typeof (chainIdOrObj) === "string") {
|
|
20
|
-
super(chainIdOrObj, (amount + 999n) / 1000n, swapFee, swapFeeInToken, quotedNetworkFee, quotedNetworkFeeInToken);
|
|
21
|
-
this.state = ToBtcLnSwapState.SAVED;
|
|
22
|
-
this.lnPaymentHash = lnPaymentHash;
|
|
23
|
-
this.pr = pr;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
super(chainIdOrObj);
|
|
27
|
-
this.pr = chainIdOrObj.pr;
|
|
28
|
-
this.secret = chainIdOrObj.secret;
|
|
29
|
-
this.lnPaymentHash = chainIdOrObj.lnPaymentHash;
|
|
30
|
-
this.payInitiated = chainIdOrObj.payInitiated;
|
|
31
|
-
//Compatibility with older versions
|
|
32
|
-
this.quotedNetworkFee ?? (this.quotedNetworkFee = (0, Utils_1.deserializeBN)(chainIdOrObj.maxFee));
|
|
33
|
-
this.realNetworkFee ?? (this.realNetworkFee = (0, Utils_1.deserializeBN)(chainIdOrObj.realRoutingFee));
|
|
34
|
-
}
|
|
35
|
-
this.type = index_1.SwapHandlerType.TO_BTCLN;
|
|
36
|
-
}
|
|
37
|
-
getIdentifierHash() {
|
|
38
|
-
return this.lnPaymentHash;
|
|
39
|
-
}
|
|
40
|
-
serialize() {
|
|
41
|
-
const partialSerialized = super.serialize();
|
|
42
|
-
partialSerialized.pr = this.pr;
|
|
43
|
-
partialSerialized.lnPaymentHash = this.lnPaymentHash;
|
|
44
|
-
partialSerialized.secret = this.secret;
|
|
45
|
-
partialSerialized.payInitiated = this.payInitiated;
|
|
46
|
-
return partialSerialized;
|
|
47
|
-
}
|
|
48
|
-
isInitiated() {
|
|
49
|
-
return this.state !== ToBtcLnSwapState.SAVED;
|
|
50
|
-
}
|
|
51
|
-
isFailed() {
|
|
52
|
-
return this.state === ToBtcLnSwapState.NON_PAYABLE || this.state === ToBtcLnSwapState.CANCELED || this.state === ToBtcLnSwapState.REFUNDED;
|
|
53
|
-
}
|
|
54
|
-
isSuccess() {
|
|
55
|
-
return this.state === ToBtcLnSwapState.CLAIMED;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.ToBtcLnSwapAbs = ToBtcLnSwapAbs;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToBtcLnSwapAbs = exports.ToBtcLnSwapState = void 0;
|
|
4
|
+
const index_1 = require("../../../index");
|
|
5
|
+
const Utils_1 = require("../../../utils/Utils");
|
|
6
|
+
const ToBtcBaseSwap_1 = require("../ToBtcBaseSwap");
|
|
7
|
+
var ToBtcLnSwapState;
|
|
8
|
+
(function (ToBtcLnSwapState) {
|
|
9
|
+
ToBtcLnSwapState[ToBtcLnSwapState["REFUNDED"] = -3] = "REFUNDED";
|
|
10
|
+
ToBtcLnSwapState[ToBtcLnSwapState["CANCELED"] = -2] = "CANCELED";
|
|
11
|
+
ToBtcLnSwapState[ToBtcLnSwapState["NON_PAYABLE"] = -1] = "NON_PAYABLE";
|
|
12
|
+
ToBtcLnSwapState[ToBtcLnSwapState["SAVED"] = 0] = "SAVED";
|
|
13
|
+
ToBtcLnSwapState[ToBtcLnSwapState["COMMITED"] = 1] = "COMMITED";
|
|
14
|
+
ToBtcLnSwapState[ToBtcLnSwapState["PAID"] = 2] = "PAID";
|
|
15
|
+
ToBtcLnSwapState[ToBtcLnSwapState["CLAIMED"] = 3] = "CLAIMED";
|
|
16
|
+
})(ToBtcLnSwapState = exports.ToBtcLnSwapState || (exports.ToBtcLnSwapState = {}));
|
|
17
|
+
class ToBtcLnSwapAbs extends ToBtcBaseSwap_1.ToBtcBaseSwap {
|
|
18
|
+
constructor(chainIdOrObj, lnPaymentHash, pr, amount, swapFee, swapFeeInToken, quotedNetworkFee, quotedNetworkFeeInToken) {
|
|
19
|
+
if (typeof (chainIdOrObj) === "string") {
|
|
20
|
+
super(chainIdOrObj, (amount + 999n) / 1000n, swapFee, swapFeeInToken, quotedNetworkFee, quotedNetworkFeeInToken);
|
|
21
|
+
this.state = ToBtcLnSwapState.SAVED;
|
|
22
|
+
this.lnPaymentHash = lnPaymentHash;
|
|
23
|
+
this.pr = pr;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
super(chainIdOrObj);
|
|
27
|
+
this.pr = chainIdOrObj.pr;
|
|
28
|
+
this.secret = chainIdOrObj.secret;
|
|
29
|
+
this.lnPaymentHash = chainIdOrObj.lnPaymentHash;
|
|
30
|
+
this.payInitiated = chainIdOrObj.payInitiated;
|
|
31
|
+
//Compatibility with older versions
|
|
32
|
+
this.quotedNetworkFee ?? (this.quotedNetworkFee = (0, Utils_1.deserializeBN)(chainIdOrObj.maxFee));
|
|
33
|
+
this.realNetworkFee ?? (this.realNetworkFee = (0, Utils_1.deserializeBN)(chainIdOrObj.realRoutingFee));
|
|
34
|
+
}
|
|
35
|
+
this.type = index_1.SwapHandlerType.TO_BTCLN;
|
|
36
|
+
}
|
|
37
|
+
getIdentifierHash() {
|
|
38
|
+
return this.lnPaymentHash;
|
|
39
|
+
}
|
|
40
|
+
serialize() {
|
|
41
|
+
const partialSerialized = super.serialize();
|
|
42
|
+
partialSerialized.pr = this.pr;
|
|
43
|
+
partialSerialized.lnPaymentHash = this.lnPaymentHash;
|
|
44
|
+
partialSerialized.secret = this.secret;
|
|
45
|
+
partialSerialized.payInitiated = this.payInitiated;
|
|
46
|
+
return partialSerialized;
|
|
47
|
+
}
|
|
48
|
+
isInitiated() {
|
|
49
|
+
return this.state !== ToBtcLnSwapState.SAVED;
|
|
50
|
+
}
|
|
51
|
+
isFailed() {
|
|
52
|
+
return this.state === ToBtcLnSwapState.NON_PAYABLE || this.state === ToBtcLnSwapState.CANCELED || this.state === ToBtcLnSwapState.REFUNDED;
|
|
53
|
+
}
|
|
54
|
+
isSuccess() {
|
|
55
|
+
return this.state === ToBtcLnSwapState.CLAIMED;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.ToBtcLnSwapAbs = ToBtcLnSwapAbs;
|
|
@@ -1,45 +1,44 @@
|
|
|
1
|
-
import { Lockable, SpvVaultClaimEvent, SpvVaultCloseEvent, SpvVaultData, SpvVaultDepositEvent, SpvVaultOpenEvent, SpvVaultTokenBalance, SpvWithdrawalTransactionData, StorageObject } from "@atomiqlabs/base";
|
|
2
|
-
export declare enum SpvVaultState {
|
|
3
|
-
CLOSED = -1,
|
|
4
|
-
BTC_INITIATED = 0,
|
|
5
|
-
BTC_CONFIRMED = 1,
|
|
6
|
-
OPENED = 2
|
|
7
|
-
}
|
|
8
|
-
export declare class SpvVault<D extends SpvWithdrawalTransactionData = SpvWithdrawalTransactionData & {
|
|
9
|
-
sending?: boolean;
|
|
10
|
-
}, T extends SpvVaultData = SpvVaultData> extends Lockable implements StorageObject {
|
|
11
|
-
readonly chainId: string;
|
|
12
|
-
readonly initialUtxo: string;
|
|
13
|
-
readonly btcAddress: string;
|
|
14
|
-
readonly pendingWithdrawals: D[];
|
|
15
|
-
readonly replacedWithdrawals: Map<number, D[]>;
|
|
16
|
-
data: T;
|
|
17
|
-
state: SpvVaultState;
|
|
18
|
-
balances: SpvVaultTokenBalance[];
|
|
19
|
-
|
|
20
|
-
txId: string;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
constructor(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
1
|
+
import { Lockable, SpvVaultClaimEvent, SpvVaultCloseEvent, SpvVaultData, SpvVaultDepositEvent, SpvVaultOpenEvent, SpvVaultTokenBalance, SpvWithdrawalTransactionData, StorageObject } from "@atomiqlabs/base";
|
|
2
|
+
export declare enum SpvVaultState {
|
|
3
|
+
CLOSED = -1,
|
|
4
|
+
BTC_INITIATED = 0,
|
|
5
|
+
BTC_CONFIRMED = 1,
|
|
6
|
+
OPENED = 2
|
|
7
|
+
}
|
|
8
|
+
export declare class SpvVault<D extends SpvWithdrawalTransactionData = SpvWithdrawalTransactionData & {
|
|
9
|
+
sending?: boolean;
|
|
10
|
+
}, T extends SpvVaultData = SpvVaultData> extends Lockable implements StorageObject {
|
|
11
|
+
readonly chainId: string;
|
|
12
|
+
readonly initialUtxo: string;
|
|
13
|
+
readonly btcAddress: string;
|
|
14
|
+
readonly pendingWithdrawals: D[];
|
|
15
|
+
readonly replacedWithdrawals: Map<number, D[]>;
|
|
16
|
+
data: T;
|
|
17
|
+
state: SpvVaultState;
|
|
18
|
+
balances: SpvVaultTokenBalance[];
|
|
19
|
+
scOpenTxs: {
|
|
20
|
+
[txId: string]: string;
|
|
21
|
+
};
|
|
22
|
+
constructor(chainId: string, vault: T, btcAddress: string);
|
|
23
|
+
constructor(obj: any);
|
|
24
|
+
update(event: SpvVaultOpenEvent | SpvVaultDepositEvent | SpvVaultCloseEvent | SpvVaultClaimEvent): void;
|
|
25
|
+
addWithdrawal(withdrawalData: D): void;
|
|
26
|
+
removeWithdrawal(withdrawalData: D): boolean;
|
|
27
|
+
doubleSpendPendingWithdrawal(withdrawalData: D): boolean;
|
|
28
|
+
toRawAmounts(amounts: bigint[]): bigint[];
|
|
29
|
+
fromRawAmounts(rawAmounts: bigint[]): bigint[];
|
|
30
|
+
/**
|
|
31
|
+
* Returns the vault balance after processing all currently confirmed (at least 1 btc confirmation) withdrawals
|
|
32
|
+
*/
|
|
33
|
+
getConfirmedBalance(): SpvVaultTokenBalance[];
|
|
34
|
+
serialize(): any;
|
|
35
|
+
getIdentifier(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the latest vault utxo
|
|
38
|
+
*/
|
|
39
|
+
getLatestUtxo(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Returns whether the vault is ready for the next swap
|
|
42
|
+
*/
|
|
43
|
+
isReady(): boolean;
|
|
44
|
+
}
|
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SpvVault = exports.SpvVaultState = void 0;
|
|
4
|
-
const base_1 = require("@atomiqlabs/base");
|
|
5
|
-
var SpvVaultState;
|
|
6
|
-
(function (SpvVaultState) {
|
|
7
|
-
SpvVaultState[SpvVaultState["CLOSED"] = -1] = "CLOSED";
|
|
8
|
-
SpvVaultState[SpvVaultState["BTC_INITIATED"] = 0] = "BTC_INITIATED";
|
|
9
|
-
SpvVaultState[SpvVaultState["BTC_CONFIRMED"] = 1] = "BTC_CONFIRMED";
|
|
10
|
-
SpvVaultState[SpvVaultState["OPENED"] = 2] = "OPENED";
|
|
11
|
-
})(SpvVaultState = exports.SpvVaultState || (exports.SpvVaultState = {}));
|
|
12
|
-
class SpvVault extends base_1.Lockable {
|
|
13
|
-
constructor(chainIdOrObj, vault, btcAddress) {
|
|
14
|
-
super();
|
|
15
|
-
if (typeof (chainIdOrObj) === "string") {
|
|
16
|
-
this.state = SpvVaultState.BTC_INITIATED;
|
|
17
|
-
this.chainId = chainIdOrObj;
|
|
18
|
-
this.data = vault;
|
|
19
|
-
this.initialUtxo = vault.getUtxo();
|
|
20
|
-
this.btcAddress = btcAddress;
|
|
21
|
-
this.pendingWithdrawals = [];
|
|
22
|
-
this.replacedWithdrawals = new Map();
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
this.state = chainIdOrObj.state;
|
|
26
|
-
this.chainId = chainIdOrObj.chainId;
|
|
27
|
-
this.data = base_1.SpvVaultData.deserialize(chainIdOrObj.data);
|
|
28
|
-
this.initialUtxo = chainIdOrObj.initialUtxo;
|
|
29
|
-
this.btcAddress = chainIdOrObj.btcAddress;
|
|
30
|
-
this.pendingWithdrawals = chainIdOrObj.pendingWithdrawals.map((base_1.SpvWithdrawalTransactionData.deserialize));
|
|
31
|
-
this.
|
|
32
|
-
this.replacedWithdrawals = new Map();
|
|
33
|
-
if (chainIdOrObj.replacedWithdrawals != null) {
|
|
34
|
-
chainIdOrObj.replacedWithdrawals.forEach((val) => {
|
|
35
|
-
this.replacedWithdrawals.set(val[0], val[1].map((base_1.SpvWithdrawalTransactionData.deserialize)));
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
this.balances = this.data.calculateStateAfter(this.pendingWithdrawals).balances;
|
|
40
|
-
}
|
|
41
|
-
update(event) {
|
|
42
|
-
if (event instanceof base_1.SpvVaultClaimEvent || event instanceof base_1.SpvVaultCloseEvent) {
|
|
43
|
-
const processedWithdrawalIndex = this.pendingWithdrawals.findIndex(val => val.btcTx.txid === event.btcTxId);
|
|
44
|
-
if (processedWithdrawalIndex !== -1)
|
|
45
|
-
this.pendingWithdrawals.splice(0, processedWithdrawalIndex + 1);
|
|
46
|
-
if (event instanceof base_1.SpvVaultClaimEvent) {
|
|
47
|
-
for (let key of this.replacedWithdrawals.keys()) {
|
|
48
|
-
if (key <= event.withdrawCount)
|
|
49
|
-
this.replacedWithdrawals.delete(key);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (event instanceof base_1.SpvVaultCloseEvent) {
|
|
53
|
-
this.replacedWithdrawals.clear();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
this.data.updateState(event);
|
|
57
|
-
this.balances = this.data.calculateStateAfter(this.pendingWithdrawals).balances;
|
|
58
|
-
}
|
|
59
|
-
addWithdrawal(withdrawalData) {
|
|
60
|
-
//Make sure this is a valid state transition before adding the tx to pending withdrawals
|
|
61
|
-
this.balances = this.data.calculateStateAfter([...this.pendingWithdrawals, withdrawalData]).balances;
|
|
62
|
-
this.pendingWithdrawals.push(withdrawalData);
|
|
63
|
-
}
|
|
64
|
-
removeWithdrawal(withdrawalData) {
|
|
65
|
-
const index = this.pendingWithdrawals.indexOf(withdrawalData);
|
|
66
|
-
if (index === -1)
|
|
67
|
-
return false;
|
|
68
|
-
this.pendingWithdrawals.splice(index, 1);
|
|
69
|
-
this.balances = this.data.calculateStateAfter(this.pendingWithdrawals).balances;
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
doubleSpendPendingWithdrawal(withdrawalData) {
|
|
73
|
-
const index = this.pendingWithdrawals.indexOf(withdrawalData);
|
|
74
|
-
if (index === -1)
|
|
75
|
-
return false;
|
|
76
|
-
this.pendingWithdrawals.splice(index, 1);
|
|
77
|
-
this.balances = this.data.calculateStateAfter(this.pendingWithdrawals).balances;
|
|
78
|
-
const withdrawalIndex = this.data.getWithdrawalCount() + index + 1;
|
|
79
|
-
let arr = this.replacedWithdrawals.get(withdrawalIndex);
|
|
80
|
-
if (arr == null)
|
|
81
|
-
this.replacedWithdrawals.set(withdrawalIndex, arr = []);
|
|
82
|
-
arr.push(withdrawalData);
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
toRawAmounts(amounts) {
|
|
86
|
-
return amounts.map((amt, index) => {
|
|
87
|
-
const tokenData = this.data.getTokenData()[index];
|
|
88
|
-
if (tokenData == null)
|
|
89
|
-
throw new Error("Amount index out of bounds!");
|
|
90
|
-
return amt / tokenData.multiplier;
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
fromRawAmounts(rawAmounts) {
|
|
94
|
-
return rawAmounts.map((amt, index) => {
|
|
95
|
-
const tokenData = this.data.getTokenData()[index];
|
|
96
|
-
if (tokenData == null)
|
|
97
|
-
throw new Error("Amount index out of bounds!");
|
|
98
|
-
return amt * tokenData.multiplier;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Returns the vault balance after processing all currently confirmed (at least 1 btc confirmation) withdrawals
|
|
103
|
-
*/
|
|
104
|
-
getConfirmedBalance() {
|
|
105
|
-
return this.data.calculateStateAfter(this.pendingWithdrawals.filter(val => val.btcTx.confirmations >= 1)).balances;
|
|
106
|
-
}
|
|
107
|
-
serialize() {
|
|
108
|
-
const replacedWithdrawals = [];
|
|
109
|
-
this.replacedWithdrawals.forEach((value, key) => {
|
|
110
|
-
replacedWithdrawals.push([key, value.map(val => val.serialize())]);
|
|
111
|
-
});
|
|
112
|
-
return {
|
|
113
|
-
state: this.state,
|
|
114
|
-
chainId: this.chainId,
|
|
115
|
-
data: this.data.serialize(),
|
|
116
|
-
initialUtxo: this.initialUtxo,
|
|
117
|
-
btcAddress: this.btcAddress,
|
|
118
|
-
pendingWithdrawals: this.pendingWithdrawals.map(val => val.serialize()),
|
|
119
|
-
replacedWithdrawals,
|
|
120
|
-
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
getIdentifier() {
|
|
124
|
-
return this.chainId + "_" + this.data.getOwner() + "_" + this.data.getVaultId().toString(10);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Returns the latest vault utxo
|
|
128
|
-
*/
|
|
129
|
-
getLatestUtxo() {
|
|
130
|
-
if (this.pendingWithdrawals.length === 0) {
|
|
131
|
-
return this.data.getUtxo();
|
|
132
|
-
}
|
|
133
|
-
const latestWithdrawal = this.pendingWithdrawals[this.pendingWithdrawals.length - 1];
|
|
134
|
-
if (latestWithdrawal.btcTx.confirmations >= 1)
|
|
135
|
-
return latestWithdrawal.btcTx.txid + ":0";
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Returns whether the vault is ready for the next swap
|
|
140
|
-
*/
|
|
141
|
-
isReady() {
|
|
142
|
-
return this.data.isOpened() && this.getLatestUtxo() != null;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
exports.SpvVault = SpvVault;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpvVault = exports.SpvVaultState = void 0;
|
|
4
|
+
const base_1 = require("@atomiqlabs/base");
|
|
5
|
+
var SpvVaultState;
|
|
6
|
+
(function (SpvVaultState) {
|
|
7
|
+
SpvVaultState[SpvVaultState["CLOSED"] = -1] = "CLOSED";
|
|
8
|
+
SpvVaultState[SpvVaultState["BTC_INITIATED"] = 0] = "BTC_INITIATED";
|
|
9
|
+
SpvVaultState[SpvVaultState["BTC_CONFIRMED"] = 1] = "BTC_CONFIRMED";
|
|
10
|
+
SpvVaultState[SpvVaultState["OPENED"] = 2] = "OPENED";
|
|
11
|
+
})(SpvVaultState = exports.SpvVaultState || (exports.SpvVaultState = {}));
|
|
12
|
+
class SpvVault extends base_1.Lockable {
|
|
13
|
+
constructor(chainIdOrObj, vault, btcAddress) {
|
|
14
|
+
super();
|
|
15
|
+
if (typeof (chainIdOrObj) === "string") {
|
|
16
|
+
this.state = SpvVaultState.BTC_INITIATED;
|
|
17
|
+
this.chainId = chainIdOrObj;
|
|
18
|
+
this.data = vault;
|
|
19
|
+
this.initialUtxo = vault.getUtxo();
|
|
20
|
+
this.btcAddress = btcAddress;
|
|
21
|
+
this.pendingWithdrawals = [];
|
|
22
|
+
this.replacedWithdrawals = new Map();
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.state = chainIdOrObj.state;
|
|
26
|
+
this.chainId = chainIdOrObj.chainId;
|
|
27
|
+
this.data = base_1.SpvVaultData.deserialize(chainIdOrObj.data);
|
|
28
|
+
this.initialUtxo = chainIdOrObj.initialUtxo;
|
|
29
|
+
this.btcAddress = chainIdOrObj.btcAddress;
|
|
30
|
+
this.pendingWithdrawals = chainIdOrObj.pendingWithdrawals.map((base_1.SpvWithdrawalTransactionData.deserialize));
|
|
31
|
+
this.scOpenTxs = chainIdOrObj.scOpenTxs;
|
|
32
|
+
this.replacedWithdrawals = new Map();
|
|
33
|
+
if (chainIdOrObj.replacedWithdrawals != null) {
|
|
34
|
+
chainIdOrObj.replacedWithdrawals.forEach((val) => {
|
|
35
|
+
this.replacedWithdrawals.set(val[0], val[1].map((base_1.SpvWithdrawalTransactionData.deserialize)));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
this.balances = this.data.calculateStateAfter(this.pendingWithdrawals).balances;
|
|
40
|
+
}
|
|
41
|
+
update(event) {
|
|
42
|
+
if (event instanceof base_1.SpvVaultClaimEvent || event instanceof base_1.SpvVaultCloseEvent) {
|
|
43
|
+
const processedWithdrawalIndex = this.pendingWithdrawals.findIndex(val => val.btcTx.txid === event.btcTxId);
|
|
44
|
+
if (processedWithdrawalIndex !== -1)
|
|
45
|
+
this.pendingWithdrawals.splice(0, processedWithdrawalIndex + 1);
|
|
46
|
+
if (event instanceof base_1.SpvVaultClaimEvent) {
|
|
47
|
+
for (let key of this.replacedWithdrawals.keys()) {
|
|
48
|
+
if (key <= event.withdrawCount)
|
|
49
|
+
this.replacedWithdrawals.delete(key);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (event instanceof base_1.SpvVaultCloseEvent) {
|
|
53
|
+
this.replacedWithdrawals.clear();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
this.data.updateState(event);
|
|
57
|
+
this.balances = this.data.calculateStateAfter(this.pendingWithdrawals).balances;
|
|
58
|
+
}
|
|
59
|
+
addWithdrawal(withdrawalData) {
|
|
60
|
+
//Make sure this is a valid state transition before adding the tx to pending withdrawals
|
|
61
|
+
this.balances = this.data.calculateStateAfter([...this.pendingWithdrawals, withdrawalData]).balances;
|
|
62
|
+
this.pendingWithdrawals.push(withdrawalData);
|
|
63
|
+
}
|
|
64
|
+
removeWithdrawal(withdrawalData) {
|
|
65
|
+
const index = this.pendingWithdrawals.indexOf(withdrawalData);
|
|
66
|
+
if (index === -1)
|
|
67
|
+
return false;
|
|
68
|
+
this.pendingWithdrawals.splice(index, 1);
|
|
69
|
+
this.balances = this.data.calculateStateAfter(this.pendingWithdrawals).balances;
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
doubleSpendPendingWithdrawal(withdrawalData) {
|
|
73
|
+
const index = this.pendingWithdrawals.indexOf(withdrawalData);
|
|
74
|
+
if (index === -1)
|
|
75
|
+
return false;
|
|
76
|
+
this.pendingWithdrawals.splice(index, 1);
|
|
77
|
+
this.balances = this.data.calculateStateAfter(this.pendingWithdrawals).balances;
|
|
78
|
+
const withdrawalIndex = this.data.getWithdrawalCount() + index + 1;
|
|
79
|
+
let arr = this.replacedWithdrawals.get(withdrawalIndex);
|
|
80
|
+
if (arr == null)
|
|
81
|
+
this.replacedWithdrawals.set(withdrawalIndex, arr = []);
|
|
82
|
+
arr.push(withdrawalData);
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
toRawAmounts(amounts) {
|
|
86
|
+
return amounts.map((amt, index) => {
|
|
87
|
+
const tokenData = this.data.getTokenData()[index];
|
|
88
|
+
if (tokenData == null)
|
|
89
|
+
throw new Error("Amount index out of bounds!");
|
|
90
|
+
return amt / tokenData.multiplier;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
fromRawAmounts(rawAmounts) {
|
|
94
|
+
return rawAmounts.map((amt, index) => {
|
|
95
|
+
const tokenData = this.data.getTokenData()[index];
|
|
96
|
+
if (tokenData == null)
|
|
97
|
+
throw new Error("Amount index out of bounds!");
|
|
98
|
+
return amt * tokenData.multiplier;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns the vault balance after processing all currently confirmed (at least 1 btc confirmation) withdrawals
|
|
103
|
+
*/
|
|
104
|
+
getConfirmedBalance() {
|
|
105
|
+
return this.data.calculateStateAfter(this.pendingWithdrawals.filter(val => val.btcTx.confirmations >= 1)).balances;
|
|
106
|
+
}
|
|
107
|
+
serialize() {
|
|
108
|
+
const replacedWithdrawals = [];
|
|
109
|
+
this.replacedWithdrawals.forEach((value, key) => {
|
|
110
|
+
replacedWithdrawals.push([key, value.map(val => val.serialize())]);
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
state: this.state,
|
|
114
|
+
chainId: this.chainId,
|
|
115
|
+
data: this.data.serialize(),
|
|
116
|
+
initialUtxo: this.initialUtxo,
|
|
117
|
+
btcAddress: this.btcAddress,
|
|
118
|
+
pendingWithdrawals: this.pendingWithdrawals.map(val => val.serialize()),
|
|
119
|
+
replacedWithdrawals,
|
|
120
|
+
scOpenTxs: this.scOpenTxs
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
getIdentifier() {
|
|
124
|
+
return this.chainId + "_" + this.data.getOwner() + "_" + this.data.getVaultId().toString(10);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Returns the latest vault utxo
|
|
128
|
+
*/
|
|
129
|
+
getLatestUtxo() {
|
|
130
|
+
if (this.pendingWithdrawals.length === 0) {
|
|
131
|
+
return this.data.getUtxo();
|
|
132
|
+
}
|
|
133
|
+
const latestWithdrawal = this.pendingWithdrawals[this.pendingWithdrawals.length - 1];
|
|
134
|
+
if (latestWithdrawal.btcTx.confirmations >= 1)
|
|
135
|
+
return latestWithdrawal.btcTx.txid + ":0";
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Returns whether the vault is ready for the next swap
|
|
140
|
+
*/
|
|
141
|
+
isReady() {
|
|
142
|
+
return this.data.isOpened() && this.getLatestUtxo() != null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.SpvVault = SpvVault;
|