2019-12-04 17:52:00 +00:00
|
|
|
#include <graphene/peerplays_sidechain/sidechain_net_handler.hpp>
|
|
|
|
|
|
2019-12-18 18:30:38 +00:00
|
|
|
#include <graphene/chain/sidechain_address_object.hpp>
|
|
|
|
|
|
|
|
|
|
#include <fc/log/logger.hpp>
|
|
|
|
|
|
2019-12-04 17:52:00 +00:00
|
|
|
namespace graphene { namespace peerplays_sidechain {
|
|
|
|
|
|
2020-02-04 18:31:45 +00:00
|
|
|
sidechain_net_handler::sidechain_net_handler(peerplays_sidechain_plugin& _plugin, const boost::program_options::variables_map& options) :
|
|
|
|
|
plugin(_plugin),
|
|
|
|
|
database(_plugin.database())
|
2019-12-18 18:30:38 +00:00
|
|
|
{
|
2019-12-04 17:52:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sidechain_net_handler::~sidechain_net_handler() {
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-04 18:31:45 +00:00
|
|
|
graphene::peerplays_sidechain::sidechain_type sidechain_net_handler::get_sidechain() {
|
|
|
|
|
return sidechain;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-18 18:30:38 +00:00
|
|
|
std::vector<std::string> sidechain_net_handler::get_sidechain_addresses() {
|
2019-12-04 17:52:00 +00:00
|
|
|
std::vector<std::string> result;
|
|
|
|
|
|
2019-12-18 18:30:38 +00:00
|
|
|
switch (sidechain) {
|
|
|
|
|
case sidechain_type::bitcoin:
|
|
|
|
|
{
|
2020-02-04 18:31:45 +00:00
|
|
|
const auto& sidechain_addresses_idx = database.get_index_type<sidechain_address_index>();
|
2019-12-18 18:30:38 +00:00
|
|
|
const auto& sidechain_addresses_by_sidechain_idx = sidechain_addresses_idx.indices().get<by_sidechain>();
|
|
|
|
|
const auto& sidechain_addresses_by_sidechain_range = sidechain_addresses_by_sidechain_idx.equal_range(sidechain);
|
|
|
|
|
std::for_each(sidechain_addresses_by_sidechain_range.first, sidechain_addresses_by_sidechain_range.second,
|
|
|
|
|
[&result] (const sidechain_address_object& sao) {
|
|
|
|
|
result.push_back(sao.address);
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-12-04 17:52:00 +00:00
|
|
|
default:
|
|
|
|
|
assert(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-18 18:30:38 +00:00
|
|
|
void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_data& sed) {
|
|
|
|
|
ilog( __FUNCTION__ );
|
|
|
|
|
ilog( "sidechain_event_data:" );
|
SON wallet transfer object and operations (#279)
* Extend GPO.active_sons to contain votes and all public keys
* Introduce son_wallet_object
* son_wallet_object operations
* son_wallet_object operations
* son_wallet_object operations completed, basic tests added
* Create son_wallet_object on new set of SONs, to initiate primary wallet recreation
* son_wallet_object API and cli wallet commands
* Send RPC command to bitcoin node to recreate multisig wallet
* Send RPC command to bitcoin node to recreate multisig wallet
* Send RPC command to bitcoin node to recreate multisig wallet
* Wallet recreation by scheduled SON only, some cosmetic refactoring
* Wallet recreation by scheduled SON only, some cosmetic refactoring
* Updating wallet info through operation instead through database.modify() for persistance
* SON wallet transfer object and operations, for tracking assets deposit/withdrawal
* Update libraries/chain/include/graphene/chain/protocol/son_wallet.hpp
Co-Authored-By: gladcow <jahr@yandex.ru>
* Update libraries/chain/include/graphene/chain/protocol/son_wallet.hpp
Co-Authored-By: gladcow <jahr@yandex.ru>
* Fix #include <graphene/chain/son_wallet_transfer_object.hpp>
* SON wallet transfer object and operations, for tracking assets deposit/withdrawal
* SON wallet transfer object and operations, for tracking assets deposit/withdrawal
* Refactor primary wallet recreation
* Refactor primary wallet recreation
* PW recreation refactoring, prevent duplicated recreations, update wallet address through proposal
* PW recreation refactoring, prevent duplicated recreations, update wallet address through proposal
* Quickfix for checking payer in evaluator
* Quickfix for checking payer in evaluator
* Fix failing son_wallet_tests
- Check for son_btc_account is temporarely disabled
* Remove redundant file
* Squashed commit of the following:
commit a688bb93ed4e16232a907aa8c76e240c83c771bf
Author: obucinac <obucinac@users.noreply.github.com>
Date: Tue Feb 4 19:31:45 2020 +0100
son_wallet_object operations and multisig wallet recreation by RPC (#263)
* Extend GPO.active_sons to contain votes and all public keys
* Introduce son_wallet_object
* son_wallet_object operations
* Create son_wallet_object on new set of SONs, to initiate primary wallet recreation
* son_wallet_object API and cli wallet commands
* Send RPC command to bitcoin node to recreate multisig wallet
* Updating wallet info through operation instead through database.modify() for persistance
* Update libraries/chain/include/graphene/chain/protocol/son_wallet.hpp
* Update libraries/chain/include/graphene/chain/protocol/son_wallet.hpp
* Fix #include <graphene/chain/son_wallet_transfer_object.hpp>
* Refactor primary wallet recreation
* PW recreation refactoring, prevent duplicated recreations, update wallet address through proposal
* Quickfix for checking payer in evaluator
* Fix failing son_wallet_tests
- Check for son_btc_account is temporarely disabled
* Remove redundant file
Co-authored-by: gladcow <jahr@yandex.ru>
commit 6e61d6b055eb276757e426245a3a7c23a61b3854
Author: satyakoneru <satyakoneru.iiith@gmail.com>
Date: Tue Feb 4 00:14:39 2020 +1100
SON233 - Provide correct downtime metrics to user (#278)
* Remove duplicated item in CMakeLists.txt
* Issue tokens to the user who deposited Bitcoin, WIP...
* Add son_wallet_transfer_process_operation
* Issue tokens to the user who deposited Bitcoin, WIP...
* Add is_active_son guards for sidechain events processing
Co-authored-by: gladcow <jahr@yandex.ru>
2020-02-11 13:46:35 +00:00
|
|
|
ilog( " timestamp: ${timestamp}", ( "timestamp", sed.timestamp ) );
|
|
|
|
|
ilog( " sidechain: ${sidechain}", ( "sidechain", sed.sidechain ) );
|
|
|
|
|
ilog( " sidechain_uid: ${uid}", ( "uid", sed.sidechain_uid ) );
|
|
|
|
|
ilog( " sidechain_transaction_id: ${transaction_id}", ( "transaction_id", sed.sidechain_transaction_id ) );
|
|
|
|
|
ilog( " sidechain_from: ${from}", ( "from", sed.sidechain_from ) );
|
|
|
|
|
ilog( " sidechain_to: ${to}", ( "to", sed.sidechain_to ) );
|
|
|
|
|
ilog( " sidechain_amount: ${amount}", ( "amount", sed.sidechain_amount ) );
|
|
|
|
|
ilog( " peerplays_from: ${peerplays_from}", ( "peerplays_from", sed.peerplays_from ) );
|
|
|
|
|
ilog( " peerplays_to: ${peerplays_to}", ( "peerplays_to", sed.peerplays_to ) );
|
|
|
|
|
|
|
|
|
|
if (!plugin.is_active_son()) {
|
|
|
|
|
ilog( " !!! SON is not active and not processing sidechain events...");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const chain::global_property_object& gpo = database.get_global_properties();
|
|
|
|
|
|
|
|
|
|
son_wallet_transfer_create_operation op;
|
|
|
|
|
op.payer = gpo.parameters.get_son_btc_account_id();
|
|
|
|
|
op.timestamp = sed.timestamp;
|
|
|
|
|
op.sidechain = sed.sidechain;
|
|
|
|
|
op.sidechain_uid = sed.sidechain_uid;
|
|
|
|
|
op.sidechain_transaction_id = sed.sidechain_transaction_id;
|
|
|
|
|
op.sidechain_from = sed.sidechain_from;
|
|
|
|
|
op.sidechain_to = sed.sidechain_to;
|
|
|
|
|
op.sidechain_amount = sed.sidechain_amount;
|
|
|
|
|
op.peerplays_from = sed.peerplays_from;
|
|
|
|
|
op.peerplays_to = sed.peerplays_to;
|
|
|
|
|
|
|
|
|
|
proposal_create_operation proposal_op;
|
|
|
|
|
proposal_op.fee_paying_account = plugin.get_son_object().son_account;
|
|
|
|
|
proposal_op.proposed_ops.push_back( op_wrapper( op ) );
|
|
|
|
|
uint32_t lifetime = ( gpo.parameters.block_interval * gpo.active_witnesses.size() ) * 3;
|
|
|
|
|
proposal_op.expiration_time = time_point_sec( database.head_block_time().sec_since_epoch() + lifetime );
|
|
|
|
|
|
|
|
|
|
signed_transaction trx = plugin.database().create_signed_transaction(plugin.get_private_keys().begin()->second, proposal_op);
|
|
|
|
|
try {
|
|
|
|
|
database.push_transaction(trx);
|
|
|
|
|
} catch(fc::exception e){
|
|
|
|
|
ilog("sidechain_net_handler: sending proposal for son wallet transfer create operation failed with exception ${e}",("e", e.what()));
|
|
|
|
|
}
|
2019-12-18 18:30:38 +00:00
|
|
|
}
|
|
|
|
|
|
2019-12-04 17:52:00 +00:00
|
|
|
} } // graphene::peerplays_sidechain
|
|
|
|
|
|