From 87c5b76e4d1011ecd1128b9ed5e68ba551586453 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 4 Nov 2021 15:20:34 +0100 Subject: [PATCH 1/3] lnd: simplify listener creation --- lnd.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lnd.go b/lnd.go index 83a23c846..37df3ef4b 100644 --- a/lnd.go +++ b/lnd.go @@ -224,10 +224,8 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg, // If we have chosen to start with a dedicated listener for the // rpc server, we set it directly. - var grpcListeners []*ListenerWithSignal - if len(lisCfg.RPCListeners) > 0 { - grpcListeners = append(grpcListeners, lisCfg.RPCListeners...) - } else { + grpcListeners := append([]*ListenerWithSignal{}, lisCfg.RPCListeners...) + if len(grpcListeners) == 0 { // Otherwise we create listeners from the RPCListeners defined // in the config. for _, grpcEndpoint := range cfg.RPCListeners { @@ -245,7 +243,8 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg, grpcListeners, &ListenerWithSignal{ Listener: lis, Ready: make(chan struct{}), - }) + }, + ) } } From 08b196e236481c91b4d69cbe9adca4771614d8fd Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 4 Nov 2021 15:20:54 +0100 Subject: [PATCH 2/3] config_builder: always send admin mac on chan --- config_builder.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/config_builder.go b/config_builder.go index a2ae613eb..b30a74f6d 100644 --- a/config_builder.go +++ b/config_builder.go @@ -422,28 +422,29 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context, return nil, nil, nil, err } + // Send an admin macaroon to all our listeners that requested + // one by setting a non-nil macaroon channel. + adminMacBytes, err := bakeMacaroon( + ctx, macaroonService, adminPermissions(), + ) + if err != nil { + return nil, nil, nil, err + } + for _, lis := range grpcListeners { + if lis.MacChan != nil { + lis.MacChan <- adminMacBytes + } + } + // In case we actually needed to unlock the wallet, we now need // to create an instance of the admin macaroon and send it to // the unlocker so it can forward it to the user. In no seed // backup mode, there's nobody listening on the channel and we'd // block here forever. if !d.cfg.NoSeedBackup { - adminMacBytes, err := bakeMacaroon( - ctx, macaroonService, adminPermissions(), - ) - if err != nil { - return nil, nil, nil, err - } - // The channel is buffered by one element so writing // should not block here. walletInitParams.MacResponseChan <- adminMacBytes - - for _, lis := range grpcListeners { - if lis.MacChan != nil { - lis.MacChan <- adminMacBytes - } - } } // If the user requested a stateless initialization, no macaroon From 77e457a48e86a4a1f5b89ce048d2220bee05e568 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 4 Nov 2021 17:50:36 +0100 Subject: [PATCH 3/3] docs: update release notes --- docs/release-notes/release-notes-0.14.0.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/release-notes/release-notes-0.14.0.md b/docs/release-notes/release-notes-0.14.0.md index f2e2526c1..c1fa4b253 100644 --- a/docs/release-notes/release-notes-0.14.0.md +++ b/docs/release-notes/release-notes-0.14.0.md @@ -615,6 +615,9 @@ messages directly. There is no routing/path finding involved. the first one was successful]( https://github.com/lightningnetwork/lnd/pull/5925) +* [Fixed an issue with external listeners and the `--noseedbackup` development + flag](https://github.com/lightningnetwork/lnd/pull/5930). + ## Documentation The [code contribution guidelines have been updated to mention the new