Add JS for prettier glob fix

This commit is contained in:
junderw 2019-03-07 11:20:28 +09:00
parent 03f86a6a54
commit ee60862df6
No known key found for this signature in database
GPG key ID: B256185D3A971908
20 changed files with 63 additions and 43 deletions

View file

@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const bscript = require("../../script"); const bscript = require("../../script");
const script_1 = require("../../script"); const script_1 = require("../../script");
function partialSignature(value) { function partialSignature(value) {
return value === script_1.OPS.OP_0 || bscript.isCanonicalScriptSignature(value); return (value === script_1.OPS.OP_0 || bscript.isCanonicalScriptSignature(value));
} }
function check(script, allowIncomplete) { function check(script, allowIncomplete) {
const chunks = bscript.decompile(script); const chunks = bscript.decompile(script);
@ -18,4 +18,6 @@ function check(script, allowIncomplete) {
return chunks.slice(1).every(bscript.isCanonicalScriptSignature); return chunks.slice(1).every(bscript.isCanonicalScriptSignature);
} }
exports.check = check; exports.check = check;
check.toJSON = function () { return 'multisig input'; }; check.toJSON = function () {
return 'multisig input';
};

View file

@ -31,4 +31,6 @@ function check(script, allowIncomplete) {
return keys.every(bscript.isCanonicalPubKey); return keys.every(bscript.isCanonicalPubKey);
} }
exports.check = check; exports.check = check;
check.toJSON = function () { return 'multi-sig output'; }; check.toJSON = function () {
return 'multi-sig output';
};

View file

@ -4,8 +4,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
const bscript = require("../../script"); const bscript = require("../../script");
function check(script) { function check(script) {
const chunks = bscript.decompile(script); const chunks = bscript.decompile(script);
return chunks.length === 1 && return (chunks.length === 1 && bscript.isCanonicalScriptSignature(chunks[0]));
bscript.isCanonicalScriptSignature(chunks[0]);
} }
exports.check = check; exports.check = check;
check.toJSON = function () { return 'pubKey input'; }; check.toJSON = function () {
return 'pubKey input';
};

View file

@ -5,9 +5,11 @@ const bscript = require("../../script");
const script_1 = require("../../script"); const script_1 = require("../../script");
function check(script) { function check(script) {
const chunks = bscript.decompile(script); const chunks = bscript.decompile(script);
return chunks.length === 2 && return (chunks.length === 2 &&
bscript.isCanonicalPubKey(chunks[0]) && bscript.isCanonicalPubKey(chunks[0]) &&
chunks[1] === script_1.OPS.OP_CHECKSIG; chunks[1] === script_1.OPS.OP_CHECKSIG);
} }
exports.check = check; exports.check = check;
check.toJSON = function () { return 'pubKey output'; }; check.toJSON = function () {
return 'pubKey output';
};

View file

@ -4,9 +4,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
const bscript = require("../../script"); const bscript = require("../../script");
function check(script) { function check(script) {
const chunks = bscript.decompile(script); const chunks = bscript.decompile(script);
return chunks.length === 2 && return (chunks.length === 2 &&
bscript.isCanonicalScriptSignature(chunks[0]) && bscript.isCanonicalScriptSignature(chunks[0]) &&
bscript.isCanonicalPubKey(chunks[1]); bscript.isCanonicalPubKey(chunks[1]));
} }
exports.check = check; exports.check = check;
check.toJSON = function () { return 'pubKeyHash input'; }; check.toJSON = function () {
return 'pubKeyHash input';
};

View file

@ -5,12 +5,14 @@ const bscript = require("../../script");
const script_1 = require("../../script"); const script_1 = require("../../script");
function check(script) { function check(script) {
const buffer = bscript.compile(script); const buffer = bscript.compile(script);
return buffer.length === 25 && return (buffer.length === 25 &&
buffer[0] === script_1.OPS.OP_DUP && buffer[0] === script_1.OPS.OP_DUP &&
buffer[1] === script_1.OPS.OP_HASH160 && buffer[1] === script_1.OPS.OP_HASH160 &&
buffer[2] === 0x14 && buffer[2] === 0x14 &&
buffer[23] === script_1.OPS.OP_EQUALVERIFY && buffer[23] === script_1.OPS.OP_EQUALVERIFY &&
buffer[24] === script_1.OPS.OP_CHECKSIG; buffer[24] === script_1.OPS.OP_CHECKSIG);
} }
exports.check = check; exports.check = check;
check.toJSON = function () { return 'pubKeyHash output'; }; check.toJSON = function () {
return 'pubKeyHash output';
};

View file

