Compare commits

...

73 commits

Author SHA1 Message Date
Srdjan Obucina
6e93ef9fb9 Merge branch 'feature/SONs-base' into feature/SON-260 2020-02-21 20:12:16 +01:00
Srdjan Obucina
b3904bb2e6 Withdrawal refactoring 2020-02-20 23:43:50 +01:00
Srdjan Obucina
4a7e70c8d6 Withdrawal refactoring 2020-02-20 19:18:11 +01:00
Srdjan Obucina
cbfaefde83 Some refactoring 2020-02-20 14:37:42 +01:00
Srdjan Obucina
22c12f5041 Rename son_wallet_withdrawal* to son_wallet_withdraw* 2020-02-20 13:03:13 +01:00
Srdjan Obucina
9ac8bbe06a Extend sidechain_address_object to contain withdrawal addresses
- Withdrawal address is the address where system will send sidechain currencies
2020-02-20 02:28:53 +01:00
Srdjan Obucina
5a37d3ecd1 Renaming son_wallet_transfer* to son_wallet_deposit*, introducing son_wallet_withdrawal* 2020-02-19 16:31:11 +01:00
Srdjan Obucina
caba98cfe3 Merge branch 'feature/SONs-base' into feature/SON-260 2020-02-19 14:09:44 +01:00
Srdjan Obucina
4b01d8064f Full Peerplays listener, use GRAPHENE_SON_ACCOUNT instead son_btc_account 2020-02-19 05:08:10 +01:00
Srdjan Obucina
188a412143 Merge branch 'feature/SON-238' into feature/SON-260 2020-02-17 14:23:39 +01:00
Srdjan Obucina
7e596a67e6 Temoprary disable account history tests for tracking accounts 2020-02-17 14:17:43 +01:00
Srdjan Obucina
992b245d5b Skeleton of Peerplays network listener 2020-02-14 21:54:02 +01:00
Srdjan Obucina
b927ffa4d0 Skeleton of sidechain_net_handler_peerplays 2020-02-14 01:25:24 +01:00
Srdjan Obucina
75626254fa Add cmake command line option SUPPORT_MULTIPLE_SONS 2020-02-11 16:59:10 +01:00
Srdjan Obucina
0d14b481a4 Fix merging issue 2020-02-11 15:18:04 +01:00
Srdjan Obucina
da7b161d3d Merge branch 'feature/SONs-base' into feature/SON-238 2020-02-11 14:52:05 +01:00
Srdjan Obucina
df369df421 Move transfer inside son_wallet_transfer_process_operation 2020-02-10 19:17:56 +01:00
Srdjan Obucina
95ad384f0c Fix aprovals on already approved or invalid proposals 2020-02-10 06:40:05 +01:00
Srdjan Obucina
532afc062f Fix bad param 2020-02-10 02:04:30 +01:00
Srdjan Obucina
7f56e8e661 Managing GRAPHENE_SON_ACCOUNT and issuing assets on Bitcoin deposit 2020-02-10 01:53:15 +01:00
Srdjan Obucina
69cad0f1bd Add is_active_son guards, fix sending proposals and aprovals 2020-02-07 21:38:30 +01:00
Srdjan Obucina
98ebbbd69b Merge branch 'feature/SON-231' into feature/SON-238 2020-02-07 18:30:52 +01:00
Srdjan Obucina
2cc90a8794 Add is_active_son guards for sidechain events processing 2020-02-07 18:30:11 +01:00
Srdjan Obucina
5b1dea0d39 Support multiple SON nodes per software instance 2020-02-07 00:17:19 +01:00
Srdjan Obucina
9056ba6d07 Issue tokens to the user who deposited Bitcoin, WIP... 2020-02-05 20:19:47 +01:00
Srdjan Obucina
bb8d334e6c Add son_wallet_transfer_process_operation 2020-02-05 14:07:00 +01:00
Srdjan Obucina
01f1b6137a Issue tokens to the user who deposited Bitcoin, WIP... 2020-02-04 23:40:40 +01:00
Srdjan Obucina
23458ee917 Merge branch 'feature/SONs-base' into feature/SON-231 2020-02-04 20:00:25 +01:00
Srdjan Obucina
bbd2e35014 Remove duplicated item in CMakeLists.txt 2020-02-04 19:58:59 +01:00
Srdjan Obucina
89ca9167d3 Squashed commit of the following:
commit a688bb93ed
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 6e61d6b055
Author: satyakoneru <satyakoneru.iiith@gmail.com>
Date:   Tue Feb 4 00:14:39 2020 +1100

    SON233 - Provide correct downtime metrics to user (#278)
2020-02-04 19:56:20 +01:00
Srdjan Obucina
9db6179f79 Merge branch 'feature/SON-98' into feature/SON-231 2020-02-04 19:00:34 +01:00
Srdjan Obucina
5c57f5d9c8 Remove redundant file 2020-02-04 18:16:27 +01:00
Srdjan Obucina
703c577d90 Merge branch 'feature/SON-98' into feature/SON-231 2020-02-03 20:13:51 +01:00
Srdjan Obucina
263ba5d15b Fix failing son_wallet_tests
- Check for son_btc_account is temporarely disabled
2020-02-03 18:59:02 +01:00
Srdjan Obucina
ca112b1eb6 Merge branch 'feature/SON-98' into feature/SON-231 2020-01-31 23:55:59 +01:00
Srdjan Obucina
f62a46e789 Merge branch 'feature/SONs-base' into feature/SON-98 2020-01-31 23:53:31 +01:00
Srdjan Obucina
5b7dd86ab9 Quickfix for checking payer in evaluator 2020-01-31 23:52:18 +01:00
Srdjan Obucina
2bb3fc79d7 Quickfix for checking payer in evaluator 2020-01-31 23:36:13 +01:00
Srdjan Obucina
c5ea418321 PW recreation refactoring, prevent duplicated recreations, update wallet address through proposal 2020-01-31 23:28:20 +01:00
Srdjan Obucina
afcb1ace1b PW recreation refactoring, prevent duplicated recreations, update wallet address through proposal 2020-01-31 21:53:51 +01:00
Srdjan Obucina
0c7ef96178 Refactor primary wallet recreation 2020-01-31 15:32:46 +01:00
Srdjan Obucina
95b515c09a Merge branch 'feature/SON-98' into feature/SON-231 2020-01-30 18:32:36 +01:00
Srdjan Obucina
01a1f584df Merge branch 'feature/SONs-base' into feature/SON-98 2020-01-30 18:31:52 +01:00
Srdjan Obucina
f6c1da53df Refactor primary wallet recreation 2020-01-30 18:25:15 +01:00
Srdjan Obucina
d048873601 Merge branch 'feature/SONs-base' into feature/SON-231 2020-01-29 21:18:22 +01:00
Srdjan Obucina
42b7d25a99 SON wallet transfer object and operations, for tracking assets deposit/withdrawal 2020-01-29 17:09:37 +01:00
Srdjan Obucina
775fdf8980 SON wallet transfer object and operations, for tracking assets deposit/withdrawal 2020-01-28 22:10:35 +01:00
Srdjan Obucina
6055576aa4 Merge branch 'feature/SON-98' into feature/SON-231 2020-01-28 16:45:35 +01:00
Srdjan Obucina
1808082d59 Fix #include <graphene/chain/son_wallet_transfer_object.hpp> 2020-01-28 14:53:27 +01:00
obucinac
9c1eb63d15
Update libraries/chain/include/graphene/chain/protocol/son_wallet.hpp
Co-Authored-By: gladcow <jahr@yandex.ru>
2020-01-28 14:16:21 +01:00
obucinac
4590f919dc
Update libraries/chain/include/graphene/chain/protocol/son_wallet.hpp
Co-Authored-By: gladcow <jahr@yandex.ru>
2020-01-28 14:16:11 +01:00
Srdjan Obucina
be60f65612 Merge branch 'feature/SONs-base' into feature/SON-98 2020-01-28 14:13:16 +01:00
Srdjan Obucina
df7ee459f9 SON wallet transfer object and operations, for tracking assets deposit/withdrawal 2020-01-28 14:04:31 +01:00
Srdjan Obucina
0142348a9c Updating wallet info through operation instead through database.modify() for persistance 2020-01-27 13:14:22 +01:00
Srdjan Obucina
8399008e7d Wallet recreation by scheduled SON only, some cosmetic refactoring 2020-01-24 16:51:45 +01:00
Srdjan Obucina
7ceed83a95 Wallet recreation by scheduled SON only, some cosmetic refactoring 2020-01-24 16:50:25 +01:00
Srdjan Obucina
a6e14af38f Merge branch 'feature/SONs-base' into feature/SON-98 2020-01-23 13:16:45 +01:00
Srdjan Obucina
7abfa78ad6 Merge branch 'feature/SONs-base' into feature/SON-98 2020-01-22 13:51:12 +01:00
Srdjan Obucina
0b491510c4 Send RPC command to bitcoin node to recreate multisig wallet 2020-01-22 13:44:11 +01:00
Srdjan Obucina
f0a8e8e376 Send RPC command to bitcoin node to recreate multisig wallet 2020-01-22 02:43:24 +01:00
Srdjan Obucina
c25108f228 Send RPC command to bitcoin node to recreate multisig wallet 2020-01-21 04:32:19 +01:00
Srdjan Obucina
23cb5310b0 Merge branch 'feature/SONs-base' into feature/SON-98 2020-01-21 02:58:03 +01:00
Srdjan Obucina
ebb6662210 Merge branch 'feature/SONs-base' into feature/SON-98 2020-01-20 13:11:23 +01:00
Srdjan Obucina
1dc0eee6b6 son_wallet_object API and cli wallet commands 2020-01-18 00:35:25 +01:00
Srdjan Obucina
b06e1d680a Create son_wallet_object on new set of SONs, to initiate primary wallet recreation 2020-01-17 21:32:44 +01:00
Srdjan Obucina
2615c41224 son_wallet_object operations completed, basic tests added 2020-01-17 14:56:44 +01:00
Srdjan Obucina
6f0c025462 son_wallet_object operations 2020-01-17 05:29:23 +01:00
Srdjan Obucina
61b8ff0cc7 son_wallet_object operations 2020-01-16 08:07:18 +01:00
Srdjan Obucina
2b8a39e332 Merge branch 'feature/SONs-base' into feature/SON-98 2020-01-16 07:55:57 +01:00
Srdjan Obucina
ba255da679 Merge branch 'feature/SONs-base' into feature/SON-98 2020-01-15 12:56:37 +01:00
Srdjan Obucina
0e47eeccf2 Merge branch 'feature/SONs-base' into feature/SON-98 2020-01-13 10:02:01 +01:00
Srdjan Obucina
6421d5e852 Introduce son_wallet_object 2020-01-03 03:25:46 +01:00
Srdjan Obucina
2e124b07c6 Extend GPO.active_sons to contain votes and all public keys 2019-12-26 06:31:21 +01:00
41 changed files with 843 additions and 412 deletions

View file

@ -322,10 +322,16 @@ struct get_impacted_account_visitor
void operator()( const son_wallet_update_operation& op ){ void operator()( const son_wallet_update_operation& op ){
_impacted.insert( op.payer ); _impacted.insert( op.payer );
} }
void operator()( const son_wallet_transfer_create_operation& op ){ void operator()( const son_wallet_deposit_create_operation& op ){
_impacted.insert( op.payer ); _impacted.insert( op.payer );
} }
void operator()( const son_wallet_transfer_process_operation& op ){ void operator()( const son_wallet_deposit_process_operation& op ){
_impacted.insert( op.payer );
}
void operator()( const son_wallet_withdraw_create_operation& op ){
_impacted.insert( op.payer );
}
void operator()( const son_wallet_withdraw_process_operation& op ){
_impacted.insert( op.payer ); _impacted.insert( op.payer );
} }
void operator()( const sidechain_address_add_operation& op ){ void operator()( const sidechain_address_add_operation& op ){

3
libraries/chain/CMakeLists.txt Normal file → Executable file
View file

@ -118,7 +118,8 @@ add_library( graphene_chain
son_object.cpp son_object.cpp
son_wallet_evaluator.cpp son_wallet_evaluator.cpp
son_wallet_transfer_evaluator.cpp son_wallet_deposit_evaluator.cpp
son_wallet_withdraw_evaluator.cpp
sidechain_address_evaluator.cpp sidechain_address_evaluator.cpp

View file

@ -57,7 +57,8 @@
#include <graphene/chain/son_object.hpp> #include <graphene/chain/son_object.hpp>
#include <graphene/chain/son_proposal_object.hpp> #include <graphene/chain/son_proposal_object.hpp>
#include <graphene/chain/son_wallet_object.hpp> #include <graphene/chain/son_wallet_object.hpp>
#include <graphene/chain/son_wallet_transfer_object.hpp> #include <graphene/chain/son_wallet_deposit_object.hpp>
#include <graphene/chain/son_wallet_withdraw_object.hpp>
#include <graphene/chain/sidechain_address_object.hpp> #include <graphene/chain/sidechain_address_object.hpp>
#include <graphene/chain/account_evaluator.hpp> #include <graphene/chain/account_evaluator.hpp>
@ -82,7 +83,8 @@
#include <graphene/chain/tournament_evaluator.hpp> #include <graphene/chain/tournament_evaluator.hpp>
#include <graphene/chain/son_evaluator.hpp> #include <graphene/chain/son_evaluator.hpp>
#include <graphene/chain/son_wallet_evaluator.hpp> #include <graphene/chain/son_wallet_evaluator.hpp>
#include <graphene/chain/son_wallet_transfer_evaluator.hpp> #include <graphene/chain/son_wallet_deposit_evaluator.hpp>
#include <graphene/chain/son_wallet_withdraw_evaluator.hpp>
#include <graphene/chain/sidechain_address_evaluator.hpp> #include <graphene/chain/sidechain_address_evaluator.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp> #include <graphene/chain/protocol/fee_schedule.hpp>
@ -258,8 +260,10 @@ void database::initialize_evaluators()
register_evaluator<son_maintenance_evaluator>(); register_evaluator<son_maintenance_evaluator>();
register_evaluator<recreate_son_wallet_evaluator>(); register_evaluator<recreate_son_wallet_evaluator>();
register_evaluator<update_son_wallet_evaluator>(); register_evaluator<update_son_wallet_evaluator>();
register_evaluator<create_son_wallet_transfer_evaluator>(); register_evaluator<create_son_wallet_deposit_evaluator>();
register_evaluator<process_son_wallet_transfer_evaluator>(); register_evaluator<process_son_wallet_deposit_evaluator>();
register_evaluator<create_son_wallet_withdraw_evaluator>();
register_evaluator<process_son_wallet_withdraw_evaluator>();
register_evaluator<add_sidechain_address_evaluator>(); register_evaluator<add_sidechain_address_evaluator>();
register_evaluator<update_sidechain_address_evaluator>(); register_evaluator<update_sidechain_address_evaluator>();
register_evaluator<delete_sidechain_address_evaluator>(); register_evaluator<delete_sidechain_address_evaluator>();
@ -308,7 +312,8 @@ void database::initialize_indexes()
add_index< primary_index<son_proposal_index> >(); add_index< primary_index<son_proposal_index> >();
add_index< primary_index<son_wallet_index> >(); add_index< primary_index<son_wallet_index> >();
add_index< primary_index<son_wallet_transfer_index> >(); add_index< primary_index<son_wallet_deposit_index> >();
add_index< primary_index<son_wallet_withdraw_index> >();
add_index< primary_index<sidechain_address_index> >(); add_index< primary_index<sidechain_address_index> >();

View file

@ -457,8 +457,9 @@ void database::update_active_sons()
a.active.account_auths[weight.first] += votes; a.active.account_auths[weight.first] += votes;
a.active.weight_threshold += votes; a.active.weight_threshold += votes;
} }
a.active.weight_threshold /= 2; a.active.weight_threshold *= 2;
a.active.weight_threshold /= 3;
a.active.weight_threshold += 1; a.active.weight_threshold += 1;
} }
else else
@ -466,12 +467,11 @@ void database::update_active_sons()
vote_counter vc; vote_counter vc;
for( const son_object& son : sons ) for( const son_object& son : sons )
vc.add( son.son_account, std::max(_vote_tally_buffer[son.vote_id], UINT64_C(1)) ); vc.add( son.son_account, std::max(_vote_tally_buffer[son.vote_id], UINT64_C(1)) );
vc.finish( a.active ); vc.finish_2_3( a.active );
} }
} ); } );
// Compare current and to-be lists of active sons // Compare current and to-be lists of active sons
//const global_property_object& gpo = get_global_properties();
auto cur_active_sons = gpo.active_sons; auto cur_active_sons = gpo.active_sons;
vector<son_info> new_active_sons; vector<son_info> new_active_sons;
for( const son_object& son : sons ) { for( const son_object& son : sons ) {
@ -602,83 +602,6 @@ void database::update_active_sons()
update_son_metrics(); update_son_metrics();
if(gpo.active_sons.size() > 0 ) {
if(gpo.parameters.get_son_btc_account_id() == GRAPHENE_NULL_ACCOUNT) {
const auto& son_btc_account = create<account_object>( [&]( account_object& obj ) {
uint64_t total_votes = 0;
obj.name = "son_btc_account";
obj.statistics = create<account_statistics_object>([&]( account_statistics_object& acc_stat ){ acc_stat.owner = obj.id; }).id;
obj.membership_expiration_date = time_point_sec::maximum();
obj.network_fee_percentage = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
obj.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT - GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
for( const auto& son_info : gpo.active_sons )
{
const son_object& son = get(son_info.son_id);
total_votes += _vote_tally_buffer[son.vote_id];
}
// total_votes is 64 bits. Subtract the number of leading low bits from 64 to get the number of useful bits,
// then I want to keep the most significant 16 bits of what's left.
int8_t bits_to_drop = std::max(int(boost::multiprecision::detail::find_msb(total_votes)) - 15, 0);
for( const auto& son_info : gpo.active_sons )
{
// Ensure that everyone has at least one vote. Zero weights aren't allowed.
const son_object& son = get(son_info.son_id);
uint16_t votes = std::max((_vote_tally_buffer[son.vote_id] >> bits_to_drop), uint64_t(1) );
obj.owner.account_auths[son.son_account] += votes;
obj.owner.weight_threshold += votes;
obj.active.account_auths[son.son_account] += votes;
obj.active.weight_threshold += votes;
}
obj.owner.weight_threshold *= 2;
obj.owner.weight_threshold /= 3;
obj.owner.weight_threshold += 1;
obj.active.weight_threshold *= 2;
obj.active.weight_threshold /= 3;
obj.active.weight_threshold += 1;
});
modify( gpo, [&]( global_property_object& gpo ) {
gpo.parameters.extensions.value.son_btc_account = son_btc_account.get_id();
if( gpo.pending_parameters )
gpo.pending_parameters->extensions.value.son_btc_account = son_btc_account.get_id();
});
} else {
modify( get(gpo.parameters.get_son_btc_account_id()), [&]( account_object& obj )
{
uint64_t total_votes = 0;
obj.owner.weight_threshold = 0;
obj.owner.account_auths.clear();
obj.active.weight_threshold = 0;
obj.active.account_auths.clear();
for( const auto& son_info : gpo.active_sons )
{
const son_object& son = get(son_info.son_id);
total_votes += _vote_tally_buffer[son.vote_id];
}
// total_votes is 64 bits. Subtract the number of leading low bits from 64 to get the number of useful bits,
// then I want to keep the most significant 16 bits of what's left.
int8_t bits_to_drop = std::max(int(boost::multiprecision::detail::find_msb(total_votes)) - 15, 0);
for( const auto& son_info : gpo.active_sons )
{
// Ensure that everyone has at least one vote. Zero weights aren't allowed.
const son_object& son = get(son_info.son_id);
uint16_t votes = std::max((_vote_tally_buffer[son.vote_id] >> bits_to_drop), uint64_t(1) );
obj.owner.account_auths[son.son_account] += votes;
obj.owner.weight_threshold += votes;
obj.active.account_auths[son.son_account] += votes;
obj.active.weight_threshold += votes;
}
obj.owner.weight_threshold *= 2;
obj.owner.weight_threshold /= 3;
obj.owner.weight_threshold += 1;
obj.active.weight_threshold *= 2;
obj.active.weight_threshold /= 3;
obj.active.weight_threshold += 1;
});
}
}
} FC_CAPTURE_AND_RETHROW() } } FC_CAPTURE_AND_RETHROW() }
void database::initialize_budget_record( fc::time_point_sec now, budget_record& rec )const void database::initialize_budget_record( fc::time_point_sec now, budget_record& rec )const

