@@ -267,6 +267,7 @@ struct sign_state
267
267
void verify_authority ( const vector<operation>& ops, const flat_set<public_key_type>& sigs,
268
268
const std::function<const authority*(account_id_type)>& get_active,
269
269
const std::function<const authority*(account_id_type)>& get_owner,
270
+ custom_authority_lookup get_custom,
270
271
bool allow_non_immediate_owner,
271
272
uint32_t max_recursion_depth,
272
273
bool allow_committe,
@@ -277,19 +278,39 @@ void verify_authority( const vector<operation>& ops, const flat_set<public_key_t
277
278
flat_set<account_id_type> required_owner;
278
279
vector<authority> other;
279
280
280
- for ( const auto & op : ops )
281
- operation_get_required_authorities ( op, required_active, required_owner, other );
282
-
283
- if ( !allow_committe )
284
- GRAPHENE_ASSERT ( required_active.find (GRAPHENE_COMMITTEE_ACCOUNT) == required_active.end (),
285
- invalid_committee_approval, " Committee account may only propose transactions" );
286
-
287
281
sign_state s ( sigs, get_active, get_owner, allow_non_immediate_owner, max_recursion_depth );
288
282
for ( auto & id : active_aprovals )
289
283
s.approved_by .insert ( id );
290
284
for ( auto & id : owner_approvals )
291
285
s.approved_by .insert ( id );
292
286
287
+ auto approved_by_custom_authority = [&s, get_custom = std::move (get_custom)]( account_id_type account,
288
+ operation op ) mutable {
289
+ auto viable_custom_auths = get_custom (account, op);
290
+ for (const auto & auth : viable_custom_auths)
291
+ if (s.check_authority (&auth)) return true ;
292
+ return false ;
293
+ };
294
+
295
+ for ( const auto & op : ops ) {
296
+ flat_set<account_id_type> operation_required_active;
297
+ operation_get_required_authorities ( op, operation_required_active, required_owner, other );
298
+
299
+ auto itr = operation_required_active.begin ();
300
+ while ( itr != operation_required_active.end () ) {
301
+ if ( approved_by_custom_authority ( *itr, op ) )
302
+ itr = operation_required_active.erase ( itr );
303
+ else
304
+ ++itr;
305
+ }
306
+
307
+ required_active.insert ( operation_required_active.begin (), operation_required_active.end () );
308
+ }
309
+
310
+ if ( !allow_committe )
311
+ GRAPHENE_ASSERT ( required_active.find (GRAPHENE_COMMITTEE_ACCOUNT) == required_active.end (),
312
+ invalid_committee_approval, " Committee account may only propose transactions" );
313
+
293
314
for ( const auto & auth : other )
294
315
{
295
316
GRAPHENE_ASSERT ( s.check_authority (&auth), tx_missing_other_auth, " Missing Authority" , (" auth" ,auth)(" sigs" ,sigs) );
@@ -375,6 +396,7 @@ set<public_key_type> signed_transaction::minimize_required_signatures(
375
396
const flat_set<public_key_type>& available_keys,
376
397
const std::function<const authority*(account_id_type)>& get_active,
377
398
const std::function<const authority*(account_id_type)>& get_owner,
399
+ custom_authority_lookup get_custom,
378
400
bool allow_non_immediate_owner,
379
401
uint32_t max_recursion
380
402
) const
@@ -387,7 +409,7 @@ set<public_key_type> signed_transaction::minimize_required_signatures(
387
409
result.erase ( k );
388
410
try
389
411
{
390
- graphene::protocol::verify_authority ( operations, result, get_active, get_owner,
412
+ graphene::protocol::verify_authority ( operations, result, get_active, get_owner, get_custom,
391
413
allow_non_immediate_owner, max_recursion );
392
414
continue ; // element stays erased if verify_authority is ok
393
415
}
@@ -433,11 +455,12 @@ void signed_transaction::verify_authority(
433
455
const chain_id_type& chain_id,
434
456
const std::function<const authority*(account_id_type)>& get_active,
435
457
const std::function<const authority*(account_id_type)>& get_owner,
458
+ custom_authority_lookup get_custom,
436
459
bool allow_non_immediate_owner,
437
460
uint32_t max_recursion )const
438
461
{ try {
439
462
graphene::protocol::verify_authority ( operations, get_signature_keys ( chain_id ), get_active, get_owner,
440
- allow_non_immediate_owner, max_recursion );
463
+ get_custom, allow_non_immediate_owner, max_recursion );
441
464
} FC_CAPTURE_AND_RETHROW ( (*this ) ) }
442
465
443
466
} } // graphene::protocol
0 commit comments