Add P2WPKH
This commit is contained in:
parent
3db951fc64
commit
c488001b82
3 changed files with 13 additions and 19 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,19 +1,16 @@
|
|||
// {signature} {pubKey}
|
||||
|
||||
const bscript = require('../../script')
|
||||
import * as bscript from '../../script'
|
||||
|
||||
function isCompressedCanonicalPubKey (pubKey) {
|
||||
function isCompressedCanonicalPubKey (pubKey: Buffer): boolean {
|
||||
return bscript.isCanonicalPubKey(pubKey) && pubKey.length === 33
|
||||
}
|
||||
|
||||
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]) &&
|
||||
isCompressedCanonicalPubKey(chunks[1])
|
||||
bscript.isCanonicalScriptSignature(<Buffer>chunks[0]) &&
|
||||
isCompressedCanonicalPubKey(<Buffer>chunks[1])
|
||||
}
|
||||
check.toJSON = function () { return 'witnessPubKeyHash input' }
|
||||
|
||||
module.exports = { check }
|
||||
export {}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
// OP_0 {pubKeyHash}
|
||||
|
||||
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 === 22 &&
|
||||
|
@ -11,8 +11,3 @@ function check (script) {
|
|||
buffer[1] === 0x14
|
||||
}
|
||||
check.toJSON = function () { return 'Witness pubKeyHash output' }
|
||||
|
||||
module.exports = {
|
||||
check
|
||||
}
|
||||
export {}
|
||||
|
|
Loading…
Add table
Reference in a new issue