fix recursion
This commit is contained in:
parent
283de52f38
commit
b325805878
1 changed files with 9 additions and 13 deletions
|
|
@ -24,19 +24,12 @@ namespace graphene {
|
|||
FC_ASSERT( is_valid( base58str ) );
|
||||
std::string prefix( GRAPHENE_ADDRESS_PREFIX );
|
||||
|
||||
// TODO: This is temporary for testing
|
||||
if( is_valid( base58str, "BTS" ) ) prefix = std::string( "BTS" );
|
||||
|
||||
std::vector<char> v = fc::from_base58( base58str.substr( prefix.size() ) );
|
||||
memcpy( (char*)addr._hash, v.data(), std::min<size_t>( v.size()-4, sizeof( addr ) ) );
|
||||
}
|
||||
|
||||
bool address::is_valid( const std::string& base58str, const std::string& prefix )
|
||||
{
|
||||
// TODO: This is temporary for testing
|
||||
if( prefix == GRAPHENE_ADDRESS_PREFIX && is_valid( base58str, "BTS" ) )
|
||||
return true;
|
||||
|
||||
const size_t prefix_len = prefix.size();
|
||||
if( base58str.size() <= prefix_len )
|
||||
return false;
|
||||
|
|
@ -45,17 +38,20 @@ namespace graphene {
|
|||
std::vector<char> v;
|
||||
try
|
||||
{
|
||||
v = fc::from_base58( base58str.substr( prefix_len ) );
|
||||
}
|
||||
catch( const fc::parse_error_exception& e )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
v = fc::from_base58( base58str.substr( prefix_len ) );
|
||||
}
|
||||
catch( const fc::parse_error_exception& e )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( v.size() != sizeof( fc::ripemd160 ) + 4 )
|
||||
return false;
|
||||
|
||||
const fc::ripemd160 checksum = fc::ripemd160::hash( v.data(), v.size() - 4 );
|
||||
if( memcmp( v.data() + 20, (char*)checksum._hash, 4 ) != 0 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue