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: self.category = reader.read_var_string(32) self.valid_block_start = reader.read_uint32() self.valid_block_end = reader.read_uint32() if self.valid_block_start >= self.valid_block_end: raise ValueError( "Deserialization error - valid_block_starts is bigger than valid_block_end" ) self.sender = reader.read_serializable(types.UInt160) self.data = reader.read_var_bytes(message.Message.PAYLOAD_MAX_SIZE)
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. """ if reader.read_uint32() != self.magic: raise ValueError("Deserialization error - Incorrect magic") self.compiler = reader.read_bytes(64).decode('utf-8') if reader.read_uint16() != 0: raise ValueError("Reserved bytes must be 0") self.tokens = reader.read_serializable_list(MethodToken) if reader.read_uint16() != 0: raise ValueError("Reserved bytes must be 0") self.script = reader.read_var_bytes(max=512 * 1024) if len(self.script) == 0: raise ValueError("Deserialization error - Script can't be empty") checksum = int.from_bytes(reader.read_bytes(4), 'little') if checksum != self.compute_checksum(): raise ValueError("Deserialization error - Invalid checksum") else: self._checksum = checksum
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: """ Deserialize the unsigned data part of the object from a binary stream. Args: reader: instance. Raises: ValueError: if the valid_block_start exceeds the valid_block_end field. """ self.category = reader.read_var_string(32) self.valid_block_start = reader.read_uint32() self.valid_block_end = reader.read_uint32() if self.valid_block_start >= self.valid_block_end: raise ValueError( "Deserialization error - valid_block_start is bigger than valid_block_end" ) self.sender = reader.read_serializable(types.UInt160) self.data = reader.read_var_bytes(message.Message.PAYLOAD_MAX_SIZE)
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_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_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.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.signers = Transaction._deserialize_signers( reader, self.MAX_TRANSACTION_ATTRIBUTES) self.attributes = Transaction._deserialize_attributes( reader, self.MAX_TRANSACTION_ATTRIBUTES - len(self.signers)) 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. Raises: ValueError: if `count` is zero or exceeds :const:`~neo3.network.payloads.getblocks.GetBlockByIndexPayload.MAX_BLOCKS_COUNT`. """ self.index_start = reader.read_uint32() self.count = reader.read_int16() if self.count < 1 or self.count == 0 or self.count > HeadersPayload.MAX_HEADERS_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.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: """ 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(self, reader: serialization.BinaryReader) -> None: self.index = reader.read_uint32() self.gas_per_block = vm.BigInteger(reader.read_var_bytes())
def deserialize(self, reader: serialization.BinaryReader) -> None: super(_NeoTokenStorageState, self).deserialize(reader) self.vote_to = reader.read_serializable( cryptography.ECPoint) # type: ignore self.balance_height = reader.read_uint32()
def deserialize_special(self, reader: serialization.BinaryReader) -> None: """ Internal use only - deserialize the data from the stream into a TX that includes the unofficial fields """ self.deserialize(reader) self.vm_state = VMState(reader.read_uint8()) self.block_height = reader.read_uint32()
def deserialize_special(self, reader: serialization.BinaryReader) -> None: self.deserialize(reader) self.vm_state = VMState(reader.read_uint8()) self.block_height = reader.read_uint32()
def deserialize(self, reader: serialization.BinaryReader) -> None: super(NameState, self).deserialize(reader) self.expiration = reader.read_uint32() self.admin = reader.read_serializable(types.UInt160)