Fix lint for templates
This commit is contained in:
parent
512b03e284
commit
08c4d6ac7d
35 changed files with 79 additions and 68 deletions
|
@ -18,6 +18,6 @@ function check(script, allowIncomplete) {
|
|||
return chunks.slice(1).every(bscript.isCanonicalScriptSignature);
|
||||
}
|
||||
exports.check = check;
|
||||
check.toJSON = function () {
|
||||
check.toJSON = () => {
|
||||
return 'multisig input';
|
||||
};
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// m [pubKeys ...] n OP_CHECKMULTISIG
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const bscript = require("../../script");
|
||||
const types = require("../../types");
|
||||
const script_1 = require("../../script");
|
||||
const types = require("../../types");
|
||||
const OP_INT_BASE = script_1.OPS.OP_RESERVED; // OP_1 - 1
|
||||
function check(script, allowIncomplete) {
|
||||
const chunks = bscript.decompile(script);
|
||||
|
@ -31,6 +31,6 @@ function check(script, allowIncomplete) {
|
|||
return keys.every(bscript.isCanonicalPubKey);
|
||||
}
|
||||
exports.check = check;
|
||||
check.toJSON = function () {
|
||||
check.toJSON = () => {
|
||||
return 'multi-sig output';
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ function check(script) {
|
|||
return buffer.length > 1 && buffer[0] === OPS.OP_RETURN;
|
||||
}
|
||||
exports.check = check;
|
||||
check.toJSON = function () {
|
||||
check.toJSON = () => {
|
||||
return 'null data output';
|
||||
};
|
||||
const output = { check };
|
||||
|
|
|
@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
const bscript = require("../../script");
|
||||
function check(script) {
|
||||
const chunks = bscript.decompile(script);
|
||||
return (chunks.length === 1 && bscript.isCanonicalScriptSignature(chunks[0]));
|
||||
return (chunks.length === 1 &&
|
||||
bscript.isCanonicalScriptSignature(chunks[0]));
|
||||
}
|
||||
exports.check = check;
|
||||
check.toJSON = function () {
|
||||
check.toJSON = () => {
|
||||
return 'pubKey input';
|
||||
};
|
||||
|
|
|
@ -10,6 +10,6 @@ function check(script) {
|
|||
chunks[1] === script_1.OPS.OP_CHECKSIG);
|
||||
}
|
||||
exports.check = check;
|
||||
check.toJSON = function () {
|
||||
check.toJSON = () => {
|
||||
return 'pubKey output';
|
||||
};
|
||||
|
|
|
@ -9,6 +9,6 @@ function check(script) {
|
|||
bscript.isCanonicalPubKey(chunks[1]));
|
||||
}
|
||||
exports.check = check;
|
||||
check.toJSON = function () {
|
||||
check.toJSON = () => {
|
||||
return 'pubKeyHash input';
|
||||
};
|
||||
|
|
|
@ -13,6 +13,6 @@ function check(script) {
|
|||
buffer[24] === script_1.OPS.OP_CHECKSIG);
|
||||
}
|
||||
exports.check = check;
|
||||
check.toJSON = function () {
|
||||
check.toJSON = () => {
|
||||
return 'pubKeyHash output';
|
||||
};
|
||||
|
|
|
@ -39,6 +39,6 @@ function check(script, allowIncomplete) {
|
|||
return false;
|
||||
}
|
||||
exports.check = check;
|
||||
check.toJSON = function () {
|
||||
check.toJSON = () => {
|
||||
return 'scriptHash input';
|
||||
};
|
||||
|
|
|
@ -11,6 +11,6 @@ function check(script) {
|
|||
buffer[22] === script_1.OPS.OP_EQUAL);
|
||||
}
|
||||
exports.check = check;
|
||||
check.toJSON = function () {
|
||||
check.toJSON = () => {
|
||||
return 'scriptHash output';
|
||||
};
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
// OP_RETURN {aa21a9ed} {commitment}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const bscript = require("../../script");
|
||||
const script_1 = require("../../script");
|
||||
const types = require("../../types");
|
||||
const typeforce = require('typeforce');
|
||||
const script_1 = require("../../script");
|
||||
const HEADER = Buffer.from('aa21a9ed', 'hex');
|
||||
function check(script) {
|
||||
const buffer = bscript.compile(script);
|
||||
|
@ -14,7 +14,7 @@ function check(script) {
|
|||
buffer.slice(2, 6).equals(HEADER));
|
||||
}
|
||||
exports.check = check;
|
||||
check.toJSON = function () {
|
||||
check.toJSON = () => {
|
||||
return 'Witness commitment output';
|
||||
};
|
||||
function encode(commitment) {
|
||||
|
|
|
@ -12,6 +12,6 @@ function check(script) {
|
|||
isCompressedCanonicalPubKey(chunks[1]));
|
||||
}
|
||||
exports.check = check;
|
||||
check.toJSON = function () {
|
||||
check.toJSON = () => {
|
||||
return 'witnessPubKeyHash input';
|
||||
};
|
||||
|
|
|
@ -8,6 +8,6 @@ function check(script) {
|
|||
return buffer.length === 22 && buffer[0] === script_1.OPS.OP_0 && buffer[1] === 0x14;
|
||||
}
|
||||
exports.check = check;
|
||||
check.toJSON = function () {
|
||||
check.toJSON = () => {
|
||||
return 'Witness pubKeyHash output';
|
||||
};
|
||||
|
|
|
@ -31,6 +31,6 @@ function check(chunks, allowIncomplete) {
|
|||
return false;
|
||||
}
|
||||
exports.check = check;
|
||||
check.toJSON = function () {
|
||||
check.toJSON = () => {
|
||||
return 'witnessScriptHash input';
|
||||
};
|
||||
|
|
|
@ -8,6 +8,6 @@ function check(script) {
|
|||
return buffer.length === 34 && buffer[0] === script_1.OPS.OP_0 && buffer[1] === 0x20;
|
||||
}
|
||||
exports.check = check;
|
||||
check.toJSON = function () {
|
||||
check.toJSON = () => {
|
||||
return 'Witness scriptHash output';
|
||||
};
|
||||
|
|
|
@ -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';
|
||||
};
|
||||
|
|
3
types/templates/multisig/input.d.ts
vendored
3
types/templates/multisig/input.d.ts
vendored
|
@ -1,5 +1,6 @@
|
|||
/// <reference types="node" />
|
||||
export declare function check(script: Buffer | Array<number | Buffer>, allowIncomplete?: boolean): boolean;
|
||||
import { Stack } from '../../payments';
|
||||
export declare function check(script: Buffer | Stack, allowIncomplete?: boolean): boolean;
|
||||
export declare namespace check {
|
||||
var toJSON: () => string;
|
||||
}
|
||||
|
|
3
types/templates/multisig/output.d.ts
vendored
3
types/templates/multisig/output.d.ts
vendored
|
@ -1,5 +1,6 @@
|
|||
/// <reference types="node" />
|
||||
export declare function check(script: Buffer | Array<number | Buffer>, allowIncomplete?: boolean): boolean;
|
||||
import { Stack } from '../../payments';
|
||||
export declare function check(script: Buffer | Stack, allowIncomplete?: boolean): boolean;
|
||||
export declare namespace check {
|
||||
var toJSON: () => string;
|
||||
}
|
||||
|
|
3
types/templates/pubkey/input.d.ts
vendored
3
types/templates/pubkey/input.d.ts
vendored
|
@ -1,5 +1,6 @@
|
|||
/// <reference types="node" />
|
||||
export declare function check(script: Buffer | Array<number | Buffer>): boolean;
|
||||
import { Stack } from '../../payments';
|
||||
export declare function check(script: Buffer | Stack): boolean;
|
||||
export declare namespace check {
|
||||
var toJSON: () => string;
|
||||
}
|
||||
|
|
3
types/templates/pubkey/output.d.ts
vendored
3
types/templates/pubkey/output.d.ts
vendored
|
@ -1,5 +1,6 @@
|
|||
/// <reference types="node" />
|
||||
export declare function check(script: Buffer | Array<number | Buffer>): boolean;
|
||||
import { Stack } from '../../payments';
|
||||
export declare function check(script: Buffer | Stack): boolean;
|
||||
export declare namespace check {
|
||||
var toJSON: () => string;
|
||||
}
|
||||
|
|
3
types/templates/pubkeyhash/input.d.ts
vendored
3
types/templates/pubkeyhash/input.d.ts
vendored
|
@ -1,5 +1,6 @@
|
|||
/// <reference types="node" />
|
||||
export declare function check(script: Buffer | Array<number | Buffer>): boolean;
|
||||
import { Stack } from '../../payments';
|
||||
export declare function check(script: Buffer | Stack): boolean;
|
||||
export declare namespace check {
|
||||
var toJSON: () => string;
|
||||
}
|
||||
|
|
3
types/templates/witnesspubkeyhash/input.d.ts
vendored
3
types/templates/witnesspubkeyhash/input.d.ts
vendored
|
@ -1,5 +1,6 @@
|
|||
/// <reference types="node" />
|
||||
export declare function check(script: Buffer | Array<number | Buffer>): boolean;
|
||||
import { Stack } from '../../payments';
|
||||
export declare function check(script: Buffer | Stack): boolean;
|
||||
export declare namespace check {
|
||||
var toJSON: () => string;
|
||||
}
|
||||
|
|
2
types/templates/witnessscripthash/input.d.ts
vendored
2
types/templates/witnessscripthash/input.d.ts
vendored
|
@ -1,5 +1,5 @@
|
|||
/// <reference types="node" />
|
||||
export declare function check(chunks: Array<Buffer>, allowIncomplete?: boolean): boolean;
|
||||
export declare function check(chunks: Buffer[], allowIncomplete?: boolean): boolean;
|
||||
export declare namespace check {
|
||||
var toJSON: () => string;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue