Skip to content

Instantly share code, notes, and snippets.

@ladaposamuel
Last active October 26, 2017 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ladaposamuel/717dd74326865e98efe3c8378ff49363 to your computer and use it in GitHub Desktop.
Save ladaposamuel/717dd74326865e98efe3c8378ff49363 to your computer and use it in GitHub Desktop.
Laravel Validation rule for bitcoin adress
public function passes($attribute, $address)
{
$decoded = decodeBase58($address);
$d1 = hash("sha256", substr($decoded,0,21), true);
$d2 = hash("sha256", $d1, true);
if(substr_compare($decoded, $d2, 21, 4)){
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment