@@ -1585,13 +1585,13 @@ var forwardingHistoryCommand = cli.Command{
1585
1585
Usage : "skip the peer alias lookup per forwarding " +
1586
1586
"event in order to improve performance" ,
1587
1587
},
1588
- cli.Int64SliceFlag {
1588
+ cli.StringSliceFlag {
1589
1589
Name : "incoming_chan_ids" ,
1590
1590
Usage : "the short channel id of the incoming " +
1591
1591
"channel to filter events by; can be " +
1592
1592
"specified multiple times in the same command" ,
1593
1593
},
1594
- cli.Int64SliceFlag {
1594
+ cli.StringSliceFlag {
1595
1595
Name : "outgoing_chan_ids" ,
1596
1596
Usage : "the short channel id of the outgoing " +
1597
1597
"channel to filter events by; can be " +
@@ -1677,21 +1677,29 @@ func forwardingHistory(ctx *cli.Context) error {
1677
1677
NumMaxEvents : maxEvents ,
1678
1678
PeerAliasLookup : lookupPeerAlias ,
1679
1679
}
1680
- outgoingChannelIDs := ctx .Int64Slice ("outgoing_chan_ids" )
1680
+
1681
+ outgoingChannelIDs := ctx .StringSlice ("outgoing_chan_ids" )
1681
1682
if len (outgoingChannelIDs ) != 0 {
1682
- req .OutgoingChanIds = make ([]uint64 , len (outgoingChannelIDs ))
1683
- for i , c := range outgoingChannelIDs {
1684
- req .OutgoingChanIds [i ] = uint64 (c )
1683
+ chanIDs , err := parseChanIDs (outgoingChannelIDs )
1684
+ if err != nil {
1685
+ return fmt .Errorf ("unable to decode " +
1686
+ "outgoing_chan_ids: %w" , err )
1685
1687
}
1688
+
1689
+ req .OutgoingChanIds = chanIDs
1686
1690
}
1687
1691
1688
- incomingChannelIDs := ctx .Int64Slice ("incoming_chan_ids" )
1692
+ incomingChannelIDs := ctx .StringSlice ("incoming_chan_ids" )
1689
1693
if len (incomingChannelIDs ) != 0 {
1690
- req .IncomingChanIds = make ([]uint64 , len (incomingChannelIDs ))
1691
- for i , c := range incomingChannelIDs {
1692
- req .IncomingChanIds [i ] = uint64 (c )
1694
+ chanIDs , err := parseChanIDs (incomingChannelIDs )
1695
+ if err != nil {
1696
+ return fmt .Errorf ("unable to decode " +
1697
+ "incoming_chan_ids: %w" , err )
1693
1698
}
1699
+
1700
+ req .IncomingChanIds = chanIDs
1694
1701
}
1702
+
1695
1703
resp , err := client .ForwardingHistory (ctxc , req )
1696
1704
if err != nil {
1697
1705
return err
@@ -2060,3 +2068,19 @@ func ordinalNumber(num uint32) string {
2060
2068
return fmt .Sprintf ("%dth" , num )
2061
2069
}
2062
2070
}
2071
+
2072
+ // parseChanIDs parses a slice of strings containing short channel IDs into a
2073
+ // slice of uint64 values.
2074
+ func parseChanIDs (idStrings []string ) ([]uint64 , error ) {
2075
+ chanIDs := make ([]uint64 , len (idStrings ))
2076
+ for i , idStr := range idStrings {
2077
+ scid , err := strconv .ParseUint (idStr , 10 , 64 )
2078
+ if err != nil {
2079
+ return nil , err
2080
+ }
2081
+
2082
+ chanIDs [i ] = scid
2083
+ }
2084
+
2085
+ return chanIDs , nil
2086
+ }
0 commit comments