View file

@ -309,10 +309,16 @@ struct get_impacted_account_visitor
void operator()( const son_wallet_update_operation& op ) { void operator()( const son_wallet_update_operation& op ) {
_impacted.insert( op.payer ); _impacted.insert( op.payer );
} }
void operator()( const son_wallet_transfer_create_operation& op ) { void operator()( const son_wallet_deposit_create_operation& op ) {
_impacted.insert( op.payer ); _impacted.insert( op.payer );
} }
void operator()( const son_wallet_transfer_process_operation& op ) { void operator()( const son_wallet_deposit_process_operation& op ) {
_impacted.insert( op.payer );
}
void operator()( const son_wallet_withdraw_create_operation& op ) {
_impacted.insert( op.payer );
}
void operator()( const son_wallet_withdraw_process_operation& op ) {
_impacted.insert( op.payer ); _impacted.insert( op.payer );
} }
void operator()( const sidechain_address_add_operation& op ) { void operator()( const sidechain_address_add_operation& op ) {
@ -419,7 +425,9 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
break; break;
} case son_wallet_object_type:{ } case son_wallet_object_type:{
break; break;
} case son_wallet_transfer_object_type:{ } case son_wallet_deposit_object_type:{
break;
} case son_wallet_withdraw_object_type:{
break; break;
} case sidechain_address_object_type:{ } case sidechain_address_object_type:{
const auto& aobj = dynamic_cast<const sidechain_address_object*>(obj); const auto& aobj = dynamic_cast<const sidechain_address_object*>(obj);

View file

@ -46,7 +46,6 @@ namespace graphene { namespace chain {
optional < uint32_t > son_vesting_amount; optional < uint32_t > son_vesting_amount;
optional < uint32_t > son_vesting_period; optional < uint32_t > son_vesting_period;
optional < uint32_t > son_pay_daily_max; optional < uint32_t > son_pay_daily_max;
optional < account_id_type > son_btc_account;
}; };
struct chain_parameters struct chain_parameters
@ -139,9 +138,6 @@ namespace graphene { namespace chain {
inline uint16_t son_pay_daily_max()const { inline uint16_t son_pay_daily_max()const {
return extensions.value.son_pay_daily_max.valid() ? *extensions.value.son_pay_daily_max : MIN_SON_PAY_DAILY_MAX; return extensions.value.son_pay_daily_max.valid() ? *extensions.value.son_pay_daily_max : MIN_SON_PAY_DAILY_MAX;
} }
inline account_id_type get_son_btc_account_id() const {
return extensions.value.son_btc_account.valid() ? *extensions.value.son_btc_account : GRAPHENE_NULL_ACCOUNT;
}
}; };
} } // graphene::chain } } // graphene::chain
@ -159,7 +155,6 @@ FC_REFLECT( graphene::chain::parameter_extension,
(son_vesting_amount) (son_vesting_amount)
(son_vesting_period) (son_vesting_period)
(son_pay_daily_max) (son_pay_daily_max)
(son_btc_account)
) )
FC_REFLECT( graphene::chain::chain_parameters, FC_REFLECT( graphene::chain::chain_parameters,

View file

@ -48,7 +48,8 @@
#include <graphene/chain/protocol/son.hpp> #include <graphene/chain/protocol/son.hpp>
#include <graphene/chain/protocol/sidechain_address.hpp> #include <graphene/chain/protocol/sidechain_address.hpp>
#include <graphene/chain/protocol/son_wallet.hpp> #include <graphene/chain/protocol/son_wallet.hpp>
#include <graphene/chain/protocol/son_wallet_transfer.hpp> #include <graphene/chain/protocol/son_wallet_deposit.hpp>
#include <graphene/chain/protocol/son_wallet_withdraw.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
@ -148,8 +149,10 @@ namespace graphene { namespace chain {
son_maintenance_operation, son_maintenance_operation,
son_wallet_recreate_operation, son_wallet_recreate_operation,
son_wallet_update_operation, son_wallet_update_operation,
son_wallet_transfer_create_operation, son_wallet_deposit_create_operation,
son_wallet_transfer_process_operation, son_wallet_deposit_process_operation,
son_wallet_withdraw_create_operation,
son_wallet_withdraw_process_operation,
sidechain_address_add_operation, sidechain_address_add_operation,
sidechain_address_update_operation, sidechain_address_update_operation,
sidechain_address_delete_operation sidechain_address_delete_operation

View file

@ -12,9 +12,8 @@ namespace graphene { namespace chain {
asset fee; asset fee;
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 address; string deposit_address;
string private_key; string withdraw_address;
string public_key;
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,9 +27,8 @@ namespace graphene { namespace chain {
sidechain_address_id_type sidechain_address_id; sidechain_address_id_type sidechain_address_id;
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> address; optional<string> deposit_address;
optional<string> private_key; optional<string> withdraw_address;
optional<string> public_key;
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; }
@ -53,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)(address)(private_key)(public_key) ) (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)(address)(private_key)(public_key) ) (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)

View file

@ -1,9 +1,11 @@
#pragma once #pragma once
#include <graphene/chain/protocol/base.hpp> #include <graphene/chain/protocol/base.hpp>
#include <fc/safe.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
struct son_wallet_transfer_create_operation : public base_operation struct son_wallet_deposit_create_operation : public base_operation
{ {
struct fee_parameters_type { uint64_t fee = 0; }; struct fee_parameters_type { uint64_t fee = 0; };
@ -16,23 +18,24 @@ namespace graphene { namespace chain {
std::string sidechain_transaction_id; std::string sidechain_transaction_id;
std::string sidechain_from; std::string sidechain_from;
std::string sidechain_to; std::string sidechain_to;
int64_t sidechain_amount; std::string sidechain_currency;
fc::safe<int64_t> sidechain_amount;
chain::account_id_type peerplays_from; chain::account_id_type peerplays_from;
chain::account_id_type peerplays_to; chain::account_id_type peerplays_to;
chain::asset peerplays_amount; chain::asset peerplays_asset;
account_id_type fee_payer()const { return payer; } account_id_type fee_payer()const { return payer; }
share_type calculate_fee(const fee_parameters_type& k)const { return 0; } share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
}; };
struct son_wallet_transfer_process_operation : public base_operation struct son_wallet_deposit_process_operation : public base_operation
{ {
struct fee_parameters_type { uint64_t fee = 0; }; struct fee_parameters_type { uint64_t fee = 0; };
asset fee; asset fee;
account_id_type payer; account_id_type payer;
son_wallet_transfer_id_type son_wallet_transfer_id; son_wallet_deposit_id_type son_wallet_deposit_id;
account_id_type fee_payer()const { return payer; } account_id_type fee_payer()const { return payer; }
share_type calculate_fee(const fee_parameters_type& k)const { return 0; } share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
@ -40,9 +43,9 @@ namespace graphene { namespace chain {
} } // namespace graphene::chain } } // namespace graphene::chain
FC_REFLECT(graphene::chain::son_wallet_transfer_create_operation::fee_parameters_type, (fee) ) FC_REFLECT(graphene::chain::son_wallet_deposit_create_operation::fee_parameters_type, (fee) )
FC_REFLECT(graphene::chain::son_wallet_transfer_create_operation, (fee)(payer) FC_REFLECT(graphene::chain::son_wallet_deposit_create_operation, (fee)(payer)
(timestamp) (sidechain) (sidechain_uid) (sidechain_transaction_id) (sidechain_from) (sidechain_to) (sidechain_amount) (peerplays_from) (peerplays_to) (peerplays_amount)) (timestamp) (sidechain) (sidechain_uid) (sidechain_transaction_id) (sidechain_from) (sidechain_to) (sidechain_currency) (sidechain_amount) (peerplays_from) (peerplays_to) (peerplays_asset))
FC_REFLECT(graphene::chain::son_wallet_transfer_process_operation::fee_parameters_type, (fee) ) FC_REFLECT(graphene::chain::son_wallet_deposit_process_operation::fee_parameters_type, (fee) )
FC_REFLECT(graphene::chain::son_wallet_transfer_process_operation, (fee)(payer) FC_REFLECT(graphene::chain::son_wallet_deposit_process_operation, (fee)(payer)
(son_wallet_transfer_id)) (son_wallet_deposit_id))

View file

@ -0,0 +1,50 @@
#pragma once
#include <graphene/chain/protocol/base.hpp>
#include <fc/safe.hpp>
namespace graphene { namespace chain {
struct son_wallet_withdraw_create_operation : public base_operation
{
struct fee_parameters_type { uint64_t fee = 0; };
asset fee;
account_id_type payer;
fc::time_point_sec timestamp;
peerplays_sidechain::sidechain_type sidechain;
std::string peerplays_uid;
std::string peerplays_transaction_id;
chain::account_id_type peerplays_from;
chain::asset peerplays_asset;
peerplays_sidechain::sidechain_type withdraw_sidechain;
std::string withdraw_address;
std::string withdraw_currency;
safe<int64_t> withdraw_amount;
account_id_type fee_payer()const { return payer; }
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
};
struct son_wallet_withdraw_process_operation : public base_operation
{
struct fee_parameters_type { uint64_t fee = 0; };
asset fee;
account_id_type payer;
son_wallet_withdraw_id_type son_wallet_withdraw_id;
account_id_type fee_payer()const { return payer; }
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
};
} } // namespace graphene::chain
FC_REFLECT(graphene::chain::son_wallet_withdraw_create_operation::fee_parameters_type, (fee) )
FC_REFLECT(graphene::chain::son_wallet_withdraw_create_operation, (fee)(payer)
(timestamp) (sidechain) (peerplays_uid) (peerplays_transaction_id) (peerplays_from) (peerplays_asset) (withdraw_sidechain) (withdraw_address) (withdraw_currency) (withdraw_amount) )
FC_REFLECT(graphene::chain::son_wallet_withdraw_process_operation::fee_parameters_type, (fee) )
FC_REFLECT(graphene::chain::son_wallet_withdraw_process_operation, (fee)(payer)
(son_wallet_withdraw_id))

View file

@ -148,7 +148,8 @@ namespace graphene { namespace chain {
son_object_type, son_object_type,
son_proposal_object_type, son_proposal_object_type,
son_wallet_object_type, son_wallet_object_type,
son_wallet_transfer_object_type, son_wallet_deposit_object_type,
son_wallet_withdraw_object_type,
sidechain_address_object_type, sidechain_address_object_type,
OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types
}; };
@ -214,7 +215,8 @@ namespace graphene { namespace chain {
class son_object; class son_object;
class son_proposal_object; class son_proposal_object;
class son_wallet_object; class son_wallet_object;
class son_wallet_transfer_object; class son_wallet_deposit_object;
class son_wallet_withdraw_object;
class sidechain_address_object; class sidechain_address_object;
typedef object_id< protocol_ids, account_object_type, account_object> account_id_type; typedef object_id< protocol_ids, account_object_type, account_object> account_id_type;
@ -245,7 +247,8 @@ namespace graphene { namespace chain {
typedef object_id< protocol_ids, son_object_type, son_object> son_id_type; typedef object_id< protocol_ids, son_object_type, son_object> son_id_type;
typedef object_id< protocol_ids, son_proposal_object_type, son_proposal_object> son_proposal_id_type; typedef object_id< protocol_ids, son_proposal_object_type, son_proposal_object> son_proposal_id_type;
typedef object_id< protocol_ids, son_wallet_object_type, son_wallet_object> son_wallet_id_type; typedef object_id< protocol_ids, son_wallet_object_type, son_wallet_object> son_wallet_id_type;
typedef object_id< protocol_ids, son_wallet_transfer_object_type, son_wallet_transfer_object> son_wallet_transfer_id_type; typedef object_id< protocol_ids, son_wallet_deposit_object_type, son_wallet_deposit_object> son_wallet_deposit_id_type;
typedef object_id< protocol_ids, son_wallet_withdraw_object_type, son_wallet_withdraw_object> son_wallet_withdraw_id_type;
typedef object_id< protocol_ids, sidechain_address_object_type, sidechain_address_object> sidechain_address_id_type; typedef object_id< protocol_ids, sidechain_address_object_type, sidechain_address_object> sidechain_address_id_type;
// implementation types // implementation types
@ -434,7 +437,8 @@ FC_REFLECT_ENUM( graphene::chain::object_type,
(son_object_type) (son_object_type)
(son_proposal_object_type) (son_proposal_object_type)
(son_wallet_object_type) (son_wallet_object_type)
(son_wallet_transfer_object_type) (son_wallet_deposit_object_type)
(son_wallet_withdraw_object_type)
(sidechain_address_object_type) (sidechain_address_object_type)
(OBJECT_TYPE_COUNT) (OBJECT_TYPE_COUNT)
) )
@ -510,7 +514,8 @@ FC_REFLECT_TYPENAME( graphene::chain::tournament_details_id_type )
FC_REFLECT_TYPENAME( graphene::chain::son_id_type ) FC_REFLECT_TYPENAME( graphene::chain::son_id_type )
FC_REFLECT_TYPENAME( graphene::chain::son_proposal_id_type ) FC_REFLECT_TYPENAME( graphene::chain::son_proposal_id_type )
FC_REFLECT_TYPENAME( graphene::chain::son_wallet_id_type ) FC_REFLECT_TYPENAME( graphene::chain::son_wallet_id_type )
FC_REFLECT_TYPENAME( graphene::chain::son_wallet_transfer_id_type ) FC_REFLECT_TYPENAME( graphene::chain::son_wallet_deposit_id_type )
FC_REFLECT_TYPENAME( graphene::chain::son_wallet_withdraw_id_type )
FC_REFLECT_TYPENAME( graphene::chain::sidechain_address_id_type ) FC_REFLECT_TYPENAME( graphene::chain::sidechain_address_id_type )

View file

@ -21,21 +21,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 address; string deposit_address;
string private_key; string withdraw_address;
string public_key;
sidechain_address_object() : sidechain_address_object() :
sidechain(graphene::peerplays_sidechain::sidechain_type::bitcoin), sidechain(graphene::peerplays_sidechain::sidechain_type::bitcoin),
address(""), deposit_address(""),
private_key(""), withdraw_address("") {}
public_key("") {}
}; };
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_address; struct by_sidechain_and_deposit_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<
@ -54,10 +52,10 @@ namespace graphene { namespace chain {
member<sidechain_address_object, peerplays_sidechain::sidechain_type, &sidechain_address_object::sidechain> member<sidechain_address_object, peerplays_sidechain::sidechain_type, &sidechain_address_object::sidechain>
> >
>, >,
ordered_unique< tag<by_sidechain_and_address>, ordered_unique< tag<by_sidechain_and_deposit_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::address> member<sidechain_address_object, std::string, &sidechain_address_object::deposit_address>
> >
> >
> >
@ -67,4 +65,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)(address)(private_key)(public_key) ) (sidechain_address_account) (sidechain) (deposit_address) (withdraw_address) )

View file

@ -0,0 +1,24 @@
#pragma once
#include <graphene/chain/evaluator.hpp>
namespace graphene { namespace chain {
class create_son_wallet_deposit_evaluator : public evaluator<create_son_wallet_deposit_evaluator>
{
public:
typedef son_wallet_deposit_create_operation operation_type;
void_result do_evaluate(const son_wallet_deposit_create_operation& o);
object_id_type do_apply(const son_wallet_deposit_create_operation& o);
};
class process_son_wallet_deposit_evaluator : public evaluator<process_son_wallet_deposit_evaluator>
{
public:
typedef son_wallet_deposit_process_operation operation_type;
void_result do_evaluate(const son_wallet_deposit_process_operation& o);
object_id_type do_apply(const son_wallet_deposit_process_operation& o);
};
} } // namespace graphene::chain

View file

@ -6,15 +6,15 @@ namespace graphene { namespace chain {
using namespace graphene::db; using namespace graphene::db;
/** /**
* @class son_wallet_transfer_object * @class son_wallet_deposit_object
* @brief tracks information about a SON wallet transfer. * @brief tracks information about a SON wallet deposit.
* @ingroup object * @ingroup object
*/ */
class son_wallet_transfer_object : public abstract_object<son_wallet_transfer_object> class son_wallet_deposit_object : public abstract_object<son_wallet_deposit_object>
{ {
public: public:
static const uint8_t space_id = protocol_ids; static const uint8_t space_id = protocol_ids;
static const uint8_t type_id = son_wallet_transfer_object_type; static const uint8_t type_id = son_wallet_deposit_object_type;
time_point_sec timestamp; time_point_sec timestamp;
peerplays_sidechain::sidechain_type sidechain; peerplays_sidechain::sidechain_type sidechain;
@ -23,10 +23,11 @@ namespace graphene { namespace chain {
std::string sidechain_transaction_id; std::string sidechain_transaction_id;
std::string sidechain_from; std::string sidechain_from;
std::string sidechain_to; std::string sidechain_to;
int64_t sidechain_amount; std::string sidechain_currency;
safe<int64_t> sidechain_amount;
chain::account_id_type peerplays_from; chain::account_id_type peerplays_from;
chain::account_id_type peerplays_to; chain::account_id_type peerplays_to;
chain::asset peerplays_amount; chain::asset peerplays_asset;
bool processed; bool processed;
}; };
@ -35,34 +36,34 @@ namespace graphene { namespace chain {
struct by_sidechain_uid; struct by_sidechain_uid;
struct by_processed; struct by_processed;
struct by_sidechain_and_processed; struct by_sidechain_and_processed;
using son_wallet_transfer_multi_index_type = multi_index_container< using son_wallet_deposit_multi_index_type = multi_index_container<
son_wallet_transfer_object, son_wallet_deposit_object,
indexed_by< indexed_by<
ordered_unique< tag<by_id>, ordered_unique< tag<by_id>,
member<object, object_id_type, &object::id> member<object, object_id_type, &object::id>
>, >,
ordered_non_unique< tag<by_sidechain>, ordered_non_unique< tag<by_sidechain>,
member<son_wallet_transfer_object, peerplays_sidechain::sidechain_type, &son_wallet_transfer_object::sidechain> member<son_wallet_deposit_object, peerplays_sidechain::sidechain_type, &son_wallet_deposit_object::sidechain>
>, >,
ordered_unique< tag<by_sidechain_uid>, ordered_unique< tag<by_sidechain_uid>,
member<son_wallet_transfer_object, std::string, &son_wallet_transfer_object::sidechain_uid> member<son_wallet_deposit_object, std::string, &son_wallet_deposit_object::sidechain_uid>
>, >,
ordered_non_unique< tag<by_processed>, ordered_non_unique< tag<by_processed>,
member<son_wallet_transfer_object, bool, &son_wallet_transfer_object::processed> member<son_wallet_deposit_object, bool, &son_wallet_deposit_object::processed>
>, >,
ordered_non_unique< tag<by_sidechain_and_processed>, ordered_non_unique< tag<by_sidechain_and_processed>,
composite_key<son_wallet_transfer_object, composite_key<son_wallet_deposit_object,
member<son_wallet_transfer_object, peerplays_sidechain::sidechain_type, &son_wallet_transfer_object::sidechain>, member<son_wallet_deposit_object, peerplays_sidechain::sidechain_type, &son_wallet_deposit_object::sidechain>,
member<son_wallet_transfer_object, bool, &son_wallet_transfer_object::processed> member<son_wallet_deposit_object, bool, &son_wallet_deposit_object::processed>
> >
> >
> >
>; >;
using son_wallet_transfer_index = generic_index<son_wallet_transfer_object, son_wallet_transfer_multi_index_type>; using son_wallet_deposit_index = generic_index<son_wallet_deposit_object, son_wallet_deposit_multi_index_type>;
} } // graphene::chain } } // graphene::chain
FC_REFLECT_DERIVED( graphene::chain::son_wallet_transfer_object, (graphene::db::object), FC_REFLECT_DERIVED( graphene::chain::son_wallet_deposit_object, (graphene::db::object),
(timestamp) (sidechain) (confirmations) (timestamp) (sidechain) (confirmations)
(sidechain_uid) (sidechain_transaction_id) (sidechain_from) (sidechain_to) (sidechain_amount) (sidechain_uid) (sidechain_transaction_id) (sidechain_from) (sidechain_to) (sidechain_currency) (sidechain_amount)
(peerplays_from) (peerplays_to) (peerplays_amount) (peerplays_from) (peerplays_to) (peerplays_asset)
(processed) ) (processed) )

View file

@ -1,24 +0,0 @@
#pragma once
#include <graphene/chain/evaluator.hpp>
namespace graphene { namespace chain {
class create_son_wallet_transfer_evaluator : public evaluator<create_son_wallet_transfer_evaluator>
{
public:
typedef son_wallet_transfer_create_operation operation_type;
void_result do_evaluate(const son_wallet_transfer_create_operation& o);
object_id_type do_apply(const son_wallet_transfer_create_operation& o);
};
class process_son_wallet_transfer_evaluator : public evaluator<process_son_wallet_transfer_evaluator>
{
public:
typedef son_wallet_transfer_process_operation operation_type;
void_result do_evaluate(const son_wallet_transfer_process_operation& o);
object_id_type do_apply(const son_wallet_transfer_process_operation& o);
};
} } // namespace graphene::chain

View file

@ -0,0 +1,24 @@
#pragma once
#include <graphene/chain/evaluator.hpp>
namespace graphene { namespace chain {
class create_son_wallet_withdraw_evaluator : public evaluator<create_son_wallet_withdraw_evaluator>
{
public:
typedef son_wallet_withdraw_create_operation operation_type;
void_result do_evaluate(const son_wallet_withdraw_create_operation& o);
object_id_type do_apply(const son_wallet_withdraw_create_operation& o);
};
class process_son_wallet_withdraw_evaluator : public evaluator<process_son_wallet_withdraw_evaluator>
{
public:
typedef son_wallet_withdraw_process_operation operation_type;
void_result do_evaluate(const son_wallet_withdraw_process_operation& o);
object_id_type do_apply(const son_wallet_withdraw_process_operation& o);
};
} } // namespace graphene::chain

View file

@ -0,0 +1,67 @@
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/peerplays_sidechain/defs.hpp>
namespace graphene { namespace chain {
using namespace graphene::db;
/**
* @class son_wallet_withdraw_object
* @brief tracks information about a SON wallet withdrawal.
* @ingroup object
*/
class son_wallet_withdraw_object : public abstract_object<son_wallet_withdraw_object>
{
public:
static const uint8_t space_id = protocol_ids;
static const uint8_t type_id = son_wallet_withdraw_object_type;
time_point_sec timestamp;
peerplays_sidechain::sidechain_type sidechain;
int64_t confirmations;
std::string peerplays_uid;
std::string peerplays_transaction_id;
chain::account_id_type peerplays_from;
chain::asset peerplays_asset;
peerplays_sidechain::sidechain_type withdraw_sidechain;
std::string withdraw_address;
std::string withdraw_currency;
safe<int64_t> withdraw_amount;
bool processed;
};
struct by_peerplays_uid;
struct by_withdraw_sidechain;
struct by_processed;
struct by_withdraw_sidechain_and_processed;
using son_wallet_withdraw_multi_index_type = multi_index_container<
son_wallet_withdraw_object,
indexed_by<
ordered_unique< tag<by_id>,
member<object, object_id_type, &object::id>
>,
ordered_unique< tag<by_peerplays_uid>,
member<son_wallet_withdraw_object, std::string, &son_wallet_withdraw_object::peerplays_uid>
>,
ordered_non_unique< tag<by_withdraw_sidechain>,
member<son_wallet_withdraw_object, peerplays_sidechain::sidechain_type, &son_wallet_withdraw_object::withdraw_sidechain>
>,
ordered_non_unique< tag<by_processed>,
member<son_wallet_withdraw_object, bool, &son_wallet_withdraw_object::processed>
>,
ordered_non_unique< tag<by_withdraw_sidechain_and_processed>,
composite_key<son_wallet_withdraw_object,
member<son_wallet_withdraw_object, peerplays_sidechain::sidechain_type, &son_wallet_withdraw_object::withdraw_sidechain>,
member<son_wallet_withdraw_object, bool, &son_wallet_withdraw_object::processed>
>
>
>
>;
using son_wallet_withdraw_index = generic_index<son_wallet_withdraw_object, son_wallet_withdraw_multi_index_type>;
} } // graphene::chain
FC_REFLECT_DERIVED( graphene::chain::son_wallet_withdraw_object, (graphene::db::object),
(timestamp) (sidechain) (confirmations)
(peerplays_uid) (peerplays_transaction_id) (peerplays_from) (peerplays_asset)
(withdraw_sidechain) (withdraw_address) (withdraw_currency) (withdraw_amount)
(processed) )

View file

@ -63,6 +63,17 @@ struct vote_counter
out_auth = auth; out_auth = auth;
} }
void finish_2_3( authority& out_auth )
{
if( total_votes == 0 )
return;
assert( total_votes <= std::numeric_limits<uint32_t>::max() );
uint32_t weight = uint32_t( total_votes );
weight = (weight * 2 / 3) + 1;
auth.weight_threshold = weight;
out_auth = auth;
}
bool is_empty()const bool is_empty()const
{ {
return (total_votes == 0); return (total_votes == 0);

View file

@ -19,9 +19,8 @@ object_id_type add_sidechain_address_evaluator::do_apply(const sidechain_address
const auto& new_sidechain_address_object = db().create<sidechain_address_object>( [&]( sidechain_address_object& obj ){ const auto& new_sidechain_address_object = db().create<sidechain_address_object>( [&]( sidechain_address_object& obj ){
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.address = op.address; obj.deposit_address = op.deposit_address;
obj.private_key = op.private_key; obj.withdraw_address = op.withdraw_address;
obj.public_key = op.public_key;
}); });
return new_sidechain_address_object.id; return new_sidechain_address_object.id;
} FC_CAPTURE_AND_RETHROW( (op) ) } } FC_CAPTURE_AND_RETHROW( (op) ) }
@ -41,9 +40,8 @@ object_id_type update_sidechain_address_evaluator::do_apply(const sidechain_addr
if(itr != idx.end()) if(itr != idx.end())
{ {
db().modify(*itr, [&op](sidechain_address_object &sao) { db().modify(*itr, [&op](sidechain_address_object &sao) {
if(op.address.valid()) sao.address = *op.address; if(op.deposit_address.valid()) sao.deposit_address = *op.deposit_address;
if(op.private_key.valid()) sao.private_key = *op.private_key; if(op.withdraw_address.valid()) sao.withdraw_address = *op.withdraw_address;
if(op.public_key.valid()) sao.public_key = *op.public_key;
}); });
} }
return op.sidechain_address_id; return op.sidechain_address_id;

View file

@ -166,7 +166,7 @@ object_id_type son_heartbeat_evaluator::do_apply(const son_heartbeat_operation&
void_result son_report_down_evaluator::do_evaluate(const son_report_down_operation& op) void_result son_report_down_evaluator::do_evaluate(const son_report_down_operation& op)
{ try { { try {
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK"); // can be removed after HF date pass FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK"); // can be removed after HF date pass
FC_ASSERT(op.payer == db().get_global_properties().parameters.get_son_btc_account_id(), "Payer should be the son btc account"); FC_ASSERT(op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer.");
const auto& idx = db().get_index_type<son_index>().indices().get<by_id>(); const auto& idx = db().get_index_type<son_index>().indices().get<by_id>();
FC_ASSERT( idx.find(op.son_id) != idx.end() ); FC_ASSERT( idx.find(op.son_id) != idx.end() );
auto itr = idx.find(op.son_id); auto itr = idx.find(op.son_id);

View file

@ -1,28 +1,27 @@
#include <graphene/chain/son_wallet_transfer_evaluator.hpp> #include <graphene/chain/son_wallet_deposit_evaluator.hpp>
#include <graphene/chain/database.hpp> #include <graphene/chain/database.hpp>
#include <graphene/chain/is_authorized_asset.hpp> #include <graphene/chain/is_authorized_asset.hpp>
#include <graphene/chain/son_wallet_transfer_object.hpp> #include <graphene/chain/son_wallet_deposit_object.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
void_result create_son_wallet_transfer_evaluator::do_evaluate(const son_wallet_transfer_create_operation& op) void_result create_son_wallet_deposit_evaluator::do_evaluate(const son_wallet_deposit_create_operation& op)
{ try{ { try{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK"); FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
//FC_ASSERT(db().get_global_properties().parameters.get_son_btc_account_id() != GRAPHENE_NULL_ACCOUNT, "SON paying account not set."); FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
FC_ASSERT( op.payer == db().get_global_properties().parameters.get_son_btc_account_id(), "SON paying account must be set as payer." );
//const auto& idx = db().get_index_type<son_wallet_transfer_index>().indices().get<by_sidechain_uid>(); //const auto& idx = db().get_index_type<son_wallet_deposit_index>().indices().get<by_sidechain_uid>();
//FC_ASSERT(idx.find(op.sidechain_uid) == idx.end(), "Already registered " + op.sidechain_uid); //FC_ASSERT(idx.find(op.sidechain_uid) == idx.end(), "Already registered " + op.sidechain_uid);
return void_result(); return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) } } FC_CAPTURE_AND_RETHROW( (op) ) }
object_id_type create_son_wallet_transfer_evaluator::do_apply(const son_wallet_transfer_create_operation& op) object_id_type create_son_wallet_deposit_evaluator::do_apply(const son_wallet_deposit_create_operation& op)
{ try { { try {
const auto& idx = db().get_index_type<son_wallet_transfer_index>().indices().get<by_sidechain_uid>(); const auto& idx = db().get_index_type<son_wallet_deposit_index>().indices().get<by_sidechain_uid>();
auto itr = idx.find(op.sidechain_uid); auto itr = idx.find(op.sidechain_uid);
if (itr == idx.end()) { if (itr == idx.end()) {
const auto& new_son_wallet_transfer_object = db().create<son_wallet_transfer_object>( [&]( son_wallet_transfer_object& swto ){ const auto& new_son_wallet_deposit_object = db().create<son_wallet_deposit_object>( [&]( son_wallet_deposit_object& swto ){
swto.timestamp = op.timestamp; swto.timestamp = op.timestamp;
swto.sidechain = op.sidechain; swto.sidechain = op.sidechain;
swto.confirmations = 1; swto.confirmations = 1;
@ -33,26 +32,25 @@ object_id_type create_son_wallet_transfer_evaluator::do_apply(const son_wallet_t
swto.sidechain_amount = op.sidechain_amount; swto.sidechain_amount = op.sidechain_amount;
swto.peerplays_from = op.peerplays_from; swto.peerplays_from = op.peerplays_from;
swto.peerplays_to = op.peerplays_to; swto.peerplays_to = op.peerplays_to;
swto.peerplays_amount = op.peerplays_amount; swto.peerplays_asset = op.peerplays_asset;
swto.processed = false; swto.processed = false;
}); });
return new_son_wallet_transfer_object.id; return new_son_wallet_deposit_object.id;
} else { } else {
db().modify(*itr, [&op](son_wallet_transfer_object &swto) { db().modify(*itr, [&op](son_wallet_deposit_object &swto) {
swto.confirmations = swto.confirmations + 1; swto.confirmations = swto.confirmations + 1;
}); });
return (*itr).id; return (*itr).id;
} }
} FC_CAPTURE_AND_RETHROW( (op) ) } } FC_CAPTURE_AND_RETHROW( (op) ) }
void_result process_son_wallet_transfer_evaluator::do_evaluate(const son_wallet_transfer_process_operation& op) void_result process_son_wallet_deposit_evaluator::do_evaluate(const son_wallet_deposit_process_operation& op)
{ try{ { try{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK"); FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
//FC_ASSERT(db().get_global_properties().parameters.get_son_btc_account_id() != GRAPHENE_NULL_ACCOUNT, "SON paying account not set."); FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
FC_ASSERT( op.payer == db().get_global_properties().parameters.get_son_btc_account_id(), "SON paying account must be set as payer." );
const auto& idx = db().get_index_type<son_wallet_transfer_index>().indices().get<by_id>(); const auto& idx = db().get_index_type<son_wallet_deposit_index>().indices().get<by_id>();
const auto& itr = idx.find(op.son_wallet_transfer_id); const auto& itr = idx.find(op.son_wallet_deposit_id);
FC_ASSERT(itr != idx.end(), "Son wallet transfer not found"); FC_ASSERT(itr != idx.end(), "Son wallet transfer not found");
//FC_ASSERT(itr->processed == false, "Son wallet transfer is already processed"); //FC_ASSERT(itr->processed == false, "Son wallet transfer is already processed");
@ -60,7 +58,7 @@ void_result process_son_wallet_transfer_evaluator::do_evaluate(const son_wallet_
const account_object& from_account = itr->peerplays_to(d); // reversed, for deposit const account_object& from_account = itr->peerplays_to(d); // reversed, for deposit
const account_object& to_account = itr->peerplays_from(d); // reversed, for deposit const account_object& to_account = itr->peerplays_from(d); // reversed, for deposit
const asset_object& asset_type = itr->peerplays_amount.asset_id(d); const asset_object& asset_type = itr->peerplays_asset.asset_id(d);
try { try {
@ -69,14 +67,14 @@ void_result process_son_wallet_transfer_evaluator::do_evaluate(const son_wallet_
transfer_from_account_not_whitelisted, transfer_from_account_not_whitelisted,
"'from' account ${from} is not whitelisted for asset ${asset}", "'from' account ${from} is not whitelisted for asset ${asset}",
("from",from_account.id) ("from",from_account.id)
("asset",itr->peerplays_amount.asset_id) ("asset",itr->peerplays_asset.asset_id)
); );
GRAPHENE_ASSERT( GRAPHENE_ASSERT(
is_authorized_asset( d, to_account, asset_type ), is_authorized_asset( d, to_account, asset_type ),
transfer_to_account_not_whitelisted, transfer_to_account_not_whitelisted,
"'to' account ${to} is not whitelisted for asset ${asset}", "'to' account ${to} is not whitelisted for asset ${asset}",
("to",to_account.id) ("to",to_account.id)
("asset",itr->peerplays_amount.asset_id) ("asset",itr->peerplays_asset.asset_id)
); );
if( asset_type.is_transfer_restricted() ) if( asset_type.is_transfer_restricted() )
@ -85,38 +83,38 @@ void_result process_son_wallet_transfer_evaluator::do_evaluate(const son_wallet_
from_account.id == asset_type.issuer || to_account.id == asset_type.issuer, from_account.id == asset_type.issuer || to_account.id == asset_type.issuer,
transfer_restricted_transfer_asset, transfer_restricted_transfer_asset,
"Asset {asset} has transfer_restricted flag enabled", "Asset {asset} has transfer_restricted flag enabled",
("asset", itr->peerplays_amount.asset_id) ("asset", itr->peerplays_asset.asset_id)
); );
} }
bool insufficient_balance = d.get_balance( from_account, asset_type ).amount >= itr->peerplays_amount.amount; bool insufficient_balance = d.get_balance( from_account, asset_type ).amount >= itr->peerplays_asset.amount;
FC_ASSERT( insufficient_balance, FC_ASSERT( insufficient_balance,
"Insufficient Balance: ${balance}, unable to transfer '${total_transfer}' from account '${a}' to '${t}'", "Insufficient Balance: ${balance}, unable to transfer '${total_transfer}' from account '${a}' to '${t}'",
("a",from_account.name)("t",to_account.name)("total_transfer",d.to_pretty_string(itr->peerplays_amount))("balance",d.to_pretty_string(d.get_balance(from_account, asset_type))) ); ("a",from_account.name)("t",to_account.name)("total_transfer",d.to_pretty_string(itr->peerplays_asset))("balance",d.to_pretty_string(d.get_balance(from_account, asset_type))) );
return void_result(); return void_result();
} FC_RETHROW_EXCEPTIONS( error, "Unable to transfer ${a} from ${f} to ${t}", ("a",d.to_pretty_string(itr->peerplays_amount))("f",from_account.name)("t",to_account.name) ); } FC_RETHROW_EXCEPTIONS( error, "Unable to transfer ${a} from ${f} to ${t}", ("a",d.to_pretty_string(itr->peerplays_asset))("f",from_account.name)("t",to_account.name) );
} FC_CAPTURE_AND_RETHROW( (op) ) } } FC_CAPTURE_AND_RETHROW( (op) ) }
object_id_type process_son_wallet_transfer_evaluator::do_apply(const son_wallet_transfer_process_operation& op) object_id_type process_son_wallet_deposit_evaluator::do_apply(const son_wallet_deposit_process_operation& op)
{ try { { try {
const auto& idx = db().get_index_type<son_wallet_transfer_index>().indices().get<by_id>(); const auto& idx = db().get_index_type<son_wallet_deposit_index>().indices().get<by_id>();
auto itr = idx.find(op.son_wallet_transfer_id); auto itr = idx.find(op.son_wallet_deposit_id);
if(itr != idx.end()) if(itr != idx.end())
{ {
if (itr->processed == false) { if (itr->processed == false) {
db().modify(*itr, [&op](son_wallet_transfer_object &swto) { db().modify(*itr, [&op](son_wallet_deposit_object &swto) {
swto.processed = true; swto.processed = true;
}); });
const account_id_type from_account = itr->peerplays_to; // reversed, for deposit const account_id_type from_account = itr->peerplays_to; // reversed, for deposit
const account_id_type to_account = itr->peerplays_from; // reversed, for deposit const account_id_type to_account = itr->peerplays_from; // reversed, for deposit
db().adjust_balance( from_account, -itr->peerplays_amount ); db().adjust_balance( from_account, -itr->peerplays_asset );
db().adjust_balance( to_account, itr->peerplays_amount ); db().adjust_balance( to_account, itr->peerplays_asset );
} }
} }
return op.son_wallet_transfer_id; return op.son_wallet_deposit_id;
} FC_CAPTURE_AND_RETHROW( (op) ) } } FC_CAPTURE_AND_RETHROW( (op) ) }
} } // namespace graphene::chain } } // namespace graphene::chain

View file

@ -8,8 +8,7 @@ namespace graphene { namespace chain {
void_result recreate_son_wallet_evaluator::do_evaluate(const son_wallet_recreate_operation& op) void_result recreate_son_wallet_evaluator::do_evaluate(const son_wallet_recreate_operation& op)
{ try{ { try{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK"); FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
//FC_ASSERT(db().get_global_properties().parameters.get_son_btc_account_id() != GRAPHENE_NULL_ACCOUNT, "SON paying account not set."); FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
FC_ASSERT( op.payer == db().get_global_properties().parameters.get_son_btc_account_id(), "SON paying account must be set as payer." );
const auto& idx = db().get_index_type<son_wallet_index>().indices().get<by_id>(); const auto& idx = db().get_index_type<son_wallet_index>().indices().get<by_id>();
auto itr = idx.rbegin(); auto itr = idx.rbegin();
@ -54,8 +53,7 @@ object_id_type recreate_son_wallet_evaluator::do_apply(const son_wallet_recreate
void_result update_son_wallet_evaluator::do_evaluate(const son_wallet_update_operation& op) void_result update_son_wallet_evaluator::do_evaluate(const son_wallet_update_operation& op)
{ try{ { try{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK"); FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
//FC_ASSERT(db().get_global_properties().parameters.get_son_btc_account_id() != GRAPHENE_NULL_ACCOUNT, "SON paying account not set."); FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
FC_ASSERT( op.payer == db().get_global_properties().parameters.get_son_btc_account_id(), "SON paying account must be set as payer." );
const auto& idx = db().get_index_type<son_wallet_index>().indices().get<by_id>(); const auto& idx = db().get_index_type<son_wallet_index>().indices().get<by_id>();
FC_ASSERT( idx.find(op.son_wallet_id) != idx.end() ); FC_ASSERT( idx.find(op.son_wallet_id) != idx.end() );

View file

@ -0,0 +1,70 @@
#include <graphene/chain/son_wallet_withdraw_evaluator.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/is_authorized_asset.hpp>
#include <graphene/chain/son_wallet_withdraw_object.hpp>
namespace graphene { namespace chain {
void_result create_son_wallet_withdraw_evaluator::do_evaluate(const son_wallet_withdraw_create_operation& op)
{ try{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }
object_id_type create_son_wallet_withdraw_evaluator::do_apply(const son_wallet_withdraw_create_operation& op)
{ try {
const auto& idx = db().get_index_type<son_wallet_withdraw_index>().indices().get<by_peerplays_uid>();
auto itr = idx.find(op.peerplays_uid);
if (itr == idx.end()) {
const auto& new_son_wallet_withdraw_object = db().create<son_wallet_withdraw_object>( [&]( son_wallet_withdraw_object& swwo ){
swwo.timestamp = op.timestamp;
swwo.sidechain = op.sidechain;
swwo.confirmations = 1;
swwo.peerplays_uid = op.peerplays_uid;
swwo.peerplays_transaction_id = op.peerplays_transaction_id;
swwo.peerplays_from = op.peerplays_from;
swwo.peerplays_asset = op.peerplays_asset;
swwo.withdraw_sidechain = op.withdraw_sidechain;
swwo.withdraw_address = op.withdraw_address;
swwo.withdraw_currency = op.withdraw_currency;
swwo.withdraw_amount = op.withdraw_amount;
swwo.processed = false;
});
return new_son_wallet_withdraw_object.id;
} else {
db().modify(*itr, [&op](son_wallet_withdraw_object &swto) {
swto.confirmations = swto.confirmations + 1;
});
return (*itr).id;
}
} FC_CAPTURE_AND_RETHROW( (op) ) }
void_result process_son_wallet_withdraw_evaluator::do_evaluate(const son_wallet_withdraw_process_operation& op)
{ try{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
const auto& idx = db().get_index_type<son_wallet_withdraw_index>().indices().get<by_id>();
const auto& itr = idx.find(op.son_wallet_withdraw_id);
FC_ASSERT(itr != idx.end(), "Son wallet withdraw not found");
} FC_CAPTURE_AND_RETHROW( (op) ) }
object_id_type process_son_wallet_withdraw_evaluator::do_apply(const son_wallet_withdraw_process_operation& op)
{ try {
const auto& idx = db().get_index_type<son_wallet_withdraw_index>().indices().get<by_id>();
auto itr = idx.find(op.son_wallet_withdraw_id);
if(itr != idx.end())
{
if (itr->processed == false) {
db().modify(*itr, [&op](son_wallet_withdraw_object &swto) {
swto.processed = true;
});
}
}
return op.son_wallet_withdraw_id;
} FC_CAPTURE_AND_RETHROW( (op) ) }
} } // namespace graphene::chain

1
libraries/plugins/peerplays_sidechain/CMakeLists.txt Normal file → Executable file
View file

@ -5,6 +5,7 @@ add_library( peerplays_sidechain
sidechain_net_manager.cpp sidechain_net_manager.cpp
sidechain_net_handler.cpp sidechain_net_handler.cpp
sidechain_net_handler_bitcoin.cpp sidechain_net_handler_bitcoin.cpp
sidechain_net_handler_peerplays.cpp
bitcoin_utils.cpp bitcoin_utils.cpp
) )

View file

@ -4,9 +4,11 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <fc/safe.hpp>
#include <fc/time.hpp> #include <fc/time.hpp>
#include <fc/crypto/sha256.hpp> #include <fc/crypto/sha256.hpp>
#include <graphene/chain/protocol/asset.hpp>
#include <graphene/chain/protocol/types.hpp> #include <graphene/chain/protocol/types.hpp>
namespace graphene { namespace peerplays_sidechain { namespace graphene { namespace peerplays_sidechain {
@ -70,9 +72,11 @@ struct sidechain_event_data {
std::string sidechain_transaction_id; std::string sidechain_transaction_id;
std::string sidechain_from; std::string sidechain_from;
std::string sidechain_to; std::string sidechain_to;
int64_t sidechain_amount; std::string sidechain_currency;
fc::safe<int64_t> sidechain_amount;
chain::account_id_type peerplays_from; chain::account_id_type peerplays_from;
chain::account_id_type peerplays_to; chain::account_id_type peerplays_to;
chain::asset peerplays_asset;
}; };
} } // graphene::peerplays_sidechain } } // graphene::peerplays_sidechain

View file

@ -16,11 +16,16 @@ public:
virtual ~sidechain_net_handler(); virtual ~sidechain_net_handler();
graphene::peerplays_sidechain::sidechain_type get_sidechain(); graphene::peerplays_sidechain::sidechain_type get_sidechain();
std::vector<std::string> get_sidechain_addresses(); std::vector<std::string> get_sidechain_deposit_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_deposit(const son_wallet_deposit_object& swdo) = 0;
virtual void process_withdrawals() = 0;
virtual void process_withdrawal(const son_wallet_withdraw_object& swwo) = 0;
protected: protected:
peerplays_sidechain_plugin& plugin; peerplays_sidechain_plugin& plugin;
@ -32,8 +37,6 @@ protected:
virtual std::string sign_transaction( const std::string& transaction ) = 0; virtual std::string sign_transaction( const std::string& transaction ) = 0;
virtual std::string send_transaction( const std::string& transaction ) = 0; virtual std::string send_transaction( const std::string& transaction ) = 0;
virtual void handle_event( const std::string& event_data ) = 0;
private: private:
}; };

View file

@ -7,7 +7,6 @@
#include <fc/signals.hpp> #include <fc/signals.hpp>
#include <fc/network/http/connection.hpp> #include <fc/network/http/connection.hpp>
#include <graphene/chain/database.hpp>
namespace graphene { namespace peerplays_sidechain { namespace graphene { namespace peerplays_sidechain {
@ -72,8 +71,10 @@ public:
virtual ~sidechain_net_handler_bitcoin(); virtual ~sidechain_net_handler_bitcoin();
void recreate_primary_wallet(); void recreate_primary_wallet();
void process_deposits();
bool connection_is_not_defined() const; void process_deposit(const son_wallet_deposit_object& swdo);
void process_withdrawals();
void process_withdrawal(const son_wallet_withdraw_object& swwo);
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 );

View file

@ -0,0 +1,34 @@
#pragma once
#include <graphene/peerplays_sidechain/sidechain_net_handler.hpp>
#include <string>
#include <fc/signals.hpp>
namespace graphene { namespace peerplays_sidechain {
class sidechain_net_handler_peerplays : public sidechain_net_handler {
public:
sidechain_net_handler_peerplays(peerplays_sidechain_plugin& _plugin, const boost::program_options::variables_map& options);
virtual ~sidechain_net_handler_peerplays();
void recreate_primary_wallet();
void process_deposits();
void process_deposit(const son_wallet_deposit_object& swdo);
void process_withdrawals();
void process_withdrawal(const son_wallet_withdraw_object& swwo);
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 sign_transaction( const std::string& transaction );
std::string send_transaction( const std::string& transaction );
private:
void on_block_applied(const signed_block& b);
};
} } // graphene::peerplays_sidechain

View file

@ -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;

View file

@ -10,7 +10,7 @@
#include <graphene/chain/proposal_object.hpp> #include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/sidechain_address_object.hpp> #include <graphene/chain/sidechain_address_object.hpp>
#include <graphene/chain/son_wallet_object.hpp> #include <graphene/chain/son_wallet_object.hpp>
#include <graphene/chain/son_wallet_transfer_object.hpp> #include <graphene/chain/son_wallet_withdraw_object.hpp>
#include <graphene/chain/protocol/transfer.hpp> #include <graphene/chain/protocol/transfer.hpp>
#include <graphene/peerplays_sidechain/sidechain_net_manager.hpp> #include <graphene/peerplays_sidechain/sidechain_net_manager.hpp>
#include <graphene/utilities/key_conversion.hpp> #include <graphene/utilities/key_conversion.hpp>
@ -46,27 +46,30 @@ class peerplays_sidechain_plugin_impl
void create_son_down_proposals(); void create_son_down_proposals();
void recreate_primary_wallet(); void recreate_primary_wallet();
void process_deposits(); void process_deposits();
//void process_withdrawals(); void process_withdrawals();
void on_block_applied( const signed_block& b );
void on_objects_new(const vector<object_id_type>& new_object_ids);
private: private:
peerplays_sidechain_plugin& plugin; peerplays_sidechain_plugin& plugin;
bool config_ready_son; bool config_ready_son;
bool config_ready_bitcoin; bool config_ready_bitcoin;
bool config_ready_peerplays;
std::unique_ptr<peerplays_sidechain::sidechain_net_manager> net_manager; std::unique_ptr<peerplays_sidechain::sidechain_net_manager> net_manager;
std::map<chain::public_key_type, fc::ecc::private_key> _private_keys; std::map<chain::public_key_type, fc::ecc::private_key> _private_keys;
std::set<chain::son_id_type> _sons; std::set<chain::son_id_type> _sons;
fc::future<void> _heartbeat_task; fc::future<void> _heartbeat_task;
void on_block_applied( const signed_block& b );
void on_objects_new(const vector<object_id_type>& new_object_ids);
}; };
peerplays_sidechain_plugin_impl::peerplays_sidechain_plugin_impl(peerplays_sidechain_plugin& _plugin) : peerplays_sidechain_plugin_impl::peerplays_sidechain_plugin_impl(peerplays_sidechain_plugin& _plugin) :
plugin(_plugin), plugin(_plugin),
config_ready_son(false), config_ready_son(false),
config_ready_bitcoin(false), config_ready_bitcoin(false),
config_ready_peerplays(false),
net_manager(nullptr) net_manager(nullptr)
{ {
} }
@ -177,6 +180,14 @@ void peerplays_sidechain_plugin_impl::plugin_initialize(const boost::program_opt
// wlog("Haven't set up Ethereum sidechain parameters"); // wlog("Haven't set up Ethereum sidechain parameters");
//} //}
config_ready_peerplays = true;
if (config_ready_peerplays) {
net_manager->create_handler(sidechain_type::peerplays, options);
ilog("Peerplays sidechain handler created");
} else {
wlog("Haven't set up Peerplays sidechain parameters");
}
if (!(config_ready_bitcoin /*&& config_ready_ethereum*/)) { if (!(config_ready_bitcoin /*&& config_ready_ethereum*/)) {
wlog("Haven't set up any sidechain parameters"); wlog("Haven't set up any sidechain parameters");
throw; throw;
@ -200,6 +211,10 @@ void peerplays_sidechain_plugin_impl::plugin_startup()
//if (config_ready_ethereum) { //if (config_ready_ethereum) {
// ilog("Ethereum sidechain handler running"); // ilog("Ethereum sidechain handler running");
//} //}
if (config_ready_peerplays) {
ilog("Peerplays sidechain handler running");
}
} }
std::set<chain::son_id_type>& peerplays_sidechain_plugin_impl::get_sons() std::set<chain::son_id_type>& peerplays_sidechain_plugin_impl::get_sons()
@ -307,7 +322,7 @@ void peerplays_sidechain_plugin_impl::create_son_down_proposals()
auto son_obj = idx.find( my_son_id ); auto son_obj = idx.find( my_son_id );
chain::son_report_down_operation son_down_op; chain::son_report_down_operation son_down_op;
son_down_op.payer = gpo.parameters.get_son_btc_account_id(); son_down_op.payer = GRAPHENE_SON_ACCOUNT;
son_down_op.son_id = son_id; son_down_op.son_id = son_id;
son_down_op.down_ts = last_active_ts; son_down_op.down_ts = last_active_ts;
@ -360,47 +375,15 @@ void peerplays_sidechain_plugin_impl::recreate_primary_wallet()
net_manager->recreate_primary_wallet(); net_manager->recreate_primary_wallet();
} }
void peerplays_sidechain_plugin_impl::process_deposits() { void peerplays_sidechain_plugin_impl::process_deposits()
{
const auto& idx = plugin.database().get_index_type<son_wallet_transfer_index>().indices().get<by_processed>(); net_manager->process_deposits();
const auto& idx_range = idx.equal_range(false);
std::for_each(idx_range.first, idx_range.second,
[&] (const son_wallet_transfer_object& swto) {
const chain::global_property_object& gpo = plugin.database().get_global_properties();
for (son_id_type son_id : plugin.get_sons()) {
if (plugin.is_active_son(son_id)) {
son_wallet_transfer_process_operation p_op;
p_op.payer = gpo.parameters.get_son_btc_account_id();
p_op.son_wallet_transfer_id = swto.id;
proposal_create_operation proposal_op;
proposal_op.fee_paying_account = plugin.get_son_object(son_id).son_account;
proposal_op.proposed_ops.emplace_back( op_wrapper( p_op ) );
uint32_t lifetime = ( gpo.parameters.block_interval * gpo.active_witnesses.size() ) * 3;
proposal_op.expiration_time = time_point_sec( plugin.database().head_block_time().sec_since_epoch() + lifetime );
ilog("sidechain_net_handler: sending proposal for transfer operation ${swto} by ${son}", ("swto", swto.id) ("son", son_id));
signed_transaction trx = plugin.database().create_signed_transaction(plugin.get_private_key(son_id), proposal_op);
trx.validate();
ilog("sidechain_net_handler: transaction validated ${swto} by ${son}", ("swto", swto.id) ("son", son_id));
try {
plugin.database().push_transaction(trx, database::validation_steps::skip_block_size_check);
if(plugin.app().p2p_node())
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
} catch(fc::exception e){
ilog("sidechain_net_handler: sending proposal for transfer operation failed with exception ${e}",("e", e.what()));
}
}
}
});
} }
//void peerplays_sidechain_plugin_impl::process_withdrawals() { void peerplays_sidechain_plugin_impl::process_withdrawals()
//} {
net_manager->process_withdrawals();
}
void peerplays_sidechain_plugin_impl::on_block_applied( const signed_block& b ) void peerplays_sidechain_plugin_impl::on_block_applied( const signed_block& b )
{ {
@ -423,7 +406,7 @@ void peerplays_sidechain_plugin_impl::on_block_applied( const signed_block& b )
process_deposits(); process_deposits();
//process_withdrawals(); process_withdrawals();
} }
} }
@ -481,13 +464,25 @@ void peerplays_sidechain_plugin_impl::on_objects_new(const vector<object_id_type
} }
if(proposal->proposed_transaction.operations.size() == 1 if(proposal->proposed_transaction.operations.size() == 1
&& proposal->proposed_transaction.operations[0].which() == chain::operation::tag<chain::son_wallet_transfer_create_operation>::value) { && proposal->proposed_transaction.operations[0].which() == chain::operation::tag<chain::son_wallet_deposit_create_operation>::value) {
approve_proposal( son_id, proposal->id ); approve_proposal( son_id, proposal->id );
continue; continue;
} }
if(proposal->proposed_transaction.operations.size() == 1 if(proposal->proposed_transaction.operations.size() == 1
&& proposal->proposed_transaction.operations[0].which() == chain::operation::tag<chain::son_wallet_transfer_process_operation>::value) { && proposal->proposed_transaction.operations[0].which() == chain::operation::tag<chain::son_wallet_deposit_process_operation>::value) {
approve_proposal( son_id, proposal->id );
continue;
}
if(proposal->proposed_transaction.operations.size() == 1
&& proposal->proposed_transaction.operations[0].which() == chain::operation::tag<chain::son_wallet_withdraw_create_operation>::value) {
approve_proposal( son_id, proposal->id );
continue;
}
if(proposal->proposed_transaction.operations.size() == 1
&& proposal->proposed_transaction.operations[0].which() == chain::operation::tag<chain::son_wallet_withdraw_process_operation>::value) {
approve_proposal( son_id, proposal->id ); approve_proposal( son_id, proposal->id );
continue; continue;
} }

View file

@ -1,6 +1,8 @@
#include <graphene/peerplays_sidechain/sidechain_net_handler.hpp> #include <graphene/peerplays_sidechain/sidechain_net_handler.hpp>
#include <graphene/chain/sidechain_address_object.hpp> #include <graphene/chain/sidechain_address_object.hpp>
#include <graphene/chain/son_wallet_deposit_object.hpp>
#include <graphene/chain/son_wallet_withdraw_object.hpp>
#include <fc/log/logger.hpp> #include <fc/log/logger.hpp>
@ -19,25 +21,29 @@ graphene::peerplays_sidechain::sidechain_type sidechain_net_handler::get_sidecha
return sidechain; return sidechain;
} }
std::vector<std::string> sidechain_net_handler::get_sidechain_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) { return result;
result.push_back(sao.address); }
});
break;
}
default:
assert(false);
}
std::vector<std::string> sidechain_net_handler::get_sidechain_withdraw_addresses() {
std::vector<std::string> result;
const auto& sidechain_addresses_idx = database.get_index_type<sidechain_address_index>();
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.withdraw_address);
});
return result; return result;
} }
@ -49,44 +55,181 @@ void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_
ilog( " sidechain_transaction_id: ${transaction_id}", ( "transaction_id", sed.sidechain_transaction_id ) ); ilog( " sidechain_transaction_id: ${transaction_id}", ( "transaction_id", sed.sidechain_transaction_id ) );
ilog( " sidechain_from: ${from}", ( "from", sed.sidechain_from ) ); ilog( " sidechain_from: ${from}", ( "from", sed.sidechain_from ) );
ilog( " sidechain_to: ${to}", ( "to", sed.sidechain_to ) ); ilog( " sidechain_to: ${to}", ( "to", sed.sidechain_to ) );
ilog( " sidechain_currency: ${currency}", ( "currency", sed.sidechain_currency ) );
ilog( " sidechain_amount: ${amount}", ( "amount", sed.sidechain_amount ) ); ilog( " sidechain_amount: ${amount}", ( "amount", sed.sidechain_amount ) );
ilog( " peerplays_from: ${peerplays_from}", ( "peerplays_from", sed.peerplays_from ) ); ilog( " peerplays_from: ${peerplays_from}", ( "peerplays_from", sed.peerplays_from ) );
ilog( " peerplays_to: ${peerplays_to}", ( "peerplays_to", sed.peerplays_to ) ); ilog( " peerplays_to: ${peerplays_to}", ( "peerplays_to", sed.peerplays_to ) );
ilog( " peerplays_asset: ${peerplays_asset}", ( "peerplays_asset", sed.peerplays_asset ) );
const chain::global_property_object& gpo = database.get_global_properties(); const chain::global_property_object& gpo = database.get_global_properties();
son_wallet_transfer_create_operation op; // Deposit request
op.payer = gpo.parameters.get_son_btc_account_id(); if ((sed.peerplays_to == GRAPHENE_SON_ACCOUNT) && (sed.sidechain_currency.compare("1.3.0") != 0)) {
op.timestamp = sed.timestamp; son_wallet_deposit_create_operation op;
op.sidechain = sed.sidechain; op.payer = GRAPHENE_SON_ACCOUNT;
op.sidechain_uid = sed.sidechain_uid; op.timestamp = sed.timestamp;
op.sidechain_transaction_id = sed.sidechain_transaction_id; op.sidechain = sed.sidechain;
op.sidechain_from = sed.sidechain_from; op.sidechain_uid = sed.sidechain_uid;
op.sidechain_to = sed.sidechain_to; op.sidechain_transaction_id = sed.sidechain_transaction_id;
op.sidechain_amount = sed.sidechain_amount; op.sidechain_from = sed.sidechain_from;
op.peerplays_from = sed.peerplays_from; op.sidechain_to = sed.sidechain_to;
op.peerplays_to = sed.peerplays_to; op.sidechain_currency = sed.sidechain_currency;
op.peerplays_amount = asset(sed.sidechain_amount / 1000); // For Bitcoin, the exchange rate is 1:1, for others, get the exchange rate from market op.sidechain_amount = sed.sidechain_amount;
op.peerplays_from = sed.peerplays_from;
op.peerplays_to = sed.peerplays_to;
op.peerplays_asset = sed.peerplays_asset;
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)) {
proposal_create_operation proposal_op; proposal_create_operation proposal_op;
proposal_op.fee_paying_account = plugin.get_son_object(son_id).son_account; proposal_op.fee_paying_account = plugin.get_son_object(son_id).son_account;
proposal_op.proposed_ops.emplace_back( op_wrapper( op ) ); proposal_op.proposed_ops.emplace_back( op_wrapper( op ) );
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()));
}
} }
} }
return;
} }
// Withdrawal request
if ((sed.peerplays_to == GRAPHENE_SON_ACCOUNT) && (sed.sidechain_currency.compare("1.3.0") == 0)) {
// BTC Payout only (for now)
const auto& sidechain_addresses_idx = database.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
const auto& addr_itr = sidechain_addresses_idx.find(std::make_tuple(sed.peerplays_from, sidechain_type::bitcoin));
if ( addr_itr == sidechain_addresses_idx.end() )
return;
son_wallet_withdraw_create_operation op;
op.payer = GRAPHENE_SON_ACCOUNT;
op.timestamp = sed.timestamp;
op.sidechain = sed.sidechain;
op.peerplays_uid = sed.sidechain_uid;
op.peerplays_transaction_id = sed.sidechain_transaction_id;
op.peerplays_from = sed.peerplays_from;
op.peerplays_asset = sed.peerplays_asset;
op.withdraw_sidechain = sidechain_type::bitcoin; // BTC payout only (for now)
op.withdraw_address = addr_itr->withdraw_address; // BTC payout only (for now)
op.withdraw_currency = "BTC"; // BTC payout only (for now)
op.withdraw_amount = sed.peerplays_asset.amount * 1000; // BTC payout only (for now)
for (son_id_type son_id : plugin.get_sons()) {
if (plugin.is_active_son(son_id)) {
proposal_create_operation proposal_op;
proposal_op.fee_paying_account = plugin.get_son_object(son_id).son_account;
proposal_op.proposed_ops.emplace_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 );
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);
try {
database.push_transaction(trx, database::validation_steps::skip_block_size_check);
if(plugin.app().p2p_node())
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
} catch(fc::exception e){
ilog("sidechain_net_handler: sending proposal for son wallet withdraw create operation by ${son} failed with exception ${e}", ("son", son_id) ("e", e.what()));
}
}
}
return;
}
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() {
const auto& idx = plugin.database().get_index_type<son_wallet_deposit_index>().indices().get<by_sidechain_and_processed>();
const auto& idx_range = idx.equal_range(std::make_tuple(sidechain, false));
std::for_each(idx_range.first, idx_range.second,
[&] (const son_wallet_deposit_object& swdo) {
process_deposit(swdo);
const chain::global_property_object& gpo = plugin.database().get_global_properties();
for (son_id_type son_id : plugin.get_sons()) {
if (plugin.is_active_son(son_id)) {
son_wallet_deposit_process_operation p_op;
p_op.payer = GRAPHENE_SON_ACCOUNT;
p_op.son_wallet_deposit_id = swdo.id;
proposal_create_operation proposal_op;
proposal_op.fee_paying_account = plugin.get_son_object(son_id).son_account;
proposal_op.proposed_ops.emplace_back( op_wrapper( p_op ) );
uint32_t lifetime = ( gpo.parameters.block_interval * gpo.active_witnesses.size() ) * 3;
proposal_op.expiration_time = time_point_sec( plugin.database().head_block_time().sec_since_epoch() + lifetime );
ilog("sidechain_net_handler: sending proposal for transfer operation ${swdo} by ${son}", ("swdo", swdo.id) ("son", son_id));
signed_transaction trx = plugin.database().create_signed_transaction(plugin.get_private_key(son_id), proposal_op);
trx.validate();
ilog("sidechain_net_handler: transaction validated ${swdo} by ${son}", ("swdo", swdo.id) ("son", son_id));
try {
plugin.database().push_transaction(trx, database::validation_steps::skip_block_size_check);
if(plugin.app().p2p_node())
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
} catch(fc::exception e){
ilog("sidechain_net_handler: sending proposal for transfer operation failed with exception ${e}",("e", e.what()));
}
}
}
});
}
void sidechain_net_handler::process_withdrawals() {
const auto& idx = plugin.database().get_index_type<son_wallet_withdraw_index>().indices().get<by_withdraw_sidechain_and_processed>();
const auto& idx_range = idx.equal_range(std::make_tuple(sidechain, false));
std::for_each(idx_range.first, idx_range.second,
[&] (const son_wallet_withdraw_object& swwo) {
process_withdrawal(swwo);
const chain::global_property_object& gpo = plugin.database().get_global_properties();
for (son_id_type son_id : plugin.get_sons()) {
if (plugin.is_active_son(son_id)) {
ilog("SON ${son_id}: Withdraw to process: ${swwo}", ("son_id", son_id) ("swwo", swwo));
//son_wallet_withdraw_process_operation p_op;
//p_op.payer = GRAPHENE_SON_ACCOUNT;
//p_op.son_wallet_withdraw_id = swwo.id;
//
//proposal_create_operation proposal_op;
//proposal_op.fee_paying_account = plugin.get_son_object(son_id).son_account;
//proposal_op.proposed_ops.emplace_back( op_wrapper( p_op ) );
//uint32_t lifetime = ( gpo.parameters.block_interval * gpo.active_witnesses.size() ) * 3;
//proposal_op.expiration_time = time_point_sec( plugin.database().head_block_time().sec_since_epoch() + lifetime );
//
//ilog("sidechain_net_handler: sending proposal for transfer operation ${swwo} by ${son}", ("swwo", swwo.id) ("son", son_id));
//signed_transaction trx = plugin.database().create_signed_transaction(plugin.get_private_key(son_id), proposal_op);
//trx.validate();
//ilog("sidechain_net_handler: transaction validated ${swwo} by ${son}", ("swwo", swwo.id) ("son", son_id));
//try {
// plugin.database().push_transaction(trx, database::validation_steps::skip_block_size_check);
// if(plugin.app().p2p_node())
// plugin.app().p2p_node()->broadcast(net::trx_message(trx));
//} catch(fc::exception e){
// ilog("sidechain_net_handler: sending proposal for transfer operation failed with exception ${e}",("e", e.what()));
//}
}
}
});
} }
} } // graphene::peerplays_sidechain } } // graphene::peerplays_sidechain

