rpcserver: add LookupHtlc call

This commit is contained in:
Joost Jager
2022-08-29 13:20:52 +02:00
parent 511fb00777
commit 3a89a84744
11 changed files with 4637 additions and 4100 deletions

View File

@ -577,6 +577,10 @@ func MainRPCServerPermissions() map[string][]bakery.Op {
Entity: "offchain",
Action: "read",
}},
"/lnrpc.Lightning/LookupHtlc": {{
Entity: "offchain",
Action: "read",
}},
"/lnrpc.Lightning/ListAliases": {{
Entity: "offchain",
Action: "read",
@ -3904,6 +3908,28 @@ func (r *rpcServer) ClosedChannels(ctx context.Context,
return resp, nil
}
// LookupHtlc retrieves a final htlc resolution from the database. If the htlc
// has no final resolution yet, a NotFound grpc status code is returned.
func (r *rpcServer) LookupHtlc(ctx context.Context,
in *lnrpc.LookupHtlcRequest) (*lnrpc.LookupHtlcResponse, error) {
chanID := lnwire.NewShortChanIDFromInt(in.ChanId)
info, err := r.server.chanStateDB.LookupFinalHtlc(chanID, in.HtlcIndex)
switch {
case errors.Is(err, channeldb.ErrHtlcUnknown):
return nil, status.Error(codes.NotFound, err.Error())
case err != nil:
return nil, err
}
return &lnrpc.LookupHtlcResponse{
Settled: info.Settled,
Offchain: info.Offchain,
}, nil
}
// ListChannels returns a description of all the open channels that this node
// is a participant in.
func (r *rpcServer) ListChannels(ctx context.Context,