chainsyncer/chainsyncer/client/translate.py

11 lines
228 B
Python
Raw Normal View History

# third-party imports
from hexathon import strip_0x
2021-02-03 23:03:39 +01:00
2021-02-03 20:55:39 +01:00
def hex_to_int(hx, endianness='big'):
hx = strip_0x(hx)
if len(hx) % 2 == 1:
hx = '0' + hx
2021-02-03 20:55:39 +01:00
b = bytes.fromhex(hx)
return int.from_bytes(b, endianness)