1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-20 05:18:08 +00:00

src/apps/wallet: add asserts to sign_tx.writers

This commit is contained in:
Pavol Rusnak 2018-06-02 15:49:55 +02:00
parent f6be3899eb
commit 6d21723330
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -33,6 +33,7 @@ def write_tx_output(w, o: TxOutputBinType):
def write_op_push(w, n: int): def write_op_push(w, n: int):
assert n >= 0 and n <= 4294967295
if n < 0x4C: if n < 0x4C:
w.append(n & 0xFF) w.append(n & 0xFF)
elif n < 0xFF: elif n < 0xFF:
@ -55,6 +56,7 @@ def write_op_push(w, n: int):
def write_varint(w, n: int): def write_varint(w, n: int):
assert n >= 0 and n <= 4294967295
if n < 253: if n < 253:
w.append(n & 0xFF) w.append(n & 0xFF)
elif n < 65536: elif n < 65536:
@ -70,6 +72,7 @@ def write_varint(w, n: int):
def write_uint32(w, n: int): def write_uint32(w, n: int):
assert n >= 0 and n <= 4294967295
w.append(n & 0xFF) w.append(n & 0xFF)
w.append((n >> 8) & 0xFF) w.append((n >> 8) & 0xFF)
w.append((n >> 16) & 0xFF) w.append((n >> 16) & 0xFF)
@ -77,6 +80,7 @@ def write_uint32(w, n: int):
def write_uint64(w, n: int): def write_uint64(w, n: int):
assert n >= 0 and n <= 18446744073709551615
w.append(n & 0xFF) w.append(n & 0xFF)
w.append((n >> 8) & 0xFF) w.append((n >> 8) & 0xFF)
w.append((n >> 16) & 0xFF) w.append((n >> 16) & 0xFF)