@atomicfinance/bitcoin-dlc-provider 2.5.0 → 3.0.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/.turbo/turbo-build.log +1 -0
- package/.turbo/turbo-test.log +1 -0
- package/CHANGELOG.md +35 -0
- package/dist/BitcoinDlcProvider.d.ts +1 -1
- package/dist/BitcoinDlcProvider.js +741 -743
- package/dist/BitcoinDlcProvider.js.map +1 -1
- package/dist/index.d.ts +0 -0
- package/dist/index.js +21 -57
- package/dist/index.js.map +0 -0
- package/dist/utils/Utils.d.ts +0 -0
- package/dist/utils/Utils.js +50 -54
- package/dist/utils/Utils.js.map +0 -0
- package/lib/BitcoinDlcProvider.ts +22 -18
- package/package.json +11 -14
- package/LICENSE +0 -674
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { chainHashFromNetwork } from '@atomicfinance/bitcoin-networks';
|
|
2
1
|
import Provider from '@atomicfinance/provider';
|
|
3
2
|
import {
|
|
4
3
|
AdaptorPair,
|
|
4
|
+
Address,
|
|
5
5
|
AddSignaturesToRefundTxRequest,
|
|
6
6
|
AddSignaturesToRefundTxResponse,
|
|
7
7
|
AddSignatureToFundTransactionRequest,
|
|
8
8
|
AddSignatureToFundTransactionResponse,
|
|
9
|
+
bitcoin,
|
|
9
10
|
CalculateEcSignatureRequest,
|
|
10
11
|
CreateCetAdaptorSignatureRequest,
|
|
11
12
|
CreateCetAdaptorSignatureResponse,
|
|
@@ -44,9 +45,7 @@ import {
|
|
|
44
45
|
VerifyRefundTxSignatureResponse,
|
|
45
46
|
VerifySignatureRequest,
|
|
46
47
|
} from '@atomicfinance/types';
|
|
47
|
-
import {
|
|
48
|
-
import { Address, bitcoin } from '@liquality/types';
|
|
49
|
-
import { sleep } from '@liquality/utils';
|
|
48
|
+
import { sleep } from '@atomicfinance/utils';
|
|
50
49
|
import {
|
|
51
50
|
DualClosingTxFinalizer,
|
|
52
51
|
DualFundingTxFinalizer,
|
|
@@ -92,6 +91,7 @@ import { StreamReader } from '@node-lightning/bufio';
|
|
|
92
91
|
import { hash160, sha256, xor } from '@node-lightning/crypto';
|
|
93
92
|
import assert from 'assert';
|
|
94
93
|
import BigNumber from 'bignumber.js';
|
|
94
|
+
import { BitcoinNetwork, chainHashFromNetwork } from 'bitcoin-networks';
|
|
95
95
|
import {
|
|
96
96
|
address,
|
|
97
97
|
ECPairInterface,
|
|
@@ -647,9 +647,9 @@ export default class BitcoinDlcProvider
|
|
|
647
647
|
network,
|
|
648
648
|
);
|
|
649
649
|
|
|
650
|
-
const {
|
|
651
|
-
|
|
652
|
-
|
|
650
|
+
const { derivationPath } = await this.client.wallet.findAddress([
|
|
651
|
+
fundingAddress,
|
|
652
|
+
]);
|
|
653
653
|
|
|
654
654
|
const fundPrivateKeyPair = await this.getMethod('keyPair')(derivationPath);
|
|
655
655
|
const fundPrivateKey = Buffer.from(fundPrivateKeyPair.__D).toString('hex');
|
|
@@ -1025,11 +1025,14 @@ export default class BitcoinDlcProvider
|
|
|
1025
1025
|
polynomialPayoutCurvePiece,
|
|
1026
1026
|
);
|
|
1027
1027
|
|
|
1028
|
+
const payouts = polynomialPayoutCurvePiece.points.map((point) =>
|
|
1029
|
+
Number(point.outcomePayout),
|
|
1030
|
+
);
|
|
1031
|
+
const minPayout = Math.min(...payouts);
|
|
1032
|
+
const maxPayout = Math.max(...payouts);
|
|
1033
|
+
|
|
1028
1034
|
const clampBN = (val: BigNumber) =>
|
|
1029
|
-
BigNumber.max(
|
|
1030
|
-
0,
|
|
1031
|
-
BigNumber.min(val, dlcOffer.contractInfo.totalCollateral.toString()),
|
|
1032
|
-
);
|
|
1035
|
+
BigNumber.max(minPayout, BigNumber.min(val, maxPayout));
|
|
1033
1036
|
|
|
1034
1037
|
const payout = clampBN(polynomialCurve.getPayout(outcome));
|
|
1035
1038
|
|
|
@@ -1737,11 +1740,11 @@ Payout Group not found',
|
|
|
1737
1740
|
network,
|
|
1738
1741
|
);
|
|
1739
1742
|
|
|
1740
|
-
let walletAddress: Address = await this.client.
|
|
1741
|
-
|
|
1742
|
-
);
|
|
1743
|
+
let walletAddress: Address = await this.client.wallet.findAddress([
|
|
1744
|
+
offerFundingAddress,
|
|
1745
|
+
]);
|
|
1743
1746
|
if (walletAddress) return true;
|
|
1744
|
-
walletAddress = await this.client.
|
|
1747
|
+
walletAddress = await this.client.wallet.findAddress([
|
|
1745
1748
|
acceptFundingAddress,
|
|
1746
1749
|
]);
|
|
1747
1750
|
if (walletAddress) return false;
|
|
@@ -2950,9 +2953,9 @@ Payout Group not found',
|
|
|
2950
2953
|
let derivationPath: string;
|
|
2951
2954
|
|
|
2952
2955
|
if (findDerivationPath) {
|
|
2953
|
-
const inputAddress: Address = await this.client.
|
|
2954
|
-
|
|
2955
|
-
);
|
|
2956
|
+
const inputAddress: Address = await this.client.wallet.findAddress([
|
|
2957
|
+
_address,
|
|
2958
|
+
]);
|
|
2956
2959
|
if (inputAddress) {
|
|
2957
2960
|
derivationPath = inputAddress.derivationPath;
|
|
2958
2961
|
}
|
|
@@ -2992,6 +2995,7 @@ Payout Group not found',
|
|
|
2992
2995
|
);
|
|
2993
2996
|
}
|
|
2994
2997
|
}
|
|
2998
|
+
|
|
2995
2999
|
const tx = Tx.decode(StreamReader.fromHex(txRaw));
|
|
2996
3000
|
|
|
2997
3001
|
fundingInput.prevTx = tx;
|
package/package.json
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomicfinance/bitcoin-dlc-provider",
|
|
3
3
|
"umdName": "BitcoinDlcProvider",
|
|
4
|
-
"version": "
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "3.0.1",
|
|
5
|
+
"description": "Bitcoin Abstraction Layer Dlc Provider",
|
|
6
6
|
"author": "Atomic Finance <info@atomic.finance>",
|
|
7
7
|
"homepage": "",
|
|
8
8
|
"license": "ISC",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "../../node_modules/.bin/
|
|
11
|
+
"build": "../../node_modules/.bin/tsc --project tsconfig.json",
|
|
12
12
|
"prepublishOnly": "yarn run build",
|
|
13
13
|
"test": "yarn run build",
|
|
14
14
|
"lint": "../../node_modules/.bin/eslint --ignore-path ../../.eslintignore -c ../../.eslintrc.js .",
|
|
15
15
|
"lint:fix": "../../node_modules/.bin/eslint --fix --ignore-path ../../.eslintignore -c ../../.eslintrc.js ."
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@atomicfinance/bitcoin-
|
|
19
|
-
"@atomicfinance/provider": "^
|
|
20
|
-
"@atomicfinance/types": "^
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"@liquality/utils": "1.1.5",
|
|
25
|
-
"@node-dlc/core": "0.18.3",
|
|
26
|
-
"@node-dlc/messaging": "0.18.3",
|
|
18
|
+
"@atomicfinance/bitcoin-utils": "3.0.1",
|
|
19
|
+
"@atomicfinance/provider": "^3.0.1",
|
|
20
|
+
"@atomicfinance/types": "^3.0.1",
|
|
21
|
+
"@atomicfinance/utils": "^3.0.1",
|
|
22
|
+
"@node-dlc/core": "0.19.1",
|
|
23
|
+
"@node-dlc/messaging": "0.19.1",
|
|
27
24
|
"@node-lightning/bitcoin": "0.26.1",
|
|
28
25
|
"@node-lightning/bufio": "0.26.1",
|
|
29
26
|
"@node-lightning/crypto": "0.26.1",
|
|
30
27
|
"bignumber.js": "^9.0.1",
|
|
31
28
|
"bip-schnorr": "0.6.2",
|
|
29
|
+
"bitcoin-networks": "^1.0.0",
|
|
32
30
|
"bitcoinjs-lib": "5.2.0",
|
|
33
31
|
"lodash": "^4.17.20",
|
|
34
32
|
"randombytes": "2.1.0",
|
|
@@ -40,6 +38,5 @@
|
|
|
40
38
|
},
|
|
41
39
|
"publishConfig": {
|
|
42
40
|
"access": "public"
|
|
43
|
-
}
|
|
44
|
-
"gitHead": "021537d74a46eb5bd578a7c4b122555e6b0a310f"
|
|
41
|
+
}
|
|
45
42
|
}
|