A Scots teenager who sent a Snapchat video showing himself brandishing a suspected handgun sparked a raid by armed cops.
Jack Elliot was seen in the clip holding and cocking a black gun with a gold bullet in its chamber.
The 18-year-old sent the video over the social media app to a relative of a man accused of stabbing him.
Edinburgh Sheriff Court heard Elliot messaged the footage in a bid to deter any future attacks.
But police became aware of the film and firearms officers who examined it deemed the gun to be “real”.
Firearms cops swooped on the home of Elliot’s grandparents under warrant in an effort to recover the weapon.
Elliot appeared at the court on Friday and admitted a charge of threatening or abusive behaviour. The charge stated he sent a video where he appeared to display a loaded handgun.
Fiscal depute Jennifer McLaren said Elliot had been stabbed last year by a male who had been arrested.
Ms McLaren said Elliot sent a video to the alleged attacker’s relative on April 2 last year.
She said: “The video contained Mr Elliot holding a black handgun with a gold bullet in the chamber. The video showed the gun being cocked before the camera moved to show Mr Elliot holding it.”
The prosecutor said the relative made a copy of the Snapchat video with a second mobile phone.
The court heard police later became aware of the footage and firearms officers “deemed the gun to be real”.
Ms McLaren said the search of Elliot’s grandparents home failed to find the weapon and Elliot later handed himself in at St Leonards police station.
A search of his mother’s home also found no gun, the court was told, and it was ultimately never recovered.
Defence agent Nigel Bruce said the video had actually been made between a year and 18 months before his client was stabbed.
Mr Bruce said Elliot was at a party drinking with other teens when someone produced the “item” and they took turns posing with it.
The solicitor said first offender Elliot, who works in roofing, “suspects it wasn’t a real gun but he has no idea”.
Mr Bruce said his client later sent that video to his alleged attacker’s relative to show he could “self-defend”. He added: “His thinking was, send the video and they won’t mess with me again.
“That’s what was going through his immature mind.”
Mr Bruce said Elliot spent three days in hospital after being stabbed.
Sheriff John Mundy deferred sentence on Elliot, of the city’s Prestonfield area, until next month for reports.
Don't miss the latest news from around Scotland and beyond - Sign up to our daily newsletter here.