diff --git a/lib/emailservice.js b/lib/emailservice.js index 4c7753f..ac4ef26 100644 --- a/lib/emailservice.js +++ b/lib/emailservice.js @@ -8,6 +8,7 @@ log.debug = log.verbose; var fs = require('fs'); var nodemailer = require('nodemailer'); +var WalletUtils = require('bitcore-wallet-utils'); var Storage = require('./storage'); var MessageBroker = require('./messagebroker'); var Lock = require('./lock'); @@ -140,6 +141,9 @@ EmailService.prototype._getDataForTemplate = function(notification, cb) { var data = _.cloneDeep(notification.data); data.subjectPrefix = _.trim(self.subjectPrefix) + ' '; + if (data.amount) { + data.amount = WalletUtils.formatAmount(+data.amount, 'bit') + ' bits'; + } self.storage.fetchWallet(notification.walletId, function(err, wallet) { if (err) return cb(err); data.walletId = wallet.id; diff --git a/lib/templates/new_incoming_tx.plain b/lib/templates/new_incoming_tx.plain index c980ef5..498b75b 100644 --- a/lib/templates/new_incoming_tx.plain +++ b/lib/templates/new_incoming_tx.plain @@ -1,2 +1,2 @@ <%= subjectPrefix %>New payment received -A Payment has been received into your wallet <%= walletName %>. +A payment of <%= amount %> has been received into your wallet <%= walletName %>. diff --git a/test/integration/server.js b/test/integration/server.js index a719d30..d1fafe9 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -329,7 +329,7 @@ describe('Wallet service', function() { }); }); - it('should notify copayers of incoming txs', function(done) { + it.only('should notify copayers of incoming txs', function(done) { server.createAddress({}, function(err, address) { should.not.exist(err); @@ -337,7 +337,7 @@ describe('Wallet service', function() { server._notify('NewIncomingTx', { txid: '999', address: address, - amount: 123, + amount: 12300000, }, function(err) { setTimeout(function() { var calls = mailerStub.sendMail.getCalls(); @@ -350,6 +350,7 @@ describe('Wallet service', function() { one.from.should.equal('bws@dummy.net'); one.subject.should.contain('New payment received'); one.text.should.contain(wallet.name); + one.text.should.contain('123,000'); server.storage.fetchUnsentEmails(function(err, unsent) { should.not.exist(err); unsent.should.be.empty;