Skip to content

Instantly share code, notes, and snippets.

@simform-solutions
Last active September 19, 2017 12:09
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 simform-solutions/ef2c9ed7c053bd2d4966a78c564e3404 to your computer and use it in GitHub Desktop.
Save simform-solutions/ef2c9ed7c053bd2d4966a78c564e3404 to your computer and use it in GitHub Desktop.
# Takes a address (81 Characters) and converts it to an address with checksum (90 Characters)
def address_checksum(address):
bytes_address = bytes(address)
addy = Address(bytes_address)
address = str(addy.with_valid_checksum())
return address
# Takes an address with checksum and verifies if the address matches with the checksum
def is_valid_address(address_with_checksum):
address = address_with_checksum[:81]
new_address_with_checksum = address_checksum(address)
if new_address_with_checksum == address_with_checksum:
return True
else:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment