Gonna buck the trend here.
Nigeel, I think you handled it fine. But I don't think you were obligated to keep this guy's identity secret.
I'd say it depends on the friendship you have with both and how you found out he was trans.
If you found it out from a support group group or some place where confidential information was shared, or if he told you in private, then you are ethically bound to keep his confidence.
If you found out in some other way, i.e. someone told you, you clocked him, you saw him at a trans rally, he told you in public, you saw his youtube video, or you knew him before his transition, etc., then you have no obligation to keep his secret. You're also not obligated to judge your acquaintance's motives for asking. I try not to keep secrets from my close friends unless I've agreed not to tell.
As someone who's often socially clueless, I depend on my friends to help me navigate the social landscape. And I have unfortunately felt the painful sting of being the only one who didn't know something because I was a bit of a social outcast and had no one close enough to me to tell me. Having friends tell me things that might be common knowledge to some others has helped me on numerous occasions. I try to return the favor when I can.
There are people who say "never gossip." I'm not one of those people. I have no ethical problem with divulging facts about other people. It's just not my responsibilities to keep their secret unless it was told to me in confidence. (I consider a friend telling me something in private, a confidence, whether or not I'm asked not to tell).
I know we'd like people not to out us, but that isn't an overarching principal. Friendship, trust, and confidences figure into it as well.
OK, go ahead and flame me...