balanceofsatoshis 11.36.3 → 11.37.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/package.json +1 -1
- package/services/advertise.js +11 -0
package/CHANGELOG.md
CHANGED
package/bos
CHANGED
|
@@ -98,6 +98,7 @@ prog
|
|
|
98
98
|
.help('use --filter conditions to limit broadcast scope: capacity > 1*m')
|
|
99
99
|
.help('--filter variables: CAPACITY/CHANNELS_COUNT/K/M')
|
|
100
100
|
.help('Default filter scope: channels_count > 9')
|
|
101
|
+
.option('--budget <budget>', 'Spending amount to allow for advertising', INT)
|
|
101
102
|
.option('--dryrun', 'Avoid actually sending advertisements')
|
|
102
103
|
.option('--filter <expression>', 'Require node match condition', REPEATABLE)
|
|
103
104
|
.option('--message <message>', 'Custom advertisement message')
|
|
@@ -107,6 +108,7 @@ prog
|
|
|
107
108
|
try {
|
|
108
109
|
return await services.advertise({
|
|
109
110
|
logger,
|
|
111
|
+
budget: options.budget || undefined,
|
|
110
112
|
filters: flatten([options.filter].filter(n => !!n)),
|
|
111
113
|
is_dry_run: !!options.dryrun,
|
|
112
114
|
lnd: (await lndForNode(logger, options.node)).lnd,
|
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.37.0"
|
|
85
85
|
}
|
package/services/advertise.js
CHANGED
|
@@ -164,11 +164,22 @@ module.exports = (args, cbk) => {
|
|
|
164
164
|
|
|
165
165
|
// Send message to nodes
|
|
166
166
|
send: ['message', 'nodes', ({message, nodes}, cbk) => {
|
|
167
|
+
const maxSpendPerNode = sendTokens + maxFeeTokens;
|
|
167
168
|
const sent = [];
|
|
168
169
|
|
|
169
170
|
args.logger.info({routable_nodes: nodes.length});
|
|
170
171
|
|
|
171
172
|
return asyncMapSeries(nodes, (node, cbk) => {
|
|
173
|
+
const paidTokens = ceil(Number(sent.reduce((sum, n) => {
|
|
174
|
+
return sum + BigInt(n.mtokens) + BigInt(n.fee_mtokens);
|
|
175
|
+
},
|
|
176
|
+
BigInt(Number()))) / mtokPerToken);
|
|
177
|
+
|
|
178
|
+
// Check that the potential next ad would not go over budget
|
|
179
|
+
if (!!args.budget && paidTokens + maxSpendPerNode > args.budget) {
|
|
180
|
+
return cbk([400, 'AdvertisingBudgetExhausted']);
|
|
181
|
+
}
|
|
182
|
+
|
|
172
183
|
const probe = subscribeToProbeForRoute({
|
|
173
184
|
cltv_delay: cltvDelay,
|
|
174
185
|
destination: node.public_key,
|