Skip to content

Commit 049d853

Browse files
committed
Implement logic for handling last tx_complete, signature for shared input
1 parent 13f021b commit 049d853

File tree

5 files changed

+447
-95
lines changed

5 files changed

+447
-95
lines changed

lightning/src/events/mod.rs

+58-1
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,56 @@ pub enum Event {
14631463
///
14641464
/// [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`]: crate::util::config::ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx
14651465
BumpTransaction(BumpTransactionEvent),
1466+
1467+
/// Indicates that a transaction constructed via interactive transaction construction for a
1468+
/// dual-funded (V2) channel is ready to be signed by the client. This event will only be triggered
1469+
/// if at least one input was contributed by the holder.
1470+
///
1471+
/// The transaction contains all inputs provided by both parties when the channel was
1472+
/// created/accepted along with the channel's funding output and a change output if applicable.
1473+
///
1474+
/// No part of the transaction should be changed before signing as the content of the transaction
1475+
/// has already been negotiated with the counterparty.
1476+
///
1477+
/// Each signature MUST use the SIGHASH_ALL flag to avoid invalidation of initial commitment and
1478+
/// hence possible loss of funds.
1479+
///
1480+
/// After signing, call [`ChannelManager::funding_transaction_signed`] with the (partially) signed
1481+
/// funding transaction.
1482+
///
1483+
/// Generated in [`ChannelManager`] message handling.
1484+
///
1485+
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1486+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1487+
FundingTransactionReadyForSigning {
1488+
/// The channel_id of the V2 channel which you'll need to pass back into
1489+
/// [`ChannelManager::funding_transaction_signed`].
1490+
///
1491+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1492+
channel_id: ChannelId,
1493+
/// The counterparty's node_id, which you'll need to pass back into
1494+
/// [`ChannelManager::funding_transaction_signed`].
1495+
///
1496+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1497+
counterparty_node_id: PublicKey,
1498+
/// The `user_channel_id` value passed in to [`ChannelManager::create_dual_funded_channel`] for outbound
1499+
/// channels, or to [`ChannelManager::accept_inbound_channel`] or [`ChannelManager::accept_inbound_channel_with_contribution`]
1500+
/// for inbound channels if [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
1501+
/// Otherwise `user_channel_id` will be randomized for an inbound channel.
1502+
/// This may be zero for objects serialized with LDK versions prior to 0.0.113.
1503+
///
1504+
/// [`ChannelManager::create_dual_funded_channel`]: crate::ln::channelmanager::ChannelManager::create_dual_funded_channel
1505+
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1506+
/// [`ChannelManager::accept_inbound_channel_with_contribution`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_with_contribution
1507+
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1508+
user_channel_id: u128,
1509+
/// The unsigned transaction to be signed and passed back to
1510+
/// [`ChannelManager::funding_transaction_signed`].
1511+
///
1512+
/// [`ChannelManager::funding_transaction_signed`]: crate::ln::channelmanager::ChannelManager::funding_transaction_signed
1513+
unsigned_transaction: Transaction,
1514+
},
1515+
14661516
/// We received an onion message that is intended to be forwarded to a peer
14671517
/// that is currently offline. This event will only be generated if the
14681518
/// `OnionMessenger` was initialized with
@@ -1768,7 +1818,7 @@ impl Writeable for Event {
17681818
BumpTransactionEvent::HTLCResolution { .. } => {}
17691819
}
17701820
write_tlv_fields!(writer, {}); // Write a length field for forwards compat
1771-
}
1821+
},
17721822
&Event::ChannelReady { ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type } => {
17731823
29u8.write(writer)?;
17741824
write_tlv_fields!(writer, {
@@ -1828,6 +1878,13 @@ impl Writeable for Event {
18281878
(8, former_temporary_channel_id, required),
18291879
});
18301880
},
1881+
&Event::FundingTransactionReadyForSigning { .. } => {
1882+
45u8.write(writer)?;
1883+
// We never write out FundingTransactionReadyForSigning events as, upon disconnection, peers
1884+
// drop any V2-established channels which have not yet exchanged the initial `commitment_signed`.
1885+
// We only exhange the initial `commitment_signed` after the client calls
1886+
// `ChannelManager::funding_transaction_signed` and ALWAYS before we send a `tx_signatures`
1887+
},
18311888
// Note that, going forward, all new events must only write data inside of
18321889
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
18331890
// data via `write_tlv_fields`.

0 commit comments

Comments
 (0)