network: GetChannelInfo

pull/1/head
Edouard Paris 5 years ago
parent 0948674486
commit 578d113902

@ -22,6 +22,8 @@ type Backend interface {
ListChannels(context.Context, ...options.Channel) ([]*models.Channel, error)
GetChannelInfo(context.Context, *models.Channel) error
CreateInvoice(context.Context, int64, string) (*models.Invoice, error)
GetInvoice(context.Context, string) (*models.Invoice, error)

@ -206,6 +206,30 @@ func (l Backend) ListChannels(ctx context.Context, opt ...options.Channel) ([]*m
return channels, nil
}
func (l Backend) GetChannelInfo(ctx context.Context, channel *models.Channel) error {
l.logger.Debug("GetChannelInfo")
clt, err := l.Client(ctx)
if err != nil {
return err
}
defer clt.Close()
req := &lnrpc.ChanInfoRequest{ChanId: channel.ID}
resp, err := clt.GetChanInfo(ctx, req)
if err != nil {
return errors.WithStack(err)
}
if resp == nil {
return nil
}
t := time.Unix(int64(uint64(resp.LastUpdate)), 0)
channel.LastUpdate = &t
return nil
}
func (l Backend) CreateInvoice(ctx context.Context, amount int64, desc string) (*models.Invoice, error) {
l.logger.Debug("Create invoice...",
logging.Int64("amount", amount),

@ -54,6 +54,10 @@ func (b *Backend) ListChannels(ctx context.Context, opt ...options.Channel) ([]*
return []*models.Channel{}, nil
}
func (b *Backend) GetChannelInfo(ctx context.Context, channel *models.Channel) error {
return nil
}
func (b *Backend) DecodePayReq(ctx context.Context, payreq string) (*models.PayReq, error) {
return &models.PayReq{}, nil
}

@ -36,7 +36,7 @@ type Channel struct {
CSVDelay uint32
Private bool
PendingHTLC []*HTLC
LastUpdated *time.Time
LastUpdate *time.Time
}
func (m Channel) MarshalLogObject(enc logging.ObjectEncoder) error {

Loading…
Cancel
Save