They were never Ukrainian nuclear weapons
They were Soviet nucs deployed to Ukraine, always under command and control of Russians. The breakup of the Soviet Union required negotiations over how the command and control of forward deployed nucs was to be reorganized.
Frankly Europe wanted them out of Ukraine because of the extreme corruption and concerns the nucs would end up on the black market
It was a bad idea for Ukraine to have nuclear weapons in 1994 due to extreme corruption like you said. But they had the possession of the nuclear weapons even if the nuclear codes were in Moscow. The Soviet Union no longer existed so Ukraine had the right to possess the nuclear weapons. They were willing to play ball and give them back to the Russians. It was done in good faith at that time. Boris Yeltsin had no desire to conquer Ukraine to expand the Russian Empire.