Create indexes for all copayers

This commit is contained in:
Yemel Jardi 2014-07-01 12:49:50 -03:00
commit b02cb17989
4 changed files with 52 additions and 2 deletions

View file

@ -6,9 +6,22 @@ var Structure = require('./Structure');
function AddressIndex(opts) {
opts = opts || {};
this.cosigner = opts.cosigner || Structure.SHARED_INDEX;
this.cosigner = opts.cosigner
this.changeIndex = opts.changeIndex || 0;
this.receiveIndex = opts.receiveIndex || 0;
if (typeof this.cosigner === 'undefined') {
this.cosigner = Structure.SHARED_INDEX;
}
}
AddressIndex.init = function(totalCopayers) {
preconditions.shouldBeNumber(totalCopayers);
var indexes = [new AddressIndex()];
for (var i = 0 ; i < totalCopayers ; i++) {
indexes.push(new AddressIndex({cosigner: i}));
}
return indexes;
}
AddressIndex.fromList = function(indexes) {

View file

@ -24,7 +24,8 @@ function PublicKeyRing(opts) {
this.copayersHK = opts.copayersHK || [];
this.indexes = opts.indexes ? AddressIndex.fromList(opts.indexes) : [new AddressIndex()];
this.indexes = opts.indexes ? AddressIndex.fromList(opts.indexes)
: AddressIndex.init(this.totalCopayers);
this.publicKeysCache = opts.publicKeysCache || {};
this.nicknameFor = opts.nicknameFor || {};