View file

@ -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 {
@ -396,7 +398,7 @@ void sidechain_net_handler_bitcoin::recreate_primary_wallet() {
boost::property_tree::json_parser::write_json(res, pt.get_child("result")); boost::property_tree::json_parser::write_json(res, pt.get_child("result"));
son_wallet_update_operation op; son_wallet_update_operation op;
op.payer = gpo.parameters.get_son_btc_account_id(); op.payer = GRAPHENE_SON_ACCOUNT;
op.son_wallet_id = (*obj).id; op.son_wallet_id = (*obj).id;
op.sidechain = sidechain_type::bitcoin; op.sidechain = sidechain_type::bitcoin;
op.address = res.str(); op.address = res.str();
@ -422,43 +424,45 @@ void sidechain_net_handler_bitcoin::recreate_primary_wallet() {
} }
} }
bool sidechain_net_handler_bitcoin::connection_is_not_defined() const void sidechain_net_handler_bitcoin::process_deposits() {
{ sidechain_net_handler::process_deposits();
return listener->connection_is_not_defined() && bitcoin_client->connection_is_not_defined();
} }
std::string sidechain_net_handler_bitcoin::create_multisignature_wallet( const std::vector<std::string> public_keys ) void sidechain_net_handler_bitcoin::process_deposit(const son_wallet_deposit_object& swdo) {
{ }
void sidechain_net_handler_bitcoin::process_withdrawals() {
sidechain_net_handler::process_withdrawals();
}
void sidechain_net_handler_bitcoin::process_withdrawal(const son_wallet_withdraw_object& swwo) {
}
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 "";
} }
void sidechain_net_handler_bitcoin::handle_event( const std::string& event_data ) { void sidechain_net_handler_bitcoin::handle_event( const std::string& event_data ) {
ilog("peerplays sidechain plugin: sidechain_net_handler_bitcoin::handle_event");
ilog(" event_data: ${event_data}", ("event_data", event_data));
std::string block = bitcoin_client->receive_full_block( event_data ); std::string block = bitcoin_client->receive_full_block( event_data );
if( block != "" ) { if( block != "" ) {
const auto& vins = extract_info_from_block( block ); const auto& vins = extract_info_from_block( block );
const auto& sidechain_addresses_idx = database.get_index_type<sidechain_address_index>().indices().get<by_sidechain_and_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;
@ -473,16 +477,17 @@ void sidechain_net_handler_bitcoin::handle_event( const std::string& event_data
sed.sidechain_transaction_id = v.out.hash_tx; sed.sidechain_transaction_id = v.out.hash_tx;
sed.sidechain_from = ""; sed.sidechain_from = "";
sed.sidechain_to = v.address; sed.sidechain_to = v.address;
sed.sidechain_currency = "BTC";
sed.sidechain_amount = v.out.amount; sed.sidechain_amount = v.out.amount;
sed.peerplays_from = addr_itr->sidechain_address_account; sed.peerplays_from = addr_itr->sidechain_address_account;
sed.peerplays_to = GRAPHENE_SON_ACCOUNT; sed.peerplays_to = GRAPHENE_SON_ACCOUNT;
sed.peerplays_asset = asset(sed.sidechain_amount / 1000); // For Bitcoin, the exchange rate is 1:1, for others, get the exchange rate from market
sidechain_event_data_received(sed); sidechain_event_data_received(sed);
} }
} }
} }
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 );

