-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds a set of convenience methods to set non-custom features #2522
Conversation
Is this better done by deserializing the features object? We could add a new constructor that makes that a bit more explicit? |
Sure, a deserializer that takes a collection of feature bits and builds the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm, I guess I'm just kinda annoyed that we're adapting our safe API to support converting from LND's API...is there no way to get the serialized features out of LND in a clean way? Otherwise, LGTM.
Regardless of what lnd's API does, I still think it's a useful change, and we already have the logic to do it on custom feature bits. |
I mean I don't really see the point here if not to support some strange API that outputs a list of features by their bits and we want to "deserialize" that - if you want to build a features object with BOLT-range features, you probably want to select the features via the usual setters, setting it via a bit is pretty weird? |
I agree, but still I'd rather just expose this than have the user (who may not be able to change the API they're using) implement it themselves. |
Oh, I agree, if there's no better way to munge LND's API responses into features this is better than not-this. |
lightning/src/ln/features.rs
Outdated
self.set_feature_bit(bit - (bit % 2)) | ||
} | ||
|
||
/// Sets an custom feature bit. Errors if `bit` is outside the feature range as defined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realised this read "an custom feature bit" when it should read "an optional feature bit"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by 992f102
I feel your pain and I partially agree with your view, but I don't think there is any other way to get the feature bit data from LND using their RPC interface. If you think this is worth the compromise, I'm happy to fix the nits, if not we'll go with a custom parser downstream |
Yea, okay, IMO let's take this, I'm just annoyed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest lgtm
lightning/src/ln/features.rs
Outdated
|
||
|
||
// Set flags manually | ||
let mut features = NodeFeatures::empty(); | ||
assert!(features.set_optional_feature_bit(55).is_ok()); | ||
assert!(features.supports_keysend()); | ||
assert!(features.set_optional_feature_bit(255).is_ok()); | ||
assert!(features.set_required_feature_bit(256).is_err()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: there're just a few extra newlines here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed by 992f102
Currently only custom features can be set by specifying the feature bit. Add also the ability to do so for regular features.
bc02b99
to
992f102
Compare
Fixes nits |
Currently only custom features can be set by specifying the feature bit. This PR adds the ability to do so for regular features too.
The rationale for this PR is being able to build a Features instance from a collection of feature bits, as returned different LND's RPC responses (such as
get_info
,get_node_info
, ...)