network: pending open channels

pull/1/head
Edouard Paris 5 years ago
parent 1ff207cacf
commit 661aee511f

@ -204,8 +204,17 @@ func (l Backend) ListChannels(ctx context.Context, opt ...options.Channel) ([]*m
channels := listChannelsProtoToChannels(resp)
fields := make([]logging.Field, len(channels))
if opts.Pending {
req := &lnrpc.PendingChannelsRequest{}
resp, err := clt.PendingChannels(ctx, req)
if err != nil {
return nil, errors.WithStack(err)
}
channels = append(channels, pendingChannelsProtoToChannels(resp)...)
}
fields := make([]logging.Field, len(channels))
for i := range channels {
fields[i] = logging.Object(fmt.Sprintf("channel_%d", i), channels[i])
}

@ -102,6 +102,23 @@ func htlcProtoToHTLC(h *lnrpc.HTLC) *models.HTLC {
}
}
func pendingChannelsProtoToChannels(r *lnrpc.PendingChannelsResponse) []*models.Channel {
resp := r.GetPendingOpenChannels()
channels := make([]*models.Channel, len(resp))
for i := range resp {
channels[i] = openingProtoToChannel(resp[i])
}
return channels
}
func openingProtoToChannel(c *lnrpc.PendingChannelsResponse_PendingOpenChannel) *models.Channel {
return &models.Channel{
CommitWeight: c.GetCommitWeight(),
FeePerKiloWeight: c.GetFeePerKw(),
}
}
func payreqProtoToPayReq(h *lnrpc.PayReq, payreq string) *models.PayReq {
if h == nil {
return nil

@ -7,6 +7,11 @@ type ChannelOptions struct {
Inactive bool
Public bool
Private bool
Pending bool
}
func WithChannelPending() Channel {
return func(c *ChannelOptions) { c.Pending = true }
}
func WithChannelPublic(v bool) Channel {

Loading…
Cancel
Save