A man who used Bitcoin to buy ecstasy on the dark web had been spared jail after a judge heard he had experienced an epiphany following a near death experience.

Steven Hancock came close to losing his life when his heart stopped after he had a cardiac arrest while suffering from pneumonia.

Once the 46-year-old was discharged from hospital he not only ceased his heavy drug use but also stopped smoking as well, a court heard.

And a judge said that after reading he was a hard working man and deemed a low risk of reoffending he could impose a suspended sentence.

Alistair Hegarty, prosecuting, told Swindon Crown Court how packages containing the drugs were intercepted by a parcel courier as they came into the country.

In March last year the first package, which contained 52 ecstasy tablets, was found addressed to his Pinehurst home from an eBay seller in Amsterdam.

The following month a second parcel, from the same vendor, contained 54 pills with a similar weight of about 23g.

When police raided his home he said they found a small amount of cannabis in his home as well as three-and-a-half other ecstasy tablets.

He was questioned and he said that he used Bitcoin to buy about 50 tablets a month on the dark web to feed his heavy habit, often taking five pills in a night.

Mr Hegarty said he handed his phone over to police, giving them the pin to access it, and they found no evidence of dealing.

However he said the defendant did volunteer that he would occasionally share his drugs with pals if they were short.

Hancock, of Cedar Close, pleaded guilty to two counts of fraudulent evasion of a prohibition, and possessing cannabis and ecstasy.

Richard Williams, defending, said that his client had the epiphany after being hospitalised in December.

The court heard that he had references from his boss, who said he is trusted and a hard worker, and landlord.

Passing sentence Judge Robert Pawson said "You are described in the presentence report as a low risk of reoffending, a low risk to the public.

"In all circumstances it seems to me had you fought it at trial it would have been two years and three months.

"You have been candid since you were arrested uttering the immortal words 'All right, you've got me'."

He imposed an 18 month jail term suspended for 18 months with 200 hours of unpaid work and a four month curfew from 7pm to 5am.

When he heard it meant he would miss a camping holiday in late August the judge told him that it was part of the punishment.