Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wallet compatibility issue #1323

Merged
merged 12 commits into from Oct 16, 2018
82 changes: 73 additions & 9 deletions libraries/wallet/wallet.cpp
Expand Up @@ -1480,7 +1480,15 @@ class wallet_api_impl
committee_member_create_operation committee_member_create_op;
committee_member_create_op.committee_member_account = get_account_id(owner_account);
committee_member_create_op.url = url;
if (_remote_db->get_committee_member_by_account(owner_account))

/*
* Compatibility issue
* Current Date: 2018-09-28 More info: https://github.com/bitshares/bitshares-core/issues/1307
* Todo: remove the next 2 lines and change always_id to name in remote call after next hardfork
*/
auto account = get_account(owner_account);
auto always_id = account_id_to_string(account.id);
if (_remote_db->get_committee_member_by_account(always_id))
FC_THROW("Account ${owner_account} is already a committee_member", ("owner_account", owner_account));

signed_transaction tx;
Expand Down Expand Up @@ -1738,8 +1746,15 @@ class wallet_api_impl
result.emplace_back( get_object<vesting_balance_object>(*vbid), now );
return result;
}

vector< vesting_balance_object > vbos = _remote_db->get_vesting_balances( account_name );
/*
* Compatibility issue
* Current Date: 2018-09-28 More info: https://github.com/bitshares/bitshares-core/issues/1307
* Todo: remove the next 2 lines and change always_id to name in remote call after next hardfork
*/
auto account = get_account(account_name);
auto always_id = account_id_to_string(account.id);

vector< vesting_balance_object > vbos = _remote_db->get_vesting_balances( always_id );
if( vbos.size() == 0 )
return result;

Expand Down Expand Up @@ -1787,7 +1802,15 @@ class wallet_api_impl
bool broadcast /* = false */)
{ try {
account_object voting_account_object = get_account(voting_account);
fc::optional<committee_member_object> committee_member_obj = _remote_db->get_committee_member_by_account(committee_member);

/*
* Compatibility issue
* Current Date: 2018-09-28 More info: https://github.com/bitshares/bitshares-core/issues/1307
* Todo: remove the next 2 lines and change always_id to name in remote call after next hardfork
*/
auto account = get_account(committee_member);
auto always_id = account_id_to_string(account.id);
fc::optional<committee_member_object> committee_member_obj = _remote_db->get_committee_member_by_account(always_id);
if (!committee_member_obj)
FC_THROW("Account ${committee_member} is not registered as a committee_member", ("committee_member", committee_member));
if (approve)
Expand Down Expand Up @@ -1821,7 +1844,14 @@ class wallet_api_impl
{ try {
account_object voting_account_object = get_account(voting_account);

fc::optional<witness_object> witness_obj = _remote_db->get_witness_by_account(witness);
/*
* Compatibility issue
* Current Date: 2018-09-28 More info: https://github.com/bitshares/bitshares-core/issues/1307
* Todo: remove the next 2 lines and change always_id to name in remote call after next hardfork
*/
auto account = get_account(witness);
auto always_id = account_id_to_string(account.id);
fc::optional<witness_object> witness_obj = _remote_db->get_witness_by_account(always_id);
if (!witness_obj)
FC_THROW("Account ${witness} is not registered as a witness", ("witness", witness));
if (approve)
Expand Down Expand Up @@ -2961,7 +2991,15 @@ map<string,account_id_type> wallet_api::list_accounts(const string& lowerbound,

vector<asset> wallet_api::list_account_balances(const string& id)
{
return my->_remote_db->get_account_balances(id, flat_set<asset_id_type>());
/*
* Compatibility issue
* Current Date: 2018-09-13 More info: https://github.com/bitshares/bitshares-core/issues/1307
* Todo: remove the next 2 lines and change always_id to id in remote call after next hardfork
*/
auto account = get_account(id);
auto always_id = my->account_id_to_string(account.id);

return my->_remote_db->get_account_balances(always_id, flat_set<asset_id_type>());
}

vector<asset_object> wallet_api::list_assets(const string& lowerbound, uint32_t limit)const
Expand All @@ -2978,6 +3016,14 @@ vector<operation_detail> wallet_api::get_account_history(string name, int limit)
{
vector<operation_detail> result;

/*
* Compatibility issue
* Current Date: 2018-09-14 More info: https://github.com/bitshares/bitshares-core/issues/1307
* Todo: remove the next 2 lines and change always_id to name in remote call after next hardfork
*/
auto account = get_account(name);
auto always_id = my->account_id_to_string(account.id);

while( limit > 0 )
{
bool skip_first_row = false;
Expand All @@ -2997,7 +3043,8 @@ vector<operation_detail> wallet_api::get_account_history(string name, int limit)

int page_limit = skip_first_row ? std::min( 100, limit + 1 ) : std::min( 100, limit );

vector<operation_history_object> current = my->_remote_hist->get_account_history( name, operation_history_id_type(),
vector<operation_history_object> current = my->_remote_hist->get_account_history( always_id,
operation_history_id_type(),
page_limit, start );
bool first_row = true;
for( auto& o : current )
Expand Down Expand Up @@ -3034,14 +3081,24 @@ vector<operation_detail> wallet_api::get_relative_account_history(string name, u
const account_object& account = my->get_account(account_id);
const account_statistics_object& stats = my->get_object(account.statistics);

/*
* Compatibility issue
* Current Date: 2018-09-14 More info: https://github.com/bitshares/bitshares-core/issues/1307
* Todo: remove the next line and change always_id to name in remote call after next hardfork
*/
auto always_id = my->account_id_to_string(account_id);

if(start == 0)
start = stats.total_ops;
else
start = std::min<uint32_t>(start, stats.total_ops);

while( limit > 0 )
{
vector <operation_history_object> current = my->_remote_hist->get_relative_account_history(name, stop, std::min<uint32_t>(100, limit), start);
vector <operation_history_object> current = my->_remote_hist->get_relative_account_history(always_id,
stop,
std::min<uint32_t>(100, limit),
start);
for (auto &o : current) {
std::stringstream ss;
auto memo = o.op.visit(detail::operation_printer(ss, *my, o.result));
Expand All @@ -3064,6 +3121,13 @@ account_history_operation_detail wallet_api::get_account_history_by_operations(s
const auto& account = my->get_account(account_id);
const auto& stats = my->get_object(account.statistics);

/*
* Compatibility issue
* Current Date: 2018-09-14 More info: https://github.com/bitshares/bitshares-core/issues/1307
* Todo: remove the next line and change always_id to name in remote call after next hardfork
*/
auto always_id = my->account_id_to_string(account_id);

// sequence of account_transaction_history_object start with 1
start = start == 0 ? 1 : start;

Expand All @@ -3074,7 +3138,7 @@ account_history_operation_detail wallet_api::get_account_history_by_operations(s

while (limit > 0 && start <= stats.total_ops) {
uint32_t min_limit = std::min<uint32_t> (100, limit);
auto current = my->_remote_hist->get_account_history_by_operations(name, operation_types, start, min_limit);
auto current = my->_remote_hist->get_account_history_by_operations(always_id, operation_types, start, min_limit);
for (auto& obj : current.operation_history_objs) {
std::stringstream ss;
auto memo = obj.op.visit(detail::operation_printer(ss, *my, obj.result));
Expand Down