From f360ec71bfb5ed983c00913fd2639fb2f7e2182b Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Wed, 15 Jul 2020 15:05:32 +0200 Subject: [PATCH] mobile: restore config parsing for mobile bindings A recent commit moved the config parsing out of lnd's Main method. This commit makes the mobile bindings compile with this change. --- mobile/bindings.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/mobile/bindings.go b/mobile/bindings.go index 8d669ca0..d64540b9 100644 --- a/mobile/bindings.go +++ b/mobile/bindings.go @@ -9,6 +9,7 @@ import ( flags "github.com/jessevdk/go-flags" "github.com/lightningnetwork/lnd" + "github.com/lightningnetwork/lnd/signal" ) // Start starts lnd in a new goroutine. @@ -40,10 +41,21 @@ func Start(extraArgs string, unlockerReady, rpcReady Callback) { splitArgs = append(splitArgs, "--"+a) } - // Add the extra arguments to os.Args, as that will be parsed during - // startup. + // Add the extra arguments to os.Args, as that will be parsed in + // LoadConfig below. os.Args = append(os.Args, splitArgs...) + // Load the configuration, and parse the extra arguments as command + // line options. This function will also set up logging properly. + loadedConfig, err := lnd.LoadConfig() + if err != nil { + _, _ = fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } + + // Hook interceptor for os signals. + signal.Intercept() + // Set up channels that will be notified when the RPC servers are ready // to accept calls. var ( @@ -67,7 +79,9 @@ func Start(extraArgs string, unlockerReady, rpcReady Callback) { // Call the "real" main in a nested manner so the defers will properly // be executed in the case of a graceful shutdown. go func() { - if err := lnd.Main(cfg); err != nil { + if err := lnd.Main( + loadedConfig, cfg, signal.ShutdownChannel(), + ); err != nil { if e, ok := err.(*flags.Error); ok && e.Type == flags.ErrHelp { } else { @@ -84,7 +98,7 @@ func Start(extraArgs string, unlockerReady, rpcReady Callback) { // We must set the TLS certificates in order to properly // authenticate with the wallet unlocker service. - auth, err := lnd.WalletUnlockerAuthOptions() + auth, err := lnd.WalletUnlockerAuthOptions(loadedConfig) if err != nil { unlockerReady.OnError(err) return @@ -102,7 +116,7 @@ func Start(extraArgs string, unlockerReady, rpcReady Callback) { // Now that the RPC server is ready, we can get the needed // authentication options, and add them to the global dial // options. - auth, err := lnd.AdminAuthOptions() + auth, err := lnd.AdminAuthOptions(loadedConfig) if err != nil { rpcReady.OnError(err) return