-
Notifications
You must be signed in to change notification settings - Fork 407
Update channel-type implementation to upstream spec as merged #1314
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1895,6 +1895,16 @@ impl<Signer: Sign> Channel<Signer> { | |
return Err(ChannelError::Close("Minimum confirmation depth must be at least 1".to_owned())); | ||
} | ||
|
||
if let Some(ty) = &msg.channel_type { | ||
if *ty != self.channel_type { | ||
return Err(ChannelError::Close("Channel Type in accept_channel didn't match the one sent in open_channel.".to_owned())); | ||
} | ||
} else if their_features.supports_channel_type() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC we might have a peer supporting channel type (feature bits 44/45) but not announcing any Maybe we can implement the spec suggestion : "The receiving node MAY fail the channel if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, the point of the feature bit is they have to announce a channel type field/TLV, though it can be empty.
Two things: a) this is about |
||
// Assume they've accepted the channel type as they said they understand it. | ||
} else { | ||
self.channel_type = ChannelTypeFeatures::from_counterparty_init(&their_features) | ||
} | ||
|
||
let counterparty_shutdown_scriptpubkey = if their_features.supports_upfront_shutdown_script() { | ||
match &msg.shutdown_scriptpubkey { | ||
&OptionalField::Present(ref script) => { | ||
|
@@ -2174,11 +2184,11 @@ impl<Signer: Sign> Channel<Signer> { | |
|
||
/// Returns transaction if there is pending funding transaction that is yet to broadcast | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: "to be broadcast" |
||
pub fn unbroadcasted_funding(&self) -> Option<Transaction> { | ||
if self.channel_state & (ChannelState::FundingCreated as u32) != 0 { | ||
self.funding_transaction.clone() | ||
} else { | ||
None | ||
} | ||
if self.channel_state & (ChannelState::FundingCreated as u32) != 0 { | ||
self.funding_transaction.clone() | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
/// Returns a HTLCStats about inbound pending htlcs | ||
|
@@ -4720,6 +4730,7 @@ impl<Signer: Sign> Channel<Signer> { | |
Some(script) => script.clone().into_inner(), | ||
None => Builder::new().into_script(), | ||
}), | ||
channel_type: Some(self.channel_type.clone()), | ||
} | ||
} | ||
|
||
|
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 think the spec says in
accept_channel
subsection:"The sender if it sets the
channel_type
MUST set it to thechannel_type
fromopen_channel
".I agree the "it" isn't clear though sounds the spec requirement to echo is already there.
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'd think
it
is pretty clearly (a) the sender, and (b) thechannel_type
, so technically I don't think we're in violation today, though we maybe should be.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.
My point was the spec already mentions it. Contrary to what the commit message sounds to suggest "Though the spec doesn't explicitly require this" :p ?
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.
No, the spec very clearly does not explicitly require this - it says "IF [the sender] sets the
channel_type
"...then it must set it to a copy. The spec does not require theaccept_channel
sender to send a copy.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'll add my unsolicited 2 cents, but my reading of this is exactly that: if
accept_channel
sets the channel type, clearly implying optionality, it must match the value fromopen_channel
, but it definitely needn't be set.