Browse Source

add indexes to copayer

activeAddress
Matias Alejo Garcia 10 years ago
parent
commit
7b68c14fb7
  1. 18
      lib/model/copayer.js
  2. 1
      lib/server.js
  3. 3
      test/integration.js

18
lib/model/copayer.js

@ -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();

1
lib/server.js

@ -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);

3
test/integration.js

@ -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();
});
});

Loading…
Cancel
Save