Documentation
¶
Index ¶
- Constants
- func GenerateAdminMacaroon(rootKey []byte) (*macaroon.Macaroon, error)
- func MacaroonInterceptor(rootKey []byte) grpc.UnaryServerInterceptor
- func MacaroonStreamInterceptor(rootKey []byte) grpc.StreamServerInterceptor
- func ReadAdminMacaroon(path string) (*macaroon.Macaroon, error)
- func ReadOrCreateRootKey(path string) ([]byte, error)
- func UseLogger(logger btclog.Logger)
- func WriteAdminMacaroon(mac *macaroon.Macaroon, path string) error
- type Server
- func (s *Server) CreateService(ctx context.Context, req *adminrpc.CreateServiceRequest) (*adminrpc.Service, error)
- func (s *Server) DeleteService(ctx context.Context, req *adminrpc.DeleteServiceRequest) (*adminrpc.DeleteServiceResponse, error)
- func (s *Server) GetHealth(_ context.Context, _ *adminrpc.GetHealthRequest) (*adminrpc.GetHealthResponse, error)
- func (s *Server) GetInfo(_ context.Context, _ *adminrpc.GetInfoRequest) (*adminrpc.GetInfoResponse, error)
- func (s *Server) GetStats(ctx context.Context, req *adminrpc.GetStatsRequest) (*adminrpc.GetStatsResponse, error)
- func (s *Server) ListServices(_ context.Context, _ *adminrpc.ListServicesRequest) (*adminrpc.ListServicesResponse, error)
- func (s *Server) ListTokens(ctx context.Context, req *adminrpc.ListTokensRequest) (*adminrpc.ListTokensResponse, error)
- func (s *Server) ListTransactions(ctx context.Context, req *adminrpc.ListTransactionsRequest) (*adminrpc.ListTransactionsResponse, error)
- func (s *Server) RevokeToken(ctx context.Context, req *adminrpc.RevokeTokenRequest) (*adminrpc.RevokeTokenResponse, error)
- func (s *Server) UpdateService(ctx context.Context, req *adminrpc.UpdateServiceRequest) (*adminrpc.Service, error)
- type ServerConfig
- type ServiceStore
Constants ¶
const Subsystem = "ADMN"
Subsystem defines the logging code for this subsystem.
Variables ¶
This section is empty.
Functions ¶
func GenerateAdminMacaroon ¶
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 ¶
ReadAdminMacaroon reads and deserializes a macaroon from the given path.
func ReadOrCreateRootKey ¶
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.
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 ¶
func (s *Server) DeleteService(ctx context.Context, req *adminrpc.DeleteServiceRequest) ( *adminrpc.DeleteServiceResponse, error)
DeleteService removes a backend service by name.
func (*Server) GetHealth ¶
func (s *Server) GetHealth(_ context.Context, _ *adminrpc.GetHealthRequest) (*adminrpc.GetHealthResponse, error)
GetHealth returns a simple health check response.
func (*Server) GetInfo ¶
func (s *Server) GetInfo(_ context.Context, _ *adminrpc.GetInfoRequest) (*adminrpc.GetInfoResponse, error)
GetInfo returns basic server information.
func (*Server) GetStats ¶
func (s *Server) GetStats(ctx context.Context, req *adminrpc.GetStatsRequest) (*adminrpc.GetStatsResponse, error)
GetStats returns aggregated revenue and transaction statistics.
func (*Server) ListServices ¶
func (s *Server) ListServices(_ context.Context, _ *adminrpc.ListServicesRequest) ( *adminrpc.ListServicesResponse, error)
ListServices returns the current list of configured services.
func (*Server) ListTokens ¶
func (s *Server) ListTokens(ctx context.Context, req *adminrpc.ListTokensRequest) ( *adminrpc.ListTokensResponse, error)
ListTokens returns settled transactions representing active L402 tokens.
func (*Server) ListTransactions ¶
func (s *Server) ListTransactions(ctx context.Context, req *adminrpc.ListTransactionsRequest) ( *adminrpc.ListTransactionsResponse, error)
ListTransactions returns a paginated list of L402 transactions.
func (*Server) RevokeToken ¶
func (s *Server) RevokeToken(ctx context.Context, req *adminrpc.RevokeTokenRequest) ( *adminrpc.RevokeTokenResponse, error)
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.