Skip to content

Commit 6099dbf

Browse files
committed
wip: Add channelmanager dual-funding support
1 parent 620bbe4 commit 6099dbf

File tree

4 files changed

+590
-163
lines changed

4 files changed

+590
-163
lines changed

Diff for: lightning/src/events/mod.rs

+59
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,59 @@ pub enum Event {
837837
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
838838
channel_type: ChannelTypeFeatures,
839839
},
840+
/// Indicates a request to open a new dual-funded channel by a peer.
841+
///
842+
/// To accept the request, call [`ChannelManager::accept_inbound_dual_funded_channel`].
843+
/// To reject the request, call [`ChannelManager::force_close_without_broadcasting_txn`].
844+
///
845+
/// The event is always triggered when a new open channel request is received for a dual-funded
846+
/// channel, regardless of the value of the [`UserConfig::manually_accept_inbound_channels`]
847+
/// config flag. This is so that funding inputs can be manually provided to contribute to the
848+
/// overall channel capacity on the acceptor side.
849+
///
850+
/// [`ChannelManager::accept_inbound_dual_funded_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_dual_funded_channel
851+
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
852+
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
853+
OpenChannelV2Request {
854+
/// The temporary channel ID of the channel requested to be opened.
855+
///
856+
/// When responding to the request, the `temporary_channel_id` should be passed
857+
/// back to the ChannelManager through [`ChannelManager::accept_inbound_dual_funded_channel`] to
858+
/// accept, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject.
859+
///
860+
/// [`ChannelManager::accept_inbound_dual_funded_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_dual_funded_channel
861+
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
862+
temporary_channel_id: [u8; 32],
863+
/// The node_id of the counterparty requesting to open the channel.
864+
///
865+
/// When responding to the request, the `counterparty_node_id` should be passed
866+
/// back to the `ChannelManager` through [`ChannelManager::accept_inbound_dual_funded_channel`] to
867+
/// accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the
868+
/// request.
869+
///
870+
/// [`ChannelManager::accept_inbound_dual_funded_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_dual_funded_channel
871+
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
872+
counterparty_node_id: PublicKey,
873+
/// The counterparty's contribution to the channel value in satoshis.
874+
funding_satoshis: u64,
875+
/// The features that this channel will operate with. If you reject the channel, a
876+
/// well-behaved counterparty may automatically re-attempt the channel with a new set of
877+
/// feature flags.
878+
///
879+
/// Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
880+
/// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
881+
/// 0.0.106.
882+
///
883+
/// Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type,
884+
/// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
885+
/// 0.0.107.
886+
///
887+
/// NOTE: Zero-conf dual-funded channels are not currently accepted.
888+
// TODO(dual_funding): Support zero-conf channels.
889+
///
890+
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
891+
channel_type: ChannelTypeFeatures,
892+
},
840893
/// Indicates that the HTLC was accepted, but could not be processed when or after attempting to
841894
/// forward it.
842895
///
@@ -1087,6 +1140,12 @@ impl Writeable for Event {
10871140
(8, funding_txo, required),
10881141
});
10891142
},
1143+
&Event::OpenChannelV2Request { .. } => {
1144+
33u8.write(writer)?;
1145+
// We never write the OpenChannelV2Request events as, upon disconnection, peers
1146+
// drop any channels which have not yet completed any interactive funding transaction
1147+
// construction.
1148+
},
10901149
// Note that, going forward, all new events must only write data inside of
10911150
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
10921151
// data via `write_tlv_fields`.

0 commit comments

Comments
 (0)