mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +01:00
Merge pull request #5930 from guggero/no-seed-backup-macaroon
config_builder: always send admin macaroon
This commit is contained in:
commit
54584aabb6
3 changed files with 21 additions and 18 deletions
|
@ -422,28 +422,29 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
|
||||||
return nil, nil, nil, err
|
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
|
// In case we actually needed to unlock the wallet, we now need
|
||||||
// to create an instance of the admin macaroon and send it to
|
// 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
|
// 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
|
// backup mode, there's nobody listening on the channel and we'd
|
||||||
// block here forever.
|
// block here forever.
|
||||||
if !d.cfg.NoSeedBackup {
|
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
|
// The channel is buffered by one element so writing
|
||||||
// should not block here.
|
// should not block here.
|
||||||
walletInitParams.MacResponseChan <- adminMacBytes
|
walletInitParams.MacResponseChan <- adminMacBytes
|
||||||
|
|
||||||
for _, lis := range grpcListeners {
|
|
||||||
if lis.MacChan != nil {
|
|
||||||
lis.MacChan <- adminMacBytes
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user requested a stateless initialization, no macaroon
|
// If the user requested a stateless initialization, no macaroon
|
||||||
|
|
|
@ -615,6 +615,9 @@ messages directly. There is no routing/path finding involved.
|
||||||
the first one was successful](
|
the first one was successful](
|
||||||
https://github.com/lightningnetwork/lnd/pull/5925)
|
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
|
## Documentation
|
||||||
|
|
||||||
The [code contribution guidelines have been updated to mention the new
|
The [code contribution guidelines have been updated to mention the new
|
||||||
|
|
9
lnd.go
9
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
|
// If we have chosen to start with a dedicated listener for the
|
||||||
// rpc server, we set it directly.
|
// rpc server, we set it directly.
|
||||||
var grpcListeners []*ListenerWithSignal
|
grpcListeners := append([]*ListenerWithSignal{}, lisCfg.RPCListeners...)
|
||||||
if len(lisCfg.RPCListeners) > 0 {
|
if len(grpcListeners) == 0 {
|
||||||
grpcListeners = append(grpcListeners, lisCfg.RPCListeners...)
|
|
||||||
} else {
|
|
||||||
// Otherwise we create listeners from the RPCListeners defined
|
// Otherwise we create listeners from the RPCListeners defined
|
||||||
// in the config.
|
// in the config.
|
||||||
for _, grpcEndpoint := range cfg.RPCListeners {
|
for _, grpcEndpoint := range cfg.RPCListeners {
|
||||||
|
@ -245,7 +243,8 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg,
|
||||||
grpcListeners, &ListenerWithSignal{
|
grpcListeners, &ListenerWithSignal{
|
||||||
Listener: lis,
|
Listener: lis,
|
||||||
Ready: make(chan struct{}),
|
Ready: make(chan struct{}),
|
||||||
})
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue