Compare commits
10 commits
master
...
feature/SO
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e91478564 | ||
|
|
5f49e982ec | ||
|
|
7ddaff10e2 | ||
|
|
71c378d5e6 | ||
|
|
f547ea33c1 | ||
|
|
07836cb3b4 | ||
|
|
8e36d0e571 | ||
|
|
dc9476b2d3 | ||
|
|
aeb201b667 | ||
|
|
94cf6b6ef4 |
24 changed files with 288 additions and 202 deletions
|
|
@ -170,8 +170,8 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
|
||||||
// Sidechain addresses
|
// Sidechain addresses
|
||||||
vector<optional<sidechain_address_object>> get_sidechain_addresses(const vector<sidechain_address_id_type>& sidechain_address_ids)const;
|
vector<optional<sidechain_address_object>> get_sidechain_addresses(const vector<sidechain_address_id_type>& sidechain_address_ids)const;
|
||||||
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_account(account_id_type account)const;
|
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_account(account_id_type account)const;
|
||||||
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_sidechain(peerplays_sidechain::sidechain_type sidechain)const;
|
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_sidechain(sidechain_type sidechain)const;
|
||||||
fc::optional<sidechain_address_object> get_sidechain_address_by_account_and_sidechain(account_id_type account, peerplays_sidechain::sidechain_type sidechain)const;
|
fc::optional<sidechain_address_object> get_sidechain_address_by_account_and_sidechain(account_id_type account, sidechain_type sidechain)const;
|
||||||
uint64_t get_sidechain_addresses_count()const;
|
uint64_t get_sidechain_addresses_count()const;
|
||||||
|
|
||||||
// Votes
|
// Votes
|
||||||
|
|
@ -1943,12 +1943,12 @@ vector<optional<sidechain_address_object>> database_api_impl::get_sidechain_addr
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<optional<sidechain_address_object>> database_api::get_sidechain_addresses_by_sidechain(peerplays_sidechain::sidechain_type sidechain)const
|
vector<optional<sidechain_address_object>> database_api::get_sidechain_addresses_by_sidechain(sidechain_type sidechain)const
|
||||||
{
|
{
|
||||||
return my->get_sidechain_addresses_by_sidechain( sidechain );
|
return my->get_sidechain_addresses_by_sidechain( sidechain );
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<optional<sidechain_address_object>> database_api_impl::get_sidechain_addresses_by_sidechain(peerplays_sidechain::sidechain_type sidechain)const
|
vector<optional<sidechain_address_object>> database_api_impl::get_sidechain_addresses_by_sidechain(sidechain_type sidechain)const
|
||||||
{
|
{
|
||||||
vector<optional<sidechain_address_object>> result;
|
vector<optional<sidechain_address_object>> result;
|
||||||
const auto& sidechain_addresses_range = _db.get_index_type<sidechain_address_index>().indices().get<by_sidechain>().equal_range(sidechain);
|
const auto& sidechain_addresses_range = _db.get_index_type<sidechain_address_index>().indices().get<by_sidechain>().equal_range(sidechain);
|
||||||
|
|
@ -1959,12 +1959,12 @@ vector<optional<sidechain_address_object>> database_api_impl::get_sidechain_addr
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
fc::optional<sidechain_address_object> database_api::get_sidechain_address_by_account_and_sidechain(account_id_type account, peerplays_sidechain::sidechain_type sidechain)const
|
fc::optional<sidechain_address_object> database_api::get_sidechain_address_by_account_and_sidechain(account_id_type account, sidechain_type sidechain)const
|
||||||
{
|
{
|
||||||
return my->get_sidechain_address_by_account_and_sidechain( account, sidechain );
|
return my->get_sidechain_address_by_account_and_sidechain( account, sidechain );
|
||||||
}
|
}
|
||||||
|
|
||||||
fc::optional<sidechain_address_object> database_api_impl::get_sidechain_address_by_account_and_sidechain(account_id_type account, peerplays_sidechain::sidechain_type sidechain)const
|
fc::optional<sidechain_address_object> database_api_impl::get_sidechain_address_by_account_and_sidechain(account_id_type account, sidechain_type sidechain)const
|
||||||
{
|
{
|
||||||
const auto& idx = _db.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
const auto& idx = _db.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
||||||
auto itr = idx.find( boost::make_tuple( account, sidechain ) );
|
auto itr = idx.find( boost::make_tuple( account, sidechain ) );
|
||||||
|
|
|
||||||
|
|
@ -679,7 +679,7 @@ class database_api
|
||||||
* @param sidechain Sidechain for which addresses should be retrieved
|
* @param sidechain Sidechain for which addresses should be retrieved
|
||||||
* @return The sidechain addresses objects, or null if the sidechain does not have any addresses
|
* @return The sidechain addresses objects, or null if the sidechain does not have any addresses
|
||||||
*/
|
*/
|
||||||
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_sidechain(peerplays_sidechain::sidechain_type sidechain)const;
|
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_sidechain(sidechain_type sidechain)const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the sidechain addresses for a given account and sidechain
|
* @brief Get the sidechain addresses for a given account and sidechain
|
||||||
|
|
@ -687,7 +687,7 @@ class database_api
|
||||||
* @param sidechain Sidechain for which address should be retrieved
|
* @param sidechain Sidechain for which address should be retrieved
|
||||||
* @return The sidechain addresses objects, or null if the account does not have a sidechain addresses for a given sidechain
|
* @return The sidechain addresses objects, or null if the account does not have a sidechain addresses for a given sidechain
|
||||||
*/
|
*/
|
||||||
fc::optional<sidechain_address_object> get_sidechain_address_by_account_and_sidechain(account_id_type account, peerplays_sidechain::sidechain_type sidechain)const;
|
fc::optional<sidechain_address_object> get_sidechain_address_by_account_and_sidechain(account_id_type account, sidechain_type sidechain)const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the total number of sidechain addresses registered with the blockchain
|
* @brief Get the total number of sidechain addresses registered with the blockchain
|
||||||
|
|
|
||||||
|
|
@ -684,10 +684,11 @@ void database::update_active_sons()
|
||||||
// Compare current and to-be lists of active sons
|
// Compare current and to-be lists of active sons
|
||||||
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;
|
||||||
|
const auto &acc = get(gpo.parameters.son_account());
|
||||||
for( const son_object& son : sons ) {
|
for( const son_object& son : sons ) {
|
||||||
son_info swi;
|
son_info swi;
|
||||||
swi.son_id = son.id;
|
swi.son_id = son.id;
|
||||||
swi.total_votes = son.total_votes;
|
swi.weight = acc.active.account_auths.at(son.son_account);
|
||||||
swi.signing_key = son.signing_key;
|
swi.signing_key = son.signing_key;
|
||||||
swi.sidechain_public_keys = son.sidechain_public_keys;
|
swi.sidechain_public_keys = son.sidechain_public_keys;
|
||||||
new_active_sons.push_back(swi);
|
new_active_sons.push_back(swi);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ 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;
|
sidechain_type sidechain;
|
||||||
string deposit_address;
|
string deposit_address;
|
||||||
string withdraw_address;
|
string withdraw_address;
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace graphene { namespace chain {
|
||||||
asset fee;
|
asset fee;
|
||||||
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;
|
sidechain_type sidechain;
|
||||||
optional<string> deposit_address;
|
optional<string> deposit_address;
|
||||||
optional<string> withdraw_address;
|
optional<string> withdraw_address;
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace graphene { namespace chain {
|
||||||
asset fee;
|
asset fee;
|
||||||
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;
|
sidechain_type sidechain;
|
||||||
|
|
||||||
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; }
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace graphene { namespace chain {
|
||||||
std::string url;
|
std::string url;
|
||||||
vesting_balance_id_type deposit;
|
vesting_balance_id_type deposit;
|
||||||
public_key_type signing_key;
|
public_key_type signing_key;
|
||||||
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
vesting_balance_id_type pay_vb;
|
vesting_balance_id_type pay_vb;
|
||||||
|
|
||||||
account_id_type fee_payer()const { return owner_account; }
|
account_id_type fee_payer()const { return owner_account; }
|
||||||
|
|
@ -30,7 +30,7 @@ namespace graphene { namespace chain {
|
||||||
optional<std::string> new_url;
|
optional<std::string> new_url;
|
||||||
optional<vesting_balance_id_type> new_deposit;
|
optional<vesting_balance_id_type> new_deposit;
|
||||||
optional<public_key_type> new_signing_key;
|
optional<public_key_type> new_signing_key;
|
||||||
optional<flat_map<peerplays_sidechain::sidechain_type, string>> new_sidechain_public_keys;
|
optional<flat_map<sidechain_type, string>> new_sidechain_public_keys;
|
||||||
optional<vesting_balance_id_type> new_pay_vb;
|
optional<vesting_balance_id_type> new_pay_vb;
|
||||||
|
|
||||||
account_id_type fee_payer()const { return owner_account; }
|
account_id_type fee_payer()const { return owner_account; }
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace graphene { namespace chain {
|
||||||
account_id_type payer;
|
account_id_type payer;
|
||||||
|
|
||||||
son_wallet_id_type son_wallet_id;
|
son_wallet_id_type son_wallet_id;
|
||||||
graphene::peerplays_sidechain::sidechain_type sidechain;
|
sidechain_type sidechain;
|
||||||
string address;
|
string address;
|
||||||
|
|
||||||
account_id_type fee_payer()const { return payer; }
|
account_id_type fee_payer()const { return payer; }
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@ namespace graphene { namespace chain {
|
||||||
static const uint8_t type_id = sidechain_address_object_type;
|
static const uint8_t type_id = sidechain_address_object_type;
|
||||||
|
|
||||||
account_id_type sidechain_address_account;
|
account_id_type sidechain_address_account;
|
||||||
graphene::peerplays_sidechain::sidechain_type sidechain;
|
sidechain_type sidechain;
|
||||||
string deposit_address;
|
string deposit_address;
|
||||||
string withdraw_address;
|
string withdraw_address;
|
||||||
|
|
||||||
sidechain_address_object() :
|
sidechain_address_object() :
|
||||||
sidechain(graphene::peerplays_sidechain::sidechain_type::bitcoin),
|
sidechain(sidechain_type::bitcoin),
|
||||||
deposit_address(""),
|
deposit_address(""),
|
||||||
withdraw_address("") {}
|
withdraw_address("") {}
|
||||||
};
|
};
|
||||||
|
|
@ -45,17 +45,17 @@ namespace graphene { namespace chain {
|
||||||
member<sidechain_address_object, account_id_type, &sidechain_address_object::sidechain_address_account>
|
member<sidechain_address_object, account_id_type, &sidechain_address_object::sidechain_address_account>
|
||||||
>,
|
>,
|
||||||
ordered_non_unique< tag<by_sidechain>,
|
ordered_non_unique< tag<by_sidechain>,
|
||||||
member<sidechain_address_object, peerplays_sidechain::sidechain_type, &sidechain_address_object::sidechain>
|
member<sidechain_address_object, sidechain_type, &sidechain_address_object::sidechain>
|
||||||
>,
|
>,
|
||||||
ordered_unique< tag<by_account_and_sidechain>,
|
ordered_unique< tag<by_account_and_sidechain>,
|
||||||
composite_key<sidechain_address_object,
|
composite_key<sidechain_address_object,
|
||||||
member<sidechain_address_object, account_id_type, &sidechain_address_object::sidechain_address_account>,
|
member<sidechain_address_object, account_id_type, &sidechain_address_object::sidechain_address_account>,
|
||||||
member<sidechain_address_object, peerplays_sidechain::sidechain_type, &sidechain_address_object::sidechain>
|
member<sidechain_address_object, sidechain_type, &sidechain_address_object::sidechain>
|
||||||
>
|
>
|
||||||
>,
|
>,
|
||||||
ordered_unique< tag<by_sidechain_and_deposit_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, sidechain_type, &sidechain_address_object::sidechain>,
|
||||||
member<sidechain_address_object, std::string, &sidechain_address_object::deposit_address>
|
member<sidechain_address_object, std::string, &sidechain_address_object::deposit_address>
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
enum class sidechain_type {
|
enum class sidechain_type {
|
||||||
|
unknown,
|
||||||
bitcoin,
|
bitcoin,
|
||||||
ethereum,
|
ethereum,
|
||||||
eos,
|
eos,
|
||||||
|
|
@ -13,13 +14,8 @@ enum class sidechain_type {
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
|
||||||
namespace graphene { namespace peerplays_sidechain {
|
|
||||||
|
|
||||||
using sidechain_type = graphene::chain::sidechain_type;
|
|
||||||
|
|
||||||
} }
|
|
||||||
|
|
||||||
FC_REFLECT_ENUM(graphene::chain::sidechain_type,
|
FC_REFLECT_ENUM(graphene::chain::sidechain_type,
|
||||||
|
(unknown)
|
||||||
(bitcoin)
|
(bitcoin)
|
||||||
(ethereum)
|
(ethereum)
|
||||||
(eos)
|
(eos)
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,14 @@ namespace graphene { namespace chain {
|
||||||
*/
|
*/
|
||||||
struct son_info {
|
struct son_info {
|
||||||
son_id_type son_id;
|
son_id_type son_id;
|
||||||
uint64_t total_votes = 0;
|
weight_type weight = 0;
|
||||||
public_key_type signing_key;
|
public_key_type signing_key;
|
||||||
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
|
|
||||||
bool operator==(const son_info& rhs) {
|
bool operator==(const son_info& rhs) {
|
||||||
bool son_sets_equal =
|
bool son_sets_equal =
|
||||||
(son_id == rhs.son_id) &&
|
(son_id == rhs.son_id) &&
|
||||||
(total_votes == rhs.total_votes) &&
|
(weight == rhs.weight) &&
|
||||||
(signing_key == rhs.signing_key) &&
|
(signing_key == rhs.signing_key) &&
|
||||||
(sidechain_public_keys.size() == rhs.sidechain_public_keys.size());
|
(sidechain_public_keys.size() == rhs.sidechain_public_keys.size());
|
||||||
|
|
||||||
|
|
@ -33,4 +33,7 @@ namespace graphene { namespace chain {
|
||||||
} }
|
} }
|
||||||
|
|
||||||
FC_REFLECT( graphene::chain::son_info,
|
FC_REFLECT( graphene::chain::son_info,
|
||||||
(son_id)(total_votes)(signing_key)(sidechain_public_keys) )
|
(son_id)
|
||||||
|
(weight)
|
||||||
|
(signing_key)
|
||||||
|
(sidechain_public_keys) )
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ namespace graphene { namespace chain {
|
||||||
vesting_balance_id_type pay_vb;
|
vesting_balance_id_type pay_vb;
|
||||||
son_statistics_id_type statistics;
|
son_statistics_id_type statistics;
|
||||||
son_status status = son_status::inactive;
|
son_status status = son_status::inactive;
|
||||||
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
|
|
||||||
void pay_son_fee(share_type pay, database& db);
|
void pay_son_fee(share_type pay, database& db);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace graphene { namespace chain {
|
||||||
static const uint8_t type_id = son_wallet_deposit_object_type;
|
static const uint8_t type_id = son_wallet_deposit_object_type;
|
||||||
|
|
||||||
time_point_sec timestamp;
|
time_point_sec timestamp;
|
||||||
sidechain_type sidechain;
|
sidechain_type sidechain = sidechain_type::unknown;
|
||||||
std::string sidechain_uid;
|
std::string sidechain_uid;
|
||||||
std::string sidechain_transaction_id;
|
std::string sidechain_transaction_id;
|
||||||
std::string sidechain_from;
|
std::string sidechain_from;
|
||||||
|
|
@ -29,34 +29,29 @@ namespace graphene { namespace chain {
|
||||||
chain::account_id_type peerplays_to;
|
chain::account_id_type peerplays_to;
|
||||||
chain::asset peerplays_asset;
|
chain::asset peerplays_asset;
|
||||||
|
|
||||||
std::set<son_id_type> expected_reports;
|
std::map<son_id_type, weight_type> expected_reports;
|
||||||
std::set<son_id_type> received_reports;
|
std::set<son_id_type> received_reports;
|
||||||
|
|
||||||
bool processed;
|
bool confirmed = false;
|
||||||
|
|
||||||
|
bool processed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct by_sidechain;
|
|
||||||
struct by_sidechain_uid;
|
struct by_sidechain_uid;
|
||||||
struct by_processed;
|
struct by_sidechain_and_confirmed_and_processed;
|
||||||
struct by_sidechain_and_processed;
|
|
||||||
using son_wallet_deposit_multi_index_type = multi_index_container<
|
using son_wallet_deposit_multi_index_type = multi_index_container<
|
||||||
son_wallet_deposit_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>,
|
|
||||||
member<son_wallet_deposit_object, sidechain_type, &son_wallet_deposit_object::sidechain>
|
|
||||||
>,
|
|
||||||
ordered_unique< tag<by_sidechain_uid>,
|
ordered_unique< tag<by_sidechain_uid>,
|
||||||
member<son_wallet_deposit_object, std::string, &son_wallet_deposit_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_sidechain_and_confirmed_and_processed>,
|
||||||
member<son_wallet_deposit_object, bool, &son_wallet_deposit_object::processed>
|
|
||||||
>,
|
|
||||||
ordered_non_unique< tag<by_sidechain_and_processed>,
|
|
||||||
composite_key<son_wallet_deposit_object,
|
composite_key<son_wallet_deposit_object,
|
||||||
member<son_wallet_deposit_object, sidechain_type, &son_wallet_deposit_object::sidechain>,
|
member<son_wallet_deposit_object, sidechain_type, &son_wallet_deposit_object::sidechain>,
|
||||||
|
member<son_wallet_deposit_object, bool, &son_wallet_deposit_object::confirmed>,
|
||||||
member<son_wallet_deposit_object, bool, &son_wallet_deposit_object::processed>
|
member<son_wallet_deposit_object, bool, &son_wallet_deposit_object::processed>
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
|
|
@ -70,4 +65,4 @@ FC_REFLECT_DERIVED( graphene::chain::son_wallet_deposit_object, (graphene::db::o
|
||||||
(sidechain_uid) (sidechain_transaction_id) (sidechain_from) (sidechain_to) (sidechain_currency) (sidechain_amount)
|
(sidechain_uid) (sidechain_transaction_id) (sidechain_from) (sidechain_to) (sidechain_currency) (sidechain_amount)
|
||||||
(peerplays_from) (peerplays_to) (peerplays_asset)
|
(peerplays_from) (peerplays_to) (peerplays_asset)
|
||||||
(expected_reports) (received_reports)
|
(expected_reports) (received_reports)
|
||||||
(processed) )
|
(confirmed) (processed) )
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace graphene { namespace chain {
|
||||||
static const uint8_t type_id = son_wallet_withdraw_object_type;
|
static const uint8_t type_id = son_wallet_withdraw_object_type;
|
||||||
|
|
||||||
time_point_sec timestamp;
|
time_point_sec timestamp;
|
||||||
sidechain_type sidechain;
|
sidechain_type sidechain = sidechain_type::unknown;
|
||||||
std::string peerplays_uid;
|
std::string peerplays_uid;
|
||||||
std::string peerplays_transaction_id;
|
std::string peerplays_transaction_id;
|
||||||
chain::account_id_type peerplays_from;
|
chain::account_id_type peerplays_from;
|
||||||
|
|
@ -28,16 +28,16 @@ namespace graphene { namespace chain {
|
||||||
std::string withdraw_currency;
|
std::string withdraw_currency;
|
||||||
safe<int64_t> withdraw_amount;
|
safe<int64_t> withdraw_amount;
|
||||||
|
|
||||||
std::set<son_id_type> expected_reports;
|
std::map<son_id_type, weight_type> expected_reports;
|
||||||
std::set<son_id_type> received_reports;
|
std::set<son_id_type> received_reports;
|
||||||
|
|
||||||
bool processed;
|
bool confirmed = false;
|
||||||
|
|
||||||
|
bool processed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct by_peerplays_uid;
|
struct by_peerplays_uid;
|
||||||
struct by_withdraw_sidechain;
|
struct by_withdraw_sidechain_and_confirmed_and_processed;
|
||||||
struct by_processed;
|
|
||||||
struct by_withdraw_sidechain_and_processed;
|
|
||||||
using son_wallet_withdraw_multi_index_type = multi_index_container<
|
using son_wallet_withdraw_multi_index_type = multi_index_container<
|
||||||
son_wallet_withdraw_object,
|
son_wallet_withdraw_object,
|
||||||
indexed_by<
|
indexed_by<
|
||||||
|
|
@ -47,15 +47,10 @@ namespace graphene { namespace chain {
|
||||||
ordered_unique< tag<by_peerplays_uid>,
|
ordered_unique< tag<by_peerplays_uid>,
|
||||||
member<son_wallet_withdraw_object, std::string, &son_wallet_withdraw_object::peerplays_uid>
|
member<son_wallet_withdraw_object, std::string, &son_wallet_withdraw_object::peerplays_uid>
|
||||||
>,
|
>,
|
||||||
ordered_non_unique< tag<by_withdraw_sidechain>,
|
ordered_non_unique< tag<by_withdraw_sidechain_and_confirmed_and_processed>,
|
||||||
member<son_wallet_withdraw_object, 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,
|
composite_key<son_wallet_withdraw_object,
|
||||||
member<son_wallet_withdraw_object, sidechain_type, &son_wallet_withdraw_object::withdraw_sidechain>,
|
member<son_wallet_withdraw_object, sidechain_type, &son_wallet_withdraw_object::withdraw_sidechain>,
|
||||||
|
member<son_wallet_withdraw_object, bool, &son_wallet_withdraw_object::confirmed>,
|
||||||
member<son_wallet_withdraw_object, bool, &son_wallet_withdraw_object::processed>
|
member<son_wallet_withdraw_object, bool, &son_wallet_withdraw_object::processed>
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
|
|
@ -69,4 +64,4 @@ FC_REFLECT_DERIVED( graphene::chain::son_wallet_withdraw_object, (graphene::db::
|
||||||
(peerplays_uid) (peerplays_transaction_id) (peerplays_from) (peerplays_asset)
|
(peerplays_uid) (peerplays_transaction_id) (peerplays_from) (peerplays_asset)
|
||||||
(withdraw_sidechain) (withdraw_address) (withdraw_currency) (withdraw_amount)
|
(withdraw_sidechain) (withdraw_address) (withdraw_currency) (withdraw_amount)
|
||||||
(expected_reports) (received_reports)
|
(expected_reports) (received_reports)
|
||||||
(processed) )
|
(confirmed) (processed) )
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ object_id_type sidechain_transaction_create_evaluator::do_apply(const sidechain_
|
||||||
return std::make_pair(si.son_id, std::string());
|
return std::make_pair(si.son_id, std::string());
|
||||||
});
|
});
|
||||||
for (const auto &si : op.signers) {
|
for (const auto &si : op.signers) {
|
||||||
sto.total_weight = sto.total_weight + si.total_votes;
|
sto.total_weight = sto.total_weight + si.weight;
|
||||||
}
|
}
|
||||||
sto.sidechain_transaction = "";
|
sto.sidechain_transaction = "";
|
||||||
sto.current_weight = 0;
|
sto.current_weight = 0;
|
||||||
|
|
@ -91,7 +91,7 @@ object_id_type sidechain_transaction_sign_evaluator::do_apply(const sidechain_tr
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < sto.signers.size(); i++) {
|
for (size_t i = 0; i < sto.signers.size(); i++) {
|
||||||
if (sto.signers.at(i).son_id == son_obj->id) {
|
if (sto.signers.at(i).son_id == son_obj->id) {
|
||||||
sto.current_weight = sto.current_weight + sto.signers.at(i).total_votes;
|
sto.current_weight = sto.current_weight + sto.signers.at(i).weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sto.complete = op.complete;
|
sto.complete = op.complete;
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,52 @@
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
void_result create_son_wallet_deposit_evaluator::do_evaluate(const son_wallet_deposit_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( op.payer == db().get_global_properties().parameters.son_account(), "SON paying account must be set as payer." );
|
|
||||||
|
|
||||||
const auto &idx = db().get_index_type<son_stats_index>().indices().get<by_owner>();
|
const auto &son_idx = db().get_index_type<son_index>().indices().get<by_id>();
|
||||||
FC_ASSERT(idx.find(op.son_id) != idx.end(), "Statistic object for a given SON ID does not exists");
|
const auto so = son_idx.find(op.son_id);
|
||||||
|
FC_ASSERT(so != son_idx.end(), "SON not found");
|
||||||
|
FC_ASSERT(so->son_account == op.payer, "Payer is not SON account owner");
|
||||||
|
|
||||||
|
const auto &ss_idx = db().get_index_type<son_stats_index>().indices().get<by_owner>();
|
||||||
|
FC_ASSERT(ss_idx.find(op.son_id) != ss_idx.end(), "Statistic object for a given SON ID does not exists");
|
||||||
|
|
||||||
|
const auto &swdo_idx = db().get_index_type<son_wallet_deposit_index>().indices().get<by_sidechain_uid>();
|
||||||
|
const auto swdo = swdo_idx.find(op.sidechain_uid);
|
||||||
|
if (swdo == swdo_idx.end()) {
|
||||||
|
auto &gpo = db().get_global_properties();
|
||||||
|
bool expected = false;
|
||||||
|
for (auto &si : gpo.active_sons) {
|
||||||
|
if (op.son_id == si.son_id) {
|
||||||
|
expected = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FC_ASSERT(expected, "Only active SON can create deposit");
|
||||||
|
} else {
|
||||||
|
bool exactly_the_same = true;
|
||||||
|
exactly_the_same = exactly_the_same && (swdo->sidechain == op.sidechain);
|
||||||
|
exactly_the_same = exactly_the_same && (swdo->sidechain_uid == op.sidechain_uid);
|
||||||
|
exactly_the_same = exactly_the_same && (swdo->sidechain_transaction_id == op.sidechain_transaction_id);
|
||||||
|
exactly_the_same = exactly_the_same && (swdo->sidechain_from == op.sidechain_from);
|
||||||
|
exactly_the_same = exactly_the_same && (swdo->sidechain_to == op.sidechain_to);
|
||||||
|
exactly_the_same = exactly_the_same && (swdo->sidechain_currency == op.sidechain_currency);
|
||||||
|
exactly_the_same = exactly_the_same && (swdo->sidechain_amount == op.sidechain_amount);
|
||||||
|
exactly_the_same = exactly_the_same && (swdo->peerplays_from == op.peerplays_from);
|
||||||
|
exactly_the_same = exactly_the_same && (swdo->peerplays_to == op.peerplays_to);
|
||||||
|
exactly_the_same = exactly_the_same && (swdo->peerplays_asset == op.peerplays_asset);
|
||||||
|
FC_ASSERT(exactly_the_same, "Invalid withdraw confirmation");
|
||||||
|
|
||||||
|
bool expected = false;
|
||||||
|
for (auto &exp : swdo->expected_reports) {
|
||||||
|
if (op.son_id == exp.first) {
|
||||||
|
expected = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FC_ASSERT(expected, "Confirmation from this SON not expected");
|
||||||
|
}
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
@ -38,7 +78,7 @@ object_id_type create_son_wallet_deposit_evaluator::do_apply(const son_wallet_de
|
||||||
|
|
||||||
auto &gpo = db().get_global_properties();
|
auto &gpo = db().get_global_properties();
|
||||||
for (auto &si : gpo.active_sons) {
|
for (auto &si : gpo.active_sons) {
|
||||||
swdo.expected_reports.insert(si.son_id);
|
swdo.expected_reports.insert(std::make_pair(si.son_id, si.weight));
|
||||||
|
|
||||||
auto stats_itr = db().get_index_type<son_stats_index>().indices().get<by_owner>().find(si.son_id);
|
auto stats_itr = db().get_index_type<son_stats_index>().indices().get<by_owner>().find(si.son_id);
|
||||||
db().modify(*stats_itr, [&op, &si](son_statistics_object &sso) {
|
db().modify(*stats_itr, [&op, &si](son_statistics_object &sso) {
|
||||||
|
|
@ -51,12 +91,32 @@ object_id_type create_son_wallet_deposit_evaluator::do_apply(const son_wallet_de
|
||||||
|
|
||||||
swdo.received_reports.insert(op.son_id);
|
swdo.received_reports.insert(op.son_id);
|
||||||
|
|
||||||
|
uint64_t total_weight = 0;
|
||||||
|
for (const auto exp : swdo.expected_reports) {
|
||||||
|
total_weight = total_weight + exp.second;
|
||||||
|
}
|
||||||
|
uint64_t current_weight = 0;
|
||||||
|
for (const auto rec : swdo.received_reports) {
|
||||||
|
current_weight = current_weight + swdo.expected_reports.find(rec)->second;
|
||||||
|
}
|
||||||
|
swdo.confirmed = (current_weight > (total_weight * 2 / 3));
|
||||||
|
|
||||||
swdo.processed = false;
|
swdo.processed = false;
|
||||||
});
|
});
|
||||||
return new_son_wallet_deposit_object.id;
|
return new_son_wallet_deposit_object.id;
|
||||||
} else {
|
} else {
|
||||||
db().modify(*itr, [&op](son_wallet_deposit_object &swdo) {
|
db().modify(*itr, [&op](son_wallet_deposit_object &swdo) {
|
||||||
swdo.received_reports.insert(op.son_id);
|
swdo.received_reports.insert(op.son_id);
|
||||||
|
|
||||||
|
uint64_t total_weight = 0;
|
||||||
|
for (const auto exp : swdo.expected_reports) {
|
||||||
|
total_weight = total_weight + exp.second;
|
||||||
|
}
|
||||||
|
uint64_t current_weight = 0;
|
||||||
|
for (const auto rec : swdo.received_reports) {
|
||||||
|
current_weight = current_weight + swdo.expected_reports.find(rec)->second;
|
||||||
|
}
|
||||||
|
swdo.confirmed = (current_weight > (total_weight * 2 / 3));
|
||||||
});
|
});
|
||||||
auto stats_itr = db().get_index_type<son_stats_index>().indices().get<by_owner>().find(op.son_id);
|
auto stats_itr = db().get_index_type<son_stats_index>().indices().get<by_owner>().find(op.son_id);
|
||||||
db().modify(*stats_itr, [&op](son_statistics_object &sso) {
|
db().modify(*stats_itr, [&op](son_statistics_object &sso) {
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,51 @@
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
void_result create_son_wallet_withdraw_evaluator::do_evaluate(const son_wallet_withdraw_create_operation& op)
|
void_result create_son_wallet_withdraw_evaluator::do_evaluate(const son_wallet_withdraw_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( op.payer == db().get_global_properties().parameters.son_account(), "SON paying account must be set as payer." );
|
|
||||||
|
|
||||||
const auto &idx = db().get_index_type<son_stats_index>().indices().get<by_owner>();
|
const auto &son_idx = db().get_index_type<son_index>().indices().get<by_id>();
|
||||||
FC_ASSERT(idx.find(op.son_id) != idx.end(), "Statistic object for a given SON ID does not exists");
|
const auto so = son_idx.find(op.son_id);
|
||||||
|
FC_ASSERT(so != son_idx.end(), "SON not found");
|
||||||
|
FC_ASSERT(so->son_account == op.payer, "Payer is not SON account owner");
|
||||||
|
|
||||||
|
const auto &ss_idx = db().get_index_type<son_stats_index>().indices().get<by_owner>();
|
||||||
|
FC_ASSERT(ss_idx.find(op.son_id) != ss_idx.end(), "Statistic object for a given SON ID does not exists");
|
||||||
|
|
||||||
|
const auto &swwo_idx = db().get_index_type<son_wallet_withdraw_index>().indices().get<by_peerplays_uid>();
|
||||||
|
const auto swwo = swwo_idx.find(op.peerplays_uid);
|
||||||
|
if (swwo == swwo_idx.end()) {
|
||||||
|
auto &gpo = db().get_global_properties();
|
||||||
|
bool expected = false;
|
||||||
|
for (auto &si : gpo.active_sons) {
|
||||||
|
if (op.son_id == si.son_id) {
|
||||||
|
expected = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FC_ASSERT(expected, "Only active SON can create deposit");
|
||||||
|
} else {
|
||||||
|
bool exactly_the_same = true;
|
||||||
|
exactly_the_same = exactly_the_same && (swwo->sidechain == op.sidechain);
|
||||||
|
exactly_the_same = exactly_the_same && (swwo->peerplays_uid == op.peerplays_uid);
|
||||||
|
exactly_the_same = exactly_the_same && (swwo->peerplays_transaction_id == op.peerplays_transaction_id);
|
||||||
|
exactly_the_same = exactly_the_same && (swwo->peerplays_from == op.peerplays_from);
|
||||||
|
exactly_the_same = exactly_the_same && (swwo->peerplays_asset == op.peerplays_asset);
|
||||||
|
exactly_the_same = exactly_the_same && (swwo->withdraw_sidechain == op.withdraw_sidechain);
|
||||||
|
exactly_the_same = exactly_the_same && (swwo->withdraw_address == op.withdraw_address);
|
||||||
|
exactly_the_same = exactly_the_same && (swwo->withdraw_currency == op.withdraw_currency);
|
||||||
|
exactly_the_same = exactly_the_same && (swwo->withdraw_amount == op.withdraw_amount);
|
||||||
|
FC_ASSERT(exactly_the_same, "Invalid withdraw confirmation");
|
||||||
|
|
||||||
|
bool expected = false;
|
||||||
|
for (auto &exp : swwo->expected_reports) {
|
||||||
|
if (op.son_id == exp.first) {
|
||||||
|
expected = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FC_ASSERT(expected, "Confirmation from this SON not expected");
|
||||||
|
}
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
@ -37,7 +76,7 @@ object_id_type create_son_wallet_withdraw_evaluator::do_apply(const son_wallet_w
|
||||||
|
|
||||||
auto &gpo = db().get_global_properties();
|
auto &gpo = db().get_global_properties();
|
||||||
for (auto &si : gpo.active_sons) {
|
for (auto &si : gpo.active_sons) {
|
||||||
swwo.expected_reports.insert(si.son_id);
|
swwo.expected_reports.insert(std::make_pair(si.son_id, si.weight));
|
||||||
|
|
||||||
auto stats_itr = db().get_index_type<son_stats_index>().indices().get<by_owner>().find(si.son_id);
|
auto stats_itr = db().get_index_type<son_stats_index>().indices().get<by_owner>().find(si.son_id);
|
||||||
db().modify(*stats_itr, [&op, &si](son_statistics_object &sso) {
|
db().modify(*stats_itr, [&op, &si](son_statistics_object &sso) {
|
||||||
|
|
@ -50,12 +89,32 @@ object_id_type create_son_wallet_withdraw_evaluator::do_apply(const son_wallet_w
|
||||||
|
|
||||||
swwo.received_reports.insert(op.son_id);
|
swwo.received_reports.insert(op.son_id);
|
||||||
|
|
||||||
|
uint64_t total_weight = 0;
|
||||||
|
for (const auto exp : swwo.expected_reports) {
|
||||||
|
total_weight = total_weight + exp.second;
|
||||||
|
}
|
||||||
|
uint64_t current_weight = 0;
|
||||||
|
for (const auto rec : swwo.received_reports) {
|
||||||
|
current_weight = current_weight + swwo.expected_reports.find(rec)->second;
|
||||||
|
}
|
||||||
|
swwo.confirmed = (current_weight > (total_weight * 2 / 3));
|
||||||
|
|
||||||
swwo.processed = false;
|
swwo.processed = false;
|
||||||
});
|
});
|
||||||
return new_son_wallet_withdraw_object.id;
|
return new_son_wallet_withdraw_object.id;
|
||||||
} else {
|
} else {
|
||||||
db().modify(*itr, [&op](son_wallet_withdraw_object &swwo) {
|
db().modify(*itr, [&op](son_wallet_withdraw_object &swwo) {
|
||||||
swwo.received_reports.insert(op.son_id);
|
swwo.received_reports.insert(op.son_id);
|
||||||
|
|
||||||
|
uint64_t total_weight = 0;
|
||||||
|
for (const auto exp : swwo.expected_reports) {
|
||||||
|
total_weight = total_weight + exp.second;
|
||||||
|
}
|
||||||
|
uint64_t current_weight = 0;
|
||||||
|
for (const auto rec : swwo.received_reports) {
|
||||||
|
current_weight = current_weight + swwo.expected_reports.find(rec)->second;
|
||||||
|
}
|
||||||
|
swwo.confirmed = (current_weight > (total_weight * 2 / 3));
|
||||||
});
|
});
|
||||||
auto stats_itr = db().get_index_type<son_stats_index>().indices().get<by_owner>().find(op.son_id);
|
auto stats_itr = db().get_index_type<son_stats_index>().indices().get<by_owner>().find(op.son_id);
|
||||||
db().modify(*stats_itr, [&op](son_statistics_object &sso) {
|
db().modify(*stats_itr, [&op](son_statistics_object &sso) {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
namespace graphene { namespace peerplays_sidechain {
|
namespace graphene { namespace peerplays_sidechain {
|
||||||
|
|
||||||
|
using namespace graphene::chain;
|
||||||
|
|
||||||
using bytes = std::vector<unsigned char>;
|
using bytes = std::vector<unsigned char>;
|
||||||
|
|
||||||
struct prev_out {
|
struct prev_out {
|
||||||
|
|
@ -64,9 +66,9 @@ struct sidechain_event_data {
|
||||||
std::string sidechain_to;
|
std::string sidechain_to;
|
||||||
std::string sidechain_currency;
|
std::string sidechain_currency;
|
||||||
fc::safe<int64_t> sidechain_amount;
|
fc::safe<int64_t> sidechain_amount;
|
||||||
chain::account_id_type peerplays_from;
|
account_id_type peerplays_from;
|
||||||
chain::account_id_type peerplays_to;
|
account_id_type peerplays_to;
|
||||||
chain::asset peerplays_asset;
|
asset peerplays_asset;
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace graphene::peerplays_sidechain
|
}} // namespace graphene::peerplays_sidechain
|
||||||
|
|
|
||||||
|
|
@ -442,16 +442,6 @@ void peerplays_sidechain_plugin_impl::approve_proposals() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op_idx_0 == chain::operation::tag<chain::son_wallet_deposit_create_operation>::value) {
|
|
||||||
approve_proposal(get_current_son_id(), proposal.id);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (op_idx_0 == chain::operation::tag<chain::son_wallet_withdraw_create_operation>::value) {
|
|
||||||
approve_proposal(get_current_son_id(), proposal.id);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (op_idx_0 == chain::operation::tag<chain::son_wallet_withdraw_process_operation>::value) {
|
if (op_idx_0 == chain::operation::tag<chain::son_wallet_withdraw_process_operation>::value) {
|
||||||
approve_proposal(get_current_son_id(), proposal.id);
|
approve_proposal(get_current_son_id(), proposal.id);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -69,39 +69,32 @@ void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_
|
||||||
|
|
||||||
// Deposit request
|
// Deposit request
|
||||||
if ((sed.peerplays_to == gpo.parameters.son_account()) && (sed.sidechain_currency.compare("1.3.0") != 0)) {
|
if ((sed.peerplays_to == gpo.parameters.son_account()) && (sed.sidechain_currency.compare("1.3.0") != 0)) {
|
||||||
son_wallet_deposit_create_operation op;
|
|
||||||
op.payer = gpo.parameters.son_account();
|
|
||||||
//op.son_id = ; // to be filled for each son
|
|
||||||
op.timestamp = sed.timestamp;
|
|
||||||
op.sidechain = sed.sidechain;
|
|
||||||
op.sidechain_uid = sed.sidechain_uid;
|
|
||||||
op.sidechain_transaction_id = sed.sidechain_transaction_id;
|
|
||||||
op.sidechain_from = sed.sidechain_from;
|
|
||||||
op.sidechain_to = sed.sidechain_to;
|
|
||||||
op.sidechain_currency = sed.sidechain_currency;
|
|
||||||
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)) {
|
||||||
|
|
||||||
|
son_wallet_deposit_create_operation op;
|
||||||
|
op.payer = plugin.get_son_object(son_id).son_account;
|
||||||
op.son_id = son_id;
|
op.son_id = son_id;
|
||||||
|
op.timestamp = sed.timestamp;
|
||||||
|
op.sidechain = sed.sidechain;
|
||||||
|
op.sidechain_uid = sed.sidechain_uid;
|
||||||
|
op.sidechain_transaction_id = sed.sidechain_transaction_id;
|
||||||
|
op.sidechain_from = sed.sidechain_from;
|
||||||
|
op.sidechain_to = sed.sidechain_to;
|
||||||
|
op.sidechain_currency = sed.sidechain_currency;
|
||||||
|
op.sidechain_amount = sed.sidechain_amount;
|
||||||
|
op.peerplays_from = sed.peerplays_from;
|
||||||
|
op.peerplays_to = sed.peerplays_to;
|
||||||
|
op.peerplays_asset = sed.peerplays_asset;
|
||||||
|
|
||||||
proposal_create_operation proposal_op;
|
signed_transaction trx = database.create_signed_transaction(plugin.get_private_key(son_id), op);
|
||||||
proposal_op.fee_paying_account = plugin.get_son_object(son_id).son_account;
|
|
||||||
proposal_op.proposed_ops.emplace_back(op);
|
|
||||||
uint32_t lifetime = (gpo.parameters.block_interval * gpo.active_witnesses.size()) * 3;
|
|
||||||
proposal_op.expiration_time = time_point_sec(database.head_block_time().sec_since_epoch() + lifetime);
|
|
||||||
|
|
||||||
signed_transaction trx = 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) {
|
||||||
elog("Sending proposal for son wallet deposit create operation by ${son} failed with exception ${e}", ("son", son_id)("e", e.what()));
|
elog("Sending son wallet deposit create operation by ${son} failed with exception ${e}", ("son", son_id)("e", e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -116,38 +109,30 @@ void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_
|
||||||
if (addr_itr == sidechain_addresses_idx.end())
|
if (addr_itr == sidechain_addresses_idx.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
son_wallet_withdraw_create_operation op;
|
|
||||||
op.payer = gpo.parameters.son_account();
|
|
||||||
//op.son_id = ; // to be filled for each son
|
|
||||||
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()) {
|
for (son_id_type son_id : plugin.get_sons()) {
|
||||||
if (plugin.is_active_son(son_id)) {
|
if (plugin.is_active_son(son_id)) {
|
||||||
|
|
||||||
|
son_wallet_withdraw_create_operation op;
|
||||||
|
op.payer = plugin.get_son_object(son_id).son_account;
|
||||||
op.son_id = son_id;
|
op.son_id = son_id;
|
||||||
|
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)
|
||||||
|
|
||||||
proposal_create_operation proposal_op;
|
signed_transaction trx = database.create_signed_transaction(plugin.get_private_key(son_id), op);
|
||||||
proposal_op.fee_paying_account = plugin.get_son_object(son_id).son_account;
|
|
||||||
proposal_op.proposed_ops.emplace_back(op);
|
|
||||||
uint32_t lifetime = (gpo.parameters.block_interval * gpo.active_witnesses.size()) * 3;
|
|
||||||
proposal_op.expiration_time = time_point_sec(database.head_block_time().sec_since_epoch() + lifetime);
|
|
||||||
|
|
||||||
signed_transaction trx = 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) {
|
||||||
elog("Sending proposal for son wallet withdraw create operation by ${son} failed with exception ${e}", ("son", son_id)("e", e.what()));
|
elog("Sending son wallet withdraw create operation by ${son} failed with exception ${e}", ("son", son_id)("e", e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -158,8 +143,8 @@ void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_
|
||||||
}
|
}
|
||||||
|
|
||||||
void sidechain_net_handler::process_deposits() {
|
void sidechain_net_handler::process_deposits() {
|
||||||
const auto &idx = database.get_index_type<son_wallet_deposit_index>().indices().get<by_sidechain_and_processed>();
|
const auto &idx = database.get_index_type<son_wallet_deposit_index>().indices().get<by_sidechain_and_confirmed_and_processed>();
|
||||||
const auto &idx_range = idx.equal_range(std::make_tuple(sidechain, false));
|
const auto &idx_range = idx.equal_range(std::make_tuple(sidechain, true, false));
|
||||||
|
|
||||||
std::for_each(idx_range.first, idx_range.second, [&](const son_wallet_deposit_object &swdo) {
|
std::for_each(idx_range.first, idx_range.second, [&](const son_wallet_deposit_object &swdo) {
|
||||||
ilog("Deposit to process: ${swdo}", ("swdo", swdo));
|
ilog("Deposit to process: ${swdo}", ("swdo", swdo));
|
||||||
|
|
@ -203,8 +188,8 @@ void sidechain_net_handler::process_deposits() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sidechain_net_handler::process_withdrawals() {
|
void sidechain_net_handler::process_withdrawals() {
|
||||||
const auto &idx = database.get_index_type<son_wallet_withdraw_index>().indices().get<by_withdraw_sidechain_and_processed>();
|
const auto &idx = database.get_index_type<son_wallet_withdraw_index>().indices().get<by_withdraw_sidechain_and_confirmed_and_processed>();
|
||||||
const auto &idx_range = idx.equal_range(std::make_tuple(sidechain, false));
|
const auto &idx_range = idx.equal_range(std::make_tuple(sidechain, true, false));
|
||||||
|
|
||||||
std::for_each(idx_range.first, idx_range.second, [&](const son_wallet_withdraw_object &swwo) {
|
std::for_each(idx_range.first, idx_range.second, [&](const son_wallet_withdraw_object &swwo) {
|
||||||
ilog("Withdraw to process: ${swwo}", ("swwo", swwo));
|
ilog("Withdraw to process: ${swwo}", ("swwo", swwo));
|
||||||
|
|
|
||||||
|
|
@ -1336,7 +1336,7 @@ class wallet_api
|
||||||
string url,
|
string url,
|
||||||
vesting_balance_id_type deposit_id,
|
vesting_balance_id_type deposit_id,
|
||||||
vesting_balance_id_type pay_vb_id,
|
vesting_balance_id_type pay_vb_id,
|
||||||
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys,
|
flat_map<sidechain_type, string> sidechain_public_keys,
|
||||||
bool broadcast = false);
|
bool broadcast = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1351,7 +1351,7 @@ class wallet_api
|
||||||
signed_transaction update_son(string owner_account,
|
signed_transaction update_son(string owner_account,
|
||||||
string url,
|
string url,
|
||||||
string block_signing_key,
|
string block_signing_key,
|
||||||
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys,
|
flat_map<sidechain_type, string> sidechain_public_keys,
|
||||||
bool broadcast = false);
|
bool broadcast = false);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1438,7 +1438,7 @@ class wallet_api
|
||||||
* @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,
|
sidechain_type sidechain,
|
||||||
string deposit_address,
|
string deposit_address,
|
||||||
string withdraw_address,
|
string withdraw_address,
|
||||||
bool broadcast = false);
|
bool broadcast = false);
|
||||||
|
|
@ -1455,7 +1455,7 @@ class wallet_api
|
||||||
* @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,
|
sidechain_type sidechain,
|
||||||
string deposit_address,
|
string deposit_address,
|
||||||
string withdraw_address,
|
string withdraw_address,
|
||||||
bool broadcast = false);
|
bool broadcast = false);
|
||||||
|
|
@ -1468,7 +1468,7 @@ class wallet_api
|
||||||
* @returns the signed transaction updating sidechain address
|
* @returns the signed transaction updating sidechain address
|
||||||
*/
|
*/
|
||||||
signed_transaction delete_sidechain_address(string account,
|
signed_transaction delete_sidechain_address(string account,
|
||||||
peerplays_sidechain::sidechain_type sidechain,
|
sidechain_type sidechain,
|
||||||
bool broadcast = false);
|
bool broadcast = false);
|
||||||
|
|
||||||
/** Retrieves all sidechain addresses owned by given account.
|
/** Retrieves all sidechain addresses owned by given account.
|
||||||
|
|
@ -1483,7 +1483,7 @@ class wallet_api
|
||||||
* @param sidechain the name of the sidechain
|
* @param sidechain the name of the sidechain
|
||||||
* @returns the list of all sidechain addresses registered for a given sidechain.
|
* @returns the list of all sidechain addresses registered for a given sidechain.
|
||||||
*/
|
*/
|
||||||
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_sidechain(peerplays_sidechain::sidechain_type sidechain);
|
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_sidechain(sidechain_type sidechain);
|
||||||
|
|
||||||
/** Retrieves sidechain address owned by given account for a given sidechain.
|
/** Retrieves sidechain address owned by given account for a given sidechain.
|
||||||
*
|
*
|
||||||
|
|
@ -1491,7 +1491,7 @@ class wallet_api
|
||||||
* @param sidechain the name of the sidechain
|
* @param sidechain the name of the sidechain
|
||||||
* @returns the sidechain address owned by given account for a given sidechain.
|
* @returns the sidechain address owned by given account for a given sidechain.
|
||||||
*/
|
*/
|
||||||
fc::optional<sidechain_address_object> get_sidechain_address_by_account_and_sidechain(string account, peerplays_sidechain::sidechain_type sidechain);
|
fc::optional<sidechain_address_object> get_sidechain_address_by_account_and_sidechain(string account, sidechain_type sidechain);
|
||||||
|
|
||||||
/** Retrieves the total number of sidechain addresses registered in the system.
|
/** Retrieves the total number of sidechain addresses registered in the system.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1937,7 +1937,7 @@ public:
|
||||||
string url,
|
string url,
|
||||||
vesting_balance_id_type deposit_id,
|
vesting_balance_id_type deposit_id,
|
||||||
vesting_balance_id_type pay_vb_id,
|
vesting_balance_id_type pay_vb_id,
|
||||||
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys,
|
flat_map<sidechain_type, string> sidechain_public_keys,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
{ try {
|
{ try {
|
||||||
fc::scoped_lock<fc::mutex> lock(_resync_mutex);
|
fc::scoped_lock<fc::mutex> lock(_resync_mutex);
|
||||||
|
|
@ -1966,7 +1966,7 @@ public:
|
||||||
signed_transaction update_son(string owner_account,
|
signed_transaction update_son(string owner_account,
|
||||||
string url,
|
string url,
|
||||||
string block_signing_key,
|
string block_signing_key,
|
||||||
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys,
|
flat_map<sidechain_type, string> sidechain_public_keys,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
{ try {
|
{ try {
|
||||||
son_object son = get_son(owner_account);
|
son_object son = get_son(owner_account);
|
||||||
|
|
@ -2096,7 +2096,7 @@ public:
|
||||||
} FC_CAPTURE_AND_RETHROW() }
|
} FC_CAPTURE_AND_RETHROW() }
|
||||||
|
|
||||||
signed_transaction add_sidechain_address(string account,
|
signed_transaction add_sidechain_address(string account,
|
||||||
peerplays_sidechain::sidechain_type sidechain,
|
sidechain_type sidechain,
|
||||||
string deposit_address,
|
string deposit_address,
|
||||||
string withdraw_address,
|
string withdraw_address,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
|
|
@ -2118,7 +2118,7 @@ public:
|
||||||
} FC_CAPTURE_AND_RETHROW() }
|
} FC_CAPTURE_AND_RETHROW() }
|
||||||
|
|
||||||
signed_transaction update_sidechain_address(string account,
|
signed_transaction update_sidechain_address(string account,
|
||||||
peerplays_sidechain::sidechain_type sidechain,
|
sidechain_type sidechain,
|
||||||
string deposit_address,
|
string deposit_address,
|
||||||
string withdraw_address,
|
string withdraw_address,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
|
|
@ -2144,7 +2144,7 @@ public:
|
||||||
} FC_CAPTURE_AND_RETHROW() }
|
} FC_CAPTURE_AND_RETHROW() }
|
||||||
|
|
||||||
signed_transaction delete_sidechain_address(string account,
|
signed_transaction delete_sidechain_address(string account,
|
||||||
peerplays_sidechain::sidechain_type sidechain,
|
sidechain_type sidechain,
|
||||||
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);
|
||||||
|
|
@ -4721,7 +4721,7 @@ signed_transaction wallet_api::create_son(string owner_account,
|
||||||
string url,
|
string url,
|
||||||
vesting_balance_id_type deposit_id,
|
vesting_balance_id_type deposit_id,
|
||||||
vesting_balance_id_type pay_vb_id,
|
vesting_balance_id_type pay_vb_id,
|
||||||
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys,
|
flat_map<sidechain_type, string> sidechain_public_keys,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
{
|
{
|
||||||
return my->create_son(owner_account, url, deposit_id, pay_vb_id, sidechain_public_keys, broadcast);
|
return my->create_son(owner_account, url, deposit_id, pay_vb_id, sidechain_public_keys, broadcast);
|
||||||
|
|
@ -4730,7 +4730,7 @@ signed_transaction wallet_api::create_son(string owner_account,
|
||||||
signed_transaction wallet_api::update_son(string owner_account,
|
signed_transaction wallet_api::update_son(string owner_account,
|
||||||
string url,
|
string url,
|
||||||
string block_signing_key,
|
string block_signing_key,
|
||||||
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys,
|
flat_map<sidechain_type, string> sidechain_public_keys,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
{
|
{
|
||||||
return my->update_son(owner_account, url, block_signing_key, sidechain_public_keys, broadcast);
|
return my->update_son(owner_account, url, block_signing_key, sidechain_public_keys, broadcast);
|
||||||
|
|
@ -4778,7 +4778,7 @@ 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,
|
sidechain_type sidechain,
|
||||||
string deposit_address,
|
string deposit_address,
|
||||||
string withdraw_address,
|
string withdraw_address,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
|
|
@ -4787,7 +4787,7 @@ signed_transaction wallet_api::add_sidechain_address(string account,
|
||||||
}
|
}
|
||||||
|
|
||||||
signed_transaction wallet_api::update_sidechain_address(string account,
|
signed_transaction wallet_api::update_sidechain_address(string account,
|
||||||
peerplays_sidechain::sidechain_type sidechain,
|
sidechain_type sidechain,
|
||||||
string deposit_address,
|
string deposit_address,
|
||||||
string withdraw_address,
|
string withdraw_address,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
|
|
@ -4796,7 +4796,7 @@ signed_transaction wallet_api::update_sidechain_address(string account,
|
||||||
}
|
}
|
||||||
|
|
||||||
signed_transaction wallet_api::delete_sidechain_address(string account,
|
signed_transaction wallet_api::delete_sidechain_address(string account,
|
||||||
peerplays_sidechain::sidechain_type sidechain,
|
sidechain_type sidechain,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
{
|
{
|
||||||
return my->delete_sidechain_address(account, sidechain, broadcast);
|
return my->delete_sidechain_address(account, sidechain, broadcast);
|
||||||
|
|
@ -4808,12 +4808,12 @@ vector<optional<sidechain_address_object>> wallet_api::get_sidechain_addresses_b
|
||||||
return my->_remote_db->get_sidechain_addresses_by_account(account_id);
|
return my->_remote_db->get_sidechain_addresses_by_account(account_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<optional<sidechain_address_object>> wallet_api::get_sidechain_addresses_by_sidechain(peerplays_sidechain::sidechain_type sidechain)
|
vector<optional<sidechain_address_object>> wallet_api::get_sidechain_addresses_by_sidechain(sidechain_type sidechain)
|
||||||
{
|
{
|
||||||
return my->_remote_db->get_sidechain_addresses_by_sidechain(sidechain);
|
return my->_remote_db->get_sidechain_addresses_by_sidechain(sidechain);
|
||||||
}
|
}
|
||||||
|
|
||||||
fc::optional<sidechain_address_object> wallet_api::get_sidechain_address_by_account_and_sidechain(string account, peerplays_sidechain::sidechain_type sidechain)
|
fc::optional<sidechain_address_object> wallet_api::get_sidechain_address_by_account_and_sidechain(string account, sidechain_type sidechain)
|
||||||
{
|
{
|
||||||
account_id_type account_id = get_account_id(account);
|
account_id_type account_id = get_account_id(account);
|
||||||
return my->_remote_db->get_sidechain_address_by_account_and_sidechain(account_id, sidechain);
|
return my->_remote_db->get_sidechain_address_by_account_and_sidechain(account_id, sidechain);
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_son(const std::string& account_name, const std::string& son_url,
|
void create_son(const std::string& account_name, const std::string& son_url,
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string>& sidechain_public_keys,
|
flat_map<sidechain_type, string>& sidechain_public_keys,
|
||||||
bool generate_maintenance = true)
|
bool generate_maintenance = true)
|
||||||
{
|
{
|
||||||
graphene::wallet::brain_key_info bki;
|
graphene::wallet::brain_key_info bki;
|
||||||
|
|
@ -112,16 +112,16 @@ BOOST_AUTO_TEST_CASE( create_sons )
|
||||||
BOOST_TEST_MESSAGE("SON cli wallet tests begin");
|
BOOST_TEST_MESSAGE("SON cli wallet tests begin");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
|
|
||||||
son_test_helper sth(*this);
|
son_test_helper sth(*this);
|
||||||
|
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 1";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address 1";
|
||||||
sth.create_son("son1account", "http://son1", sidechain_public_keys);
|
sth.create_son("son1account", "http://son1", sidechain_public_keys);
|
||||||
|
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 2";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address 2";
|
||||||
sth.create_son("son2account", "http://son2", sidechain_public_keys);
|
sth.create_son("son2account", "http://son2", sidechain_public_keys);
|
||||||
|
|
||||||
auto son1_obj = con.wallet_api_ptr->get_son("son1account");
|
auto son1_obj = con.wallet_api_ptr->get_son("son1account");
|
||||||
|
|
@ -146,10 +146,10 @@ BOOST_AUTO_TEST_CASE( cli_update_son )
|
||||||
{
|
{
|
||||||
BOOST_TEST_MESSAGE("Cli get_son and update_son Test");
|
BOOST_TEST_MESSAGE("Cli get_son and update_son Test");
|
||||||
|
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
|
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 1";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address 1";
|
||||||
|
|
||||||
son_test_helper sth(*this);
|
son_test_helper sth(*this);
|
||||||
sth.create_son("sonmember", "http://sonmember", sidechain_public_keys);
|
sth.create_son("sonmember", "http://sonmember", sidechain_public_keys);
|
||||||
|
|
@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE( cli_update_son )
|
||||||
|
|
||||||
// update SON
|
// update SON
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 2";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address 2";
|
||||||
|
|
||||||
con.wallet_api_ptr->update_son("sonmember", "http://sonmember_updated", "", sidechain_public_keys, true);
|
con.wallet_api_ptr->update_son("sonmember", "http://sonmember_updated", "", sidechain_public_keys, true);
|
||||||
son_data = con.wallet_api_ptr->get_son("sonmember");
|
son_data = con.wallet_api_ptr->get_son("sonmember");
|
||||||
|
|
@ -187,16 +187,16 @@ BOOST_AUTO_TEST_CASE( son_voting )
|
||||||
BOOST_TEST_MESSAGE("SON Vote cli wallet tests begin");
|
BOOST_TEST_MESSAGE("SON Vote cli wallet tests begin");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
|
|
||||||
son_test_helper sth(*this);
|
son_test_helper sth(*this);
|
||||||
|
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 1";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address 1";
|
||||||
sth.create_son("son1account", "http://son1", sidechain_public_keys);
|
sth.create_son("son1account", "http://son1", sidechain_public_keys);
|
||||||
|
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 2";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address 2";
|
||||||
sth.create_son("son2account", "http://son2", sidechain_public_keys);
|
sth.create_son("son2account", "http://son2", sidechain_public_keys);
|
||||||
|
|
||||||
BOOST_TEST_MESSAGE("Voting for SONs");
|
BOOST_TEST_MESSAGE("Voting for SONs");
|
||||||
|
|
@ -267,16 +267,16 @@ BOOST_AUTO_TEST_CASE( delete_son )
|
||||||
BOOST_TEST_MESSAGE("SON delete cli wallet tests begin");
|
BOOST_TEST_MESSAGE("SON delete cli wallet tests begin");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
|
|
||||||
son_test_helper sth(*this);
|
son_test_helper sth(*this);
|
||||||
|
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 1";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address 1";
|
||||||
sth.create_son("son1account", "http://son1", sidechain_public_keys);
|
sth.create_son("son1account", "http://son1", sidechain_public_keys);
|
||||||
|
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 2";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address 2";
|
||||||
sth.create_son("son2account", "http://son2", sidechain_public_keys);
|
sth.create_son("son2account", "http://son2", sidechain_public_keys);
|
||||||
|
|
||||||
BOOST_TEST_MESSAGE("Deleting SONs");
|
BOOST_TEST_MESSAGE("Deleting SONs");
|
||||||
|
|
@ -315,13 +315,13 @@ BOOST_FIXTURE_TEST_CASE( select_top_fifteen_sons, cli_fixture )
|
||||||
gpo = con.wallet_api_ptr->get_global_properties();
|
gpo = con.wallet_api_ptr->get_global_properties();
|
||||||
unsigned int son_number = gpo.parameters.maximum_son_count;
|
unsigned int son_number = gpo.parameters.maximum_son_count;
|
||||||
|
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
|
|
||||||
// create son accounts
|
// create son accounts
|
||||||
for(unsigned int i = 0; i < son_number + 1; i++)
|
for(unsigned int i = 0; i < son_number + 1; i++)
|
||||||
{
|
{
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address " + fc::to_pretty_string(i);
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address " + fc::to_pretty_string(i);
|
||||||
sth.create_son("sonaccount" + fc::to_pretty_string(i),
|
sth.create_son("sonaccount" + fc::to_pretty_string(i),
|
||||||
"http://son" + fc::to_pretty_string(i),
|
"http://son" + fc::to_pretty_string(i),
|
||||||
sidechain_public_keys,
|
sidechain_public_keys,
|
||||||
|
|
@ -390,16 +390,16 @@ BOOST_AUTO_TEST_CASE( list_son )
|
||||||
BOOST_TEST_MESSAGE("List SONs cli wallet tests begin");
|
BOOST_TEST_MESSAGE("List SONs cli wallet tests begin");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
|
|
||||||
son_test_helper sth(*this);
|
son_test_helper sth(*this);
|
||||||
|
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 1";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address 1";
|
||||||
sth.create_son("son1account", "http://son1", sidechain_public_keys);
|
sth.create_son("son1account", "http://son1", sidechain_public_keys);
|
||||||
|
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 2";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address 2";
|
||||||
sth.create_son("son2account", "http://son2", sidechain_public_keys);
|
sth.create_son("son2account", "http://son2", sidechain_public_keys);
|
||||||
|
|
||||||
auto res = con.wallet_api_ptr->list_sons("", 100);
|
auto res = con.wallet_api_ptr->list_sons("", 100);
|
||||||
|
|
@ -420,16 +420,16 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
BOOST_TEST_MESSAGE("SON update_son_votes cli wallet tests begin");
|
BOOST_TEST_MESSAGE("SON update_son_votes cli wallet tests begin");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
|
|
||||||
son_test_helper sth(*this);
|
son_test_helper sth(*this);
|
||||||
|
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 1";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address 1";
|
||||||
sth.create_son("son1account", "http://son1", sidechain_public_keys);
|
sth.create_son("son1account", "http://son1", sidechain_public_keys);
|
||||||
|
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 2";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address 2";
|
||||||
sth.create_son("son2account", "http://son2", sidechain_public_keys);
|
sth.create_son("son2account", "http://son2", sidechain_public_keys);
|
||||||
|
|
||||||
BOOST_TEST_MESSAGE("Vote for 2 accounts with update_son_votes");
|
BOOST_TEST_MESSAGE("Vote for 2 accounts with update_son_votes");
|
||||||
|
|
@ -579,16 +579,16 @@ BOOST_AUTO_TEST_CASE( related_functions )
|
||||||
global_property_object gpo = con.wallet_api_ptr->get_global_properties();
|
global_property_object gpo = con.wallet_api_ptr->get_global_properties();
|
||||||
BOOST_CHECK(gpo.active_sons.size() == 0);
|
BOOST_CHECK(gpo.active_sons.size() == 0);
|
||||||
|
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
|
|
||||||
son_test_helper sth(*this);
|
son_test_helper sth(*this);
|
||||||
|
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 1";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address 1";
|
||||||
sth.create_son("son1account", "http://son1", sidechain_public_keys);
|
sth.create_son("son1account", "http://son1", sidechain_public_keys);
|
||||||
|
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 2";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address 2";
|
||||||
sth.create_son("son2account", "http://son2", sidechain_public_keys);
|
sth.create_son("son2account", "http://son2", sidechain_public_keys);
|
||||||
|
|
||||||
gpo = con.wallet_api_ptr->get_global_properties();
|
gpo = con.wallet_api_ptr->get_global_properties();
|
||||||
|
|
@ -615,13 +615,13 @@ BOOST_FIXTURE_TEST_CASE( cli_list_active_sons, cli_fixture )
|
||||||
gpo = con.wallet_api_ptr->get_global_properties();
|
gpo = con.wallet_api_ptr->get_global_properties();
|
||||||
unsigned int son_number = gpo.parameters.maximum_son_count;
|
unsigned int son_number = gpo.parameters.maximum_son_count;
|
||||||
|
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
|
|
||||||
// create son accounts
|
// create son accounts
|
||||||
for(unsigned int i = 0; i < son_number + 1; i++)
|
for(unsigned int i = 0; i < son_number + 1; i++)
|
||||||
{
|
{
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address " + fc::to_pretty_string(i);
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address " + fc::to_pretty_string(i);
|
||||||
sth.create_son("sonaccount" + fc::to_pretty_string(i),
|
sth.create_son("sonaccount" + fc::to_pretty_string(i),
|
||||||
"http://son" + fc::to_pretty_string(i),
|
"http://son" + fc::to_pretty_string(i),
|
||||||
sidechain_public_keys,
|
sidechain_public_keys,
|
||||||
|
|
@ -684,13 +684,13 @@ BOOST_AUTO_TEST_CASE( maintenance_test )
|
||||||
gpo = con.wallet_api_ptr->get_global_properties();
|
gpo = con.wallet_api_ptr->get_global_properties();
|
||||||
unsigned int son_number = gpo.parameters.maximum_son_count;
|
unsigned int son_number = gpo.parameters.maximum_son_count;
|
||||||
|
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
|
|
||||||
// create son accounts
|
// create son accounts
|
||||||
for(unsigned int i = 0; i < son_number + 1; i++)
|
for(unsigned int i = 0; i < son_number + 1; i++)
|
||||||
{
|
{
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address " + fc::to_pretty_string(i);
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address " + fc::to_pretty_string(i);
|
||||||
sth.create_son("sonaccount" + fc::to_pretty_string(i),
|
sth.create_son("sonaccount" + fc::to_pretty_string(i),
|
||||||
"http://son" + fc::to_pretty_string(i),
|
"http://son" + fc::to_pretty_string(i),
|
||||||
sidechain_public_keys,
|
sidechain_public_keys,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ BOOST_AUTO_TEST_CASE( sidechain_address_add_test ) {
|
||||||
sidechain_address_add_operation op;
|
sidechain_address_add_operation op;
|
||||||
|
|
||||||
op.sidechain_address_account = alice_id;
|
op.sidechain_address_account = alice_id;
|
||||||
op.sidechain = graphene::peerplays_sidechain::sidechain_type::bitcoin;
|
op.sidechain = sidechain_type::bitcoin;
|
||||||
op.deposit_address = "deposit_address";
|
op.deposit_address = "deposit_address";
|
||||||
op.withdraw_address = "withdraw_address";
|
op.withdraw_address = "withdraw_address";
|
||||||
|
|
||||||
|
|
@ -43,10 +43,10 @@ BOOST_AUTO_TEST_CASE( sidechain_address_add_test ) {
|
||||||
|
|
||||||
const auto& idx = db.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
const auto& idx = db.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
||||||
BOOST_REQUIRE( idx.size() == 1 );
|
BOOST_REQUIRE( idx.size() == 1 );
|
||||||
auto obj = idx.find( boost::make_tuple( alice_id, graphene::peerplays_sidechain::sidechain_type::bitcoin ) );
|
auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin ) );
|
||||||
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 == sidechain_type::bitcoin );
|
||||||
BOOST_CHECK( obj->deposit_address == "deposit_address" );
|
BOOST_CHECK( obj->deposit_address == "deposit_address" );
|
||||||
BOOST_CHECK( obj->withdraw_address == "withdraw_address" );
|
BOOST_CHECK( obj->withdraw_address == "withdraw_address" );
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE( sidechain_address_update_test ) {
|
||||||
|
|
||||||
const auto& idx = db.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
const auto& idx = db.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
||||||
BOOST_REQUIRE( idx.size() == 1 );
|
BOOST_REQUIRE( idx.size() == 1 );
|
||||||
auto obj = idx.find( boost::make_tuple( alice_id, graphene::peerplays_sidechain::sidechain_type::bitcoin ) );
|
auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin ) );
|
||||||
BOOST_REQUIRE( obj != idx.end() );
|
BOOST_REQUIRE( obj != idx.end() );
|
||||||
|
|
||||||
std::string new_deposit_address = "new_deposit_address";
|
std::string new_deposit_address = "new_deposit_address";
|
||||||
|
|
@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE( sidechain_address_update_test ) {
|
||||||
|
|
||||||
const auto& idx = db.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
const auto& idx = db.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
||||||
BOOST_REQUIRE( idx.size() == 1 );
|
BOOST_REQUIRE( idx.size() == 1 );
|
||||||
auto obj = idx.find( boost::make_tuple( alice_id, graphene::peerplays_sidechain::sidechain_type::bitcoin ) );
|
auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin ) );
|
||||||
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 );
|
||||||
|
|
@ -107,7 +107,7 @@ BOOST_AUTO_TEST_CASE( sidechain_address_delete_test ) {
|
||||||
|
|
||||||
const auto& idx = db.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
const auto& idx = db.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
||||||
BOOST_REQUIRE( idx.size() == 1 );
|
BOOST_REQUIRE( idx.size() == 1 );
|
||||||
auto obj = idx.find( boost::make_tuple( alice_id, graphene::peerplays_sidechain::sidechain_type::bitcoin ) );
|
auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin ) );
|
||||||
BOOST_REQUIRE( obj != idx.end() );
|
BOOST_REQUIRE( obj != idx.end() );
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -129,7 +129,7 @@ BOOST_AUTO_TEST_CASE( sidechain_address_delete_test ) {
|
||||||
|
|
||||||
const auto& idx = db.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
const auto& idx = db.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
||||||
BOOST_REQUIRE( idx.size() == 0 );
|
BOOST_REQUIRE( idx.size() == 0 );
|
||||||
auto obj = idx.find( boost::make_tuple( alice_id, graphene::peerplays_sidechain::sidechain_type::bitcoin ) );
|
auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin ) );
|
||||||
BOOST_REQUIRE( obj == idx.end() );
|
BOOST_REQUIRE( obj == idx.end() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,8 @@ BOOST_AUTO_TEST_CASE( create_son_test ) {
|
||||||
|
|
||||||
// alice became son
|
// alice became son
|
||||||
{
|
{
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin address";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin address";
|
||||||
|
|
||||||
son_create_operation op;
|
son_create_operation op;
|
||||||
op.owner_account = alice_id;
|
op.owner_account = alice_id;
|
||||||
|
|
@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE( create_son_test ) {
|
||||||
BOOST_REQUIRE( obj != idx.end() );
|
BOOST_REQUIRE( obj != idx.end() );
|
||||||
BOOST_CHECK( obj->url == test_url );
|
BOOST_CHECK( obj->url == test_url );
|
||||||
BOOST_CHECK( obj->signing_key == alice_public_key );
|
BOOST_CHECK( obj->signing_key == alice_public_key );
|
||||||
BOOST_CHECK( obj->sidechain_public_keys.at(graphene::peerplays_sidechain::sidechain_type::bitcoin) == "bitcoin address" );
|
BOOST_CHECK( obj->sidechain_public_keys.at(sidechain_type::bitcoin) == "bitcoin address" );
|
||||||
BOOST_CHECK( obj->deposit.instance == deposit.instance.value );
|
BOOST_CHECK( obj->deposit.instance == deposit.instance.value );
|
||||||
BOOST_CHECK( obj->pay_vb.instance == payment.instance.value );
|
BOOST_CHECK( obj->pay_vb.instance == payment.instance.value );
|
||||||
}
|
}
|
||||||
|
|
@ -118,8 +118,8 @@ BOOST_AUTO_TEST_CASE( update_son_test ) {
|
||||||
std::string new_url = "https://anewurl.com";
|
std::string new_url = "https://anewurl.com";
|
||||||
|
|
||||||
{
|
{
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "new bitcoin address";
|
sidechain_public_keys[sidechain_type::bitcoin] = "new bitcoin address";
|
||||||
|
|
||||||
son_update_operation op;
|
son_update_operation op;
|
||||||
op.son_id = son_id_type(0);
|
op.son_id = son_id_type(0);
|
||||||
|
|
@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE( update_son_test ) {
|
||||||
auto obj = idx.find( alice_id );
|
auto obj = idx.find( alice_id );
|
||||||
BOOST_REQUIRE( obj != idx.end() );
|
BOOST_REQUIRE( obj != idx.end() );
|
||||||
BOOST_CHECK( obj->url == new_url );
|
BOOST_CHECK( obj->url == new_url );
|
||||||
BOOST_CHECK( obj->sidechain_public_keys.at(graphene::peerplays_sidechain::sidechain_type::bitcoin) == "new bitcoin address" );
|
BOOST_CHECK( obj->sidechain_public_keys.at(sidechain_type::bitcoin) == "new bitcoin address" );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( delete_son_test ) {
|
BOOST_AUTO_TEST_CASE( delete_son_test ) {
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,8 @@ BOOST_AUTO_TEST_CASE( son_wallet_recreate_test ) {
|
||||||
|
|
||||||
// alice becomes son
|
// alice becomes son
|
||||||
{
|
{
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin address";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin address";
|
||||||
|
|
||||||
son_create_operation op;
|
son_create_operation op;
|
||||||
op.owner_account = alice_id;
|
op.owner_account = alice_id;
|
||||||
|
|
@ -126,8 +126,8 @@ BOOST_AUTO_TEST_CASE( son_wallet_recreate_test ) {
|
||||||
|
|
||||||
// bob becomes son
|
// bob becomes son
|
||||||
{
|
{
|
||||||
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin address";
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin address";
|
||||||
|
|
||||||
son_create_operation op;
|
son_create_operation op;
|
||||||
op.owner_account = bob_id;
|
op.owner_account = bob_id;
|
||||||
|
|
@ -157,18 +157,18 @@ BOOST_AUTO_TEST_CASE( son_wallet_recreate_test ) {
|
||||||
{
|
{
|
||||||
son_info si;
|
son_info si;
|
||||||
si.son_id = son_id_type(0);
|
si.son_id = son_id_type(0);
|
||||||
si.total_votes = 1000;
|
si.weight = 1000;
|
||||||
si.signing_key = alice_public_key;
|
si.signing_key = alice_public_key;
|
||||||
si.sidechain_public_keys[peerplays_sidechain::sidechain_type::bitcoin] = "";
|
si.sidechain_public_keys[sidechain_type::bitcoin] = "";
|
||||||
op.sons.push_back(si);
|
op.sons.push_back(si);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
son_info si;
|
son_info si;
|
||||||
si.son_id = son_id_type(1);
|
si.son_id = son_id_type(1);
|
||||||
si.total_votes = 1000;
|
si.weight = 1000;
|
||||||
si.signing_key = bob_public_key;
|
si.signing_key = bob_public_key;
|
||||||
si.sidechain_public_keys[peerplays_sidechain::sidechain_type::bitcoin] = "";
|
si.sidechain_public_keys[sidechain_type::bitcoin] = "";
|
||||||
op.sons.push_back(si);
|
op.sons.push_back(si);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -201,7 +201,7 @@ BOOST_AUTO_TEST_CASE( son_wallet_update_test ) {
|
||||||
|
|
||||||
op.payer = db.get_global_properties().parameters.son_account();
|
op.payer = db.get_global_properties().parameters.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 = sidechain_type::bitcoin;
|
||||||
op.address = "bitcoin address";
|
op.address = "bitcoin address";
|
||||||
|
|
||||||
trx.operations.push_back(op);
|
trx.operations.push_back(op);
|
||||||
|
|
@ -217,7 +217,7 @@ BOOST_AUTO_TEST_CASE( son_wallet_update_test ) {
|
||||||
BOOST_REQUIRE( idx.size() == 1 );
|
BOOST_REQUIRE( idx.size() == 1 );
|
||||||
auto obj = idx.find(son_wallet_id_type(0));
|
auto obj = idx.find(son_wallet_id_type(0));
|
||||||
BOOST_REQUIRE( obj != idx.end() );
|
BOOST_REQUIRE( obj != idx.end() );
|
||||||
BOOST_REQUIRE( obj->addresses.at(graphene::peerplays_sidechain::sidechain_type::bitcoin) == "bitcoin address" );
|
BOOST_REQUIRE( obj->addresses.at(sidechain_type::bitcoin) == "bitcoin address" );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue