From 7c85363ef6b136789967b4099640a8ffc4bd4595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hampus=20Sj=C3=B6berg?= Date: Thu, 5 Sep 2019 02:12:37 +0200 Subject: [PATCH 1/2] config: Add norest config for disabling REST API This commit adds a new config `norest` for disabling the REST API. This is useful in cases where it is not needed (i.e lnd running on mobile devices). --- config.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/config.go b/config.go index 3a0af8df..499870ba 100644 --- a/config.go +++ b/config.go @@ -259,6 +259,7 @@ type config struct { Listeners []net.Addr ExternalIPs []net.Addr DisableListen bool `long:"nolisten" description:"Disable listening for incoming peer connections"` + DisableRest bool `long:"norest" description:"Disable REST API"` NAT bool `long:"nat" description:"Toggle NAT traversal support (using either UPnP or NAT-PMP) to automatically advertise your external IP address to the network -- NOTE this does not support devices behind multiple NATs"` MinBackoff time.Duration `long:"minbackoff" description:"Shortest backoff when reconnecting to persistent peers. Valid time units are {s, m, h}."` MaxBackoff time.Duration `long:"maxbackoff" description:"Longest backoff when reconnecting to persistent peers. Valid time units are {s, m, h}."` @@ -1031,11 +1032,17 @@ func loadConfig() (*config, error) { if err != nil { return nil, err } - err = lncfg.EnforceSafeAuthentication( - cfg.RESTListeners, !cfg.NoMacaroons, - ) - if err != nil { - return nil, err + + if cfg.DisableRest { + ltndLog.Infof("REST API is disabled!") + cfg.RESTListeners = nil + } else { + err = lncfg.EnforceSafeAuthentication( + cfg.RESTListeners, !cfg.NoMacaroons, + ) + if err != nil { + return nil, err + } } // Remove the listening addresses specified if listening is disabled. From 2445be6552cd5fef32b238ec7ad50cf564e01352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hampus=20Sj=C3=B6berg?= Date: Mon, 9 Sep 2019 22:20:49 +0200 Subject: [PATCH 2/2] mobile: Updating sample_lnd.conf to contain norest config --- mobile/sample_lnd.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/mobile/sample_lnd.conf b/mobile/sample_lnd.conf index 008be571..a1b93647 100644 --- a/mobile/sample_lnd.conf +++ b/mobile/sample_lnd.conf @@ -3,6 +3,7 @@ debuglevel=info no-macaroons=1 maxbackoff=2s nolisten=1 +norest=1 [Routing] routing.assumechanvalid=1