mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
subservers: add Impl to subservers, GetServer to mgr
This commit is contained in:
parent
d368f8a8fe
commit
57c40e5ad8
6 changed files with 76 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/lightninglabs/faraday/frdrpcserver"
|
||||
"github.com/lightninglabs/faraday/frdrpcserver/perms"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/taproot-assets/fn"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"google.golang.org/grpc"
|
||||
"gopkg.in/macaroon-bakery.v2/bakery"
|
||||
|
|
@ -126,3 +127,13 @@ func (f *faradaySubServer) Permissions() map[string][]bakery.Op {
|
|||
func (f *faradaySubServer) WhiteListedURLs() map[string]struct{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Impl returns the actual implementation of the sub-server. This might not be
|
||||
// set if the sub-server is running in remote mode.
|
||||
func (f *faradaySubServer) Impl() fn.Option[any] {
|
||||
if f.RPCServer == nil {
|
||||
return fn.None[any]()
|
||||
}
|
||||
|
||||
return fn.Some[any](f.RPCServer)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
restProxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/taproot-assets/fn"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/macaroons"
|
||||
"google.golang.org/grpc"
|
||||
|
|
@ -62,4 +63,8 @@ type SubServer interface {
|
|||
// WhiteListedURLs returns a map of all the sub-server's URLs that can
|
||||
// be accessed without a macaroon.
|
||||
WhiteListedURLs() map[string]struct{}
|
||||
|
||||
// Impl returns the actual implementation of the sub-server. This might
|
||||
// not be set if the sub-server is running in remote mode.
|
||||
Impl() fn.Option[any]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/lightninglabs/loop/loopd"
|
||||
"github.com/lightninglabs/loop/loopd/perms"
|
||||
"github.com/lightninglabs/loop/looprpc"
|
||||
"github.com/lightninglabs/taproot-assets/fn"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"google.golang.org/grpc"
|
||||
"gopkg.in/macaroon-bakery.v2/bakery"
|
||||
|
|
@ -136,3 +137,13 @@ func (l *loopSubServer) Permissions() map[string][]bakery.Op {
|
|||
func (l *loopSubServer) WhiteListedURLs() map[string]struct{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Impl returns the actual implementation of the sub-server. This might not be
|
||||
// set if the sub-server is running in remote mode.
|
||||
func (l *loopSubServer) Impl() fn.Option[any] {
|
||||
if l.Daemon == nil {
|
||||
return fn.None[any]()
|
||||
}
|
||||
|
||||
return fn.Some[any](l.Daemon)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,6 +90,19 @@ func (s *Manager) AddServer(ss SubServer, enable bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// GetServer returns the sub-server with the given name if it exists.
|
||||
func (s *Manager) GetServer(name string) (SubServer, bool) {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
ss, ok := s.servers[name]
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
return ss.SubServer, true
|
||||
}
|
||||
|
||||
// StartIntegratedServers starts all the manager's sub-servers that should be
|
||||
// started in integrated mode.
|
||||
func (s *Manager) StartIntegratedServers(lndClient lnrpc.LightningClient,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/lightninglabs/pool"
|
||||
"github.com/lightninglabs/pool/perms"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightninglabs/taproot-assets/fn"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"google.golang.org/grpc"
|
||||
"gopkg.in/macaroon-bakery.v2/bakery"
|
||||
|
|
@ -126,3 +127,13 @@ func (p *poolSubServer) Permissions() map[string][]bakery.Op {
|
|||
func (p *poolSubServer) WhiteListedURLs() map[string]struct{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Impl returns the actual implementation of the sub-server. This might not be
|
||||
// set if the sub-server is running in remote mode.
|
||||
func (p *poolSubServer) Impl() fn.Option[any] {
|
||||
if p.Server == nil {
|
||||
return fn.None[any]()
|
||||
}
|
||||
|
||||
return fn.Some[any](p.Server)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/lightninglabs/lndclient"
|
||||
tap "github.com/lightninglabs/taproot-assets"
|
||||
"github.com/lightninglabs/taproot-assets/address"
|
||||
"github.com/lightninglabs/taproot-assets/fn"
|
||||
"github.com/lightninglabs/taproot-assets/perms"
|
||||
"github.com/lightninglabs/taproot-assets/tapcfg"
|
||||
"github.com/lightninglabs/taproot-assets/taprpc"
|
||||
|
|
@ -177,6 +178,20 @@ func (t *taprootAssetsSubServer) RegisterRestService(ctx context.Context,
|
|||
return err
|
||||
}
|
||||
|
||||
err = rfqrpc.RegisterRfqHandlerFromEndpoint(
|
||||
ctx, mux, endpoint, dialOpts,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = tchrpc.RegisterTaprootAssetChannelsHandlerFromEndpoint(
|
||||
ctx, mux, endpoint, dialOpts,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = universerpc.RegisterUniverseHandlerFromEndpoint(
|
||||
ctx, mux, endpoint, dialOpts,
|
||||
)
|
||||
|
|
@ -239,3 +254,13 @@ func (t *taprootAssetsSubServer) WhiteListedURLs() map[string]struct{} {
|
|||
t.cfg.RpcConf.AllowPublicStats || t.remote,
|
||||
)
|
||||
}
|
||||
|
||||
// Impl returns the actual implementation of the sub-server. This might not be
|
||||
// set if the sub-server is running in remote mode.
|
||||
func (t *taprootAssetsSubServer) Impl() fn.Option[any] {
|
||||
if t.Server == nil {
|
||||
return fn.None[any]()
|
||||
}
|
||||
|
||||
return fn.Some[any](t.Server)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue