Beispiel #1
0
    def serialize(self) -> bytes:
        invoke_script = ProgramBuilder.program_from_params(self.sig_data)
        if len(self.public_keys) == 0:
            raise ValueError("no public key in sig")

        if len(self.public_keys) == 1:
            verification_script = ProgramBuilder.program_from_pubkey(
                self.public_keys[0])
        else:
            verification_script = ProgramBuilder.program_from_multi_pubkey(
                self.M, self.public_keys)
        ms = StreamManager.GetStream()
        writer = BinaryWriter(ms)
        writer.WriteVarBytes(invoke_script)
        writer.WriteVarBytes(verification_script)
        ms.flush()
        res = ms.ToArray()
        res = bytes_reader(res)
        StreamManager.ReleaseStream(ms)
        return res
 def serialize_unsigned(self) -> bytes:
     ms = StreamManager.GetStream()
     writer = BinaryWriter(ms)
     writer.WriteUInt8(self.version)
     writer.WriteUInt8(self.tx_type)
     writer.WriteUInt32(self.nonce)
     writer.WriteUInt64(self.gas_price)
     writer.WriteUInt64(self.gas_limit)
     writer.WriteBytes(bytes(self.payer))
     writer.WriteVarBytes(bytes(self.payload))
     writer.WriteVarInt(len(self.attributes))
     ms.flush()
     res = ms.ToArray()
     StreamManager.ReleaseStream(ms)
     return res