diff --git a/feature/manager.go b/feature/manager.go index 50a54d625..9d5d1cad4 100644 --- a/feature/manager.go +++ b/feature/manager.go @@ -91,6 +91,21 @@ func newManager(cfg Config, desc setDesc) (*Manager, error) { if cfg.NoAnchors { raw.Unset(lnwire.AnchorsZeroFeeHtlcTxOptional) raw.Unset(lnwire.AnchorsZeroFeeHtlcTxRequired) + + // If anchors are disabled, then we also need to + // disable all other features that depend on it as + // well, as otherwise we may create an invalid feature + // bit set. + for bit, depFeatures := range deps { + for depFeature := range depFeatures { + switch { + case depFeature == lnwire.AnchorsZeroFeeHtlcTxRequired: + fallthrough + case depFeature == lnwire.AnchorsZeroFeeHtlcTxOptional: + raw.Unset(bit) + } + } + } } if cfg.NoWumbo { raw.Unset(lnwire.WumboChannelsOptional) diff --git a/feature/manager_internal_test.go b/feature/manager_internal_test.go index 9c97bd052..2778a86d9 100644 --- a/feature/manager_internal_test.go +++ b/feature/manager_internal_test.go @@ -52,6 +52,12 @@ var managerTests = []managerTest{ NoStaticRemoteKey: true, }, }, + { + name: "anchors should disable anything dependent on it", + cfg: Config{ + NoAnchors: true, + }, + }, } // TestManager asserts basic initialazation and operation of a feature manager, @@ -104,6 +110,10 @@ func testManager(t *testing.T, test managerTest) { if test.cfg.NoStaticRemoteKey { assertUnset(lnwire.StaticRemoteKeyOptional) } + if test.cfg.NoAnchors { + assertUnset(lnwire.ScriptEnforcedLeaseRequired) + assertUnset(lnwire.ScriptEnforcedLeaseOptional) + } assertUnset(unknownFeature) }