mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
session: move MacaroonBaker to macaroons package
Move the MacaroonBaker type to the new macaroons package to avoid import cycles in future.
This commit is contained in:
parent
4d22dfb7e9
commit
402373cfca
4 changed files with 9 additions and 9 deletions
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/lightninglabs/lightning-terminal/litrpc"
|
||||
litmac "github.com/lightninglabs/lightning-terminal/macaroons"
|
||||
"github.com/lightninglabs/lightning-terminal/session"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/macaroons"
|
||||
|
|
@ -23,12 +22,12 @@ type RPCServer struct {
|
|||
|
||||
service *InterceptorService
|
||||
|
||||
superMacBaker session.MacaroonBaker
|
||||
superMacBaker litmac.Baker
|
||||
}
|
||||
|
||||
// NewRPCServer returns a new RPC server for the given service.
|
||||
func NewRPCServer(service *InterceptorService,
|
||||
superMacBaker session.MacaroonBaker) *RPCServer {
|
||||
superMacBaker litmac.Baker) *RPCServer {
|
||||
|
||||
return &RPCServer{
|
||||
service: service,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package macaroons
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
|
|
@ -10,6 +11,10 @@ import (
|
|||
"gopkg.in/macaroon.v2"
|
||||
)
|
||||
|
||||
// Baker is a function type for baking a super macaroon.
|
||||
type Baker func(ctx context.Context, rootKeyID uint64,
|
||||
perms []bakery.Op, caveats []macaroon.Caveat) (string, error)
|
||||
|
||||
// RootKeyIDFromMacaroon extracts the root key ID of the passed macaroon.
|
||||
func RootKeyIDFromMacaroon(mac *macaroon.Macaroon) (uint64, error) {
|
||||
rawID := mac.Id()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
|
|
@ -72,10 +71,6 @@ type Session struct {
|
|||
GroupID ID
|
||||
}
|
||||
|
||||
// MacaroonBaker is a function type for baking a super macaroon.
|
||||
type MacaroonBaker func(ctx context.Context, rootKeyID uint64,
|
||||
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,
|
||||
expiry time.Time, serverAddr string, devServer bool, perms []bakery.Op,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"github.com/lightninglabs/lightning-terminal/firewall"
|
||||
"github.com/lightninglabs/lightning-terminal/firewalldb"
|
||||
"github.com/lightninglabs/lightning-terminal/litrpc"
|
||||
litmac "github.com/lightninglabs/lightning-terminal/macaroons"
|
||||
"github.com/lightninglabs/lightning-terminal/perms"
|
||||
"github.com/lightninglabs/lightning-terminal/rules"
|
||||
"github.com/lightninglabs/lightning-terminal/session"
|
||||
|
|
@ -62,7 +63,7 @@ type sessionRpcServerConfig struct {
|
|||
basicAuth string
|
||||
grpcOptions []grpc.ServerOption
|
||||
registerGrpcServers func(server *grpc.Server)
|
||||
superMacBaker session.MacaroonBaker
|
||||
superMacBaker litmac.Baker
|
||||
firstConnectionDeadline time.Duration
|
||||
permMgr *perms.Manager
|
||||
actionsDB *firewalldb.DB
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue