How to calculate geocentric conjunction time and moon altitude at a given time
I assume you have an algorithm to compute position of the Sun, since you can compute rise and set times.  You will need to compute the position of the Moon in a similar manner.  Then, convert both positions to geocentric ecliptical coordinates (ecliptic latitude and longitude) and use some numerical bisection method (root finder) to find where the difference of the longitudes of the two objects has a root (i.e., becomes zero).  The corresponding JD provides the moment of the geocentric conjunction.
Calculation of the altitude is a standard procedure - you'll need to convert your ecliptic coordinates to equatorial (right ascension and declination) and then to horizontal (azimuth and altitude).  Finally, correct for the horizontal parallax to convert your geocentric coordinates to topocentric coordinates for the location of the observer.