@@ -1585,13 +1585,13 @@ var forwardingHistoryCommand = cli.Command{
15851585 Usage : "skip the peer alias lookup per forwarding " +
15861586 "event in order to improve performance" ,
15871587 },
1588- cli.Int64SliceFlag {
1588+ cli.StringSliceFlag {
15891589 Name : "incoming_chan_ids" ,
15901590 Usage : "the short channel id of the incoming " +
15911591 "channel to filter events by; can be " +
15921592 "specified multiple times in the same command" ,
15931593 },
1594- cli.Int64SliceFlag {
1594+ cli.StringSliceFlag {
15951595 Name : "outgoing_chan_ids" ,
15961596 Usage : "the short channel id of the outgoing " +
15971597 "channel to filter events by; can be " +
@@ -1677,21 +1677,19 @@ func forwardingHistory(ctx *cli.Context) error {
16771677 NumMaxEvents : maxEvents ,
16781678 PeerAliasLookup : lookupPeerAlias ,
16791679 }
1680- outgoingChannelIDs := ctx .Int64Slice ("outgoing_chan_ids" )
1681- if len (outgoingChannelIDs ) != 0 {
1682- req .OutgoingChanIds = make ([]uint64 , len (outgoingChannelIDs ))
1683- for i , c := range outgoingChannelIDs {
1684- req .OutgoingChanIds [i ] = uint64 (c )
1685- }
1680+
1681+ outgoingChannelIDs := ctx .StringSlice ("outgoing_chan_ids" )
1682+ req .OutgoingChanIds , err = parseChanIDs (outgoingChannelIDs )
1683+ if err != nil {
1684+ return fmt .Errorf ("unable to decode outgoing_chan_ids: %w" , err )
16861685 }
16871686
1688- incomingChannelIDs := ctx .Int64Slice ("incoming_chan_ids" )
1689- if len (incomingChannelIDs ) != 0 {
1690- req .IncomingChanIds = make ([]uint64 , len (incomingChannelIDs ))
1691- for i , c := range incomingChannelIDs {
1692- req .IncomingChanIds [i ] = uint64 (c )
1693- }
1687+ incomingChannelIDs := ctx .StringSlice ("incoming_chan_ids" )
1688+ req .IncomingChanIds , err = parseChanIDs (incomingChannelIDs )
1689+ if err != nil {
1690+ return fmt .Errorf ("unable to decode incoming_chan_ids: %w" , err )
16941691 }
1692+
16951693 resp , err := client .ForwardingHistory (ctxc , req )
16961694 if err != nil {
16971695 return err
@@ -2060,3 +2058,24 @@ func ordinalNumber(num uint32) string {
20602058 return fmt .Sprintf ("%dth" , num )
20612059 }
20622060}
2061+
2062+ // parseChanIDs parses a slice of strings containing short channel IDs into a
2063+ // slice of uint64 values.
2064+ func parseChanIDs (idStrings []string ) ([]uint64 , error ) {
2065+ // Return early if no chan IDs are passed.
2066+ if len (idStrings ) == 0 {
2067+ return nil , nil
2068+ }
2069+
2070+ chanIDs := make ([]uint64 , len (idStrings ))
2071+ for i , idStr := range idStrings {
2072+ scid , err := strconv .ParseUint (idStr , 10 , 64 )
2073+ if err != nil {
2074+ return nil , err
2075+ }
2076+
2077+ chanIDs [i ] = scid
2078+ }
2079+
2080+ return chanIDs , nil
2081+ }
0 commit comments