mirror of
https://github.com/aljazceru/breez-lnd.git
synced 2025-12-17 06:04:20 +01:00
feature: if a bit is unset, then all other features that dep it should be
This fixes an issue where if one tries to unset a feature like anchors, and other feature depend on it, then `lnd` fails to start as it realizes that its dependnacy set is inconsistent. Fixes https://github.com/lightningnetwork/lnd/issues/6002
This commit is contained in:
committed by
Oliver Gugger
parent
80720cb63f
commit
31ae48c59c
@@ -91,6 +91,21 @@ func newManager(cfg Config, desc setDesc) (*Manager, error) {
|
|||||||
if cfg.NoAnchors {
|
if cfg.NoAnchors {
|
||||||
raw.Unset(lnwire.AnchorsZeroFeeHtlcTxOptional)
|
raw.Unset(lnwire.AnchorsZeroFeeHtlcTxOptional)
|
||||||
raw.Unset(lnwire.AnchorsZeroFeeHtlcTxRequired)
|
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 {
|
if cfg.NoWumbo {
|
||||||
raw.Unset(lnwire.WumboChannelsOptional)
|
raw.Unset(lnwire.WumboChannelsOptional)
|
||||||
|
|||||||
@@ -52,6 +52,12 @@ var managerTests = []managerTest{
|
|||||||
NoStaticRemoteKey: true,
|
NoStaticRemoteKey: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "anchors should disable anything dependent on it",
|
||||||
|
cfg: Config{
|
||||||
|
NoAnchors: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestManager asserts basic initialazation and operation of a feature manager,
|
// 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 {
|
if test.cfg.NoStaticRemoteKey {
|
||||||
assertUnset(lnwire.StaticRemoteKeyOptional)
|
assertUnset(lnwire.StaticRemoteKeyOptional)
|
||||||
}
|
}
|
||||||
|
if test.cfg.NoAnchors {
|
||||||
|
assertUnset(lnwire.ScriptEnforcedLeaseRequired)
|
||||||
|
assertUnset(lnwire.ScriptEnforcedLeaseOptional)
|
||||||
|
}
|
||||||
|
|
||||||
assertUnset(unknownFeature)
|
assertUnset(unknownFeature)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user