Skip to content

Commit 8202265

Browse files
committed
Handle interactive signing sessions
1 parent ef43f1a commit 8202265

File tree

5 files changed

+1745
-311
lines changed

5 files changed

+1745
-311
lines changed

lightning/src/events/mod.rs

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

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

0 commit comments

Comments
 (0)