Fix for nonce = 0

This commit is contained in:
Vlad Dobromyslov 2022-08-29 13:52:37 +03:00
parent ab7bb9e633
commit fbe263e2cb

View file

@ -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 ethereum_rpc_client::get_nonce(const std::string &address) {
std::string reply_str = eth_get_transaction_count("[\"" + address + "\", \"latest\"]"); std::string reply_str = eth_get_transaction_count("[\"" + address + "\", \"latest\"]");
return retrieve_value_from_reply(reply_str, ""); const auto nonce_val = ethereum::from_hex<boost::multiprecision::uint256_t>(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() { 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 #ifdef SEND_RAW_TRANSACTION
ethereum::raw_transaction raw_tr; ethereum::raw_transaction raw_tr;
raw_tr.nonce = ethereum::add_0x(ethereum::to_hex(ethereum::from_hex<boost::multiprecision::uint256_t>(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_price = rpc_client->get_gas_price();
raw_tr.gas_limit = rpc_client->get_gas_limit(); raw_tr.gas_limit = rpc_client->get_gas_limit();
raw_tr.to = wallet_contract_address; raw_tr.to = wallet_contract_address;