Imam al-Shafi'i (may Allah have mercy on him) said: "The wage of those who divide (al-qassam) should be given from the public treasury (bayt al-mal), because those who divide are (in a sense) judges."
The Shaykh, the jurist (Imam al-Bayhaqi) (may Allah have mercy on him), said: "It has been narrated to us concerning the share for public interests, that is, the share of the Prophet (peace and blessings be upon him), that it was for his (own) needs and the needs (and calamities) of the people."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب آداب القاضي / Q20441
Musa bin Tarif al-Asadi said: Sayyiduna Ali (may Allah be pleased with him) entered the public treasury (bayt al-mal) and expressed his contempt for it. He said: "I will not reach the evening while a single dirham remains in you." He ordered a man from Banu Asad, and he distributed it until nightfall. The people said: "If only you had given him some compensation!" He said: "If he wishes, but it is unlawful (suht)."
Imam al-Shafi'i (may Allah have mercy on him) said: It is not lawful for anyone to give unlawful earnings, just as it is not lawful to take them, and Sayyiduna Ali (may Allah be pleased with him) would not give anything unlawful to anyone.
Its chain is weak; Musa bin Tarif is not used as proof.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب آداب القاضي / 20441
Musa bin Tarif narrates from his father that Sayyiduna Ali (may Allah be pleased with him) distributed something and called a man to do the reckoning. It was said: "If only you had given him something!" He said: "If he wishes, though it is unlawful."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب آداب القاضي / 20442