The Bloomberg Billionaires Index puts Musk's fortune at $26.6 billion.

Elon Musk says he doesn't have a lot of cash.

His wealth came up in the second day of his testimony before a federal jury in Los Angeles, where the Tesla and SpaceX chief executive is on trial over a tweet in which he referred to a British cave expert as a "pedo guy."

After an unsuccessful objection from his lawyer, Musk told the jury that he has Tesla stock and SpaceX stock, with debt against those holdings, and that his net worth is about $20 billion. But contrary to public opinion, he said, he didn't have much cash. Musk finished testifying after a total of about six hours on the stand over two days.

Caver Vernon Unsworth sued Musk over the "pedo guy" tweet, which the CEO called "a flippant, off-the-cuff insult." Musk said he was responding to Unsworth's criticism of Musk's effort to help rescue members of a Thai soccer team from a flooded cave in 2018. Musk and engineers at his companies prepared a mini-submarine to help with the rescue efforts. The 12 kids, ages 11 to 16, and their coach were ultimately saved without the sub.

Usnworth, who knew the caves well, ridiculed the high-profile effort from Musk. He told CNN that Musk could "stick his submarine where it hurts" and called the idea a PR stunt with no chance of working.

That angered Musk, who said a team of engineers worked very hard to build the sub to save the boys. He said Unsworth's comments denigrated the efforts of his team.

Thai rescue officials were "very happy" with his team's effort, and the government thanked him for it, Musk said, contradicting Unsworth's comments in the CNN interview.

Musk also explained to the jury his penchant to tweet. (He retweeted a Tesla post during a break in his testimony.)

Musk said he likes to solicit public input on Twitter.

"There are pretty smart people out there," Musk said.

Despite Musk's status as one of the richest people on the planet, his net worth is largely illiquid.

The Bloomberg Billionaires Index puts his fortune at $26.6 billion. That comprises an estimated $14.6 billion stake in SpaceX. Musk has said previously he doesn't intend to sell any of his holdings in the closely held company.

Musk has also long been a buyer of Tesla shares to bolster his $11.4 billion holding.

He's pledged about 40% of his Tesla shares to unlock some of the wealth without shrinking his stake. A May filing revealed that he had access to about $500 million of credit lines from affiliates of Morgan Stanley, Goldman Sachs and Bank of America as of April 30. Still, that's a fraction of his $26.6 billion overall fortune on the Bloomberg Billionaires Index and it's unclear how much of those credit lines remain unused.

Musk's wealth is an issue at the trial because a jury may consider evidence of his net worth in determining punitive damages. But Musk's lawyers argued in court papers that the jury can't award more in punitive damages than in compensatory damages. There is no way the jury would award more than $1 billion in compensation, so Musk's net worth exceeding that isn't relevant, the lawyers said.

In his testimony, Musk cited his mother as having some good advice, that Unsworth might want to follow.

"As my mom said, if somebody insults you, just let it go," Musk said.

In September, Musk revealed in court documents that one of his trusted aides, Jared Birchall, paid $50,000 to hire a private investigator who looked into Unsworth. Attorneys for Unsworth said the investigator was offered a $10,000 bonus if he was able to confirm nefarious behavior - which was never paid.

Birchall worked at Morgan Stanley until 2016 and is the manager of Excession, Musk's family office.

He took the stand after Musk.

Birchall testified that he hired James Howard, who later turned out to be a conman.

After Howard came up with what later turned out to be fake dirt on Unsworth, such as that he had been visiting Thailand since the 1980s and that he met his wife when she was a teenager, Birchall, using the name James Brickhouse, told Howard to leak the information to media in the U.K.

"I believed him to be a credible investigator," Birchall told the jury. "I understood these things to be facts. I asked him to share facts."

Musk also enlisted help from a second investigator at the Palo Alto, California-based law firm Cooley, which didn't respond to a request for comment.