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 = {
input: require('./input'),
output: require('./output')
import * as input from './input'
import * as output from './output'
export {
input,
output,
}
export {}

16
src/templates/witnessscripthash/input.ts

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

7
src/templates/witnessscripthash/output.ts

@ -1,9 +1,9 @@
// OP_0 {scriptHash}
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 === 34 &&
@ -11,6 +11,3 @@ function check (script) {
buffer[1] === 0x20
}
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 Hash256bit = typeforce.BufferN(32)
export * from 'typeforce'
export { Number } from 'typeforce'
export { Number, Array } from 'typeforce'

Loading…
Cancel
Save