add walletId to txProposal model

This commit is contained in:
Ivan Socolsky 2015-03-30 11:29:19 -03:00
parent ef45a97e5b
commit 4e840328bd
4 changed files with 6 additions and 0 deletions

View File

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

View File

@ -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,

View File

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

View File

@ -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,