I take the original to be that in the broadside ballad index at www.erols.com/olsonw as "A Constant wife". It's listed at ZN3202 (Laws M13, in DT). It was entered in the Stationers' Register in 1631. In the index are cited some close relatives with pretty much the same tale as the 1st half of the song (e.g. the oft told 'Earl Brand' [Child #7] tale, and Abraham Miles' The Masterpiece of Love Songs/ The Bold Soldier (index ZN1516, Laws M27, in DT), Percy's 'Child of Elle'. The song was undoubtably not entirely original. The 2nd half is a common 'praise of a pretty woman' and the 1st half was undoubtably based on an earlier version of the tale that's now unknown.
Gavin Grieg in 'Folksong of the Northeast' (Art. #8) gave "The Bonnie Lass of Benachie" and a version of "Locks and Bolts" and noted that the Bonnie Lass of Benachie was said to be a Miss Erskine, heiress of Pittodrie, who married her soldier lover about 1770. He adds that "Locks and Bolts" is said to refer to the tale, but we know it was already nearly 140 years old by 1770.