config_builder: always send admin mac on chan

This commit is contained in:
Oliver Gugger
2021-11-04 15:20:54 +01:00
parent 87c5b76e4d
commit 08b196e236

View File

@ -422,28 +422,29 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
return nil, nil, nil, err return nil, nil, nil, err
} }
// In case we actually needed to unlock the wallet, we now need // Send an admin macaroon to all our listeners that requested
// to create an instance of the admin macaroon and send it to // one by setting a non-nil macaroon channel.
// 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( adminMacBytes, err := bakeMacaroon(
ctx, macaroonService, adminPermissions(), ctx, macaroonService, adminPermissions(),
) )
if err != nil { if err != nil {
return nil, nil, nil, err 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 { for _, lis := range grpcListeners {
if lis.MacChan != nil { if lis.MacChan != nil {
lis.MacChan <- adminMacBytes 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 {
// The channel is buffered by one element so writing
// should not block here.
walletInitParams.MacResponseChan <- adminMacBytes
} }
// If the user requested a stateless initialization, no macaroon // If the user requested a stateless initialization, no macaroon