Skip to content

Commit

Permalink
Merge pull request #189 from Roasbeef/list-peers-features
Browse files Browse the repository at this point in the history
lndclient: expose feature bits for ListPeers resp
  • Loading branch information
guggero authored Jul 23, 2024
2 parents 4ce52a1 + 5bdea63 commit 8c4e702
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lightning_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func WithRemoteReserve(reserve uint64) OpenChannelOption {
return func(r *lnrpc.OpenChannelRequest) {
r.RemoteChanReserveSat = reserve
}

}

// LightningClient exposes base lightning functionality.
Expand Down Expand Up @@ -839,6 +838,9 @@ type Peer struct {

// Received is the total amount we have received from this peer.
Received btcutil.Amount

// Features is the set of the features supported by the node.
Features *lnwire.FeatureVector
}

// ChannelBalance contains information about our channel balances.
Expand Down Expand Up @@ -3358,6 +3360,18 @@ func (s *lightningClient) ListPeers(ctx context.Context) ([]Peer,

pingTime := time.Microsecond * time.Duration(peer.PingTime)

var featureBits []lnwire.FeatureBit
for rpcBit := range peer.Features {
featureBits = append(
featureBits, lnwire.FeatureBit(rpcBit),
)
}

peerFeatures := lnwire.NewFeatureVector(
lnwire.NewRawFeatureVector(featureBits...),
lnwire.Features,
)

peers[i] = Peer{
Pubkey: pk,
Address: peer.Address,
Expand All @@ -3367,6 +3381,7 @@ func (s *lightningClient) ListPeers(ctx context.Context) ([]Peer,
PingTime: pingTime,
Sent: btcutil.Amount(peer.SatSent),
Received: btcutil.Amount(peer.SatRecv),
Features: peerFeatures,
}
}

Expand Down

0 comments on commit 8c4e702

Please sign in to comment.