From b6385e21173f92434c963c5ec61a47e4c00c8f8d Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Thu, 6 Aug 2015 13:43:18 -0400 Subject: [PATCH] Adding API call: get_potential_signatures This call allows wallets to filter the set of keys that may potentially sign a transaction prior to calling get_required_signatures to get the minimum subset. --- libraries/app/api.cpp | 20 ++++++++++++++++++++ libraries/app/include/graphene/app/api.hpp | 8 ++++++++ libraries/fc | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index e92b602d..60a44af0 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -1129,6 +1129,26 @@ namespace graphene { namespace app { [&]( account_id_type id ){ return &id(_db).owner; }, _db.get_global_properties().parameters.max_authority_depth ); } + set database_api::get_potential_signatures( const signed_transaction& trx )const + { + set result; + trx.get_required_signatures( _db.get_chain_id(), + flat_set(), + [&]( account_id_type id ){ + const auto& auth = &id(_db).active + for( const auto& k : auth.get_keys() ) + result.insert(k) + return &auth; }, + [&]( account_id_type id ){ + const auto& auth = &id(_db).owner + for( const auto& k : auth.get_keys() ) + result.insert(k) + return &auth; }, + }, + _db.get_global_properties().parameters.max_authority_depth ); + + return result; + } bool database_api::verify_authority( const signed_transaction& trx )const { diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 8eb4359f..ce3aebf8 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -331,6 +331,13 @@ namespace graphene { namespace app { */ set get_required_signatures( const signed_transaction& trx, const flat_set& available_keys )const; + /** + * This method will return the set of all public keys that could possibly sign for a given transaction. This call can + * be used by wallets to filter their set of public keys to just the relevant subset prior to calling @ref get_required_signatures + * to get the minimum subset. + */ + set get_potential_signatures( const signed_transaction& trx )const; + /** * @return true of the @ref trx has all of the required signatures, otherwise throws an exception */ @@ -562,6 +569,7 @@ FC_API(graphene::app::database_api, (get_balance_objects) (get_vested_balances) (get_required_signatures) + (get_potential_signatures) (verify_authority) (get_blinded_balances) (get_required_fees) diff --git a/libraries/fc b/libraries/fc index 088dadd1..d11b48a0 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 088dadd12481e75829b83c098f3bc36b7e296ca0 +Subproject commit d11b48a015e0c339cc20f739ef1f8a5b3c57b913