From 5915338407f9b64e9e0a1f59f8094ace34d631af Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 13 May 2017 00:33:21 -0700 Subject: [PATCH] address: improve isNull. --- lib/primitives/address.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/primitives/address.js b/lib/primitives/address.js index 9b3bccc2..c95f122d 100644 --- a/lib/primitives/address.js +++ b/lib/primitives/address.js @@ -138,7 +138,20 @@ Address.prototype.verifyNetwork = function verifyNetwork(network) { */ Address.prototype.isNull = function isNull() { - return util.equal(this.hash, encoding.ZERO_HASH160); + var i; + + if (this.hash.length === 20) + return util.equal(this.hash, encoding.ZERO_HASH160); + + if (this.hash.length === 32) + return util.equal(this.hash, encoding.ZERO_HASH); + + for (i = 0; i < this.hash.length; i++) { + if (this.hash[i] !== 0) + return false; + } + + return true; }; /**