From 4b68dbf1aa0f3a0a003ea2a9cc9b5ac4c11d8d74 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Mon, 2 Feb 2015 15:32:32 -0500 Subject: [PATCH] LW: fix BitAsset fees serverside (needs testing) --- libraries/client/blockchain_api.cpp | 12 ++++++++++-- libraries/light_wallet/light_wallet.cpp | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libraries/client/blockchain_api.cpp b/libraries/client/blockchain_api.cpp index 4d4635a03..2211bdefd 100644 --- a/libraries/client/blockchain_api.cpp +++ b/libraries/client/blockchain_api.cpp @@ -755,6 +755,15 @@ vector 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 ) @@ -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; diff --git a/libraries/light_wallet/light_wallet.cpp b/libraries/light_wallet/light_wallet.cpp index a3d263267..eb5ece6b0 100644 --- a/libraries/light_wallet/light_wallet.cpp +++ b/libraries/light_wallet/light_wallet.cpp @@ -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 ); @@ -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(...){} }