@atomiqlabs/lp-lib 16.1.2 → 16.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +60 -60
- 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 +29 -29
- package/dist/prices/BinanceSwapPrice.js +79 -79
- package/dist/prices/CoinGeckoSwapPrice.d.ts +33 -33
- package/dist/prices/CoinGeckoSwapPrice.js +51 -51
- package/dist/prices/ISwapPrice.d.ts +43 -43
- package/dist/prices/ISwapPrice.js +55 -55
- package/dist/prices/OKXSwapPrice.d.ts +29 -29
- package/dist/prices/OKXSwapPrice.js +79 -79
- 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 +171 -171
- package/dist/swaps/SwapHandler.js +217 -217
- 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 +185 -185
- 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 +50 -50
- package/dist/swaps/escrow/EscrowHandler.js +151 -151
- 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 +84 -84
- package/dist/swaps/escrow/frombtc_abstract/FromBtcAbs.js +322 -322
- 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 +108 -108
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.js +695 -695
- 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 +112 -112
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.js +708 -708
- 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 +170 -170
- package/dist/swaps/escrow/tobtc_abstract/ToBtcAbs.js +745 -745
- 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 +178 -178
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.js +900 -899
- 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 -44
- 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 +561 -561
- package/dist/swaps/spv_vault_swap/SpvVaults.d.ts +63 -63
- package/dist/swaps/spv_vault_swap/SpvVaults.js +491 -491
- package/dist/swaps/trusted/frombtc_trusted/FromBtcTrusted.d.ts +52 -52
- package/dist/swaps/trusted/frombtc_trusted/FromBtcTrusted.js +662 -662
- 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 +77 -77
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.js +504 -504
- 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 +32 -29
- package/dist/utils/Utils.js +129 -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 +149 -74
- package/dist/wallets/IBitcoinWallet.js +97 -2
- package/dist/wallets/ILightningWallet.d.ts +136 -136
- 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 +103 -103
- package/src/plugins/IPlugin.ts +174 -174
- package/src/plugins/PluginManager.ts +354 -354
- package/src/prices/BinanceSwapPrice.ts +101 -101
- package/src/prices/CoinGeckoSwapPrice.ts +75 -75
- package/src/prices/ISwapPrice.ts +88 -88
- package/src/prices/OKXSwapPrice.ts +101 -101
- 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 +323 -323
- package/src/swaps/SwapHandlerSwap.ts +141 -141
- package/src/swaps/assertions/AmountAssertions.ts +77 -77
- package/src/swaps/assertions/FromBtcAmountAssertions.ts +251 -251
- package/src/swaps/assertions/LightningAssertions.ts +103 -103
- package/src/swaps/assertions/ToBtcAmountAssertions.ts +203 -203
- package/src/swaps/escrow/EscrowHandler.ts +172 -172
- 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 +457 -457
- package/src/swaps/escrow/frombtc_abstract/FromBtcSwapAbs.ts +61 -61
- package/src/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.ts +873 -873
- package/src/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.ts +141 -141
- package/src/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.ts +866 -866
- package/src/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.ts +196 -196
- package/src/swaps/escrow/tobtc_abstract/ToBtcAbs.ts +920 -920
- package/src/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.ts +108 -108
- package/src/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.ts +1150 -1149
- 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 +718 -712
- package/src/swaps/spv_vault_swap/SpvVaults.ts +567 -567
- package/src/swaps/trusted/frombtc_trusted/FromBtcTrusted.ts +762 -762
- package/src/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.ts +185 -185
- package/src/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.ts +603 -603
- package/src/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.ts +121 -121
- package/src/utils/BitcoinUtils.ts +59 -59
- package/src/utils/Utils.ts +150 -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 +237 -76
- package/src/wallets/ILightningWallet.ts +200 -200
- package/src/wallets/ISpvVaultSigner.ts +10 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Transaction } from "@scure/btc-signer";
|
|
2
|
-
export interface ISpvVaultSigner {
|
|
3
|
-
init(): Promise<void>;
|
|
4
|
-
getAddressType(): "p2wpkh" | "p2tr";
|
|
5
|
-
getAddress(chainId: string, vaultId: bigint): Promise<string>;
|
|
6
|
-
signPsbt(chainId: string, vaultId: bigint, psbt: Transaction, inputs: number[]): Promise<Transaction>;
|
|
7
|
-
}
|
|
1
|
+
import { Transaction } from "@scure/btc-signer";
|
|
2
|
+
export interface ISpvVaultSigner {
|
|
3
|
+
init(): Promise<void>;
|
|
4
|
+
getAddressType(): "p2wpkh" | "p2tr";
|
|
5
|
+
getAddress(chainId: string, vaultId: bigint): Promise<string>;
|
|
6
|
+
signPsbt(chainId: string, vaultId: bigint, psbt: Transaction, inputs: number[]): Promise<Transaction>;
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atomiqlabs/lp-lib",
|
|
3
|
-
"version": "16.1
|
|
4
|
-
"description": "Main functionality implementation for atomiq LP node",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"types:": "./dist/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
-
},
|
|
10
|
-
"files": [
|
|
11
|
-
"/dist",
|
|
12
|
-
"/src"
|
|
13
|
-
],
|
|
14
|
-
"keywords": [
|
|
15
|
-
"Solana",
|
|
16
|
-
"Bitcoin",
|
|
17
|
-
"Cross-chain",
|
|
18
|
-
"Cryptocurrency",
|
|
19
|
-
"Bridge",
|
|
20
|
-
"Trustless"
|
|
21
|
-
],
|
|
22
|
-
"author": "adambor",
|
|
23
|
-
"license": "ISC",
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"@atomiqlabs/base": "^12.0.0",
|
|
26
|
-
"@atomiqlabs/server-base": "^3.0.0",
|
|
27
|
-
"@scure/btc-signer": "1.6.0",
|
|
28
|
-
"express": "4.21.1",
|
|
29
|
-
"promise-queue-ts": "1.0.0"
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
32
|
-
"@types/express": "4.17.21",
|
|
33
|
-
"@types/node": "18.15.11",
|
|
34
|
-
"typescript": "4.9.5"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@atomiqlabs/lp-lib",
|
|
3
|
+
"version": "16.2.1",
|
|
4
|
+
"description": "Main functionality implementation for atomiq LP node",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types:": "./dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"/dist",
|
|
12
|
+
"/src"
|
|
13
|
+
],
|
|
14
|
+
"keywords": [
|
|
15
|
+
"Solana",
|
|
16
|
+
"Bitcoin",
|
|
17
|
+
"Cross-chain",
|
|
18
|
+
"Cryptocurrency",
|
|
19
|
+
"Bridge",
|
|
20
|
+
"Trustless"
|
|
21
|
+
],
|
|
22
|
+
"author": "adambor",
|
|
23
|
+
"license": "ISC",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@atomiqlabs/base": "^12.0.0",
|
|
26
|
+
"@atomiqlabs/server-base": "^3.0.0",
|
|
27
|
+
"@scure/btc-signer": "1.6.0",
|
|
28
|
+
"express": "4.21.1",
|
|
29
|
+
"promise-queue-ts": "1.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/express": "4.17.21",
|
|
33
|
+
"@types/node": "18.15.11",
|
|
34
|
+
"typescript": "4.9.5"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export interface IBtcFeeEstimator {
|
|
3
|
-
|
|
4
|
-
//Returns estimated fee in sats/vB
|
|
5
|
-
estimateFee(): Promise<number | null>;
|
|
6
|
-
|
|
1
|
+
|
|
2
|
+
export interface IBtcFeeEstimator {
|
|
3
|
+
|
|
4
|
+
//Returns estimated fee in sats/vB
|
|
5
|
+
estimateFee(): Promise<number | null>;
|
|
6
|
+
|
|
7
7
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
export * from "./info/InfoHandler";
|
|
2
|
-
|
|
3
|
-
export * from "./prices/CoinGeckoSwapPrice";
|
|
4
|
-
export * from "./prices/BinanceSwapPrice";
|
|
5
|
-
export * from "./prices/OKXSwapPrice";
|
|
6
|
-
|
|
7
|
-
export * from "./storage/IIntermediaryStorage";
|
|
8
|
-
|
|
9
|
-
export * from "./storagemanager/StorageManager";
|
|
10
|
-
export * from "./storagemanager/IntermediaryStorageManager";
|
|
11
|
-
|
|
12
|
-
export * from "./swaps/escrow/frombtc_abstract/FromBtcAbs";
|
|
13
|
-
export * from "./swaps/escrow/frombtc_abstract/FromBtcSwapAbs";
|
|
14
|
-
export * from "./swaps/escrow/frombtcln_abstract/FromBtcLnAbs";
|
|
15
|
-
export * from "./swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs";
|
|
16
|
-
export * from "./swaps/escrow/frombtcln_autoinit/FromBtcLnAuto";
|
|
17
|
-
export * from "./swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap";
|
|
18
|
-
export * from "./swaps/escrow/tobtc_abstract/ToBtcAbs";
|
|
19
|
-
export * from "./swaps/escrow/tobtc_abstract/ToBtcSwapAbs";
|
|
20
|
-
export * from "./swaps/escrow/tobtcln_abstract/ToBtcLnAbs";
|
|
21
|
-
export * from "./swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs";
|
|
22
|
-
|
|
23
|
-
export * from "./swaps/trusted/frombtc_trusted/FromBtcTrusted";
|
|
24
|
-
export * from "./swaps/trusted/frombtc_trusted/FromBtcTrustedSwap";
|
|
25
|
-
export * from "./swaps/trusted/frombtcln_trusted/FromBtcLnTrusted";
|
|
26
|
-
export * from "./swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap";
|
|
27
|
-
|
|
28
|
-
export * from "./prices/ISwapPrice";
|
|
29
|
-
export * from "./swaps/SwapHandler";
|
|
30
|
-
export * from "./swaps/SwapHandlerSwap";
|
|
31
|
-
|
|
32
|
-
export * from "./plugins/PluginManager";
|
|
33
|
-
export * from "./plugins/IPlugin";
|
|
34
|
-
|
|
35
|
-
export * from "./fees/IBtcFeeEstimator";
|
|
36
|
-
|
|
37
|
-
export * from "./utils/paramcoders/IParamReader";
|
|
38
|
-
export * from "./utils/paramcoders/IParamWriter";
|
|
39
|
-
export * from "./utils/paramcoders/LegacyParamEncoder";
|
|
40
|
-
export * from "./utils/paramcoders/ParamDecoder";
|
|
41
|
-
export * from "./utils/paramcoders/ParamEncoder";
|
|
42
|
-
export * from "./utils/paramcoders/SchemaVerifier";
|
|
43
|
-
export * from "./utils/paramcoders/server/ServerParamDecoder";
|
|
44
|
-
export * from "./utils/paramcoders/server/ServerParamEncoder";
|
|
45
|
-
|
|
46
|
-
export * from "./wallets/IBitcoinWallet";
|
|
47
|
-
export * from "./wallets/ILightningWallet";
|
|
48
|
-
export * from "./wallets/ISpvVaultSigner";
|
|
49
|
-
|
|
50
|
-
export * from "./swaps/spv_vault_swap/SpvVaults";
|
|
51
|
-
export * from "./swaps/spv_vault_swap/SpvVault";
|
|
52
|
-
export * from "./swaps/spv_vault_swap/SpvVaultSwap";
|
|
53
|
-
export * from "./swaps/spv_vault_swap/SpvVaultSwapHandler";
|
|
1
|
+
export * from "./info/InfoHandler";
|
|
2
|
+
|
|
3
|
+
export * from "./prices/CoinGeckoSwapPrice";
|
|
4
|
+
export * from "./prices/BinanceSwapPrice";
|
|
5
|
+
export * from "./prices/OKXSwapPrice";
|
|
6
|
+
|
|
7
|
+
export * from "./storage/IIntermediaryStorage";
|
|
8
|
+
|
|
9
|
+
export * from "./storagemanager/StorageManager";
|
|
10
|
+
export * from "./storagemanager/IntermediaryStorageManager";
|
|
11
|
+
|
|
12
|
+
export * from "./swaps/escrow/frombtc_abstract/FromBtcAbs";
|
|
13
|
+
export * from "./swaps/escrow/frombtc_abstract/FromBtcSwapAbs";
|
|
14
|
+
export * from "./swaps/escrow/frombtcln_abstract/FromBtcLnAbs";
|
|
15
|
+
export * from "./swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs";
|
|
16
|
+
export * from "./swaps/escrow/frombtcln_autoinit/FromBtcLnAuto";
|
|
17
|
+
export * from "./swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap";
|
|
18
|
+
export * from "./swaps/escrow/tobtc_abstract/ToBtcAbs";
|
|
19
|
+
export * from "./swaps/escrow/tobtc_abstract/ToBtcSwapAbs";
|
|
20
|
+
export * from "./swaps/escrow/tobtcln_abstract/ToBtcLnAbs";
|
|
21
|
+
export * from "./swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs";
|
|
22
|
+
|
|
23
|
+
export * from "./swaps/trusted/frombtc_trusted/FromBtcTrusted";
|
|
24
|
+
export * from "./swaps/trusted/frombtc_trusted/FromBtcTrustedSwap";
|
|
25
|
+
export * from "./swaps/trusted/frombtcln_trusted/FromBtcLnTrusted";
|
|
26
|
+
export * from "./swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap";
|
|
27
|
+
|
|
28
|
+
export * from "./prices/ISwapPrice";
|
|
29
|
+
export * from "./swaps/SwapHandler";
|
|
30
|
+
export * from "./swaps/SwapHandlerSwap";
|
|
31
|
+
|
|
32
|
+
export * from "./plugins/PluginManager";
|
|
33
|
+
export * from "./plugins/IPlugin";
|
|
34
|
+
|
|
35
|
+
export * from "./fees/IBtcFeeEstimator";
|
|
36
|
+
|
|
37
|
+
export * from "./utils/paramcoders/IParamReader";
|
|
38
|
+
export * from "./utils/paramcoders/IParamWriter";
|
|
39
|
+
export * from "./utils/paramcoders/LegacyParamEncoder";
|
|
40
|
+
export * from "./utils/paramcoders/ParamDecoder";
|
|
41
|
+
export * from "./utils/paramcoders/ParamEncoder";
|
|
42
|
+
export * from "./utils/paramcoders/SchemaVerifier";
|
|
43
|
+
export * from "./utils/paramcoders/server/ServerParamDecoder";
|
|
44
|
+
export * from "./utils/paramcoders/server/ServerParamEncoder";
|
|
45
|
+
|
|
46
|
+
export * from "./wallets/IBitcoinWallet";
|
|
47
|
+
export * from "./wallets/ILightningWallet";
|
|
48
|
+
export * from "./wallets/ISpvVaultSigner";
|
|
49
|
+
|
|
50
|
+
export * from "./swaps/spv_vault_swap/SpvVaults";
|
|
51
|
+
export * from "./swaps/spv_vault_swap/SpvVault";
|
|
52
|
+
export * from "./swaps/spv_vault_swap/SpvVaultSwap";
|
|
53
|
+
export * from "./swaps/spv_vault_swap/SpvVaultSwapHandler";
|
package/src/info/InfoHandler.ts
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
import {Express} from "express";
|
|
2
|
-
import {MultichainData, SwapHandler, SwapHandlerInfoType, SwapHandlerType} from "../swaps/SwapHandler";
|
|
3
|
-
import * as express from "express";
|
|
4
|
-
|
|
5
|
-
const HEX_REGEX = /[0-9a-f]+/i;
|
|
6
|
-
|
|
7
|
-
type InfoHandlerResponseEnvelope = {
|
|
8
|
-
nonce: string,
|
|
9
|
-
services: {
|
|
10
|
-
[key in SwapHandlerType]?: SwapHandlerInfoType
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
type InfoHandlerResponse = {
|
|
15
|
-
envelope: string,
|
|
16
|
-
chains: {
|
|
17
|
-
[chainIdentifier: string]: {
|
|
18
|
-
address: string,
|
|
19
|
-
signature: string
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Handles info requests to POST /info returning information about fees, swap params, etc.
|
|
26
|
-
*/
|
|
27
|
-
export class InfoHandler {
|
|
28
|
-
|
|
29
|
-
readonly chainData: MultichainData;
|
|
30
|
-
readonly path: string;
|
|
31
|
-
|
|
32
|
-
readonly swapHandlers: SwapHandler[];
|
|
33
|
-
|
|
34
|
-
constructor(chainData: MultichainData, path: string, swapHandlers: SwapHandler[]) {
|
|
35
|
-
this.chainData = chainData;
|
|
36
|
-
this.path = path;
|
|
37
|
-
this.swapHandlers = swapHandlers;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Adds a listener to POST /info
|
|
42
|
-
*
|
|
43
|
-
* @param restServer
|
|
44
|
-
*/
|
|
45
|
-
startRestServer(restServer: Express) {
|
|
46
|
-
|
|
47
|
-
const infoHandler = async (req, res) => {
|
|
48
|
-
const reqParams = {...req.body, ...req.query};
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
reqParams.nonce == null ||
|
|
52
|
-
typeof(reqParams.nonce) !== "string" ||
|
|
53
|
-
reqParams.nonce.length>64 ||
|
|
54
|
-
!HEX_REGEX.test(reqParams.nonce)
|
|
55
|
-
) {
|
|
56
|
-
res.status(400).json({
|
|
57
|
-
msg: "Invalid request body (nonce)"
|
|
58
|
-
});
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const env: InfoHandlerResponseEnvelope = {
|
|
63
|
-
nonce: reqParams.nonce,
|
|
64
|
-
services: {}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
for(let swapHandler of this.swapHandlers) {
|
|
68
|
-
env.services[swapHandler.type] = swapHandler.getInfo();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const envelope = JSON.stringify(env);
|
|
72
|
-
const envelopeBuffer = Buffer.from(envelope);
|
|
73
|
-
|
|
74
|
-
const chains: {
|
|
75
|
-
[chainIdentifier: string]: {
|
|
76
|
-
address: string,
|
|
77
|
-
signature: string
|
|
78
|
-
}
|
|
79
|
-
} = {};
|
|
80
|
-
for(let chainIdentifier in this.chainData.chains) {
|
|
81
|
-
const singleChain = this.chainData.chains[chainIdentifier];
|
|
82
|
-
chains[chainIdentifier] = {
|
|
83
|
-
address: singleChain.signer.getAddress(),
|
|
84
|
-
signature: await singleChain.swapContract.getDataSignature(singleChain.signer, envelopeBuffer)
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const response: InfoHandlerResponse = {
|
|
89
|
-
envelope,
|
|
90
|
-
chains
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
res.status(200).json(response);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
restServer.use(this.path+"/info", express.json());
|
|
97
|
-
restServer.post(this.path+"/info", infoHandler);
|
|
98
|
-
restServer.get(this.path+"/info", infoHandler);
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
1
|
+
import {Express} from "express";
|
|
2
|
+
import {MultichainData, SwapHandler, SwapHandlerInfoType, SwapHandlerType} from "../swaps/SwapHandler";
|
|
3
|
+
import * as express from "express";
|
|
4
|
+
|
|
5
|
+
const HEX_REGEX = /[0-9a-f]+/i;
|
|
6
|
+
|
|
7
|
+
type InfoHandlerResponseEnvelope = {
|
|
8
|
+
nonce: string,
|
|
9
|
+
services: {
|
|
10
|
+
[key in SwapHandlerType]?: SwapHandlerInfoType
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type InfoHandlerResponse = {
|
|
15
|
+
envelope: string,
|
|
16
|
+
chains: {
|
|
17
|
+
[chainIdentifier: string]: {
|
|
18
|
+
address: string,
|
|
19
|
+
signature: string
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Handles info requests to POST /info returning information about fees, swap params, etc.
|
|
26
|
+
*/
|
|
27
|
+
export class InfoHandler {
|
|
28
|
+
|
|
29
|
+
readonly chainData: MultichainData;
|
|
30
|
+
readonly path: string;
|
|
31
|
+
|
|
32
|
+
readonly swapHandlers: SwapHandler[];
|
|
33
|
+
|
|
34
|
+
constructor(chainData: MultichainData, path: string, swapHandlers: SwapHandler[]) {
|
|
35
|
+
this.chainData = chainData;
|
|
36
|
+
this.path = path;
|
|
37
|
+
this.swapHandlers = swapHandlers;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Adds a listener to POST /info
|
|
42
|
+
*
|
|
43
|
+
* @param restServer
|
|
44
|
+
*/
|
|
45
|
+
startRestServer(restServer: Express) {
|
|
46
|
+
|
|
47
|
+
const infoHandler = async (req, res) => {
|
|
48
|
+
const reqParams = {...req.body, ...req.query};
|
|
49
|
+
|
|
50
|
+
if (
|
|
51
|
+
reqParams.nonce == null ||
|
|
52
|
+
typeof(reqParams.nonce) !== "string" ||
|
|
53
|
+
reqParams.nonce.length>64 ||
|
|
54
|
+
!HEX_REGEX.test(reqParams.nonce)
|
|
55
|
+
) {
|
|
56
|
+
res.status(400).json({
|
|
57
|
+
msg: "Invalid request body (nonce)"
|
|
58
|
+
});
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const env: InfoHandlerResponseEnvelope = {
|
|
63
|
+
nonce: reqParams.nonce,
|
|
64
|
+
services: {}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
for(let swapHandler of this.swapHandlers) {
|
|
68
|
+
env.services[swapHandler.type] = swapHandler.getInfo();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const envelope = JSON.stringify(env);
|
|
72
|
+
const envelopeBuffer = Buffer.from(envelope);
|
|
73
|
+
|
|
74
|
+
const chains: {
|
|
75
|
+
[chainIdentifier: string]: {
|
|
76
|
+
address: string,
|
|
77
|
+
signature: string
|
|
78
|
+
}
|
|
79
|
+
} = {};
|
|
80
|
+
for(let chainIdentifier in this.chainData.chains) {
|
|
81
|
+
const singleChain = this.chainData.chains[chainIdentifier];
|
|
82
|
+
chains[chainIdentifier] = {
|
|
83
|
+
address: singleChain.signer.getAddress(),
|
|
84
|
+
signature: await singleChain.swapContract.getDataSignature(singleChain.signer, envelopeBuffer)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const response: InfoHandlerResponse = {
|
|
89
|
+
envelope,
|
|
90
|
+
chains
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
res.status(200).json(response);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
restServer.use(this.path+"/info", express.json());
|
|
97
|
+
restServer.post(this.path+"/info", infoHandler);
|
|
98
|
+
restServer.get(this.path+"/info", infoHandler);
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
}
|