From fbe263e2cb294816773d7a4fa155e0484e80c2b1 Mon Sep 17 00:00:00 2001 From: Vlad Dobromyslov Date: Mon, 29 Aug 2022 13:52:37 +0300 Subject: [PATCH] Fix for nonce = 0 --- .../peerplays_sidechain/sidechain_net_handler_ethereum.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_ethereum.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_ethereum.cpp index 163f2599..8ceb582b 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_ethereum.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_ethereum.cpp @@ -67,7 +67,8 @@ std::string ethereum_rpc_client::get_network_id() { std::string ethereum_rpc_client::get_nonce(const std::string &address) { std::string reply_str = eth_get_transaction_count("[\"" + address + "\", \"latest\"]"); - return retrieve_value_from_reply(reply_str, ""); + const auto nonce_val = ethereum::from_hex(retrieve_value_from_reply(reply_str, "")); + return nonce_val == 0 ? ethereum::add_0x("0") : ethereum::add_0x(ethereum::to_hex(nonce_val)); } std::string ethereum_rpc_client::get_gas_price() { @@ -639,7 +640,7 @@ std::string sidechain_net_handler_ethereum::sign_transaction(const sidechain_tra #ifdef SEND_RAW_TRANSACTION ethereum::raw_transaction raw_tr; - raw_tr.nonce = ethereum::add_0x(ethereum::to_hex(ethereum::from_hex(rpc_client->get_nonce(ethereum::add_0x(public_key))))); + raw_tr.nonce = rpc_client->get_nonce(ethereum::add_0x(public_key)); raw_tr.gas_price = rpc_client->get_gas_price(); raw_tr.gas_limit = rpc_client->get_gas_limit(); raw_tr.to = wallet_contract_address;