From 4e840328bd1f135b8622f9346ce311ebe42d7db0 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Mon, 30 Mar 2015 11:29:19 -0300 Subject: [PATCH] add walletId to txProposal model --- lib/model/txproposal.js | 2 ++ lib/server.js | 1 + test/integration/server.js | 2 ++ test/models/txproposal.js | 1 + 4 files changed, 6 insertions(+) diff --git a/lib/model/txproposal.js b/lib/model/txproposal.js index 025ada5..a20599e 100644 --- a/lib/model/txproposal.js +++ b/lib/model/txproposal.js @@ -20,6 +20,7 @@ TxProposal.create = function(opts) { var now = Date.now(); x.createdOn = Math.floor(now / 1000); x.id = _.padLeft(now, 14, '0') + Uuid.v4(); + x.walletId = opts.walletId; x.creatorId = opts.creatorId; x.toAddress = opts.toAddress; x.amount = opts.amount; @@ -45,6 +46,7 @@ TxProposal.fromObj = function(obj) { x.version = obj.version; x.createdOn = obj.createdOn; x.id = obj.id; + x.walletId = obj.walletId; x.creatorId = obj.creatorId; x.toAddress = obj.toAddress; x.amount = obj.amount; diff --git a/lib/server.js b/lib/server.js index 5c190f8..090d1c9 100644 --- a/lib/server.js +++ b/lib/server.js @@ -581,6 +581,7 @@ WalletService.prototype.createTx = function(opts, cb) { var changeAddress = wallet.createAddress(true); var txp = TxProposal.create({ + walletId: self.walletId, creatorId: self.copayerId, toAddress: opts.toAddress, amount: opts.amount, diff --git a/test/integration/server.js b/test/integration/server.js index 705827b..fa02405 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -800,6 +800,8 @@ describe('Copay server', function() { server.createTx(txOpts, function(err, tx) { should.not.exist(err); should.exist(tx); + tx.walletId.should.equal(wallet.id); + tx.creatorId.should.equal(wallet.copayers[0].id); tx.message.should.equal('some message'); tx.isAccepted().should.equal.false; tx.isRejected().should.equal.false; diff --git a/test/models/txproposal.js b/test/models/txproposal.js index 9b864f3..142291e 100644 --- a/test/models/txproposal.js +++ b/test/models/txproposal.js @@ -91,6 +91,7 @@ var aTXP = function() { "version": "1.0.0", "createdOn": 1423146231, "id": "75c34f49-1ed6-255f-e9fd-0c71ae75ed1e", + "walletId": "1", "creatorId": "1", "toAddress": "18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7", "amount": 50000000,