def deserialize_unsigned(self, reader: serialization.BinaryReader) -> None: self.version = reader.read_uint32() self.prev_hash = reader.read_serializable(types.UInt256) self.merkle_root = reader.read_serializable(types.UInt256) self.timestamp = reader.read_uint64() self.index = reader.read_uint32() self.next_consensus = reader.read_serializable(types.UInt160)
def deserialize(self, reader: serialization.BinaryReader) -> None: """ Deserialize the object from a binary stream. Args: reader: instance. """ self.current_height = reader.read_uint32() self.timestamp = reader.read_uint32() self.nonce = reader.read_uint32()
def deserialize_unsigned(self, reader: serialization.BinaryReader) -> None: """ Deserialize the object from a binary stream excluding the validation byte + witness. Args: reader: instance. """ self.version = reader.read_uint32() self.prev_hash = reader.read_serializable(types.UInt256) self.block_index = reader.read_uint32() self.validator_index = reader.read_uint16() self.data = reader.read_var_bytes()
def deserialize(self, reader: serialization.BinaryReader) -> None: """ Deserialize the object from a binary stream. Args: reader: instance. """ self.magic = reader.read_uint32() self.version = reader.read_uint32() self.timestamp = reader.read_uint32() self.nonce = reader.read_uint32() self.user_agent = reader.read_var_string(max=1024) capabilities_cnt = reader.read_var_int(self.MAX_CAPABILITIES) capabilities_list = [] for _ in range(capabilities_cnt): capabilities_list.append(capabilities.NodeCapability.deserialize_from(reader)) self.capabilities = capabilities_list
def deserialize_without_type(self, reader: serialization.BinaryReader) -> None: """ Deserialize the object from a binary stream without deserializing the base class `type` property. Args: reader: instance. """ self.start_height = reader.read_uint32()
def deserialize_unsigned(self, reader: serialization.BinaryReader) -> None: self.version = reader.read_uint8() if self.version > 0: raise ValueError("Deserialization error - invalid version") self.nonce = reader.read_uint32() self.sender = reader.read_serializable(types.UInt160) self.system_fee = reader.read_int64() if self.system_fee < 0: raise ValueError("Deserialization error - negative system fee") self.network_fee = reader.read_int64() if self.network_fee < 0: raise ValueError("Deserialization error - negative network fee") # Impossible overflow, only applicable to the C# implementation where they use longs # if (self.system_fee + self.network_fee < self.system_fee): # raise ValueError("Deserialization error - overflow") self.valid_until_block = reader.read_uint32() self.attributes = reader.read_serializable_list(TransactionAttribute) self.cosigners = reader.read_serializable_list(payloads.Cosigner) self.script = reader.read_var_bytes(max=65535) if len(self.script) == 0: raise ValueError("Deserialization error - invalid script length 0")
def deserialize(self, reader: serialization.BinaryReader) -> None: """ Deserialize the object from a binary stream. Args: reader: instance. """ self.filter = reader.read_var_bytes(max=36000) self.K = reader.read_uint8() if self.K > 50: raise ValueError("Deserialization error - K exceeds limit of 50") self.tweak = reader.read_uint32()
def deserialize(self, reader: serialization.BinaryReader) -> None: self.magic = reader.read_uint32() self.compiler = reader.read_bytes(32).decode('utf-8') self.version = Version.deserialize_from_bytes(reader.read_bytes(16)) self.script_hash = reader.read_serializable(types.UInt160) self.checksum = reader.read_bytes(4) if self.checksum != self.compute_checksum(): raise ValueError("Deserialization error - invalid checksum") self.script = reader.read_var_bytes() if self.script_hash != self.compute_script_hash(): raise ValueError("Deserialization error - invalid script_hash")
def deserialize(self, reader: serialization.BinaryReader) -> None: self.magic = reader.read_uint32() compiler_with_version = reader.read_bytes(64).decode('utf-8') self.compiler, version = compiler_with_version.rsplit('-', maxsplit=1) self.version = Version.deserialize_from_bytes( version[:32].encode('utf-8')) assert reader.read_uint16() == 0 # 2 reserved bytes reader.read_var_int(128) # TODO: method tokens assert reader.read_uint16() == 0 # 2 reserved bytes self.script = reader.read_var_bytes() self.checksum = reader.read_bytes(4) if self.checksum != self.compute_checksum(): raise ValueError("Deserialization error - invalid checksum")
def deserialize(self, reader: serialization.BinaryReader) -> None: """ Deserialize the object from a binary stream. Args: reader: instance. Raises: ValueError: if `count` is zero or exceeds :const:`~neo3.network.payloads.getblocks.GetBlockDataPayload.MAX_BLOCKS_COUNT`. """ self.index_start = reader.read_uint32() self.count = reader.read_uint16() if self.count == 0 or self.count > self.MAX_BLOCKS_COUNT: raise ValueError("Deserialization error - invalid count")
def deserialize(self, reader: serialization.BinaryReader) -> None: """ Deserialize the object from a binary stream. Args: reader: instance. """ self.timestamp = reader.read_uint32() full_address_bytes = bytearray(reader.read_bytes(16)) ip_bytes = full_address_bytes[-4:] host = '.'.join(map(lambda b: str(b), ip_bytes)) port = 0 capabilities_cnt = reader.read_var_int(VersionPayload.MAX_CAPABILITIES) capabilities_list = [] for _ in range(capabilities_cnt): capa = capabilities.NodeCapability.deserialize_from(reader) if isinstance(capa, capabilities.ServerCapability): port = capa.port capabilities_list.append(capa) self.capabilities = capabilities_list self.address = f"{host}:{port}"
def deserialize_special(self, reader: serialization.BinaryReader) -> None: self.deserialize(reader) self.vm_state = VMState(reader.read_uint8()) self.block_height = reader.read_uint32()