Skip to content

Commit

Permalink
HARDFORK: fix address authority
Browse files Browse the repository at this point in the history
Accounts that use address_auths rather than key_auths would fail to
recognize a properly signed transaction.  This is only relevant to
genesis accounts for imported collateral positions.
  • Loading branch information
bytemaster committed Sep 24, 2015
1 parent 738abf0 commit a308289
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions libraries/chain/protocol/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,42 @@ struct sign_state
return itr->second = true;
}

optional<map<address,public_key_type>> available_address_sigs;
optional<map<address,public_key_type>> provided_address_sigs;

bool signed_by( const address& a ) {
if( !available_address_sigs ) {
available_address_sigs = std::map<address,public_key_type>();
provided_address_sigs = std::map<address,public_key_type>();
for( auto& item : available_keys ) {
(*available_address_sigs)[ address(pts_address(item, false, 56) ) ] = item;
(*available_address_sigs)[ address(pts_address(item, true, 56) ) ] = item;
(*available_address_sigs)[ address(pts_address(item, false, 0) ) ] = item;
(*available_address_sigs)[ address(pts_address(item, true, 0) ) ] = item;
(*available_address_sigs)[ address(item) ] = item;
}
for( auto& item : provided_signatures ) {
(*provided_address_sigs)[ address(pts_address(item.first, false, 56) ) ] = item.first;
(*provided_address_sigs)[ address(pts_address(item.first, true, 56) ) ] = item.first;
(*provided_address_sigs)[ address(pts_address(item.first, false, 0) ) ] = item.first;
(*provided_address_sigs)[ address(pts_address(item.first, true, 0) ) ] = item.first;
(*provided_address_sigs)[ address(item.first) ] = item.first;
}
}
auto itr = provided_address_sigs->find(a);
if( itr == provided_address_sigs->end() )
{
auto aitr = available_address_sigs->find(a);
if( aitr != available_address_sigs->end() ) {
auto pk = available_keys.find(aitr->second);
if( pk != available_keys.end() )
return provided_signatures[aitr->second] = true;
return false;
}
}
return provided_signatures[itr->second] = true;
}

bool check_authority( account_id_type id )
{
if( approved_by.find(id) != approved_by.end() ) return true;
Expand All @@ -138,6 +174,14 @@ struct sign_state
return true;
}

for( const auto& k : auth.address_auths )
if( signed_by( k.first ) )
{
total_weight += k.second;
if( total_weight >= auth.weight_threshold )
return true;
}

for( const auto& a : auth.account_auths )
{
if( approved_by.find(a.first) == approved_by.end() )
Expand Down

0 comments on commit a308289

Please sign in to comment.