mirror of
https://github.com/aljazceru/python-nostr.git
synced 2025-12-19 15:24:19 +01:00
add error handling to mine_vanity_key function
This commit is contained in:
@@ -109,8 +109,10 @@ class PrivateKey:
|
|||||||
return self.raw_secret == other.raw_secret
|
return self.raw_secret == other.raw_secret
|
||||||
|
|
||||||
def mine_vanity_key(prefix: str = None, suffix: str = None) -> PrivateKey:
|
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:
|
while True:
|
||||||
attempts += 1
|
|
||||||
sk = PrivateKey()
|
sk = PrivateKey()
|
||||||
if prefix is not None and not sk.public_key.bech32()[5:5+len(prefix)] == prefix:
|
if prefix is not None and not sk.public_key.bech32()[5:5+len(prefix)] == prefix:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user