From 0b491510c44e630b4985688d6b21a40999bd7975 Mon Sep 17 00:00:00 2001 From: Srdjan Obucina Date: Wed, 22 Jan 2020 13:44:11 +0100 Subject: [PATCH] Send RPC command to bitcoin node to recreate multisig wallet --- .../peerplays_sidechain_plugin.cpp | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp b/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp index 45f029e4..8ee66a58 100644 --- a/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp +++ b/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp @@ -256,38 +256,30 @@ void peerplays_sidechain_plugin_impl::son_event_processing_loop() void peerplays_sidechain_plugin_impl::recreate_primary_wallet() { - ilog(__FUNCTION__); chain::database& d = plugin.database(); - ilog(__FUNCTION__); const auto& idx_swi = d.get_index_type().indices().get(); auto obj = idx_swi.rbegin(); if (obj != idx_swi.rend()) { - ilog(__FUNCTION__); if ((obj->addresses.find(sidechain_type::bitcoin) == obj->addresses.end()) || (obj->addresses.at(sidechain_type::bitcoin).empty())) { - ilog(__FUNCTION__); auto active_sons = d.get_global_properties().active_sons; vector son_pubkeys_bitcoin; for ( const son_info& si : active_sons ) { son_pubkeys_bitcoin.push_back(si.sidechain_public_keys.at(sidechain_type::bitcoin)); } - ilog(__FUNCTION__); string reply_str = net_manager->recreate_primary_wallet(sidechain_type::bitcoin, son_pubkeys_bitcoin); - ilog(reply_str); std::stringstream ss(reply_str); - boost::property_tree::ptree json; - boost::property_tree::read_json( ss, json ); - - if (json.count( "result" )) { - //if (json.get_child( "result" ).count( "address" )) { - d.modify(*obj, [&, &obj, &json](son_wallet_object &swo) { - ilog(__FUNCTION__); - swo.addresses[sidechain_type::bitcoin] = json.get_child("result").get_value();; - }); - //} + boost::property_tree::ptree pt; + boost::property_tree::read_json( ss, pt ); + if( pt.count( "error" ) && pt.get_child( "error" ).empty() ) { + d.modify(*obj, [&, &obj, &pt](son_wallet_object &swo) { + std::stringstream ss; + boost::property_tree::json_parser::write_json(ss, pt.get_child("result")); + swo.addresses[sidechain_type::bitcoin] = ss.str(); + }); } } }