-
Notifications
You must be signed in to change notification settings - Fork 385
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
Move checking of specific require peer feature bits to handlers #1717
Move checking of specific require peer feature bits to handlers #1717
Conversation
Codecov ReportBase: 90.84% // Head: 90.83% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1717 +/- ##
==========================================
- Coverage 90.84% 90.83% -0.02%
==========================================
Files 86 86
Lines 46448 47509 +1061
Branches 46448 47509 +1061
==========================================
+ Hits 42198 43153 +955
- Misses 4250 4356 +106
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@@ -6034,7 +6034,12 @@ impl<Signer: Sign, M: Deref , T: Deref , K: Deref , F: Deref , L: Deref > | |||
} | |||
} | |||
|
|||
fn peer_connected(&self, counterparty_node_id: &PublicKey, init_msg: &msgs::Init) { | |||
fn peer_connected(&self, counterparty_node_id: &PublicKey, init_msg: &msgs::Init) -> Result<(), ()> { | |||
if !init_msg.features.supports_static_remote_key() { |
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.
It's not obvious to me why we wouldn't also disallow peers that don't support payment_secret
, since it looks like we'll fail payments that don't have one.
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.
Payment_secret
is really between us and the sender - we can have a channel with someone who doesn't speak payment_secret, and our counterparty can't pay us directly, but we can still receive funds via them.
dc3e512
to
7e0c8fe
Compare
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.
LGTM after squash.
It appears our code is already correct here, but its also nice to add a quick safety check in `channel.rs` which ensures we will remain idempotent.
In the next commit we'll enforce counterparty `InitFeatures` matching our required set in `ChannelManager`, implying they must be set for many tests where they previously did not need to be (as they were enforced in `PeerManager`, which is not used in functional tests).
As we remove the concept of a global "known/supported" feature set in LDK, we should also remove the concept of a global "required" feature set. This does so by moving the checks for specific required features into handlers. Specifically, it allows the handler `peer_connected` method to return an `Err` if the peer should be disconnected. Only one such required feature bit is currently set - `static_remote_key`, which is required in `ChannelManager`.
7e0c8fe
to
f725c5a
Compare
Squashed without change. |
As we remove the concept of a global "known/supported" feature set
in LDK, we should also remove the concept of a global "required"
feature set. This does so by moving the checks for specific
required features into handlers.
Specifically, it allows the handler
peer_connected
method toreturn an
Err
if the peer should be disconnected. Only one suchrequired feature bit is currently set -
static_remote_key
, whichis required in
ChannelManager
.