Skip to content

Commit 72eaed3

Browse files
committed
Handle interactive signing sessions
1 parent b8b1e93 commit 72eaed3

File tree

5 files changed

+1716
-369
lines changed

5 files changed

+1716
-369
lines changed

lightning/src/events/mod.rs

+58-1
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,56 @@ pub enum Event {
11961196
/// The node id of the peer we just connected to, who advertises support for
11971197
/// onion messages.
11981198
peer_node_id: PublicKey,
1199-
}
1199+
},
1200+
#[cfg(any(dual_funding, splicing))]
1201+
/// Indicates that a transaction constructed via interactive transaction construction for a
1202+
/// dual-funded (V2) channel is ready to be signed by the client. This event will only be triggered
1203+
/// if at least one input was contributed by the holder.
1204+
///
1205+
/// The transaction contains all inputs provided by both parties when the channel was
1206+
/// created/accepted along with the channel's funding output and a change output if applicable.
1207+
///
1208+
/// No part of the transaction should be changed before signing as the content of the transaction
1209+
/// has already been negotiated with the counterparty.
1210+
///
1211+
/// Each signature MUST use the SIGHASH_ALL flag to avoid invalidation of initial commitment and
1212+
/// hence possible loss of funds.
1213+
///
1214+
/// After signing, call [`ChannelManager::funding_transaction_signed`] with the (partially) signed
1215+
/// funding transaction.
1216+
///
1217+
/// Generated in [`ChannelManager`] message handling.
1218+
///
1219+
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1220+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1221+
FundingTransactionReadyForSigning {
1222+
/// The channel_id of the V2 channel which you'll need to pass back into
1223+
/// [`ChannelManager::funding_transaction_signed`].
1224+
///
1225+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1226+
channel_id: ChannelId,
1227+
/// The counterparty's node_id, which you'll need to pass back into
1228+
/// [`ChannelManager::funding_transaction_signed`].
1229+
///
1230+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1231+
counterparty_node_id: PublicKey,
1232+
/// The `user_channel_id` value passed in to [`ChannelManager::create_dual_funded_channel`] for outbound
1233+
/// channels, or to [`ChannelManager::accept_inbound_channel`] or [`ChannelManager::accept_inbound_channel_with_contribution`]
1234+
/// for inbound channels if [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
1235+
/// Otherwise `user_channel_id` will be randomized for an inbound channel.
1236+
/// This may be zero for objects serialized with LDK versions prior to 0.0.113.
1237+
///
1238+
/// [`ChannelManager::create_dual_funded_channel`]: crate::ln::channelmanager::ChannelManager::create_dual_funded_channel
1239+
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1240+
/// [`ChannelManager::accept_inbound_channel_with_contribution`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_with_contribution
1241+
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1242+
user_channel_id: u128,
1243+
/// The unsigned transaction to be signed and passed back to
1244+
/// [`ChannelManager::funding_transaction_signed`].
1245+
///
1246+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1247+
unsigned_transaction: Transaction,
1248+
},
12001249
}
12011250

12021251
impl Writeable for Event {
@@ -1474,6 +1523,14 @@ impl Writeable for Event {
14741523
(0, peer_node_id, required),
14751524
});
14761525
}
1526+
#[cfg(any(splicing, dual_funding))]
1527+
&Event::FundingTransactionReadyForSigning { .. } => {
1528+
41u8.write(writer)?;
1529+
// We never write out FundingTransactionReadyForSigning events as, upon disconnection, peers
1530+
// drop any V2-established channels which have not yet exchanged the initial `commitment_signed`.
1531+
// We only exhange the initial `commitment_signed` after the client calls
1532+
// `ChannelManager::funding_transaction_signed` and ALWAYS before we send a `tx_signatures`
1533+
},
14771534
// Note that, going forward, all new events must only write data inside of
14781535
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
14791536
// data via `write_tlv_fields`.

0 commit comments

Comments
 (0)