mirror of https://github.com/BTCPrivate/copay.git
add forPath and tests
This commit is contained in:
parent
a10e6f4908
commit
96a5f0aeb8
|
@ -298,6 +298,15 @@ PublicKeyRing.prototype.getForPaths = function(paths) {
|
||||||
return paths.map(this.getForPath.bind(this));
|
return paths.map(this.getForPath.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
PublicKeyRing.prototype.forPaths = function(paths) {
|
||||||
|
return {
|
||||||
|
pubKeys: paths.map(this.getForPath.bind(this)),
|
||||||
|
copayerIds: this.copayerIds,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// TODO this could be cached
|
// TODO this could be cached
|
||||||
PublicKeyRing.prototype._addScriptMap = function(map, path) {
|
PublicKeyRing.prototype._addScriptMap = function(map, path) {
|
||||||
var p = HDPath.indexesForPath(path);
|
var p = HDPath.indexesForPath(path);
|
||||||
|
|
|
@ -489,4 +489,27 @@ describe('PublicKeyRing model', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('#getForPath should return 5 pubkeys', function() {
|
||||||
|
var w = getCachedW().w;
|
||||||
|
var pubkeys = w.getForPath('m/45\'/2147483647/1/0');
|
||||||
|
pubkeys.length.should.equal(5);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('#getForPaths should return 2 arrays of 5 pubkey ', function() {
|
||||||
|
var w = getCachedW().w;
|
||||||
|
var pubkeys = w.getForPaths([ 'm/45\'/2147483647/1/0', 'm/45\'/2147483647/1/1'] );
|
||||||
|
pubkeys.length.should.equal(2);
|
||||||
|
pubkeys[0].length.should.equal(5);
|
||||||
|
pubkeys[1].length.should.equal(5);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('#forPaths should return copayers and pubkeys ', function() {
|
||||||
|
var w = getCachedW().w;
|
||||||
|
var ret = w.forPaths([ 'm/45\'/2147483647/1/0', 'm/45\'/2147483647/1/1'] );
|
||||||
|
ret.copayerIds.length.should.equal(5);
|
||||||
|
ret.pubKeys.length.should.equal(2);
|
||||||
|
ret.pubKeys[0].length.should.equal(5);
|
||||||
|
ret.pubKeys[1].length.should.equal(5);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue