style: fix glob pattern for prettier
This commit is contained in:
parent
e8857d3a84
commit
a567a97877
21 changed files with 240 additions and 190 deletions
|
@ -28,7 +28,7 @@
|
|||
"nobuild:integration": "mocha --timeout 50000 test/integration/",
|
||||
"nobuild:unit": "mocha",
|
||||
"prepare": "npm run build",
|
||||
"prettier": "prettier ts_src/*.ts ts_src/**/*.ts --ignore-path ./.prettierignore",
|
||||
"prettier": "prettier 'ts_src/**/*.ts' --ignore-path ./.prettierignore",
|
||||
"test": "npm run build && npm run format:ci && npm run nobuild:coverage",
|
||||
"unit": "npm run build && npm run nobuild:unit"
|
||||
},
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
import * as input from './input'
|
||||
import * as output from './output'
|
||||
import * as input from './input';
|
||||
import * as output from './output';
|
||||
|
||||
export {
|
||||
input,
|
||||
output,
|
||||
}
|
||||
export { input, output };
|
||||
|
|
|
@ -1,21 +1,30 @@
|
|||
// OP_0 [signatures ...]
|
||||
|
||||
import * as bscript from '../../script'
|
||||
import { OPS } from '../../script'
|
||||
import * as bscript from '../../script';
|
||||
import { OPS } from '../../script';
|
||||
|
||||
function partialSignature (value: number | Buffer): boolean {
|
||||
return value === OPS.OP_0 || bscript.isCanonicalScriptSignature(<Buffer>value)
|
||||
function partialSignature(value: number | Buffer): boolean {
|
||||
return (
|
||||
value === OPS.OP_0 || bscript.isCanonicalScriptSignature(<Buffer>value)
|
||||
);
|
||||
}
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>, allowIncomplete?: boolean): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script)
|
||||
if (chunks.length < 2) return false
|
||||
if (chunks[0] !== OPS.OP_0) return false
|
||||
export function check(
|
||||
script: Buffer | Array<number | Buffer>,
|
||||
allowIncomplete?: boolean,
|
||||
): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script);
|
||||
if (chunks.length < 2) return false;
|
||||
if (chunks[0] !== OPS.OP_0) return false;
|
||||
|
||||
if (allowIncomplete) {
|
||||
return chunks.slice(1).every(partialSignature)
|
||||
return chunks.slice(1).every(partialSignature);
|
||||
}
|
||||
|
||||
return (<Array<Buffer>>chunks.slice(1)).every(bscript.isCanonicalScriptSignature)
|
||||
return (<Array<Buffer>>chunks.slice(1)).every(
|
||||
bscript.isCanonicalScriptSignature,
|
||||
);
|
||||
}
|
||||
check.toJSON = function () { return 'multisig input' }
|
||||
check.toJSON = function() {
|
||||
return 'multisig input';
|
||||
};
|
||||
|
|
|
@ -1,27 +1,32 @@
|
|||
// m [pubKeys ...] n OP_CHECKMULTISIG
|
||||
|
||||
import * as bscript from '../../script'
|
||||
import * as types from '../../types'
|
||||
import { OPS } from '../../script'
|
||||
const OP_INT_BASE = OPS.OP_RESERVED // OP_1 - 1
|
||||
import * as bscript from '../../script';
|
||||
import * as types from '../../types';
|
||||
import { OPS } from '../../script';
|
||||
const OP_INT_BASE = OPS.OP_RESERVED; // OP_1 - 1
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>, allowIncomplete?: boolean): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script)
|
||||
export function check(
|
||||
script: Buffer | Array<number | Buffer>,
|
||||
allowIncomplete?: boolean,
|
||||
): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script);
|
||||
|
||||
if (chunks.length < 4) return false
|
||||
if (chunks[chunks.length - 1] !== OPS.OP_CHECKMULTISIG) return false
|
||||
if (!types.Number(chunks[0])) return false
|
||||
if (!types.Number(chunks[chunks.length - 2])) return false
|
||||
const m = <number>chunks[0] - OP_INT_BASE
|
||||
const n = <number>chunks[chunks.length - 2] - OP_INT_BASE
|
||||
if (chunks.length < 4) return false;
|
||||
if (chunks[chunks.length - 1] !== OPS.OP_CHECKMULTISIG) return false;
|
||||
if (!types.Number(chunks[0])) return false;
|
||||
if (!types.Number(chunks[chunks.length - 2])) return false;
|
||||
const m = <number>chunks[0] - OP_INT_BASE;
|
||||
const n = <number>chunks[chunks.length - 2] - OP_INT_BASE;
|
||||
|
||||
if (m <= 0) return false
|
||||
if (n > 16) return false
|
||||
if (m > n) return false
|
||||
if (n !== chunks.length - 3) return false
|
||||
if (allowIncomplete) return true
|
||||
if (m <= 0) return false;
|
||||
if (n > 16) return false;
|
||||
if (m > n) return false;
|
||||
if (n !== chunks.length - 3) return false;
|
||||
if (allowIncomplete) return true;
|
||||
|
||||
const keys = <Array<Buffer>> chunks.slice(1, -2)
|
||||
return keys.every(bscript.isCanonicalPubKey)
|
||||
const keys = <Array<Buffer>>chunks.slice(1, -2);
|
||||
return keys.every(bscript.isCanonicalPubKey);
|
||||
}
|
||||
check.toJSON = function () { return 'multi-sig output' }
|
||||
check.toJSON = function() {
|
||||
return 'multi-sig output';
|
||||
};
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
import * as input from './input'
|
||||
import * as output from './output'
|
||||
import * as input from './input';
|
||||
import * as output from './output';
|
||||
|
||||
export {
|
||||
input,
|
||||
output,
|
||||
}
|
||||
export { input, output };
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
// {signature}
|
||||
|
||||
import * as bscript from '../../script'
|
||||
import * as bscript from '../../script';
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script)
|
||||
export function check(script: Buffer | Array<number | Buffer>): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script);
|
||||
|
||||
return chunks.length === 1 &&
|
||||
bscript.isCanonicalScriptSignature(<Buffer>chunks[0])
|
||||
return (
|
||||
chunks.length === 1 && bscript.isCanonicalScriptSignature(<Buffer>chunks[0])
|
||||
);
|
||||
}
|
||||
check.toJSON = function () { return 'pubKey input' }
|
||||
check.toJSON = function() {
|
||||
return 'pubKey input';
|
||||
};
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
// {pubKey} OP_CHECKSIG
|
||||
|
||||
import * as bscript from '../../script'
|
||||
import { OPS } from '../../script'
|
||||
import * as bscript from '../../script';
|
||||
import { OPS } from '../../script';
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script)
|
||||
export function check(script: Buffer | Array<number | Buffer>): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script);
|
||||
|
||||
return chunks.length === 2 &&
|
||||
return (
|
||||
chunks.length === 2 &&
|
||||
bscript.isCanonicalPubKey(<Buffer>chunks[0]) &&
|
||||
chunks[1] === OPS.OP_CHECKSIG
|
||||
);
|
||||
}
|
||||
check.toJSON = function () { return 'pubKey output' }
|
||||
check.toJSON = function() {
|
||||
return 'pubKey output';
|
||||
};
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
import * as input from './input'
|
||||
import * as output from './output'
|
||||
import * as input from './input';
|
||||
import * as output from './output';
|
||||
|
||||
export {
|
||||
input,
|
||||
output,
|
||||
}
|
||||
export { input, output };
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
// {signature} {pubKey}
|
||||
|
||||
import * as bscript from '../../script'
|
||||
import * as bscript from '../../script';
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script)
|
||||
export function check(script: Buffer | Array<number | Buffer>): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script);
|
||||
|
||||
return chunks.length === 2 &&
|
||||
return (
|
||||
chunks.length === 2 &&
|
||||
bscript.isCanonicalScriptSignature(<Buffer>chunks[0]) &&
|
||||
bscript.isCanonicalPubKey(<Buffer>chunks[1])
|
||||
);
|
||||
}
|
||||
check.toJSON = function () { return 'pubKeyHash input' }
|
||||
check.toJSON = function() {
|
||||
return 'pubKeyHash input';
|
||||
};
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
// OP_DUP OP_HASH160 {pubKeyHash} OP_EQUALVERIFY OP_CHECKSIG
|
||||
|
||||
import * as bscript from '../../script'
|
||||
import { OPS } from '../../script'
|
||||
import * as bscript from '../../script';
|
||||
import { OPS } from '../../script';
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script)
|
||||
export function check(script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script);
|
||||
|
||||
return buffer.length === 25 &&
|
||||
return (
|
||||
buffer.length === 25 &&
|
||||
buffer[0] === OPS.OP_DUP &&
|
||||
buffer[1] === OPS.OP_HASH160 &&
|
||||
buffer[2] === 0x14 &&
|
||||
buffer[23] === OPS.OP_EQUALVERIFY &&
|
||||
buffer[24] === OPS.OP_CHECKSIG
|
||||
);
|
||||
}
|
||||
check.toJSON = function () { return 'pubKeyHash output' }
|
||||
check.toJSON = function() {
|
||||
return 'pubKeyHash output';
|
||||
};
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
import * as input from './input'
|
||||
import * as output from './output'
|
||||
import * as input from './input';
|
||||
import * as output from './output';
|
||||
|
||||
export {
|
||||
input,
|
||||
output,
|
||||
}
|
||||
export { input, output };
|
||||
|
|
|
@ -1,46 +1,61 @@
|
|||
// <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'
|
||||
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';
|
||||
|
||||
export function check(
|
||||
script: Buffer | Array<number | Buffer>,
|
||||
allowIncomplete?: boolean,
|
||||
): boolean {
|
||||
const chunks = bscript.decompile(script)!;
|
||||
if (chunks.length < 1) return false;
|
||||
|
||||
const lastChunk = chunks[chunks.length - 1];
|
||||
if (!Buffer.isBuffer(lastChunk)) return false;
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>, allowIncomplete?: boolean): boolean {
|
||||
const chunks = bscript.decompile(script)!
|
||||
if (chunks.length < 1) return false
|
||||
|
||||
const lastChunk = chunks[chunks.length - 1]
|
||||
if (!Buffer.isBuffer(lastChunk)) return false
|
||||
|
||||
const scriptSigChunks = bscript.decompile(bscript.compile(chunks.slice(0, -1)))!
|
||||
const redeemScriptChunks = bscript.decompile(lastChunk)
|
||||
const scriptSigChunks = bscript.decompile(
|
||||
bscript.compile(chunks.slice(0, -1)),
|
||||
)!;
|
||||
const redeemScriptChunks = bscript.decompile(lastChunk);
|
||||
|
||||
// is redeemScript a valid script?
|
||||
if (!redeemScriptChunks) return false
|
||||
if (!redeemScriptChunks) return false;
|
||||
|
||||
// is redeemScriptSig push only?
|
||||
if (!bscript.isPushOnly(scriptSigChunks)) return false
|
||||
if (!bscript.isPushOnly(scriptSigChunks)) return false;
|
||||
|
||||
// is witness?
|
||||
if (chunks.length === 1) {
|
||||
return p2wsho.check(redeemScriptChunks) ||
|
||||
p2wpkho.check(redeemScriptChunks)
|
||||
return (
|
||||
p2wsho.check(redeemScriptChunks) || p2wpkho.check(redeemScriptChunks)
|
||||
);
|
||||
}
|
||||
|
||||
// match types
|
||||
if (p2pkh.input.check(scriptSigChunks) &&
|
||||
p2pkh.output.check(redeemScriptChunks)) return true
|
||||
if (
|
||||
p2pkh.input.check(scriptSigChunks) &&
|
||||
p2pkh.output.check(redeemScriptChunks)
|
||||
)
|
||||
return true;
|
||||
|
||||
if (p2ms.input.check(scriptSigChunks, allowIncomplete) &&
|
||||
p2ms.output.check(redeemScriptChunks)) return true
|
||||
if (
|
||||
p2ms.input.check(scriptSigChunks, allowIncomplete) &&
|
||||
p2ms.output.check(redeemScriptChunks)
|
||||
)
|
||||
return true;
|
||||
|
||||
if (p2pk.input.check(scriptSigChunks) &&
|
||||
p2pk.output.check(redeemScriptChunks)) return true
|
||||
if (
|
||||
p2pk.input.check(scriptSigChunks) &&
|
||||
p2pk.output.check(redeemScriptChunks)
|
||||
)
|
||||
return true;
|
||||
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
check.toJSON = function () { return 'scriptHash input' }
|
||||
check.toJSON = function() {
|
||||
return 'scriptHash input';
|
||||
};
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
// OP_HASH160 {scriptHash} OP_EQUAL
|
||||
|
||||
import * as bscript from '../../script'
|
||||
import { OPS } from '../../script'
|
||||
import * as bscript from '../../script';
|
||||
import { OPS } from '../../script';
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script)
|
||||
export function check(script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script);
|
||||
|
||||
return buffer.length === 23 &&
|
||||
return (
|
||||
buffer.length === 23 &&
|
||||
buffer[0] === OPS.OP_HASH160 &&
|
||||
buffer[1] === 0x14 &&
|
||||
buffer[22] === OPS.OP_EQUAL
|
||||
);
|
||||
}
|
||||
check.toJSON = function () { return 'scriptHash output' }
|
||||
check.toJSON = function() {
|
||||
return 'scriptHash output';
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import * as output from './output'
|
||||
import * as output from './output';
|
||||
|
||||
export {
|
||||
output,
|
||||
}
|
||||
export { output };
|
||||
|
|
|
@ -1,36 +1,40 @@
|
|||
// OP_RETURN {aa21a9ed} {commitment}
|
||||
|
||||
import * as bscript from '../../script'
|
||||
import * as types from '../../types'
|
||||
import * as bscript from '../../script';
|
||||
import * as types from '../../types';
|
||||
|
||||
const typeforce = require('typeforce')
|
||||
import { OPS } from '../../script'
|
||||
const typeforce = require('typeforce');
|
||||
import { OPS } from '../../script';
|
||||
|
||||
const HEADER: Buffer = Buffer.from('aa21a9ed', 'hex')
|
||||
const HEADER: Buffer = Buffer.from('aa21a9ed', 'hex');
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script)
|
||||
export function check(script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script);
|
||||
|
||||
return buffer.length > 37 &&
|
||||
return (
|
||||
buffer.length > 37 &&
|
||||
buffer[0] === OPS.OP_RETURN &&
|
||||
buffer[1] === 0x24 &&
|
||||
buffer.slice(2, 6).equals(HEADER)
|
||||
);
|
||||
}
|
||||
|
||||
check.toJSON = function () { return 'Witness commitment output' }
|
||||
check.toJSON = function() {
|
||||
return 'Witness commitment output';
|
||||
};
|
||||
|
||||
export function encode (commitment: Buffer): Buffer {
|
||||
typeforce(types.Hash256bit, commitment)
|
||||
export function encode(commitment: Buffer): Buffer {
|
||||
typeforce(types.Hash256bit, commitment);
|
||||
|
||||
const buffer = Buffer.allocUnsafe(36)
|
||||
HEADER.copy(buffer, 0)
|
||||
commitment.copy(buffer, 4)
|
||||
const buffer = Buffer.allocUnsafe(36);
|
||||
HEADER.copy(buffer, 0);
|
||||
commitment.copy(buffer, 4);
|
||||
|
||||
return bscript.compile([OPS.OP_RETURN, buffer])
|
||||
return bscript.compile([OPS.OP_RETURN, buffer]);
|
||||
}
|
||||
|
||||
export function decode (buffer: Buffer): Buffer {
|
||||
typeforce(check, buffer)
|
||||
export function decode(buffer: Buffer): Buffer {
|
||||
typeforce(check, buffer);
|
||||
|
||||
return (<Buffer>bscript.decompile(buffer)![1]).slice(4, 36)
|
||||
return (<Buffer>bscript.decompile(buffer)![1]).slice(4, 36);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
import * as input from './input'
|
||||
import * as output from './output'
|
||||
import * as input from './input';
|
||||
import * as output from './output';
|
||||
|
||||
export {
|
||||
input,
|
||||
output,
|
||||
}
|
||||
export { input, output };
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
// {signature} {pubKey}
|
||||
|
||||
import * as bscript from '../../script'
|
||||
import * as bscript from '../../script';
|
||||
|
||||
function isCompressedCanonicalPubKey (pubKey: Buffer): boolean {
|
||||
return bscript.isCanonicalPubKey(pubKey) && pubKey.length === 33
|
||||
function isCompressedCanonicalPubKey(pubKey: Buffer): boolean {
|
||||
return bscript.isCanonicalPubKey(pubKey) && pubKey.length === 33;
|
||||
}
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script)
|
||||
export function check(script: Buffer | Array<number | Buffer>): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script);
|
||||
|
||||
return chunks.length === 2 &&
|
||||
return (
|
||||
chunks.length === 2 &&
|
||||
bscript.isCanonicalScriptSignature(<Buffer>chunks[0]) &&
|
||||
isCompressedCanonicalPubKey(<Buffer>chunks[1])
|
||||
);
|
||||
}
|
||||
check.toJSON = function () { return 'witnessPubKeyHash input' }
|
||||
check.toJSON = function() {
|
||||
return 'witnessPubKeyHash input';
|
||||
};
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// OP_0 {pubKeyHash}
|
||||
|
||||
import * as bscript from '../../script'
|
||||
import { OPS } from '../../script'
|
||||
import * as bscript from '../../script';
|
||||
import { OPS } from '../../script';
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script)
|
||||
export function check(script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script);
|
||||
|
||||
return buffer.length === 22 &&
|
||||
buffer[0] === OPS.OP_0 &&
|
||||
buffer[1] === 0x14
|
||||
return buffer.length === 22 && buffer[0] === OPS.OP_0 && buffer[1] === 0x14;
|
||||
}
|
||||
check.toJSON = function () { return 'Witness pubKeyHash output' }
|
||||
check.toJSON = function() {
|
||||
return 'Witness pubKeyHash output';
|
||||
};
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
import * as input from './input'
|
||||
import * as output from './output'
|
||||
import * as input from './input';
|
||||
import * as output from './output';
|
||||
|
||||
export {
|
||||
input,
|
||||
output,
|
||||
}
|
||||
export { input, output };
|
||||
|
|
|
@ -1,36 +1,50 @@
|
|||
// <scriptSig> {serialized scriptPubKey script}
|
||||
|
||||
import * as bscript from '../../script'
|
||||
const typeforce = require('typeforce')
|
||||
import * as bscript from '../../script';
|
||||
const typeforce = require('typeforce');
|
||||
|
||||
import * as p2ms from '../multisig'
|
||||
import * as p2pk from '../pubkey'
|
||||
import * as p2pkh from '../pubkeyhash'
|
||||
import * as p2ms from '../multisig';
|
||||
import * as p2pk from '../pubkey';
|
||||
import * as p2pkh from '../pubkeyhash';
|
||||
|
||||
export function check (chunks: Array<Buffer>, allowIncomplete?: boolean): boolean {
|
||||
typeforce(typeforce.Array, chunks)
|
||||
if (chunks.length < 1) return false
|
||||
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]
|
||||
if (!Buffer.isBuffer(witnessScript)) return false
|
||||
const witnessScript = chunks[chunks.length - 1];
|
||||
if (!Buffer.isBuffer(witnessScript)) return false;
|
||||
|
||||
const witnessScriptChunks = bscript.decompile(witnessScript)
|
||||
const witnessScriptChunks = bscript.decompile(witnessScript);
|
||||
|
||||
// is witnessScript a valid script?
|
||||
if (!witnessScriptChunks || witnessScriptChunks.length === 0) return false
|
||||
if (!witnessScriptChunks || witnessScriptChunks.length === 0) return false;
|
||||
|
||||
const witnessRawScriptSig = bscript.compile(chunks.slice(0, -1))
|
||||
const witnessRawScriptSig = bscript.compile(chunks.slice(0, -1));
|
||||
|
||||
// match types
|
||||
if (p2pkh.input.check(witnessRawScriptSig) &&
|
||||
p2pkh.output.check(witnessScriptChunks)) return true
|
||||
if (
|
||||
p2pkh.input.check(witnessRawScriptSig) &&
|
||||
p2pkh.output.check(witnessScriptChunks)
|
||||
)
|
||||
return true;
|
||||
|
||||
if (p2ms.input.check(witnessRawScriptSig, allowIncomplete) &&
|
||||
p2ms.output.check(witnessScriptChunks)) return true
|
||||
if (
|
||||
p2ms.input.check(witnessRawScriptSig, allowIncomplete) &&
|
||||
p2ms.output.check(witnessScriptChunks)
|
||||
)
|
||||
return true;
|
||||
|
||||
if (p2pk.input.check(witnessRawScriptSig) &&
|
||||
p2pk.output.check(witnessScriptChunks)) return true
|
||||
if (
|
||||
p2pk.input.check(witnessRawScriptSig) &&
|
||||
p2pk.output.check(witnessScriptChunks)
|
||||
)
|
||||
return true;
|
||||
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
check.toJSON = function () { return 'witnessScriptHash input' }
|
||||
check.toJSON = function() {
|
||||
return 'witnessScriptHash input';
|
||||
};
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// OP_0 {scriptHash}
|
||||
|
||||
import * as bscript from '../../script'
|
||||
import { OPS } from '../../script'
|
||||
import * as bscript from '../../script';
|
||||
import { OPS } from '../../script';
|
||||
|
||||
export function check (script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script)
|
||||
export function check(script: Buffer | Array<number | Buffer>): boolean {
|
||||
const buffer = bscript.compile(script);
|
||||
|
||||
return buffer.length === 34 &&
|
||||
buffer[0] === OPS.OP_0 &&
|
||||
buffer[1] === 0x20
|
||||
return buffer.length === 34 && buffer[0] === OPS.OP_0 && buffer[1] === 0x20;
|
||||
}
|
||||
check.toJSON = function () { return 'Witness scriptHash output' }
|
||||
check.toJSON = function() {
|
||||
return 'Witness scriptHash output';
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue