macaroons: futher abstract NewService from root key store impl

In this commit, we modify the `macaroons.NewService` consturctor to
accept the main interface rather than the raw DB. This allows us to use
other backends other than bolt or the kvdb interface to store the
macaroon root keys.

We also create a new ExtendedRootKeyStore interface that implements some
of the more advanced features we use such as macaroon encryption and
password rotation.
This commit is contained in:
Olaoluwa Osuntokun
2022-05-06 16:58:10 -07:00
parent 947639bb60
commit e073b1d343
5 changed files with 91 additions and 24 deletions

View File

@@ -807,8 +807,12 @@ func (u *UnlockerService) ChangePassword(ctx context.Context,
// then close it again.
// Attempt to open the macaroon DB, unlock it and then change
// the passphrase.
rootKeyStore, err := macaroons.NewRootKeyStorage(u.macaroonDB)
if err != nil {
return nil, err
}
macaroonService, err := macaroons.NewService(
u.macaroonDB, "lnd", in.StatelessInit,
rootKeyStore, "lnd", in.StatelessInit,
)
if err != nil {
return nil, err