View file

@ -0,0 +1,99 @@
#include <graphene/peerplays_sidechain/sidechain_net_handler_peerplays.hpp>
#include <algorithm>
#include <thread>
#include <boost/algorithm/hex.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <fc/crypto/base64.hpp>
#include <fc/log/logger.hpp>
#include <fc/network/ip.hpp>
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/sidechain_address_object.hpp>
#include <graphene/chain/son_info.hpp>
#include <graphene/chain/son_wallet_object.hpp>
#include <graphene/chain/protocol/son_wallet.hpp>
namespace graphene { namespace peerplays_sidechain {
sidechain_net_handler_peerplays::sidechain_net_handler_peerplays(peerplays_sidechain_plugin& _plugin, const boost::program_options::variables_map& options) :
sidechain_net_handler(_plugin, options) {
sidechain = sidechain_type::peerplays;
plugin.database().applied_block.connect( [&] (const signed_block& b) { on_block_applied(b); } );
}
sidechain_net_handler_peerplays::~sidechain_net_handler_peerplays() {
}
void sidechain_net_handler_peerplays::recreate_primary_wallet() {
}
void sidechain_net_handler_peerplays::process_deposits() {
sidechain_net_handler::process_deposits();
}
void sidechain_net_handler_peerplays::process_deposit(const son_wallet_deposit_object& swdo) {
}
void sidechain_net_handler_peerplays::process_withdrawals() {
sidechain_net_handler::process_withdrawals();
}
void sidechain_net_handler_peerplays::process_withdrawal(const son_wallet_withdraw_object& swwo) {
}
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_block_applied(const signed_block& b) {
for (const auto& trx: b.transactions) {
size_t operation_index = -1;
for (auto op: trx.operations) {
operation_index = operation_index + 1;
if (op.which() == operation::tag<transfer_operation>::value){
transfer_operation transfer_op = op.get<transfer_operation>();
if (transfer_op.to != GRAPHENE_SON_ACCOUNT) {
continue;
}
std::stringstream ss;
ss << "peerplays" << "-" << trx.id().str() << "-" << operation_index;
std::string sidechain_uid = ss.str();
sidechain_event_data sed;
sed.timestamp = plugin.database().head_block_time();
sed.sidechain = sidechain_type::peerplays;
sed.sidechain_uid = sidechain_uid;
sed.sidechain_transaction_id = trx.id().str();
sed.sidechain_from = fc::to_string(transfer_op.from.space_id) + "." + fc::to_string(transfer_op.from.type_id) + "." + fc::to_string((uint64_t)transfer_op.from.instance);
sed.sidechain_to = fc::to_string(transfer_op.to.space_id) + "." + fc::to_string(transfer_op.to.type_id) + "." + fc::to_string((uint64_t)transfer_op.to.instance);
sed.sidechain_currency = fc::to_string(transfer_op.amount.asset_id.space_id) + "." + fc::to_string(transfer_op.amount.asset_id.type_id) + "." + fc::to_string((uint64_t)transfer_op.amount.asset_id.instance); //transfer_op.amount.asset_id(plugin.database()).symbol;
sed.sidechain_amount = transfer_op.amount.amount;
sed.peerplays_from = transfer_op.from;
sed.peerplays_to = transfer_op.to;
// We should calculate exchange rate between CORE/TEST and other Peerplays asset
sed.peerplays_asset = asset(transfer_op.amount.amount / transfer_op.amount.asset_id(plugin.database()).options.core_exchange_rate.quote.amount);
sidechain_event_data_received(sed);
}
}
}
}
} } // graphene::peerplays_sidechain

