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 committed 2022-08-12 11:34:44 -04:00
1 parent 4b14226e81
commit f1ed9754c2
1 file changed
+12
+12
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