A mere five feet tall in his sailor’s clothes, with a mop of brown hair and twinkling hazel eyes, James Scott was just 16 but already had more than a years’ hard work under his belt toiling on the fishing smack, Venus.

When a small wooden spice box wrapped in paper caught his eye, the teen - with a tough life behind him and the probability of an even tougher one ahead - may have thought there was little to lose should it find its way into his pocket.

Once unwrapped, James peered inside and found the key to a very different world. Intoxicated by the generous handful of sovereigns it held - perhaps blinded by the thrill of his find - he gaily set off to see how much of it he could spend.

In an exhilarating few days, young James lived like a lord, says researcher and writer Margaret Hubble, who delved into old High Court records to uncover a ‘Great Expectations’ Victorian world of poverty, crime and prison for her new book.

“He was just a young lad, and he was always going to get caught,” she adds. “He headed off with the money, treating his pals to all sorts, spending it on food, drink and dancing.

Read more: Old Macdonald had a robot: Driverless tractors appear on farms

“It was obvious he had money that he shouldn’t have had, because no-one had money in those days and yet, here he was, spending it like water.”

It might easily be a scene from the dark and gritty new BBC One adaption of Charles Dickens’ Victorian tale of good versus evil, poverty and prison, Great Expectations.

In it, young Pip encounters convicts and unsavoury characters, there are courtroom dramas, transportation to the colonies, prison ships and the familiar scenes of Victorian hardship, squalor and desperation found in a Charles Dickens’ book.

The reality of that grim 19th century world was found lurking in yellowing High Court papers stored in Register House at the east end of Edinburgh’s Princes Street, as Margaret searched for interesting tales of crime to include in her new book, Dark Tales of Leith.

Many documents had been left intact, bound in tape, since the day the clerk of court had completed his duties. And each, she says,  sheds light on Dickensian life in Scotland: the grim poverty that drove some to crime, and the dreadful consequences of prison, execution or transportation that awaited even those convicted of what today would be seen as minor misdemeanours borne out of poverty, hopeless and desperation.

The Herald:

“The court papers are fascinating,” she says. “They tell us so much about the lives people led – they’re not fiction, they are the real thing.”

Indeed, they bring to life Dickensian-style stories such as that of young James, with his stolen box of sovereigns that would pay for a few extravagant days of fun and games but which would cost him dear.

He had worked on the Venus for 14 months, making the journey twice a week between Leith and London where the 208-ton smack would offload its cargo of boxes of spices, usually stored in a locked cabin, and its handful of passengers.

In March 1824, however, one box was instead stored in a sideboard. Alone on the boat, James seized his chance.

This, however, was no small theft of spices. For inside was £1500 worth of sovereigns – worth around £150,000 today.

Read more: Scientists bid to unlock the darkest secret of whisky’s unique taste

He stuffed his pockets with sovereigns, hid the rest and set off to have fun.

What followed was a raucous pub crawl across Leith and beyond, with James and his friends fuelled on beer, rum and gin, sustained thanks to beef, “cow heel and a couple of baps”.

At one point James splashed out to pay a fiddler “for a bit of a jig”. Done with Leith, the stag party headed for Fife where they bought a dozen oranges, an expensive indulgence for the times.

Back in Leith, James settled in to his new, monied lifestyle and bought golf clubs, a few balls and headed off for a game on the Links.

Such lavish spending, however, meant he was soon under arrest. Convicted of theft, he faced another long boat journey: transportation to New South Wales for 14 years.

The Herald:

The journey alone would be gruelling: often spanning eight months, including weeks of waiting for a prison ship, many convicts died in transit.

Those who survived faced grim conditions and no return ticket home at the end.

In Edinburgh, around 2000 prisoners were sentenced to be transported to Australia between the 1780s and 1879, and some were transported for trivial crimes, adds Margaret.

“An incredible number were transported for stealing. Often they had stolen before, but mostly it was what we’d consider now to be not a lot of money, and things like clothes.

“The authorities were trying to get as many people to Australia as possible - sending them away was a good way to get rid of them.”

Read more: Power to the people: How electricity changed crofters lives forever

Many cases in the papers were distinctly ‘of their time’. Such as that of James Grieve, a porter, transported for seven years in 1821 after being convicted of stealing 574lbs of East India indigo.

“At this time, indigo was an extremely valuable commodity,” explains Margaret. “Later grown in plantations in localities such as South Carolina where slaves cultivated the crops, the finished dye was expensive to purchase, a symbol of status and affluence, and in great demand in Europe.”

Australia also awaited Robert Ward and John Ross, vicious muggers who pounced on victims and stole pocket watches and seals – status symbols of the times. Both were given 14 years’ transportation.

Likewise, printer David Cossar, who was found in February 1823 at Leith Wynd with a bundle of mostly women’s clothes and fabric under his arm.

The items were traced to a break in at a nearby property, where the man of the house was said to be  outraged to find his favourite red nightcap which “he always wore to bed” stolen.

The Herald:

Stealing clothes was not unusual in hard times when people had few possessions other than the clothes on their backs, says Margaret.

“Most of the women in the court papers had committed thefts such as child stripping, where children, probably from a wealthier classes, would be stripped of their clothes which were then sold or pawned.

“The people who did it probably got very little money for it but then they had little money. One, Margaret Williams, was all over Leith taking clothes from various children and going to various pawn shops.”

She paid a heavy price: 10 years’ transportation.

Other cases shine light on the difficult times faced by 19th century women.

Read more: New technology to ease Scottish tourist hotspot congestion

One involved bigamist William Bennison, hanged after being convicted for poisoning his wife with arsenic and suspected of also murdering his first wife. Attached to the 170-year-old documents was a patch of blue fabric from his dead wife’s dress, a poignant link to tragic events in Leith Walk.

While the young victims of sleazy Leith Provost Robert Philip – convicted of molesting young girls – faced a lifetime of being shunned and their reputations besmirched, while his status meant he avoided his sentence of 15 years transportation. Instead, he spent two years in Calton Hill prison, “mainly reading and writing”.

Even lesser crimes could lead to prison, and age was no barrier. Perhaps the saddest case is that of 11-year-old John Kay, 4ft 5ins, fair haired with brown eyes, dirty with ragged clothes, sentenced to ten days in prison for stealing a bedcover.

“It was a brutal time, and people were dirt poor,” adds Margaret.

“You never know what you will find in these old documents.”

The Dark Streets of Leith by Margaret Hubble, £7.99 Amazon