def estimated_input_weight(cls, txin: TxInput, is_segwit_tx: bool) -> int:
        """Return an estimate of serialized input weight in weight units."""
        script_sig = cls.input_script(txin, estimate_size=True)
        input_size = len(txin.serialize_to_network(script_sig=script_sig))

        if txin.is_segwit(guess_for_address=True):
            witness_size = len(cls.serialize_witness(txin, estimate_size=True))
        else:
            witness_size = 1 if is_segwit_tx else 0

        return 4 * input_size + witness_size
Return an estimate of serialized input weight in weight units.
electrum/transaction.py