Skip to content

Commit

Permalink
LW: fix BitAsset fees serverside (needs testing)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielhourt committed Feb 2, 2015
1 parent 3eac06e commit 4b68dbf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions libraries/client/blockchain_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,15 @@ vector<burn_record> client_impl::blockchain_get_account_wall( const string& acco
void client_impl::blockchain_broadcast_transaction(const signed_transaction& trx)
{
auto collector = _chain_db->get_account_record(_config.faucet_account_name);
auto accept_fee = [this](const asset& fee) -> bool {
auto feed_price = _chain_db->get_active_feed_price(fee.asset_id);
if( !feed_price ) return false;

//Forgive up to a 5% change in price from the last sync by the lightwallet
asset required = asset(_config.light_relay_fee * .95) * *feed_price;
return fee >= required;
};

if( collector && _config.light_relay_fee )
{
for( operation op : trx.operations )
Expand All @@ -764,8 +773,7 @@ void client_impl::blockchain_broadcast_transaction(const signed_transaction& trx
ilog("Checking if deposit ${d} is to ${c}", ("d", deposit)("c", collector->active_address()));
if( deposit.condition.owner() && *deposit.condition.owner() == collector->active_address() &&
( (deposit.condition.asset_id == 0 && deposit.amount >= _config.light_relay_fee) ||
// Sshhhhh, don't tell! TODO: figure out minimum MIA fee
deposit.amount > 0 ) )
accept_fee(asset(deposit.amount, deposit.condition.asset_id)) ) )
{
network_broadcast_transaction(trx);
return;
Expand Down
4 changes: 2 additions & 2 deletions libraries/light_wallet/light_wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ oprice light_wallet::get_median_feed_price( const string& symbol )
auto cached_price_itr = _data->price_cache.find(symbol);
if( cached_price_itr != _data->price_cache.end() )
{
if( cached_price_itr->second.second + fc::days(1) > fc::time_point::now() )
if( cached_price_itr->second.second + fc::hours(1) > fc::time_point::now() )
return cached_price_itr->second.first;
else
_data->price_cache.erase( cached_price_itr );
Expand Down Expand Up @@ -662,7 +662,7 @@ bts::wallet::transaction_ledger_entry light_wallet::summarize(const string& acco
{
auto one_time_key = create_one_time_key(account_name, fc::to_string(record.trx.expiration.sec_since_epoch()));
try {
memo_data data = condition.decrypt_memo_data(one_time_key.get_shared_secret(account->active_key()));
extended_memo_data data = condition.decrypt_memo_data(one_time_key.get_shared_secret(account->active_key()));
summary.operation_notes[i] = data.get_message();
} catch(...){}
}
Expand Down

0 comments on commit 4b68dbf

Please sign in to comment.