Skip to content

Commit 6e8fd90

Browse files
committed
Handle interactive signing sessions
1 parent b181fe7 commit 6e8fd90

File tree

5 files changed

+1745
-311
lines changed

5 files changed

+1745
-311
lines changed

lightning/src/events/mod.rs

+58-1
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,56 @@ pub enum Event {
12411241
/// The node id of the peer we just connected to, who advertises support for
12421242
/// onion messages.
12431243
peer_node_id: PublicKey,
1244-
}
1244+
},
1245+
#[cfg(any(dual_funding, splicing))]
1246+
/// Indicates that a transaction constructed via interactive transaction construction for a
1247+
/// dual-funded (V2) channel is ready to be signed by the client. This event will only be triggered
1248+
/// if at least one input was contributed by the holder.
1249+
///
1250+
/// The transaction contains all inputs provided by both parties when the channel was
1251+
/// created/accepted along with the channel's funding output and a change output if applicable.
1252+
///
1253+
/// No part of the transaction should be changed before signing as the content of the transaction
1254+
/// has already been negotiated with the counterparty.
1255+
///
1256+
/// Each signature MUST use the SIGHASH_ALL flag to avoid invalidation of initial commitment and
1257+
/// hence possible loss of funds.
1258+
///
1259+
/// After signing, call [`ChannelManager::funding_transaction_signed`] with the (partially) signed
1260+
/// funding transaction.
1261+
///
1262+
/// Generated in [`ChannelManager`] message handling.
1263+
///
1264+
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1265+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1266+
FundingTransactionReadyForSigning {
1267+
/// The channel_id of the V2 channel which you'll need to pass back into
1268+
/// [`ChannelManager::funding_transaction_signed`].
1269+
///
1270+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1271+
channel_id: ChannelId,
1272+
/// The counterparty's node_id, which you'll need to pass back into
1273+
/// [`ChannelManager::funding_transaction_signed`].
1274+
///
1275+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1276+
counterparty_node_id: PublicKey,
1277+
/// The `user_channel_id` value passed in to [`ChannelManager::create_dual_funded_channel`] for outbound
1278+
/// channels, or to [`ChannelManager::accept_inbound_channel`] or [`ChannelManager::accept_inbound_channel_with_contribution`]
1279+
/// for inbound channels if [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
1280+
/// Otherwise `user_channel_id` will be randomized for an inbound channel.
1281+
/// This may be zero for objects serialized with LDK versions prior to 0.0.113.
1282+
///
1283+
/// [`ChannelManager::create_dual_funded_channel`]: crate::ln::channelmanager::ChannelManager::create_dual_funded_channel
1284+
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1285+
/// [`ChannelManager::accept_inbound_channel_with_contribution`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_with_contribution
1286+
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1287+
user_channel_id: u128,
1288+
/// The unsigned transaction to be signed and passed back to
1289+
/// [`ChannelManager::funding_transaction_signed`].
1290+
///
1291+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1292+
unsigned_transaction: Transaction,
1293+
},
12451294
}
12461295

12471296
impl Writeable for Event {
@@ -1519,6 +1568,14 @@ impl Writeable for Event {
15191568
(0, peer_node_id, required),
15201569
});
15211570
}
1571+
#[cfg(any(splicing, dual_funding))]
1572+
&Event::FundingTransactionReadyForSigning { .. } => {
1573+
41u8.write(writer)?;
1574+
// We never write out FundingTransactionReadyForSigning events as, upon disconnection, peers
1575+
// drop any V2-established channels which have not yet exchanged the initial `commitment_signed`.
1576+
// We only exhange the initial `commitment_signed` after the client calls
1577+
// `ChannelManager::funding_transaction_signed` and ALWAYS before we send a `tx_signatures`
1578+
},
15221579
// Note that, going forward, all new events must only write data inside of
15231580
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
15241581
// data via `write_tlv_fields`.

0 commit comments

Comments
 (0)