-
Notifications
You must be signed in to change notification settings - Fork 0
/
ltc-wallet.js
57 lines (45 loc) · 1016 Bytes
/
ltc-wallet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict';
var Currencies = require('./currencies');
var _ = require('lodash');
var LtcWallet = function() {
this.currency = Currencies.LTC;
/**
*
* @type {Array<Transaction>}
*/
this.transactions = [];
/**
*
* @type {number}
*/
this.amount = 0;
this.stats = {
total: 0,
transactions: 0
};
/**
*
* @param {Transaction} transaction
*/
this.performTransaction = function(transaction) {
if(transaction.destCurrency !== this.currency) {
//TODO throw error
}
if(transaction.amount >0 ) {
this.amount += transaction.amount;
this.transactions.push(transaction);
} else {
}
};
/**
*
* @returns {{total: number, transactions: *}}
*/
this.getStats = function() {
return {
total: this.amount,
transactions: this.transactions.length
}
};
};
module.exports = LtcWallet;