Skip to content

Commit a77c22f

Browse files
committed
Add OpenChannelV2Request & dual-funded channel contribute config
1 parent 60ff104 commit a77c22f

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

lightning/src/events/mod.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,59 @@ pub enum Event {
812812
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
813813
channel_type: ChannelTypeFeatures,
814814
},
815+
/// Indicates a request to open a new dual-funded channel by a peer.
816+
///
817+
/// To accept the request, call [`ChannelManager::accept_inbound_dual_funded_channel`].
818+
/// To reject the request, call [`ChannelManager::force_close_without_broadcasting_txn`].
819+
///
820+
/// The event is always triggered when a new open channel request is received for a dual-funded
821+
/// channel, regardless of the value of the [`UserConfig::manually_accept_inbound_channels`]
822+
/// config flag. This is so that funding inputs can be manually provided to contribute to the
823+
/// overall channel capacity on the acceptor side.
824+
///
825+
/// [`ChannelManager::accept_inbound_dual_funded_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_dual_funded_channel
826+
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
827+
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
828+
OpenChannelV2Request {
829+
/// The temporary channel ID of the channel requested to be opened.
830+
///
831+
/// When responding to the request, the `temporary_channel_id` should be passed
832+
/// back to the ChannelManager through [`ChannelManager::accept_inbound_dual_funded_channel`] to
833+
/// accept, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject.
834+
///
835+
/// [`ChannelManager::accept_inbound_dual_funded_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_dual_funded_channel
836+
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
837+
temporary_channel_id: [u8; 32],
838+
/// The node_id of the counterparty requesting to open the channel.
839+
///
840+
/// When responding to the request, the `counterparty_node_id` should be passed
841+
/// back to the `ChannelManager` through [`ChannelManager::accept_inbound_dual_funded_channel`] to
842+
/// accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the
843+
/// request.
844+
///
845+
/// [`ChannelManager::accept_inbound_dual_funded_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_dual_funded_channel
846+
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
847+
counterparty_node_id: PublicKey,
848+
/// The counterparty's contribution to the channel value in satoshis.
849+
funding_satoshis: u64,
850+
/// The features that this channel will operate with. If you reject the channel, a
851+
/// well-behaved counterparty may automatically re-attempt the channel with a new set of
852+
/// feature flags.
853+
///
854+
/// Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
855+
/// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
856+
/// 0.0.106.
857+
///
858+
/// Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type,
859+
/// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
860+
/// 0.0.107.
861+
///
862+
/// NOTE: Zero-conf dual-funded channels are not currently accepted.
863+
// TODO(dual_funding): Maybe support opportunistic zero-conf channels like Eclair?
864+
///
865+
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
866+
channel_type: ChannelTypeFeatures,
867+
},
815868
/// Indicates that the HTLC was accepted, but could not be processed when or after attempting to
816869
/// forward it.
817870
///
@@ -1058,6 +1111,12 @@ impl Writeable for Event {
10581111
(8, funding_txo, required),
10591112
});
10601113
},
1114+
&Event::OpenChannelV2Request { .. } => {
1115+
33u8.write(writer)?;
1116+
// We never write the OpenChannelV2Request events as, upon disconnection, peers
1117+
// drop any channels which have not yet completed any interactive funding transaction
1118+
// construction.
1119+
},
10611120
// Note that, going forward, all new events must only write data inside of
10621121
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
10631122
// data via `write_tlv_fields`.

lightning/src/util/config.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,21 @@ pub struct UserConfig {
764764
///
765765
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
766766
pub accept_mpp_keysend: bool,
767+
/// If this is set to true, regardless of `accept_inbound_channels`, the user needs to manually
768+
/// accept inbound requests to open a new dual-funded channel and provide any UTXOs they'd like
769+
/// to contribute to the funding transaction.
770+
///
771+
/// When set to true, [`Event::OpenChannelV2Request`] will be triggered once a request to open a
772+
/// new inbound dual-funded channel is received through a [`msgs::OpenChannelV2`] message. In that
773+
/// case, a [`msgs::AcceptChannelV2`] message will not be sent back to the counterparty node unless
774+
/// the user explicitly chooses to accept the request.
775+
///
776+
/// Default value: false.
777+
///
778+
/// [`Event::OpenChannelV2Request`]: crate::events::Event::OpenChannelV2Request
779+
/// [`msgs::OpenChannelV2`]: crate::ln::msgs::OpenChannelV2
780+
/// [`msgs::AcceptChannelV2`]: crate::ln::msgs::AcceptChannelV2
781+
pub contribute_to_dual_funded_channels: bool,
767782
}
768783

769784
impl Default for UserConfig {
@@ -777,6 +792,7 @@ impl Default for UserConfig {
777792
manually_accept_inbound_channels: false,
778793
accept_intercept_htlcs: false,
779794
accept_mpp_keysend: false,
795+
contribute_to_dual_funded_channels: false,
780796
}
781797
}
782798
}

0 commit comments

Comments
 (0)