Fix classify.ts lint
This commit is contained in:
parent
51d078cbce
commit
cb5ab7684e
3 changed files with 14 additions and 17 deletions
|
@ -6,9 +6,9 @@ const nullData = require("./templates/nulldata");
|
||||||
const pubKey = require("./templates/pubkey");
|
const pubKey = require("./templates/pubkey");
|
||||||
const pubKeyHash = require("./templates/pubkeyhash");
|
const pubKeyHash = require("./templates/pubkeyhash");
|
||||||
const scriptHash = require("./templates/scripthash");
|
const scriptHash = require("./templates/scripthash");
|
||||||
|
const witnessCommitment = require("./templates/witnesscommitment");
|
||||||
const witnessPubKeyHash = require("./templates/witnesspubkeyhash");
|
const witnessPubKeyHash = require("./templates/witnesspubkeyhash");
|
||||||
const witnessScriptHash = require("./templates/witnessscripthash");
|
const witnessScriptHash = require("./templates/witnessscripthash");
|
||||||
const witnessCommitment = require("./templates/witnesscommitment");
|
|
||||||
const types = {
|
const types = {
|
||||||
P2MS: 'multisig',
|
P2MS: 'multisig',
|
||||||
NONSTANDARD: 'nonstandard',
|
NONSTANDARD: 'nonstandard',
|
||||||
|
|
|
@ -4,20 +4,20 @@ import * as nullData from './templates/nulldata';
|
||||||
import * as pubKey from './templates/pubkey';
|
import * as pubKey from './templates/pubkey';
|
||||||
import * as pubKeyHash from './templates/pubkeyhash';
|
import * as pubKeyHash from './templates/pubkeyhash';
|
||||||
import * as scriptHash from './templates/scripthash';
|
import * as scriptHash from './templates/scripthash';
|
||||||
|
import * as witnessCommitment from './templates/witnesscommitment';
|
||||||
import * as witnessPubKeyHash from './templates/witnesspubkeyhash';
|
import * as witnessPubKeyHash from './templates/witnesspubkeyhash';
|
||||||
import * as witnessScriptHash from './templates/witnessscripthash';
|
import * as witnessScriptHash from './templates/witnessscripthash';
|
||||||
import * as witnessCommitment from './templates/witnesscommitment';
|
|
||||||
|
|
||||||
const types = {
|
const types = {
|
||||||
P2MS: <string>'multisig',
|
P2MS: 'multisig' as string,
|
||||||
NONSTANDARD: <string>'nonstandard',
|
NONSTANDARD: 'nonstandard' as string,
|
||||||
NULLDATA: <string>'nulldata',
|
NULLDATA: 'nulldata' as string,
|
||||||
P2PK: <string>'pubkey',
|
P2PK: 'pubkey' as string,
|
||||||
P2PKH: <string>'pubkeyhash',
|
P2PKH: 'pubkeyhash' as string,
|
||||||
P2SH: <string>'scripthash',
|
P2SH: 'scripthash' as string,
|
||||||
P2WPKH: <string>'witnesspubkeyhash',
|
P2WPKH: 'witnesspubkeyhash' as string,
|
||||||
P2WSH: <string>'witnessscripthash',
|
P2WSH: 'witnessscripthash' as string,
|
||||||
WITNESS_COMMITMENT: <string>'witnesscommitment',
|
WITNESS_COMMITMENT: 'witnesscommitment' as string,
|
||||||
};
|
};
|
||||||
|
|
||||||
function classifyOutput(script: Buffer): string {
|
function classifyOutput(script: Buffer): string {
|
||||||
|
@ -51,16 +51,13 @@ function classifyInput(script: Buffer, allowIncomplete: boolean): string {
|
||||||
return types.NONSTANDARD;
|
return types.NONSTANDARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
function classifyWitness(
|
function classifyWitness(script: Buffer[], allowIncomplete: boolean): string {
|
||||||
script: Array<Buffer>,
|
|
||||||
allowIncomplete: boolean,
|
|
||||||
): string {
|
|
||||||
// XXX: optimization, below functions .decompile before use
|
// XXX: optimization, below functions .decompile before use
|
||||||
const chunks = decompile(script);
|
const chunks = decompile(script);
|
||||||
if (!chunks) throw new TypeError('Invalid script');
|
if (!chunks) throw new TypeError('Invalid script');
|
||||||
|
|
||||||
if (witnessPubKeyHash.input.check(chunks)) return types.P2WPKH;
|
if (witnessPubKeyHash.input.check(chunks)) return types.P2WPKH;
|
||||||
if (witnessScriptHash.input.check(<Array<Buffer>>chunks, allowIncomplete))
|
if (witnessScriptHash.input.check(chunks as Buffer[], allowIncomplete))
|
||||||
return types.P2WSH;
|
return types.P2WSH;
|
||||||
|
|
||||||
return types.NONSTANDARD;
|
return types.NONSTANDARD;
|
||||||
|
|
2
types/classify.d.ts
vendored
2
types/classify.d.ts
vendored
|
@ -12,5 +12,5 @@ declare const types: {
|
||||||
};
|
};
|
||||||
declare function classifyOutput(script: Buffer): string;
|
declare function classifyOutput(script: Buffer): string;
|
||||||
declare function classifyInput(script: Buffer, allowIncomplete: boolean): string;
|
declare function classifyInput(script: Buffer, allowIncomplete: boolean): string;
|
||||||
declare function classifyWitness(script: Array<Buffer>, allowIncomplete: boolean): string;
|
declare function classifyWitness(script: Buffer[], allowIncomplete: boolean): string;
|
||||||
export { classifyInput as input, classifyOutput as output, classifyWitness as witness, types, };
|
export { classifyInput as input, classifyOutput as output, classifyWitness as witness, types, };
|
||||||
|
|
Loading…
Add table
Reference in a new issue