move key sorting to utils.
This commit is contained in:
parent
b74e8de067
commit
efe1181bc1
@ -781,10 +781,7 @@ script.multisig = function(keys, m, n) {
|
||||
while (keys.length < n)
|
||||
keys.push([]);
|
||||
|
||||
// Keys need to be in a predictable order.
|
||||
keys = keys.sort(function(a, b) {
|
||||
return new bn(a).cmp(new bn(b)) > 0;
|
||||
});
|
||||
keys = utils.sortKeys(keys);
|
||||
|
||||
return [ m ].concat(
|
||||
keys,
|
||||
|
||||
@ -586,3 +586,9 @@ utils.hidden = function(obj, prop, value) {
|
||||
});
|
||||
return obj;
|
||||
};
|
||||
|
||||
utils.sortKeys = function(keys) {
|
||||
return keys.sort(function(a, b) {
|
||||
return new bn(a).cmp(new bn(b)) > 0;
|
||||
});
|
||||
};
|
||||
|
||||
@ -170,10 +170,7 @@ Wallet.prototype.addKey = function addKey(key) {
|
||||
|
||||
this.keys.push(key);
|
||||
|
||||
// Keys need to be in a predictable order.
|
||||
this.keys = this.keys.sort(function(a, b) {
|
||||
return new bn(a).cmp(new bn(b)) > 0;
|
||||
});
|
||||
this.keys = utils.sortKeys(this.keys);
|
||||
};
|
||||
|
||||
Wallet.prototype.removeKey = function removeKey(key) {
|
||||
@ -190,10 +187,7 @@ Wallet.prototype.removeKey = function removeKey(key) {
|
||||
|
||||
this.keys.splice(index, 1);
|
||||
|
||||
// Keys need to be in a predictable order.
|
||||
this.keys = this.keys.sort(function(a, b) {
|
||||
return new bn(a).cmp(new bn(b)) > 0;
|
||||
});
|
||||
this.keys = utils.sortKeys(this.keys);
|
||||
};
|
||||
|
||||
Wallet.prototype.derive = function derive() {
|
||||
@ -267,10 +261,7 @@ Wallet.prototype.getPublicKey = function getPublicKey(enc) {
|
||||
Wallet.prototype.getPublicKeys = function() {
|
||||
var keys = this.keys.slice().map(utils.toKeyArray);
|
||||
|
||||
// Keys need to be in a predictable order.
|
||||
keys = keys.sort(function(a, b) {
|
||||
return new bn(a).cmp(new bn(b)) > 0;
|
||||
});
|
||||
keys = utils.sortKeys(keys);
|
||||
|
||||
return keys;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user