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.
This commit is contained in:
Johan T. Halseth 2020-07-15 15:05:32 +02:00
parent 6d815379d4
commit f360ec71bf
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -9,6 +9,7 @@ import (
flags "github.com/jessevdk/go-flags" flags "github.com/jessevdk/go-flags"
"github.com/lightningnetwork/lnd" "github.com/lightningnetwork/lnd"
"github.com/lightningnetwork/lnd/signal"
) )
// Start starts lnd in a new goroutine. // Start starts lnd in a new goroutine.
@ -40,10 +41,21 @@ func Start(extraArgs string, unlockerReady, rpcReady Callback) {
splitArgs = append(splitArgs, "--"+a) splitArgs = append(splitArgs, "--"+a)
} }
// Add the extra arguments to os.Args, as that will be parsed during // Add the extra arguments to os.Args, as that will be parsed in
// startup. // LoadConfig below.
os.Args = append(os.Args, splitArgs...) 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 // Set up channels that will be notified when the RPC servers are ready
// to accept calls. // to accept calls.
var ( 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 // Call the "real" main in a nested manner so the defers will properly
// be executed in the case of a graceful shutdown. // be executed in the case of a graceful shutdown.
go func() { 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 && if e, ok := err.(*flags.Error); ok &&
e.Type == flags.ErrHelp { e.Type == flags.ErrHelp {
} else { } else {
@ -84,7 +98,7 @@ func Start(extraArgs string, unlockerReady, rpcReady Callback) {
// We must set the TLS certificates in order to properly // We must set the TLS certificates in order to properly
// authenticate with the wallet unlocker service. // authenticate with the wallet unlocker service.
auth, err := lnd.WalletUnlockerAuthOptions() auth, err := lnd.WalletUnlockerAuthOptions(loadedConfig)
if err != nil { if err != nil {
unlockerReady.OnError(err) unlockerReady.OnError(err)
return return
@ -102,7 +116,7 @@ func Start(extraArgs string, unlockerReady, rpcReady Callback) {
// Now that the RPC server is ready, we can get the needed // Now that the RPC server is ready, we can get the needed
// authentication options, and add them to the global dial // authentication options, and add them to the global dial
// options. // options.
auth, err := lnd.AdminAuthOptions() auth, err := lnd.AdminAuthOptions(loadedConfig)
if err != nil { if err != nil {
rpcReady.OnError(err) rpcReady.OnError(err)
return return