config_builder: specify root key during wallet init

This sets the macaroon root key during wallet initialization when one
is provided in the init wallet params.
This commit is contained in:
Daniel McNally 2022-04-25 00:52:31 -04:00
parent 4b14226e81
commit f1ed9754c2
No known key found for this signature in database
GPG Key ID: BC19D851B2FC3A00

View File

@ -426,6 +426,17 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
return nil, nil, nil, err
}
// If we have a macaroon root key from the init wallet params,
// set the root key before baking any macaroons.
if len(walletInitParams.MacRootKey) > 0 {
err := macaroonService.SetRootKey(
walletInitParams.MacRootKey,
)
if err != nil {
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(
@ -1065,6 +1076,7 @@ func waitForWalletPassword(cfg *Config,
UnloadWallet: loader.UnloadWallet,
StatelessInit: initMsg.StatelessInit,
MacResponseChan: pwService.MacResponseChan,
MacRootKey: initMsg.MacRootKey,
}, nil
// The wallet has already been created in the past, and is simply being