Geth/infura nonce fix (#295)

* Geth/infura nonce fix

* Fix nonce logic
This commit is contained in:
Rafael Taranto 2019-07-17 12:32:53 +01:00 committed by Josh Harvey
parent 9f8693a33e
commit 919848aecd

View file

@ -13,6 +13,7 @@ exports.SUPPORTED_MODULES = ['wallet']
const paymentPrefixPath = "m/44'/60'/0'/0'"
const defaultPrefixPath = "m/44'/60'/1'/0'"
let lastUsedNonces = {}
module.exports = {
NAME,
@ -99,7 +100,11 @@ function generateTx (_toAddress, wallet, amount, includesFee) {
.then(arr => {
const gas = arr[0]
const gasPrice = arr[1]
const txCount = arr[2]
const txCount = arr[2] <= lastUsedNonces[fromAddress]
? lastUsedNonces[fromAddress] + 1
: arr[2]
lastUsedNonces[fromAddress] = txCount
const toSend = includesFee
? amount.minus(gasPrice.times(gas))