From d22f543906e1d600b54765d631f6dd4e3bbb30ec Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 2 Feb 2022 14:24:53 +0100 Subject: [PATCH] lnrpc: use amount based default routing fee --- lnrpc/lightning.pb.go | 6 ++++-- lnrpc/lightning.proto | 6 ++++-- lnrpc/lightning.swagger.json | 2 +- lnrpc/marshall_utils.go | 7 +++---- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lnrpc/lightning.pb.go b/lnrpc/lightning.pb.go index ba6bff1eb..42b937825 100644 --- a/lnrpc/lightning.pb.go +++ b/lnrpc/lightning.pb.go @@ -1938,7 +1938,8 @@ type SendRequest struct { //The maximum number of satoshis that will be paid as a fee of the payment. //This value can be represented either as a percentage of the amount being //sent, or as a fixed amount of the maximum fee the user is willing the pay to - //send the payment. + //send the payment. If not specified, lnd will use a default value of 100% + //fees for small amounts (<=50 sat) or 5% fees for larger amounts. FeeLimit *FeeLimit `protobuf:"bytes,8,opt,name=fee_limit,json=feeLimit,proto3" json:"fee_limit,omitempty"` // //The channel id of the channel that must be taken to the first hop. If zero, @@ -8517,7 +8518,8 @@ type QueryRoutesRequest struct { //The maximum number of satoshis that will be paid as a fee of the payment. //This value can be represented either as a percentage of the amount being //sent, or as a fixed amount of the maximum fee the user is willing the pay to - //send the payment. + //send the payment. If not specified, lnd will use a default value of 100% + //fees for small amounts (<=50 sat) or 5% fees for larger amounts. FeeLimit *FeeLimit `protobuf:"bytes,5,opt,name=fee_limit,json=feeLimit,proto3" json:"fee_limit,omitempty"` // //A list of nodes to ignore during path finding. When using REST, these fields diff --git a/lnrpc/lightning.proto b/lnrpc/lightning.proto index 38e7f0aec..905f839c4 100644 --- a/lnrpc/lightning.proto +++ b/lnrpc/lightning.proto @@ -753,7 +753,8 @@ message SendRequest { The maximum number of satoshis that will be paid as a fee of the payment. This value can be represented either as a percentage of the amount being sent, or as a fixed amount of the maximum fee the user is willing the pay to - send the payment. + send the payment. If not specified, lnd will use a default value of 100% + fees for small amounts (<=50 sat) or 5% fees for larger amounts. */ FeeLimit fee_limit = 8; @@ -2574,7 +2575,8 @@ message QueryRoutesRequest { The maximum number of satoshis that will be paid as a fee of the payment. This value can be represented either as a percentage of the amount being sent, or as a fixed amount of the maximum fee the user is willing the pay to - send the payment. + send the payment. If not specified, lnd will use a default value of 100% + fees for small amounts (<=50 sat) or 5% fees for larger amounts. */ FeeLimit fee_limit = 5; diff --git a/lnrpc/lightning.swagger.json b/lnrpc/lightning.swagger.json index 9cec28593..7ae032167 100644 --- a/lnrpc/lightning.swagger.json +++ b/lnrpc/lightning.swagger.json @@ -6238,7 +6238,7 @@ }, "fee_limit": { "$ref": "#/definitions/lnrpcFeeLimit", - "description": "The maximum number of satoshis that will be paid as a fee of the payment.\nThis value can be represented either as a percentage of the amount being\nsent, or as a fixed amount of the maximum fee the user is willing the pay to\nsend the payment." + "description": "The maximum number of satoshis that will be paid as a fee of the payment.\nThis value can be represented either as a percentage of the amount being\nsent, or as a fixed amount of the maximum fee the user is willing the pay to\nsend the payment. If not specified, lnd will use a default value of 100%\nfees for small amounts (\u003c=50 sat) or 5% fees for larger amounts." }, "outgoing_chan_id": { "type": "string", diff --git a/lnrpc/marshall_utils.go b/lnrpc/marshall_utils.go index d0e501160..013e1f9be 100644 --- a/lnrpc/marshall_utils.go +++ b/lnrpc/marshall_utils.go @@ -40,10 +40,9 @@ func CalculateFeeLimit(feeLimit *FeeLimit, return amount * lnwire.MilliSatoshi(feeLimit.GetPercent()) / 100 default: - // If a fee limit was not specified, we'll use the payment's - // amount as an upper bound in order to avoid payment attempts - // from incurring fees higher than the payment amount itself. - return amount + // Fall back to a sane default value that is based on the amount + // itself. + return lnwallet.DefaultRoutingFeeLimitForAmount(amount) } }