adding verify_account_authority api
This commit is contained in:
parent
866c453f1a
commit
a32075897f
4 changed files with 34 additions and 2 deletions
|
|
@ -1223,6 +1223,32 @@ namespace graphene { namespace app {
|
|||
_db.get_global_properties().parameters.max_authority_depth );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool database_api::verify_account_authority( const string& name_or_id, const flat_set<public_key_type>& keys )const
|
||||
{
|
||||
FC_ASSERT( name_or_id.size() > 0);
|
||||
const account_object* account = nullptr;
|
||||
if (std::isdigit(name_or_id[0]))
|
||||
account = _db.find(fc::variant(name_or_id).as<account_id_type>());
|
||||
else
|
||||
{
|
||||
const auto& idx = _db.get_index_type<account_index>().indices().get<by_name>();
|
||||
auto itr = idx.find(name_or_id);
|
||||
if (itr != idx.end())
|
||||
account = &*itr;
|
||||
}
|
||||
FC_ASSERT( account, "no such account" );
|
||||
|
||||
|
||||
/// reuse trx.verify_authority by creating a dummy transfer
|
||||
signed_transaction trx;
|
||||
transfer_operation op;
|
||||
op.from = account->id;
|
||||
trx.operations.emplace_back(op);
|
||||
|
||||
return verify_authority( trx );
|
||||
}
|
||||
|
||||
vector<blinded_balance_object> database_api::get_blinded_balances( const flat_set<commitment_type>& commitments )const
|
||||
{
|
||||
vector<blinded_balance_object> result; result.reserve(commitments.size());
|
||||
|
|
|
|||
|
|
@ -342,6 +342,11 @@ namespace graphene { namespace app {
|
|||
*/
|
||||
bool verify_authority( const signed_transaction& trx )const;
|
||||
|
||||
/**
|
||||
* @return true if the signers have enough authority to authorize an account
|
||||
*/
|
||||
bool verify_account_authority( const string& name_or_id, const flat_set<public_key_type>& signers )const;
|
||||
|
||||
|
||||
/**
|
||||
* @return the set of blinded balance objects by commitment ID
|
||||
|
|
@ -586,6 +591,7 @@ FC_API(graphene::app::database_api,
|
|||
(get_required_signatures)
|
||||
(get_potential_signatures)
|
||||
(verify_authority)
|
||||
(verify_account_authority)
|
||||
(get_blinded_balances)
|
||||
(get_required_fees)
|
||||
(set_subscribe_callback)
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ const signed_transaction& database::get_recent_transaction(const transaction_id_
|
|||
*/
|
||||
bool database::push_block(const signed_block& new_block, uint32_t skip)
|
||||
{
|
||||
|
||||
idump((new_block.block_num())(new_block.id()));
|
||||
bool result;
|
||||
with_skip_flags(skip, [&]()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ void database::wipe(const fc::path& data_dir, bool include_blocks)
|
|||
void database::open(
|
||||
const fc::path& data_dir,
|
||||
std::function<genesis_state_type()> genesis_loader )
|
||||
elog( "Open Database" );
|
||||
{
|
||||
elog( "Open Database" );
|
||||
try
|
||||
{
|
||||
object_database::open(data_dir);
|
||||
|
|
|
|||
Loading…
Reference in a new issue