mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-12 10:39:00 +00:00
19 lines
392 B
Python
19 lines
392 B
Python
from trezor.utils import BufferReader
|
|
|
|
|
|
def read_bitcoin_varint(r: BufferReader) -> int:
|
|
prefix = r.get()
|
|
if prefix < 253:
|
|
n = prefix
|
|
elif prefix == 253:
|
|
n = r.get()
|
|
n += r.get() << 8
|
|
elif prefix == 254:
|
|
n = r.get()
|
|
n += r.get() << 8
|
|
n += r.get() << 16
|
|
n += r.get() << 24
|
|
else:
|
|
raise ValueError
|
|
return n
|