Exemplo n.º 1
0
 def serialize(self):
     return b''.join((
         pack_le_int32(self.version),
         pack_le_int32(self.time),
         pack_varint(len(self.inputs)),
         b''.join(tx_in.serialize() for tx_in in self.inputs),
         pack_varint(len(self.outputs)),
         b''.join(tx_out.serialize() for tx_out in self.outputs),
         pack_le_uint32(self.locktime)
     ))
Exemplo n.º 2
0
    def serialize(self):
        nLocktime = pack_le_uint32(self.locktime)
        txins = (pack_varint(len(self.inputs)) +
                 b''.join(tx_in.serialize() for tx_in in self.inputs))
        txouts = (pack_varint(len(self.outputs)) +
                  b''.join(tx_out.serialize() for tx_out in self.outputs))

        if self.tx_type:
            uVersion = pack_le_uint16(self.version)
            uTxType = pack_le_uint16(self.tx_type)
            vExtra = self._serialize_extra_payload()
            return uVersion + uTxType + txins + txouts + nLocktime + vExtra
        else:
            nVersion = pack_le_int32(self.version)
            return nVersion + txins + txouts + nLocktime