Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
39 changes: 32 additions & 7 deletions lightning/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1836,7 +1836,7 @@ pub enum Event {
///
/// # Failure Behavior and Persistence
/// This event will eventually be replayed after failures-to-handle (i.e., the event handler
/// returning `Err(ReplayEvent ())`), but will only be regenerated as needed after restarts.
/// returning `Err(ReplayEvent ())`) and will be persisted across restarts.
///
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
Expand Down Expand Up @@ -2305,10 +2305,19 @@ impl Writeable for Event {
47u8.write(writer)?;
// Never write StaticInvoiceRequested events as buffered onion messages aren't serialized.
},
&Event::FundingTransactionReadyForSigning { .. } => {
49u8.write(writer)?;
// We never write out FundingTransactionReadyForSigning events as they will be regenerated when
// necessary.
&Event::FundingTransactionReadyForSigning {
ref channel_id,
ref counterparty_node_id,
ref user_channel_id,
ref unsigned_transaction,
} => {
48u8.write(writer)?;
write_tlv_fields!(writer, {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Bleh, I'm really not a fan of this. We're really trying hard to write less in ChannelManager right now, it would be really nice to automatically regenerate this on startup if were in a state where we're waiting on the user to sign a funding tx.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's only generated in one place (internal_tx_complete) where we already incur a write, so it shouldn't matter?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Less about I/O and more about what happens if we don't write a ChannelManager at all.

(1, channel_id, required),
(3, counterparty_node_id, required),
(5, user_channel_id, required),
(7, unsigned_transaction, required),
});
},
&Event::SplicePending {
ref channel_id,
Expand Down Expand Up @@ -2931,8 +2940,24 @@ impl MaybeReadable for Event {
45u8 => Ok(None),
// Note that we do not write a length-prefixed TLV for StaticInvoiceRequested events.
47u8 => Ok(None),
// Note that we do not write a length-prefixed TLV for FundingTransactionReadyForSigning events.
49u8 => Ok(None),
48u8 => {
let mut f = || {
_init_and_read_len_prefixed_tlv_fields!(reader, {
(1, channel_id, required),
(3, counterparty_node_id, required),
(5, user_channel_id, required),
(7, unsigned_transaction, required),
});

Ok(Some(Event::FundingTransactionReadyForSigning {
channel_id: channel_id.0.unwrap(),
user_channel_id: user_channel_id.0.unwrap(),
counterparty_node_id: counterparty_node_id.0.unwrap(),
unsigned_transaction: unsigned_transaction.0.unwrap(),
}))
};
f()
},
50u8 => {
let mut f = || {
_init_and_read_len_prefixed_tlv_fields!(reader, {
Expand Down
Loading