View file

@ -3,6 +3,7 @@
#include <fc/log/logger.hpp> #include <fc/log/logger.hpp>
#include <graphene/chain/son_wallet_object.hpp> #include <graphene/chain/son_wallet_object.hpp>
#include <graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp> #include <graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp>
#include <graphene/peerplays_sidechain/sidechain_net_handler_peerplays.hpp>
namespace graphene { namespace peerplays_sidechain { namespace graphene { namespace peerplays_sidechain {
@ -26,6 +27,12 @@ bool sidechain_net_manager::create_handler(peerplays_sidechain::sidechain_type s
ret_val = true; ret_val = true;
break; break;
} }
case sidechain_type::peerplays: {
std::unique_ptr<sidechain_net_handler> h = std::unique_ptr<sidechain_net_handler>(new sidechain_net_handler_peerplays(plugin, options));
net_handlers.push_back(std::move(h));
ret_val = true;
break;
}
default: default:
assert(false); assert(false);
} }
@ -39,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

View file

@ -1416,17 +1416,15 @@ 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 address sidechain address * @param deposit_address sidechain address for deposits
* @param private_key private key for sidechain address * @param withdraw_address sidechain address for withdrawals
* @param public_key public key for sidechain address
* @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 address, string deposit_address,
string private_key, string withdraw_address,
string public_key,
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.
@ -1435,17 +1433,15 @@ 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 address sidechain address * @param deposit_address sidechain address for deposits
* @param private_key private key for sidechain address * @param withdraw_address sidechain address for withdrawals
* @param public_key public key for sidechain address
* @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 address, string deposit_address,
string private_key, string withdraw_address,
string public_key,
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.

View file

@ -2022,9 +2022,8 @@ 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 address, string deposit_address,
string private_key, string withdraw_address,
string public_key,
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,9 +2031,8 @@ public:
sidechain_address_add_operation op; sidechain_address_add_operation op;
op.sidechain_address_account = sidechain_address_account_id; op.sidechain_address_account = sidechain_address_account_id;
op.sidechain = sidechain; op.sidechain = sidechain;
op.address = address; op.deposit_address = deposit_address;
op.private_key = private_key; op.withdraw_address = withdraw_address;
op.public_key = public_key;
signed_transaction tx; signed_transaction tx;
tx.operations.push_back( op ); tx.operations.push_back( op );
@ -2046,9 +2044,8 @@ 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 address, string deposit_address,
string private_key, string withdraw_address,
string public_key,
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);
@ -2060,9 +2057,8 @@ public:
op.sidechain_address_id = sao->id; op.sidechain_address_id = sao->id;
op.sidechain_address_account = sidechain_address_account_id; op.sidechain_address_account = sidechain_address_account_id;
op.sidechain = sidechain; op.sidechain = sidechain;
op.address = address; op.deposit_address = deposit_address;
op.private_key = private_key; op.withdraw_address = withdraw_address;
op.public_key = public_key;
signed_transaction tx; signed_transaction tx;
tx.operations.push_back( op ); tx.operations.push_back( op );
@ -4501,22 +4497,20 @@ 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 address, string deposit_address,
string private_key, string withdraw_address,
string public_key,
bool broadcast /* = false */) bool broadcast /* = false */)
{ {
return my->add_sidechain_address(account, sidechain, address, private_key, public_key, 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 address, string deposit_address,
string private_key, string withdraw_address,
string public_key,
bool broadcast /* = false */) bool broadcast /* = false */)
{ {
return my->update_sidechain_address(account, sidechain, address, private_key, public_key, 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,

View file

@ -45,7 +45,8 @@
#include <graphene/chain/game_object.hpp> #include <graphene/chain/game_object.hpp>
#include <graphene/chain/son_object.hpp> #include <graphene/chain/son_object.hpp>
#include <graphene/chain/son_wallet_object.hpp> #include <graphene/chain/son_wallet_object.hpp>
#include <graphene/chain/son_wallet_transfer_object.hpp> #include <graphene/chain/son_wallet_deposit_object.hpp>
#include <graphene/chain/son_wallet_withdraw_object.hpp>
#include <graphene/chain/sidechain_address_object.hpp> #include <graphene/chain/sidechain_address_object.hpp>
#include <fc/smart_ref_impl.hpp> #include <fc/smart_ref_impl.hpp>

0
tests/tests/history_api_tests.cpp Executable file → Normal file
View file

View file

@ -30,9 +30,8 @@ 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.address = "address"; op.deposit_address = "deposit_address";
op.private_key = "private_key"; op.withdraw_address = "withdraw_address";
op.public_key = "public_key";
trx.operations.push_back(op); trx.operations.push_back(op);
sign(trx, alice_private_key); sign(trx, alice_private_key);
@ -48,9 +47,8 @@ BOOST_AUTO_TEST_CASE( sidechain_address_add_test ) {
BOOST_REQUIRE( obj != idx.end() ); BOOST_REQUIRE( obj != idx.end() );
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->address == "address" ); BOOST_CHECK( obj->deposit_address == "deposit_address" );
BOOST_CHECK( obj->private_key == "private_key" ); BOOST_CHECK( obj->withdraw_address == "withdraw_address" );
BOOST_CHECK( obj->public_key == "public_key" );
} }
BOOST_AUTO_TEST_CASE( sidechain_address_update_test ) { BOOST_AUTO_TEST_CASE( sidechain_address_update_test ) {
@ -66,9 +64,8 @@ BOOST_AUTO_TEST_CASE( sidechain_address_update_test ) {
auto obj = idx.find( boost::make_tuple( alice_id, graphene::peerplays_sidechain::sidechain_type::bitcoin ) ); auto obj = idx.find( boost::make_tuple( alice_id, graphene::peerplays_sidechain::sidechain_type::bitcoin ) );
BOOST_REQUIRE( obj != idx.end() ); BOOST_REQUIRE( obj != idx.end() );
std::string new_address = "new_address"; std::string new_deposit_address = "new_deposit_address";
std::string new_private_key = "new_private_key"; std::string new_withdraw_address = "new_withdraw_address";
std::string new_public_key = "new_public_key";
{ {
BOOST_TEST_MESSAGE("Send sidechain_address_update_operation"); BOOST_TEST_MESSAGE("Send sidechain_address_update_operation");
@ -77,9 +74,8 @@ BOOST_AUTO_TEST_CASE( sidechain_address_update_test ) {
op.sidechain_address_id = sidechain_address_id_type(0); op.sidechain_address_id = sidechain_address_id_type(0);
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.address = new_address; op.deposit_address = new_deposit_address;
op.private_key = new_private_key; op.withdraw_address = new_withdraw_address;
op.public_key = new_public_key;
trx.operations.push_back(op); trx.operations.push_back(op);
sign(trx, alice_private_key); sign(trx, alice_private_key);
@ -96,9 +92,8 @@ BOOST_AUTO_TEST_CASE( sidechain_address_update_test ) {
BOOST_REQUIRE( obj != idx.end() ); BOOST_REQUIRE( obj != idx.end() );
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->address == new_address ); BOOST_CHECK( obj->deposit_address == new_deposit_address );
BOOST_CHECK( obj->private_key == new_private_key ); BOOST_CHECK( obj->withdraw_address == new_withdraw_address );
BOOST_CHECK( obj->public_key == new_public_key );
} }
} }

View file

@ -843,35 +843,12 @@ BOOST_AUTO_TEST_CASE( son_report_down_test ) {
BOOST_CHECK( obj->status == son_status::active); BOOST_CHECK( obj->status == son_status::active);
const auto& son_btc_account = db.create<account_object>( [&]( account_object& obj ) {
obj.name = "son_btc_account";
obj.statistics = db.create<account_statistics_object>([&]( account_statistics_object& acc_stat ){ acc_stat.owner = obj.id; }).id;
obj.membership_expiration_date = time_point_sec::maximum();
obj.network_fee_percentage = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
obj.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT - GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
obj.owner.add_authority( bob_id, 1 );
obj.active.add_authority( bob_id, 1 );
obj.active.weight_threshold = 1;
obj.owner.weight_threshold = 1;
});
db.modify( db.get_global_properties(), [&]( global_property_object& _gpo )
{
_gpo.parameters.extensions.value.son_pay_daily_max = 200;
_gpo.parameters.witness_pay_per_block = 0;
_gpo.parameters.extensions.value.son_btc_account = son_btc_account.get_id();
if( _gpo.pending_parameters )
_gpo.pending_parameters->extensions.value.son_btc_account = son_btc_account.get_id();
});
{ {
// Check that transaction fails if down_ts < last_active_timestamp // Check that transaction fails if down_ts < last_active_timestamp
generate_block(); generate_block();
// Send Report Down Operation for an active status SON // Send Report Down Operation for an active status SON
son_report_down_operation op; son_report_down_operation op;
op.payer = db.get_global_properties().parameters.get_son_btc_account_id(); op.payer = GRAPHENE_SON_ACCOUNT;
op.son_id = son_id_type(0); op.son_id = son_id_type(0);
op.down_ts = fc::time_point_sec(son_stats_obj->last_active_timestamp - fc::seconds(1)); op.down_ts = fc::time_point_sec(son_stats_obj->last_active_timestamp - fc::seconds(1));
@ -884,7 +861,7 @@ BOOST_AUTO_TEST_CASE( son_report_down_test ) {
} }
{ {
// Check that transaction fails if payer is not son_btc_account. // Check that transaction fails if payer is not GRAPHENE_SON_ACCOUNT.
generate_block(); generate_block();
// Send Report Down Operation for an active status SON // Send Report Down Operation for an active status SON
son_report_down_operation op; son_report_down_operation op;
@ -901,11 +878,11 @@ BOOST_AUTO_TEST_CASE( son_report_down_test ) {
} }
{ {
// Check that transaction succeeds after getting enough approvals on son_btc_account. // Check that transaction succeeds after getting enough approvals on GRAPHENE_SON_ACCOUNT.
generate_block(); generate_block();
// Send Report Down Operation for an active status SON // Send Report Down Operation for an active status SON
son_report_down_operation op; son_report_down_operation op;
op.payer = db.get_global_properties().parameters.get_son_btc_account_id(); op.payer = GRAPHENE_SON_ACCOUNT;
op.son_id = son_id_type(0); op.son_id = son_id_type(0);
op.down_ts = son_stats_obj->last_active_timestamp; op.down_ts = son_stats_obj->last_active_timestamp;
@ -925,7 +902,7 @@ BOOST_AUTO_TEST_CASE( son_report_down_test ) {
generate_block(); generate_block();
// Send Report Down Operation for an active status SON // Send Report Down Operation for an active status SON
son_report_down_operation op; son_report_down_operation op;
op.payer = db.get_global_properties().parameters.get_son_btc_account_id(); op.payer = GRAPHENE_SON_ACCOUNT;
op.son_id = son_id_type(0); op.son_id = son_id_type(0);
op.down_ts = son_stats_obj->last_active_timestamp; op.down_ts = son_stats_obj->last_active_timestamp;

View file

@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE( son_wallet_recreate_test ) {
son_wallet_recreate_operation op; son_wallet_recreate_operation op;
op.payer = db.get_global_properties().parameters.get_son_btc_account_id(); op.payer = GRAPHENE_SON_ACCOUNT;
{ {
son_info si; son_info si;
@ -199,7 +199,7 @@ BOOST_AUTO_TEST_CASE( son_wallet_update_test ) {
son_wallet_update_operation op; son_wallet_update_operation op;
op.payer = db.get_global_properties().parameters.get_son_btc_account_id(); op.payer = GRAPHENE_SON_ACCOUNT;
op.son_wallet_id = son_wallet_id_type(0); op.son_wallet_id = son_wallet_id_type(0);
op.sidechain = graphene::peerplays_sidechain::sidechain_type::bitcoin; op.sidechain = graphene::peerplays_sidechain::sidechain_type::bitcoin;
op.address = "bitcoin address"; op.address = "bitcoin address";