Add P2PK templates
This commit is contained in:
parent
2f32ea6bc9
commit
9da1c95f89
4 changed files with 14 additions and 20 deletions
|
@ -3,8 +3,8 @@
|
||||||
import * as bscript from '../../script'
|
import * as bscript from '../../script'
|
||||||
const OPS = require('bitcoin-ops')
|
const OPS = require('bitcoin-ops')
|
||||||
|
|
||||||
function partialSignature (value) {
|
function partialSignature (value: number | Buffer): boolean {
|
||||||
return value === OPS.OP_0 || bscript.isCanonicalScriptSignature(value)
|
return value === OPS.OP_0 || bscript.isCanonicalScriptSignature(<Buffer>value)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function check (script: Buffer | Array<number | Buffer>, allowIncomplete?: boolean): boolean {
|
export function check (script: Buffer | Array<number | Buffer>, allowIncomplete?: boolean): boolean {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
module.exports = {
|
import * as input from './input'
|
||||||
input: require('./input'),
|
import * as output from './output'
|
||||||
output: require('./output')
|
|
||||||
|
export {
|
||||||
|
input,
|
||||||
|
output,
|
||||||
}
|
}
|
||||||
export {}
|
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
// {signature}
|
// {signature}
|
||||||
|
|
||||||
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)
|
const chunks = bscript.decompile(script)
|
||||||
|
|
||||||
return chunks.length === 1 &&
|
return chunks.length === 1 &&
|
||||||
bscript.isCanonicalScriptSignature(chunks[0])
|
bscript.isCanonicalScriptSignature(<Buffer>chunks[0])
|
||||||
}
|
}
|
||||||
check.toJSON = function () { return 'pubKey input' }
|
check.toJSON = function () { return 'pubKey input' }
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
check: check
|
|
||||||
}
|
|
||||||
export {}
|
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
// {pubKey} OP_CHECKSIG
|
// {pubKey} OP_CHECKSIG
|
||||||
|
|
||||||
const bscript = require('../../script')
|
import * as bscript from '../../script'
|
||||||
const OPS = require('bitcoin-ops')
|
const OPS = require('bitcoin-ops')
|
||||||
|
|
||||||
function check (script) {
|
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||||
const chunks = bscript.decompile(script)
|
const chunks = bscript.decompile(script)
|
||||||
|
|
||||||
return chunks.length === 2 &&
|
return chunks.length === 2 &&
|
||||||
bscript.isCanonicalPubKey(chunks[0]) &&
|
bscript.isCanonicalPubKey(<Buffer>chunks[0]) &&
|
||||||
chunks[1] === OPS.OP_CHECKSIG
|
chunks[1] === OPS.OP_CHECKSIG
|
||||||
}
|
}
|
||||||
check.toJSON = function () { return 'pubKey output' }
|
check.toJSON = function () { return 'pubKey output' }
|
||||||
|
|
||||||
module.exports = { check }
|
|
||||||
export {}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue