mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-09 21:56:47 +01:00
multi: add custom feature bits to config options
This commit is contained in:
@@ -49,6 +49,10 @@ type Config struct {
|
||||
// NoAnySegwit unsets any bits that signal support for using other
|
||||
// segwit witness versions for co-op closes.
|
||||
NoAnySegwit bool
|
||||
|
||||
// CustomFeatures is a set of custom features to advertise in each
|
||||
// set.
|
||||
CustomFeatures map[Set][]lnwire.FeatureBit
|
||||
}
|
||||
|
||||
// Manager is responsible for generating feature vectors for different requested
|
||||
@@ -156,6 +160,23 @@ func newManager(cfg Config, desc setDesc) (*Manager, error) {
|
||||
raw.Unset(lnwire.ShutdownAnySegwitRequired)
|
||||
}
|
||||
|
||||
for _, custom := range cfg.CustomFeatures[set] {
|
||||
if custom > set.Maximum() {
|
||||
return nil, fmt.Errorf("feature bit: %v "+
|
||||
"exceeds set: %v maximum: %v", custom,
|
||||
set, set.Maximum())
|
||||
}
|
||||
|
||||
if raw.IsSet(custom) {
|
||||
return nil, fmt.Errorf("feature bit: %v "+
|
||||
"already set", custom)
|
||||
}
|
||||
|
||||
if err := raw.SafeSet(custom); err != nil {
|
||||
return nil, fmt.Errorf("%w: could not set "+
|
||||
"feature: %d", err, custom)
|
||||
}
|
||||
}
|
||||
// Ensure that all of our feature sets properly set any
|
||||
// dependent features.
|
||||
fv := lnwire.NewFeatureVector(raw, lnwire.Features)
|
||||
|
||||
Reference in New Issue
Block a user