chore: code format

This commit is contained in:
Vlad Stan 2023-02-10 17:25:02 +02:00
parent 8678090e7b
commit ebada934b0
6 changed files with 32 additions and 29 deletions

View file

@ -2,18 +2,18 @@ from bech32 import bech32_decode, convertbits
def normalize_public_key(pubkey: str) -> str:
if pubkey.startswith('npub1'):
if pubkey.startswith("npub1"):
_, decoded_data = bech32_decode(pubkey)
if not decoded_data:
raise ValueError("Public Key is not valid npub")
decoded_data_bits = convertbits(decoded_data, 5, 8, False)
if not decoded_data_bits:
if not decoded_data_bits:
raise ValueError("Public Key is not valid npub")
return bytes(decoded_data_bits).hex()
#check if valid hex
# check if valid hex
if len(pubkey) != 64:
raise ValueError("Public Key is not valid hex")
int(pubkey, 16)
return pubkey
return pubkey