2021-03-23 12:35:27 +00:00
|
|
|
from trezor.messages import NEMTransactionCommon
|
2018-04-06 08:40:46 +00:00
|
|
|
|
2020-03-16 10:31:11 +00:00
|
|
|
from apps.common.writers import write_bytes_unchecked, write_uint32_le, write_uint64_le
|
2018-04-06 08:40:46 +00:00
|
|
|
|
2018-03-16 12:55:37 +00:00
|
|
|
|
2018-08-23 12:39:30 +00:00
|
|
|
def serialize_tx_common(
|
2018-07-03 14:20:58 +00:00
|
|
|
common: NEMTransactionCommon,
|
|
|
|
public_key: bytearray,
|
|
|
|
transaction_type: int,
|
|
|
|
version: int = None,
|
|
|
|
) -> bytearray:
|
2018-08-23 12:39:30 +00:00
|
|
|
w = bytearray()
|
2018-06-06 12:04:56 +00:00
|
|
|
|
2018-08-23 12:39:30 +00:00
|
|
|
write_uint32_le(w, transaction_type)
|
2018-04-06 08:40:46 +00:00
|
|
|
if version is None:
|
|
|
|
version = common.network << 24 | 1
|
2018-08-23 12:39:30 +00:00
|
|
|
write_uint32_le(w, version)
|
|
|
|
write_uint32_le(w, common.timestamp)
|
|
|
|
|
|
|
|
write_bytes_with_len(w, public_key)
|
|
|
|
write_uint64_le(w, common.fee)
|
|
|
|
write_uint32_le(w, common.deadline)
|
2018-03-26 10:05:47 +00:00
|
|
|
|
2018-08-23 12:39:30 +00:00
|
|
|
return w
|
2018-03-26 10:05:47 +00:00
|
|
|
|
2018-08-23 12:39:30 +00:00
|
|
|
|
|
|
|
def write_bytes_with_len(w, buf: bytes):
|
|
|
|
write_uint32_le(w, len(buf))
|
2020-03-16 10:31:11 +00:00
|
|
|
write_bytes_unchecked(w, buf)
|