Skip to content

Commit 6d47f0a

Browse files
authored
Merge pull request #3889 from dunxen/2025-06-readyforsigningevent
Introduce `FundingTransactionReadyForSignatures` event
2 parents c475db5 + 9cd4091 commit 6d47f0a

File tree

4 files changed

+831
-160
lines changed

4 files changed

+831
-160
lines changed

lightning/src/events/mod.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,52 @@ pub enum Event {
16981698
/// [`ChannelManager::send_static_invoice`]: crate::ln::channelmanager::ChannelManager::send_static_invoice
16991699
reply_path: Responder,
17001700
},
1701+
/// Indicates that a channel funding transaction constructed interactively is ready to be
1702+
/// signed. This event will only be triggered if at least one input was contributed.
1703+
///
1704+
/// The transaction contains all inputs and outputs provided by both parties including the
1705+
/// channel's funding output and a change output if applicable.
1706+
///
1707+
/// No part of the transaction should be changed before signing as the content of the transaction
1708+
/// has already been negotiated with the counterparty.
1709+
///
1710+
/// Each signature MUST use the `SIGHASH_ALL` flag to avoid invalidation of the initial commitment and
1711+
/// hence possible loss of funds.
1712+
///
1713+
/// After signing, call [`ChannelManager::funding_transaction_signed`] with the (partially) signed
1714+
/// funding transaction.
1715+
///
1716+
/// Generated in [`ChannelManager`] message handling.
1717+
///
1718+
/// # Failure Behavior and Persistence
1719+
/// This event will eventually be replayed after failures-to-handle (i.e., the event handler
1720+
/// returning `Err(ReplayEvent ())`), but will only be regenerated as needed after restarts.
1721+
///
1722+
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1723+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1724+
FundingTransactionReadyForSigning {
1725+
/// The `channel_id` of the channel which you'll need to pass back into
1726+
/// [`ChannelManager::funding_transaction_signed`].
1727+
///
1728+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1729+
channel_id: ChannelId,
1730+
/// The counterparty's `node_id`, which you'll need to pass back into
1731+
/// [`ChannelManager::funding_transaction_signed`].
1732+
///
1733+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1734+
counterparty_node_id: PublicKey,
1735+
/// The `user_channel_id` value passed in for outbound channels, or for inbound channels if
1736+
/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
1737+
/// `user_channel_id` will be randomized for inbound channels.
1738+
///
1739+
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1740+
user_channel_id: u128,
1741+
/// The unsigned transaction to be signed and passed back to
1742+
/// [`ChannelManager::funding_transaction_signed`].
1743+
///
1744+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1745+
unsigned_transaction: Transaction,
1746+
},
17011747
}
17021748

17031749
impl Writeable for Event {
@@ -2140,6 +2186,11 @@ impl Writeable for Event {
21402186
47u8.write(writer)?;
21412187
// Never write StaticInvoiceRequested events as buffered onion messages aren't serialized.
21422188
},
2189+
&Event::FundingTransactionReadyForSigning { .. } => {
2190+
49u8.write(writer)?;
2191+
// We never write out FundingTransactionReadyForSigning events as they will be regenerated when
2192+
// necessary.
2193+
},
21432194
// Note that, going forward, all new events must only write data inside of
21442195
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
21452196
// data via `write_tlv_fields`.
@@ -2722,6 +2773,8 @@ impl MaybeReadable for Event {
27222773
// Note that we do not write a length-prefixed TLV for StaticInvoiceRequested events.
27232774
#[cfg(async_payments)]
27242775
47u8 => Ok(None),
2776+
// Note that we do not write a length-prefixed TLV for FundingTransactionReadyForSigning events.
2777+
49u8 => Ok(None),
27252778
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
27262779
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
27272780
// reads.

0 commit comments

Comments
 (0)