1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

wallet/signing: move default input sequence to sanitizer

This commit is contained in:
Jan Pochyla 2017-11-15 14:03:24 +01:00 committed by Tomas Susanka
parent aa29667059
commit 5a6b2a5a97
2 changed files with 8 additions and 8 deletions

View File

@ -107,8 +107,10 @@ def sanitize_tx_meta(tx: TransactionType) -> TransactionType:
def sanitize_tx_input(tx: TransactionType) -> TxInputType:
txi = tx.inputs[0]
txi.script_type = (
txi.script_type if txi.script_type is not None else InputScriptType.SPENDADDRESS)
if txi.script_type is None:
txi.script_type = InputScriptType.SPENDADDRESS
if txi.sequence is None:
txi.sequence = 4294967295
return txi

View File

@ -1,3 +1,5 @@
from micropython import const
from trezor.messages.TxOutputBinType import TxOutputBinType
from trezor.messages.TxInputType import TxInputType
from trezor.crypto.hashlib import sha256
@ -5,26 +7,22 @@ from trezor.crypto.hashlib import sha256
# TX Serialization
# ===
_DEFAULT_SEQUENCE = 4294967295
def write_tx_input(w, i: TxInputType):
i_sequence = i.sequence if i.sequence is not None else _DEFAULT_SEQUENCE
write_bytes_rev(w, i.prev_hash)
write_uint32(w, i.prev_index)
write_varint(w, len(i.script_sig))
write_bytes(w, i.script_sig)
write_uint32(w, i_sequence)
write_uint32(w, i.sequence)
def write_tx_input_check(w, i: TxInputType):
i_sequence = i.sequence if i.sequence is not None else _DEFAULT_SEQUENCE
write_bytes(w, i.prev_hash)
write_uint32(w, i.prev_index)
write_uint32(w, len(i.address_n))
for n in i.address_n:
write_uint32(w, n)
write_uint32(w, i_sequence)
write_uint32(w, i.sequence)
i_amount = i.amount if i.amount is not None else 0
write_uint32(w, i_amount) # this is probably redundant, but better safe than sorry