From 096f71ba1a4490fb882d39471d040c764b59c1f7 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 9 Apr 2016 03:46:40 -0700 Subject: [PATCH] cleanup. --- lib/bcoin/script.js | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index 3d60891e..24c43e86 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -1925,11 +1925,8 @@ Script.isScripthashInput = function isScripthashInput(code, isWitness) { }; Script.prototype.getCoinbaseData = function getCoinbaseData() { - var coinbase, flags; - - coinbase = { - script: this - }; + var coinbase = {}; + var flags; if (Buffer.isBuffer(this.code[0]) && this.code[0].length <= 6) coinbase.height = new bn(this.code[0], 'le').toNumber(); @@ -1956,36 +1953,20 @@ Script.prototype.getCoinbaseData = function getCoinbaseData() { return coinbase; }; -// Detect script array types. Note: these functions -// are not mutually exclusive. Only use for -// verification, not detection. - Script.isHash = function isHash(hash) { - if (!Buffer.isBuffer(hash)) - return false; - - return hash.length === 20; + return Buffer.isBuffer(hash) && hash.length === 20; }; Script.isKey = function isKey(key) { - if (!Buffer.isBuffer(key)) - return false; - - return key.length >= 33 && key.length <= 65; + return Buffer.isBuffer(key) && key.length >= 33 && key.length <= 65; }; Script.isSignature = function isSignature(sig) { - if (!Buffer.isBuffer(sig)) - return false; - - return sig.length >= 9 && sig.length <= 73; + return Buffer.isBuffer(sig) && sig.length >= 9 && sig.length <= 73; }; Script.isDummy = function isDummy(data) { - if (!Buffer.isBuffer(data)) - return false; - - return data.length === 0; + return Buffer.isBuffer(data) && data.length === 0; }; Script.isZero = function isZero(op) { @@ -1996,10 +1977,7 @@ Script.isZero = function isZero(op) { }; Script.isData = function isData(data) { - if (!Buffer.isBuffer(data)) - return false; - - return data.length <= constants.script.maxOpReturn; + return Buffer.isBuffer(data) && data.length <= constants.script.maxOpReturn; }; Script.isValidKey = function isValidKey(key, flags) {