add indexes to copayer

This commit is contained in:
Matias Alejo Garcia 2015-02-02 09:36:55 -03:00
parent d6733de12d
commit 7b68c14fb7
3 changed files with 22 additions and 0 deletions

View File

@ -24,6 +24,24 @@ Copayer.prototype.getSigningPubKey = function () {
return HDPublicKey.fromString(this.xPubKey).derive(MESSAGE_SIGNING_PATH).publicKey.toString();
};
Copayer.prototype.addAddress = function (isChange) {
if (isChange) {
this.changeAddressIndex++;
} else {
this.receiveAddressIndex++;
}
};
Copayer.prototype.getCurrentAddressPath = function (isChange) {
return
};
Copayer.prototype.getNewAddressPath = function (isChange) {
this.addAddress(isChange);
return this.currentAddressPath(isChange);
};
Copayer.fromObj = function (obj) {
var x = new Copayer();

View File

@ -139,6 +139,7 @@ CopayServer.prototype._verifySignature = function (text, signature, pubKey) {
name: opts.name,
xPubKey: opts.xPubKey,
xPubKeySignature: opts.xPubKeySignature,
copayerIndex: wallet.copayers.length,
});
wallet.addCopayer(copayer);

View File

@ -471,6 +471,9 @@ describe('Copay server', function() {
should.not.exist(err);
wallet.status.should.equal('complete');
wallet.publicKeyRing.length.should.equal(3);
_.each([0,1,2], function(i) {
wallet.copayers[i].copayerIndex.should.equal(i);
});
done();
});
});