From 7b68c14fb7f96370338e50e926d59fb40fdd027e Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 2 Feb 2015 09:36:55 -0300 Subject: [PATCH] add indexes to copayer --- lib/model/copayer.js | 18 ++++++++++++++++++ lib/server.js | 1 + test/integration.js | 3 +++ 3 files changed, 22 insertions(+) diff --git a/lib/model/copayer.js b/lib/model/copayer.js index 0f0abe0..0c1c7e9 100644 --- a/lib/model/copayer.js +++ b/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(); diff --git a/lib/server.js b/lib/server.js index 06c95dd..05f7618 100644 --- a/lib/server.js +++ b/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); diff --git a/test/integration.js b/test/integration.js index a88657e..cec51a5 100644 --- a/test/integration.js +++ b/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(); }); });