Skip to content

Commit

Permalink
Merge pull request #4335 from joostjager/queryroutes-limit
Browse files Browse the repository at this point in the history
rpcserver+routerrpc: remove payment limit
  • Loading branch information
Roasbeef authored May 28, 2020
2 parents 703e8ac + df7a05d commit 6b3c2c1
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 49 deletions.
1 change: 0 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,6 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
// primary chain.
cfg.registeredChains.RegisterPrimaryChain(litecoinChain)
MaxFundingAmount = maxLtcFundingAmount
MaxPaymentMSat = maxLtcPaymentMSat

case cfg.Bitcoin.Active:
// Multiple networks can't be selected simultaneously. Count
Expand Down
14 changes: 0 additions & 14 deletions lnrpc/routerrpc/router_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ import (
// RouterBackend contains the backend implementation of the router rpc sub
// server calls.
type RouterBackend struct {
// MaxPaymentMSat is the largest payment permitted by the backend.
MaxPaymentMSat lnwire.MilliSatoshi

// SelfNode is the vertex of the node sending the payment.
SelfNode route.Vertex

Expand Down Expand Up @@ -143,10 +140,6 @@ func (r *RouterBackend) QueryRoutes(ctx context.Context,
if err != nil {
return nil, err
}
if amt > r.MaxPaymentMSat {
return nil, fmt.Errorf("payment of %v is too large, max payment "+
"allowed is %v", amt, r.MaxPaymentMSat.ToSatoshis())
}

// Unmarshall restrictions from request.
feeLimit := lnrpc.CalculateFeeLimit(in.FeeLimit, amt)
Expand Down Expand Up @@ -489,13 +482,6 @@ func (r *RouterBackend) UnmarshallRoute(rpcroute *lnrpc.Route) (
return nil, err
}

if routeHop.AmtToForward > r.MaxPaymentMSat {
return nil, fmt.Errorf("payment of %v is too large, "+
"max payment allowed is %v",
routeHop.AmtToForward,
r.MaxPaymentMSat.ToSatoshis())
}

hops[i] = routeHop

prevNodePubKey = routeHop.PubKeyBytes
Expand Down
5 changes: 2 additions & 3 deletions lnrpc/routerrpc/router_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,8 @@ func testQueryRoutes(t *testing.T, useMissionControl bool, useMsat bool) {
}

backend := &RouterBackend{
MaxPaymentMSat: lnwire.NewMSatFromSatoshis(1000000),
FindRoute: findRoute,
SelfNode: route.Vertex{1, 2, 3},
FindRoute: findRoute,
SelfNode: route.Vertex{1, 2, 3},
FetchChannelCapacity: func(chanID uint64) (
btcutil.Amount, error) {

Expand Down
3 changes: 2 additions & 1 deletion lntest/itest/lnd_multi-hop-error-propagation.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package itest

import (
"context"
"math"
"strings"
"time"

Expand Down Expand Up @@ -260,7 +261,7 @@ out:
// We'll send in chunks of the max payment amount. If we're
// about to send too much, then we'll only send the amount
// remaining.
toSend := int64(lnd.MaxPaymentMSat.ToSatoshis())
toSend := int64(math.MaxUint32)
if toSend+amtSent > amtToSend {
toSend = amtToSend - amtSent
}
Expand Down
31 changes: 1 addition & 30 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,7 @@ import (
"gopkg.in/macaroon-bakery.v2/bakery"
)

const (
// maxBtcPaymentMSat is the maximum allowed Bitcoin payment currently
// permitted as defined in BOLT-0002.
maxBtcPaymentMSat = lnwire.MilliSatoshi(math.MaxUint32)

// maxLtcPaymentMSat is the maximum allowed Litecoin payment currently
// permitted.
maxLtcPaymentMSat = lnwire.MilliSatoshi(math.MaxUint32) *
btcToLtcConversionRate
)

var (
// MaxPaymentMSat is the maximum allowed payment currently permitted as
// defined in BOLT-002. This value depends on which chain is active.
// It is set to the value under the Bitcoin chain as default.
MaxPaymentMSat = maxBtcPaymentMSat

// readPermissions is a slice of all entities that allow read
// permissions for authorization purposes, all lowercase.
readPermissions = []bakery.Op{
Expand Down Expand Up @@ -540,8 +524,7 @@ func newRPCServer(cfg *Config, s *server, macService *macaroons.Service,
}
graph := s.chanDB.ChannelGraph()
routerBackend := &routerrpc.RouterBackend{
MaxPaymentMSat: MaxPaymentMSat,
SelfNode: selfNode.PubKeyBytes,
SelfNode: selfNode.PubKeyBytes,
FetchChannelCapacity: func(chanID uint64) (btcutil.Amount,
error) {

Expand Down Expand Up @@ -3987,18 +3970,6 @@ func (r *rpcServer) extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPayme
return payIntent, err
}

// Currently, within the bootstrap phase of the network, we limit the
// largest payment size allotted to (2^32) - 1 mSAT or 4.29 million
// satoshis.
if payIntent.msat > MaxPaymentMSat {
// In this case, we'll send an error to the caller, but
// continue our loop for the next payment.
return payIntent, fmt.Errorf("payment of %v is too large, "+
"max payment allowed is %v", payIntent.msat,
MaxPaymentMSat)

}

return payIntent, nil
}

Expand Down

0 comments on commit 6b3c2c1

Please sign in to comment.