Skip to content

Instantly share code, notes, and snippets.

@mariodian
Created November 1, 2017 06:55
Show Gist options
  • Save mariodian/236a831c4e0dd4772ca866eb81f9cac5 to your computer and use it in GitHub Desktop.
Save mariodian/236a831c4e0dd4772ca866eb81f9cac5 to your computer and use it in GitHub Desktop.
Add nLocktime to a raw Bitcoin transcation
String.prototype.lpad = function(padString, length) {
var str = this;
while (str.length < length)
str = padString + str;
return str;
}
var blockHeight = 434695,
rawTx = '<raw transaction>',
blockLittleEndian = (blockHeight).toString(16).lpad('0', 8).match(/../g).reverse().join('');
document.write(rawTx.slice(0, -8) + blockLittleEndian);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment