diff --git a/justfile b/justfile index f190f5a9..bceaaac0 100644 --- a/justfile +++ b/justfile @@ -7,5 +7,12 @@ build: test: yarn run test +# sequential test +seqtest: + yarn test:integration:sequential + lint: yarn run lint + +clean: + find . -name "node_modules" -type d -exec rm -rf '{}' + diff --git a/package.json b/package.json index 577fefa4..cf371088 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,9 @@ ], "devDependencies": { "@changesets/cli": "^2.22.0", - "@node-dlc/core": "0.22.4", - "@node-dlc/messaging": "0.22.4", + "@node-dlc/bitcoin": "0.23.0", + "@node-dlc/core": "0.23.0", + "@node-dlc/messaging": "0.23.0", "@swc/cli": "^0.1.57", "@swc/core": "^1.2.172", "@swc/register": "^0.1.10", @@ -61,7 +62,7 @@ "test": "yarn run test:unit && yarn run test:integration", "test:unit": "turbo run test", "test:integration": "nyc --reporter=text --reporter=lcov cross-env NODE_ENV=test mocha --parallel", - "test:integration:single": "nyc --reporter=text --reporter=lcov cross-env NODE_ENV=test mocha", + "test:integration:sequential": "nyc --reporter=text --reporter=lcov cross-env NODE_ENV=test mocha", "prepublishOnly": "yarn build", "changeset": "changeset", "version": "yarn changeset version", diff --git a/packages/bitcoin-dlc-provider/lib/BitcoinDlcProvider.ts b/packages/bitcoin-dlc-provider/lib/BitcoinDlcProvider.ts index b38551ad..db2b2909 100644 --- a/packages/bitcoin-dlc-provider/lib/BitcoinDlcProvider.ts +++ b/packages/bitcoin-dlc-provider/lib/BitcoinDlcProvider.ts @@ -6,7 +6,6 @@ import { AddSignaturesToRefundTxResponse, AddSignatureToFundTransactionRequest, AddSignatureToFundTransactionResponse, - bitcoin, CalculateEcSignatureRequest, CreateBatchDlcTransactionsRequest, CreateBatchDlcTransactionsResponse, @@ -112,8 +111,6 @@ import { outputsToPayouts, } from './utils/Utils'; -const ESTIMATED_SIZE = 312; - export default class BitcoinDlcProvider extends Provider implements Partial { @@ -168,26 +165,27 @@ export default class BitcoinDlcProvider } async GetInputsForAmount( - amount: bigint, + amounts: bigint[], feeRatePerVb: bigint, fixedInputs: Input[] = [], ): Promise { - if (amount === BigInt(0)) return []; - const targets: bitcoin.OutputTarget[] = [ - { - address: BurnAddress, - value: Number(amount) + ESTIMATED_SIZE * (Number(feeRatePerVb) - 1), - }, - ]; + if (amounts.length === 0) return []; + + const fixedUtxos = fixedInputs.map((input) => input.toUtxo()); + let inputs: Input[]; try { - const inputsForAmount: InputsForAmountResponse = await this.getMethod( - 'getInputsForAmount', - )(targets, Number(feeRatePerVb), fixedInputs); + const inputsForAmount: InputsForDualAmountResponse = await this.getMethod( + 'getInputsForDualFunding', + )(amounts, feeRatePerVb, fixedUtxos); + inputs = inputsForAmount.inputs; } catch (e) { + const errorMessage = e instanceof Error ? e.message : 'Unknown error'; if (fixedInputs.length === 0) { - throw Error('Not enough balance getInputsForAmount'); + throw Error( + `Not enough balance getInputsForAmount. Error: ${errorMessage}`, + ); } else { inputs = fixedInputs; } @@ -226,7 +224,7 @@ export default class BitcoinDlcProvider throw Error('Address reuse'); const inputs: Input[] = await this.GetInputsForAmount( - collateral, + [collateral], feeRatePerVb, fixedInputs, ); @@ -256,10 +254,8 @@ export default class BitcoinDlcProvider ): Promise { const network = await this.getConnectedNetwork(); - const collateral = collaterals.reduce((a, b) => a + b, BigInt(0)); - const inputs: Input[] = await this.GetInputsForAmount( - collateral, + collaterals, feeRatePerVb, fixedInputs, ); @@ -2928,7 +2924,7 @@ Payout Group found but incorrect group index', let inputs: Input[] = _inputs; if (!_inputs) { const tempInputs = await this.GetInputsForAmount( - BigInt(20000), + [BigInt(20000)], dlcOffer.feeRatePerVb, _inputs, ); @@ -3793,4 +3789,9 @@ export interface InputsForAmountResponse { fee: number; } +export interface InputsForDualAmountResponse { + inputs: Input[]; + fee: number; +} + const BurnAddress = 'bcrt1qxcjufgh2jarkp2qkx68azh08w9v5gah8u6es8s'; diff --git a/packages/bitcoin-dlc-provider/lib/utils/Utils.ts b/packages/bitcoin-dlc-provider/lib/utils/Utils.ts index 9793713a..29b48c0f 100644 --- a/packages/bitcoin-dlc-provider/lib/utils/Utils.ts +++ b/packages/bitcoin-dlc-provider/lib/utils/Utils.ts @@ -14,11 +14,14 @@ import { } from '@node-dlc/messaging'; import randomBytes from 'randombytes'; -export async function asyncForEach(array: any, callback: any) { +export const asyncForEach = async ( + array: any, + callback: any, +): Promise => { for (let index = 0; index < array.length; index++) { await callback(array[index], index, array); } -} +}; export function generateSerialId(): bigint { return randomBytes(4).reduce((acc, num, i) => acc + num ** i, 0); diff --git a/packages/bitcoin-dlc-provider/package.json b/packages/bitcoin-dlc-provider/package.json index e6f8fd68..ab3f14fc 100644 --- a/packages/bitcoin-dlc-provider/package.json +++ b/packages/bitcoin-dlc-provider/package.json @@ -19,8 +19,8 @@ "@atomicfinance/provider": "^3.4.0", "@atomicfinance/types": "^3.4.0", "@atomicfinance/utils": "^3.4.0", - "@node-dlc/core": "0.22.4", - "@node-dlc/messaging": "0.22.4", + "@node-dlc/core": "0.23.0", + "@node-dlc/messaging": "0.23.0", "@node-lightning/bitcoin": "0.26.1", "@node-lightning/bufio": "0.26.1", "@node-lightning/crypto": "0.26.1", diff --git a/packages/bitcoin-js-wallet-provider/lib/BitcoinJsWalletProvider.ts b/packages/bitcoin-js-wallet-provider/lib/BitcoinJsWalletProvider.ts index 95e04dac..4c14c658 100644 --- a/packages/bitcoin-js-wallet-provider/lib/BitcoinJsWalletProvider.ts +++ b/packages/bitcoin-js-wallet-provider/lib/BitcoinJsWalletProvider.ts @@ -303,7 +303,10 @@ export default class BitcoinJsWalletProvider extends BitcoinWalletProvider( feePerByte: number, _outputs: Output[], fixedInputs: Input[], - ) { + ): Promise<{ + hex: string; + fee: number; + }> { return this._buildSweepTransactionWithSetOutputs( externalChangeAddress, feePerByte, @@ -317,7 +320,10 @@ export default class BitcoinJsWalletProvider extends BitcoinWalletProvider( feePerByte: number, _outputs: Output[] = [], fixedInputs: Input[], - ) { + ): Promise<{ + hex: string; + fee: number; + }> { const _feePerByte = feePerByte || (await this.getMethod('getFeePerByte')()) || @@ -605,7 +611,7 @@ export default class BitcoinJsWalletProvider extends BitcoinWalletProvider( tx: any, _lockTime?: number, segwit?: boolean, - ) { + ): Promise { const keyPairs = []; for (const address of addresses) { const wallet = await this.getWalletAddress(address); @@ -613,7 +619,7 @@ export default class BitcoinJsWalletProvider extends BitcoinWalletProvider( keyPairs.push(keyPair); } - const sigs = []; + const sigs: Buffer[] = []; for (let i = 0; i < inputs.length; i++) { const index = inputs[i].txInputIndex ? inputs[i].txInputIndex diff --git a/packages/bitcoin-js-wallet-provider/package.json b/packages/bitcoin-js-wallet-provider/package.json index 8df066a3..7331ad04 100644 --- a/packages/bitcoin-js-wallet-provider/package.json +++ b/packages/bitcoin-js-wallet-provider/package.json @@ -29,6 +29,7 @@ "@atomicfinance/types": "^3.4.0", "@atomicfinance/utils": "^3.4.0", "@babel/runtime": "^7.12.1", + "@node-dlc/core": "0.23.0", "bip32": "^2.0.6", "bip39": "^3.0.2", "bitcoin-networks": "^1.0.0", diff --git a/packages/bitcoin-utils/lib/index.ts b/packages/bitcoin-utils/lib/index.ts index cac0cc31..a49c1f85 100644 --- a/packages/bitcoin-utils/lib/index.ts +++ b/packages/bitcoin-utils/lib/index.ts @@ -18,34 +18,34 @@ import { findKey } from 'lodash'; const AddressTypes = ['legacy', 'p2sh-segwit', 'bech32']; -function calculateFee( +const calculateFee = ( numInputs: number, numOutputs: number, feePerByte: number, -) { +): number => { return (numInputs * 148 + numOutputs * 34 + 10) * feePerByte; -} +}; /** * Get compressed pubKey from pubKey. * @param {!string} pubKey - 65 byte string with prefix, x, y. * @return {string} Returns the compressed pubKey of uncompressed pubKey. */ -function compressPubKey(pubKey: string) { +const compressPubKey = (pubKey: string): string => { const x = pubKey.substring(2, 66); const y = pubKey.substring(66, 130); const even = parseInt(y.substring(62, 64), 16) % 2 === 0; const prefix = even ? '02' : '03'; return prefix + x; -} +}; /** * Get a network object from an address * @param {string} address The bitcoin address * @return {Network} */ -function getAddressNetwork(address: string) { +const getAddressNetwork = (address: string): BitcoinNetwork => { // TODO: can this be simplified using just bitcoinjs-lib?? let networkKey; // bech32 @@ -62,7 +62,7 @@ function getAddressNetwork(address: string) { }); } return (BitcoinNetworks as { [key: string]: BitcoinNetwork })[networkKey]; -} +}; type CoinSelectTarget = { value: number; @@ -83,12 +83,12 @@ type CoinSelectFunction = ( feePerByte: number, ) => CoinSelectResponse; -function selectCoins( +const selectCoins = ( utxos: bT.UTXO[], targets: CoinSelectTarget[], feePerByte: number, fixedInputs: bT.UTXO[] = [], -) { +): CoinSelectResponse => { let selectUtxos = utxos; // Default coinselect won't accumulate some inputs @@ -121,17 +121,17 @@ function selectCoins( } return { inputs, outputs, fee, change }; -} +}; const OUTPUT_TYPES_MAP = { [classify.types.P2WPKH]: 'witness_v0_keyhash', [classify.types.P2WSH]: 'witness_v0_scripthash', }; -function decodeRawTransaction( +const decodeRawTransaction = ( hex: string, network: BitcoinNetwork, -): bT.Transaction { +): bT.Transaction => { const bjsTx = bitcoin.Transaction.fromHex(hex); const vin = bjsTx.ins.map((input) => { @@ -184,13 +184,13 @@ function decodeRawTransaction( vout, hex, }; -} +}; -function normalizeTransactionObject( +const normalizeTransactionObject = ( tx: bT.Transaction, fee: number, block?: { number: number; hash: string }, -): Transaction { +): Transaction => { const value = tx.vout.reduce( (p, n) => p.plus(new BigNumber(n.value).times(1e8)), new BigNumber(0), @@ -220,11 +220,11 @@ function normalizeTransactionObject( } return result; -} +}; // TODO: This is copy pasta because it's not exported from bitcoinjs-lib // https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/csv.spec.ts#L477 -function witnessStackToScriptWitness(witness: Buffer[]): Buffer { +const witnessStackToScriptWitness = (witness: Buffer[]): Buffer => { let buffer = Buffer.allocUnsafe(0); function writeSlice(slice: Buffer): void { @@ -252,9 +252,9 @@ function witnessStackToScriptWitness(witness: Buffer[]): Buffer { writeVector(witness); return buffer; -} +}; -function getPubKeyHash(address: string, network: BitcoinNetwork) { +const getPubKeyHash = (address: string, network: BitcoinNetwork): Buffer => { const outputScript = bitcoin.address.toOutputScript(address, network); const type = classify.output(outputScript); if (![classify.types.P2PKH, classify.types.P2WPKH].includes(type)) { @@ -270,9 +270,12 @@ function getPubKeyHash(address: string, network: BitcoinNetwork) { const base58 = bitcoin.address.fromBase58Check(address); return base58.hash; } -} +}; -function validateAddress(_address: Address | string, network: BitcoinNetwork) { +const validateAddress = ( + _address: Address | string, + network: BitcoinNetwork, +): void => { const address = addressToString(_address); if (typeof address !== 'string') { @@ -291,7 +294,7 @@ function validateAddress(_address: Address | string, network: BitcoinNetwork) { if (!pubKeyHash) { throw new InvalidAddressError(`Invalid Address: ${address}`); } -} +}; export { calculateFee, diff --git a/packages/bitcoin-wallet-provider/lib/BitcoinWalletProvider.ts b/packages/bitcoin-wallet-provider/lib/BitcoinWalletProvider.ts index d461040d..b485bce3 100644 --- a/packages/bitcoin-wallet-provider/lib/BitcoinWalletProvider.ts +++ b/packages/bitcoin-wallet-provider/lib/BitcoinWalletProvider.ts @@ -16,6 +16,7 @@ import { WalletProvider, } from '@atomicfinance/types'; import { addressToString } from '@atomicfinance/utils'; +import { dualFundingCoinSelect } from '@node-dlc/core'; import { BitcoinNetwork } from 'bitcoin-networks'; import * as bitcoin from 'bitcoinjs-lib'; import { BIP32Interface } from 'bitcoinjs-lib'; @@ -765,6 +766,135 @@ export default >(superclass: T) => { throw new InsufficientBalanceError('Not enough balance'); } + + async getInputsForDualFunding( + collaterals: number[], + feePerByte?: number, + fixedInputs: bT.Input[] = [], + numAddressPerCall = 100, + ) { + let addressIndex = 0; + let changeAddresses: Address[] = []; + let externalAddresses: Address[] = []; + const addressCountMap = { + change: 0, + nonChange: 0, + }; + + const feePerBytePromise = this.getMethod('getFeePerByte')(); + let utxos: bT.UTXO[] = []; + + while ( + addressCountMap.change < ADDRESS_GAP || + addressCountMap.nonChange < ADDRESS_GAP + ) { + let addrList: Address[] = []; + + if (addressCountMap.change < ADDRESS_GAP) { + // Scanning for change addr + changeAddresses = await this.getAddresses( + addressIndex, + numAddressPerCall, + true, + ); + addrList = addrList.concat(changeAddresses); + } else { + changeAddresses = []; + } + + if (addressCountMap.nonChange < ADDRESS_GAP) { + // Scanning for non change addr + externalAddresses = await this.getAddresses( + addressIndex, + numAddressPerCall, + false, + ); + addrList = addrList.concat(externalAddresses); + } + + const fixedUtxos: bT.UTXO[] = []; + if (fixedInputs.length > 0) { + for (const input of fixedInputs) { + const txHex = await this.getMethod('getRawTransactionByHash')( + input.txid, + ); + const tx = decodeRawTransaction(txHex, this._network); + const value = new BigNumber(tx.vout[input.vout].value) + .times(1e8) + .toNumber(); + const address = tx.vout[input.vout].scriptPubKey.addresses[0]; + const walletAddress = await this.getWalletAddress(address); + const utxo = { + ...input, + value, + address, + derivationPath: walletAddress.derivationPath, + }; + fixedUtxos.push(utxo); + } + } + + if (fixedUtxos.length === 0) { + const _utxos: bT.UTXO[] = await this.getMethod( + 'getUnspentTransactions', + )(addrList); + utxos.push( + ..._utxos.map((utxo) => { + const addr = addrList.find((a) => a.address === utxo.address); + return { + ...utxo, + derivationPath: addr.derivationPath, + }; + }), + ); + } else { + utxos = fixedUtxos; + } + + const transactionCounts: bT.AddressTxCounts = await this.getMethod( + 'getAddressTransactionCounts', + )(addrList); + + if (!feePerByte) feePerByte = await feePerBytePromise; + const minRelayFee = await this.getMethod('getMinRelayFee')(); + if (feePerByte < minRelayFee) { + throw new Error( + `Fee supplied (${feePerByte} sat/b) too low. Minimum relay fee is ${minRelayFee} sat/b`, + ); + } + + const { fee, inputs } = dualFundingCoinSelect( + utxos, + collaterals.map((c) => BigInt(c)), + BigInt(feePerByte), + ); + + if (inputs.length > 0) { + return { + inputs, + fee, + }; + } + + for (const address of addrList) { + const isUsed = transactionCounts[address.address]; + const isChangeAddress = changeAddresses.find( + (a) => address.address === a.address, + ); + const key = isChangeAddress ? 'change' : 'nonChange'; + + if (isUsed) { + addressCountMap[key] = 0; + } else { + addressCountMap[key]++; + } + } + + addressIndex += numAddressPerCall; + } + + throw new InsufficientBalanceError('Not enough balance for dual funding'); + } } return BitcoinWalletProvider; }; diff --git a/packages/bitcoin-wallet-provider/package.json b/packages/bitcoin-wallet-provider/package.json index e300ba57..27a2f6ce 100644 --- a/packages/bitcoin-wallet-provider/package.json +++ b/packages/bitcoin-wallet-provider/package.json @@ -18,6 +18,7 @@ "@atomicfinance/bitcoin-utils": "^3.4.0", "@atomicfinance/provider": "^3.4.0", "@atomicfinance/types": "^3.4.0", + "@node-dlc/core": "0.23.0", "bitcoin-networks": "^1.0.0", "bitcoinjs-lib": "5.2.0", "lodash": "^4.17.20", diff --git a/packages/client/lib/Client.ts b/packages/client/lib/Client.ts index b0772caf..cb0d2ff9 100644 --- a/packages/client/lib/Client.ts +++ b/packages/client/lib/Client.ts @@ -146,7 +146,7 @@ export default class Client implements IClient { * above the requestor in the stack. * @return {function} Returns method from provider instance associated with the requested method */ - getMethod(method: string, requestor?: any) { + getMethod(method: string, requestor?: any): (...args: any[]) => any { const provider = this.getProviderForMethod(method, requestor); return (provider)[method].bind(provider); } diff --git a/packages/client/lib/Dlc.ts b/packages/client/lib/Dlc.ts index 25ad61c2..0c03a6a1 100644 --- a/packages/client/lib/Dlc.ts +++ b/packages/client/lib/Dlc.ts @@ -459,12 +459,12 @@ export default class Dlc implements DlcProvider { } async GetInputsForAmount( - amount: bigint, + amounts: bigint[], feeRatePerVb: bigint, fixedInputs: Input[], ): Promise { return this.client.getMethod('GetInputsForAmount')( - amount, + amounts, feeRatePerVb, fixedInputs, ); diff --git a/packages/client/lib/Wallet.ts b/packages/client/lib/Wallet.ts index 8fe11c95..ae080e3e 100644 --- a/packages/client/lib/Wallet.ts +++ b/packages/client/lib/Wallet.ts @@ -1,12 +1,15 @@ +import { CoinSelectTarget } from '@atomicfinance/bitcoin-utils'; import { InvalidProviderResponseError, UnimplementedMethodError, } from '@atomicfinance/errors'; import { Address, + bitcoin as bT, CreateMultisigResponse, Input, Output, + Transaction as Tx, WalletProvider, } from '@atomicfinance/types'; import { Transaction } from 'bitcoinjs-lib'; @@ -121,8 +124,11 @@ export default class Wallet implements WalletProvider { return this.client.getMethod('exportPrivateKey')(); } - findAddress(addresses: string[]) { - return this.client.getMethod('findAddress')(addresses); + async findAddress( + addresses: string[], + change: boolean | null = null, + ): Promise
{ + return this.client.getMethod('findAddress')(addresses, change); } setUnusedAddressesBlacklist(unusedAddressesBlacklist: any) { @@ -166,7 +172,10 @@ export default class Wallet implements WalletProvider { feePerByte: number, outputs: Output[], fixedInputs: Input[], - ) { + ): Promise<{ + hex: string; + fee: number; + }> { return this.client.getMethod('buildSweepTransactionWithSetOutputs')( externalChangeAddress, feePerByte, @@ -180,7 +189,7 @@ export default class Wallet implements WalletProvider { feePerByte: number, outputs: Output[], fixedInputs: Input[], - ) { + ): Promise> { return this.client.getMethod('sendSweepTransactionWithSetOutputs')( externalChangeAddress, feePerByte, @@ -188,4 +197,42 @@ export default class Wallet implements WalletProvider { fixedInputs, ); } + + async getInputsForAmount( + _targets: bT.OutputTarget[], + feePerByte?: number, + fixedInputs: bT.Input[] = [], + numAddressPerCall = 100, + sweep = false, + ): Promise<{ + inputs: bT.UTXO[]; + change: CoinSelectTarget; + outputs: CoinSelectTarget[]; + fee: number; + }> { + return this.client.getMethod('getInputsForAmount')( + _targets, + feePerByte, + fixedInputs, + numAddressPerCall, + sweep, + ); + } + + async getInputsForDualFunding( + collaterals: number[], + feePerByte?: number, + fixedInputs: bT.Input[] = [], + numAddressPerCall = 100, + ): Promise<{ + inputs: bT.UTXO[]; + fee: bigint; + }> { + return this.client.getMethod('getInputsForDualFunding')( + collaterals, + feePerByte, + fixedInputs, + numAddressPerCall, + ); + } } diff --git a/packages/client/package.json b/packages/client/package.json index 5cab406e..76a71da0 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -15,10 +15,11 @@ "lint:fix": "../../node_modules/.bin/eslint --fix --ignore-path ../../.eslintignore -c ../../.eslintrc.js ." }, "dependencies": { + "@atomicfinance/bitcoin-utils": "^3.4.0", "@atomicfinance/errors": "^3.4.0", "@atomicfinance/provider": "^3.4.0", "@atomicfinance/types": "^3.4.0", - "@node-dlc/messaging": "0.22.4", + "@node-dlc/messaging": "0.23.0", "@node-lightning/bitcoin": "0.26.1", "ajv": "^6.10.0", "lodash": "^4.17.20" diff --git a/packages/types/lib/dlc.ts b/packages/types/lib/dlc.ts index 68a97ee5..6681858a 100644 --- a/packages/types/lib/dlc.ts +++ b/packages/types/lib/dlc.ts @@ -20,7 +20,7 @@ import Input from './models/Input'; export interface DlcProvider { GetInputsForAmount( - amount: bigint, + amounts: bigint[], feeRatePerVb: bigint, fixedInputs: Input[], ): Promise; diff --git a/packages/types/package.json b/packages/types/package.json index 2da7637e..ffbcbb42 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -15,7 +15,7 @@ "lint:fix": "../../node_modules/.bin/eslint --fix --ignore-path ../../.eslintignore -c ../../.eslintrc.js ." }, "dependencies": { - "@node-dlc/messaging": "0.22.4", + "@node-dlc/messaging": "0.23.0", "@node-lightning/bitcoin": "0.26.1", "@node-lightning/noise": "0.26.1", "lodash": "^4.17.20" diff --git a/tests/integration/dlc/custom-oracle.test.ts b/tests/integration/dlc/custom-oracle.test.ts index ff38f3fd..5f46e335 100644 --- a/tests/integration/dlc/custom-oracle.test.ts +++ b/tests/integration/dlc/custom-oracle.test.ts @@ -596,9 +596,6 @@ describe('Custom Strategy Oracle POC numdigits=21', () => { const cetLocktime = 1617170572; const refundLocktime = 1617170573; - console.time('total'); - console.time('offer'); - const tempDlcOffer = await alice.dlc.createDlcOffer( offer.contractInfo, offer.offerCollateralSatoshis, diff --git a/tests/integration/dlc/dlc.test.ts b/tests/integration/dlc/dlc.test.ts index 08354d01..a85bdd60 100644 --- a/tests/integration/dlc/dlc.test.ts +++ b/tests/integration/dlc/dlc.test.ts @@ -618,8 +618,6 @@ describe('dlc provider', () => { const contractSize = 0.1; - console.log('networkFees.bitcoin', networkFees.bitcoin); - const maxGain = Value.fromBitcoin( LONG_OPTION_MAX_GAIN.bitcoin * contractSize + contractPrice * contractSize + diff --git a/yarn.lock b/yarn.lock index 6c7f2c2c..9bfaf14c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19,9 +19,9 @@ __metadata: version: 0.0.0-use.local resolution: "@atomicfinance/bitcoin-cfd-provider@workspace:packages/bitcoin-cfd-provider" dependencies: - "@atomicfinance/provider": ^3.3.1 - "@atomicfinance/types": ^3.3.1 - "@atomicfinance/utils": ^3.3.1 + "@atomicfinance/provider": ^3.4.0 + "@atomicfinance/types": ^3.4.0 + "@atomicfinance/utils": ^3.4.0 "@types/lodash": ^4.14.160 "@types/node": 16.10.3 lodash: ^4.17.20 @@ -32,12 +32,12 @@ __metadata: version: 0.0.0-use.local resolution: "@atomicfinance/bitcoin-dlc-provider@workspace:packages/bitcoin-dlc-provider" dependencies: - "@atomicfinance/bitcoin-utils": 3.3.1 - "@atomicfinance/provider": ^3.3.1 - "@atomicfinance/types": ^3.3.1 - "@atomicfinance/utils": ^3.3.1 - "@node-dlc/core": 0.22.4 - "@node-dlc/messaging": 0.22.4 + "@atomicfinance/bitcoin-utils": 3.4.0 + "@atomicfinance/provider": ^3.4.0 + "@atomicfinance/types": ^3.4.0 + "@atomicfinance/utils": ^3.4.0 + "@node-dlc/core": 0.23.0 + "@node-dlc/messaging": 0.23.0 "@node-lightning/bitcoin": 0.26.1 "@node-lightning/bufio": 0.26.1 "@node-lightning/crypto": 0.26.1 @@ -53,16 +53,16 @@ __metadata: languageName: unknown linkType: soft -"@atomicfinance/bitcoin-esplora-api-provider@^3.3.1, @atomicfinance/bitcoin-esplora-api-provider@workspace:packages/bitcoin-esplora-api-provider": +"@atomicfinance/bitcoin-esplora-api-provider@^3.4.0, @atomicfinance/bitcoin-esplora-api-provider@workspace:packages/bitcoin-esplora-api-provider": version: 0.0.0-use.local resolution: "@atomicfinance/bitcoin-esplora-api-provider@workspace:packages/bitcoin-esplora-api-provider" dependencies: - "@atomicfinance/bitcoin-utils": ^3.3.1 - "@atomicfinance/crypto": ^3.3.1 - "@atomicfinance/errors": ^3.3.1 - "@atomicfinance/node-provider": ^3.3.1 - "@atomicfinance/types": ^3.3.1 - "@atomicfinance/utils": ^3.3.1 + "@atomicfinance/bitcoin-utils": ^3.4.0 + "@atomicfinance/crypto": ^3.4.0 + "@atomicfinance/errors": ^3.4.0 + "@atomicfinance/node-provider": ^3.4.0 + "@atomicfinance/types": ^3.4.0 + "@atomicfinance/utils": ^3.4.0 "@babel/runtime": ^7.12.1 "@types/lodash": ^4.14.168 bignumber.js: ^9.0.0 @@ -76,10 +76,10 @@ __metadata: version: 0.0.0-use.local resolution: "@atomicfinance/bitcoin-esplora-batch-api-provider@workspace:packages/bitcoin-esplora-batch-api-provider" dependencies: - "@atomicfinance/bitcoin-esplora-api-provider": ^3.3.1 - "@atomicfinance/node-provider": ^3.3.1 - "@atomicfinance/types": ^3.3.1 - "@atomicfinance/utils": ^3.3.1 + "@atomicfinance/bitcoin-esplora-api-provider": ^3.4.0 + "@atomicfinance/node-provider": ^3.4.0 + "@atomicfinance/types": ^3.4.0 + "@atomicfinance/utils": ^3.4.0 "@babel/runtime": ^7.12.1 "@types/lodash": ^4.14.168 bignumber.js: ^9.0.0 @@ -92,11 +92,12 @@ __metadata: version: 0.0.0-use.local resolution: "@atomicfinance/bitcoin-js-wallet-provider@workspace:packages/bitcoin-js-wallet-provider" dependencies: - "@atomicfinance/bitcoin-utils": ^3.3.1 - "@atomicfinance/bitcoin-wallet-provider": ^3.3.1 - "@atomicfinance/types": ^3.3.1 - "@atomicfinance/utils": ^3.3.1 + "@atomicfinance/bitcoin-utils": ^3.4.0 + "@atomicfinance/bitcoin-wallet-provider": ^3.4.0 + "@atomicfinance/types": ^3.4.0 + "@atomicfinance/utils": ^3.4.0 "@babel/runtime": ^7.12.1 + "@node-dlc/core": 0.23.0 bip32: ^2.0.6 bip39: ^3.0.2 bitcoin-networks: ^1.0.0 @@ -110,11 +111,11 @@ __metadata: version: 0.0.0-use.local resolution: "@atomicfinance/bitcoin-node-wallet-provider@workspace:packages/bitcoin-node-wallet-provider" dependencies: - "@atomicfinance/bitcoin-utils": ^3.3.1 - "@atomicfinance/crypto": ^3.3.1 - "@atomicfinance/jsonrpc-provider": ^3.3.1 - "@atomicfinance/types": ^3.3.1 - "@atomicfinance/utils": ^3.3.1 + "@atomicfinance/bitcoin-utils": ^3.4.0 + "@atomicfinance/crypto": ^3.4.0 + "@atomicfinance/jsonrpc-provider": ^3.4.0 + "@atomicfinance/types": ^3.4.0 + "@atomicfinance/utils": ^3.4.0 "@babel/runtime": ^7.12.1 "@types/lodash": ^4.14.168 bignumber.js: ^9.0.0 @@ -128,11 +129,11 @@ __metadata: version: 0.0.0-use.local resolution: "@atomicfinance/bitcoin-rpc-provider@workspace:packages/bitcoin-rpc-provider" dependencies: - "@atomicfinance/bitcoin-utils": ^3.3.1 - "@atomicfinance/errors": ^3.3.1 - "@atomicfinance/jsonrpc-provider": ^3.3.1 - "@atomicfinance/types": ^3.3.1 - "@atomicfinance/utils": ^3.3.1 + "@atomicfinance/bitcoin-utils": ^3.4.0 + "@atomicfinance/errors": ^3.4.0 + "@atomicfinance/jsonrpc-provider": ^3.4.0 + "@atomicfinance/types": ^3.4.0 + "@atomicfinance/utils": ^3.4.0 "@babel/runtime": ^7.12.1 "@types/lodash": ^4.14.168 bignumber.js: ^9.0.0 @@ -141,14 +142,14 @@ __metadata: languageName: unknown linkType: soft -"@atomicfinance/bitcoin-utils@3.3.1, @atomicfinance/bitcoin-utils@^3.3.1, @atomicfinance/bitcoin-utils@workspace:packages/bitcoin-utils": +"@atomicfinance/bitcoin-utils@3.4.0, @atomicfinance/bitcoin-utils@^3.4.0, @atomicfinance/bitcoin-utils@workspace:packages/bitcoin-utils": version: 0.0.0-use.local resolution: "@atomicfinance/bitcoin-utils@workspace:packages/bitcoin-utils" dependencies: - "@atomicfinance/crypto": ^3.3.1 - "@atomicfinance/errors": ^3.3.1 - "@atomicfinance/types": ^3.3.1 - "@atomicfinance/utils": ^3.3.1 + "@atomicfinance/crypto": ^3.4.0 + "@atomicfinance/errors": ^3.4.0 + "@atomicfinance/types": ^3.4.0 + "@atomicfinance/utils": ^3.4.0 "@babel/runtime": ^7.12.1 "@types/bitcoinjs-lib": ^5.0.0 "@types/lodash": ^4.14.168 @@ -162,13 +163,14 @@ __metadata: languageName: unknown linkType: soft -"@atomicfinance/bitcoin-wallet-provider@^3.3.1, @atomicfinance/bitcoin-wallet-provider@workspace:packages/bitcoin-wallet-provider": +"@atomicfinance/bitcoin-wallet-provider@^3.4.0, @atomicfinance/bitcoin-wallet-provider@workspace:packages/bitcoin-wallet-provider": version: 0.0.0-use.local resolution: "@atomicfinance/bitcoin-wallet-provider@workspace:packages/bitcoin-wallet-provider" dependencies: - "@atomicfinance/bitcoin-utils": ^3.3.1 - "@atomicfinance/provider": ^3.3.1 - "@atomicfinance/types": ^3.3.1 + "@atomicfinance/bitcoin-utils": ^3.4.0 + "@atomicfinance/provider": ^3.4.0 + "@atomicfinance/types": ^3.4.0 + "@node-dlc/core": 0.23.0 "@types/lodash": ^4.14.160 "@types/node": 16.10.3 bitcoin-networks: ^1.0.0 @@ -182,10 +184,11 @@ __metadata: version: 0.0.0-use.local resolution: "@atomicfinance/client@workspace:packages/client" dependencies: - "@atomicfinance/errors": ^3.3.1 - "@atomicfinance/provider": ^3.3.1 - "@atomicfinance/types": ^3.3.1 - "@node-dlc/messaging": 0.22.4 + "@atomicfinance/bitcoin-utils": ^3.4.0 + "@atomicfinance/errors": ^3.4.0 + "@atomicfinance/provider": ^3.4.0 + "@atomicfinance/types": ^3.4.0 + "@node-dlc/messaging": 0.23.0 "@node-lightning/bitcoin": 0.26.1 "@types/lodash": ^4.14.160 "@types/node": 16.10.3 @@ -194,7 +197,7 @@ __metadata: languageName: unknown linkType: soft -"@atomicfinance/crypto@^3.3.1, @atomicfinance/crypto@workspace:packages/crypto": +"@atomicfinance/crypto@^3.4.0, @atomicfinance/crypto@workspace:packages/crypto": version: 0.0.0-use.local resolution: "@atomicfinance/crypto@workspace:packages/crypto" dependencies: @@ -206,7 +209,7 @@ __metadata: languageName: unknown linkType: soft -"@atomicfinance/errors@^3.3.1, @atomicfinance/errors@workspace:packages/errors": +"@atomicfinance/errors@^3.4.0, @atomicfinance/errors@workspace:packages/errors": version: 0.0.0-use.local resolution: "@atomicfinance/errors@workspace:packages/errors" dependencies: @@ -215,12 +218,12 @@ __metadata: languageName: unknown linkType: soft -"@atomicfinance/jsonrpc-provider@^3.3.1, @atomicfinance/jsonrpc-provider@workspace:packages/jsonrpc-provider": +"@atomicfinance/jsonrpc-provider@^3.4.0, @atomicfinance/jsonrpc-provider@workspace:packages/jsonrpc-provider": version: 0.0.0-use.local resolution: "@atomicfinance/jsonrpc-provider@workspace:packages/jsonrpc-provider" dependencies: - "@atomicfinance/errors": ^3.3.1 - "@atomicfinance/node-provider": ^3.3.1 + "@atomicfinance/errors": ^3.4.0 + "@atomicfinance/node-provider": ^3.4.0 "@babel/runtime": ^7.12.1 "@types/json-bigint": ^1.0.0 "@types/lodash": ^4.14.168 @@ -229,12 +232,12 @@ __metadata: languageName: unknown linkType: soft -"@atomicfinance/node-provider@^3.3.1, @atomicfinance/node-provider@workspace:packages/node-provider": +"@atomicfinance/node-provider@^3.4.0, @atomicfinance/node-provider@workspace:packages/node-provider": version: 0.0.0-use.local resolution: "@atomicfinance/node-provider@workspace:packages/node-provider" dependencies: - "@atomicfinance/errors": ^3.3.1 - "@atomicfinance/provider": ^3.3.1 + "@atomicfinance/errors": ^3.4.0 + "@atomicfinance/provider": ^3.4.0 "@babel/runtime": ^7.12.1 "@types/lodash": ^4.14.168 axios: ^0.21.0 @@ -242,22 +245,22 @@ __metadata: languageName: unknown linkType: soft -"@atomicfinance/provider@^3.3.1, @atomicfinance/provider@workspace:packages/provider": +"@atomicfinance/provider@^3.4.0, @atomicfinance/provider@workspace:packages/provider": version: 0.0.0-use.local resolution: "@atomicfinance/provider@workspace:packages/provider" dependencies: - "@atomicfinance/types": ^3.3.1 + "@atomicfinance/types": ^3.4.0 "@types/lodash": ^4.14.160 "@types/node": 16.10.3 lodash: ^4.17.20 languageName: unknown linkType: soft -"@atomicfinance/types@^3.3.1, @atomicfinance/types@workspace:packages/types": +"@atomicfinance/types@^3.4.0, @atomicfinance/types@workspace:packages/types": version: 0.0.0-use.local resolution: "@atomicfinance/types@workspace:packages/types" dependencies: - "@node-dlc/messaging": 0.22.4 + "@node-dlc/messaging": 0.23.0 "@node-lightning/bitcoin": 0.26.1 "@node-lightning/noise": 0.26.1 "@types/lodash": ^4.14.160 @@ -266,13 +269,13 @@ __metadata: languageName: unknown linkType: soft -"@atomicfinance/utils@^3.3.1, @atomicfinance/utils@workspace:packages/utils": +"@atomicfinance/utils@^3.4.0, @atomicfinance/utils@workspace:packages/utils": version: 0.0.0-use.local resolution: "@atomicfinance/utils@workspace:packages/utils" dependencies: - "@atomicfinance/crypto": ^3.3.1 - "@atomicfinance/errors": ^3.3.1 - "@atomicfinance/types": ^3.3.1 + "@atomicfinance/crypto": ^3.4.0 + "@atomicfinance/errors": ^3.4.0 + "@atomicfinance/types": ^3.4.0 "@babel/runtime": ^7.12.1 bignumber.js: ^9.0.0 bip174: ^2.0.1 @@ -1708,30 +1711,32 @@ __metadata: languageName: node linkType: hard -"@node-dlc/bitcoin@npm:^0.22.4": - version: 0.22.4 - resolution: "@node-dlc/bitcoin@npm:0.22.4" - checksum: e6b9a27d45d34fa8fc99b8bc986e08113f3e8787ca2cb9d4b1c085d58ca64a46f317e8ae5d120f86ab3de65290e0980a9d3c0d42f070509567e5685878fe1f55 +"@node-dlc/bitcoin@npm:0.23.0, @node-dlc/bitcoin@npm:^0.23.0": + version: 0.23.0 + resolution: "@node-dlc/bitcoin@npm:0.23.0" + checksum: d02574689870f33dedaeaf262da449ce01f8b136d0077e110d3149fe48cee4615871527e09cdf48723764313fb017c223b22f99c2c2b2dbb3d59ae3cbfa0fad8 languageName: node linkType: hard -"@node-dlc/core@npm:0.22.4": - version: 0.22.4 - resolution: "@node-dlc/core@npm:0.22.4" +"@node-dlc/core@npm:0.23.0": + version: 0.23.0 + resolution: "@node-dlc/core@npm:0.23.0" dependencies: - "@node-dlc/bitcoin": ^0.22.4 - "@node-dlc/messaging": ^0.22.4 + "@node-dlc/bitcoin": ^0.23.0 + "@node-dlc/messaging": ^0.23.0 "@node-lightning/core": 0.26.1 bignumber.js: ^9.0.1 bitcoin-networks: ^1.0.0 - checksum: 7ae45b57d3fdcc9c759d6cda0d037cfae1483512ae74e86f2388f89ddf352d0c23634b4744e726a35fdff7c1900bf95936a4c1b55fac3b257746a9025b0b11c3 + decimal.js: 10.4.3 + checksum: 6ef03625c43db7fea523d2bf7e0660b6cdb580af15e029850653424e1697a54b16a5e06b26247a5cc647a3a6723a2704ed0e2ef4e93f466b33e7204e347234ea languageName: node linkType: hard -"@node-dlc/messaging@npm:0.22.4, @node-dlc/messaging@npm:^0.22.4": - version: 0.22.4 - resolution: "@node-dlc/messaging@npm:0.22.4" +"@node-dlc/messaging@npm:0.23.0, @node-dlc/messaging@npm:^0.23.0": + version: 0.23.0 + resolution: "@node-dlc/messaging@npm:0.23.0" dependencies: + "@node-dlc/bitcoin": ^0.23.0 "@node-lightning/bitcoin": 0.26.1 "@node-lightning/bufio": 0.26.1 "@node-lightning/checksum": 0.26.1 @@ -1739,7 +1744,7 @@ __metadata: bip-schnorr: 0.6.3 bitcoin-networks: ^1.0.0 bitcoinjs-lib: 5.2.0 - checksum: bd1bbd83682242fca385dfc8f02ac3e123cc5c4278cac09005d9ca2afca709f2400076e8ff1ea28849913f7d37fac4369ef035b573a6b0ddd5ef5dacaaa70e2a + checksum: 68665b62029de291407705a1137db347df6e97cacf4f3610baad64dc53e0ea3ade9989dac6819c4ab49495655d80f3e24e462a2c4bf1c9bdd19cfdc510ffad4a languageName: node linkType: hard @@ -5287,6 +5292,13 @@ __metadata: languageName: node linkType: hard +"decimal.js@npm:10.4.3": + version: 10.4.3 + resolution: "decimal.js@npm:10.4.3" + checksum: 796404dcfa9d1dbfdc48870229d57f788b48c21c603c3f6554a1c17c10195fc1024de338b0cf9e1efe0c7c167eeb18f04548979bcc5fdfabebb7cc0ae3287bae + languageName: node + linkType: hard + "decode-uri-component@npm:^0.2.0": version: 0.2.0 resolution: "decode-uri-component@npm:0.2.0" @@ -12133,8 +12145,9 @@ __metadata: resolution: "root@workspace:." dependencies: "@changesets/cli": ^2.22.0 - "@node-dlc/core": 0.22.4 - "@node-dlc/messaging": 0.22.4 + "@node-dlc/bitcoin": 0.23.0 + "@node-dlc/core": 0.23.0 + "@node-dlc/messaging": 0.23.0 "@swc/cli": ^0.1.57 "@swc/core": ^1.2.172 "@swc/register": ^0.1.10