mirror of
https://github.com/alexbosworth/balanceofsatoshis.git
synced 2026-08-13 12:33:37 +02:00
add tag support to forwards
This commit is contained in:
parent
00ea934ad2
commit
6cb426d57f
3 changed files with 29 additions and 0 deletions
|
|
@ -1,5 +1,9 @@
|
|||
# Versions
|
||||
|
||||
## 12.33.0
|
||||
|
||||
- `forwards`: Add support for `tag` filters to show forwards from alias'd peers
|
||||
|
||||
## 12.32.0
|
||||
|
||||
- `inbound-channel-rules`: Add support for `PRIVATE` variable in rule formulas
|
||||
|
|
|
|||
2
bos
2
bos
|
|
@ -694,6 +694,7 @@ prog
|
|||
.option('--node <node_name>', 'Node to get forwards for')
|
||||
.option('--out <to>', 'Forwards that sent out to a specified peer')
|
||||
.option('--sort <type>', 'Sort forward-active peers by earnings/liquidity')
|
||||
.option('--tag <tag_name>', 'Only show peers in a tag', REPEATABLE)
|
||||
.action((args, options, logger) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
|
|
@ -708,6 +709,7 @@ prog
|
|||
is_monochrome: !!options.noColor,
|
||||
is_table: !options.complete,
|
||||
sort: options.sort || undefined,
|
||||
tags: collect(options.tag),
|
||||
to: (await lnSync.findKey({lnd, query: options.out})).public_key,
|
||||
},
|
||||
responses.returnObject({logger, reject, resolve, table}));
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ const isRelevantForward = require('./is_relevant_forward');
|
|||
const isRelevantSource = require('./is_relevant_source');
|
||||
const {lndCredentials} = require('./../lnd');
|
||||
|
||||
const {isArray} = Array;
|
||||
const lastTime = times => !times.length ? null : new Date(max(...times));
|
||||
const limit = 99999;
|
||||
const {max} = Math;
|
||||
|
|
@ -45,6 +46,7 @@ const wideSizeCols = 155;
|
|||
[is_table]: <Return Results As Table Bool>
|
||||
lnd: <Authenticated LND API Object>
|
||||
[sort]: <Sort By Field String>
|
||||
[tags]: [<Tag Identifier String>]
|
||||
}
|
||||
|
||||
@returns via cbk or Promise
|
||||
|
|
@ -80,6 +82,10 @@ module.exports = (args, cbk) => {
|
|||
return cbk([400, 'ExpectedKnownSortToSortForwards', {sorts}]);
|
||||
}
|
||||
|
||||
if (!isArray(args.tags)) {
|
||||
return cbk([400, 'ExpectedArrayOfTagsToGetForwardingRecords']);
|
||||
}
|
||||
|
||||
return cbk();
|
||||
},
|
||||
|
||||
|
|
@ -313,6 +319,23 @@ module.exports = (args, cbk) => {
|
|||
})
|
||||
.filter(peer => {
|
||||
return peer.earned_inbound_fees || peer.earned_outbound_fees;
|
||||
})
|
||||
.filter(peer => {
|
||||
// Exit early when there is no tag filter
|
||||
if (!args.tags.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const {nodes} = getIcons;
|
||||
|
||||
const node = nodes.find(n => n.public_key === peer.public_key);
|
||||
|
||||
// Exit early when there is no matching tagged node
|
||||
if (!node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!args.tags.find(tag => node.aliases.includes(tag));
|
||||
});
|
||||
|
||||
return cbk(null, {peers: sorted});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue