From 363caa441aca977747027a6e1152b6e4d12452af Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 12 Mar 2020 18:07:09 -0700 Subject: [PATCH] rpc: allow wumbo invoices In this commit, we remove the restriction surrounding the largest invoices that we'll allow a user to create. After #3967 has landed, users will be able to send in _aggregate_ a payment larger than the current max HTLC size limit in the network. As a result, we can just treat that value as the system's MTU, and allow users to request payments it multiples of that MTU value. A follow up to this PR at a later time will also allow wumbo _channels_. However, that requires us to tweak the way we scale CSV values, as post wumbo, there is no true channel size limit, only the _local_ limit of a given node. We also need to implement a way for nodes to signal to other nodes their accepted max channel size. --- lnrpc/invoicesrpc/addinvoice.go | 12 ------------ lnrpc/invoicesrpc/config_active.go | 3 --- lnrpc/invoicesrpc/invoices_server.go | 1 - lnrpc/routerrpc/router_backend.go | 12 ------------ rpcserver.go | 1 - subrpcserver_config.go | 3 --- 6 files changed, 32 deletions(-) diff --git a/lnrpc/invoicesrpc/addinvoice.go b/lnrpc/invoicesrpc/addinvoice.go index 28b48e54..24463ccb 100644 --- a/lnrpc/invoicesrpc/addinvoice.go +++ b/lnrpc/invoicesrpc/addinvoice.go @@ -37,9 +37,6 @@ type AddInvoiceConfig struct { // that's backed by the identity private key of the running lnd node. NodeSigner *netann.NodeSigner - // MaxPaymentMSat is the maximum allowed payment. - MaxPaymentMSat lnwire.MilliSatoshi - // DefaultCLTVExpiry is the default invoice expiry if no values is // specified. DefaultCLTVExpiry uint32 @@ -167,15 +164,6 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig, amtMSat := invoice.Value - // The value of the invoice must also not exceed the current soft-limit - // on the largest payment within the network. - if amtMSat > cfg.MaxPaymentMSat { - return nil, nil, fmt.Errorf("payment of %v is too large, max "+ - "payment allowed is %v", invoice.Value, - cfg.MaxPaymentMSat.ToSatoshis(), - ) - } - // We also create an encoded payment request which allows the // caller to compactly send the invoice to the payer. We'll create a // list of options to be added to the encoded payment request. For now diff --git a/lnrpc/invoicesrpc/config_active.go b/lnrpc/invoicesrpc/config_active.go index b347ecd5..9e43ccc8 100644 --- a/lnrpc/invoicesrpc/config_active.go +++ b/lnrpc/invoicesrpc/config_active.go @@ -40,9 +40,6 @@ type Config struct { // that's backed by the identity private key of the running lnd node. NodeSigner *netann.NodeSigner - // MaxPaymentMSat is the maximum allowed payment. - MaxPaymentMSat lnwire.MilliSatoshi - // DefaultCLTVExpiry is the default invoice expiry if no values is // specified. DefaultCLTVExpiry uint32 diff --git a/lnrpc/invoicesrpc/invoices_server.go b/lnrpc/invoicesrpc/invoices_server.go index 87cdc026..e915bc1a 100644 --- a/lnrpc/invoicesrpc/invoices_server.go +++ b/lnrpc/invoicesrpc/invoices_server.go @@ -250,7 +250,6 @@ func (s *Server) AddHoldInvoice(ctx context.Context, IsChannelActive: s.cfg.IsChannelActive, ChainParams: s.cfg.ChainParams, NodeSigner: s.cfg.NodeSigner, - MaxPaymentMSat: s.cfg.MaxPaymentMSat, DefaultCLTVExpiry: s.cfg.DefaultCLTVExpiry, ChanDB: s.cfg.ChanDB, GenInvoiceFeatures: s.cfg.GenInvoiceFeatures, diff --git a/lnrpc/routerrpc/router_backend.go b/lnrpc/routerrpc/router_backend.go index d4d75edd..3ee61c97 100644 --- a/lnrpc/routerrpc/router_backend.go +++ b/lnrpc/routerrpc/router_backend.go @@ -698,18 +698,6 @@ func (r *RouterBackend) extractIntentFromSendRequest( payIntent.DestFeatures = features } - // 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.Amount > r.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.Amount, - r.MaxPaymentMSat) - - } - // Check for disallowed payments to self. if !rpcPayReq.AllowSelfPayment && payIntent.Target == r.SelfNode { return nil, errors.New("self-payments not allowed") diff --git a/rpcserver.go b/rpcserver.go index 3928eeb1..043373bf 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -4305,7 +4305,6 @@ func (r *rpcServer) AddInvoice(ctx context.Context, IsChannelActive: r.server.htlcSwitch.HasActiveLink, ChainParams: activeNetParams.Params, NodeSigner: r.server.nodeSigner, - MaxPaymentMSat: MaxPaymentMSat, DefaultCLTVExpiry: defaultDelta, ChanDB: r.server.chanDB, GenInvoiceFeatures: func() *lnwire.FeatureVector { diff --git a/subrpcserver_config.go b/subrpcserver_config.go index 48559118..31632028 100644 --- a/subrpcserver_config.go +++ b/subrpcserver_config.go @@ -202,9 +202,6 @@ func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl, subCfgValue.FieldByName("NodeSigner").Set( reflect.ValueOf(nodeSigner), ) - subCfgValue.FieldByName("MaxPaymentMSat").Set( - reflect.ValueOf(MaxPaymentMSat), - ) defaultDelta := cfg.Bitcoin.TimeLockDelta if registeredChains.PrimaryChain() == litecoinChain { defaultDelta = cfg.Litecoin.TimeLockDelta