add error handling to mine_vanity_key function

This commit is contained in:
jeffthibault
2023-01-21 14:20:08 -05:00
parent 35c500cf14
commit 9d523c8942

View File

@@ -109,8 +109,10 @@ class PrivateKey:
return self.raw_secret == other.raw_secret
def mine_vanity_key(prefix: str = None, suffix: str = None) -> PrivateKey:
if prefix is None and suffix is None:
raise ValueError("Expected at least one of 'prefix' or 'suffix' arguments")
while True:
attempts += 1
sk = PrivateKey()
if prefix is not None and not sk.public_key.bech32()[5:5+len(prefix)] == prefix:
continue