Skip to content

Commit 402373c

Browse files
committed
session: move MacaroonBaker to macaroons package
Move the MacaroonBaker type to the new macaroons package to avoid import cycles in future.
1 parent 4d22dfb commit 402373c

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

accounts/rpcserver.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/btcsuite/btcd/btcutil"
1010
"github.com/lightninglabs/lightning-terminal/litrpc"
1111
litmac "github.com/lightninglabs/lightning-terminal/macaroons"
12-
"github.com/lightninglabs/lightning-terminal/session"
1312
"github.com/lightningnetwork/lnd/lntypes"
1413
"github.com/lightningnetwork/lnd/lnwire"
1514
"github.com/lightningnetwork/lnd/macaroons"
@@ -23,12 +22,12 @@ type RPCServer struct {
2322

2423
service *InterceptorService
2524

26-
superMacBaker session.MacaroonBaker
25+
superMacBaker litmac.Baker
2726
}
2827

2928
// NewRPCServer returns a new RPC server for the given service.
3029
func NewRPCServer(service *InterceptorService,
31-
superMacBaker session.MacaroonBaker) *RPCServer {
30+
superMacBaker litmac.Baker) *RPCServer {
3231

3332
return &RPCServer{
3433
service: service,

macaroons/macaroons.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package macaroons
22

33
import (
4+
"context"
45
"fmt"
56
"strconv"
67

@@ -10,6 +11,10 @@ import (
1011
"gopkg.in/macaroon.v2"
1112
)
1213

14+
// Baker is a function type for baking a super macaroon.
15+
type Baker func(ctx context.Context, rootKeyID uint64,
16+
perms []bakery.Op, caveats []macaroon.Caveat) (string, error)
17+
1318
// RootKeyIDFromMacaroon extracts the root key ID of the passed macaroon.
1419
func RootKeyIDFromMacaroon(mac *macaroon.Macaroon) (uint64, error) {
1520
rawID := mac.Id()

session/interface.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package session
22

33
import (
4-
"context"
54
"fmt"
65
"time"
76

@@ -72,10 +71,6 @@ type Session struct {
7271
GroupID ID
7372
}
7473

75-
// MacaroonBaker is a function type for baking a super macaroon.
76-
type MacaroonBaker func(ctx context.Context, rootKeyID uint64,
77-
perms []bakery.Op, caveats []macaroon.Caveat) (string, error)
78-
7974
// NewSession creates a new session with the given user-defined parameters.
8075
func NewSession(id ID, localPrivKey *btcec.PrivateKey, label string, typ Type,
8176
expiry time.Time, serverAddr string, devServer bool, perms []bakery.Op,

session_rpcserver.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/lightninglabs/lightning-terminal/firewall"
1919
"github.com/lightninglabs/lightning-terminal/firewalldb"
2020
"github.com/lightninglabs/lightning-terminal/litrpc"
21+
litmac "github.com/lightninglabs/lightning-terminal/macaroons"
2122
"github.com/lightninglabs/lightning-terminal/perms"
2223
"github.com/lightninglabs/lightning-terminal/rules"
2324
"github.com/lightninglabs/lightning-terminal/session"
@@ -62,7 +63,7 @@ type sessionRpcServerConfig struct {
6263
basicAuth string
6364
grpcOptions []grpc.ServerOption
6465
registerGrpcServers func(server *grpc.Server)
65-
superMacBaker session.MacaroonBaker
66+
superMacBaker litmac.Baker
6667
firstConnectionDeadline time.Duration
6768
permMgr *perms.Manager
6869
actionsDB *firewalldb.DB

0 commit comments

Comments
 (0)