sutterseba

Calculate checksum for mnemonic phrase

Mar 7th, 2022 (edited)
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. from mnemonic import Mnemonic
  2.  
  3. def main():
  4.  
  5.     m = Mnemonic('english')
  6.  
  7.     print("\033[93mThis script should only be used for testing or learning purposes. Use a hardware wallet for your personal keys.\033[0m\n")
  8.     incomplete = input("Enter your incomplete mnemonic phrase: \n\n").lower().strip()
  9.  
  10.     if (m.check(incomplete)):
  11.         print("\n\033[92m\033[1mALREADY VALID MNEMONIC\033[0m")
  12.         return
  13.  
  14.     valid = [word for word in m.wordlist if m.check(f"{incomplete} {word}")]
  15.  
  16.     if len(valid) == 0:
  17.         print("\n\033[91m\033[1mINVALID INPUT\n\033[0mCheck for spelling mistakes or incorrect amount of words")
  18.  
  19.     else:
  20.         print("\n\033[92m\033[1mCHOOSE ANY OF THESE WORDS:\033[0m\n")
  21.         print("\n".join(valid))
  22.    
  23. if __name__ == "__main__":
  24.     main()
Add Comment
Please, Sign In to add comment