routerrpc: update final cltv delta default

The default was increased for the main sendpayment RPC in commit
d3fa9767a9729756bab9b4a1121344b265410b1a. This commit sets the
same default for QueryRoutes, routerrpc.SendPayment and
router.EstimateRouteFee.
This commit is contained in:
Joost Jager 2020-01-14 12:00:26 +01:00
parent 81bf6e15b3
commit 5de308c4b5
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
6 changed files with 20 additions and 20 deletions

@ -46,7 +46,7 @@ type RouterBackend struct {
amt lnwire.MilliSatoshi, restrictions *routing.RestrictParams, amt lnwire.MilliSatoshi, restrictions *routing.RestrictParams,
destCustomRecords record.CustomSet, destCustomRecords record.CustomSet,
routeHints map[route.Vertex][]*channeldb.ChannelEdgePolicy, routeHints map[route.Vertex][]*channeldb.ChannelEdgePolicy,
finalExpiry ...uint16) (*route.Route, error) finalExpiry uint16) (*route.Route, error)
MissionControl MissionControl MissionControl MissionControl
@ -63,6 +63,10 @@ type RouterBackend struct {
// MaxTotalTimelock is the maximum total time lock a route is allowed to // MaxTotalTimelock is the maximum total time lock a route is allowed to
// have. // have.
MaxTotalTimelock uint32 MaxTotalTimelock uint32
// DefaultFinalCltvDelta is the default value used as final cltv delta
// when an RPC caller doesn't specify a value.
DefaultFinalCltvDelta uint16
} }
// MissionControl defines the mission control dependencies of routerrpc. // MissionControl defines the mission control dependencies of routerrpc.
@ -194,7 +198,7 @@ func (r *RouterBackend) QueryRoutes(ctx context.Context,
// We need to subtract the final delta before passing it into path // We need to subtract the final delta before passing it into path
// finding. The optimal path is independent of the final cltv delta and // finding. The optimal path is independent of the final cltv delta and
// the path finding algorithm is unaware of this value. // the path finding algorithm is unaware of this value.
finalCLTVDelta := uint16(zpay32.DefaultFinalCLTVDelta) finalCLTVDelta := r.DefaultFinalCltvDelta
if in.FinalCltvDelta != 0 { if in.FinalCltvDelta != 0 {
finalCLTVDelta = uint16(in.FinalCltvDelta) finalCLTVDelta = uint16(in.FinalCltvDelta)
} }
@ -657,7 +661,7 @@ func (r *RouterBackend) extractIntentFromSendRequest(
payIntent.FinalCLTVDelta = payIntent.FinalCLTVDelta =
uint16(rpcPayReq.FinalCltvDelta) uint16(rpcPayReq.FinalCltvDelta)
} else { } else {
payIntent.FinalCLTVDelta = zpay32.DefaultFinalCLTVDelta payIntent.FinalCLTVDelta = r.DefaultFinalCltvDelta
} }
// Amount. // Amount.

