mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
rpcperms+lnd: use macaroon service from interceptor chain
We'll refactor the wallet creation and unlock process in a following commit and want to make it possible to not need a direct reference to the macaroon service in our main function. Since we store it in the interceptor chain anyway (if we're using macaroons in the first place), we might as well use the instance there directly.
This commit is contained in:
parent
d12154154a
commit
b22f51098a
4
lnd.go
4
lnd.go
@ -917,8 +917,8 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error
|
||||
// Now we have created all dependencies necessary to populate and
|
||||
// start the RPC server.
|
||||
err = rpcServer.addDeps(
|
||||
server, macaroonService, cfg.SubRPCServers, atplManager,
|
||||
server.invoices, tower, chainedAcceptor,
|
||||
server, interceptorChain.MacaroonService(), cfg.SubRPCServers,
|
||||
atplManager, server.invoices, tower, chainedAcceptor,
|
||||
)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("unable to add deps to RPC server: %v", err)
|
||||
|
@ -386,6 +386,15 @@ func (r *InterceptorChain) AddMacaroonService(svc *macaroons.Service) {
|
||||
r.svc = svc
|
||||
}
|
||||
|
||||
// MacaroonService returns the currently registered macaroon service. This might
|
||||
// be nil if none was registered (yet).
|
||||
func (r *InterceptorChain) MacaroonService() *macaroons.Service {
|
||||
r.RLock()
|
||||
defer r.RUnlock()
|
||||
|
||||
return r.svc
|
||||
}
|
||||
|
||||
// AddPermission adds a new macaroon rule for the given method.
|
||||
func (r *InterceptorChain) AddPermission(method string, ops []bakery.Op) error {
|
||||
r.Lock()
|
||||
|
Loading…
Reference in New Issue
Block a user