@classmethod
def estimated_input_weight(cls, txin, is_segwit_tx):
    """Return an estimate of serialized input weight in weight units."""
    script = cls.input_script(txin, True)
    input_size = len(cls.serialize_input(txin, script)) // 2
    if cls.is_segwit_input(txin, guess_for_address=True):
        witness_size = len(cls.serialize_witness(txin, True)) // 2
    else:
        witness_size = 1 if is_segwit_tx else 0
    return 4 * input_size + witness_size
