Browse Source

Add P2WSH

fixTypes
junderw 6 years ago
parent
commit
528dff01c1
No known key found for this signature in database GPG Key ID: B256185D3A971908
  1. 10
      src/templates/witnessscripthash/index.ts
  2. 16
      src/templates/witnessscripthash/input.ts
  3. 7
      src/templates/witnessscripthash/output.ts
  4. 2
      src/types.ts

10
src/templates/witnessscripthash/index.ts

@ -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 {}

16
src/templates/witnessscripthash/input.ts

@ -1,15 +1,14 @@
// <scriptSig> {serialized scriptPubKey script} // <scriptSig> {serialized scriptPubKey script}
const bscript = require('../../script') import * as bscript from '../../script'
const types = require('../../types')
const typeforce = require('typeforce') const typeforce = require('typeforce')
const p2ms = require('../multisig/') import * as p2ms from '../multisig'
const p2pk = require('../pubkey/') import * as p2pk from '../pubkey'
const p2pkh = require('../pubkeyhash/') import * as p2pkh from '../pubkeyhash'
function check (chunks, allowIncomplete) { export function check (chunks: Array<Buffer>, allowIncomplete?: boolean): boolean {
typeforce(types.Array, chunks) typeforce(typeforce.Array, chunks)
if (chunks.length < 1) return false if (chunks.length < 1) return false
const witnessScript = chunks[chunks.length - 1] const witnessScript = chunks[chunks.length - 1]
@ -35,6 +34,3 @@ function check (chunks, allowIncomplete) {
return false return false
} }
check.toJSON = function () { return 'witnessScriptHash input' } check.toJSON = function () { return 'witnessScriptHash input' }
module.exports = { check }
export {}

7
src/templates/witnessscripthash/output.ts

@ -1,9 +1,9 @@
// OP_0 {scriptHash} // OP_0 {scriptHash}
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 === 34 && return buffer.length === 34 &&
@ -11,6 +11,3 @@ function check (script) {
buffer[1] === 0x20 buffer[1] === 0x20
} }
check.toJSON = function () { return 'Witness scriptHash output' } check.toJSON = function () { return 'Witness scriptHash output' }
module.exports = { check }
export {}

2
src/types.ts

@ -34,4 +34,4 @@ export const Buffer256bit = typeforce.BufferN(32)
export const Hash160bit = typeforce.BufferN(20) export const Hash160bit = typeforce.BufferN(20)
export const Hash256bit = typeforce.BufferN(32) export const Hash256bit = typeforce.BufferN(32)
export * from 'typeforce' export * from 'typeforce'
export { Number } from 'typeforce' export { Number, Array } from 'typeforce'

Loading…
Cancel
Save