Skip to content

Instantly share code, notes, and snippets.

@svasva
Created October 23, 2013 14:54
Show Gist options
  • Save svasva/7120319 to your computer and use it in GitHub Desktop.
Save svasva/7120319 to your computer and use it in GitHub Desktop.
# util
script_to_pubkey: (pubkey) ->
b = []
if pubkey[..1] == '04'
b.push new Buffer([0x41])
else
b.push new Buffer([0x21])
b.push util.unhexlify(pubkey)
b.push new Buffer([0xAC])
return Buffer.concat(b)
# transaction
serialize: ->
b = []
b.push binpack.packUInt32(@version, 'little')
if @pos
b.push binpack.packUInt32(@time, 'little')
b.push util.ser_vector(@vin)
b.push util.ser_vector(@vout)
b.push binpack.packUInt32(@lockTime, 'little')
if @pos && @algo == 'sha256'
b.push util.ser_string(@message)
return Buffer.concat(b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment