Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3457,6 +3457,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
Copy link
Contributor

@jkczyz jkczyz Aug 28, 2024

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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())
}
Expand Down
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).