feature/manager: ensure all feature sets properly set deps

This commit is contained in:
Conner Fromknecht 2019-12-16 13:06:45 -08:00
parent 868a5425c1
commit 3208e287c3
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -63,14 +63,27 @@ func newManager(cfg Config, desc setDesc) (*Manager, error) {
} }
// Now, remove any features as directed by the config. // Now, remove any features as directed by the config.
for _, fv := range fsets { for set, raw := range fsets {
if cfg.NoTLVOnion { if cfg.NoTLVOnion {
fv.Unset(lnwire.TLVOnionPayloadOptional) raw.Unset(lnwire.TLVOnionPayloadOptional)
fv.Unset(lnwire.TLVOnionPayloadRequired) raw.Unset(lnwire.TLVOnionPayloadRequired)
raw.Unset(lnwire.PaymentAddrOptional)
raw.Unset(lnwire.PaymentAddrRequired)
raw.Unset(lnwire.MPPOptional)
raw.Unset(lnwire.MPPRequired)
} }
if cfg.NoStaticRemoteKey { if cfg.NoStaticRemoteKey {
fv.Unset(lnwire.StaticRemoteKeyOptional) raw.Unset(lnwire.StaticRemoteKeyOptional)
fv.Unset(lnwire.StaticRemoteKeyRequired) raw.Unset(lnwire.StaticRemoteKeyRequired)
}
// Ensure that all of our feature sets properly set any
// dependent features.
fv := lnwire.NewFeatureVector(raw, lnwire.Features)
err := ValidateDeps(fv)
if err != nil {
return nil, fmt.Errorf("invalid feature set %v: %v",
set, err)
} }
} }