@@ -118,7 +118,8 @@ type LightningClient interface {
118
118
opts ... ListTransactionsOption ) ([]Transaction , error )
119
119
120
120
// ListChannels retrieves all channels of the backing lnd node.
121
- ListChannels (ctx context.Context , activeOnly , publicOnly bool ) ([]ChannelInfo , error )
121
+ ListChannels (ctx context.Context , activeOnly , publicOnly bool ,
122
+ opts ... ListChannelsOption ) ([]ChannelInfo , error )
122
123
123
124
// PendingChannels returns a list of lnd's pending channels.
124
125
PendingChannels (ctx context.Context ) (* PendingChannels , error )
@@ -1964,19 +1965,35 @@ func unmarshallTransaction(rpcTx *lnrpc.Transaction) (Transaction, error) {
1964
1965
}, nil
1965
1966
}
1966
1967
1968
+ // ListChannelsOption is a functional type for an option that modifies a
1969
+ // ListChannelsRequest.
1970
+ type ListChannelsOption func (r * lnrpc.ListChannelsRequest )
1971
+
1972
+ // WithPeer is an option for setting the account on a ListChannelsRequest.
1973
+ func WithPeer (peer []byte ) ListChannelsOption {
1974
+ return func (r * lnrpc.ListChannelsRequest ) {
1975
+ r .Peer = peer
1976
+ }
1977
+ }
1978
+
1967
1979
// ListChannels retrieves all channels of the backing lnd node.
1968
1980
func (s * lightningClient ) ListChannels (ctx context.Context , activeOnly ,
1969
- publicOnly bool ) ([]ChannelInfo , error ) {
1981
+ publicOnly bool , opts ... ListChannelsOption ) ([]ChannelInfo , error ) {
1970
1982
1971
1983
rpcCtx , cancel := context .WithTimeout (ctx , s .timeout )
1972
1984
defer cancel ()
1973
1985
1986
+ request := & lnrpc.ListChannelsRequest {
1987
+ ActiveOnly : activeOnly ,
1988
+ PublicOnly : publicOnly ,
1989
+ }
1990
+
1991
+ for _ , opt := range opts {
1992
+ opt (request )
1993
+ }
1994
+
1974
1995
response , err := s .client .ListChannels (
1975
- s .adminMac .WithMacaroonAuth (rpcCtx ),
1976
- & lnrpc.ListChannelsRequest {
1977
- ActiveOnly : activeOnly ,
1978
- PublicOnly : publicOnly ,
1979
- },
1996
+ s .adminMac .WithMacaroonAuth (rpcCtx ), request ,
1980
1997
)
1981
1998
if err != nil {
1982
1999
return nil , err
0 commit comments