def deserialize(self, f):
    self.nVersion = struct.unpack('<i', f.read(4))[0]
    self.vin = deser_vector(f, CTxIn)
    flags = 0
    if (len(self.vin) == 0):
        flags = struct.unpack('<B', f.read(1))[0]
        if (flags != 0):
            self.vin = deser_vector(f, CTxIn)
            self.vout = deser_vector(f, CTxOut)
    else:
        self.vout = deser_vector(f, CTxOut)
    if (flags != 0):
        self.wit.vtxinwit = [CTxInWitness() for _ in range(len(self.vin))]
        self.wit.deserialize(f)
    else:
        self.wit = CTxWitness()
    self.nLockTime = struct.unpack('<I', f.read(4))[0]
    self.sha256 = None
    self.hash = None
def deserialize(self, f):
    self.nVersion = struct.unpack('<i', f.read(4))[0]
    self.vin = deser_vector(f, CTxIn)
    flags = 0
    if (len(self.vin) == 0):
        flags = struct.unpack('<B', f.read(1))[0]
        if (flags != 0):
            self.vin = deser_vector(f, CTxIn)
            self.vout = deser_vector(f, CTxOut)
    else:
        self.vout = deser_vector(f, CTxOut)
    if (flags != 0):
        self.wit.vtxinwit = [CTxInWitness() for _ in range(len(self.vin))]
        self.wit.deserialize(f)
    else:
        self.wit = CTxWitness()
    self.nLockTime = struct.unpack('<I', f.read(4))[0]
    self.sha256 = None
    self.hash = None