Skip to content

Commit 7e8c3dd

Browse files
committed
Handle interactive signing sessions
1 parent dac491f commit 7e8c3dd

File tree

5 files changed

+1749
-314
lines changed

5 files changed

+1749
-314
lines changed

lightning/src/events/mod.rs

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,56 @@ pub enum Event {
12701270
/// The node id of the peer we just connected to, who advertises support for
12711271
/// onion messages.
12721272
peer_node_id: PublicKey,
1273-
}
1273+
},
1274+
#[cfg(any(dual_funding, splicing))]
1275+
/// Indicates that a transaction constructed via interactive transaction construction for a
1276+
/// dual-funded (V2) channel is ready to be signed by the client. This event will only be triggered
1277+
/// if at least one input was contributed by the holder.
1278+
///
1279+
/// The transaction contains all inputs provided by both parties when the channel was
1280+
/// created/accepted along with the channel's funding output and a change output if applicable.
1281+
///
1282+
/// No part of the transaction should be changed before signing as the content of the transaction
1283+
/// has already been negotiated with the counterparty.
1284+
///
1285+
/// Each signature MUST use the SIGHASH_ALL flag to avoid invalidation of initial commitment and
1286+
/// hence possible loss of funds.
1287+
///
1288+
/// After signing, call [`ChannelManager::funding_transaction_signed`] with the (partially) signed
1289+
/// funding transaction.
1290+
///
1291+
/// Generated in [`ChannelManager`] message handling.
1292+
///
1293+
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1294+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1295+
FundingTransactionReadyForSigning {
1296+
/// The channel_id of the V2 channel which you'll need to pass back into
1297+
/// [`ChannelManager::funding_transaction_signed`].
1298+
///
1299+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1300+
channel_id: ChannelId,
1301+
/// The counterparty's node_id, which you'll need to pass back into
1302+
/// [`ChannelManager::funding_transaction_signed`].
1303+
///
1304+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1305+
counterparty_node_id: PublicKey,
1306+
/// The `user_channel_id` value passed in to [`ChannelManager::create_dual_funded_channel`] for outbound
1307+
/// channels, or to [`ChannelManager::accept_inbound_channel`] or [`ChannelManager::accept_inbound_channel_with_contribution`]
1308+
/// for inbound channels if [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
1309+
/// Otherwise `user_channel_id` will be randomized for an inbound channel.
1310+
/// This may be zero for objects serialized with LDK versions prior to 0.0.113.
1311+
///
1312+
/// [`ChannelManager::create_dual_funded_channel`]: crate::ln::channelmanager::ChannelManager::create_dual_funded_channel
1313+
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1314+
/// [`ChannelManager::accept_inbound_channel_with_contribution`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_with_contribution
1315+
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1316+
user_channel_id: u128,
1317+
/// The unsigned transaction to be signed and passed back to
1318+
/// [`ChannelManager::funding_transaction_signed`].
1319+
///
1320+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1321+
unsigned_transaction: Transaction,
1322+
},
12741323
}
12751324

12761325
impl Writeable for Event {
@@ -1556,6 +1605,14 @@ impl Writeable for Event {
15561605
(4, responder, option),
15571606
})
15581607
},
1608+
#[cfg(any(splicing, dual_funding))]
1609+
&Event::FundingTransactionReadyForSigning { .. } => {
1610+
43u8.write(writer)?;
1611+
// We never write out FundingTransactionReadyForSigning events as, upon disconnection, peers
1612+
// drop any V2-established channels which have not yet exchanged the initial `commitment_signed`.
1613+
// We only exhange the initial `commitment_signed` after the client calls
1614+
// `ChannelManager::funding_transaction_signed` and ALWAYS before we send a `tx_signatures`
1615+
},
15591616
// Note that, going forward, all new events must only write data inside of
15601617
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
15611618
// data via `write_tlv_fields`.

0 commit comments

Comments
 (0)