Documentation ¶
Overview ¶
Package frdrpcserver contains the server logic for faraday's grpc server which serves requests for close recommendations.
The Faraday server interface is implemented by the RPCServer struct. To keep this file readable, each function implemented by the interface has a file named after the function call which contains rpc parsing code for the request and response. If the call requires extensive additional logic, and unexported function with the same name should be created in this file as well.
Index ¶
- Constants
- Variables
- func UseLogger(logger btclog.Logger)
- type Config
- type RPCServer
- func (s *RPCServer) ChannelInsights(ctx context.Context, _ *frdrpc.ChannelInsightsRequest) (*frdrpc.ChannelInsightsResponse, error)
- func (s *RPCServer) CloseReport(ctx context.Context, req *frdrpc.CloseReportRequest) (*frdrpc.CloseReportResponse, error)
- func (s *RPCServer) ExchangeRate(ctx context.Context, req *frdrpc.ExchangeRateRequest) (*frdrpc.ExchangeRateResponse, error)
- func (s *RPCServer) NodeAudit(ctx context.Context, req *frdrpc.NodeAuditRequest) (*frdrpc.NodeAuditResponse, error)
- func (s *RPCServer) OutlierRecommendations(ctx context.Context, req *frdrpc.OutlierRecommendationsRequest) (*frdrpc.CloseRecommendationsResponse, error)
- func (s *RPCServer) RevenueReport(ctx context.Context, req *frdrpc.RevenueReportRequest) (*frdrpc.RevenueReportResponse, error)
- func (s *RPCServer) Start() error
- func (s *RPCServer) StartAsSubserver(lndClient lndclient.LndServices, withMacaroonService bool) error
- func (s *RPCServer) Stop() error
- func (s *RPCServer) ThresholdRecommendations(ctx context.Context, req *frdrpc.ThresholdRecommendationsRequest) (*frdrpc.CloseRecommendationsResponse, error)
- func (s *RPCServer) ValidateMacaroon(ctx context.Context, requiredPermissions []bakery.Op, fullMethod string) error
Constants ¶
const Subsystem = "FRPC"
Subsystem defines the logging code for this subsystem.
Variables ¶
var ( // ErrNoCategoryName is returned if a category does not have a name. ErrNoCategoryName = errors.New("category must have a name") // ErrSetChain is returned when on on/off chain boolean is set for // a category ErrSetChain = errors.New("category must be for on chain, off chain " + "or both") )
var ( // ErrBitcoinNodeRequired is required when an endpoint which requires // a bitcoin node backend is hit and we are not connected to one. ErrBitcoinNodeRequired = errors.New("bitcoin node required") )
Functions ¶
Types ¶
type Config ¶
type Config struct { // Lnd is a client which can be used to query lnd. Lnd lndclient.LndServices // RPCListen is the address:port that the gRPC server should listen on. RPCListen string // RESTListen is the address:port that the REST server should listen on. RESTListen string // CORSOrigin specifies the CORS header that should be set on REST // responses. No header is added if the value is empty. CORSOrigin string // BitcoinClient is set if the client opted to connect to a bitcoin // backend, if not, it will be nil. BitcoinClient chain.BitcoinClient // TLSServerConfig is the configuration to serve a secure connection // over TLS. TLSServerConfig *tls.Config // RestClientConfig is the client configuration to connect to a TLS // server started with the TLS config above. This is used for the REST // proxy that connects internally to the gRPC server and therefore is a // TLS client. RestClientConfig *credentials.TransportCredentials // FaradayDir is the main directory faraday uses. The macaroon database // will be created there. FaradayDir string // MacaroonPath is the full path to the default faraday macaroon file // that is created automatically. This path normally is within // FaradayDir unless otherwise specified by the user. MacaroonPath string }
Config provides closures and settings required to run the rpc server.
type RPCServer ¶
type RPCServer struct { // Required by the grpc-gateway/v2 library for forward compatibility. // Must be after the atomically used variables to not break struct // alignment. frdrpc.UnimplementedFaradayServerServer // contains filtered or unexported fields }
RPCServer implements the faraday service, serving requests over grpc.
func NewRPCServer ¶
NewRPCServer returns a server which will listen for rpc requests on the rpc listen address provided. Note that the server returned is not running, and should be started using Start().
func (*RPCServer) ChannelInsights ¶
func (s *RPCServer) ChannelInsights(ctx context.Context, _ *frdrpc.ChannelInsightsRequest) (*frdrpc.ChannelInsightsResponse, error)
ChannelInsights returns the channel insights for our currently open set of channels.
func (*RPCServer) CloseReport ¶
func (s *RPCServer) CloseReport(ctx context.Context, req *frdrpc.CloseReportRequest) (*frdrpc.CloseReportResponse, error)
CloseReport returns a close report for the channel provided. Note that this endpoint requires connection to an external bitcoind node.
func (*RPCServer) ExchangeRate ¶
func (s *RPCServer) ExchangeRate(ctx context.Context, req *frdrpc.ExchangeRateRequest) (*frdrpc.ExchangeRateResponse, error)
ExchangeRate provides a fiat estimate for a set of timestamped bitcoin prices.
func (*RPCServer) NodeAudit ¶
func (s *RPCServer) NodeAudit(ctx context.Context, req *frdrpc.NodeAuditRequest) (*frdrpc.NodeAuditResponse, error)
NodeAudit returns an on chain report for the period requested.
func (*RPCServer) OutlierRecommendations ¶
func (s *RPCServer) OutlierRecommendations(ctx context.Context, req *frdrpc.OutlierRecommendationsRequest) (*frdrpc.CloseRecommendationsResponse, error)
OutlierRecommendations provides a set of close recommendations for the current set of open channels based on whether they are outliers.
func (*RPCServer) RevenueReport ¶
func (s *RPCServer) RevenueReport(ctx context.Context, req *frdrpc.RevenueReportRequest) (*frdrpc.RevenueReportResponse, error)
RevenueReport returns a pairwise revenue report for a channel over the period requested.
func (*RPCServer) StartAsSubserver ¶
func (s *RPCServer) StartAsSubserver(lndClient lndclient.LndServices, withMacaroonService bool) error
StartAsSubserver is an alternative to Start where the RPC server does not create its own gRPC server but registers to an existing one. The same goes for REST (if enabled), instead of creating an own mux and HTTP server, we register to an existing one.
func (*RPCServer) ThresholdRecommendations ¶
func (s *RPCServer) ThresholdRecommendations(ctx context.Context, req *frdrpc.ThresholdRecommendationsRequest) (*frdrpc.CloseRecommendationsResponse, error)
ThresholdRecommendations provides a set of close recommendations for the current set of open channels based on whether they are above or below a given threshold.
func (*RPCServer) ValidateMacaroon ¶
func (s *RPCServer) ValidateMacaroon(ctx context.Context, requiredPermissions []bakery.Op, fullMethod string) error
ValidateMacaroon extracts the macaroon from the context's gRPC metadata, checks its signature, makes sure all specified permissions for the called method are contained within and finally ensures all caveat conditions are met. A non-nil error is returned if any of the checks fail. This method is needed to enable faraday running as an external subserver in the same process as lnd but still validate its own macaroons.