Harry Potter creator JK Rowling has accepted a substantial charity donation from the law firm that revealed she was writing under a pseudonym.
The writer brought a legal action against Chris Gossage, a partner at Russells Solicitors, and his friend, Judith Callegari.
Rowling was revealed as the writer of crime novel The Cuckoo's Calling in a Sunday Times article.
The author had published the book under the pen name Robert Galbraith.
Rowling's solicitor told Mr Justice Tugendhat that Russells had contacted the writer's agent after the story was published, revealing it was Mr Gossage who had divulged the confidential information to Ms Callegari.
Ms Callegari then revealed the information in the course of a Twitter exchange with a journalist.
The court heard Rowling had been "left dismayed and distressed by such a fundamental betrayal of trust".
Mr Gossage, Ms Callegari and Russells all apologised and the firm agreed to pay the author's legal costs.
It also agreed to make a payment, by way of damages, to the Soldiers' Charity, formerly known as the Army Benevolent Fund.
Rowling explained that she was donating the money "partly as a thank you to the army people" who helped her with research.
"But also because writing a hero who is a veteran has given me an even greater appreciation and understanding of exactly how much this charity does for ex-servicemen and their families, and how much that support is needed," she said.
The Cuckoo's Calling, about a war veteran turned private investigator called Cormoran Strike, had sold 1,500 copies before it was revealed that Rowling was its author.
Within hours, the novel rose more than 5,000 places to top Amazon's sales list.
Rowling said she would also be donating all the royalties for the book to the charity.
She said she had "always intended to give The Soldiers' Charity a donation out of Robert's royalties but I had not anticipated him making the bestseller list a mere three months after publication (indeed, I had not counted on him ever being there!)"
Major General Martin Rutledge, Chief Executive of ABF The Soldiers' Charity said they were "absolutely thrilled" by her "extraordinary generosity".
"This donation will make a huge difference to the lives of thousands of soldiers, former soldiers and their families who are in real need. Her tremendous show of support for The Soldiers' Charity will help to remind people of the many sacrifices made by our soldiers, long after any news of Afghanistan has left the front page," he added.