1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-16 03:18:09 +00:00

src/apps/wallet/sign_tx: handle timestamp field

This commit is contained in:
Tibor Arpas 2018-10-19 17:59:33 +02:00 committed by Pavol Rusnak
parent 1d43322d21
commit be58549fd9
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 8 additions and 0 deletions

View File

@ -122,6 +122,7 @@ def sanitize_sign_tx(tx: SignTx) -> SignTx:
tx.coin_name = tx.coin_name if tx.coin_name is not None else "Bitcoin"
tx.expiry = tx.expiry if tx.expiry is not None else 0
tx.overwintered = tx.overwintered if tx.overwintered is not None else False
tx.timestamp = tx.timestamp if tx.timestamp is not None else 0
return tx
@ -133,6 +134,7 @@ def sanitize_tx_meta(tx: TransactionType) -> TransactionType:
tx.extra_data_len = tx.extra_data_len if tx.extra_data_len is not None else 0
tx.expiry = tx.expiry if tx.expiry is not None else 0
tx.overwintered = tx.overwintered if tx.overwintered is not None else False
tx.timestamp = tx.timestamp if tx.timestamp is not None else 0
return tx

View File

@ -391,6 +391,8 @@ async def sign_tx(tx: SignTx, root: bip32.HDNode):
write_uint32(h_sign, tx.version_group_id) # nVersionGroupId
else:
write_uint32(h_sign, tx.version) # nVersion
if tx.timestamp:
write_uint32(h_sign, tx.timestamp)
write_varint(h_sign, tx.inputs_count)
@ -586,6 +588,8 @@ async def get_prevtx_output_value(
write_uint32(txh, tx.version | DECRED_SERIALIZE_NO_WITNESS)
else:
write_uint32(txh, tx.version) # nVersion
if tx.timestamp:
write_uint32(txh, tx.timestamp)
write_varint(txh, tx.inputs_cnt)
@ -653,6 +657,8 @@ def get_tx_header(coin: CoinInfo, tx: SignTx, segwit: bool = False):
write_uint32(w_txi, tx.version_group_id) # nVersionGroupId
else:
write_uint32(w_txi, tx.version) # nVersion
if tx.timestamp:
write_uint32(w_txi, tx.timestamp)
if segwit:
write_varint(w_txi, 0x00) # segwit witness marker
write_varint(w_txi, 0x01) # segwit witness flag