Fix lint for templates
This commit is contained in:
parent
512b03e284
commit
08c4d6ac7d
35 changed files with 79 additions and 68 deletions
|
@ -1,19 +1,20 @@
|
|||
// OP_0 [signatures ...]
|
||||
|
||||
import { Stack } from '../../payments';
|
||||
import * as bscript from '../../script';
|
||||
import { OPS } from '../../script';
|
||||
|
||||
function partialSignature(value: number | Buffer): boolean {
|
||||
return (
|
||||
value === OPS.OP_0 || bscript.isCanonicalScriptSignature(<Buffer>value)
|
||||
value === OPS.OP_0 || bscript.isCanonicalScriptSignature(value as Buffer)
|
||||
);
|
||||
}
|
||||
|
||||
export function check(
|
||||
script: Buffer | Array<number | Buffer>,
|
||||
script: Buffer | Stack,
|
||||
allowIncomplete?: boolean,
|
||||
): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script);
|
||||
const chunks = bscript.decompile(script) as Stack;
|
||||
if (chunks.length < 2) return false;
|
||||
if (chunks[0] !== OPS.OP_0) return false;
|
||||
|
||||
|
@ -21,10 +22,10 @@ export function check(
|
|||
return chunks.slice(1).every(partialSignature);
|
||||
}
|
||||
|
||||
return (<Array<Buffer>>chunks.slice(1)).every(
|
||||
return (chunks.slice(1) as Buffer[]).every(
|
||||
bscript.isCanonicalScriptSignature,
|
||||
);
|
||||
}
|
||||
check.toJSON = function() {
|
||||
check.toJSON = () => {
|
||||
return 'multisig input';
|
||||
};
|
||||
|
|
|
@ -1,22 +1,23 @@
|
|||
// m [pubKeys ...] n OP_CHECKMULTISIG
|
||||
|
||||
import { Stack } from '../../payments';
|
||||
import * as bscript from '../../script';
|
||||
import * as types from '../../types';
|
||||
import { OPS } from '../../script';
|
||||
import * as types from '../../types';
|
||||
const OP_INT_BASE = OPS.OP_RESERVED; // OP_1 - 1
|
||||
|
||||
export function check(
|
||||
script: Buffer | Array<number | Buffer>,
|
||||
script: Buffer | Stack,
|
||||
allowIncomplete?: boolean,
|
||||
): boolean {
|
||||
const chunks = <Array<number | Buffer>>bscript.decompile(script);
|
||||
const chunks = bscript.decompile(script) as Stack;
|
||||
|
||||
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;
|
||||
const m = (chunks[0] as number) - OP_INT_BASE;
|
||||
const n = (chunks[chunks.length - 2] as number) - OP_INT_BASE;
|
||||
|
||||
if (m <= 0) return false;
|
||||
if (n > 16) return false;
|
||||
|
@ -24,9 +25,9 @@ export function check(
|
|||
if (n !== chunks.length - 3) return false;
|
||||
if (allowIncomplete) return true;
|
||||
|
||||
const keys = <Array<Buffer>>chunks.slice(1, -2);
|
||||
const keys = chunks.slice(1, -2) as Buffer[];
|
||||
return keys.every(bscript.isCanonicalPubKey);
|
||||
}
|
||||
check.toJSON = function() {
|
||||
check.toJSON = () => {
|
||||
return 'multi-sig output';
|
||||
};
|
||||
|
|
|
@ -7,7 +7,7 @@ export function check(script: Buffer | Array<number | Buffer>): boolean {
|
|||
|
||||
return buffer.length > 1 && buffer[0] === OPS.OP_RETURN;
|
||||
}
|
||||
check.toJSON = function() {
|
||||
check.toJSON = () => {
|
||||
return 'null data output';
|
||||
};
|
||||
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
// {signature}
|
||||
|
||||
import { Stack } from '../../payments';
|
||||
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 | Stack): boolean {
|
||||
const chunks = bscript.decompile(script) as Stack;
|
||||
|
||||
return (
|
||||
chunks.length === 1 && bscript.isCanonicalScriptSignature(<Buffer>chunks[0])
|
||||
chunks.length === 1 &&
|
||||
bscript.isCanonicalScriptSignature(chunks[0] as Buffer)
|
||||
);
|
||||
}
|
||||
check.toJSON = function() {
|
||||
check.toJSON = () => {
|
||||
return 'pubKey input';
|
||||
};
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
// {pubKey} OP_CHECKSIG
|
||||
|
||||
import { Stack } from '../../payments';
|
||||
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 | Stack): boolean {
|
||||
const chunks = bscript.decompile(script) as Stack;
|
||||
|
||||
return (
|
||||
chunks.length === 2 &&
|
||||
bscript.isCanonicalPubKey(<Buffer>chunks[0]) &&
|
||||
bscript.isCanonicalPubKey(chunks[0] as Buffer) &&
|
||||
chunks[1] === OPS.OP_CHECKSIG
|
||||
);
|
||||
}
|
||||
check.toJSON = function() {
|
||||
check.toJSON = () => {
|
||||
return 'pubKey output';
|
||||
};
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
// {signature} {pubKey}
|
||||
|
||||
import { Stack } from '../../payments';
|
||||
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 | Stack): boolean {
|
||||
const chunks = bscript.decompile(script) as Stack;
|
||||
|
||||
return (
|
||||
chunks.length === 2 &&
|
||||
bscript.isCanonicalScriptSignature(<Buffer>chunks[0]) &&
|
||||
bscript.isCanonicalPubKey(<Buffer>chunks[1])
|
||||
bscript.isCanonicalScriptSignature(chunks[0] as Buffer) &&
|
||||
bscript.isCanonicalPubKey(chunks[1] as Buffer)
|
||||
);
|
||||
}
|
||||
check.toJSON = function() {
|
||||
check.toJSON = () => {
|
||||
return 'pubKeyHash input';
|
||||
};
|
||||
|
|
|
@ -15,6 +15,6 @@ export function check(script: Buffer | Array<number | Buffer>): boolean {
|
|||
buffer[24] === OPS.OP_CHECKSIG
|
||||
);
|
||||
}
|
||||
check.toJSON = function() {
|
||||
check.toJSON = () => {
|
||||
return 'pubKeyHash output';
|
||||
};
|
||||
|
|
|
@ -56,6 +56,6 @@ export function check(
|
|||
|
||||
return false;
|
||||
}
|
||||
check.toJSON = function() {
|
||||
check.toJSON = () => {
|
||||
return 'scriptHash input';
|
||||
};
|
||||
|
|
|
@ -13,6 +13,6 @@ export function check(script: Buffer | Array<number | Buffer>): boolean {
|
|||
buffer[22] === OPS.OP_EQUAL
|
||||
);
|
||||
}
|
||||
check.toJSON = function() {
|
||||
check.toJSON = () => {
|
||||
return 'scriptHash output';
|
||||
};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// OP_RETURN {aa21a9ed} {commitment}
|
||||
|
||||
import * as bscript from '../../script';
|
||||
import { OPS } from '../../script';
|
||||
import * as types from '../../types';
|
||||
|
||||
const typeforce = require('typeforce');
|
||||
import { OPS } from '../../script';
|
||||
|
||||
const HEADER: Buffer = Buffer.from('aa21a9ed', 'hex');
|
||||
|
||||
|
@ -19,7 +19,7 @@ export function check(script: Buffer | Array<number | Buffer>): boolean {
|
|||
);
|
||||
}
|
||||
|
||||
check.toJSON = function() {
|
||||
check.toJSON = () => {
|
||||
return 'Witness commitment output';
|
||||
};
|
||||
|
||||
|
@ -36,5 +36,5 @@ export function encode(commitment: Buffer): Buffer {
|
|||
export function decode(buffer: Buffer): Buffer {
|
||||
typeforce(check, buffer);
|
||||
|
||||
return (<Buffer>bscript.decompile(buffer)![1]).slice(4, 36);
|
||||
return (bscript.decompile(buffer)![1] as Buffer).slice(4, 36);
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
// {signature} {pubKey}
|
||||
|
||||
import { Stack } from '../../payments';
|
||||
import * as bscript from '../../script';
|
||||
|
||||
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 | Stack): boolean {
|
||||
const chunks = bscript.decompile(script) as Stack;
|
||||
|
||||
return (
|
||||
chunks.length === 2 &&
|
||||
bscript.isCanonicalScriptSignature(<Buffer>chunks[0]) &&
|
||||
isCompressedCanonicalPubKey(<Buffer>chunks[1])
|
||||
bscript.isCanonicalScriptSignature(chunks[0] as Buffer) &&
|
||||
isCompressedCanonicalPubKey(chunks[1] as Buffer)
|
||||
);
|
||||
}
|
||||
check.toJSON = function() {
|
||||
check.toJSON = () => {
|
||||
return 'witnessPubKeyHash input';
|
||||
};
|
||||
|
|
|
@ -8,6 +8,6 @@ export function check(script: Buffer | Array<number | Buffer>): boolean {
|
|||
|
||||
return buffer.length === 22 && buffer[0] === OPS.OP_0 && buffer[1] === 0x14;
|
||||
}
|
||||
check.toJSON = function() {
|
||||
check.toJSON = () => {
|
||||
return 'Witness pubKeyHash output';
|
||||
};
|
||||
|
|
|
@ -7,10 +7,7 @@ import * as p2ms from '../multisig';
|
|||
import * as p2pk from '../pubkey';
|
||||
import * as p2pkh from '../pubkeyhash';
|
||||
|
||||
export function check(
|
||||
chunks: Array<Buffer>,
|
||||
allowIncomplete?: boolean,
|
||||
): boolean {
|
||||
export function check(chunks: Buffer[], allowIncomplete?: boolean): boolean {
|
||||
typeforce(typeforce.Array, chunks);
|
||||
if (chunks.length < 1) return false;
|
||||
|
||||
|
@ -45,6 +42,6 @@ export function check(
|
|||
|
||||
return false;
|
||||
}
|
||||
check.toJSON = function() {
|
||||
check.toJSON = () => {
|
||||
return 'witnessScriptHash input';
|
||||
};
|
||||
|
|
|
@ -8,6 +8,6 @@ export function check(script: Buffer | Array<number | Buffer>): boolean {
|
|||
|
||||
return buffer.length === 34 && buffer[0] === OPS.OP_0 && buffer[1] === 0x20;
|
||||
}
|
||||
check.toJSON = function() {
|
||||
check.toJSON = () => {
|
||||
return 'Witness scriptHash output';
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue