Class FeatureSet
- Namespace
- NLightning.Domain.Node
- Assembly
- NLightning.Domain.dll
Represents the features supported by a node. BOLT-9
public class FeatureSet
- Inheritance
-
FeatureSet
- Inherited Members
Constructors
FeatureSet()
Initializes a new instance of the FeatureSet class.
public FeatureSet()
Remarks
Always set the bit of VarOnionOptin as Optional.
Properties
SizeInBits
Gets the position of the last index of one in the BitArray and add 1 because arrays starts at 0.
public int SizeInBits { get; }
Property Value
Methods
Combine(FeatureSet, FeatureSet)
Combines two feature sets.
public static FeatureSet Combine(FeatureSet first, FeatureSet second)
Parameters
first
FeatureSetThe first feature set.
second
FeatureSetThe second feature set.
Returns
- FeatureSet
The combined feature set.
Remarks
The combined feature set is the logical OR of the two feature sets.
DeserializeFromBitReader(IBitReader, int, bool)
Deserializes the features from a BitReader.
public static FeatureSet DeserializeFromBitReader(IBitReader bitReader, int length, bool shouldPad)
Parameters
bitReader
IBitReaderThe bit reader to read from.
length
intThe number of bits to read.
shouldPad
boolIf the bit array should be padded.
Returns
- FeatureSet
The deserialized features.
Exceptions
- SerializationException
Error deserializing Features
DeserializeFromBytes(byte[])
Deserializes the features from a byte array.
public static FeatureSet DeserializeFromBytes(byte[] data)
Parameters
data
byte[]The byte array to deserialize from.
Returns
- FeatureSet
The deserialized features.
Remarks
The byte array can have a length less than or equal to 8 bytes.
Exceptions
- SerializationException
Error deserializing Features
HasFeature(Feature)
Checks if a feature is set.
public bool HasFeature(Feature feature)
Parameters
feature
FeatureThe feature to check.
Returns
- bool
true if the feature is set, false otherwise.
Remarks
We don't care if the feature is compulsory or optional.
IsCompatible(FeatureSet)
Check if this feature set is compatible with the other provided feature set.
public bool IsCompatible(FeatureSet other)
Parameters
other
FeatureSetThe other feature set to check compatibility with.
Returns
- bool
true if the feature sets are compatible, false otherwise.
Remarks
The other feature set must support the var_onion_optin feature. The other feature set must have all dependencies set.
IsFeatureSet(Feature, bool)
Checks if a feature is set.
public bool IsFeatureSet(Feature feature, bool isCompulsory)
Parameters
Returns
- bool
true if the feature is set, false otherwise.
IsFeatureSet(int, bool)
Checks if a feature is set.
public bool IsFeatureSet(int bitPosition, bool isCompulsory)
Parameters
bitPosition
intThe bit position of the feature to check.
isCompulsory
boolIf the feature is compulsory.
Returns
- bool
true if the feature is set, false otherwise.
IsOptionAnchorsSet()
Checks if the option_anchor_outputs or option_anchors_zero_fee_htlc_tx feature is set.
public bool IsOptionAnchorsSet()
Returns
- bool
true if one of the features are set, false otherwise.
SetFeature(Feature, bool, bool)
Sets a feature.
public void SetFeature(Feature feature, bool isCompulsory, bool isSet = true)
Parameters
feature
FeatureThe feature to set.
isCompulsory
boolIf the feature is compulsory.
isSet
booltrue to set the feature, false to unset it
Remarks
If the feature has dependencies, they will be set first. The dependencies keep the same isCompulsory value as the feature being set.
SetFeature(int, bool)
Sets a feature.
public void SetFeature(int bitPosition, bool isSet)
Parameters
bitPosition
intThe bit position of the feature to set.
isSet
booltrue to set the feature, false to unset it
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
WriteToBitWriter(IBitWriter, int, bool)
Serializes the features to a byte array.
public void WriteToBitWriter(IBitWriter bitWriter, int length, bool shouldPad)
Parameters
bitWriter
IBitWriterlength
intshouldPad
bool
Events
Changed
public event EventHandler? Changed