Merge pull request #3262 from cfromknecht/watchtowerrpc-crash-fix

lnrpc/watchtowerrpc: prevent watchtowerrpc panic when tower not active
This commit is contained in:
Conner Fromknecht authored and GitHub committed 2019-07-02 18:07:53 -07:00
commit 5f4922cd57
3 files changed
+7 -1

No files matched your search

+3
View File
@@ -7,6 +7,9 @@ package watchtowerrpc
// 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.
type Config struct {
// Active indicates if the watchtower is enabled.
Active bool
// Tower is the active watchtower which serves as the primary source for
// information presented via RPC.
Tower WatchtowerBackend
+1 -1
View File
@@ -124,7 +124,7 @@ func (c *Handler) GetInfo(ctx context.Context,
// isActive returns nil if the tower backend is initialized, and the Handler can
// proccess RPC requests.
func (c *Handler) isActive() error {
if c.cfg.Tower != nil {
if c.cfg.Active {
return nil
}
return ErrTowerNotActive
+3
View File
@@ -216,6 +216,9 @@ func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
case *watchtowerrpc.Config:
subCfgValue := extractReflectValue(subCfg)
subCfgValue.FieldByName("Active").Set(
reflect.ValueOf(tower != nil),
)
subCfgValue.FieldByName("Tower").Set(
reflect.ValueOf(tower),
)