// {signature} {pubKey} var bscript = require('../../script') var typeforce = require('typeforce') function check (script) { var chunks = bscript.decompile(script) return chunks.length === 2 && bscript.isCanonicalSignature(chunks[0]) && bscript.isCanonicalPubKey(chunks[1]) } check.toJSON = function () { return 'pubKeyHash input' } function encodeStack (signature, pubKey) { typeforce({ signature: bscript.isCanonicalSignature, pubKey: bscript.isCanonicalPubKey }, { signature: signature, pubKey: pubKey }) return [signature, pubKey] } function encode (signature, pubKey) { return bscript.compile(encodeStack(signature, pubKey)) } function decodeStack (stack) { typeforce(typeforce.Array, stack) typeforce(check, stack) return { signature: stack[0], pubKey: stack[1] } } function decode (buffer) { var stack = bscript.decompile(buffer) return decodeStack(stack) } module.exports = { check: check, decode: decode, decodeStack: decodeStack, encode: encode, encodeStack: encodeStack }