The setup assumes a large mass(Earth?) an a photon launched from its surface initially. The wavelength of the photon on launch is known. Then the new energy of the photon is compared with energy it traveled a distance $d$.
Initially, $$E_1 = \frac{GMm}{R} + \frac{1}{2}mv^2$$
where m- mass of photon, M is mass of earth, R is radius.
Finally $$E_2 = \frac{GMx}{R+d} + \frac{1}{2}xv^2$$
where $x$ is new mass of the photon.
Putting $m = \frac{h}{Lc}$, $L$ is wavelength
Leet the new wavelength be $W$.
we can equate the 2:
$$\frac{GMh}{RLc} + \frac{1}{2}\left(\frac{h}{L}\right)^2 = \frac{GMh}{(R+d)Wc} + \frac{1}{2}\left(\frac{h}{W}\right)^2$$
Solving and putting $\frac{1}{W} = y$, we'll get,
$$\frac{h^2}{2}y^2 + \frac{GMhy}{(R+d)c} = \frac{GMh}{RcL} + \frac{1}{2}\left(\frac{h}{L}\right)^2$$
So this follows a quadratic equation $ax^2 + bx + c =0$
So that would mean that $y$ would keep decreasing as $d$ increases. Then it would mean that the mass of the photon increases as it rises.
Is this logic correct or am I making a really blockheaded mistake here?