Browse Source

add walletId to txProposal model

activeAddress
Ivan Socolsky 10 years ago
parent
commit
4e840328bd
  1. 2
      lib/model/txproposal.js
  2. 1
      lib/server.js
  3. 2
      test/integration/server.js
  4. 1
      test/models/txproposal.js

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

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

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

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

Loading…
Cancel
Save