mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-24 14:50:40 +01:00
Merge pull request #3262 from cfromknecht/watchtowerrpc-crash-fix
lnrpc/watchtowerrpc: prevent watchtowerrpc panic when tower not active
This commit is contained in:
commit
5f4922cd57
3 changed files with 7 additions and 1 deletions
|
@ -7,6 +7,9 @@ package watchtowerrpc
|
||||||
// fields with struct tags are meant to parsed as normal configuration options,
|
// fields with struct tags are meant to parsed as normal configuration options,
|
||||||
// while if able to be populated, the latter fields MUST also be specified.
|
// while if able to be populated, the latter fields MUST also be specified.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
// Active indicates if the watchtower is enabled.
|
||||||
|
Active bool
|
||||||
|
|
||||||
// Tower is the active watchtower which serves as the primary source for
|
// Tower is the active watchtower which serves as the primary source for
|
||||||
// information presented via RPC.
|
// information presented via RPC.
|
||||||
Tower WatchtowerBackend
|
Tower WatchtowerBackend
|
||||||
|
|
|
@ -124,7 +124,7 @@ func (c *Handler) GetInfo(ctx context.Context,
|
||||||
// isActive returns nil if the tower backend is initialized, and the Handler can
|
// isActive returns nil if the tower backend is initialized, and the Handler can
|
||||||
// proccess RPC requests.
|
// proccess RPC requests.
|
||||||
func (c *Handler) isActive() error {
|
func (c *Handler) isActive() error {
|
||||||
if c.cfg.Tower != nil {
|
if c.cfg.Active {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return ErrTowerNotActive
|
return ErrTowerNotActive
|
||||||
|
|
|
@ -216,6 +216,9 @@ func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
|
||||||
case *watchtowerrpc.Config:
|
case *watchtowerrpc.Config:
|
||||||
subCfgValue := extractReflectValue(subCfg)
|
subCfgValue := extractReflectValue(subCfg)
|
||||||
|
|
||||||
|
subCfgValue.FieldByName("Active").Set(
|
||||||
|
reflect.ValueOf(tower != nil),
|
||||||
|
)
|
||||||
subCfgValue.FieldByName("Tower").Set(
|
subCfgValue.FieldByName("Tower").Set(
|
||||||
reflect.ValueOf(tower),
|
reflect.ValueOf(tower),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue