From 86564e2a1b6e8641d85746f0d3ab3ee68a83f5ce Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Mon, 27 Jul 2015 17:50:02 -0400 Subject: [PATCH] Resolve #207 Add API to get required fees. --- libraries/app/api.cpp | 10 ++++++++++ libraries/app/include/graphene/app/api.hpp | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index cbcb9295..a92b9ee7 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -1120,4 +1120,14 @@ namespace graphene { namespace app { return result; } + vector database_api::get_required_fees( const vector& ops, asset_id_type id )const + { + vector result; + result.reserve(ops.size()); + const asset_object& a = id(_db); + for( const auto& op : ops ) + result.push_back( _db.current_fee_schedule().calculate_fee( op, a.options.core_exchange_rate ) ); + return result; + } + } } // graphene::app diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 48de0024..50b46278 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -328,6 +328,12 @@ namespace graphene { namespace app { vector get_blinded_balances( const flat_set& commitments )const; + /** + * For each operation calculate the required fee in the specified asset type. If the asset type does + * not have a valid core_exchange_rate + */ + vector get_required_fees( const vector& ops, asset_id_type id = asset_id_type() )const; + private: /** called every time a block is applied to report the objects that were changed */ void on_objects_changed(const vector& ids); @@ -541,6 +547,7 @@ FC_API(graphene::app::database_api, (get_required_signatures) (verify_authority) (get_blinded_balances) + (get_required_fees) ) FC_API(graphene::app::history_api, (get_account_history)