Exemple #1
0
    def DeserializeExclusiveData(self, reader):
        """
        Deserialize full object.

        Args:
            reader (neo.IO.BinaryReader):

        Raises:
            Exception: If the transaction type is incorrect or if there are no claims.
        """
        self.Type = TransactionType.ClaimTransaction
        if self.Version != 0:
            raise Exception('Format Exception')

        numrefs = reader.ReadVarInt()

        claims = []
        for i in range(0, numrefs):
            c = CoinReference()
            c.Deserialize(reader)
            claims.append(c)

        self.Claims = claims
        if len(self.Claims) == 0:
            raise Exception('Format Exception')
Exemple #2
0
    def DeserializeExclusiveData(self, reader):
        """
        Deserialize full object.

        Args:
            reader (neo.IO.BinaryReader):
        """
        if self.Type == b'\x02':  # ClaimTransaction
            if self.Version != 0:
                raise FormatError('Invalid format')

            numrefs = reader.ReadVarInt()

            claims = []
            for i in range(0, numrefs):
                c = CoinReference()
                c.Deserialize(reader)
                claims.append(c)

            self.Claims = claims
            if len(self.Claims) == 0:
                raise FormatError('Invalid format')

        elif self.Type == b'\xd1':  # InvocationTransaction
            if self.Version > 1:
                raise FormatError('Invalid format')

            self.Script = reader.ReadVarBytes()

            if len(self.Script) == 0:
                raise FormatError('Invalid Format')

            if self.Version >= 1:
                self.Gas = reader.ReadFixed8()
                if self.Gas < Fixed8.Zero():
                    raise FormatError("Invalid Format")
            else:
                self.Gas = Fixed8(0)
        else:
            super(RawTransaction, self).DeserializeExclusiveData(reader=reader)