@atomiqlabs/lp-lib 11.0.5 → 12.0.0-beta.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/dist/info/InfoHandler.js +3 -12
- package/dist/plugins/IPlugin.d.ts +34 -35
- package/dist/plugins/IPlugin.js +7 -8
- package/dist/plugins/PluginManager.d.ts +29 -30
- package/dist/plugins/PluginManager.js +160 -188
- package/dist/prices/BinanceSwapPrice.d.ts +1 -2
- package/dist/prices/BinanceSwapPrice.js +56 -70
- package/dist/prices/CoinGeckoSwapPrice.d.ts +2 -3
- package/dist/prices/CoinGeckoSwapPrice.js +30 -42
- package/dist/prices/OKXSwapPrice.d.ts +1 -2
- package/dist/prices/OKXSwapPrice.js +56 -70
- package/dist/storage/IIntermediaryStorage.d.ts +8 -5
- package/dist/storagemanager/IntermediaryStorageManager.d.ts +8 -5
- package/dist/storagemanager/IntermediaryStorageManager.js +52 -61
- package/dist/storagemanager/StorageManager.js +42 -59
- package/dist/swaps/FromBtcBaseSwap.d.ts +7 -8
- package/dist/swaps/FromBtcBaseSwap.js +2 -3
- package/dist/swaps/FromBtcBaseSwapHandler.d.ts +44 -31
- package/dist/swaps/FromBtcBaseSwapHandler.js +217 -196
- package/dist/swaps/FromBtcLnBaseSwapHandler.d.ts +1 -2
- package/dist/swaps/FromBtcLnBaseSwapHandler.js +13 -24
- package/dist/swaps/ISwapPrice.d.ts +4 -5
- package/dist/swaps/ISwapPrice.js +8 -30
- package/dist/swaps/SwapHandler.d.ts +26 -15
- package/dist/swaps/SwapHandler.js +107 -66
- package/dist/swaps/SwapHandlerSwap.d.ts +22 -11
- package/dist/swaps/SwapHandlerSwap.js +32 -8
- package/dist/swaps/ToBtcBaseSwap.d.ts +16 -17
- package/dist/swaps/ToBtcBaseSwap.js +4 -4
- package/dist/swaps/ToBtcBaseSwapHandler.d.ts +17 -17
- package/dist/swaps/ToBtcBaseSwapHandler.js +140 -155
- package/dist/swaps/frombtc_abstract/FromBtcAbs.d.ts +8 -15
- package/dist/swaps/frombtc_abstract/FromBtcAbs.js +131 -196
- package/dist/swaps/frombtc_abstract/FromBtcSwapAbs.d.ts +3 -5
- package/dist/swaps/frombtc_abstract/FromBtcSwapAbs.js +4 -4
- package/dist/swaps/frombtc_trusted/FromBtcTrusted.d.ts +10 -8
- package/dist/swaps/frombtc_trusted/FromBtcTrusted.js +330 -362
- package/dist/swaps/frombtc_trusted/FromBtcTrustedSwap.d.ts +10 -10
- package/dist/swaps/frombtc_trusted/FromBtcTrustedSwap.js +7 -4
- package/dist/swaps/frombtcln_abstract/FromBtcLnAbs.d.ts +8 -8
- package/dist/swaps/frombtcln_abstract/FromBtcLnAbs.js +330 -400
- package/dist/swaps/frombtcln_abstract/FromBtcLnSwapAbs.d.ts +10 -4
- package/dist/swaps/frombtcln_abstract/FromBtcLnSwapAbs.js +36 -6
- package/dist/swaps/frombtcln_trusted/FromBtcLnTrusted.d.ts +8 -7
- package/dist/swaps/frombtcln_trusted/FromBtcLnTrusted.js +251 -273
- package/dist/swaps/frombtcln_trusted/FromBtcLnTrustedSwap.d.ts +5 -5
- package/dist/swaps/frombtcln_trusted/FromBtcLnTrustedSwap.js +7 -5
- package/dist/swaps/tobtc_abstract/ToBtcAbs.d.ts +13 -12
- package/dist/swaps/tobtc_abstract/ToBtcAbs.js +261 -323
- package/dist/swaps/tobtc_abstract/ToBtcSwapAbs.d.ts +4 -4
- package/dist/swaps/tobtc_abstract/ToBtcSwapAbs.js +7 -6
- package/dist/swaps/tobtcln_abstract/ToBtcLnAbs.d.ts +22 -21
- package/dist/swaps/tobtcln_abstract/ToBtcLnAbs.js +398 -453
- package/dist/swaps/tobtcln_abstract/ToBtcLnSwapAbs.d.ts +3 -2
- package/dist/swaps/tobtcln_abstract/ToBtcLnSwapAbs.js +10 -6
- package/dist/utils/Utils.d.ts +2 -3
- package/dist/utils/Utils.js +4 -14
- package/dist/utils/paramcoders/LegacyParamEncoder.js +3 -14
- package/dist/utils/paramcoders/ParamDecoder.js +53 -65
- package/dist/utils/paramcoders/SchemaVerifier.d.ts +4 -5
- package/dist/utils/paramcoders/SchemaVerifier.js +8 -9
- package/dist/utils/paramcoders/server/ServerParamDecoder.js +1 -1
- package/dist/utils/paramcoders/server/ServerParamEncoder.js +3 -14
- package/dist/wallets/IBitcoinWallet.d.ts +4 -5
- package/dist/wallets/ILightningWallet.d.ts +20 -21
- package/dist/wallets/ILightningWallet.js +1 -1
- package/package.json +4 -6
- package/src/plugins/IPlugin.ts +28 -29
- package/src/plugins/PluginManager.ts +21 -22
- package/src/prices/BinanceSwapPrice.ts +3 -4
- package/src/prices/CoinGeckoSwapPrice.ts +4 -5
- package/src/prices/OKXSwapPrice.ts +3 -4
- package/src/storage/IIntermediaryStorage.ts +4 -5
- package/src/storagemanager/IntermediaryStorageManager.ts +17 -9
- package/src/swaps/FromBtcBaseSwap.ts +9 -10
- package/src/swaps/FromBtcBaseSwapHandler.ts +133 -91
- package/src/swaps/FromBtcLnBaseSwapHandler.ts +2 -3
- package/src/swaps/ISwapPrice.ts +10 -20
- package/src/swaps/SwapHandler.ts +101 -35
- package/src/swaps/SwapHandlerSwap.ts +42 -17
- package/src/swaps/ToBtcBaseSwap.ts +20 -18
- package/src/swaps/ToBtcBaseSwapHandler.ts +33 -33
- package/src/swaps/frombtc_abstract/FromBtcAbs.ts +64 -97
- package/src/swaps/frombtc_abstract/FromBtcSwapAbs.ts +7 -8
- package/src/swaps/frombtc_trusted/FromBtcTrusted.ts +56 -55
- package/src/swaps/frombtc_trusted/FromBtcTrustedSwap.ts +28 -21
- package/src/swaps/frombtcln_abstract/FromBtcLnAbs.ts +81 -116
- package/src/swaps/frombtcln_abstract/FromBtcLnSwapAbs.ts +73 -9
- package/src/swaps/frombtcln_trusted/FromBtcLnTrusted.ts +39 -36
- package/src/swaps/frombtcln_trusted/FromBtcLnTrustedSwap.ts +26 -12
- package/src/swaps/tobtc_abstract/ToBtcAbs.ts +82 -98
- package/src/swaps/tobtc_abstract/ToBtcSwapAbs.ts +25 -20
- package/src/swaps/tobtcln_abstract/ToBtcLnAbs.ts +106 -118
- package/src/swaps/tobtcln_abstract/ToBtcLnSwapAbs.ts +17 -9
- package/src/utils/Utils.ts +3 -4
- package/src/utils/paramcoders/ParamDecoder.ts +5 -5
- package/src/utils/paramcoders/SchemaVerifier.ts +10 -11
- package/src/utils/paramcoders/server/ServerParamDecoder.ts +1 -1
- package/src/wallets/IBitcoinWallet.ts +4 -5
- package/src/wallets/ILightningWallet.ts +21 -22
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BtcTx, SwapData } from "@atomiqlabs/base";
|
|
2
2
|
import { FromBtcBaseSwap } from "../FromBtcBaseSwap";
|
|
3
|
-
import * as BN from "bn.js";
|
|
4
3
|
export declare enum FromBtcTrustedSwapState {
|
|
5
4
|
DOUBLE_SPENT = -4,
|
|
6
5
|
REFUNDED = -3,
|
|
@@ -14,16 +13,17 @@ export declare enum FromBtcTrustedSwapState {
|
|
|
14
13
|
FINISHED = 5
|
|
15
14
|
}
|
|
16
15
|
export declare class FromBtcTrustedSwap<T extends SwapData = SwapData> extends FromBtcBaseSwap<T, FromBtcTrustedSwapState> {
|
|
17
|
-
readonly sequence:
|
|
16
|
+
readonly sequence: bigint;
|
|
18
17
|
readonly btcAddress: string;
|
|
19
18
|
readonly dstAddress: string;
|
|
20
|
-
readonly outputTokens:
|
|
19
|
+
readonly outputTokens: bigint;
|
|
21
20
|
readonly createdHeight: number;
|
|
22
21
|
readonly expiresAt: number;
|
|
23
22
|
readonly recommendedFee: number;
|
|
23
|
+
readonly token: string;
|
|
24
24
|
refundAddress: string;
|
|
25
|
-
adjustedInput:
|
|
26
|
-
adjustedOutput:
|
|
25
|
+
adjustedInput: bigint;
|
|
26
|
+
adjustedOutput: bigint;
|
|
27
27
|
doubleSpent: boolean;
|
|
28
28
|
scRawTx: string;
|
|
29
29
|
btcTx: BtcTx;
|
|
@@ -33,13 +33,13 @@ export declare class FromBtcTrustedSwap<T extends SwapData = SwapData> extends F
|
|
|
33
33
|
vout: number;
|
|
34
34
|
burnTxId: string;
|
|
35
35
|
refundTxId: string;
|
|
36
|
-
constructor(chainIdentifier: string, swapFee:
|
|
36
|
+
constructor(chainIdentifier: string, swapFee: bigint, swapFeeInToken: bigint, btcAddress: string, inputSats: bigint, dstAddress: string, outputTokens: bigint, createdHeight: number, expiresAt: number, recommendedFee: number, refundAddress: string, token: string);
|
|
37
37
|
constructor(obj: any);
|
|
38
38
|
serialize(): any;
|
|
39
|
-
|
|
40
|
-
getSequence():
|
|
41
|
-
getOutputAmount():
|
|
42
|
-
getTotalInputAmount():
|
|
39
|
+
getClaimHash(): string;
|
|
40
|
+
getSequence(): bigint;
|
|
41
|
+
getOutputAmount(): bigint;
|
|
42
|
+
getTotalInputAmount(): bigint;
|
|
43
43
|
isFailed(): boolean;
|
|
44
44
|
isInitiated(): boolean;
|
|
45
45
|
isSuccess(): boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FromBtcTrustedSwap = exports.FromBtcTrustedSwapState = void 0;
|
|
4
|
+
const base_1 = require("@atomiqlabs/base");
|
|
4
5
|
const FromBtcBaseSwap_1 = require("../FromBtcBaseSwap");
|
|
5
|
-
const BN = require("bn.js");
|
|
6
6
|
const Utils_1 = require("../../utils/Utils");
|
|
7
7
|
const crypto_1 = require("crypto");
|
|
8
8
|
var FromBtcTrustedSwapState;
|
|
@@ -19,12 +19,12 @@ var FromBtcTrustedSwapState;
|
|
|
19
19
|
FromBtcTrustedSwapState[FromBtcTrustedSwapState["FINISHED"] = 5] = "FINISHED";
|
|
20
20
|
})(FromBtcTrustedSwapState = exports.FromBtcTrustedSwapState || (exports.FromBtcTrustedSwapState = {}));
|
|
21
21
|
class FromBtcTrustedSwap extends FromBtcBaseSwap_1.FromBtcBaseSwap {
|
|
22
|
-
constructor(objOrChainIdentifier, swapFee, swapFeeInToken, btcAddress, inputSats, dstAddress, outputTokens, createdHeight, expiresAt, recommendedFee, refundAddress) {
|
|
22
|
+
constructor(objOrChainIdentifier, swapFee, swapFeeInToken, btcAddress, inputSats, dstAddress, outputTokens, createdHeight, expiresAt, recommendedFee, refundAddress, token) {
|
|
23
23
|
if (typeof (objOrChainIdentifier) === "string") {
|
|
24
24
|
super(objOrChainIdentifier, inputSats, swapFee, swapFeeInToken);
|
|
25
25
|
this.state = FromBtcTrustedSwapState.CREATED;
|
|
26
26
|
this.doubleSpent = false;
|
|
27
|
-
this.sequence =
|
|
27
|
+
this.sequence = base_1.BigIntBufferUtils.fromBuffer((0, crypto_1.randomBytes)(8));
|
|
28
28
|
this.btcAddress = btcAddress;
|
|
29
29
|
this.dstAddress = dstAddress;
|
|
30
30
|
this.outputTokens = outputTokens;
|
|
@@ -32,6 +32,7 @@ class FromBtcTrustedSwap extends FromBtcBaseSwap_1.FromBtcBaseSwap {
|
|
|
32
32
|
this.expiresAt = expiresAt;
|
|
33
33
|
this.recommendedFee = recommendedFee;
|
|
34
34
|
this.refundAddress = refundAddress;
|
|
35
|
+
this.token = token;
|
|
35
36
|
}
|
|
36
37
|
else {
|
|
37
38
|
super(objOrChainIdentifier);
|
|
@@ -54,6 +55,7 @@ class FromBtcTrustedSwap extends FromBtcBaseSwap_1.FromBtcBaseSwap {
|
|
|
54
55
|
this.vout = objOrChainIdentifier.vout;
|
|
55
56
|
this.burnTxId = objOrChainIdentifier.burnTxId;
|
|
56
57
|
this.refundTxId = objOrChainIdentifier.refundTxId;
|
|
58
|
+
this.token = objOrChainIdentifier.token;
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
serialize() {
|
|
@@ -77,9 +79,10 @@ class FromBtcTrustedSwap extends FromBtcBaseSwap_1.FromBtcBaseSwap {
|
|
|
77
79
|
partialSerialized.vout = this.vout;
|
|
78
80
|
partialSerialized.burnTxId = this.burnTxId;
|
|
79
81
|
partialSerialized.refundTxId = this.refundTxId;
|
|
82
|
+
partialSerialized.token = this.token;
|
|
80
83
|
return partialSerialized;
|
|
81
84
|
}
|
|
82
|
-
|
|
85
|
+
getClaimHash() {
|
|
83
86
|
return (0, crypto_1.createHash)("sha256").update(this.btcAddress).digest().toString("hex");
|
|
84
87
|
}
|
|
85
88
|
getSequence() {
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import * as BN from "bn.js";
|
|
2
1
|
import { Express } from "express";
|
|
3
2
|
import { FromBtcLnSwapAbs, FromBtcLnSwapState } from "./FromBtcLnSwapAbs";
|
|
4
3
|
import { MultichainData, SwapHandlerType } from "../SwapHandler";
|
|
5
4
|
import { ISwapPrice } from "../ISwapPrice";
|
|
6
|
-
import { ClaimEvent, InitializeEvent, RefundEvent, SwapData } from "@atomiqlabs/base";
|
|
5
|
+
import { ChainSwapType, ClaimEvent, InitializeEvent, RefundEvent, SwapData } from "@atomiqlabs/base";
|
|
7
6
|
import { IIntermediaryStorage } from "../../storage/IIntermediaryStorage";
|
|
8
7
|
import { FromBtcBaseConfig } from "../FromBtcBaseSwapHandler";
|
|
9
8
|
import { FromBtcLnBaseSwapHandler } from "../FromBtcLnBaseSwapHandler";
|
|
10
9
|
import { ILightningWallet } from "../../wallets/ILightningWallet";
|
|
11
10
|
export type FromBtcLnConfig = FromBtcBaseConfig & {
|
|
12
11
|
invoiceTimeoutSeconds?: number;
|
|
13
|
-
minCltv:
|
|
14
|
-
gracePeriod:
|
|
12
|
+
minCltv: bigint;
|
|
13
|
+
gracePeriod: bigint;
|
|
15
14
|
};
|
|
16
15
|
export type FromBtcLnRequestType = {
|
|
17
16
|
address: string;
|
|
18
17
|
paymentHash: string;
|
|
19
|
-
amount:
|
|
18
|
+
amount: bigint;
|
|
20
19
|
token: string;
|
|
21
20
|
descriptionHash?: string;
|
|
22
21
|
exactOut?: boolean;
|
|
@@ -26,6 +25,7 @@ export type FromBtcLnRequestType = {
|
|
|
26
25
|
*/
|
|
27
26
|
export declare class FromBtcLnAbs extends FromBtcLnBaseSwapHandler<FromBtcLnSwapAbs, FromBtcLnSwapState> {
|
|
28
27
|
readonly type = SwapHandlerType.FROM_BTCLN;
|
|
28
|
+
readonly swapType = ChainSwapType.HTLC;
|
|
29
29
|
readonly config: FromBtcLnConfig;
|
|
30
30
|
constructor(storageDirectory: IIntermediaryStorage<FromBtcLnSwapAbs>, path: string, chains: MultichainData, lightning: ILightningWallet, swapPricing: ISwapPrice, config: FromBtcLnConfig);
|
|
31
31
|
protected processPastSwap(swap: FromBtcLnSwapAbs): Promise<"REFUND" | "SETTLE" | "CANCEL" | null>;
|
|
@@ -36,9 +36,9 @@ export declare class FromBtcLnAbs extends FromBtcLnBaseSwapHandler<FromBtcLnSwap
|
|
|
36
36
|
* Checks past swaps, refunds and deletes ones that are already expired.
|
|
37
37
|
*/
|
|
38
38
|
protected processPastSwaps(): Promise<void>;
|
|
39
|
-
protected processInitializeEvent(chainIdentifier: string, event: InitializeEvent<SwapData>): Promise<void>;
|
|
40
|
-
protected processClaimEvent(chainIdentifier: string, event: ClaimEvent<SwapData>): Promise<void>;
|
|
41
|
-
protected processRefundEvent(chainIdentifier: string, event: RefundEvent<SwapData>): Promise<void>;
|
|
39
|
+
protected processInitializeEvent(chainIdentifier: string, savedSwap: FromBtcLnSwapAbs, event: InitializeEvent<SwapData>): Promise<void>;
|
|
40
|
+
protected processClaimEvent(chainIdentifier: string, savedSwap: FromBtcLnSwapAbs, event: ClaimEvent<SwapData>): Promise<void>;
|
|
41
|
+
protected processRefundEvent(chainIdentifier: string, savedSwap: FromBtcLnSwapAbs, event: RefundEvent<SwapData>): Promise<void>;
|
|
42
42
|
/**
|
|
43
43
|
* Called when lightning HTLC is received, also signs an init transaction on the smart chain side, expiry of the
|
|
44
44
|
* smart chain authorization starts ticking as soon as this HTLC is received
|