Ma'n bin Yazid bin Akhnas (May Allah be pleased with them) (he, his father and his grandfather, all were Companions) reported:
My father set aside some dinars for charity and gave them to a man in the mosque. I went to that man and took back those dinars. He said: "I had not intended you to be given." So we went to Messenger of Allah (ﷺ), and put forth the matter before him. He said to my father, "Yazid, you have been rewarded for what you intended." And he said to me, "Ma'n, you are entitled to what you have taken."[Al- Bukhari].
Arabic/English book reference: Book 1, Hadith 5