admin

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const Subsystem = "ADMN"

Subsystem defines the logging code for this subsystem.

Variables

This section is empty.

Functions

func GenerateAdminMacaroon

func GenerateAdminMacaroon(
	rootKey []byte) (*macaroon.Macaroon, error)

GenerateAdminMacaroon creates a new admin macaroon signed with the given root key.

func MacaroonInterceptor

func MacaroonInterceptor(
	rootKey []byte) grpc.UnaryServerInterceptor

MacaroonInterceptor returns a gRPC unary server interceptor that validates requests using macaroon-based authentication. The macaroon is expected in the gRPC metadata under the key "macaroon" as a hex-encoded string.

func MacaroonStreamInterceptor

func MacaroonStreamInterceptor(
	rootKey []byte) grpc.StreamServerInterceptor

MacaroonStreamInterceptor returns a gRPC stream server interceptor that validates requests using macaroon-based authentication.

func ReadAdminMacaroon

func ReadAdminMacaroon(path string) (*macaroon.Macaroon, error)

ReadAdminMacaroon reads and deserializes a macaroon from the given path.

func ReadOrCreateRootKey

func ReadOrCreateRootKey(path string) ([]byte, error)

ReadOrCreateRootKey reads a root key from the given file path, or generates a new random 32-byte key and writes it to disk if the file does not exist. Storing the root key on disk rather than in the shared SecretStore avoids the root key being accessible via a well-known deterministic hash.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

func WriteAdminMacaroon

func WriteAdminMacaroon(mac *macaroon.Macaroon, path string) error

WriteAdminMacaroon serializes and writes the macaroon to the given path.

Types

type Server

type Server struct {
	adminrpc.UnimplementedAdminServer
	// contains filtered or unexported fields
}

Server implements the adminrpc.AdminServer gRPC interface. Thread safety for service reads/updates is provided by the serviceHolder and proxy mutexes; the Server itself does not need its own lock.

func NewServer

func NewServer(cfg ServerConfig) *Server

NewServer creates a new admin gRPC server with the given configuration.

func (*Server) CreateService

func (s *Server) CreateService(ctx context.Context,
	req *adminrpc.CreateServiceRequest) (*adminrpc.Service, error)

CreateService creates a new backend service. When a ServiceStore is configured, the service is persisted to the database and will survive restarts.

func (*Server) DeleteService

DeleteService removes a backend service by name.

func (*Server) GetHealth

GetHealth returns a simple health check response.

func (*Server) GetInfo

GetInfo returns basic server information.

func (*Server) GetStats

GetStats returns aggregated revenue and transaction statistics.

func (*Server) ListServices

ListServices returns the current list of configured services.

func (*Server) ListTokens

ListTokens returns settled transactions representing active L402 tokens.

func (*Server) ListTransactions

ListTransactions returns a paginated list of L402 transactions.

func (*Server) RevokeToken

RevokeToken revokes an L402 token by revoking its secret and deleting the transaction record.

func (*Server) UpdateService

func (s *Server) UpdateService(ctx context.Context,
	req *adminrpc.UpdateServiceRequest) (*adminrpc.Service, error)

UpdateService updates a service's mutable fields. When a ServiceStore is configured, the updated service is persisted to the database.

type ServerConfig

type ServerConfig struct {
	// Network is the Lightning Network being used (e.g. "mainnet",
	// "testnet", "regtest").
	Network string

	// ListenAddr is the address Aperture is listening on.
	ListenAddr string

	// Insecure indicates whether Aperture is running without TLS.
	Insecure bool

	// TransactionStore provides access to L402 transaction data.
	TransactionStore *aperturedb.L402TransactionsStore

	// Services returns the current list of configured services.
	Services func() []*proxy.Service

	// UpdateServices updates the proxy's service configuration.
	UpdateServices func([]*proxy.Service) error

	// SecretStore is the secret store for token revocation.
	SecretStore mint.SecretStore

	// ServiceStore is an optional persistent store for service
	// configurations. If nil, service changes are held in memory only.
	ServiceStore ServiceStore

	// MPPEnabled indicates whether MPP is enabled globally.
	MPPEnabled bool

	// SessionsEnabled indicates whether MPP sessions are enabled.
	SessionsEnabled bool

	// MPPRealm is the realm string used in MPP challenge headers.
	MPPRealm string
}

ServerConfig holds the dependencies for the admin gRPC server.

type ServiceStore

type ServiceStore interface {
	// UpsertService creates or updates a persisted service configuration.
	UpsertService(ctx context.Context,
		params aperturedb.ServiceParams) error

	// DeleteService removes a persisted service by name.
	DeleteService(ctx context.Context, name string) error
}

ServiceStore is an interface for persisting service configurations across restarts. When provided, service CRUD operations write through to both the in-memory proxy and the persistent store.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL