style: fix glob pattern for prettier
This commit is contained in:
parent
e8857d3a84
commit
a567a97877
21 changed files with 240 additions and 190 deletions
ts_src/templates/witnessscripthash
|
@ -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';
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue