Skip to content

Instantly share code, notes, and snippets.

@angeloped
Created January 3, 2021 08:15
Show Gist options
  • Save angeloped/986f602d631daf3ad3c7a8c4ab35dd44 to your computer and use it in GitHub Desktop.
Save angeloped/986f602d631daf3ad3c7a8c4ab35dd44 to your computer and use it in GitHub Desktop.
Bitcoin address validator. 1000% realshit
import base58
import binascii
from hashlib import sha256
# base58 src: https://github.com/keis/base58
def verifyBTCaddr(addr):
try:
base58Decoder = base58.b58decode(addr).hex()
prefixAndHash = base58Decoder[:len(base58Decoder)-8]
checksum = base58Decoder[len(base58Decoder)-8:]
hash_ = prefixAndHash
for x in range(1,3):
hash_ = sha256(binascii.unhexlify(hash_)).hexdigest()
if(checksum == hash_[:8]):
return True
else:
return False
except:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment