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