Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lnrpc: rejects positive inbound fees by default #8627

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/lncli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2376,14 +2376,14 @@ func updateChannelPolicy(ctx *cli.Context) error {

inboundBaseFeeMsat := ctx.Int64("inbound_base_fee_msat")
if inboundBaseFeeMsat < math.MinInt32 ||
inboundBaseFeeMsat > 0 {
inboundBaseFeeMsat > math.MaxInt32 {

return errors.New("inbound_base_fee_msat out of range")
}

inboundFeeRatePpm := ctx.Int64("inbound_fee_rate_ppm")
ziggie1984 marked this conversation as resolved.
Show resolved Hide resolved
if inboundFeeRatePpm < math.MinInt32 ||
inboundFeeRatePpm > 0 {
inboundFeeRatePpm > math.MaxInt32 {

return errors.New("inbound_fee_rate_ppm out of range")
}
Expand Down
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ type Config struct {

RejectHTLC bool `long:"rejecthtlc" description:"If true, lnd will not forward any HTLCs that are meant as onward payments. This option will still allow lnd to send HTLCs and receive HTLCs but lnd won't be used as a hop."`

AcceptPositiveInboundFees bool `long:"accept-positive-inbound-fees" description:"If true, lnd will also allow setting positive inbound fees. By default, lnd only allows to set negative inbound fees (an inbound \"discount\") to remain backwards compatible with senders whose implementations do not yet support inbound fees."`

// RequireInterceptor determines whether the HTLC interceptor is
// registered regardless of whether the RPC is called or not.
RequireInterceptor bool `long:"requireinterceptor" description:"Whether to always intercept HTLCs, even if no stream is attached"`
Expand Down
8 changes: 7 additions & 1 deletion docs/release-notes/release-notes-0.18.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,14 @@ call where arguments were swapped.
node operators to require senders to pay an inbound fee for forwards and
payments. It is recommended to only use negative fees (an inbound "discount")
initially to keep the channels open for senders that do not recognize inbound
fees. [Send support](https://github.com/lightningnetwork/lnd/pull/6934) is
fees.

[Send support](https://github.com/lightningnetwork/lnd/pull/6934) is
implemented as well.

[Positive inbound fees](https://github.com/lightningnetwork/lnd/pull/8627)
can be enabled with the option `accept-positive-inbound-fees`.

* A new config value,
[sweeper.maxfeerate](https://github.com/lightningnetwork/lnd/pull/7823), is
added so users can specify the max allowed fee rate when sweeping on-chain
Expand Down Expand Up @@ -448,6 +453,7 @@ bitcoin peers' feefilter values into account](https://github.com/lightningnetwor
* Carla Kirk-Cohen
* Elle Mouton
* ErikEk
* Feelancer21
* Jesse de Wit
* Joost Jager
* Keagan McClelland
Expand Down
14 changes: 14 additions & 0 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7109,6 +7109,20 @@ func (r *rpcServer) UpdateChannelPolicy(ctx context.Context,
MaxTimeLockDelta)
}

// By default, positive inbound fees are rejected.
if !r.cfg.AcceptPositiveInboundFees {
if req.InboundBaseFeeMsat > 0 {
return nil, fmt.Errorf("positive values for inbound "+
"base fee msat are not supported: %v",
req.InboundBaseFeeMsat)
}
if req.InboundFeeRatePpm > 0 {
return nil, fmt.Errorf("positive values for inbound "+
"fee rate ppm are not supported: %v",
req.InboundFeeRatePpm)
}
}

baseFeeMsat := lnwire.MilliSatoshi(req.BaseFeeMsat)
feeSchema := routing.FeeSchema{
BaseFee: baseFeeMsat,
Expand Down
7 changes: 7 additions & 0 deletions sample-lnd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,13 @@
; If true, all HTLCs will be held until they are handled by an interceptor
; requireinterceptor=false

; If true, lnd will also allow setting positive inbound fees. By default, lnd
; only allows to set negative inbound fees (an inbound "discount") to remain
; backwards compatible with senders whose implementations do not yet support
; inbound fees. Therefore, you should ONLY set this setting if you know what you
; are doing. [experimental]
; accept-positive-inbound-fees=false
bitromortac marked this conversation as resolved.
Show resolved Hide resolved

; If true, will apply a randomized staggering between 0s and 30s when
; reconnecting to persistent peers on startup. The first 10 reconnections will be
; attempted instantly, regardless of the flag's value
Expand Down
Loading