Merge pull request #8886 from bitromortac/buildroute-inbound-fees

routing: inbound fees support for BuildRoute
This commit is contained in:
Oliver Gugger
2024-08-07 08:11:17 -06:00
committed by GitHub
7 changed files with 915 additions and 227 deletions

View File

@@ -15,6 +15,7 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
"github.com/lightningnetwork/lnd/lntypes"
@@ -1400,6 +1401,10 @@ func (s *Server) trackPaymentStream(context context.Context,
func (s *Server) BuildRoute(_ context.Context,
req *BuildRouteRequest) (*BuildRouteResponse, error) {
if len(req.HopPubkeys) == 0 {
return nil, errors.New("no hops specified")
}
// Unmarshall hop list.
hops := make([]route.Vertex, len(req.HopPubkeys))
for i, pubkeyBytes := range req.HopPubkeys {
@@ -1411,10 +1416,10 @@ func (s *Server) BuildRoute(_ context.Context,
}
// Prepare BuildRoute call parameters from rpc request.
var amt *lnwire.MilliSatoshi
var amt fn.Option[lnwire.MilliSatoshi]
if req.AmtMsat != 0 {
rpcAmt := lnwire.MilliSatoshi(req.AmtMsat)
amt = &rpcAmt
amt = fn.Some(rpcAmt)
}
var outgoingChan *uint64