balanceofsatoshis 11.44.0 → 11.47.0
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 +12 -0
- package/CONTRIBUTING.md +72 -0
- package/bos +5 -4
- package/package.json +5 -6
- package/telegram/start_telegram_bot.js +41 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 11.47.0
|
|
4
|
+
|
|
5
|
+
- `telegram`: Add `/graph <node public key or peer alias>` to lookup node info
|
|
6
|
+
|
|
7
|
+
## 11.46.0
|
|
8
|
+
|
|
9
|
+
- `telegram`: Add `/stop` command to terminate the running bot
|
|
10
|
+
|
|
11
|
+
## 11.45.1
|
|
12
|
+
|
|
13
|
+
- `increase-inbound-liquidity`: Add support for formulas in `--amount`
|
|
14
|
+
|
|
3
15
|
## 11.44.0
|
|
4
16
|
|
|
5
17
|
- `send`: Add support for `--max-fee-rate` to limit fees paid via PPM measure
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Contribution Guidelines
|
|
2
|
+
|
|
3
|
+
- Feel free to open issues or pull requests
|
|
4
|
+
- They may not be addressed or merged
|
|
5
|
+
- You can ignore coding styles if you want
|
|
6
|
+
|
|
7
|
+
## Coding Style
|
|
8
|
+
|
|
9
|
+
If you want to help with style, here are some rough guidelines on style ideas:
|
|
10
|
+
|
|
11
|
+
### Formatting
|
|
12
|
+
|
|
13
|
+
- Spaces not tabs, 2 spaces
|
|
14
|
+
- Arguments to methods are snake_case
|
|
15
|
+
- Regular variables are camelCase
|
|
16
|
+
- Returned attributes are snake_case
|
|
17
|
+
- Minimize function nesting, make new files if nesting is required
|
|
18
|
+
- No extraneous whitespace
|
|
19
|
+
- A single newline should appear at the end of a file
|
|
20
|
+
- Don't bother with () in functions when not needed: `const a = b => c`
|
|
21
|
+
- If there are multiple things together, alphabetize them
|
|
22
|
+
- Don't split up long strings over multiple lines
|
|
23
|
+
- Lines should be terminated by explicit semicolons
|
|
24
|
+
- Logic like ternary operators should not extend beyond a single line
|
|
25
|
+
- Don't let any lines linger when they don't do anything
|
|
26
|
+
- Tightly space objects, like `{attribute: value}` not `{ attribute : value }`
|
|
27
|
+
- Use single '' quotes not double "" quotes, except when `` is required
|
|
28
|
+
- If conditions should avoid spanning multiple lines
|
|
29
|
+
- Avoid double specifying an attribute and value, `{type: type}` vs `{type}`
|
|
30
|
+
|
|
31
|
+
### Control Flow
|
|
32
|
+
|
|
33
|
+
- Async functions should support both cbk and Promise style
|
|
34
|
+
- Use async.js methods for asynchronous control flow
|
|
35
|
+
- Try to exit early from functions when possible, and note this exit in comment
|
|
36
|
+
- Prefer cbk over Promise style, aside from in tests or in Promise libs
|
|
37
|
+
- Use `asyncAuto` for asynchronous control flow dependency management
|
|
38
|
+
- Callbacks should generally be named cbk even when redefinining in inner scope
|
|
39
|
+
- Avoid mixing non-async complex logic and async control flows in the same file
|
|
40
|
+
- Minimize async nesting in returned attributes and in method arguments
|
|
41
|
+
- Methods should always document their arguments and their output
|
|
42
|
+
|
|
43
|
+
### Variables
|
|
44
|
+
|
|
45
|
+
- Generally use undefined rather than null when defining nil types
|
|
46
|
+
- Prefer variable assignments on new lines rather than on a single line
|
|
47
|
+
- Reduce the usage of . property access, like isArray instead of Array.isArray
|
|
48
|
+
- When there is a newline in an object, always put a comma at the end of a line
|
|
49
|
+
- Short properties always go first in objects: `{short, longer: type}`
|
|
50
|
+
- If a statement relies on a statement above it, it should have a newline above
|
|
51
|
+
- Avoid including scalar values such as strings or numbers in the code itself
|
|
52
|
+
|
|
53
|
+
### JS Features
|
|
54
|
+
|
|
55
|
+
- Limit usage of `let` and never use `var`, prefer `const`
|
|
56
|
+
- Limit use of npm dependencies when possible, only use good dependencies
|
|
57
|
+
- Target support of the oldest node.js LTS release still being supported
|
|
58
|
+
- Never use class or prototype
|
|
59
|
+
- Do not import more methods from an import than you actually use
|
|
60
|
+
- Try to avoid passing objects in arguments as much as possible
|
|
61
|
+
- Prefer using function iteration like map and forEach over for and while
|
|
62
|
+
- Use arrow functions and not `function` functions whenever possible
|
|
63
|
+
|
|
64
|
+
### Errors
|
|
65
|
+
|
|
66
|
+
- Never ignore an error case, always deal with it as soon as possible
|
|
67
|
+
- In the case of errors, do include the error string in the code
|
|
68
|
+
- Add simple validations to help target simple calling mistakes
|
|
69
|
+
- When throwing or returning error messages, use PascalCase for the message
|
|
70
|
+
- Use HTTP status codes as a guideline: 4** is a local issue, 5** is remote
|
|
71
|
+
- Return async errors as arrays: `[typeNumber, errorMsgString, extraDetails]`
|
|
72
|
+
- Try to be very specific with error messages and try to not repeat one
|
package/bos
CHANGED
|
@@ -25,6 +25,7 @@ const {accountingCategories} = commandConstants;
|
|
|
25
25
|
const balances = importLazy('./balances');
|
|
26
26
|
const chain = importLazy('./chain');
|
|
27
27
|
const commands = importLazy('./commands');
|
|
28
|
+
const display = importLazy('./display');
|
|
28
29
|
const encryption = importLazy('./encryption');
|
|
29
30
|
const lnd = importLazy('./lnd');
|
|
30
31
|
const network = importLazy('./network');
|
|
@@ -54,7 +55,6 @@ const months = [...Array(12).keys()].map(n => ++n);
|
|
|
54
55
|
const {REPEATABLE} = prog;
|
|
55
56
|
const {STRING} = prog;
|
|
56
57
|
const yearMatch = /^\d{4}$/;
|
|
57
|
-
|
|
58
58
|
prog
|
|
59
59
|
.version(version)
|
|
60
60
|
|
|
@@ -884,10 +884,11 @@ prog
|
|
|
884
884
|
.command('increase-inbound-liquidity', 'Increase node inbound liquidity')
|
|
885
885
|
.help('Spend down a channel to get inbound. Fee is an estimate, may be more')
|
|
886
886
|
.help('If you want to control chain fee increases, use show-raw-recoveries')
|
|
887
|
+
.help('Formulas supported for --amount like 5*m or 0.05*BTC for 5 million')
|
|
887
888
|
.option('--address <out_address>', 'Out chain address to send funds out to')
|
|
888
889
|
.option('--api-key <api_key>', 'Pre-paid API key to use')
|
|
890
|
+
.option('--amount <amount>', 'Amount to increase inbound', STRING, '500*k')
|
|
889
891
|
.option('--avoid <pubkey/chan/tag>', 'Avoid forwarding through', REPEATABLE)
|
|
890
|
-
.option('--amount <amount>', 'Amount to increase liquidity', INT, 5e5)
|
|
891
892
|
.option('--confs <confs>', 'Confs to consider reorg safe', INT, 1)
|
|
892
893
|
.option('--dryrun', 'Only show cost estimate for increase')
|
|
893
894
|
.option('--fast', 'Request swap server avoid batching delay')
|
|
@@ -930,11 +931,11 @@ prog
|
|
|
930
931
|
spend_address: options.spendAddress || undefined,
|
|
931
932
|
spend_tokens: options.spendAmount || undefined,
|
|
932
933
|
timeout: 1000 * 60 * 60 * 10,
|
|
933
|
-
tokens: options.amount,
|
|
934
|
+
tokens: display.parseAmount({amount: options.amount}).tokens,
|
|
934
935
|
},
|
|
935
936
|
responses.returnObject({exit, logger, reject, resolve}));
|
|
936
937
|
} catch (err) {
|
|
937
|
-
return reject(err);
|
|
938
|
+
return reject(logger.error({err}));
|
|
938
939
|
}
|
|
939
940
|
});
|
|
940
941
|
})
|
package/package.json
CHANGED
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
"crypto-js": "4.1.1",
|
|
29
29
|
"csv-parse": "5.0.4",
|
|
30
30
|
"goldengate": "11.0.0",
|
|
31
|
-
"grammy": "1.
|
|
31
|
+
"grammy": "1.7.0",
|
|
32
32
|
"hot-formula-parser": "4.0.0",
|
|
33
33
|
"import-lazy": "4.0.0",
|
|
34
34
|
"ini": "2.0.0",
|
|
35
35
|
"inquirer": "8.2.0",
|
|
36
36
|
"invoices": "2.0.3",
|
|
37
37
|
"ln-accounting": "5.0.5",
|
|
38
|
-
"ln-service": "53.
|
|
38
|
+
"ln-service": "53.7.0",
|
|
39
39
|
"ln-sync": "3.9.0",
|
|
40
|
-
"ln-telegram": "3.
|
|
40
|
+
"ln-telegram": "3.14.0",
|
|
41
41
|
"moment": "2.29.1",
|
|
42
42
|
"paid-services": "3.11.0",
|
|
43
43
|
"probing": "2.0.2",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"description": "Lightning balance CLI",
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@alexbosworth/tap": "15.0.10",
|
|
55
|
-
"ln-docker-daemons": "2.2.
|
|
55
|
+
"ln-docker-daemons": "2.2.3",
|
|
56
56
|
"mock-lnd": "1.4.1",
|
|
57
57
|
"secp256k1": "4.0.3"
|
|
58
58
|
},
|
|
@@ -77,9 +77,8 @@
|
|
|
77
77
|
"scripts": {
|
|
78
78
|
"build-docker": "docker build -t alexbosworth/balanceofsatoshis . && docker save alexbosworth/balanceofsatoshis > balanceofsatoshis.tar && gzip balanceofsatoshis.tar",
|
|
79
79
|
"integration-tests": "tap --branches=1 --functions=1 --lines=1 --statements=1 -t 120 test/integration/*.js",
|
|
80
|
-
"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",
|
|
81
80
|
"postpublish": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t alexbosworth/balanceofsatoshis --push .",
|
|
82
81
|
"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"
|
|
83
82
|
},
|
|
84
|
-
"version": "11.
|
|
83
|
+
"version": "11.47.0"
|
|
85
84
|
}
|
|
@@ -19,12 +19,14 @@ const {handleConnectCommand} = require('ln-telegram');
|
|
|
19
19
|
const {handleCostsCommand} = require('ln-telegram');
|
|
20
20
|
const {handleEarningsCommand} = require('ln-telegram');
|
|
21
21
|
const {handleEditedMessage} = require('ln-telegram');
|
|
22
|
+
const {handleGraphCommand} = require('ln-telegram');
|
|
22
23
|
const {handleInvoiceCommand} = require('ln-telegram');
|
|
23
24
|
const {handleLiquidityCommand} = require('ln-telegram');
|
|
24
25
|
const {handleMempoolCommand} = require('ln-telegram');
|
|
25
26
|
const {handlePayCommand} = require('ln-telegram');
|
|
26
27
|
const {handlePendingCommand} = require('ln-telegram');
|
|
27
28
|
const {handleStartCommand} = require('ln-telegram');
|
|
29
|
+
const {handleStopCommand} = require('ln-telegram');
|
|
28
30
|
const {handleVersionCommand} = require('ln-telegram');
|
|
29
31
|
const {InputFile} = require('grammy');
|
|
30
32
|
const inquirer = require('inquirer');
|
|
@@ -266,12 +268,14 @@ module.exports = (args, cbk) => {
|
|
|
266
268
|
{command: 'connect', description: 'Get connect code for the bot'},
|
|
267
269
|
{command: 'costs', description: 'Show costs over the week'},
|
|
268
270
|
{command: 'earnings', description: 'Show earnings over the week'},
|
|
271
|
+
{command: 'graph', description: 'Show info about a node'},
|
|
269
272
|
{command: 'help', description: 'Show the list of commands'},
|
|
270
273
|
{command: 'invoice', description: 'Create an invoice'},
|
|
271
274
|
{command: 'liquidity', description: 'Get liquidity [with-peer]'},
|
|
272
275
|
{command: 'mempool', description: 'Get info about the mempool'},
|
|
273
276
|
{command: 'pay', description: 'Pay a payment request'},
|
|
274
277
|
{command: 'pending', description: 'Get pending forwards, channels'},
|
|
278
|
+
{command: 'stop', description: 'Stop the bot'},
|
|
275
279
|
{command: 'version', description: 'View current bot version'},
|
|
276
280
|
]);
|
|
277
281
|
|
|
@@ -355,6 +359,22 @@ module.exports = (args, cbk) => {
|
|
|
355
359
|
return;
|
|
356
360
|
});
|
|
357
361
|
|
|
362
|
+
bot.command('graph', async ctx => {
|
|
363
|
+
try {
|
|
364
|
+
await handleGraphCommand({
|
|
365
|
+
from: ctx.message.from.id,
|
|
366
|
+
id: connectedId,
|
|
367
|
+
nodes: allNodes,
|
|
368
|
+
remove: () => ctx.deleteMessage(),
|
|
369
|
+
reply: (message, options) => ctx.reply(message, options),
|
|
370
|
+
text: ctx.message.text,
|
|
371
|
+
working: () => ctx.replyWithChatAction('typing'),
|
|
372
|
+
});
|
|
373
|
+
} catch (err) {
|
|
374
|
+
logger.error({err});
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
|
|
358
378
|
// Handle creation of an invoice
|
|
359
379
|
bot.command('invoice', async ctx => {
|
|
360
380
|
try {
|
|
@@ -457,6 +477,22 @@ module.exports = (args, cbk) => {
|
|
|
457
477
|
});
|
|
458
478
|
});
|
|
459
479
|
|
|
480
|
+
// Terminate the running bot
|
|
481
|
+
bot.command('stop', async ctx => {
|
|
482
|
+
try {
|
|
483
|
+
await handleStopCommand({
|
|
484
|
+
from: ctx.message.from.id,
|
|
485
|
+
id: connectedId,
|
|
486
|
+
quit: () => bot.stop(),
|
|
487
|
+
reply: (msg, mode) => ctx.reply(msg, mode),
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
process.exit();
|
|
491
|
+
} catch (err) {
|
|
492
|
+
logger.error({err});
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
|
|
460
496
|
bot.command('version', async ctx => {
|
|
461
497
|
try {
|
|
462
498
|
await handleVersionCommand({
|
|
@@ -476,11 +512,13 @@ module.exports = (args, cbk) => {
|
|
|
476
512
|
'/connect - Connect bot',
|
|
477
513
|
'/costs - View costs over the past week',
|
|
478
514
|
'/earnings - View earnings over the past week',
|
|
515
|
+
'/graph [pubkey or peer alias] - Show info about a node',
|
|
479
516
|
'/invoice [amount] [memo] - Make an invoice',
|
|
480
517
|
'/liquidity [with] - View node liquidity',
|
|
481
518
|
'/mempool - BTC mempool report',
|
|
482
519
|
'/pay - Pay an invoice',
|
|
483
520
|
'/pending - View pending channels, probes, and forwards',
|
|
521
|
+
'/stop - Stop bot',
|
|
484
522
|
'/version - View the current bot version',
|
|
485
523
|
];
|
|
486
524
|
|
|
@@ -599,15 +637,14 @@ module.exports = (args, cbk) => {
|
|
|
599
637
|
return postClosedMessage({
|
|
600
638
|
from,
|
|
601
639
|
lnd,
|
|
602
|
-
request,
|
|
603
640
|
capacity: update.capacity,
|
|
604
641
|
id: connectedId,
|
|
605
642
|
is_breach_close: update.is_breach_close,
|
|
606
643
|
is_cooperative_close: update.is_cooperative_close,
|
|
607
644
|
is_local_force_close: update.is_local_force_close,
|
|
608
645
|
is_remote_force_close: update.is_remote_force_close,
|
|
609
|
-
key: apiKey.key,
|
|
610
646
|
partner_public_key: update.partner_public_key,
|
|
647
|
+
send: (id, message) => bot.api.sendMessage(id, message, markdown),
|
|
611
648
|
},
|
|
612
649
|
err => !!err ? logger.error({node: from, closed_err: err}) : null);
|
|
613
650
|
});
|
|
@@ -616,13 +653,12 @@ module.exports = (args, cbk) => {
|
|
|
616
653
|
return postOpenMessage({
|
|
617
654
|
from,
|
|
618
655
|
lnd,
|
|
619
|
-
request,
|
|
620
656
|
capacity: update.capacity,
|
|
621
657
|
id: connectedId,
|
|
622
658
|
is_partner_initiated: update.is_partner_initiated,
|
|
623
659
|
is_private: update.is_private,
|
|
624
|
-
key: apiKey.key,
|
|
625
660
|
partner_public_key: update.partner_public_key,
|
|
661
|
+
send: (id, message) => bot.api.sendMessage(id, message, markdown),
|
|
626
662
|
},
|
|
627
663
|
err => !!err ? logger.error({open_err: err}) : null);
|
|
628
664
|
});
|
|
@@ -899,10 +935,9 @@ module.exports = (args, cbk) => {
|
|
|
899
935
|
|
|
900
936
|
return await postChainTransaction({
|
|
901
937
|
from,
|
|
902
|
-
request,
|
|
903
938
|
confirmed: transaction.is_confirmed,
|
|
904
939
|
id: connectedId,
|
|
905
|
-
|
|
940
|
+
send: (id, message) => bot.api.sendMessage(id, message, markdown),
|
|
906
941
|
transaction: record,
|
|
907
942
|
});
|
|
908
943
|
} catch (err) {
|