Changing code to not deal with nonces

This commit is contained in:
Richard Ramos 2018-10-10 20:17:32 -04:00
parent db48083dfb
commit 23f8ebc0bb
2 changed files with 6 additions and 9 deletions

View File

@ -103,8 +103,6 @@ class MessageProcessor {
const gasPrice = toBN(await this.web3.eth.getGasPrice()).add(toBN(this.config.gasPrice.modifier)).toString(); const gasPrice = toBN(await this.web3.eth.getGasPrice()).add(toBN(this.config.gasPrice.modifier)).toString();
const nonce = await this.web3.eth.getTransactionCount(this.config.node.blockchain.account.address);
if(!validationResult.estimatedGas){ if(!validationResult.estimatedGas){
validationResult.estimatedGas = await this.web3.eth.estimateGas(p); validationResult.estimatedGas = await this.web3.eth.estimateGas(p);
} }
@ -116,12 +114,10 @@ class MessageProcessor {
to: input.contract, to: input.contract,
value: "0x00", value: "0x00",
data: input.payload, data: input.payload,
nonce: toHex(nonce), gasPrice: parseInt(gasPrice, 10),
gasPrice: toHex(parseInt(gasPrice, 10)), gas: estimatedGas + 1000 // Tune this,
gasLimit: toHex(estimatedGas) // Tune this,
}; };
const nodeBalance = await this.web3.eth.getBalance(this.config.node.blockchain.account.address); const nodeBalance = await this.web3.eth.getBalance(this.config.node.blockchain.account.address);
if(nodeBalance < p.gas){ if(nodeBalance < p.gas){
@ -130,9 +126,7 @@ class MessageProcessor {
this.events.emit('exit'); this.events.emit('exit');
} else { } else {
try { try {
const signedTrx = await account.signTransaction(p); this.web3.eth.sendTransaction(p)
this.web3.eth.sendSignedTransaction(signedTrx.rawTransaction)
.on('transactionHash', function(hash){ .on('transactionHash', function(hash){
reply("Transaction broadcasted: " + hash); reply("Transaction broadcasted: " + hash);
cb(); cb();

View File

@ -45,6 +45,9 @@ events.on('web3:connected', connURL => {
account = accountParser.get(config.node.blockchain, web3); account = accountParser.get(config.node.blockchain, web3);
web3.eth.accounts.wallet.add(account);
if(!account) { if(!account) {
process.exit(1); process.exit(1);
} else { } else {