Skip to content

Commit a8450ca

Browse files
committed
Introduce FundingTransactionReadyForSignatures event
The `FundingTransactionReadyForSignatures` event requests witnesses from the client for their contributed inputs to an interactively constructed transaction. The client calls `ChannelManager::funding_transaction_signed` to provide the witnesses to LDK. The `handle_channel_resumption` method handles resumption from both a channel re-establish and a monitor update. When the corresponding monitor update for the commitment_signed message completes, we will push the event here. We can thus only ever provide holder signatures after a monitor update has completed. We can also get rid of the reestablish code involved with `monitor_pending_tx_signatures` and remove that field too.
1 parent e01663a commit a8450ca

File tree

4 files changed

+284
-107
lines changed

4 files changed

+284
-107
lines changed

lightning/src/events/mod.rs

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

16971743
impl Writeable for Event {
@@ -2134,6 +2180,11 @@ impl Writeable for Event {
21342180
47u8.write(writer)?;
21352181
// Never write StaticInvoiceRequested events as buffered onion messages aren't serialized.
21362182
},
2183+
&Event::FundingTransactionReadyForSigning { .. } => {
2184+
49u8.write(writer)?;
2185+
// We never write out FundingTransactionReadyForSigning events as they will be regenerated when
2186+
// necessary.
2187+
},
21372188
// Note that, going forward, all new events must only write data inside of
21382189
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
21392190
// data via `write_tlv_fields`.
@@ -2716,6 +2767,8 @@ impl MaybeReadable for Event {
27162767
// Note that we do not write a length-prefixed TLV for StaticInvoiceRequested events.
27172768
#[cfg(async_payments)]
27182769
47u8 => Ok(None),
2770+
// Note that we do not write a length-prefixed TLV for FundingTransactionReadyForSigning events.
2771+
49u8 => Ok(None),
27192772
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
27202773
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
27212774
// reads.

0 commit comments

Comments
 (0)