lnrpc: add filters to forwardhistoryrequest
This commit adds incoming and outgoing channel ids filter to forwarding history request to filter events received/forwarded from/to a particular channel
This commit is contained in:
1 parent
92a5d35cff
commit
bfe1edf4ec
8 files changed
+1089
-815
No files matched your search
@@ -1521,10 +1521,11 @@ func listPayments(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
var forwardingHistoryCommand = cli.Command{
|
||||
Name: "fwdinghistory",
|
||||
Category: "Payments",
|
||||
Usage: "Query the history of all forwarded HTLCs.",
|
||||
ArgsUsage: "start_time [end_time] [index_offset] [max_events]",
|
||||
Name: "fwdinghistory",
|
||||
Category: "Payments",
|
||||
Usage: "Query the history of all forwarded HTLCs.",
|
||||
ArgsUsage: "start_time [end_time] [index_offset] [max_events]" +
|
||||
"[--incoming_channel_ids] [--outgoing_channel_ids]",
|
||||
Description: `
|
||||
Query the HTLC switch's internal forwarding log for all completed
|
||||
payment circuits (HTLCs) over a particular time range (--start_time and
|
||||
@@ -1539,6 +1540,9 @@ var forwardingHistoryCommand = cli.Command{
|
||||
The max number of events returned is 50k. The default number is 100,
|
||||
callers can use the --max_events param to modify this value.
|
||||
|
||||
Incoming and outgoing channel IDs can be provided to further filter
|
||||
the events. If not provided, all events will be returned.
|
||||
|
||||
Finally, callers can skip a series of events using the --index_offset
|
||||
parameter. Each response will contain the offset index of the last
|
||||
entry. Using this callers can manually paginate within a time slice.
|
||||
@@ -1567,6 +1571,18 @@ var forwardingHistoryCommand = cli.Command{
|
||||
Usage: "skip the peer alias lookup per forwarding " +
|
||||
"event in order to improve performance",
|
||||
},
|
||||
cli.Int64SliceFlag{
|
||||
Name: "incoming_chan_ids",
|
||||
Usage: "the short channel id of the incoming " +
|
||||
"channel to filter events by; can be " +
|
||||
"specified multiple times in the same command",
|
||||
},
|
||||
cli.Int64SliceFlag{
|
||||
Name: "outgoing_chan_ids",
|
||||
Usage: "the short channel id of the outgoing " +
|
||||
"channel to filter events by; can be " +
|
||||
"specified multiple times in the same command",
|
||||
},
|
||||
},
|
||||
Action: actionDecorator(forwardingHistory),
|
||||
}
|
||||
@@ -1647,6 +1663,21 @@ func forwardingHistory(ctx *cli.Context) error {
|
||||
NumMaxEvents: maxEvents,
|
||||
PeerAliasLookup: lookupPeerAlias,
|
||||
}
|
||||
outgoingChannelIDs := ctx.Int64Slice("outgoing_chan_ids")
|
||||
if len(outgoingChannelIDs) != 0 {
|
||||
req.OutgoingChanIds = make([]uint64, len(outgoingChannelIDs))
|
||||
for i, c := range outgoingChannelIDs {
|
||||
req.OutgoingChanIds[i] = uint64(c)
|
||||
}
|
||||
}
|
||||
|
||||
incomingChannelIDs := ctx.Int64Slice("incoming_chan_ids")
|
||||
if len(incomingChannelIDs) != 0 {
|
||||
req.IncomingChanIds = make([]uint64, len(incomingChannelIDs))
|
||||
for i, c := range incomingChannelIDs {
|
||||
req.IncomingChanIds[i] = uint64(c)
|
||||
}
|
||||
}
|
||||
resp, err := client.ForwardingHistory(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user