mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-23 18:20:06 +02:00
rpcserver: retrieve channel info for channel point
This commit is contained in:
parent
1936aa7261
commit
7923ca0de4
35
rpcserver.go
35
rpcserver.go
@ -6295,15 +6295,40 @@ func (r *rpcServer) GetNodeMetrics(ctx context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetChanInfo returns the latest authenticated network announcement for the
|
// GetChanInfo returns the latest authenticated network announcement for the
|
||||||
// given channel identified by its channel ID: an 8-byte integer which uniquely
|
// given channel identified by either its channel ID or a channel outpoint. Both
|
||||||
// identifies the location of transaction's funding output within the block
|
// uniquely identify the location of transaction's funding output within the
|
||||||
// chain.
|
// blockchain. The former is an 8-byte integer, while the latter is a string
|
||||||
func (r *rpcServer) GetChanInfo(ctx context.Context,
|
// formatted as funding_txid:output_index.
|
||||||
|
func (r *rpcServer) GetChanInfo(_ context.Context,
|
||||||
in *lnrpc.ChanInfoRequest) (*lnrpc.ChannelEdge, error) {
|
in *lnrpc.ChanInfoRequest) (*lnrpc.ChannelEdge, error) {
|
||||||
|
|
||||||
graph := r.server.graphDB
|
graph := r.server.graphDB
|
||||||
|
|
||||||
edgeInfo, edge1, edge2, err := graph.FetchChannelEdgesByID(in.ChanId)
|
var (
|
||||||
|
edgeInfo *models.ChannelEdgeInfo
|
||||||
|
edge1, edge2 *models.ChannelEdgePolicy
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case in.ChanId != 0:
|
||||||
|
edgeInfo, edge1, edge2, err = graph.FetchChannelEdgesByID(
|
||||||
|
in.ChanId,
|
||||||
|
)
|
||||||
|
|
||||||
|
case in.ChanPoint != "":
|
||||||
|
var chanPoint *wire.OutPoint
|
||||||
|
chanPoint, err = wire.NewOutPointFromString(in.ChanPoint)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
edgeInfo, edge1, edge2, err = graph.FetchChannelEdgesByOutpoint(
|
||||||
|
chanPoint,
|
||||||
|
)
|
||||||
|
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("specify either chan_id or chan_point")
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user