def write_header(hasher: Writer, header: EosTxHeader) -> None: write_uint32_le(hasher, header.expiration) write_uint16_le(hasher, header.ref_block_num) write_uint32_le(hasher, header.ref_block_prefix) write_variant32(hasher, header.max_net_usage_words) write_uint8(hasher, header.max_cpu_usage_ms) write_variant32(hasher, header.delay_sec)
def write_tx_header(self, w: Writer, tx: SignTx | PrevTx, witness_marker: bool) -> None: # defined in ZIP-225 (see https://zips.z.cash/zip-0225) assert tx.version_group_id is not None assert tx.branch_id is not None # checked in sanitize_* assert tx.expiry is not None write_uint32_le(w, tx.version | OVERWINTERED) # nVersion | fOverwintered write_uint32_le(w, tx.version_group_id) # nVersionGroupId write_uint32_le(w, tx.branch_id) # nConsensusBranchId write_uint32_le(w, tx.lock_time) # lock_time write_uint32_le(w, tx.expiry) # expiryHeight
def write_auth(w: Writer, auth: EosAuthorization) -> None: write_uint32_le(w, auth.threshold) write_variant32(w, len(auth.keys)) for key in auth.keys: write_variant32(w, key.type) write_bytes_unchecked(w, key.key) write_uint16_le(w, key.weight) write_variant32(w, len(auth.accounts)) for account in auth.accounts: write_uint64_le(w, account.account.actor) write_uint64_le(w, account.account.permission) write_uint16_le(w, account.weight) write_variant32(w, len(auth.waits)) for wait in auth.waits: write_uint32_le(w, wait.wait_sec) write_uint16_le(w, wait.weight)
def write_auth(w: Writer, auth: EosAuthorization) -> None: write_uint32_le(w, auth.threshold) write_uvarint(w, len(auth.keys)) for key in auth.keys: if key.key is None: raise wire.DataError("Key must be provided explicitly.") write_uvarint(w, key.type) write_bytes_fixed(w, key.key, 33) write_uint16_le(w, key.weight) write_uvarint(w, len(auth.accounts)) for account in auth.accounts: write_uint64_le(w, account.account.actor) write_uint64_le(w, account.account.permission) write_uint16_le(w, account.weight) write_uvarint(w, len(auth.waits)) for wait in auth.waits: write_uint32_le(w, wait.wait_sec) write_uint16_le(w, wait.weight)
def serialize_tx_common( common: NEMTransactionCommon, public_key: bytes, transaction_type: int, version: int | None = None, ) -> bytearray: w = bytearray() write_uint32_le(w, transaction_type) if version is None: version = common.network << 24 | 1 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) return w
def write_action_buyrambytes(w: Writer, msg: EosActionBuyRamBytes) -> None: write_uint64_le(w, msg.payer) write_uint64_le(w, msg.receiver) write_uint32_le(w, msg.bytes)
def write_bytes_with_len(w: Writer, buf: bytes) -> None: write_uint32_le(w, len(buf)) write_bytes_unchecked(w, buf)
def write_bytes_with_len(w, buf: bytes): write_uint32_le(w, len(buf)) write_bytes(w, buf)
def write_action_buyrambytes(w: bytearray, msg: EosActionBuyRamBytes): write_uint64_le(w, msg.payer) write_uint64_le(w, msg.receiver) write_uint32_le(w, msg.bytes)