Skip to content

Instantly share code, notes, and snippets.

@Hribek25
Last active September 24, 2019 10:30
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 Hribek25/787ab8f331d2e0f1e808577981dceaac to your computer and use it in GitHub Desktop.
Save Hribek25/787ab8f331d2e0f1e808577981dceaac to your computer and use it in GitHub Desktop.
Validating IOTA address
# The snippet is a part of the IOTA Developer Essentials project. You can reach it at https://hribek25.github.io/IOTA101/
# Complete description and story behind the snippet is available at: https://hribek25.github.io/IOTA101/Allchapters_python.ipynb.html#C65223B0864A
# Requirement: PyOTA library (!pip install pyota)
import iota
import sys
from pprint import pprint
InputAddr = b"CYJV9DRIE9NCQJYLOYOJOGKQGOOELTWXVWUYGQSWCNODHJAHACADUAAHQ9ODUICCESOIVZABA9LTMM9RWTHBIRSXTA"
if len(InputAddr)!=90:
print("Incorrect lenght of the given address. Please, use an address including checksum.")
exit(2)
try:
# address including checksum
Adr2 = iota.Address(InputAddr)
except :
print("Not valid input address given")
sys.exit(1)
pprint("Input address incl checksum:")
pprint(Adr2)
print("Is it valid addr based on checksum? %s" % (Adr2.is_checksum_valid()))
print("\nInput address excl checksum:")
pprint(Adr2[:81]) # return only first 81 characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment