Cherrypick important fixes/cosmetics from feature/son-for-ethereum
This commit is contained in:
parent
9c5aab826d
commit
b895b52b7b
10 changed files with 138 additions and 94 deletions
|
|
@ -917,8 +917,8 @@ void application::initialize(const fc::path &data_dir, const boost::program_opti
|
|||
wanted.insert("accounts_list");
|
||||
wanted.insert("affiliate_stats");
|
||||
}
|
||||
if (!wanted.count("delayed_node") && !wanted.count("witness")) // explicitly requested delayed_node functionality suppresses witness functions
|
||||
wanted.insert("witness");
|
||||
if (!wanted.count("delayed_node") && !wanted.count("witness")) // explicitly requested delayed_node functionality suppresses witness functions
|
||||
wanted.insert("witness");
|
||||
wanted.insert("bookie");
|
||||
|
||||
int es_ah_conflict_counter = 0;
|
||||
|
|
|
|||
|
|
@ -2,23 +2,20 @@
|
|||
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/xpressive/xpressive.hpp>
|
||||
|
||||
#include <boost/asio/buffers_iterator.hpp>
|
||||
#include <boost/asio/connect.hpp>
|
||||
#include <boost/asio/ssl/error.hpp>
|
||||
#include <boost/asio/ssl/stream.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/xpressive/xpressive.hpp>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include <fc/crypto/base64.hpp>
|
||||
#include <fc/log/logger.hpp>
|
||||
|
||||
#include <graphene/peerplays_sidechain/common/utils.hpp>
|
||||
|
||||
namespace graphene { namespace peerplays_sidechain {
|
||||
|
||||
rpc_client::rpc_client(std::string _url, std::string _user, std::string _password, bool _debug_rpc_calls) :
|
||||
|
|
@ -55,7 +52,8 @@ rpc_client::rpc_client(std::string _url, std::string _user, std::string _passwor
|
|||
target = "/";
|
||||
}
|
||||
|
||||
authorization = "Basic " + fc::base64_encode(user + ":" + password);
|
||||
authorization = "Basic " + base64_encode(user + ":" + password);
|
||||
|
||||
results = resolver.resolve(host, port);
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,50 @@
|
|||
#include <graphene/peerplays_sidechain/common/utils.hpp>
|
||||
|
||||
#include <boost/archive/iterators/base64_from_binary.hpp>
|
||||
#include <boost/archive/iterators/binary_from_base64.hpp>
|
||||
#include <boost/archive/iterators/transform_width.hpp>
|
||||
|
||||
namespace graphene { namespace peerplays_sidechain {
|
||||
|
||||
const std::string base64_padding[] = {"", "==", "="};
|
||||
|
||||
std::string base64_encode(const std::string &s) {
|
||||
using namespace boost::archive::iterators;
|
||||
|
||||
typedef base64_from_binary<transform_width<const char *, 6, 8>> base64_enc;
|
||||
|
||||
std::stringstream os;
|
||||
std::copy(base64_enc(s.c_str()), base64_enc(s.c_str() + s.size()), std::ostream_iterator<char>(os));
|
||||
os << base64_padding[s.size() % 3];
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string base64_decode(const std::string &s) {
|
||||
using namespace boost::archive::iterators;
|
||||
|
||||
typedef transform_width<binary_from_base64<const char *>, 8, 6> base64_dec;
|
||||
|
||||
std::stringstream os;
|
||||
unsigned int size = s.size();
|
||||
if (size && s[size - 1] == '=') {
|
||||
--size;
|
||||
if (size && s[size - 1] == '=')
|
||||
--size;
|
||||
}
|
||||
if (size == 0)
|
||||
return std::string();
|
||||
|
||||
std::copy(base64_dec(s.data()), base64_dec(s.data() + size), std::ostream_iterator<char>(os));
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string object_id_to_string(graphene::chain::object_id_type id) {
|
||||
std::string object_id = fc::to_string(id.space()) + "." +
|
||||
fc::to_string(id.type()) + "." +
|
||||
fc::to_string(id.instance());
|
||||
return object_id;
|
||||
}
|
||||
|
||||
}} // namespace graphene::peerplays_sidechain
|
||||
|
|
|
|||
|
|
@ -23,15 +23,16 @@ protected:
|
|||
std::string send_post_request(std::string method, std::string params, bool show_log);
|
||||
|
||||
std::string url;
|
||||
std::string user;
|
||||
std::string password;
|
||||
bool debug_rpc_calls;
|
||||
|
||||
std::string protocol;
|
||||
std::string host;
|
||||
std::string port;
|
||||
std::string target;
|
||||
std::string authorization;
|
||||
|
||||
std::string user;
|
||||
std::string password;
|
||||
bool debug_rpc_calls;
|
||||
uint32_t request_id;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -2,4 +2,11 @@
|
|||
|
||||
#include <graphene/chain/protocol/asset.hpp>
|
||||
|
||||
namespace graphene { namespace peerplays_sidechain {
|
||||
|
||||
std::string base64_encode(const std::string &s);
|
||||
std::string base64_decode(const std::string &s);
|
||||
|
||||
std::string object_id_to_string(graphene::chain::object_id_type id);
|
||||
|
||||
}} // namespace graphene::peerplays_sidechain
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ private:
|
|||
uint32_t rpc_port;
|
||||
std::string user;
|
||||
std::string password;
|
||||
std::string wallet;
|
||||
std::string wallet_name;
|
||||
std::string wallet_password;
|
||||
};
|
||||
|
||||
|
|
@ -111,17 +111,18 @@ private:
|
|||
std::string ip;
|
||||
uint32_t zmq_port;
|
||||
uint32_t rpc_port;
|
||||
uint32_t bitcoin_major_version;
|
||||
std::string rpc_user;
|
||||
std::string rpc_password;
|
||||
std::string wallet;
|
||||
std::string wallet_name;
|
||||
std::string wallet_password;
|
||||
|
||||
std::unique_ptr<bitcoin_rpc_client> bitcoin_client;
|
||||
std::unique_ptr<zmq_listener> listener;
|
||||
|
||||
fc::future<void> on_changed_objects_task;
|
||||
|
||||
bitcoin::bitcoin_address::network network_type;
|
||||
uint32_t bitcoin_major_version;
|
||||
|
||||
std::mutex event_handler_mutex;
|
||||
typedef std::lock_guard<decltype(event_handler_mutex)> scoped_lock;
|
||||
|
|
|
|||
|
|
@ -6,15 +6,14 @@
|
|||
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
#include <fc/network/http/connection.hpp>
|
||||
#include <graphene/peerplays_sidechain/common/rpc_client.hpp>
|
||||
#include <graphene/peerplays_sidechain/hive/types.hpp>
|
||||
|
||||
namespace graphene { namespace peerplays_sidechain {
|
||||
|
||||
class hive_node_rpc_client : public rpc_client {
|
||||
class hive_rpc_client : public rpc_client {
|
||||
public:
|
||||
hive_node_rpc_client(const std::string &url, const std::string &user_name, const std::string &password, bool debug_rpc_calls);
|
||||
hive_rpc_client(const std::string &url, const std::string &user_name, const std::string &password, bool debug_rpc_calls);
|
||||
|
||||
std::string account_history_api_get_transaction(std::string transaction_id);
|
||||
std::string block_api_get_block(uint32_t block_number);
|
||||
|
|
@ -48,10 +47,12 @@ public:
|
|||
bool settle_sidechain_transaction(const sidechain_transaction_object &sto, asset &settle_amount);
|
||||
|
||||
private:
|
||||
std::string node_rpc_url;
|
||||
std::string node_rpc_user;
|
||||
std::string node_rpc_password;
|
||||
hive_node_rpc_client *node_rpc_client;
|
||||
std::string rpc_url;
|
||||
std::string rpc_user;
|
||||
std::string rpc_password;
|
||||
std::string wallet_account_name;
|
||||
|
||||
hive_rpc_client *rpc_client;
|
||||
|
||||
hive::chain_id_type chain_id;
|
||||
hive::network network_type;
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ void peerplays_sidechain_plugin_impl::plugin_set_program_options(
|
|||
cli.add_options()("bitcoin-node-rpc-port", bpo::value<uint32_t>()->default_value(8332), "RPC port of Bitcoin node");
|
||||
cli.add_options()("bitcoin-node-rpc-user", bpo::value<string>()->default_value("1"), "Bitcoin RPC user");
|
||||
cli.add_options()("bitcoin-node-rpc-password", bpo::value<string>()->default_value("1"), "Bitcoin RPC password");
|
||||
cli.add_options()("bitcoin-wallet", bpo::value<string>(), "Bitcoin wallet");
|
||||
cli.add_options()("bitcoin-wallet-name", bpo::value<string>(), "Bitcoin wallet name");
|
||||
cli.add_options()("bitcoin-wallet-password", bpo::value<string>(), "Bitcoin wallet password");
|
||||
cli.add_options()("bitcoin-private-key", bpo::value<vector<string>>()->composing()->multitoken()->DEFAULT_VALUE_VECTOR(std::make_pair("02d0f137e717fb3aab7aff99904001d49a0a636c5e1342f8927a4ba2eaee8e9772", "cVN31uC9sTEr392DLVUEjrtMgLA8Yb3fpYmTRj7bomTm6nn2ANPr")),
|
||||
"Tuple of [Bitcoin public key, Bitcoin private key] (may specify multiple times)");
|
||||
|
|
@ -181,6 +181,7 @@ void peerplays_sidechain_plugin_impl::plugin_set_program_options(
|
|||
cli.add_options()("hive-node-rpc-url", bpo::value<string>()->default_value("127.0.0.1:28090"), "Hive node RPC URL [http[s]://]host[:port]");
|
||||
cli.add_options()("hive-node-rpc-user", bpo::value<string>(), "Hive node RPC user");
|
||||
cli.add_options()("hive-node-rpc-password", bpo::value<string>(), "Hive node RPC password");
|
||||
cli.add_options()("hive-wallet-account-name", bpo::value<string>(), "Hive wallet account name");
|
||||
cli.add_options()("hive-private-key", bpo::value<vector<string>>()->composing()->multitoken()->DEFAULT_VALUE_VECTOR(std::make_pair("TST6LLegbAgLAy28EHrffBVuANFWcFgmqRMW13wBmTExqFE9SCkg4", "5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n")),
|
||||
"Tuple of [Hive public key, Hive private key] (may specify multiple times)");
|
||||
|
||||
|
|
@ -231,9 +232,9 @@ void peerplays_sidechain_plugin_impl::plugin_initialize(const boost::program_opt
|
|||
config_ready_bitcoin = options.count("bitcoin-node-ip") &&
|
||||
options.count("bitcoin-node-zmq-port") && options.count("bitcoin-node-rpc-port") &&
|
||||
options.count("bitcoin-node-rpc-user") && options.count("bitcoin-node-rpc-password") &&
|
||||
/*options.count("bitcoin-wallet") && options.count("bitcoin-wallet-password") &&*/
|
||||
options.count("bitcoin-wallet-name") && options.count("bitcoin-wallet-password") &&
|
||||
options.count("bitcoin-private-key");
|
||||
if (!config_ready_bitcoin) {
|
||||
if (sidechain_enabled_bitcoin && !config_ready_bitcoin) {
|
||||
wlog("Haven't set up Bitcoin sidechain parameters");
|
||||
}
|
||||
|
||||
|
|
@ -248,28 +249,21 @@ void peerplays_sidechain_plugin_impl::plugin_initialize(const boost::program_opt
|
|||
sidechain_enabled_hive = options.at("hive-sidechain-enabled").as<bool>();
|
||||
config_ready_hive = options.count("hive-node-rpc-url") &&
|
||||
/*options.count("hive-node-rpc-user") && options.count("hive-node-rpc-password") &&*/
|
||||
options.count("hive-wallet-account-name") &&
|
||||
options.count("hive-private-key");
|
||||
if (!config_ready_hive) {
|
||||
if (sidechain_enabled_hive && !config_ready_hive) {
|
||||
wlog("Haven't set up Hive sidechain parameters");
|
||||
}
|
||||
|
||||
#ifdef ENABLE_PEERPLAYS_ASSET_DEPOSITS
|
||||
sidechain_enabled_peerplays = true; //options.at("peerplays-sidechain-enabled").as<bool>();
|
||||
sidechain_enabled_peerplays = true;
|
||||
#else
|
||||
sidechain_enabled_peerplays = false;
|
||||
#endif
|
||||
config_ready_peerplays = true;
|
||||
if (!config_ready_peerplays) {
|
||||
if (sidechain_enabled_peerplays && !config_ready_peerplays) {
|
||||
wlog("Haven't set up Peerplays sidechain parameters");
|
||||
}
|
||||
|
||||
if (!(config_ready_bitcoin &&
|
||||
/*config_ready_ethereum &&*/
|
||||
config_ready_hive &&
|
||||
config_ready_peerplays)) {
|
||||
wlog("Haven't set up any sidechain parameters");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void peerplays_sidechain_plugin_impl::plugin_startup() {
|
||||
|
|
|
|||
|
|
@ -334,9 +334,9 @@ sidechain_net_handler_bitcoin::sidechain_net_handler_bitcoin(peerplays_sidechain
|
|||
rpc_port = options.at("bitcoin-node-rpc-port").as<uint32_t>();
|
||||
rpc_user = options.at("bitcoin-node-rpc-user").as<std::string>();
|
||||
rpc_password = options.at("bitcoin-node-rpc-password").as<std::string>();
|
||||
wallet = "";
|
||||
if (options.count("bitcoin-wallet")) {
|
||||
wallet = options.at("bitcoin-wallet").as<std::string>();
|
||||
wallet_name = "";
|
||||
if (options.count("bitcoin-wallet-name")) {
|
||||
wallet_name = options.at("bitcoin-wallet-name").as<std::string>();
|
||||
}
|
||||
wallet_password = "";
|
||||
if (options.count("bitcoin-wallet-password")) {
|
||||
|
|
@ -356,13 +356,13 @@ sidechain_net_handler_bitcoin::sidechain_net_handler_bitcoin(peerplays_sidechain
|
|||
}
|
||||
|
||||
std::string url = ip + ":" + std::to_string(rpc_port);
|
||||
if (wallet.length() > 0) {
|
||||
url = url + "/wallet/" + wallet;
|
||||
if (!wallet_name.empty()) {
|
||||
url = url + "/wallet/" + wallet_name;
|
||||
}
|
||||
|
||||
bitcoin_client = std::unique_ptr<bitcoin_rpc_client>(new bitcoin_rpc_client(url, rpc_user, rpc_password, debug_rpc_calls));
|
||||
if (!wallet.empty()) {
|
||||
bitcoin_client->loadwallet(wallet);
|
||||
if (!wallet_name.empty()) {
|
||||
bitcoin_client->loadwallet(wallet_name);
|
||||
}
|
||||
|
||||
std::string blockchain_info = bitcoin_client->getblockchaininfo();
|
||||
|
|
|
|||
|
|
@ -28,25 +28,23 @@
|
|||
#include <graphene/peerplays_sidechain/hive/transaction.hpp>
|
||||
#include <graphene/utilities/key_conversion.hpp>
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
namespace graphene { namespace peerplays_sidechain {
|
||||
|
||||
hive_node_rpc_client::hive_node_rpc_client(const std::string &url, const std::string &user_name, const std::string &password, bool debug_rpc_calls) :
|
||||
hive_rpc_client::hive_rpc_client(const std::string &url, const std::string &user_name, const std::string &password, bool debug_rpc_calls) :
|
||||
rpc_client(url, user_name, password, debug_rpc_calls) {
|
||||
}
|
||||
|
||||
std::string hive_node_rpc_client::account_history_api_get_transaction(std::string transaction_id) {
|
||||
std::string hive_rpc_client::account_history_api_get_transaction(std::string transaction_id) {
|
||||
std::string params = "{ \"id\": \"" + transaction_id + "\" }";
|
||||
return send_post_request("account_history_api.get_transaction", params, debug_rpc_calls);
|
||||
}
|
||||
|
||||
std::string hive_node_rpc_client::block_api_get_block(uint32_t block_number) {
|
||||
std::string hive_rpc_client::block_api_get_block(uint32_t block_number) {
|
||||
std::string params = "{ \"block_num\": " + std::to_string(block_number) + " }";
|
||||
return send_post_request("block_api.get_block", params, debug_rpc_calls);
|
||||
}
|
||||
|
||||
std::string hive_node_rpc_client::condenser_api_get_accounts(std::vector<std::string> accounts) {
|
||||
std::string hive_rpc_client::condenser_api_get_accounts(std::vector<std::string> accounts) {
|
||||
std::string params = "";
|
||||
for (auto account : accounts) {
|
||||
if (!params.empty()) {
|
||||
|
|
@ -58,58 +56,58 @@ std::string hive_node_rpc_client::condenser_api_get_accounts(std::vector<std::st
|
|||
return send_post_request("condenser_api.get_accounts", params, debug_rpc_calls);
|
||||
}
|
||||
|
||||
std::string hive_node_rpc_client::condenser_api_get_config() {
|
||||
std::string hive_rpc_client::condenser_api_get_config() {
|
||||
std::string params = "[]";
|
||||
return send_post_request("condenser_api.get_config", params, debug_rpc_calls);
|
||||
}
|
||||
|
||||
std::string hive_node_rpc_client::database_api_get_dynamic_global_properties() {
|
||||
std::string hive_rpc_client::database_api_get_dynamic_global_properties() {
|
||||
return send_post_request("database_api.get_dynamic_global_properties", "", debug_rpc_calls);
|
||||
}
|
||||
|
||||
std::string hive_node_rpc_client::database_api_get_version() {
|
||||
std::string hive_rpc_client::database_api_get_version() {
|
||||
return send_post_request("database_api.get_version", "", debug_rpc_calls);
|
||||
}
|
||||
|
||||
std::string hive_node_rpc_client::network_broadcast_api_broadcast_transaction(std::string htrx) {
|
||||
std::string hive_rpc_client::network_broadcast_api_broadcast_transaction(std::string htrx) {
|
||||
std::string params = "{ \"trx\": " + htrx + ", \"max_block_age\": -1 }";
|
||||
return send_post_request("network_broadcast_api.broadcast_transaction", params, debug_rpc_calls);
|
||||
}
|
||||
|
||||
std::string hive_node_rpc_client::get_account(std::string account) {
|
||||
std::string hive_rpc_client::get_account(std::string account) {
|
||||
std::vector<std::string> accounts;
|
||||
accounts.push_back(account);
|
||||
std::string reply_str = condenser_api_get_accounts(accounts);
|
||||
return retrieve_array_value_from_reply(reply_str, "", 0);
|
||||
}
|
||||
|
||||
std::string hive_node_rpc_client::get_account_memo_key(std::string account) {
|
||||
std::string hive_rpc_client::get_account_memo_key(std::string account) {
|
||||
std::string reply_str = get_account(account);
|
||||
reply_str = "{\"result\":" + reply_str + "}";
|
||||
return retrieve_value_from_reply(reply_str, "memo_key");
|
||||
}
|
||||
|
||||
std::string hive_node_rpc_client::get_chain_id() {
|
||||
std::string hive_rpc_client::get_chain_id() {
|
||||
std::string reply_str = database_api_get_version();
|
||||
return retrieve_value_from_reply(reply_str, "chain_id");
|
||||
}
|
||||
|
||||
std::string hive_node_rpc_client::get_head_block_id() {
|
||||
std::string hive_rpc_client::get_head_block_id() {
|
||||
std::string reply_str = database_api_get_dynamic_global_properties();
|
||||
return retrieve_value_from_reply(reply_str, "head_block_id");
|
||||
}
|
||||
|
||||
std::string hive_node_rpc_client::get_head_block_time() {
|
||||
std::string hive_rpc_client::get_head_block_time() {
|
||||
std::string reply_str = database_api_get_dynamic_global_properties();
|
||||
return retrieve_value_from_reply(reply_str, "time");
|
||||
}
|
||||
|
||||
std::string hive_node_rpc_client::get_is_test_net() {
|
||||
std::string hive_rpc_client::get_is_test_net() {
|
||||
std::string reply_str = condenser_api_get_config();
|
||||
return retrieve_value_from_reply(reply_str, "IS_TEST_NET");
|
||||
}
|
||||
|
||||
std::string hive_node_rpc_client::get_last_irreversible_block_num() {
|
||||
std::string hive_rpc_client::get_last_irreversible_block_num() {
|
||||
std::string reply_str = database_api_get_dynamic_global_properties();
|
||||
return retrieve_value_from_reply(reply_str, "last_irreversible_block_num");
|
||||
}
|
||||
|
|
@ -122,18 +120,20 @@ sidechain_net_handler_hive::sidechain_net_handler_hive(peerplays_sidechain_plugi
|
|||
debug_rpc_calls = options.at("debug-rpc-calls").as<bool>();
|
||||
}
|
||||
|
||||
node_rpc_url = options.at("hive-node-rpc-url").as<std::string>();
|
||||
if (options.count("hive-node-rpc-user")) {
|
||||
node_rpc_user = options.at("hive-node-rpc-user").as<std::string>();
|
||||
rpc_url = options.at("hive-node-rpc-url").as<std::string>();
|
||||
if (options.count("hive-rpc-user")) {
|
||||
rpc_user = options.at("hive-rpc-user").as<std::string>();
|
||||
} else {
|
||||
node_rpc_user = "";
|
||||
rpc_user = "";
|
||||
}
|
||||
if (options.count("hive-node-rpc-password")) {
|
||||
node_rpc_password = options.at("hive-node-rpc-password").as<std::string>();
|
||||
if (options.count("hive-rpc-password")) {
|
||||
rpc_password = options.at("hive-rpc-password").as<std::string>();
|
||||
} else {
|
||||
node_rpc_password = "";
|
||||
rpc_password = "";
|
||||
}
|
||||
|
||||
wallet_account_name = options.at("hive-wallet-account-name").as<std::string>();
|
||||
|
||||
if (options.count("hive-private-key")) {
|
||||
const std::vector<std::string> pub_priv_keys = options["hive-private-key"].as<std::vector<std::string>>();
|
||||
for (const std::string &itr_key_pair : pub_priv_keys) {
|
||||
|
|
@ -146,16 +146,16 @@ sidechain_net_handler_hive::sidechain_net_handler_hive(peerplays_sidechain_plugi
|
|||
}
|
||||
}
|
||||
|
||||
node_rpc_client = new hive_node_rpc_client(node_rpc_url, node_rpc_user, node_rpc_password, debug_rpc_calls);
|
||||
rpc_client = new hive_rpc_client(rpc_url, rpc_user, rpc_password, debug_rpc_calls);
|
||||
|
||||
std::string chain_id_str = node_rpc_client->get_chain_id();
|
||||
std::string chain_id_str = rpc_client->get_chain_id();
|
||||
if (chain_id_str.empty()) {
|
||||
elog("No Hive node running at ${url}", ("url", node_rpc_url));
|
||||
elog("No Hive node running at ${url}", ("url", rpc_url));
|
||||
FC_ASSERT(false);
|
||||
}
|
||||
chain_id = chain_id_type(chain_id_str);
|
||||
|
||||
std::string is_test_net = node_rpc_client->get_is_test_net();
|
||||
std::string is_test_net = rpc_client->get_is_test_net();
|
||||
network_type = is_test_net.compare("true") == 0 ? hive::network::testnet : hive::network::mainnet;
|
||||
if (network_type == hive::network::mainnet) {
|
||||
ilog("Running on Hive mainnet, chain id ${chain_id_str}", ("chain_id_str", chain_id_str));
|
||||
|
|
@ -225,7 +225,7 @@ bool sidechain_net_handler_hive::process_proposal(const proposal_object &po) {
|
|||
}
|
||||
|
||||
if (son_sets_equal) {
|
||||
address_ok = (op_obj_idx_0.get<son_wallet_update_operation>().address == "son-account");
|
||||
address_ok = (op_obj_idx_0.get<son_wallet_update_operation>().address == wallet_account_name);
|
||||
}
|
||||
|
||||
if (po.proposed_transaction.operations.size() >= 2) {
|
||||
|
|
@ -254,14 +254,14 @@ bool sidechain_net_handler_hive::process_proposal(const proposal_object &po) {
|
|||
account_auths[wallet_son.public_key] = wallet_son.weight;
|
||||
}
|
||||
|
||||
std::string memo_key = node_rpc_client->get_account_memo_key("son-account");
|
||||
std::string memo_key = rpc_client->get_account_memo_key(wallet_account_name);
|
||||
|
||||
hive::authority active;
|
||||
active.weight_threshold = total_weight * 2 / 3 + 1;
|
||||
active.account_auths = account_auths;
|
||||
|
||||
hive::account_update_operation auo;
|
||||
auo.account = "son-account";
|
||||
auo.account = wallet_account_name;
|
||||
auo.active = active;
|
||||
auo.memo_key = op_trx.operations[0].get<hive::account_update_operation>().memo_key;
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ bool sidechain_net_handler_hive::process_proposal(const proposal_object &po) {
|
|||
uint64_t swdo_sidechain_amount = swdo->sidechain_amount.value;
|
||||
uint64_t swdo_op_idx = std::stoll(swdo->sidechain_uid.substr(swdo->sidechain_uid.find_last_of("-")));
|
||||
|
||||
std::string tx_str = node_rpc_client->account_history_api_get_transaction(swdo_txid);
|
||||
std::string tx_str = rpc_client->account_history_api_get_transaction(swdo_txid);
|
||||
if (tx_str != "") {
|
||||
|
||||
std::stringstream ss_tx(tx_str);
|
||||
|
|
@ -408,7 +408,7 @@ bool sidechain_net_handler_hive::process_proposal(const proposal_object &po) {
|
|||
}
|
||||
|
||||
hive::transfer_operation t_op;
|
||||
t_op.from = "son-account";
|
||||
t_op.from = wallet_account_name;
|
||||
t_op.to = swwo->withdraw_address;
|
||||
t_op.amount.amount = swwo->withdraw_amount;
|
||||
t_op.amount.symbol = symbol;
|
||||
|
|
@ -495,7 +495,7 @@ void sidechain_net_handler_hive::process_primary_wallet() {
|
|||
account_auths[active_son.public_key] = active_son.weight;
|
||||
}
|
||||
|
||||
std::string memo_key = node_rpc_client->get_account_memo_key("son-account");
|
||||
std::string memo_key = rpc_client->get_account_memo_key(wallet_account_name);
|
||||
|
||||
if (memo_key.empty()) {
|
||||
return;
|
||||
|
|
@ -506,14 +506,14 @@ void sidechain_net_handler_hive::process_primary_wallet() {
|
|||
active.account_auths = account_auths;
|
||||
|
||||
hive::account_update_operation auo;
|
||||
auo.account = "son-account";
|
||||
auo.account = wallet_account_name;
|
||||
auo.active = active;
|
||||
auo.memo_key = hive::public_key_type(memo_key);
|
||||
|
||||
std::string block_id_str = node_rpc_client->get_head_block_id();
|
||||
std::string block_id_str = rpc_client->get_head_block_id();
|
||||
hive::block_id_type head_block_id(block_id_str);
|
||||
|
||||
std::string head_block_time_str = node_rpc_client->get_head_block_time();
|
||||
std::string head_block_time_str = rpc_client->get_head_block_time();
|
||||
time_point head_block_time = fc::time_point_sec::from_iso_string(head_block_time_str);
|
||||
|
||||
hive::signed_transaction htrx;
|
||||
|
|
@ -538,7 +538,7 @@ void sidechain_net_handler_hive::process_primary_wallet() {
|
|||
swu_op.payer = gpo.parameters.son_account();
|
||||
swu_op.son_wallet_id = active_sw->id;
|
||||
swu_op.sidechain = sidechain;
|
||||
swu_op.address = "son-account";
|
||||
swu_op.address = wallet_account_name;
|
||||
|
||||
proposal_op.proposed_ops.emplace_back(swu_op);
|
||||
|
||||
|
|
@ -662,16 +662,16 @@ bool sidechain_net_handler_hive::process_withdrawal(const son_wallet_withdraw_ob
|
|||
}
|
||||
|
||||
hive::transfer_operation t_op;
|
||||
t_op.from = "son-account";
|
||||
t_op.from = wallet_account_name;
|
||||
t_op.to = swwo.withdraw_address;
|
||||
t_op.amount.amount = swwo.withdraw_amount;
|
||||
t_op.amount.symbol = symbol;
|
||||
t_op.memo = "";
|
||||
|
||||
std::string block_id_str = node_rpc_client->get_head_block_id();
|
||||
std::string block_id_str = rpc_client->get_head_block_id();
|
||||
hive::block_id_type head_block_id(block_id_str);
|
||||
|
||||
std::string head_block_time_str = node_rpc_client->get_head_block_time();
|
||||
std::string head_block_time_str = rpc_client->get_head_block_time();
|
||||
time_point head_block_time = fc::time_point_sec::from_iso_string(head_block_time_str);
|
||||
|
||||
hive::signed_transaction htrx;
|
||||
|
|
@ -727,7 +727,7 @@ std::string sidechain_net_handler_hive::process_sidechain_transaction(const side
|
|||
hive::signed_transaction htrx;
|
||||
fc::raw::unpack(ss_trx, htrx, 1000);
|
||||
|
||||
std::string chain_id_str = node_rpc_client->get_chain_id();
|
||||
std::string chain_id_str = rpc_client->get_chain_id();
|
||||
const hive::chain_id_type chain_id(chain_id_str);
|
||||
|
||||
fc::optional<fc::ecc::private_key> privkey = graphene::utilities::wif_to_key(get_private_key(plugin.get_current_son_object(sidechain).sidechain_public_keys.at(sidechain)));
|
||||
|
|
@ -755,7 +755,7 @@ std::string sidechain_net_handler_hive::send_sidechain_transaction(const sidecha
|
|||
}
|
||||
|
||||
std::string params = fc::json::to_string(htrx);
|
||||
node_rpc_client->network_broadcast_api_broadcast_transaction(params);
|
||||
rpc_client->network_broadcast_api_broadcast_transaction(params);
|
||||
|
||||
return htrx.id().str();
|
||||
}
|
||||
|
|
@ -770,7 +770,7 @@ bool sidechain_net_handler_hive::settle_sidechain_transaction(const sidechain_tr
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string tx_str = node_rpc_client->account_history_api_get_transaction(sto.sidechain_transaction);
|
||||
std::string tx_str = rpc_client->account_history_api_get_transaction(sto.sidechain_transaction);
|
||||
if (tx_str != "") {
|
||||
|
||||
std::stringstream ss_tx(tx_str);
|
||||
|
|
@ -781,7 +781,7 @@ bool sidechain_net_handler_hive::settle_sidechain_transaction(const sidechain_tr
|
|||
|
||||
std::string tx_txid = tx_json.get<std::string>("result.transaction_id");
|
||||
uint32_t tx_block_num = tx_json.get<uint32_t>("result.block_num");
|
||||
uint32_t last_irreversible_block = std::stoul(node_rpc_client->get_last_irreversible_block_num());
|
||||
uint32_t last_irreversible_block = std::stoul(rpc_client->get_last_irreversible_block_num());
|
||||
|
||||
//std::string tx_address = addr.get_address();
|
||||
//int64_t tx_amount = -1;
|
||||
|
|
@ -817,7 +817,7 @@ void sidechain_net_handler_hive::schedule_hive_listener() {
|
|||
void sidechain_net_handler_hive::hive_listener_loop() {
|
||||
schedule_hive_listener();
|
||||
|
||||
std::string reply = node_rpc_client->database_api_get_dynamic_global_properties();
|
||||
std::string reply = rpc_client->database_api_get_dynamic_global_properties();
|
||||
if (!reply.empty()) {
|
||||
std::stringstream ss(reply);
|
||||
boost::property_tree::ptree json;
|
||||
|
|
@ -832,7 +832,7 @@ void sidechain_net_handler_hive::hive_listener_loop() {
|
|||
}
|
||||
}
|
||||
|
||||
//std::string reply = node_rpc_client->get_last_irreversible_block_num();
|
||||
//std::string reply = rpc_client->get_last_irreversible_block_num();
|
||||
//if (!reply.empty()) {
|
||||
// uint64_t last_irreversible_block = std::stoul(reply);
|
||||
// if (last_irreversible_block != last_block_received) {
|
||||
|
|
@ -844,7 +844,7 @@ void sidechain_net_handler_hive::hive_listener_loop() {
|
|||
}
|
||||
|
||||
void sidechain_net_handler_hive::handle_event(const std::string &event_data) {
|
||||
std::string block = node_rpc_client->block_api_get_block(std::atoll(event_data.c_str()));
|
||||
std::string block = rpc_client->block_api_get_block(std::atoll(event_data.c_str()));
|
||||
if (block != "") {
|
||||
add_to_son_listener_log("BLOCK : " + event_data);
|
||||
std::stringstream ss(block);
|
||||
|
|
@ -869,7 +869,7 @@ void sidechain_net_handler_hive::handle_event(const std::string &event_data) {
|
|||
std::string from = op_value.get<std::string>("from");
|
||||
std::string to = op_value.get<std::string>("to");
|
||||
|
||||
if (to == "son-account") {
|
||||
if (to == wallet_account_name) {
|
||||
|
||||
const auto &amount_child = op_value.get_child("amount");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue