Skip to content

Commit e50d576

Browse files
committed
wip: Add channelmanager dual-funding support
1 parent d4320f6 commit e50d576

File tree

4 files changed

+589
-166
lines changed

4 files changed

+589
-166
lines changed

lightning/src/events/mod.rs

+59
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,59 @@ pub enum Event {
891891
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
892892
channel_type: ChannelTypeFeatures,
893893
},
894+
/// Indicates a request to open a new dual-funded channel by a peer.
895+
///
896+
/// To accept the request, call [`ChannelManager::accept_inbound_dual_funded_channel`].
897+
/// To reject the request, call [`ChannelManager::force_close_without_broadcasting_txn`].
898+
///
899+
/// The event is always triggered when a new open channel request is received for a dual-funded
900+
/// channel, regardless of the value of the [`UserConfig::manually_accept_inbound_channels`]
901+
/// config flag. This is so that funding inputs can be manually provided to contribute to the
902+
/// overall channel capacity on the acceptor side.
903+
///
904+
/// [`ChannelManager::accept_inbound_dual_funded_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_dual_funded_channel
905+
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
906+
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
907+
OpenChannelV2Request {
908+
/// The temporary channel ID of the channel requested to be opened.
909+
///
910+
/// When responding to the request, the `temporary_channel_id` should be passed
911+
/// back to the ChannelManager through [`ChannelManager::accept_inbound_dual_funded_channel`] to
912+
/// accept, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject.
913+
///
914+
/// [`ChannelManager::accept_inbound_dual_funded_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_dual_funded_channel
915+
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
916+
temporary_channel_id: [u8; 32],
917+
/// The node_id of the counterparty requesting to open the channel.
918+
///
919+
/// When responding to the request, the `counterparty_node_id` should be passed
920+
/// back to the `ChannelManager` through [`ChannelManager::accept_inbound_dual_funded_channel`] to
921+
/// accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the
922+
/// request.
923+
///
924+
/// [`ChannelManager::accept_inbound_dual_funded_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_dual_funded_channel
925+
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
926+
counterparty_node_id: PublicKey,
927+
/// The counterparty's contribution to the channel value in satoshis.
928+
funding_satoshis: u64,
929+
/// The features that this channel will operate with. If you reject the channel, a
930+
/// well-behaved counterparty may automatically re-attempt the channel with a new set of
931+
/// feature flags.
932+
///
933+
/// Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
934+
/// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
935+
/// 0.0.106.
936+
///
937+
/// Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type,
938+
/// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
939+
/// 0.0.107.
940+
///
941+
/// NOTE: Zero-conf dual-funded channels are not currently accepted.
942+
// TODO(dual_funding): Support zero-conf channels.
943+
///
944+
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
945+
channel_type: ChannelTypeFeatures,
946+
},
894947
/// Indicates that the HTLC was accepted, but could not be processed when or after attempting to
895948
/// forward it.
896949
///
@@ -1143,6 +1196,12 @@ impl Writeable for Event {
11431196
(8, funding_txo, required),
11441197
});
11451198
},
1199+
&Event::OpenChannelV2Request { .. } => {
1200+
33u8.write(writer)?;
1201+
// We never write the OpenChannelV2Request events as, upon disconnection, peers
1202+
// drop any channels which have not yet completed any interactive funding transaction
1203+
// construction.
1204+
},
11461205
// Note that, going forward, all new events must only write data inside of
11471206
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
11481207
// data via `write_tlv_fields`.

0 commit comments

Comments
 (0)