balanceofsatoshis 11.20.2 → 11.22.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 11.22.3
|
|
4
|
+
|
|
5
|
+
- `telegram`: Fix issue when moving a created invoice to a saved node
|
|
6
|
+
|
|
7
|
+
## 11.22.0
|
|
8
|
+
|
|
9
|
+
- `accounting`: Add summation total as secondary table
|
|
10
|
+
|
|
3
11
|
## 11.20.2
|
|
4
12
|
|
|
5
13
|
- `change-channel-capacity`: Increase RBF fee buffer when increasing capacity
|
|
@@ -12,6 +12,13 @@ const {notFoundIndex} = require('./constants');
|
|
|
12
12
|
const rangeForDate = require('./range_for_date');
|
|
13
13
|
const tableRowsFromCsv = require('./table_rows_from_csv');
|
|
14
14
|
|
|
15
|
+
const assetType = 'BTC';
|
|
16
|
+
const currentDate = new Date().toISOString();
|
|
17
|
+
const empty = '';
|
|
18
|
+
const round = n => parseFloat(n).toFixed(2);
|
|
19
|
+
const sumOf = arr => arr.reduce((sum, n) => sum + n, 0);
|
|
20
|
+
const summaryHeadings = ['Total', 'Asset', 'Report Date', 'Total Fiat'];
|
|
21
|
+
|
|
15
22
|
/** Get an accounting report
|
|
16
23
|
|
|
17
24
|
{
|
|
@@ -20,7 +27,7 @@ const tableRowsFromCsv = require('./table_rows_from_csv');
|
|
|
20
27
|
[fiat]: <Fiat Type String>
|
|
21
28
|
[is_csv]: <Return CSV Output Bool>
|
|
22
29
|
[is_fiat_disabled]: <Omit Fiat Conversion Bool>
|
|
23
|
-
lnd: <Authenticated LND
|
|
30
|
+
lnd: <Authenticated LND API Object>
|
|
24
31
|
[month]: <Month for Report String>
|
|
25
32
|
[node]: <Node Name String>
|
|
26
33
|
[rate_provider]: <Rate Provider String>
|
|
@@ -31,6 +38,7 @@ const tableRowsFromCsv = require('./table_rows_from_csv');
|
|
|
31
38
|
@returns via cbk or Promise
|
|
32
39
|
{
|
|
33
40
|
[rows]: [[<Column String>]]
|
|
41
|
+
[rows_summary]: [[<Column String>]]
|
|
34
42
|
}
|
|
35
43
|
*/
|
|
36
44
|
module.exports = (args, cbk) => {
|
|
@@ -97,8 +105,31 @@ module.exports = (args, cbk) => {
|
|
|
97
105
|
return tableRowsFromCsv({csv: getAccounting[csvType]}, cbk);
|
|
98
106
|
}],
|
|
99
107
|
|
|
108
|
+
// Calculate total amounts
|
|
109
|
+
total: ['getAccounting', ({getAccounting}, cbk) => {
|
|
110
|
+
// Exit early when a CSV dump is requested
|
|
111
|
+
if (!!args.is_csv) {
|
|
112
|
+
return cbk();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const rows = getAccounting[categories[args.category]];
|
|
116
|
+
|
|
117
|
+
// Token values are represented as amounts
|
|
118
|
+
const tokens = sumOf(rows.map(n => n.amount));
|
|
119
|
+
|
|
120
|
+
// Exit early when there is no fiat data
|
|
121
|
+
if (!!args.is_fiat_disabled) {
|
|
122
|
+
return cbk(null, {tokens, fiat: empty});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Fiat values are represented as fiat amounts
|
|
126
|
+
const fiat = round(sumOf(rows.map(n => n.fiat_amount)));
|
|
127
|
+
|
|
128
|
+
return cbk(null, {fiat, tokens});
|
|
129
|
+
}],
|
|
130
|
+
|
|
100
131
|
// Clean rows for display if necessary
|
|
101
|
-
report: ['accounting', ({accounting}, cbk) => {
|
|
132
|
+
report: ['accounting', 'total',({accounting, total}, cbk) => {
|
|
102
133
|
// Exit early when there is no cleaning necessary
|
|
103
134
|
if (!!args.is_csv) {
|
|
104
135
|
return cbk(null, accounting);
|
|
@@ -115,14 +146,19 @@ module.exports = (args, cbk) => {
|
|
|
115
146
|
}
|
|
116
147
|
|
|
117
148
|
if (j === fiatIndex && !!col) {
|
|
118
|
-
return
|
|
149
|
+
return round(col);
|
|
119
150
|
}
|
|
120
151
|
|
|
121
152
|
return col.substring(0, 32);
|
|
122
153
|
});
|
|
123
154
|
});
|
|
124
155
|
|
|
125
|
-
|
|
156
|
+
const summary = [
|
|
157
|
+
summaryHeadings,
|
|
158
|
+
[total.tokens, assetType, currentDate, total.fiat],
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
return cbk(null, {rows, rows_summary: summary});
|
|
126
162
|
}],
|
|
127
163
|
},
|
|
128
164
|
returnResult({reject, resolve, of: 'report'}, cbk));
|
package/package.json
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"ln-accounting": "5.0.5",
|
|
38
38
|
"ln-service": "53.2.0",
|
|
39
39
|
"ln-sync": "3.6.1",
|
|
40
|
-
"ln-telegram": "3.5.
|
|
40
|
+
"ln-telegram": "3.5.1",
|
|
41
41
|
"moment": "2.29.1",
|
|
42
42
|
"paid-services": "3.5.1",
|
|
43
43
|
"probing": "2.0.1",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@alexbosworth/tap": "15.0.10",
|
|
54
54
|
"ln-docker-daemons": "2.1.0",
|
|
55
55
|
"mock-lnd": "1.4.1",
|
|
56
|
-
"secp256k1": "4.0.
|
|
56
|
+
"secp256k1": "4.0.3"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=12.20"
|
|
@@ -69,6 +69,9 @@
|
|
|
69
69
|
"license": "MIT",
|
|
70
70
|
"main": "index.js",
|
|
71
71
|
"name": "balanceofsatoshis",
|
|
72
|
+
"resolutions": {
|
|
73
|
+
"colors": "1.1.2"
|
|
74
|
+
},
|
|
72
75
|
"repository": {
|
|
73
76
|
"type": "git",
|
|
74
77
|
"url": "https://github.com/alexbosworth/balanceofsatoshis.git"
|
|
@@ -80,5 +83,5 @@
|
|
|
80
83
|
"postpublish": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t alexbosworth/balanceofsatoshis --push .",
|
|
81
84
|
"test": "tap --branches=1 --functions=1 --lines=1 --statements=1 -t 60 test/arrays/*.js test/balances/*.js test/chain/*.js test/display/*.js test/encryption/*.js test/lnd/*.js test/network/*.js test/nodes/*.js test/peers/*.js test/responses/*.js test/routing/*.js test/services/*.js test/swaps/*.js test/tags/*.js test/wallets/*.js"
|
|
82
85
|
},
|
|
83
|
-
"version": "11.
|
|
86
|
+
"version": "11.22.3"
|
|
84
87
|
}
|
|
@@ -7,7 +7,9 @@ const writeJsonFile = require('./write_json_file');
|
|
|
7
7
|
|
|
8
8
|
const border = getBorderCharacters('norc');
|
|
9
9
|
const emptyCell = ' ';
|
|
10
|
+
const {isArray} = Array;
|
|
10
11
|
const notifier = updateNotifier({pkg});
|
|
12
|
+
const summary = n => `${n}_summary`;
|
|
11
13
|
|
|
12
14
|
/** Return an object result to a logger in a promise
|
|
13
15
|
|
|
@@ -59,6 +61,10 @@ module.exports = ({exit, file, logger, reject, resolve, table, write}) => {
|
|
|
59
61
|
if (!!table) {
|
|
60
62
|
logger.info(renderTable(res[table], {border}));
|
|
61
63
|
|
|
64
|
+
if (isArray(res[summary(table)])) {
|
|
65
|
+
logger.info(renderTable(res[summary(table)], {border}));
|
|
66
|
+
}
|
|
67
|
+
|
|
62
68
|
return resolve();
|
|
63
69
|
}
|
|
64
70
|
|
|
@@ -8,7 +8,6 @@ const asyncDetectSeries = require('async/detectSeries');
|
|
|
8
8
|
const {cancelHodlInvoice} = require('ln-service');
|
|
9
9
|
const {connectPeer} = require('ln-sync');
|
|
10
10
|
const {createInvoice} = require('ln-service');
|
|
11
|
-
const {createPsbt} = require('psbt');
|
|
12
11
|
const {getChainFeeRate} = require('ln-service');
|
|
13
12
|
const {getChannels} = require('ln-service');
|
|
14
13
|
const {getNode} = require('ln-service');
|