balanceofsatoshis 13.1.7 → 13.3.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 +8 -0
- package/bos +2 -1
- package/chain/fund_transaction.js +1 -2
- package/display/index.js +0 -2
- package/network/probe.js +1 -1
- package/network/push_payment.js +1 -1
- package/network/transfer_funds.js +1 -1
- package/package.json +3 -3
- package/peers/open_channels.js +1 -1
- package/swaps/rebalance.js +1 -1
- package/telegram/start_telegram_bot.js +2 -0
- package/display/parse_amount.js +0 -76
- package/test/display/test_parse_amount.js +0 -55
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 13.3.0
|
|
4
|
+
|
|
5
|
+
- `telegram`: Support multiple word queries in /graph and /liquidity
|
|
6
|
+
|
|
7
|
+
## 13.2.0
|
|
8
|
+
|
|
9
|
+
- `telegram`: Support formulas in /invoice command, including *USD and *EUR
|
|
10
|
+
|
|
3
11
|
## 13.1.7
|
|
4
12
|
|
|
5
13
|
- `open-group-channel`: Fix support for LND 0.15.3 when using P2TR inputs
|
package/bos
CHANGED
|
@@ -11,6 +11,7 @@ const {writeFile} = require('fs');
|
|
|
11
11
|
|
|
12
12
|
const importLazy = require('import-lazy')(require);
|
|
13
13
|
|
|
14
|
+
const accounting = importLazy('ln-accounting');
|
|
14
15
|
const fetch = importLazy('@alexbosworth/node-fetch');
|
|
15
16
|
const fiat = importLazy('@alexbosworth/fiat');
|
|
16
17
|
const lnService = importLazy('ln-service');
|
|
@@ -1007,7 +1008,7 @@ prog
|
|
|
1007
1008
|
spend_address: options.spendAddress || undefined,
|
|
1008
1009
|
spend_tokens: options.spendAmount || undefined,
|
|
1009
1010
|
timeout: 1000 * 60 * 60 * 10,
|
|
1010
|
-
tokens:
|
|
1011
|
+
tokens: accounting.parseAmount({amount: options.amount}).tokens,
|
|
1011
1012
|
},
|
|
1012
1013
|
responses.returnObject({exit, logger, reject, resolve}));
|
|
1013
1014
|
} catch (err) {
|
|
@@ -10,13 +10,12 @@ const {getMaxFundAmount} = require('ln-sync');
|
|
|
10
10
|
const {getNetwork} = require('ln-sync');
|
|
11
11
|
const {getUtxos} = require('ln-service');
|
|
12
12
|
const {networks} = require('bitcoinjs-lib');
|
|
13
|
+
const {parseAmount} = require('ln-accounting');
|
|
13
14
|
const {returnResult} = require('asyncjs-util');
|
|
14
15
|
const {signPsbt} = require('ln-service');
|
|
15
16
|
const {Transaction} = require('bitcoinjs-lib');
|
|
16
17
|
const {unlockUtxo} = require('ln-service');
|
|
17
18
|
|
|
18
|
-
const {parseAmount} = require('./../display');
|
|
19
|
-
|
|
20
19
|
const asBigUnit = n => (n / 1e8).toFixed(8);
|
|
21
20
|
const asOutpoint = utxo => `${utxo.transaction_id}:${utxo.transaction_vout}`;
|
|
22
21
|
const asInput = n => ({transaction_id: n.id, transaction_vout: n.vout});
|
package/display/index.js
CHANGED
|
@@ -6,7 +6,6 @@ const describeRoutingFailure = require('./describe_routing_failure');
|
|
|
6
6
|
const formatFeeRate = require('./format_fee_rate');
|
|
7
7
|
const getIcons = require('./get_icons');
|
|
8
8
|
const isMatchingFilters = require('./is_matching_filters');
|
|
9
|
-
const parseAmount = require('./parse_amount');
|
|
10
9
|
const segmentMeasure = require('./segment_measure');
|
|
11
10
|
const sumsForSegment = require('./sums_for_segment');
|
|
12
11
|
|
|
@@ -19,7 +18,6 @@ module.exports = {
|
|
|
19
18
|
formatFeeRate,
|
|
20
19
|
getIcons,
|
|
21
20
|
isMatchingFilters,
|
|
22
|
-
parseAmount,
|
|
23
21
|
segmentMeasure,
|
|
24
22
|
sumsForSegment,
|
|
25
23
|
};
|
package/network/probe.js
CHANGED
|
@@ -9,6 +9,7 @@ const {getIdentity} = require('ln-service');
|
|
|
9
9
|
const {getNode} = require('ln-service');
|
|
10
10
|
const {getSyntheticOutIgnores} = require('probing');
|
|
11
11
|
const {getWalletVersion} = require('ln-service');
|
|
12
|
+
const {parseAmount} = require('ln-accounting');
|
|
12
13
|
const {parsePaymentRequest} = require('ln-service');
|
|
13
14
|
const {returnResult} = require('asyncjs-util');
|
|
14
15
|
const {subscribeToMultiPathProbe} = require('probing');
|
|
@@ -17,7 +18,6 @@ const {describeRoute} = require('./../display');
|
|
|
17
18
|
const {describeRoutingFailure} = require('./../display');
|
|
18
19
|
const {getIgnores} = require('./../routing');
|
|
19
20
|
const {getTags} = require('./../tags');
|
|
20
|
-
const {parseAmount} = require('./../display');
|
|
21
21
|
const probeDestination = require('./probe_destination');
|
|
22
22
|
|
|
23
23
|
const defaultFinalCltvDelta = 144;
|
package/network/push_payment.js
CHANGED
|
@@ -6,13 +6,13 @@ const {getIdentity} = require('ln-service');
|
|
|
6
6
|
const {getNetwork} = require('ln-sync');
|
|
7
7
|
const {getPeerLiquidity} = require('ln-sync');
|
|
8
8
|
const {getPrices} = require('@alexbosworth/fiat');
|
|
9
|
+
const {parseAmount} = require('ln-accounting');
|
|
9
10
|
const {parsePaymentRequest} = require('ln-service');
|
|
10
11
|
const {returnResult} = require('asyncjs-util');
|
|
11
12
|
|
|
12
13
|
const {getIgnores} = require('./../routing');
|
|
13
14
|
const getLnurlRequest = require('./../lnurl/get_lnurl_request');
|
|
14
15
|
const {getTags} = require('./../tags');
|
|
15
|
-
const {parseAmount} = require('./../display');
|
|
16
16
|
const parseUrl = require('./../lnurl/parse_url');
|
|
17
17
|
const probeDestination = require('./probe_destination');
|
|
18
18
|
|
|
@@ -5,9 +5,9 @@ const {formatTokens} = require('ln-sync');
|
|
|
5
5
|
const {getChannels} = require('ln-service');
|
|
6
6
|
const {getIdentity} = require('ln-service');
|
|
7
7
|
const {getPeerLiquidity} = require('ln-sync');
|
|
8
|
+
const {parseAmount} = require('ln-accounting');
|
|
8
9
|
const {returnResult} = require('asyncjs-util');
|
|
9
10
|
|
|
10
|
-
const {parseAmount} = require('./../display');
|
|
11
11
|
const probeDestination = require('./probe_destination');
|
|
12
12
|
|
|
13
13
|
const defaultDescription = 'bos transfer between saved nodes';
|
package/package.json
CHANGED
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"import-lazy": "4.0.0",
|
|
36
36
|
"ini": "3.0.1",
|
|
37
37
|
"inquirer": "9.1.4",
|
|
38
|
-
"ln-accounting": "6.
|
|
38
|
+
"ln-accounting": "6.1.0",
|
|
39
39
|
"ln-service": "54.2.3",
|
|
40
40
|
"ln-sync": "4.0.4",
|
|
41
|
-
"ln-telegram": "4.
|
|
41
|
+
"ln-telegram": "4.2.0",
|
|
42
42
|
"moment": "2.29.4",
|
|
43
43
|
"paid-services": "4.0.1",
|
|
44
44
|
"probing": "2.0.6",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"postpublish": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t alexbosworth/balanceofsatoshis --push .",
|
|
84
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/telegram/*.js test/wallets/*.js"
|
|
85
85
|
},
|
|
86
|
-
"version": "13.
|
|
86
|
+
"version": "13.3.0"
|
|
87
87
|
}
|
package/peers/open_channels.js
CHANGED
|
@@ -25,6 +25,7 @@ const {getWalletVersion} = require('ln-service');
|
|
|
25
25
|
const {openChannels} = require('ln-service');
|
|
26
26
|
const {maintainUtxoLocks} = require('ln-sync');
|
|
27
27
|
const moment = require('moment');
|
|
28
|
+
const {parseAmount} = require('ln-accounting');
|
|
28
29
|
const {returnResult} = require('asyncjs-util');
|
|
29
30
|
const {Transaction} = require('bitcoinjs-lib');
|
|
30
31
|
const {unlockUtxo} = require('ln-service');
|
|
@@ -34,7 +35,6 @@ const {authenticatedLnd} = require('./../lnd');
|
|
|
34
35
|
const channelsFromArguments = require('./channels_from_arguments');
|
|
35
36
|
const {getAddressUtxo} = require('./../chain');
|
|
36
37
|
const getChannelOutpoints = require('./get_channel_outpoints');
|
|
37
|
-
const {parseAmount} = require('./../display');
|
|
38
38
|
|
|
39
39
|
const bech32AsData = bech32 => address.fromBech32(bech32).data;
|
|
40
40
|
const description = 'bos open';
|
package/swaps/rebalance.js
CHANGED
|
@@ -12,6 +12,7 @@ const {getNode} = require('ln-service');
|
|
|
12
12
|
const {getPeerLiquidity} = require('ln-sync');
|
|
13
13
|
const {getRouteThroughHops} = require('ln-service');
|
|
14
14
|
const {getWalletVersion} = require('ln-service');
|
|
15
|
+
const {parseAmount} = require('ln-accounting');
|
|
15
16
|
const {payViaRoutes} = require('ln-service');
|
|
16
17
|
const {returnResult} = require('asyncjs-util');
|
|
17
18
|
const {routeFromChannels} = require('ln-service');
|
|
@@ -20,7 +21,6 @@ const {findTagMatch} = require('./../peers');
|
|
|
20
21
|
const {formatFeeRate} = require('./../display');
|
|
21
22
|
const {getIgnores} = require('./../routing');
|
|
22
23
|
const {homePath} = require('../storage');
|
|
23
|
-
const {parseAmount} = require('./../display');
|
|
24
24
|
const {probeDestination} = require('./../network');
|
|
25
25
|
const {sortBy} = require('./../arrays');
|
|
26
26
|
|
|
@@ -288,6 +288,7 @@ module.exports = (args, cbk) => {
|
|
|
288
288
|
ctx,
|
|
289
289
|
id: connectedId,
|
|
290
290
|
nodes: (await getLnds(args.logger, names, args.nodes)).nodes,
|
|
291
|
+
request: args.request,
|
|
291
292
|
});
|
|
292
293
|
} catch (err) {
|
|
293
294
|
args.logger.error({err});
|
|
@@ -467,6 +468,7 @@ module.exports = (args, cbk) => {
|
|
|
467
468
|
api: args.bot.api,
|
|
468
469
|
id: connectedId,
|
|
469
470
|
nodes: (await getLnds(args.logger, names, args.nodes)).nodes,
|
|
471
|
+
request: args.request,
|
|
470
472
|
});
|
|
471
473
|
} catch (err) {
|
|
472
474
|
args.logger.error({err});
|
package/display/parse_amount.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
const {Parser} = require('hot-formula-parser');
|
|
2
|
-
|
|
3
|
-
const {ceil} = Math;
|
|
4
|
-
const {isArray} = Array;
|
|
5
|
-
const {keys} = Object;
|
|
6
|
-
const {round} = Math;
|
|
7
|
-
|
|
8
|
-
/** Parse a described amount into tokens
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
amount: <Amount String>
|
|
12
|
-
[variables]: {
|
|
13
|
-
<Name String>: <Amount Number>
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
@throws
|
|
18
|
-
<Error>
|
|
19
|
-
|
|
20
|
-
@returns
|
|
21
|
-
{
|
|
22
|
-
tokens: <Tokens Number>
|
|
23
|
-
}
|
|
24
|
-
*/
|
|
25
|
-
module.exports = ({amount, variables}) => {
|
|
26
|
-
if (isArray(amount)) {
|
|
27
|
-
throw new Error('CannotParseMultipleAmounts');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const parser = new Parser();
|
|
31
|
-
|
|
32
|
-
keys(variables || {}).forEach(key => {
|
|
33
|
-
parser.setVariable(key.toLowerCase(), variables[key]);
|
|
34
|
-
parser.setVariable(key.toUpperCase(), variables[key]);
|
|
35
|
-
|
|
36
|
-
return;
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
parser.setVariable('BTC', 1e8);
|
|
40
|
-
parser.setVariable('btc', 1e8);
|
|
41
|
-
parser.setVariable('m', 1e6);
|
|
42
|
-
parser.setVariable('M', 1e6);
|
|
43
|
-
parser.setVariable('mm', 1e6);
|
|
44
|
-
parser.setVariable('MM', 1e6);
|
|
45
|
-
parser.setVariable('k', 1e3);
|
|
46
|
-
parser.setVariable('K', 1e3);
|
|
47
|
-
|
|
48
|
-
const parsed = parser.parse(amount);
|
|
49
|
-
|
|
50
|
-
switch (parsed.error) {
|
|
51
|
-
case '#DIV/0!':
|
|
52
|
-
throw new Error('CannotDivideByZeroInSpecifiedAmount');
|
|
53
|
-
|
|
54
|
-
case '#ERROR!':
|
|
55
|
-
throw new Error('FailedToParseSpecifiedAmount');
|
|
56
|
-
|
|
57
|
-
case '#N/A':
|
|
58
|
-
case '#NAME?':
|
|
59
|
-
throw new Error('UnrecognizedVariableOrFunctionInSpecifiedAmount');
|
|
60
|
-
|
|
61
|
-
case '#NUM!':
|
|
62
|
-
throw new Error('InvalidNumberFoundInSpecifiedAmount');
|
|
63
|
-
|
|
64
|
-
case '#VALUE!':
|
|
65
|
-
throw new Error('UnexpectedValueTypeInSpecifiedAmount');
|
|
66
|
-
|
|
67
|
-
default:
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!!parsed.error) {
|
|
72
|
-
throw new Error(parsed.error);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return {tokens: round(parsed.result)};
|
|
76
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const {test} = require('@alexbosworth/tap');
|
|
2
|
-
|
|
3
|
-
const {parseAmount} = require('./../../display');
|
|
4
|
-
|
|
5
|
-
const tests = [
|
|
6
|
-
{
|
|
7
|
-
args: {amount: 'amount'},
|
|
8
|
-
description: 'A value is required',
|
|
9
|
-
error: 'UnrecognizedVariableOrFunctionInSpecifiedAmount',
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
args: {amount: '1/0'},
|
|
13
|
-
description: 'Dividing by zero is not allowed',
|
|
14
|
-
error: 'CannotDivideByZeroInSpecifiedAmount',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
args: {amount: '0.0.0'},
|
|
18
|
-
description: 'A generic invalid amount is rejected',
|
|
19
|
-
error: 'FailedToParseSpecifiedAmount',
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
args: {amount: 'OCT2DEC()'},
|
|
23
|
-
description: 'Invalid numbers are rejected',
|
|
24
|
-
error: 'InvalidNumberFoundInSpecifiedAmount',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
args: {amount: '"string" + 1'},
|
|
28
|
-
description: 'Invalid formulas are rejected',
|
|
29
|
-
error: 'UnexpectedValueTypeInSpecifiedAmount',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
args: {amount: '1.20969468*btc', variables: {variable: 'value'}},
|
|
33
|
-
description: 'A long precision BTC value is parsed',
|
|
34
|
-
expected: {tokens: 120969468},
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
args: {amount: '1.20969465*btc'},
|
|
38
|
-
description: 'A long precision BTC value that rounds down is parsed',
|
|
39
|
-
expected: {tokens: 120969465},
|
|
40
|
-
},
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
tests.forEach(({args, description, error, expected}) => {
|
|
44
|
-
return test(description, ({end, equal, throws}) => {
|
|
45
|
-
if (!!error) {
|
|
46
|
-
throws(() => parseAmount(args), new Error(error), 'Got expected error');
|
|
47
|
-
} else {
|
|
48
|
-
const {tokens} = parseAmount(args);
|
|
49
|
-
|
|
50
|
-
equal(tokens, expected.tokens, 'Got expected output');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return end();
|
|
54
|
-
});
|
|
55
|
-
});
|