Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3547,12 +3547,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 {
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errr, yea, good thing I did that....the whole logic was broken.

Copy link
Contributor

Choose a reason for hiding this comment

The 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 unbroadcasted_funding_tx. Because I assumed it would always be None for unsafe_manual_broadcast'd channels, but that would mean we would never hit the manual broadcast clause below so that doesn't make sense..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, we added some to Channel::funding_transaction, but not the method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, I see the docs now

Copy link
Contributor

Choose a reason for hiding this comment

The 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 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));
Expand Down
4 changes: 4 additions & 0 deletions pending_changelog/3259-no-downgrade.txt
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).