Add P2SH
This commit is contained in:
parent
528dff01c1
commit
604072ffad
3 changed files with 17 additions and 21 deletions
|
@ -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,15 +1,15 @@
|
||||||
// <scriptSig> {serialized scriptPubKey script}
|
// <scriptSig> {serialized scriptPubKey script}
|
||||||
|
|
||||||
|
import * as bscript from '../../script'
|
||||||
|
import * as p2ms from '../multisig'
|
||||||
|
import * as p2pk from '../pubkey'
|
||||||
|
import * as p2pkh from '../pubkeyhash'
|
||||||
|
import * as p2wpkho from '../witnesspubkeyhash/output'
|
||||||
|
import * as p2wsho from '../witnessscripthash/output'
|
||||||
|
|
||||||
const Buffer = require('safe-buffer').Buffer
|
const Buffer = require('safe-buffer').Buffer
|
||||||
const bscript = require('../../script')
|
|
||||||
|
|
||||||
const p2ms = require('../multisig/')
|
export function check (script: Buffer | Array<number | Buffer>, allowIncomplete?: boolean): boolean {
|
||||||
const p2pk = require('../pubkey/')
|
|
||||||
const p2pkh = require('../pubkeyhash/')
|
|
||||||
const p2wpkho = require('../witnesspubkeyhash/output')
|
|
||||||
const p2wsho = require('../witnessscripthash/output')
|
|
||||||
|
|
||||||
function check (script, allowIncomplete) {
|
|
||||||
const chunks = bscript.decompile(script)
|
const chunks = bscript.decompile(script)
|
||||||
if (chunks.length < 1) return false
|
if (chunks.length < 1) return false
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ function check (script, allowIncomplete) {
|
||||||
if (!Buffer.isBuffer(lastChunk)) return false
|
if (!Buffer.isBuffer(lastChunk)) return false
|
||||||
|
|
||||||
const scriptSigChunks = bscript.decompile(bscript.compile(chunks.slice(0, -1)))
|
const scriptSigChunks = bscript.decompile(bscript.compile(chunks.slice(0, -1)))
|
||||||
const redeemScriptChunks = bscript.decompile(lastChunk)
|
const redeemScriptChunks = bscript.decompile(<Buffer>lastChunk)
|
||||||
|
|
||||||
// is redeemScript a valid script?
|
// is redeemScript a valid script?
|
||||||
if (!redeemScriptChunks) return false
|
if (!redeemScriptChunks) return false
|
||||||
|
@ -44,6 +44,3 @@ function check (script, allowIncomplete) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
check.toJSON = function () { return 'scriptHash input' }
|
check.toJSON = function () { return 'scriptHash input' }
|
||||||
|
|
||||||
module.exports = { check }
|
|
||||||
export {}
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// OP_HASH160 {scriptHash} OP_EQUAL
|
// OP_HASH160 {scriptHash} OP_EQUAL
|
||||||
|
|
||||||
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 buffer = bscript.compile(script)
|
const buffer = bscript.compile(script)
|
||||||
|
|
||||||
return buffer.length === 23 &&
|
return buffer.length === 23 &&
|
||||||
|
@ -12,6 +12,3 @@ function check (script) {
|
||||||
buffer[22] === OPS.OP_EQUAL
|
buffer[22] === OPS.OP_EQUAL
|
||||||
}
|
}
|
||||||
check.toJSON = function () { return 'scriptHash output' }
|
check.toJSON = function () { return 'scriptHash output' }
|
||||||
|
|
||||||
module.exports = { check }
|
|
||||||
export {}
|
|
||||||
|
|
Loading…
Reference in a new issue