diff --git a/bin/lamassu-eth-sweep-to-new-wallet b/bin/lamassu-eth-sweep-to-new-wallet index 8cb2ec6b..57fb4f0b 100644 --- a/bin/lamassu-eth-sweep-to-new-wallet +++ b/bin/lamassu-eth-sweep-to-new-wallet @@ -263,7 +263,7 @@ settingsLoader.loadLatest() } const opts = { - chainId: 3, + chainId: 1, nonce: 0, includesFee: true } diff --git a/lib/plugins/wallet/geth/base.js b/lib/plugins/wallet/geth/base.js index 056f8cf4..c3d82f1b 100644 --- a/lib/plugins/wallet/geth/base.js +++ b/lib/plugins/wallet/geth/base.js @@ -210,18 +210,20 @@ function generateTx (_toAddress, wallet, amount, includesFee, cryptoCode) { .then(([gas, gasPrice, txCount, baseFeePerGas]) => { lastUsedNonces[fromAddress] = txCount - const toSend = includesFee - ? amount.minus(gasPrice.times(gas)) - : amount - const maxPriorityFeePerGas = new BN(web3.utils.toWei('2.5', 'gwei')) // web3 default value - const maxFeePerGas = new BN(2).times(baseFeePerGas).plus(maxPriorityFeePerGas) + const neededPriority = new BN(web3.utils.toWei('2.0', 'gwei')) + const maxFeePerGas = baseFeePerGas.plus(neededPriority) + const newGasPrice = BN.minimum(maxFeePerGas, baseFeePerGas.plus(maxPriorityFeePerGas)) + + const toSend = includesFee + ? new BN(amount).minus(newGasPrice.times(gas)) + : amount const rawTx = { chainId: 1, nonce: txCount, - maxPriorityFeePerGas: web3.utils.toHex(web3.utils.toWei(maxPriorityFeePerGas.toString(), 'gwei')), - maxFeePerGas: web3.utils.toHex(web3.utils.toWei(maxFeePerGas.toString(), 'gwei')), + maxPriorityFeePerGas: web3.utils.toHex(maxPriorityFeePerGas), + maxFeePerGas: web3.utils.toHex(maxFeePerGas), gasLimit: hex(gas), to: toAddress, from: fromAddress,