address: improve isNull.

This commit is contained in:
Christopher Jeffrey 2017-05-13 00:33:21 -07:00
parent 41d9493cc7
commit 5915338407
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -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;
};
/**