From 9d523c89425e51885e390deaa1ac142975ef7359 Mon Sep 17 00:00:00 2001 From: jeffthibault Date: Sat, 21 Jan 2023 14:20:08 -0500 Subject: [PATCH] add error handling to mine_vanity_key function --- nostr/key.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nostr/key.py b/nostr/key.py index 1e6fb3f..19eadd8 100644 --- a/nostr/key.py +++ b/nostr/key.py @@ -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