Some refactoring
This commit is contained in:
parent
22c12f5041
commit
cbfaefde83
15 changed files with 105 additions and 81 deletions
|
|
@ -13,7 +13,7 @@ namespace graphene { namespace chain {
|
||||||
account_id_type sidechain_address_account;
|
account_id_type sidechain_address_account;
|
||||||
graphene::peerplays_sidechain::sidechain_type sidechain;
|
graphene::peerplays_sidechain::sidechain_type sidechain;
|
||||||
string deposit_address;
|
string deposit_address;
|
||||||
string withdrawal_address;
|
string withdraw_address;
|
||||||
|
|
||||||
account_id_type fee_payer()const { return sidechain_address_account; }
|
account_id_type fee_payer()const { return sidechain_address_account; }
|
||||||
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
|
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
|
||||||
|
|
@ -28,7 +28,7 @@ namespace graphene { namespace chain {
|
||||||
account_id_type sidechain_address_account;
|
account_id_type sidechain_address_account;
|
||||||
graphene::peerplays_sidechain::sidechain_type sidechain;
|
graphene::peerplays_sidechain::sidechain_type sidechain;
|
||||||
optional<string> deposit_address;
|
optional<string> deposit_address;
|
||||||
optional<string> withdrawal_address;
|
optional<string> withdraw_address;
|
||||||
|
|
||||||
account_id_type fee_payer()const { return sidechain_address_account; }
|
account_id_type fee_payer()const { return sidechain_address_account; }
|
||||||
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
|
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
|
||||||
|
|
@ -51,12 +51,12 @@ namespace graphene { namespace chain {
|
||||||
|
|
||||||
FC_REFLECT(graphene::chain::sidechain_address_add_operation::fee_parameters_type, (fee) )
|
FC_REFLECT(graphene::chain::sidechain_address_add_operation::fee_parameters_type, (fee) )
|
||||||
FC_REFLECT(graphene::chain::sidechain_address_add_operation, (fee)
|
FC_REFLECT(graphene::chain::sidechain_address_add_operation, (fee)
|
||||||
(sidechain_address_account)(sidechain)(deposit_address)(withdrawal_address) )
|
(sidechain_address_account)(sidechain)(deposit_address)(withdraw_address) )
|
||||||
|
|
||||||
FC_REFLECT(graphene::chain::sidechain_address_update_operation::fee_parameters_type, (fee) )
|
FC_REFLECT(graphene::chain::sidechain_address_update_operation::fee_parameters_type, (fee) )
|
||||||
FC_REFLECT(graphene::chain::sidechain_address_update_operation, (fee)
|
FC_REFLECT(graphene::chain::sidechain_address_update_operation, (fee)
|
||||||
(sidechain_address_id)
|
(sidechain_address_id)
|
||||||
(sidechain_address_account)(sidechain)(deposit_address)(withdrawal_address) )
|
(sidechain_address_account)(sidechain)(deposit_address)(withdraw_address) )
|
||||||
|
|
||||||
FC_REFLECT(graphene::chain::sidechain_address_delete_operation::fee_parameters_type, (fee) )
|
FC_REFLECT(graphene::chain::sidechain_address_delete_operation::fee_parameters_type, (fee) )
|
||||||
FC_REFLECT(graphene::chain::sidechain_address_delete_operation, (fee)
|
FC_REFLECT(graphene::chain::sidechain_address_delete_operation, (fee)
|
||||||
|
|
|
||||||
|
|
@ -22,19 +22,19 @@ namespace graphene { namespace chain {
|
||||||
account_id_type sidechain_address_account;
|
account_id_type sidechain_address_account;
|
||||||
graphene::peerplays_sidechain::sidechain_type sidechain;
|
graphene::peerplays_sidechain::sidechain_type sidechain;
|
||||||
string deposit_address;
|
string deposit_address;
|
||||||
string withdrawal_address;
|
string withdraw_address;
|
||||||
|
|
||||||
sidechain_address_object() :
|
sidechain_address_object() :
|
||||||
sidechain(graphene::peerplays_sidechain::sidechain_type::bitcoin),
|
sidechain(graphene::peerplays_sidechain::sidechain_type::bitcoin),
|
||||||
deposit_address(""),
|
deposit_address(""),
|
||||||
withdrawal_address("") {}
|
withdraw_address("") {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct by_account;
|
struct by_account;
|
||||||
struct by_sidechain;
|
struct by_sidechain;
|
||||||
struct by_account_and_sidechain;
|
struct by_account_and_sidechain;
|
||||||
struct by_sidechain_and_deposit_address;
|
struct by_sidechain_and_deposit_address;
|
||||||
struct by_sidechain_and_withdrawal_address;
|
struct by_sidechain_and_withdraw_address;
|
||||||
using sidechain_address_multi_index_type = multi_index_container<
|
using sidechain_address_multi_index_type = multi_index_container<
|
||||||
sidechain_address_object,
|
sidechain_address_object,
|
||||||
indexed_by<
|
indexed_by<
|
||||||
|
|
@ -59,10 +59,10 @@ namespace graphene { namespace chain {
|
||||||
member<sidechain_address_object, std::string, &sidechain_address_object::deposit_address>
|
member<sidechain_address_object, std::string, &sidechain_address_object::deposit_address>
|
||||||
>
|
>
|
||||||
>,
|
>,
|
||||||
ordered_unique< tag<by_sidechain_and_withdrawal_address>,
|
ordered_unique< tag<by_sidechain_and_withdraw_address>,
|
||||||
composite_key<sidechain_address_object,
|
composite_key<sidechain_address_object,
|
||||||
member<sidechain_address_object, peerplays_sidechain::sidechain_type, &sidechain_address_object::sidechain>,
|
member<sidechain_address_object, peerplays_sidechain::sidechain_type, &sidechain_address_object::sidechain>,
|
||||||
member<sidechain_address_object, std::string, &sidechain_address_object::withdrawal_address>
|
member<sidechain_address_object, std::string, &sidechain_address_object::withdraw_address>
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
|
|
@ -72,4 +72,4 @@ namespace graphene { namespace chain {
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
||||||
FC_REFLECT_DERIVED( graphene::chain::sidechain_address_object, (graphene::db::object),
|
FC_REFLECT_DERIVED( graphene::chain::sidechain_address_object, (graphene::db::object),
|
||||||
(sidechain_address_account) (sidechain) (deposit_address) (withdrawal_address) )
|
(sidechain_address_account) (sidechain) (deposit_address) (withdraw_address) )
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ object_id_type add_sidechain_address_evaluator::do_apply(const sidechain_address
|
||||||
obj.sidechain_address_account = op.sidechain_address_account;
|
obj.sidechain_address_account = op.sidechain_address_account;
|
||||||
obj.sidechain = op.sidechain;
|
obj.sidechain = op.sidechain;
|
||||||
obj.deposit_address = op.deposit_address;
|
obj.deposit_address = op.deposit_address;
|
||||||
obj.withdrawal_address = op.withdrawal_address;
|
obj.withdraw_address = op.withdraw_address;
|
||||||
});
|
});
|
||||||
return new_sidechain_address_object.id;
|
return new_sidechain_address_object.id;
|
||||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
@ -41,7 +41,7 @@ object_id_type update_sidechain_address_evaluator::do_apply(const sidechain_addr
|
||||||
{
|
{
|
||||||
db().modify(*itr, [&op](sidechain_address_object &sao) {
|
db().modify(*itr, [&op](sidechain_address_object &sao) {
|
||||||
if(op.deposit_address.valid()) sao.deposit_address = *op.deposit_address;
|
if(op.deposit_address.valid()) sao.deposit_address = *op.deposit_address;
|
||||||
if(op.withdrawal_address.valid()) sao.withdrawal_address = *op.withdrawal_address;
|
if(op.withdraw_address.valid()) sao.withdraw_address = *op.withdraw_address;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return op.sidechain_address_id;
|
return op.sidechain_address_id;
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,13 @@ public:
|
||||||
|
|
||||||
graphene::peerplays_sidechain::sidechain_type get_sidechain();
|
graphene::peerplays_sidechain::sidechain_type get_sidechain();
|
||||||
std::vector<std::string> get_sidechain_deposit_addresses();
|
std::vector<std::string> get_sidechain_deposit_addresses();
|
||||||
std::vector<std::string> get_sidechain_withdrawal_addresses();
|
std::vector<std::string> get_sidechain_withdraw_addresses();
|
||||||
|
|
||||||
void sidechain_event_data_received(const sidechain_event_data& sed);
|
void sidechain_event_data_received(const sidechain_event_data& sed);
|
||||||
|
|
||||||
virtual void recreate_primary_wallet() = 0;
|
virtual void recreate_primary_wallet() = 0;
|
||||||
|
virtual void process_deposits() = 0;
|
||||||
|
virtual void process_withdrawals() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
peerplays_sidechain_plugin& plugin;
|
peerplays_sidechain_plugin& plugin;
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,8 @@ public:
|
||||||
virtual ~sidechain_net_handler_bitcoin();
|
virtual ~sidechain_net_handler_bitcoin();
|
||||||
|
|
||||||
void recreate_primary_wallet();
|
void recreate_primary_wallet();
|
||||||
|
void process_deposits();
|
||||||
|
void process_withdrawals();
|
||||||
|
|
||||||
std::string create_multisignature_wallet( const std::vector<std::string> public_keys );
|
std::string create_multisignature_wallet( const std::vector<std::string> public_keys );
|
||||||
std::string transfer( const std::string& from, const std::string& to, const uint64_t amount );
|
std::string transfer( const std::string& from, const std::string& to, const uint64_t amount );
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ public:
|
||||||
virtual ~sidechain_net_handler_peerplays();
|
virtual ~sidechain_net_handler_peerplays();
|
||||||
|
|
||||||
void recreate_primary_wallet();
|
void recreate_primary_wallet();
|
||||||
|
void process_deposits();
|
||||||
|
void process_withdrawals();
|
||||||
|
|
||||||
std::string create_multisignature_wallet( const std::vector<std::string> public_keys );
|
std::string create_multisignature_wallet( const std::vector<std::string> public_keys );
|
||||||
std::string transfer( const std::string& from, const std::string& to, const uint64_t amount );
|
std::string transfer( const std::string& from, const std::string& to, const uint64_t amount );
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ public:
|
||||||
|
|
||||||
bool create_handler(peerplays_sidechain::sidechain_type sidechain, const boost::program_options::variables_map& options);
|
bool create_handler(peerplays_sidechain::sidechain_type sidechain, const boost::program_options::variables_map& options);
|
||||||
void recreate_primary_wallet();
|
void recreate_primary_wallet();
|
||||||
|
void process_deposits();
|
||||||
|
void process_withdrawals();
|
||||||
private:
|
private:
|
||||||
peerplays_sidechain_plugin& plugin;
|
peerplays_sidechain_plugin& plugin;
|
||||||
graphene::chain::database& database;
|
graphene::chain::database& database;
|
||||||
|
|
|
||||||
|
|
@ -409,7 +409,7 @@ void peerplays_sidechain_plugin_impl::process_deposits() {
|
||||||
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
||||||
} catch(fc::exception e){
|
} catch(fc::exception e){
|
||||||
ilog("sidechain_net_handler: sending proposal for transfer operation failed with exception ${e}",("e", e.what()));
|
ilog("sidechain_net_handler: sending proposal for transfer operation failed with exception ${e}",("e", e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -428,6 +428,7 @@ void peerplays_sidechain_plugin_impl::process_withdrawals() {
|
||||||
for (son_id_type son_id : plugin.get_sons()) {
|
for (son_id_type son_id : plugin.get_sons()) {
|
||||||
if (plugin.is_active_son(son_id)) {
|
if (plugin.is_active_son(son_id)) {
|
||||||
|
|
||||||
|
ilog("Withdraw to process: ${swwo}", ("swwo", swwo));
|
||||||
//son_wallet_withdraw_process_operation p_op;
|
//son_wallet_withdraw_process_operation p_op;
|
||||||
//p_op.payer = GRAPHENE_SON_ACCOUNT;
|
//p_op.payer = GRAPHENE_SON_ACCOUNT;
|
||||||
//p_op.son_wallet_withdraw_id = swwo.id;
|
//p_op.son_wallet_withdraw_id = swwo.id;
|
||||||
|
|
@ -449,7 +450,7 @@ void peerplays_sidechain_plugin_impl::process_withdrawals() {
|
||||||
//} catch(fc::exception e){
|
//} catch(fc::exception e){
|
||||||
// ilog("sidechain_net_handler: sending proposal for transfer operation failed with exception ${e}",("e", e.what()));
|
// ilog("sidechain_net_handler: sending proposal for transfer operation failed with exception ${e}",("e", e.what()));
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -475,7 +476,7 @@ void peerplays_sidechain_plugin_impl::on_block_applied( const signed_block& b )
|
||||||
|
|
||||||
process_deposits();
|
process_deposits();
|
||||||
|
|
||||||
//process_withdrawals();
|
process_withdrawals();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,44 +22,26 @@ graphene::peerplays_sidechain::sidechain_type sidechain_net_handler::get_sidecha
|
||||||
std::vector<std::string> sidechain_net_handler::get_sidechain_deposit_addresses() {
|
std::vector<std::string> sidechain_net_handler::get_sidechain_deposit_addresses() {
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
|
|
||||||
switch (sidechain) {
|
const auto& sidechain_addresses_idx = database.get_index_type<sidechain_address_index>();
|
||||||
case sidechain_type::bitcoin:
|
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);
|
||||||
const auto& sidechain_addresses_idx = database.get_index_type<sidechain_address_index>();
|
std::for_each(sidechain_addresses_by_sidechain_range.first, sidechain_addresses_by_sidechain_range.second,
|
||||||
const auto& sidechain_addresses_by_sidechain_idx = sidechain_addresses_idx.indices().get<by_sidechain>();
|
[&result] (const sidechain_address_object& sao) {
|
||||||
const auto& sidechain_addresses_by_sidechain_range = sidechain_addresses_by_sidechain_idx.equal_range(sidechain);
|
result.push_back(sao.deposit_address);
|
||||||
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.deposit_address);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> sidechain_net_handler::get_sidechain_withdrawal_addresses() {
|
std::vector<std::string> sidechain_net_handler::get_sidechain_withdraw_addresses() {
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
|
|
||||||
switch (sidechain) {
|
const auto& sidechain_addresses_idx = database.get_index_type<sidechain_address_index>();
|
||||||
case sidechain_type::bitcoin:
|
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);
|
||||||
const auto& sidechain_addresses_idx = database.get_index_type<sidechain_address_index>();
|
std::for_each(sidechain_addresses_by_sidechain_range.first, sidechain_addresses_by_sidechain_range.second,
|
||||||
const auto& sidechain_addresses_by_sidechain_idx = sidechain_addresses_idx.indices().get<by_sidechain>();
|
[&result] (const sidechain_address_object& sao) {
|
||||||
const auto& sidechain_addresses_by_sidechain_range = sidechain_addresses_by_sidechain_idx.equal_range(sidechain);
|
result.push_back(sao.withdraw_address);
|
||||||
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.withdrawal_address);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,14 +85,14 @@ void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_
|
||||||
uint32_t lifetime = ( gpo.parameters.block_interval * gpo.active_witnesses.size() ) * 3;
|
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 );
|
proposal_op.expiration_time = time_point_sec( database.head_block_time().sec_since_epoch() + lifetime );
|
||||||
|
|
||||||
ilog("sidechain_net_handler: sending proposal for son wallet transfer create operation by ${son}", ("son", son_id));
|
ilog("sidechain_net_handler: sending proposal for son wallet deposit create operation by ${son}", ("son", son_id));
|
||||||
signed_transaction trx = plugin.database().create_signed_transaction(plugin.get_private_key(son_id), proposal_op);
|
signed_transaction trx = plugin.database().create_signed_transaction(plugin.get_private_key(son_id), proposal_op);
|
||||||
try {
|
try {
|
||||||
database.push_transaction(trx, database::validation_steps::skip_block_size_check);
|
database.push_transaction(trx, database::validation_steps::skip_block_size_check);
|
||||||
if(plugin.app().p2p_node())
|
if(plugin.app().p2p_node())
|
||||||
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
||||||
} catch(fc::exception e){
|
} catch(fc::exception e){
|
||||||
ilog("sidechain_net_handler: sending proposal for son wallet transfer create operation by ${son} failed with exception ${e}", ("son", son_id) ("e", e.what()));
|
ilog("sidechain_net_handler: sending proposal for son wallet deposit create operation by ${son} failed with exception ${e}", ("son", son_id) ("e", e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -141,14 +123,14 @@ void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_
|
||||||
uint32_t lifetime = ( gpo.parameters.block_interval * gpo.active_witnesses.size() ) * 3;
|
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 );
|
proposal_op.expiration_time = time_point_sec( database.head_block_time().sec_since_epoch() + lifetime );
|
||||||
|
|
||||||
ilog("sidechain_net_handler: sending proposal for son wallet transfer create operation by ${son}", ("son", son_id));
|
ilog("sidechain_net_handler: sending proposal for son wallet withdraw create operation by ${son}", ("son", son_id));
|
||||||
signed_transaction trx = plugin.database().create_signed_transaction(plugin.get_private_key(son_id), proposal_op);
|
signed_transaction trx = plugin.database().create_signed_transaction(plugin.get_private_key(son_id), proposal_op);
|
||||||
try {
|
try {
|
||||||
database.push_transaction(trx, database::validation_steps::skip_block_size_check);
|
database.push_transaction(trx, database::validation_steps::skip_block_size_check);
|
||||||
if(plugin.app().p2p_node())
|
if(plugin.app().p2p_node())
|
||||||
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
||||||
} catch(fc::exception e){
|
} catch(fc::exception e){
|
||||||
ilog("sidechain_net_handler: sending proposal for son wallet transfer create operation by ${son} failed with exception ${e}", ("son", son_id) ("e", e.what()));
|
ilog("sidechain_net_handler: sending proposal for son wallet withdraw create operation by ${son} failed with exception ${e}", ("son", son_id) ("e", e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -158,5 +140,17 @@ void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_
|
||||||
FC_ASSERT(false, "Invalid sidechain event");
|
FC_ASSERT(false, "Invalid sidechain event");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sidechain_net_handler::recreate_primary_wallet() {
|
||||||
|
FC_ASSERT(false, "recreate_primary_wallet not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
void sidechain_net_handler::process_deposits() {
|
||||||
|
FC_ASSERT(false, "process_deposits not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
void sidechain_net_handler::process_withdrawals() {
|
||||||
|
FC_ASSERT(false, "process_withdrawals not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
} } // graphene::peerplays_sidechain
|
} } // graphene::peerplays_sidechain
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@
|
||||||
#include <graphene/chain/sidechain_address_object.hpp>
|
#include <graphene/chain/sidechain_address_object.hpp>
|
||||||
#include <graphene/chain/son_info.hpp>
|
#include <graphene/chain/son_info.hpp>
|
||||||
#include <graphene/chain/son_wallet_object.hpp>
|
#include <graphene/chain/son_wallet_object.hpp>
|
||||||
|
#include <graphene/chain/son_wallet_deposit_object.hpp>
|
||||||
|
#include <graphene/chain/son_wallet_withdraw_object.hpp>
|
||||||
#include <graphene/chain/protocol/son_wallet.hpp>
|
#include <graphene/chain/protocol/son_wallet.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace peerplays_sidechain {
|
namespace graphene { namespace peerplays_sidechain {
|
||||||
|
|
@ -422,23 +424,25 @@ void sidechain_net_handler_bitcoin::recreate_primary_wallet() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string sidechain_net_handler_bitcoin::create_multisignature_wallet( const std::vector<std::string> public_keys )
|
void sidechain_net_handler_bitcoin::process_deposits() {
|
||||||
{
|
}
|
||||||
|
|
||||||
|
void sidechain_net_handler_bitcoin::process_withdrawals() {
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string sidechain_net_handler_bitcoin::create_multisignature_wallet( const std::vector<std::string> public_keys ) {
|
||||||
return bitcoin_client->add_multisig_address(public_keys);
|
return bitcoin_client->add_multisig_address(public_keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string sidechain_net_handler_bitcoin::transfer( const std::string& from, const std::string& to, const uint64_t amount )
|
std::string sidechain_net_handler_bitcoin::transfer( const std::string& from, const std::string& to, const uint64_t amount ) {
|
||||||
{
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string sidechain_net_handler_bitcoin::sign_transaction( const std::string& transaction )
|
std::string sidechain_net_handler_bitcoin::sign_transaction( const std::string& transaction ) {
|
||||||
{
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string sidechain_net_handler_bitcoin::send_transaction( const std::string& transaction )
|
std::string sidechain_net_handler_bitcoin::send_transaction( const std::string& transaction ) {
|
||||||
{
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -450,7 +454,7 @@ void sidechain_net_handler_bitcoin::handle_event( const std::string& event_data
|
||||||
const auto& sidechain_addresses_idx = database.get_index_type<sidechain_address_index>().indices().get<by_sidechain_and_deposit_address>();
|
const auto& sidechain_addresses_idx = database.get_index_type<sidechain_address_index>().indices().get<by_sidechain_and_deposit_address>();
|
||||||
|
|
||||||
for( const auto& v : vins ) {
|
for( const auto& v : vins ) {
|
||||||
const auto& addr_itr = sidechain_addresses_idx.find(std::make_tuple(sidechain_type::bitcoin, v.address));
|
const auto& addr_itr = sidechain_addresses_idx.find(std::make_tuple(sidechain, v.address));
|
||||||
if ( addr_itr == sidechain_addresses_idx.end() )
|
if ( addr_itr == sidechain_addresses_idx.end() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -475,8 +479,7 @@ void sidechain_net_handler_bitcoin::handle_event( const std::string& event_data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<info_for_vin> sidechain_net_handler_bitcoin::extract_info_from_block( const std::string& _block )
|
std::vector<info_for_vin> sidechain_net_handler_bitcoin::extract_info_from_block( const std::string& _block ) {
|
||||||
{
|
|
||||||
std::stringstream ss( _block );
|
std::stringstream ss( _block );
|
||||||
boost::property_tree::ptree block;
|
boost::property_tree::ptree block;
|
||||||
boost::property_tree::read_json( ss, block );
|
boost::property_tree::read_json( ss, block );
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,12 @@ sidechain_net_handler_peerplays::~sidechain_net_handler_peerplays() {
|
||||||
void sidechain_net_handler_peerplays::recreate_primary_wallet() {
|
void sidechain_net_handler_peerplays::recreate_primary_wallet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sidechain_net_handler_peerplays::process_deposits() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void sidechain_net_handler_peerplays::process_withdrawals() {
|
||||||
|
}
|
||||||
|
|
||||||
std::string sidechain_net_handler_peerplays::create_multisignature_wallet( const std::vector<std::string> public_keys ) {
|
std::string sidechain_net_handler_peerplays::create_multisignature_wallet( const std::vector<std::string> public_keys ) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,5 +46,17 @@ void sidechain_net_manager::recreate_primary_wallet() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sidechain_net_manager::process_deposits() {
|
||||||
|
for ( size_t i = 0; i < net_handlers.size(); i++ ) {
|
||||||
|
net_handlers.at(i)->process_deposits();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sidechain_net_manager::process_withdrawals() {
|
||||||
|
for ( size_t i = 0; i < net_handlers.size(); i++ ) {
|
||||||
|
net_handlers.at(i)->process_withdrawals();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} } // graphene::peerplays_sidechain
|
} } // graphene::peerplays_sidechain
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1417,14 +1417,14 @@ class wallet_api
|
||||||
* @param account the name or id of the account who owns the address
|
* @param account the name or id of the account who owns the address
|
||||||
* @param sidechain a sidechain to whom address belongs
|
* @param sidechain a sidechain to whom address belongs
|
||||||
* @param deposit_address sidechain address for deposits
|
* @param deposit_address sidechain address for deposits
|
||||||
* @param withdrawal_address sidechain address for withdrawals
|
* @param withdraw_address sidechain address for withdrawals
|
||||||
* @param broadcast true to broadcast the transaction on the network
|
* @param broadcast true to broadcast the transaction on the network
|
||||||
* @returns the signed transaction adding sidechain address
|
* @returns the signed transaction adding sidechain address
|
||||||
*/
|
*/
|
||||||
signed_transaction add_sidechain_address(string account,
|
signed_transaction add_sidechain_address(string account,
|
||||||
peerplays_sidechain::sidechain_type sidechain,
|
peerplays_sidechain::sidechain_type sidechain,
|
||||||
string deposit_address,
|
string deposit_address,
|
||||||
string withdrawal_address,
|
string withdraw_address,
|
||||||
bool broadcast = false);
|
bool broadcast = false);
|
||||||
|
|
||||||
/** Updates existing sidechain address owned by the given account for a given sidechain.
|
/** Updates existing sidechain address owned by the given account for a given sidechain.
|
||||||
|
|
@ -1434,14 +1434,14 @@ class wallet_api
|
||||||
* @param account the name or id of the account who owns the address
|
* @param account the name or id of the account who owns the address
|
||||||
* @param sidechain a sidechain to whom address belongs
|
* @param sidechain a sidechain to whom address belongs
|
||||||
* @param deposit_address sidechain address for deposits
|
* @param deposit_address sidechain address for deposits
|
||||||
* @param withdrawal_address sidechain address for withdrawals
|
* @param withdraw_address sidechain address for withdrawals
|
||||||
* @param broadcast true to broadcast the transaction on the network
|
* @param broadcast true to broadcast the transaction on the network
|
||||||
* @returns the signed transaction updating sidechain address
|
* @returns the signed transaction updating sidechain address
|
||||||
*/
|
*/
|
||||||
signed_transaction update_sidechain_address(string account,
|
signed_transaction update_sidechain_address(string account,
|
||||||
peerplays_sidechain::sidechain_type sidechain,
|
peerplays_sidechain::sidechain_type sidechain,
|
||||||
string deposit_address,
|
string deposit_address,
|
||||||
string withdrawal_address,
|
string withdraw_address,
|
||||||
bool broadcast = false);
|
bool broadcast = false);
|
||||||
|
|
||||||
/** Deletes existing sidechain address owned by the given account for a given sidechain.
|
/** Deletes existing sidechain address owned by the given account for a given sidechain.
|
||||||
|
|
|
||||||
|
|
@ -2023,7 +2023,7 @@ public:
|
||||||
signed_transaction add_sidechain_address(string account,
|
signed_transaction add_sidechain_address(string account,
|
||||||
peerplays_sidechain::sidechain_type sidechain,
|
peerplays_sidechain::sidechain_type sidechain,
|
||||||
string deposit_address,
|
string deposit_address,
|
||||||
string withdrawal_address,
|
string withdraw_address,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
{ try {
|
{ try {
|
||||||
account_id_type sidechain_address_account_id = get_account_id(account);
|
account_id_type sidechain_address_account_id = get_account_id(account);
|
||||||
|
|
@ -2032,7 +2032,7 @@ public:
|
||||||
op.sidechain_address_account = sidechain_address_account_id;
|
op.sidechain_address_account = sidechain_address_account_id;
|
||||||
op.sidechain = sidechain;
|
op.sidechain = sidechain;
|
||||||
op.deposit_address = deposit_address;
|
op.deposit_address = deposit_address;
|
||||||
op.withdrawal_address = withdrawal_address;
|
op.withdraw_address = withdraw_address;
|
||||||
|
|
||||||
signed_transaction tx;
|
signed_transaction tx;
|
||||||
tx.operations.push_back( op );
|
tx.operations.push_back( op );
|
||||||
|
|
@ -2045,7 +2045,7 @@ public:
|
||||||
signed_transaction update_sidechain_address(string account,
|
signed_transaction update_sidechain_address(string account,
|
||||||
peerplays_sidechain::sidechain_type sidechain,
|
peerplays_sidechain::sidechain_type sidechain,
|
||||||
string deposit_address,
|
string deposit_address,
|
||||||
string withdrawal_address,
|
string withdraw_address,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
{ try {
|
{ try {
|
||||||
account_id_type sidechain_address_account_id = get_account_id(account);
|
account_id_type sidechain_address_account_id = get_account_id(account);
|
||||||
|
|
@ -2058,7 +2058,7 @@ public:
|
||||||
op.sidechain_address_account = sidechain_address_account_id;
|
op.sidechain_address_account = sidechain_address_account_id;
|
||||||
op.sidechain = sidechain;
|
op.sidechain = sidechain;
|
||||||
op.deposit_address = deposit_address;
|
op.deposit_address = deposit_address;
|
||||||
op.withdrawal_address = withdrawal_address;
|
op.withdraw_address = withdraw_address;
|
||||||
|
|
||||||
signed_transaction tx;
|
signed_transaction tx;
|
||||||
tx.operations.push_back( op );
|
tx.operations.push_back( op );
|
||||||
|
|
@ -4498,19 +4498,19 @@ vector<optional<son_wallet_object>> wallet_api::get_son_wallets(uint32_t limit)
|
||||||
signed_transaction wallet_api::add_sidechain_address(string account,
|
signed_transaction wallet_api::add_sidechain_address(string account,
|
||||||
peerplays_sidechain::sidechain_type sidechain,
|
peerplays_sidechain::sidechain_type sidechain,
|
||||||
string deposit_address,
|
string deposit_address,
|
||||||
string withdrawal_address,
|
string withdraw_address,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
{
|
{
|
||||||
return my->add_sidechain_address(account, sidechain, deposit_address, withdrawal_address, broadcast);
|
return my->add_sidechain_address(account, sidechain, deposit_address, withdraw_address, broadcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
signed_transaction wallet_api::update_sidechain_address(string account,
|
signed_transaction wallet_api::update_sidechain_address(string account,
|
||||||
peerplays_sidechain::sidechain_type sidechain,
|
peerplays_sidechain::sidechain_type sidechain,
|
||||||
string deposit_address,
|
string deposit_address,
|
||||||
string withdrawal_address,
|
string withdraw_address,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
{
|
{
|
||||||
return my->update_sidechain_address(account, sidechain, deposit_address, withdrawal_address, broadcast);
|
return my->update_sidechain_address(account, sidechain, deposit_address, withdraw_address, broadcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
signed_transaction wallet_api::delete_sidechain_address(string account,
|
signed_transaction wallet_api::delete_sidechain_address(string account,
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ BOOST_AUTO_TEST_CASE( sidechain_address_add_test ) {
|
||||||
op.sidechain_address_account = alice_id;
|
op.sidechain_address_account = alice_id;
|
||||||
op.sidechain = graphene::peerplays_sidechain::sidechain_type::bitcoin;
|
op.sidechain = graphene::peerplays_sidechain::sidechain_type::bitcoin;
|
||||||
op.deposit_address = "deposit_address";
|
op.deposit_address = "deposit_address";
|
||||||
op.withdrawal_address = "withdrawal_address";
|
op.withdraw_address = "withdraw_address";
|
||||||
|
|
||||||
trx.operations.push_back(op);
|
trx.operations.push_back(op);
|
||||||
sign(trx, alice_private_key);
|
sign(trx, alice_private_key);
|
||||||
|
|
@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE( sidechain_address_add_test ) {
|
||||||
BOOST_CHECK( obj->sidechain_address_account == alice_id );
|
BOOST_CHECK( obj->sidechain_address_account == alice_id );
|
||||||
BOOST_CHECK( obj->sidechain == graphene::peerplays_sidechain::sidechain_type::bitcoin );
|
BOOST_CHECK( obj->sidechain == graphene::peerplays_sidechain::sidechain_type::bitcoin );
|
||||||
BOOST_CHECK( obj->deposit_address == "deposit_address" );
|
BOOST_CHECK( obj->deposit_address == "deposit_address" );
|
||||||
BOOST_CHECK( obj->withdrawal_address == "withdrawal_address" );
|
BOOST_CHECK( obj->withdraw_address == "withdraw_address" );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( sidechain_address_update_test ) {
|
BOOST_AUTO_TEST_CASE( sidechain_address_update_test ) {
|
||||||
|
|
@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE( sidechain_address_update_test ) {
|
||||||
BOOST_REQUIRE( obj != idx.end() );
|
BOOST_REQUIRE( obj != idx.end() );
|
||||||
|
|
||||||
std::string new_deposit_address = "new_deposit_address";
|
std::string new_deposit_address = "new_deposit_address";
|
||||||
std::string new_withdrawal_address = "new_withdrawal_address";
|
std::string new_withdraw_address = "new_withdraw_address";
|
||||||
|
|
||||||
{
|
{
|
||||||
BOOST_TEST_MESSAGE("Send sidechain_address_update_operation");
|
BOOST_TEST_MESSAGE("Send sidechain_address_update_operation");
|
||||||
|
|
@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE( sidechain_address_update_test ) {
|
||||||
op.sidechain_address_account = obj->sidechain_address_account;
|
op.sidechain_address_account = obj->sidechain_address_account;
|
||||||
op.sidechain = obj->sidechain;
|
op.sidechain = obj->sidechain;
|
||||||
op.deposit_address = new_deposit_address;
|
op.deposit_address = new_deposit_address;
|
||||||
op.withdrawal_address = new_withdrawal_address;
|
op.withdraw_address = new_withdraw_address;
|
||||||
|
|
||||||
trx.operations.push_back(op);
|
trx.operations.push_back(op);
|
||||||
sign(trx, alice_private_key);
|
sign(trx, alice_private_key);
|
||||||
|
|
@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE( sidechain_address_update_test ) {
|
||||||
BOOST_CHECK( obj->sidechain_address_account == obj->sidechain_address_account );
|
BOOST_CHECK( obj->sidechain_address_account == obj->sidechain_address_account );
|
||||||
BOOST_CHECK( obj->sidechain == obj->sidechain );
|
BOOST_CHECK( obj->sidechain == obj->sidechain );
|
||||||
BOOST_CHECK( obj->deposit_address == new_deposit_address );
|
BOOST_CHECK( obj->deposit_address == new_deposit_address );
|
||||||
BOOST_CHECK( obj->withdrawal_address == new_withdrawal_address );
|
BOOST_CHECK( obj->withdraw_address == new_withdraw_address );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue