Add p2pkh template
This commit is contained in:
parent
9da1c95f89
commit
3db951fc64
3 changed files with 12 additions and 16 deletions
|
@ -1,5 +1,7 @@
|
|||
module.exports = {
|
||||
input: require('./input'),
|
||||
output: require('./output')
|
||||
import * as input from './input'
|
||||
import * as output from './output'
|
||||
|
||||
export {
|
||||
input,
|
||||
output,
|
||||
}
|
||||
export {}
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
// {signature} {pubKey}
|
||||
|
||||
const bscript = require('../../script')
|
||||
import * as bscript from '../../script'
|
||||
|
||||
function check (script) {
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const chunks = bscript.decompile(script)
|
||||
|
||||
return chunks.length === 2 &&
|
||||
bscript.isCanonicalScriptSignature(chunks[0]) &&
|
||||
bscript.isCanonicalPubKey(chunks[1])
|
||||
bscript.isCanonicalScriptSignature(<Buffer>chunks[0]) &&
|
||||
bscript.isCanonicalPubKey(<Buffer>chunks[1])
|
||||
}
|
||||
check.toJSON = function () { return 'pubKeyHash input' }
|
||||
|
||||
module.exports = { check }
|
||||
export {}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
// OP_DUP OP_HASH160 {pubKeyHash} OP_EQUALVERIFY OP_CHECKSIG
|
||||
|
||||
const bscript = require('../../script')
|
||||
import * as bscript from '../../script'
|
||||
const OPS = require('bitcoin-ops')
|
||||
|
||||
function check (script) {
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script)
|
||||
|
||||
return buffer.length === 25 &&
|
||||
|
@ -14,6 +14,3 @@ function check (script) {
|
|||
buffer[24] === OPS.OP_CHECKSIG
|
||||
}
|
||||
check.toJSON = function () { return 'pubKeyHash output' }
|
||||
|
||||
module.exports = { check }
|
||||
export {}
|
||||
|
|
Loading…
Add table
Reference in a new issue