@ -121,7 +121,7 @@ func testQueryRoutes(t *testing.T, useMissionControl bool, useMsat bool) {
amt lnwire.MilliSatoshi, restrictions *routing.RestrictParams, amt lnwire.MilliSatoshi, restrictions *routing.RestrictParams,
_ record.CustomSet, _ record.CustomSet,
routeHints map[route.Vertex][]*channeldb.ChannelEdgePolicy, routeHints map[route.Vertex][]*channeldb.ChannelEdgePolicy,
finalExpiry ...uint16) (*route.Route, error) { finalExpiry uint16) (*route.Route, error) {
if int64(amt) != amtSat*1000 { if int64(amt) != amtSat*1000 {
t.Fatal("unexpected amount") t.Fatal("unexpected amount")

@ -260,7 +260,7 @@ func (s *Server) EstimateRouteFee(ctx context.Context,
&routing.RestrictParams{ &routing.RestrictParams{
FeeLimit: feeLimit, FeeLimit: feeLimit,
CltvLimit: s.cfg.RouterBackend.MaxTotalTimelock, CltvLimit: s.cfg.RouterBackend.MaxTotalTimelock,
}, nil, nil, }, nil, nil, s.cfg.RouterBackend.DefaultFinalCltvDelta,
) )
if err != nil { if err != nil {
return nil, err return nil, err

@ -2110,6 +2110,7 @@ func TestPathFindSpecExample(t *testing.T) {
const amt lnwire.MilliSatoshi = 4999999 const amt lnwire.MilliSatoshi = 4999999
route, err := ctx.router.FindRoute( route, err := ctx.router.FindRoute(
bobNode.PubKeyBytes, carol, amt, noRestrictions, nil, nil, bobNode.PubKeyBytes, carol, amt, noRestrictions, nil, nil,
zpay32.DefaultFinalCLTVDelta,
) )
if err != nil { if err != nil {
t.Fatalf("unable to find route: %v", err) t.Fatalf("unable to find route: %v", err)
@ -2165,6 +2166,7 @@ func TestPathFindSpecExample(t *testing.T) {
// We'll now request a route from A -> B -> C. // We'll now request a route from A -> B -> C.
route, err = ctx.router.FindRoute( route, err = ctx.router.FindRoute(
source.PubKeyBytes, carol, amt, noRestrictions, nil, nil, source.PubKeyBytes, carol, amt, noRestrictions, nil, nil,
zpay32.DefaultFinalCLTVDelta,
) )
if err != nil { if err != nil {
t.Fatalf("unable to find routes: %v", err) t.Fatalf("unable to find routes: %v", err)

@ -1403,14 +1403,7 @@ func (r *ChannelRouter) FindRoute(source, target route.Vertex,
amt lnwire.MilliSatoshi, restrictions *RestrictParams, amt lnwire.MilliSatoshi, restrictions *RestrictParams,
destCustomRecords record.CustomSet, destCustomRecords record.CustomSet,
routeHints map[route.Vertex][]*channeldb.ChannelEdgePolicy, routeHints map[route.Vertex][]*channeldb.ChannelEdgePolicy,
finalExpiry ...uint16) (*route.Route, error) { finalExpiry uint16) (*route.Route, error) {
var finalCLTVDelta uint16
if len(finalExpiry) == 0 {
finalCLTVDelta = zpay32.DefaultFinalCLTVDelta
} else {
finalCLTVDelta = finalExpiry[0]
}
log.Debugf("Searching for path to %v, sending %v", target, amt) log.Debugf("Searching for path to %v, sending %v", target, amt)
@ -1441,7 +1434,7 @@ func (r *ChannelRouter) FindRoute(source, target route.Vertex,
// Now that we know the destination is reachable within the graph, we'll // Now that we know the destination is reachable within the graph, we'll
// execute our path finding algorithm. // execute our path finding algorithm.
finalHtlcExpiry := currentHeight + int32(finalCLTVDelta) finalHtlcExpiry := currentHeight + int32(finalExpiry)
path, err := findPath( path, err := findPath(
&graphParams{ &graphParams{
@ -1461,7 +1454,7 @@ func (r *ChannelRouter) FindRoute(source, target route.Vertex,
source, path, uint32(currentHeight), source, path, uint32(currentHeight),
finalHopParams{ finalHopParams{
amt: amt, amt: amt,
cltvDelta: finalCLTVDelta, cltvDelta: finalExpiry,
records: destCustomRecords, records: destCustomRecords,
}, },
) )

@ -562,11 +562,12 @@ func newRPCServer(s *server, macService *macaroons.Service,
return info.NodeKey1Bytes, info.NodeKey2Bytes, nil return info.NodeKey1Bytes, info.NodeKey2Bytes, nil
}, },
FindRoute: s.chanRouter.FindRoute, FindRoute: s.chanRouter.FindRoute,
MissionControl: s.missionControl, MissionControl: s.missionControl,
ActiveNetParams: activeNetParams.Params, ActiveNetParams: activeNetParams.Params,
Tower: s.controlTower, Tower: s.controlTower,
MaxTotalTimelock: cfg.MaxOutgoingCltvExpiry, MaxTotalTimelock: cfg.MaxOutgoingCltvExpiry,
DefaultFinalCltvDelta: uint16(cfg.Bitcoin.TimeLockDelta),
} }
genInvoiceFeatures := func() *lnwire.FeatureVector { genInvoiceFeatures := func() *lnwire.FeatureVector {