primitives: use equals instead of equal for consistency.
This commit is contained in:
parent
33c32d32c1
commit
edebc51d18
@ -393,9 +393,8 @@ HDPrivateKey.prototype.derivePath = function derivePath(path) {
|
|||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
HDPrivateKey.prototype.equal = function equal(obj) {
|
HDPrivateKey.prototype.equals = function equals(obj) {
|
||||||
if (!HDPrivateKey.isHDPrivateKey(obj))
|
assert(HDPrivateKey.isHDPrivateKey(obj));
|
||||||
return false;
|
|
||||||
|
|
||||||
return this.network === obj.network
|
return this.network === obj.network
|
||||||
&& this.depth === obj.depth
|
&& this.depth === obj.depth
|
||||||
|
|||||||
@ -315,9 +315,8 @@ HDPublicKey.prototype.derivePath = function derivePath(path) {
|
|||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
HDPublicKey.prototype.equal = function equal(obj) {
|
HDPublicKey.prototype.equals = function equals(obj) {
|
||||||
if (!HDPublicKey.isHDPublicKey(obj))
|
assert(HDPublicKey.isHDPublicKey(obj));
|
||||||
return false;
|
|
||||||
|
|
||||||
return this.network === obj.network
|
return this.network === obj.network
|
||||||
&& this.depth === obj.depth
|
&& this.depth === obj.depth
|
||||||
|
|||||||
@ -119,6 +119,21 @@ Address.prototype.isNull = function isNull() {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test equality against another address.
|
||||||
|
* @param {Address} addr
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
|
||||||
|
Address.prototype.equals = function equals(addr) {
|
||||||
|
assert(addr instanceof Address);
|
||||||
|
|
||||||
|
return this.network === addr.network
|
||||||
|
&& this.type === addr.type
|
||||||
|
&& this.version === addr.version
|
||||||
|
&& this.hash.equals(addr.hash);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the address type as a string.
|
* Get the address type as a string.
|
||||||
* @returns {String}
|
* @returns {String}
|
||||||
|
|||||||
@ -85,7 +85,7 @@ SigCache.prototype.has = function has(hash, sig, key) {
|
|||||||
if (!entry)
|
if (!entry)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return entry.equal(sig, key);
|
return entry.equals(sig, key);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,7 +138,7 @@ function SigCacheEntry(sig, key) {
|
|||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SigCacheEntry.prototype.equal = function equal(sig, key) {
|
SigCacheEntry.prototype.equals = function equals(sig, key) {
|
||||||
return this.sig.equals(sig) && this.key.equals(key);
|
return this.sig.equals(sig) && this.key.equals(key);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -289,7 +289,7 @@ Account.prototype.pushKey = function pushKey(key) {
|
|||||||
if (this.type !== Account.types.MULTISIG)
|
if (this.type !== Account.types.MULTISIG)
|
||||||
throw new Error('Cannot add keys to non-multisig wallet.');
|
throw new Error('Cannot add keys to non-multisig wallet.');
|
||||||
|
|
||||||
if (key.equal(this.accountKey))
|
if (key.equals(this.accountKey))
|
||||||
throw new Error('Cannot add own key.');
|
throw new Error('Cannot add own key.');
|
||||||
|
|
||||||
const index = util.binaryInsert(this.keys, key, cmp, true);
|
const index = util.binaryInsert(this.keys, key, cmp, true);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user