Merge branch 'feature/SON-134' of github.com:peerplays-network/peerplays into feature/SON-134
This commit is contained in:
commit
06a9b1f75e
6 changed files with 16 additions and 76 deletions
|
|
@ -37,11 +37,6 @@ protected:
|
|||
|
||||
std::map<std::string, std::string> private_keys;
|
||||
|
||||
virtual std::string create_multisignature_wallet(const std::vector<std::string> public_keys) = 0;
|
||||
virtual std::string transfer(const std::string &from, const std::string &to, const uint64_t amount) = 0;
|
||||
virtual std::string sign_transaction(const std::string &transaction) = 0;
|
||||
virtual std::string send_transaction(const std::string &transaction) = 0;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ public:
|
|||
class bitcoin_rpc_client {
|
||||
public:
|
||||
bitcoin_rpc_client(std::string _ip, uint32_t _rpc, std::string _user, std::string _password, std::string _wallet, std::string _wallet_password);
|
||||
bool connection_is_not_defined() const;
|
||||
|
||||
std::string addmultisigaddress(const std::vector<std::string> public_keys);
|
||||
std::string createrawtransaction(const std::vector<btc_txout> &ins, const fc::flat_map<std::string, double> outs);
|
||||
|
|
@ -59,9 +58,6 @@ private:
|
|||
class zmq_listener {
|
||||
public:
|
||||
zmq_listener(std::string _ip, uint32_t _zmq);
|
||||
bool connection_is_not_defined() const {
|
||||
return zmq_port == 0;
|
||||
}
|
||||
|
||||
fc::signal<void(const std::string &)> event_received;
|
||||
|
||||
|
|
@ -101,12 +97,7 @@ private:
|
|||
std::unique_ptr<bitcoin_rpc_client> bitcoin_client;
|
||||
std::unique_ptr<zmq_listener> listener;
|
||||
|
||||
std::string create_multisignature_wallet(const std::vector<std::string> public_keys) override;
|
||||
std::string transfer(const std::string &from, const std::string &to, const uint64_t amount) override;
|
||||
std::string sign_transaction(const std::string &transaction) override;
|
||||
std::string send_transaction(const std::string &transaction) override;
|
||||
std::string sign_and_send_transaction_with_wallet(const std::string &tx_json);
|
||||
std::string create_weighted_multisignature_wallet(const std::vector<std::pair<std::string, uint64_t>> &public_keys);
|
||||
void transfer_all_btc(const std::string &from_address, const vector<son_info> &from_sons, const std::string &to_address);
|
||||
std::string transfer_deposit_to_primary_wallet(const son_wallet_deposit_object &swdo);
|
||||
std::string transfer_withdrawal_from_primary_wallet(const son_wallet_withdraw_object &swwo);
|
||||
|
|
|
|||
|
|
@ -20,11 +20,6 @@ public:
|
|||
void complete_signing() override;
|
||||
|
||||
private:
|
||||
std::string create_multisignature_wallet(const std::vector<std::string> public_keys) override;
|
||||
std::string transfer(const std::string &from, const std::string &to, const uint64_t amount) override;
|
||||
std::string sign_transaction(const std::string &transaction) override;
|
||||
std::string send_transaction(const std::string &transaction) override;
|
||||
|
||||
void on_applied_block(const signed_block &b);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ void peerplays_sidechain_plugin_impl::heartbeat_loop() {
|
|||
for (son_id_type son_id : sons) {
|
||||
if (is_active_son(son_id) || get_son_object(son_id).status == chain::son_status::in_maintenance) {
|
||||
|
||||
ilog("peerplays_sidechain_plugin: sending heartbeat for SON ${son}", ("son", son_id));
|
||||
ilog("sending heartbeat for SON ${son}", ("son", son_id));
|
||||
chain::son_heartbeat_operation op;
|
||||
op.owner_account = get_son_object(son_id).son_account;
|
||||
op.son_id = son_id;
|
||||
|
|
@ -302,7 +302,7 @@ void peerplays_sidechain_plugin_impl::heartbeat_loop() {
|
|||
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
||||
return true;
|
||||
} catch (fc::exception e) {
|
||||
ilog("peerplays_sidechain_plugin_impl: sending heartbeat failed with exception ${e}", ("e", e.what()));
|
||||
ilog("sending heartbeat failed with exception ${e}", ("e", e.what()));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
|
@ -329,7 +329,7 @@ void peerplays_sidechain_plugin_impl::son_processing() {
|
|||
}
|
||||
|
||||
chain::son_id_type next_son_id = plugin.database().get_scheduled_son(1);
|
||||
ilog("peerplays_sidechain_plugin_impl: Scheduled SON ${son}", ("son", next_son_id));
|
||||
ilog("Scheduled SON ${son}", ("son", next_son_id));
|
||||
|
||||
// Tasks that are executed by all active SONs, no matter if scheduled
|
||||
// E.g. sending approvals and signing
|
||||
|
|
@ -355,14 +355,6 @@ void peerplays_sidechain_plugin_impl::son_processing() {
|
|||
}
|
||||
}
|
||||
|
||||
void peerplays_sidechain_plugin_impl::process_signing() {
|
||||
net_manager->process_signing();
|
||||
}
|
||||
|
||||
void peerplays_sidechain_plugin_impl::complete_signing() {
|
||||
net_manager->complete_signing();
|
||||
}
|
||||
|
||||
void peerplays_sidechain_plugin_impl::approve_proposals() {
|
||||
|
||||
auto approve_proposal = [&](const chain::son_id_type &son_id, const chain::proposal_id_type &proposal_id) {
|
||||
|
|
@ -379,7 +371,7 @@ void peerplays_sidechain_plugin_impl::approve_proposals() {
|
|||
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
||||
return true;
|
||||
} catch (fc::exception e) {
|
||||
ilog("peerplays_sidechain_plugin_impl: sending approval failed with exception ${e}", ("e", e.what()));
|
||||
ilog("sending approval failed with exception ${e}", ("e", e.what()));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
|
@ -497,7 +489,7 @@ void peerplays_sidechain_plugin_impl::create_son_down_proposals() {
|
|||
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
||||
return true;
|
||||
} catch (fc::exception e) {
|
||||
ilog("peerplays_sidechain_plugin_impl: sending son down proposal failed with exception ${e}", ("e", e.what()));
|
||||
ilog("sending son down proposal failed with exception ${e}", ("e", e.what()));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
|
@ -531,7 +523,7 @@ void peerplays_sidechain_plugin_impl::create_son_deregister_proposals() {
|
|||
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
||||
return true;
|
||||
} catch (fc::exception e) {
|
||||
ilog("peerplays_sidechain_plugin_impl: sending son dereg proposal failed with exception ${e}", ("e", e.what()));
|
||||
ilog("sending son dereg proposal failed with exception ${e}", ("e", e.what()));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
|
@ -554,6 +546,14 @@ void peerplays_sidechain_plugin_impl::process_withdrawals() {
|
|||
net_manager->process_withdrawals();
|
||||
}
|
||||
|
||||
void peerplays_sidechain_plugin_impl::process_signing() {
|
||||
net_manager->process_signing();
|
||||
}
|
||||
|
||||
void peerplays_sidechain_plugin_impl::complete_signing() {
|
||||
net_manager->complete_signing();
|
||||
}
|
||||
|
||||
void peerplays_sidechain_plugin_impl::on_applied_block(const signed_block &b) {
|
||||
schedule_son_processing();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,10 +38,6 @@ bitcoin_rpc_client::bitcoin_rpc_client(std::string _ip, uint32_t _rpc, std::stri
|
|||
authorization.val = "Basic " + fc::base64_encode(user + ":" + password);
|
||||
}
|
||||
|
||||
bool bitcoin_rpc_client::connection_is_not_defined() const {
|
||||
return ip.empty() || rpc_port == 0 || user.empty() || password.empty();
|
||||
}
|
||||
|
||||
std::string bitcoin_rpc_client::addmultisigaddress(const std::vector<std::string> public_keys) {
|
||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"addmultisigaddress\", "
|
||||
"\"method\": \"addmultisigaddress\", \"params\": [");
|
||||
|
|
@ -633,7 +629,8 @@ void sidechain_net_handler_bitcoin::recreate_primary_wallet() {
|
|||
si.total_votes));
|
||||
}
|
||||
|
||||
string address = create_weighted_multisignature_wallet(son_pubkeys_bitcoin);
|
||||
string address = get_weighted_multisig_address(son_pubkeys_bitcoin);
|
||||
bitcoin_client->importaddress(address);
|
||||
|
||||
ilog(address);
|
||||
|
||||
|
|
@ -756,28 +753,6 @@ void sidechain_net_handler_bitcoin::complete_signing() {
|
|||
});
|
||||
}
|
||||
|
||||
std::string sidechain_net_handler_bitcoin::create_multisignature_wallet(const std::vector<std::string> public_keys) {
|
||||
return bitcoin_client->addmultisigaddress(public_keys);
|
||||
}
|
||||
|
||||
std::string sidechain_net_handler_bitcoin::create_weighted_multisignature_wallet(const std::vector<std::pair<std::string, uint64_t>> &public_keys) {
|
||||
string address = get_weighted_multisig_address(public_keys);
|
||||
bitcoin_client->importaddress(address);
|
||||
return address;
|
||||
}
|
||||
|
||||
std::string sidechain_net_handler_bitcoin::transfer(const std::string &from, const std::string &to, const uint64_t amount) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string sidechain_net_handler_bitcoin::sign_transaction(const std::string &transaction) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string sidechain_net_handler_bitcoin::send_transaction(const std::string &transaction) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string sidechain_net_handler_bitcoin::sign_and_send_transaction_with_wallet(const std::string &tx_json) {
|
||||
if (!wallet_password.empty()) {
|
||||
bitcoin_client->walletpassphrase(wallet_password, 60);
|
||||
|
|
|
|||
|
|
@ -45,22 +45,6 @@ void sidechain_net_handler_peerplays::process_signing() {
|
|||
void sidechain_net_handler_peerplays::complete_signing() {
|
||||
}
|
||||
|
||||
std::string sidechain_net_handler_peerplays::create_multisignature_wallet(const std::vector<std::string> public_keys) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string sidechain_net_handler_peerplays::transfer(const std::string &from, const std::string &to, const uint64_t amount) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string sidechain_net_handler_peerplays::sign_transaction(const std::string &transaction) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string sidechain_net_handler_peerplays::send_transaction(const std::string &transaction) {
|
||||
return "";
|
||||
}
|
||||
|
||||
void sidechain_net_handler_peerplays::on_applied_block(const signed_block &b) {
|
||||
for (const auto &trx : b.transactions) {
|
||||
size_t operation_index = -1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue