balanceofsatoshis 16.0.0 → 16.0.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 +5 -1
- package/package.json +4 -4
- package/peers/open_channels.js +31 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
"csv-parse": "5.5.0",
|
|
32
32
|
"ecpair": "2.1.0",
|
|
33
33
|
"goldengate": "13.0.2",
|
|
34
|
-
"grammy": "1.
|
|
34
|
+
"grammy": "1.19.0",
|
|
35
35
|
"hot-formula-parser": "4.0.0",
|
|
36
36
|
"import-lazy": "4.0.0",
|
|
37
37
|
"ini": "4.1.1",
|
|
38
38
|
"inquirer": "9.2.11",
|
|
39
39
|
"ln-accounting": "7.0.2",
|
|
40
|
-
"ln-service": "56.
|
|
40
|
+
"ln-service": "56.14.0",
|
|
41
41
|
"ln-sync": "5.2.3",
|
|
42
42
|
"ln-telegram": "5.0.0",
|
|
43
43
|
"moment": "2.29.4",
|
|
44
|
-
"paid-services": "5.0.
|
|
44
|
+
"paid-services": "5.0.5",
|
|
45
45
|
"probing": "4.0.0",
|
|
46
46
|
"psbt": "3.0.0",
|
|
47
47
|
"qrcode-terminal": "0.12.0",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"postpublish": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t alexbosworth/balanceofsatoshis -t alexbosworth/balanceofsatoshis:$npm_package_version --push .",
|
|
83
83
|
"test": "npx nyc@15.1.0 node --experimental-test-coverage --test 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/telegram/*.js test/wallets/*.js"
|
|
84
84
|
},
|
|
85
|
-
"version": "16.0.
|
|
85
|
+
"version": "16.0.2"
|
|
86
86
|
}
|
package/peers/open_channels.js
CHANGED
|
@@ -15,6 +15,7 @@ const asyncRetry = require('async/retry');
|
|
|
15
15
|
const {broadcastChainTransaction} = require('ln-service');
|
|
16
16
|
const {cancelPendingChannel} = require('ln-service');
|
|
17
17
|
const {fundPendingChannels} = require('ln-service');
|
|
18
|
+
const {getChainBalance} = require('ln-service');
|
|
18
19
|
const {getChannels} = require('ln-service');
|
|
19
20
|
const {getFundedTransaction} = require('ln-sync');
|
|
20
21
|
const {getNetwork} = require('ln-sync');
|
|
@@ -53,6 +54,7 @@ const peerAddedDelayMs = 1000 * 5;
|
|
|
53
54
|
const pendingCheckTimes = 60 * 10;
|
|
54
55
|
const per = (a, b) => (a / b).toFixed(2);
|
|
55
56
|
const relockIntervalMs = 1000 * 20;
|
|
57
|
+
const sumOf = arr => arr.reduce((sum, n) => sum + n, 0);
|
|
56
58
|
const times = 10;
|
|
57
59
|
const tokAsBigUnit = tokens => (tokens / 1e8).toFixed(8);
|
|
58
60
|
const uniq = arr => Array.from(new Set(arr));
|
|
@@ -470,8 +472,35 @@ module.exports = (args, cbk) => {
|
|
|
470
472
|
({internal}) => cbk(null, !internal));
|
|
471
473
|
}],
|
|
472
474
|
|
|
475
|
+
// Get the chain balance to see if there is enough available
|
|
476
|
+
getBalance: ['isExternal', ({isExternal}, cbk) => {
|
|
477
|
+
// Exit early when not using internal balance to fund
|
|
478
|
+
if (!!isExternal) {
|
|
479
|
+
return cbk();
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
return getChainBalance({lnd: args.lnd}, cbk);
|
|
483
|
+
}],
|
|
484
|
+
|
|
485
|
+
// Make sure there is enough coins to fund the opens
|
|
486
|
+
checkBalance: ['getBalance', 'opens', ({getBalance, opens}, cbk) => {
|
|
487
|
+
// Exit early when externally funding
|
|
488
|
+
if (!getBalance) {
|
|
489
|
+
return cbk();
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
const capacities = opens.map(n => n.channels.map(n => n.capacity));
|
|
493
|
+
|
|
494
|
+
// Make sure that the chain balance is sufficient
|
|
495
|
+
if (getBalance.chain_balance < sumOf(flatten(capacities))) {
|
|
496
|
+
return cbk([400, 'ExpectedChainBalanceAboveCapacityBeingOpened']);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
return cbk();
|
|
500
|
+
}],
|
|
501
|
+
|
|
473
502
|
// Ask for the fee rate to use for internally funded opens
|
|
474
|
-
askForFeeRate: ['isExternal', ({isExternal}, cbk) => {
|
|
503
|
+
askForFeeRate: ['checkBalance', 'isExternal', ({isExternal}, cbk) => {
|
|
475
504
|
// Exit early when there are no internal funds being spent or internal fee rate is specified
|
|
476
505
|
if (!!isExternal || !!args.internal_fund_fee_rate) {
|
|
477
506
|
return cbk(null, {});
|
|
@@ -484,6 +513,7 @@ module.exports = (args, cbk) => {
|
|
|
484
513
|
openChannels: [
|
|
485
514
|
'askForFeeRate',
|
|
486
515
|
'capacities',
|
|
516
|
+
'checkBalance',
|
|
487
517
|
'connect',
|
|
488
518
|
'getLnds',
|
|
489
519
|
'getNodes',
|