Enable padding in hex_to_bech32

This commit is contained in:
thePR0M3TH3AN
2025-08-08 12:53:24 -04:00
parent fd9d3fa51b
commit fdd2530635

View File

@@ -27,7 +27,8 @@ class Keys:
@staticmethod
def hex_to_bech32(key_str: str, prefix: str = "npub") -> str:
data = convertbits(bytes.fromhex(key_str), 8, 5)
# Pad to align with 5-bit groups as expected for Bech32 encoding
data = convertbits(bytes.fromhex(key_str), 8, 5, True)
return bech32_encode(prefix, data)
@staticmethod