Ayesha reported,

Two men came in to see the Messenger of Allah ﷺ and spoke with him about something I do not know, and they angered him, so he cursed them and reviled them. When they left, I said, "Messenger of Allah, no one will gain any good from what these two received."He asked, "What do you mean?"I replied, "You cursed them and reviled them."He said, "Do you not know the agreement I made with my Lord? I said, 'O Allah, I am only a human being, so whichever of the Muslims I curse or revile, make that a means of purification and reward for him.'"

Azami 9642

Sahih

عن عائشة قالت

دخل على رسول الله ﷺ رجلان، فكلماه بشيء لا أدري ما هو؟ فأغضباه، فلعنهما وسبهما، فلما خرجا، قلت: يا رسول الله من أصاب من الخير شيئا ما أصابه هذان، قال: وما ذاك؟ قالت: قلت: لعنتهما وسببتهما. قال: أو ما علمت ما شارطت عليه ربي؟ قلت: اللهم إنما أنا بشر، فأي المسلمين لعنته أو سببته فاجعله له زكاة وأجرا.

الأعظمي 9642صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Biography of the Prophet ﷺ
Chapter
Characteristics of the Prophet ﷺ
Section
One whom the Prophet ﷺ cursed or reviled while he was not deserving of that, it would be purification, reward, and mercy for him
Numbering
Jami al-Kamil 9642 (2nd edition)
Azami 9642