You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

34 lines
671 B

// OP_RETURN {data}
const bscript = require('../script')
const types = require('../types')
const typeforce = require('typeforce')
const OPS = require('bitcoin-ops')
function check (script) {
const buffer = bscript.compile(script)
return buffer.length > 1 &&
buffer[0] === OPS.OP_RETURN
}
check.toJSON = function () { return 'null data output' }
function encode (data) {
typeforce([types.Buffer], data)
return bscript.compile([OPS.OP_RETURN].concat(data))
}
function decode (buffer) {
typeforce(check, buffer)
return bscript.decompile(buffer).slice(1)
}
module.exports = {
output: {
check: check,
decode: decode,
encode: encode
}
}