diff --git a/rpcserver.go b/rpcserver.go index ac8b93ad9..0f6495b87 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -3192,13 +3192,13 @@ func (r *rpcServer) FeeReport(ctx context.Context, // 0.000001, or 0.0001%. const minFeeRate = 1e-6 -// UpdateFees allows the caller to update the fee schedule for all channels -// globally, or a particular channel. -func (r *rpcServer) UpdateFees(ctx context.Context, - req *lnrpc.FeeUpdateRequest) (*lnrpc.FeeUpdateResponse, error) { +// UpdateChannelPolicy allows the caller to update the channel forwarding policy +// for all channels globally, or a particular channel. +func (r *rpcServer) UpdateChannelPolicy(ctx context.Context, + req *lnrpc.PolicyUpdateRequest) (*lnrpc.PolicyUpdateResponse, error) { if r.authSvc != nil { - if err := macaroons.ValidateMacaroon(ctx, "udpatefees", + if err := macaroons.ValidateMacaroon(ctx, "updatechannelpolicy", r.authSvc); err != nil { return nil, err } @@ -3208,11 +3208,11 @@ func (r *rpcServer) UpdateFees(ctx context.Context, switch scope := req.Scope.(type) { // If the request is targeting all active channels, then we don't need // target any channels by their channel point. - case *lnrpc.FeeUpdateRequest_Global: + case *lnrpc.PolicyUpdateRequest_Global: // Otherwise, we're targeting an individual channel by its channel // point. - case *lnrpc.FeeUpdateRequest_ChanPoint: + case *lnrpc.PolicyUpdateRequest_ChanPoint: txid, err := chainhash.NewHash(scope.ChanPoint.FundingTxid) if err != nil { return nil, err @@ -3226,12 +3226,19 @@ func (r *rpcServer) UpdateFees(ctx context.Context, } // As a sanity check, we'll ensure that the passed fee rate is below - // 1e-6, or the lowest allowed fee rate. + // 1e-6, or the lowest allowed fee rate, and that the passed timelock + // is large enough. if req.FeeRate < minFeeRate { return nil, fmt.Errorf("fee rate of %v is too small, min fee "+ "rate is %v", req.FeeRate, minFeeRate) } + if req.TimeLockDelta < minTimeLockDelta { + return nil, fmt.Errorf("time lock delta of %v is too small, "+ + "minimum supported is %v", req.TimeLockDelta, + minTimeLockDelta) + } + // We'll also need to convert the floating point fee rate we accept // over RPC to the fixed point rate that we use within the protocol. We // do this by multiplying the passed fee rate by the fee base. This @@ -3244,16 +3251,21 @@ func (r *rpcServer) UpdateFees(ctx context.Context, FeeRate: feeRateFixed, } - rpcsLog.Tracef("[updatefees] updating fee schedule base_fee=%v, "+ - "rate_float=%v, rate_fixed=%v, targets=%v", - req.BaseFeeMsat, req.FeeRate, feeRateFixed, + chanPolicy := routing.ChannelPolicy{ + FeeSchema: feeSchema, + TimeLockDelta: req.TimeLockDelta, + } + + rpcsLog.Tracef("[updatechanpolicy] updating channel policy base_fee=%v, "+ + "rate_float=%v, rate_fixed=%v, time_lock_delta: %v, targets=%v", + req.BaseFeeMsat, req.FeeRate, feeRateFixed, req.TimeLockDelta, spew.Sdump(targetChans)) // With the scope resolved, we'll now send this to the - // AuthenticatedGossiper so it can propagate the new fee schema for out + // AuthenticatedGossiper so it can propagate the new policy for our // target channel(s). - err := r.server.authGossiper.PropagateFeeUpdate( - feeSchema, targetChans..., + err := r.server.authGossiper.PropagateChanPolicyUpdate( + chanPolicy, targetChans..., ) if err != nil { return nil, err @@ -3265,8 +3277,9 @@ func (r *rpcServer) UpdateFees(ctx context.Context, // We create a partially policy as the logic won't overwrite a valid // sub-policy with a "nil" one. p := htlcswitch.ForwardingPolicy{ - BaseFee: baseFeeMsat, - FeeRate: lnwire.MilliSatoshi(feeRateFixed), + BaseFee: baseFeeMsat, + FeeRate: lnwire.MilliSatoshi(feeRateFixed), + TimeLockDelta: req.TimeLockDelta, } err = r.server.htlcSwitch.UpdateForwardingPolicies(p, targetChans...) if err != nil { @@ -3276,5 +3289,5 @@ func (r *rpcServer) UpdateFees(ctx context.Context, rpcsLog.Warnf("Unable to update link fees: %v", err) } - return &lnrpc.FeeUpdateResponse{}, nil + return &lnrpc.PolicyUpdateResponse{}, nil }