diff --git a/subservers/faraday.go b/subservers/faraday.go index 9b9efd8e..9b8498ff 100644 --- a/subservers/faraday.go +++ b/subservers/faraday.go @@ -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) +} diff --git a/subservers/interface.go b/subservers/interface.go index cc7ed505..4ff0083c 100644 --- a/subservers/interface.go +++ b/subservers/interface.go @@ -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] } diff --git a/subservers/loop.go b/subservers/loop.go index 4281125f..8a405eb1 100644 --- a/subservers/loop.go +++ b/subservers/loop.go @@ -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) +} diff --git a/subservers/manager.go b/subservers/manager.go index e8159517..8d9f6b1b 100644 --- a/subservers/manager.go +++ b/subservers/manager.go @@ -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, diff --git a/subservers/pool.go b/subservers/pool.go index 9c476705..6a657612 100644 --- a/subservers/pool.go +++ b/subservers/pool.go @@ -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) +} diff --git a/subservers/taproot-assets.go b/subservers/taproot-assets.go index 6c6a15fc..039882f8 100644 --- a/subservers/taproot-assets.go +++ b/subservers/taproot-assets.go @@ -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) +}