Merge pull request #804 from PR0M3TH3AN/codex/modify-hex_to_bech32-for-padding

Enable padding for hex_to_bech32 conversion
This commit is contained in:
thePR0M3TH3AN
2025-08-08 13:00:20 -04:00
committed by GitHub

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