balanceofsatoshis 11.20.1 → 11.22.2
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,18 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 11.22.2
|
|
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
|
+
|
|
11
|
+
## 11.20.2
|
|
12
|
+
|
|
13
|
+
- `change-channel-capacity`: Increase RBF fee buffer when increasing capacity
|
|
14
|
+
- `telegram`: Redesign /invoice user interface to be button based
|
|
15
|
+
|
|
3
16
|
## 11.20.1
|
|
4
17
|
|
|
5
18
|
- `fees`: Correct issue where fee rate could not be set to zero
|
package/README.md
CHANGED
|
@@ -89,6 +89,9 @@ bos chart-fees-paid
|
|
|
89
89
|
# Show a chart of payments received
|
|
90
90
|
bos chart-payments-received
|
|
91
91
|
|
|
92
|
+
# Remove old failed payment data for probes and other failed payments
|
|
93
|
+
bos clean-failed-payments
|
|
94
|
+
|
|
92
95
|
# See details on how closed channels resolved on-chain
|
|
93
96
|
bos closed
|
|
94
97
|
|
|
@@ -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,9 +37,9 @@
|
|
|
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.
|
|
40
|
+
"ln-telegram": "3.5.1",
|
|
41
41
|
"moment": "2.29.1",
|
|
42
|
-
"paid-services": "3.5.
|
|
42
|
+
"paid-services": "3.5.1",
|
|
43
43
|
"probing": "2.0.1",
|
|
44
44
|
"psbt": "1.1.10",
|
|
45
45
|
"qrcode-terminal": "0.12.0",
|
|
@@ -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"
|
|
@@ -78,7 +81,8 @@
|
|
|
78
81
|
"integration-tests": "tap --branches=1 --functions=1 --lines=1 --statements=1 -t 120 test/integration/*.js",
|
|
79
82
|
"postpack": "PACKAGE_VERSION=$(cat package.json | grep \\\"version\\\" | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag -s v$PACKAGE_VERSION -m v$PACKAGE_VERSION && git push github --tags",
|
|
80
83
|
"postpublish": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t alexbosworth/balanceofsatoshis --push .",
|
|
84
|
+
"preinstall": "npx npm-force-resolutions",
|
|
81
85
|
"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
86
|
},
|
|
83
|
-
"version": "11.
|
|
87
|
+
"version": "11.22.2"
|
|
84
88
|
}
|
|
@@ -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');
|
|
@@ -12,6 +12,7 @@ const {getTransactionRecord} = require('ln-sync');
|
|
|
12
12
|
const {getWalletInfo} = require('ln-service');
|
|
13
13
|
const {handleBackupCommand} = require('ln-telegram');
|
|
14
14
|
const {handleBlocknotifyCommand} = require('ln-telegram');
|
|
15
|
+
const {handleButtonPush} = require('ln-telegram');
|
|
15
16
|
const {handleConnectCommand} = require('ln-telegram');
|
|
16
17
|
const {handleCostsCommand} = require('ln-telegram');
|
|
17
18
|
const {handleEarningsCommand} = require('ln-telegram');
|
|
@@ -23,6 +24,7 @@ const {handlePendingCommand} = require('ln-telegram');
|
|
|
23
24
|
const {handleVersionCommand} = require('ln-telegram');
|
|
24
25
|
const {InputFile} = require('grammy');
|
|
25
26
|
const inquirer = require('inquirer');
|
|
27
|
+
const {isMessageReplyToInvoice} = require('ln-telegram');
|
|
26
28
|
const {notifyOfForwards} = require('ln-telegram');
|
|
27
29
|
const {postChainTransaction} = require('ln-telegram');
|
|
28
30
|
const {postClosedMessage} = require('ln-telegram');
|
|
@@ -38,6 +40,7 @@ const {subscribeToChannels} = require('ln-service');
|
|
|
38
40
|
const {subscribeToInvoices} = require('ln-service');
|
|
39
41
|
const {subscribeToPastPayments} = require('ln-service');
|
|
40
42
|
const {subscribeToTransactions} = require('ln-service');
|
|
43
|
+
const {updateInvoiceFromReply} = require('ln-telegram');
|
|
41
44
|
|
|
42
45
|
const interaction = require('./interaction');
|
|
43
46
|
const markdown = {parse_mode: 'Markdown'};
|
|
@@ -298,19 +301,17 @@ module.exports = ({fs, id, limits, lnds, logger, payments, request}, cbk) => {
|
|
|
298
301
|
return;
|
|
299
302
|
});
|
|
300
303
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
return;
|
|
304
|
+
// Handle creation of an invoice
|
|
305
|
+
bot.command('invoice', async ctx => {
|
|
306
|
+
try {
|
|
307
|
+
await handleInvoiceCommand({
|
|
308
|
+
ctx,
|
|
309
|
+
id: connectedId,
|
|
310
|
+
nodes: getNodes,
|
|
311
|
+
});
|
|
312
|
+
} catch (err) {
|
|
313
|
+
logger.error({err});
|
|
314
|
+
}
|
|
314
315
|
});
|
|
315
316
|
|
|
316
317
|
bot.command('mempool', async ctx => {
|
|
@@ -425,7 +426,7 @@ module.exports = ({fs, id, limits, lnds, logger, payments, request}, cbk) => {
|
|
|
425
426
|
'/connect - Connect bot',
|
|
426
427
|
'/costs - View costs over the past week',
|
|
427
428
|
'/earnings - View earnings over the past week',
|
|
428
|
-
'/invoice - Make an invoice',
|
|
429
|
+
'/invoice [amount] [memo] - Make an invoice',
|
|
429
430
|
'/liquidity [with] - View node liquidity',
|
|
430
431
|
'/mempool - BTC mempool report',
|
|
431
432
|
'/pay - Pay an invoice',
|
|
@@ -441,6 +442,32 @@ module.exports = ({fs, id, limits, lnds, logger, payments, request}, cbk) => {
|
|
|
441
442
|
}
|
|
442
443
|
});
|
|
443
444
|
|
|
445
|
+
// Handle button push type commands
|
|
446
|
+
bot.on('callback_query:data', async ctx => {
|
|
447
|
+
try {
|
|
448
|
+
await handleButtonPush({ctx, id: connectedId, nodes: getNodes});
|
|
449
|
+
} catch (err) {
|
|
450
|
+
logger.error({err});
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
// Listen for replies to created invoice messages
|
|
455
|
+
bot.on('message').filter(
|
|
456
|
+
ctx => isMessageReplyToInvoice({ctx, nodes: getNodes}),
|
|
457
|
+
async ctx => {
|
|
458
|
+
try {
|
|
459
|
+
return await updateInvoiceFromReply({
|
|
460
|
+
ctx,
|
|
461
|
+
api: bot.api,
|
|
462
|
+
id: connectedId,
|
|
463
|
+
nodes: getNodes,
|
|
464
|
+
});
|
|
465
|
+
} catch (err) {
|
|
466
|
+
logger.error({err});
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
);
|
|
470
|
+
|
|
444
471
|
bot.start();
|
|
445
472
|
|
|
446
473
|
return cbk();
|