rpcserver+lnrpc: register REST subservers with root server
This commit is contained in:
parent
fe16be5bb8
commit
558d63718b
@ -8,6 +8,7 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec"
|
"github.com/btcsuite/btcd/btcec"
|
||||||
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
"github.com/lightningnetwork/lnd/autopilot"
|
"github.com/lightningnetwork/lnd/autopilot"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@ -129,6 +130,28 @@ func (s *Server) RegisterWithRootServer(grpcServer *grpc.Server) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterWithRestServer will be called by the root REST mux to direct a sub
|
||||||
|
// RPC server to register itself with the main REST mux server. Until this is
|
||||||
|
// called, each sub-server won't be able to have requests routed towards it.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||||
|
func (s *Server) RegisterWithRestServer(ctx context.Context,
|
||||||
|
mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error {
|
||||||
|
|
||||||
|
// We make sure that we register it with the main REST server to ensure
|
||||||
|
// all our methods are routed properly.
|
||||||
|
err := RegisterAutopilotHandlerFromEndpoint(ctx, mux, dest, opts)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Could not register Autopilot REST server "+
|
||||||
|
"with root REST server: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("Autopilot REST server successfully registered with " +
|
||||||
|
"root REST server")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Status returns the current status of the autopilot agent.
|
// Status returns the current status of the autopilot agent.
|
||||||
//
|
//
|
||||||
// NOTE: Part of the AutopilotServer interface.
|
// NOTE: Part of the AutopilotServer interface.
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
|
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@ -189,6 +190,28 @@ func (s *Server) RegisterWithRootServer(grpcServer *grpc.Server) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterWithRestServer will be called by the root REST mux to direct a sub
|
||||||
|
// RPC server to register itself with the main REST mux server. Until this is
|
||||||
|
// called, each sub-server won't be able to have requests routed towards it.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||||
|
func (s *Server) RegisterWithRestServer(ctx context.Context,
|
||||||
|
mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error {
|
||||||
|
|
||||||
|
// We make sure that we register it with the main REST server to ensure
|
||||||
|
// all our methods are routed properly.
|
||||||
|
err := RegisterChainNotifierHandlerFromEndpoint(ctx, mux, dest, opts)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Could not register ChainNotifier REST server "+
|
||||||
|
"with root REST server: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("ChainNotifier REST server successfully registered with " +
|
||||||
|
"root REST server")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// RegisterConfirmationsNtfn is a synchronous response-streaming RPC that
|
// RegisterConfirmationsNtfn is a synchronous response-streaming RPC that
|
||||||
// registers an intent for a client to be notified once a confirmation request
|
// registers an intent for a client to be notified once a confirmation request
|
||||||
// has reached its required number of confirmations on-chain.
|
// has reached its required number of confirmations on-chain.
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"gopkg.in/macaroon-bakery.v2/bakery"
|
"gopkg.in/macaroon-bakery.v2/bakery"
|
||||||
|
|
||||||
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
@ -164,6 +165,28 @@ func (s *Server) RegisterWithRootServer(grpcServer *grpc.Server) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterWithRestServer will be called by the root REST mux to direct a sub
|
||||||
|
// RPC server to register itself with the main REST mux server. Until this is
|
||||||
|
// called, each sub-server won't be able to have requests routed towards it.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||||
|
func (s *Server) RegisterWithRestServer(ctx context.Context,
|
||||||
|
mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error {
|
||||||
|
|
||||||
|
// We make sure that we register it with the main REST server to ensure
|
||||||
|
// all our methods are routed properly.
|
||||||
|
err := RegisterInvoicesHandlerFromEndpoint(ctx, mux, dest, opts)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Could not register Invoices REST server "+
|
||||||
|
"with root REST server: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("Invoices REST server successfully registered with " +
|
||||||
|
"root REST server")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// SubscribeSingleInvoice returns a uni-directional stream (server -> client)
|
// SubscribeSingleInvoice returns a uni-directional stream (server -> client)
|
||||||
// for notifying the client of state changes for a specified invoice.
|
// for notifying the client of state changes for a specified invoice.
|
||||||
func (s *Server) SubscribeSingleInvoice(req *SubscribeSingleInvoiceRequest,
|
func (s *Server) SubscribeSingleInvoice(req *SubscribeSingleInvoiceRequest,
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
@ -226,6 +227,28 @@ func (s *Server) RegisterWithRootServer(grpcServer *grpc.Server) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterWithRestServer will be called by the root REST mux to direct a sub
|
||||||
|
// RPC server to register itself with the main REST mux server. Until this is
|
||||||
|
// called, each sub-server won't be able to have requests routed towards it.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||||
|
func (s *Server) RegisterWithRestServer(ctx context.Context,
|
||||||
|
mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error {
|
||||||
|
|
||||||
|
// We make sure that we register it with the main REST server to ensure
|
||||||
|
// all our methods are routed properly.
|
||||||
|
err := RegisterRouterHandlerFromEndpoint(ctx, mux, dest, opts)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Could not register Router REST server "+
|
||||||
|
"with root REST server: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("Router REST server successfully registered with " +
|
||||||
|
"root REST server")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// SendPaymentV2 attempts to route a payment described by the passed
|
// SendPaymentV2 attempts to route a payment described by the passed
|
||||||
// PaymentRequest to the final destination. If we are unable to route the
|
// PaymentRequest to the final destination. If we are unable to route the
|
||||||
// payment, or cannot find a route that satisfies the constraints in the
|
// payment, or cannot find a route that satisfies the constraints in the
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/txscript"
|
"github.com/btcsuite/btcd/txscript"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
"github.com/lightningnetwork/lnd/input"
|
"github.com/lightningnetwork/lnd/input"
|
||||||
"github.com/lightningnetwork/lnd/keychain"
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
@ -174,6 +175,28 @@ func (s *Server) RegisterWithRootServer(grpcServer *grpc.Server) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterWithRestServer will be called by the root REST mux to direct a sub
|
||||||
|
// RPC server to register itself with the main REST mux server. Until this is
|
||||||
|
// called, each sub-server won't be able to have requests routed towards it.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||||
|
func (s *Server) RegisterWithRestServer(ctx context.Context,
|
||||||
|
mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error {
|
||||||
|
|
||||||
|
// We make sure that we register it with the main REST server to ensure
|
||||||
|
// all our methods are routed properly.
|
||||||
|
err := RegisterSignerHandlerFromEndpoint(ctx, mux, dest, opts)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Could not register Signer REST server "+
|
||||||
|
"with root REST server: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("Signer REST server successfully registered with " +
|
||||||
|
"root REST server")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// SignOutputRaw generates a signature for the passed transaction according to
|
// SignOutputRaw generates a signature for the passed transaction according to
|
||||||
// the data within the passed SignReq. If we're unable to find the keys that
|
// the data within the passed SignReq. If we're unable to find the keys that
|
||||||
// correspond to the KeyLocators in the SignReq then we'll return an error.
|
// correspond to the KeyLocators in the SignReq then we'll return an error.
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package lnrpc
|
package lnrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"gopkg.in/macaroon-bakery.v2/bakery"
|
"gopkg.in/macaroon-bakery.v2/bakery"
|
||||||
)
|
)
|
||||||
@ -36,6 +38,13 @@ type SubServer interface {
|
|||||||
// server. Until this is called, each sub-server won't be able to have
|
// server. Until this is called, each sub-server won't be able to have
|
||||||
// requests routed towards it.
|
// requests routed towards it.
|
||||||
RegisterWithRootServer(*grpc.Server) error
|
RegisterWithRootServer(*grpc.Server) error
|
||||||
|
|
||||||
|
// RegisterWithRestServer will be called by the root REST mux to direct
|
||||||
|
// a sub RPC server to register itself with the main REST mux server.
|
||||||
|
// Until this is called, each sub-server won't be able to have requests
|
||||||
|
// routed towards it.
|
||||||
|
RegisterWithRestServer(context.Context, *runtime.ServeMux, string,
|
||||||
|
[]grpc.DialOption) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubServerConfigDispatcher is an interface that all sub-servers will use to
|
// SubServerConfigDispatcher is an interface that all sub-servers will use to
|
||||||
|
@ -3,6 +3,7 @@ package verrpc
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
"github.com/lightningnetwork/lnd/build"
|
"github.com/lightningnetwork/lnd/build"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"gopkg.in/macaroon-bakery.v2/bakery"
|
"gopkg.in/macaroon-bakery.v2/bakery"
|
||||||
@ -57,6 +58,28 @@ func (s *Server) RegisterWithRootServer(grpcServer *grpc.Server) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterWithRestServer will be called by the root REST mux to direct a sub
|
||||||
|
// RPC server to register itself with the main REST mux server. Until this is
|
||||||
|
// called, each sub-server won't be able to have requests routed towards it.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||||
|
func (s *Server) RegisterWithRestServer(ctx context.Context,
|
||||||
|
mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error {
|
||||||
|
|
||||||
|
// We make sure that we register it with the main REST server to ensure
|
||||||
|
// all our methods are routed properly.
|
||||||
|
err := RegisterVersionerHandlerFromEndpoint(ctx, mux, dest, opts)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Could not register Versioner REST server "+
|
||||||
|
"with root REST server: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("Versioner REST server successfully registered with " +
|
||||||
|
"root REST server")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetVersion returns information about the compiled binary.
|
// GetVersion returns information about the compiled binary.
|
||||||
func (s *Server) GetVersion(_ context.Context,
|
func (s *Server) GetVersion(_ context.Context,
|
||||||
_ *VersionRequest) (*Version, error) {
|
_ *VersionRequest) (*Version, error) {
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/txscript"
|
"github.com/btcsuite/btcd/txscript"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcwallet/wtxmgr"
|
"github.com/btcsuite/btcwallet/wtxmgr"
|
||||||
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
"github.com/lightningnetwork/lnd/input"
|
"github.com/lightningnetwork/lnd/input"
|
||||||
"github.com/lightningnetwork/lnd/keychain"
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
"github.com/lightningnetwork/lnd/labels"
|
"github.com/lightningnetwork/lnd/labels"
|
||||||
@ -217,6 +218,28 @@ func (w *WalletKit) RegisterWithRootServer(grpcServer *grpc.Server) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterWithRestServer will be called by the root REST mux to direct a sub
|
||||||
|
// RPC server to register itself with the main REST mux server. Until this is
|
||||||
|
// called, each sub-server won't be able to have requests routed towards it.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||||
|
func (w *WalletKit) RegisterWithRestServer(ctx context.Context,
|
||||||
|
mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error {
|
||||||
|
|
||||||
|
// We make sure that we register it with the main REST server to ensure
|
||||||
|
// all our methods are routed properly.
|
||||||
|
err := RegisterWalletKitHandlerFromEndpoint(ctx, mux, dest, opts)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Could not register WalletKit REST server "+
|
||||||
|
"with root REST server: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("WalletKit REST server successfully registered with " +
|
||||||
|
"root REST server")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// ListUnspent returns useful information about each unspent output owned by the
|
// ListUnspent returns useful information about each unspent output owned by the
|
||||||
// wallet, as reported by the underlying `ListUnspentWitness`; the information
|
// wallet, as reported by the underlying `ListUnspentWitness`; the information
|
||||||
// returned is: outpoint, amount in satoshis, address, address type,
|
// returned is: outpoint, amount in satoshis, address, address type,
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
|
|
||||||
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"gopkg.in/macaroon-bakery.v2/bakery"
|
"gopkg.in/macaroon-bakery.v2/bakery"
|
||||||
@ -91,6 +92,28 @@ func (c *Handler) RegisterWithRootServer(grpcServer *grpc.Server) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterWithRestServer will be called by the root REST mux to direct a sub
|
||||||
|
// RPC server to register itself with the main REST mux server. Until this is
|
||||||
|
// called, each sub-server won't be able to have requests routed towards it.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||||
|
func (c *Handler) RegisterWithRestServer(ctx context.Context,
|
||||||
|
mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error {
|
||||||
|
|
||||||
|
// We make sure that we register it with the main REST server to ensure
|
||||||
|
// all our methods are routed properly.
|
||||||
|
err := RegisterWatchtowerHandlerFromEndpoint(ctx, mux, dest, opts)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Could not register Watchtower REST server "+
|
||||||
|
"with root REST server: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("Watchtower REST server successfully registered with " +
|
||||||
|
"root REST server")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// AddTower adds a new watchtower reachable at the given address and considers
|
// AddTower adds a new watchtower reachable at the given address and considers
|
||||||
// it for new sessions. If the watchtower already exists, then any new addresses
|
// it for new sessions. If the watchtower already exists, then any new addresses
|
||||||
// included will be considered when dialing it for session negotiations and
|
// included will be considered when dialing it for session negotiations and
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec"
|
"github.com/btcsuite/btcd/btcec"
|
||||||
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
"github.com/lightningnetwork/lnd/lncfg"
|
"github.com/lightningnetwork/lnd/lncfg"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
@ -121,6 +122,24 @@ func (c *WatchtowerClient) RegisterWithRootServer(grpcServer *grpc.Server) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterWithRestServer will be called by the root REST mux to direct a sub
|
||||||
|
// RPC server to register itself with the main REST mux server. Until this is
|
||||||
|
// called, each sub-server won't be able to have requests routed towards it.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||||
|
func (c *WatchtowerClient) RegisterWithRestServer(ctx context.Context,
|
||||||
|
mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error {
|
||||||
|
|
||||||
|
// We make sure that we register it with the main REST server to ensure
|
||||||
|
// all our methods are routed properly.
|
||||||
|
err := RegisterWatchtowerClientHandlerFromEndpoint(ctx, mux, dest, opts)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// isActive returns nil if the watchtower client is initialized so that we can
|
// isActive returns nil if the watchtower client is initialized so that we can
|
||||||
// process RPC requests.
|
// process RPC requests.
|
||||||
func (c *WatchtowerClient) isActive() error {
|
func (c *WatchtowerClient) isActive() error {
|
||||||
|
16
rpcserver.go
16
rpcserver.go
@ -791,23 +791,31 @@ func (r *rpcServer) Start() error {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Finally, start the REST proxy for our gRPC server above. We'll ensure
|
// Now start the REST proxy for our gRPC server above. We'll ensure
|
||||||
// we direct LND to connect to its loopback address rather than a
|
// we direct LND to connect to its loopback address rather than a
|
||||||
// wildcard to prevent certificate issues when accessing the proxy
|
// wildcard to prevent certificate issues when accessing the proxy
|
||||||
// externally.
|
// externally.
|
||||||
//
|
|
||||||
// TODO(roasbeef): eventually also allow the sub-servers to themselves
|
|
||||||
// have a REST proxy.
|
|
||||||
restMux := proxy.NewServeMux(customMarshalerOption)
|
restMux := proxy.NewServeMux(customMarshalerOption)
|
||||||
restCtx, restCancel := context.WithCancel(context.Background())
|
restCtx, restCancel := context.WithCancel(context.Background())
|
||||||
r.listenerCleanUp = append(r.listenerCleanUp, restCancel)
|
r.listenerCleanUp = append(r.listenerCleanUp, restCancel)
|
||||||
|
|
||||||
|
// With our custom REST proxy mux created, register our main RPC and
|
||||||
|
// give all subservers a chance to register as well.
|
||||||
err := lnrpc.RegisterLightningHandlerFromEndpoint(
|
err := lnrpc.RegisterLightningHandlerFromEndpoint(
|
||||||
restCtx, restMux, r.restProxyDest, r.restDialOpts,
|
restCtx, restMux, r.restProxyDest, r.restDialOpts,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
for _, subServer := range r.subServers {
|
||||||
|
err := subServer.RegisterWithRestServer(
|
||||||
|
restCtx, restMux, r.restProxyDest, r.restDialOpts,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to register REST sub-server "+
|
||||||
|
"%v with root: %v", subServer.Name(), err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Before listening on any of the interfaces, we also want to give the
|
// Before listening on any of the interfaces, we also want to give the
|
||||||
// external subservers a chance to register their own REST proxy stub
|
// external subservers a chance to register their own REST proxy stub
|
||||||
|
Loading…
Reference in New Issue
Block a user