bitcoinjs-lib/src/templates/witnesspubkeyhash/input.ts

20 lines
486 B
TypeScript
Raw Normal View History

// {signature} {pubKey}
2018-06-25 08:25:12 +02:00
const bscript = require('../../script')
function isCompressedCanonicalPubKey (pubKey) {
return bscript.isCanonicalPubKey(pubKey) && pubKey.length === 33
}
function check (script) {
const chunks = bscript.decompile(script)
return chunks.length === 2 &&
bscript.isCanonicalScriptSignature(chunks[0]) &&
isCompressedCanonicalPubKey(chunks[1])
}
check.toJSON = function () { return 'witnessPubKeyHash input' }
2018-07-03 15:00:00 +02:00
module.exports = { check }
export {}