-
Notifications
You must be signed in to change notification settings - Fork 403
#3259 followups #3275
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
#3259 followups #3275
Changes from all commits
1e285cb
3b70bd2
6a81d5d
683aa83
ea646ae
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 |
---|---|---|
|
@@ -936,6 +936,7 @@ pub(crate) struct ShutdownResult { | |
pub(crate) user_channel_id: u128, | ||
pub(crate) channel_capacity_satoshis: u64, | ||
pub(crate) counterparty_node_id: PublicKey, | ||
pub(crate) is_manual_broadcast: bool, | ||
pub(crate) unbroadcasted_funding_tx: Option<Transaction>, | ||
pub(crate) channel_funding_txo: Option<OutPoint>, | ||
} | ||
|
@@ -3457,6 +3458,9 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider { | |
|
||
/// Returns the transaction if there is a pending funding transaction that is yet to be | ||
/// broadcast. | ||
/// | ||
/// Note that if [`Self::is_manual_broadcast`] is true the transaction will be a dummy | ||
/// transaction. | ||
Comment on lines
+3462
to
+3463
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. Could we have used an enum indicating the manual case? Or does that affect the serialization logic / format? 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. We could swap this, yea. We didn't bother in the initial PR cause we forgot about this issue until it was basically ready. 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. Also this method is only actually used in batch funding, which never has a non-transaction, so... |
||
pub fn unbroadcasted_funding(&self) -> Option<Transaction> { | ||
self.if_unbroadcasted_funding(|| self.funding_transaction.clone()) | ||
} | ||
|
@@ -3537,6 +3541,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider { | |
channel_capacity_satoshis: self.channel_value_satoshis, | ||
counterparty_node_id: self.counterparty_node_id, | ||
unbroadcasted_funding_tx, | ||
is_manual_broadcast: self.is_manual_broadcast, | ||
channel_funding_txo: self.get_funding_txo(), | ||
} | ||
} | ||
|
@@ -6240,6 +6245,7 @@ impl<SP: Deref> Channel<SP> where | |
channel_capacity_satoshis: self.context.channel_value_satoshis, | ||
counterparty_node_id: self.context.counterparty_node_id, | ||
unbroadcasted_funding_tx: self.context.unbroadcasted_funding(), | ||
is_manual_broadcast: self.context.is_manual_broadcast, | ||
channel_funding_txo: self.context.get_funding_txo(), | ||
}; | ||
let tx = self.build_signed_closing_transaction(&mut closing_tx, &msg.signature, &sig); | ||
|
@@ -6272,6 +6278,7 @@ impl<SP: Deref> Channel<SP> where | |
channel_capacity_satoshis: self.context.channel_value_satoshis, | ||
counterparty_node_id: self.context.counterparty_node_id, | ||
unbroadcasted_funding_tx: self.context.unbroadcasted_funding(), | ||
is_manual_broadcast: self.context.is_manual_broadcast, | ||
channel_funding_txo: self.context.get_funding_txo(), | ||
}; | ||
if closing_signed.is_some() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3510,7 +3510,6 @@ where | |
let _ = self.chain_monitor.update_channel(funding_txo, &monitor_update); | ||
} | ||
let mut shutdown_results = Vec::new(); | ||
let mut is_manual_broadcast = false; | ||
if let Some(txid) = shutdown_res.unbroadcasted_batch_funding_txid { | ||
let mut funding_batch_states = self.funding_batch_states.lock().unwrap(); | ||
let affected_channels = funding_batch_states.remove(&txid).into_iter().flatten(); | ||
|
@@ -3520,10 +3519,6 @@ where | |
if let Some(peer_state_mutex) = per_peer_state.get(&counterparty_node_id) { | ||
let mut peer_state = peer_state_mutex.lock().unwrap(); | ||
if let Some(mut chan) = peer_state.channel_by_id.remove(&channel_id) { | ||
// We override the previous value, so we could change from true -> false, | ||
// but this is fine because if a channel has manual_broadcast set to false | ||
// we should choose the safier condition. | ||
is_manual_broadcast = chan.context().is_manual_broadcast(); | ||
update_maps_on_chan_removal!(self, &chan.context()); | ||
shutdown_results.push(chan.context_mut().force_shutdown(false, ClosureReason::FundingBatchClosure)); | ||
} | ||
|
@@ -3547,12 +3542,15 @@ where | |
channel_funding_txo: shutdown_res.channel_funding_txo, | ||
}, None)); | ||
|
||
let funding_info = if is_manual_broadcast { | ||
shutdown_res.channel_funding_txo.map(|outpoint| FundingInfo::OutPoint{ outpoint }) | ||
} else { | ||
shutdown_res.unbroadcasted_funding_tx.map(|transaction| FundingInfo::Tx{ transaction }) | ||
}; | ||
if let Some(funding_info) = funding_info { | ||
if let Some(transaction) = shutdown_res.unbroadcasted_funding_tx { | ||
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. Would it be easy to add test coverage for the bug described in the commit message (maybe in follow-up)? Seems obvious in retrospect, ugh. 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. Errr, yea, good thing I did that....the whole logic was broken. 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. Pre-existing, but I think it would be useful to have some docs on 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. Ah, we added some to 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. Ah okay, I see the docs now 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. ops this is my fault, sorry that I did not thing about this! |
||
let funding_info = if shutdown_res.is_manual_broadcast { | ||
FundingInfo::OutPoint { | ||
outpoint: shutdown_res.channel_funding_txo | ||
.expect("We had an unbroadcasted funding tx, so should also have had a funding outpoint"), | ||
} | ||
} else { | ||
FundingInfo::Tx{ transaction } | ||
}; | ||
pending_events.push_back((events::Event::DiscardFunding { | ||
channel_id: shutdown_res.channel_id, funding_info | ||
}, None)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Backwards Compatibility | ||
* Downgrading after using `ChannelManager`'s | ||
`unsafe_manual_funding_transaction_generated` may cause deserialization of | ||
`ChannelManager` to fail with an `Err` (#3259). |
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 though of doing it but I choose the monkey way of doing it by iterating over all the channels, thanks for catching it