mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
multi: refactor to not use session.MacaroonRecipe outside the package
In this commit, we refactor various uses of the session.MacaroonRecipe type outside of the session package. This is to decouple the baking of a super macaroon from the sessions package and will help avoid import cycles in future.
This commit is contained in:
parent
832fbad1c5
commit
4d22dfb7e9
4 changed files with 9 additions and 15 deletions
|
|
@ -87,12 +87,10 @@ func (s *RPCServer) CreateAccount(ctx context.Context,
|
|||
fmt.Sprintf("%s %x", CondAccount, account.ID[:]),
|
||||
)
|
||||
|
||||
macHex, err := s.superMacBaker(ctx, macRootKey, &session.MacaroonRecipe{
|
||||
Permissions: MacaroonPermissions,
|
||||
Caveats: []macaroon.Caveat{{
|
||||
Id: []byte(accountCaveat),
|
||||
}},
|
||||
})
|
||||
macHex, err := s.superMacBaker(
|
||||
ctx, macRootKey, MacaroonPermissions,
|
||||
[]macaroon.Caveat{{Id: []byte(accountCaveat)}},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error baking account macaroon: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ type Session struct {
|
|||
|
||||
// MacaroonBaker is a function type for baking a super macaroon.
|
||||
type MacaroonBaker func(ctx context.Context, rootKeyID uint64,
|
||||
recipe *MacaroonRecipe) (string, error)
|
||||
perms []bakery.Op, caveats []macaroon.Caveat) (string, error)
|
||||
|
||||
// NewSession creates a new session with the given user-defined parameters.
|
||||
func NewSession(id ID, localPrivKey *btcec.PrivateKey, label string, typ Type,
|
||||
|
|
|
|||
|
|
@ -424,11 +424,7 @@ func (s *sessionRpcServer) resumeSession(ctx context.Context,
|
|||
})
|
||||
|
||||
mac, err := s.cfg.superMacBaker(
|
||||
ctx, sess.MacaroonRootKey,
|
||||
&session.MacaroonRecipe{
|
||||
Permissions: permissions,
|
||||
Caveats: caveats,
|
||||
},
|
||||
ctx, sess.MacaroonRootKey, permissions, caveats,
|
||||
)
|
||||
if err != nil {
|
||||
log.Debugf("Not resuming session %x. Could not bake "+
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ import (
|
|||
"google.golang.org/grpc/test/bufconn"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"gopkg.in/macaroon-bakery.v2/bakery"
|
||||
"gopkg.in/macaroon.v2"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -430,11 +431,10 @@ func (g *LightningTerminal) start(ctx context.Context) error {
|
|||
}
|
||||
|
||||
superMacBaker := func(ctx context.Context, rootKeyID uint64,
|
||||
recipe *session.MacaroonRecipe) (string, error) {
|
||||
perms []bakery.Op, caveats []macaroon.Caveat) (string, error) {
|
||||
|
||||
return litmac.BakeSuperMacaroon(
|
||||
ctx, g.basicClient, rootKeyID,
|
||||
recipe.Permissions, recipe.Caveats,
|
||||
ctx, g.basicClient, rootKeyID, perms, caveats,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue