From 3208e287c3bd6155df944cf8d022d42c078795f0 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Mon, 16 Dec 2019 13:06:45 -0800 Subject: [PATCH] feature/manager: ensure all feature sets properly set deps --- feature/manager.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/feature/manager.go b/feature/manager.go index f201cad1..6d9cfe07 100644 --- a/feature/manager.go +++ b/feature/manager.go @@ -63,14 +63,27 @@ func newManager(cfg Config, desc setDesc) (*Manager, error) { } // Now, remove any features as directed by the config. - for _, fv := range fsets { + for set, raw := range fsets { if cfg.NoTLVOnion { - fv.Unset(lnwire.TLVOnionPayloadOptional) - fv.Unset(lnwire.TLVOnionPayloadRequired) + raw.Unset(lnwire.TLVOnionPayloadOptional) + raw.Unset(lnwire.TLVOnionPayloadRequired) + raw.Unset(lnwire.PaymentAddrOptional) + raw.Unset(lnwire.PaymentAddrRequired) + raw.Unset(lnwire.MPPOptional) + raw.Unset(lnwire.MPPRequired) } if cfg.NoStaticRemoteKey { - fv.Unset(lnwire.StaticRemoteKeyOptional) - fv.Unset(lnwire.StaticRemoteKeyRequired) + raw.Unset(lnwire.StaticRemoteKeyOptional) + 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) } }