@ -24,8 +24,7 @@ function check(script, allowIncomplete) {
return false; return false;
// is witness? // is witness?
if (chunks.length === 1) { if (chunks.length === 1) {
return p2wsho.check(redeemScriptChunks) || return (p2wsho.check(redeemScriptChunks) || p2wpkho.check(redeemScriptChunks));
p2wpkho.check(redeemScriptChunks);
} }
// match types // match types
if (p2pkh.input.check(scriptSigChunks) && if (p2pkh.input.check(scriptSigChunks) &&
@ -40,4 +39,6 @@ function check(script, allowIncomplete) {
return false; return false;
} }
exports.check = check; exports.check = check;
check.toJSON = function () { return 'scriptHash input'; }; check.toJSON = function () {
return 'scriptHash input';
};

View file

@ -5,10 +5,12 @@ const bscript = require("../../script");
const script_1 = require("../../script"); const script_1 = require("../../script");
function check(script) { function check(script) {
const buffer = bscript.compile(script); const buffer = bscript.compile(script);
return buffer.length === 23 && return (buffer.length === 23 &&
buffer[0] === script_1.OPS.OP_HASH160 && buffer[0] === script_1.OPS.OP_HASH160 &&
buffer[1] === 0x14 && buffer[1] === 0x14 &&
buffer[22] === script_1.OPS.OP_EQUAL; buffer[22] === script_1.OPS.OP_EQUAL);
} }
exports.check = check; exports.check = check;
check.toJSON = function () { return 'scriptHash output'; }; check.toJSON = function () {
return 'scriptHash output';
};

View file

@ -8,13 +8,15 @@ const script_1 = require("../../script");
const HEADER = Buffer.from('aa21a9ed', 'hex'); const HEADER = Buffer.from('aa21a9ed', 'hex');
function check(script) { function check(script) {
const buffer = bscript.compile(script); const buffer = bscript.compile(script);
return buffer.length > 37 && return (buffer.length > 37 &&
buffer[0] === script_1.OPS.OP_RETURN && buffer[0] === script_1.OPS.OP_RETURN &&
buffer[1] === 0x24 && buffer[1] === 0x24 &&
buffer.slice(2, 6).equals(HEADER); buffer.slice(2, 6).equals(HEADER));
} }
exports.check = check; exports.check = check;
check.toJSON = function () { return 'Witness commitment output'; }; check.toJSON = function () {
return 'Witness commitment output';
};
function encode(commitment) { function encode(commitment) {
typeforce(types.Hash256bit, commitment); typeforce(types.Hash256bit, commitment);
const buffer = Buffer.allocUnsafe(36); const buffer = Buffer.allocUnsafe(36);

View file

@ -7,9 +7,11 @@ function isCompressedCanonicalPubKey(pubKey) {
} }
function check(script) { function check(script) {
const chunks = bscript.decompile(script); const chunks = bscript.decompile(script);
return chunks.length === 2 && return (chunks.length === 2 &&
bscript.isCanonicalScriptSignature(chunks[0]) && bscript.isCanonicalScriptSignature(chunks[0]) &&
isCompressedCanonicalPubKey(chunks[1]); isCompressedCanonicalPubKey(chunks[1]));
} }
exports.check = check; exports.check = check;
check.toJSON = function () { return 'witnessPubKeyHash input'; }; check.toJSON = function () {
return 'witnessPubKeyHash input';
};

View file

@ -5,9 +5,9 @@ const bscript = require("../../script");
const script_1 = require("../../script"); const script_1 = require("../../script");
function check(script) { function check(script) {
const buffer = bscript.compile(script); const buffer = bscript.compile(script);
return buffer.length === 22 && return buffer.length === 22 && buffer[0] === script_1.OPS.OP_0 && buffer[1] === 0x14;
buffer[0] === script_1.OPS.OP_0 &&
buffer[1] === 0x14;
} }
exports.check = check; exports.check = check;
check.toJSON = function () { return 'Witness pubKeyHash output'; }; check.toJSON = function () {
return 'Witness pubKeyHash output';
};

View file

@ -31,4 +31,6 @@ function check(chunks, allowIncomplete) {
return false; return false;
} }
exports.check = check; exports.check = check;
check.toJSON = function () { return 'witnessScriptHash input'; }; check.toJSON = function () {
return 'witnessScriptHash input';
};

View file

@ -5,9 +5,9 @@ const bscript = require("../../script");
const script_1 = require("../../script"); const script_1 = require("../../script");
function check(script) { function check(script) {
const buffer = bscript.compile(script); const buffer = bscript.compile(script);
return buffer.length === 34 && return buffer.length === 34 && buffer[0] === script_1.OPS.OP_0 && buffer[1] === 0x20;
buffer[0] === script_1.OPS.OP_0 &&
buffer[1] === 0x20;
} }
exports.check = check; exports.check = check;
check.toJSON = function () { return 'Witness scriptHash output'; }; check.toJSON = function () {
return 'Witness scriptHash output';
};

View file

@ -1,3 +1,3 @@
import * as input from './input'; import * as input from './input';
import * as output from './output'; import * as output from './output';
export { input, output, }; export { input, output };

View file

@ -1,3 +1,3 @@
import * as input from './input'; import * as input from './input';
import * as output from './output'; import * as output from './output';
export { input, output, }; export { input, output };

View file

@ -1,3 +1,3 @@
import * as input from './input'; import * as input from './input';
import * as output from './output'; import * as output from './output';
export { input, output, }; export { input, output };

View file

@ -1,3 +1,3 @@
import * as input from './input'; import * as input from './input';
import * as output from './output'; import * as output from './output';
export { input, output, }; export { input, output };

View file

@ -1,2 +1,2 @@
import * as output from './output'; import * as output from './output';
export { output, }; export { output };

View file

@ -1,3 +1,3 @@
import * as input from './input'; import * as input from './input';
import * as output from './output'; import * as output from './output';
export { input, output, }; export { input, output };

View file

@ -1,3 +1,3 @@
import * as input from './input'; import * as input from './input';
import * as output from './output'; import * as output from './output';
export { input, output, }; export { input, output };