balanceofsatoshis 11.43.0 → 11.44.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 +4 -0
- package/bos +2 -0
- package/network/push_payment.js +16 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/bos
CHANGED
|
@@ -1464,6 +1464,7 @@ prog
|
|
|
1464
1464
|
.option('--dryrun', 'Avoid actually sending funds')
|
|
1465
1465
|
.option('--in <pubkey_or_alias>', 'Route in through a specific node')
|
|
1466
1466
|
.option('--max-fee <fee>', 'Maximum fee tokens', INT, 1337)
|
|
1467
|
+
.option('--max-fee-rate <max_fee_rate>', 'Max fee rate in PPM to pay', INT)
|
|
1467
1468
|
.option('--message <message>', 'Message to include with payment')
|
|
1468
1469
|
.option('--message-omit-from-key', 'Leave out the from key on messages')
|
|
1469
1470
|
.option('--no-color', 'Mute all colors')
|
|
@@ -1484,6 +1485,7 @@ prog
|
|
|
1484
1485
|
is_omitting_message_from: options.messageOmitFromKey,
|
|
1485
1486
|
lnd: (await lndForNode(logger, options.node)).lnd,
|
|
1486
1487
|
max_fee: options.maxFee,
|
|
1488
|
+
max_fee_rate: options.maxFeeRate,
|
|
1487
1489
|
message: options.message,
|
|
1488
1490
|
quiz_answers: flatten([options.quiz].filter(n => !!n)),
|
|
1489
1491
|
out_through: options.out,
|
package/network/push_payment.js
CHANGED
|
@@ -16,6 +16,7 @@ const probeDestination = require('./probe_destination');
|
|
|
16
16
|
|
|
17
17
|
const coins = ['BTC', 'LTC'];
|
|
18
18
|
const defaultFiatRateProvider = 'coingecko';
|
|
19
|
+
const feeTokensForFeeRate = (tokens, rate) => Math.floor(rate * tokens / 1e6);
|
|
19
20
|
const fiats = ['EUR', 'USD'];
|
|
20
21
|
const hasFiat = n => /(eur|usd)/gim.test(n);
|
|
21
22
|
const {isArray} = Array;
|
|
@@ -23,6 +24,7 @@ const isPublicKey = n => /^[0-9A-F]{66}$/i.test(n);
|
|
|
23
24
|
const maxQuizLength = 10;
|
|
24
25
|
const rateAsTokens = rate => 1e8 / rate;
|
|
25
26
|
const sumOf = arr => arr.reduce((sum, n) => sum + n, Number());
|
|
27
|
+
const {min} = Math;
|
|
26
28
|
const minQuiz = 2;
|
|
27
29
|
const minTokens = 1;
|
|
28
30
|
const networks = {btc: 'BTC', btctestnet: 'BTC', ltc: 'LTC'};
|
|
@@ -45,6 +47,7 @@ const utf8AsHex = n => Buffer.from(n, 'utf8').toString('hex');
|
|
|
45
47
|
lnd: <Authenticated LND API Object>
|
|
46
48
|
logger: <Winston Logger Object>
|
|
47
49
|
max_fee: <Maximum Fee Tokens Number>
|
|
50
|
+
[max_fee_rate]: <Max Fee Rate Tokens Per Million Number>
|
|
48
51
|
[message]: <Message to Include With Payment String>
|
|
49
52
|
[out_through]: <Pay Out Through Peer String>
|
|
50
53
|
quiz_answers: [<Quiz Answer String>]
|
|
@@ -346,7 +349,18 @@ module.exports = (args, cbk) => {
|
|
|
346
349
|
};
|
|
347
350
|
|
|
348
351
|
try {
|
|
349
|
-
|
|
352
|
+
const {tokens} = parseAmount({variables, amount: args.amount});
|
|
353
|
+
|
|
354
|
+
// Exit early when there is no max fee rate to compute max fee for
|
|
355
|
+
if (!!args.max_fee_rate === undefined) {
|
|
356
|
+
return cbk(null, {tokens, max_fee: args.mage_fee});
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// Compute the max potential fee given the max fee rate constraint
|
|
360
|
+
const maxFeeByRate = feeTokensForFeeRate(tokens, args.max_fee_rate);
|
|
361
|
+
|
|
362
|
+
// The maximum fee to pay is the lower of the fee limit, fee by rate
|
|
363
|
+
return cbk(null, {tokens, max_fee: min(args.max_fee, maxFeeByRate)});
|
|
350
364
|
} catch (err) {
|
|
351
365
|
return cbk([400, 'FailedToParsePushAmount', err]);
|
|
352
366
|
}
|
|
@@ -384,7 +398,7 @@ module.exports = (args, cbk) => {
|
|
|
384
398
|
is_omitting_message_from: args.is_omitting_message_from,
|
|
385
399
|
is_push: payment.is_push,
|
|
386
400
|
is_real_payment: true,
|
|
387
|
-
max_fee:
|
|
401
|
+
max_fee: parseAmount.max_fee,
|
|
388
402
|
message: args.message,
|
|
389
403
|
messages: args.quiz_answers.map((answer, i) => ({
|
|
390
404
|
type: (quizStart + i).toString(),
|
package/package.json
CHANGED
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"postpublish": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t alexbosworth/balanceofsatoshis --push .",
|
|
82
82
|
"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
83
|
},
|
|
84
|
-
"version": "11.
|
|
84
|
+
"version": "11.44.0"
|
|
85
85
|
}
|