Skip to content

Commit 9fafba9

Browse files
committed
Implement support for accepting V2 channels
1 parent 6451e2b commit 9fafba9

File tree

5 files changed

+991
-124
lines changed

5 files changed

+991
-124
lines changed

lightning/src/events/mod.rs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,18 @@ impl_writeable_tlv_based_enum!(PaymentFailureReason,
538538
(10, UnexpectedError) => {}, ;
539539
);
540540

541+
/// Used to indicate the kind of funding for this channel by the channel acceptor (us).
542+
///
543+
/// Allows the differentiation between a request for a dual-funded and non-dual-funded channel.
544+
#[derive(Clone, Debug, PartialEq, Eq)]
545+
pub enum InboundChannelFunds {
546+
/// For a non-dual-funded channel, the `push_msat` value from the channel initiator to us.
547+
PushMsat(u64),
548+
/// Indicates the open request is for a dual funded channel and we may choose to contribute
549+
/// funds to the channel.
550+
DualFunded,
551+
}
552+
541553
/// An Event which you should probably take some action in response to.
542554
///
543555
/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
@@ -1143,14 +1155,28 @@ pub enum Event {
11431155
},
11441156
/// Indicates a request to open a new channel by a peer.
11451157
///
1146-
/// To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the request,
1147-
/// call [`ChannelManager::force_close_without_broadcasting_txn`]. Note that a ['ChannelClosed`]
1148-
/// event will _not_ be triggered if the channel is rejected.
1158+
/// If `acceptor_funds` is `InboundChannelFunds::DualFunded`, this indicates that the peer wishes to
1159+
/// open a dual-funded channel. In this case you can choose whether to contribute funds or not.
1160+
/// Otherwise, `acceptor_funds` will be `InboundChannelFunds::PushMsats`, indicating the `push_msats`
1161+
/// value for a non-dual-funded channel.
1162+
///
1163+
/// To accept the request (and in the case of a dual-funded channel, not contribute funds),
1164+
/// call [`ChannelManager::accept_inbound_channel`].
1165+
// TODO(dual_funding): Make this a doc comment when dual-funding fully released.
1166+
// To accept the request and contribute funds for a dual-funded channel,
1167+
// call [`ChannelManager::accept_inbound_channel_with_contribution`].
1168+
/// To reject the request, call [`ChannelManager::force_close_without_broadcasting_txn`].
1169+
/// Note that a ['ChannelClosed`] event will _not_ be triggered if the channel is rejected.
11491170
///
11501171
/// The event is only triggered when a new open channel request is received and the
11511172
/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
1173+
/// Note that if you wish to be able to contribute funds to dual-funded open channel requests,
1174+
/// [`UserConfig::manually_accept_inbound_channels`] MUST be set to true so that you may
1175+
/// provide funding inputs when choosing to contribute to the channel capacity.
11521176
///
11531177
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1178+
// TODO(dual_funding): Make this a doc comment when dual-funding fully released.
1179+
// [`ChannelManager::accept_inbound_channel_with_contribution`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_with_contribution
11541180
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
11551181
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
11561182
OpenChannelRequest {
@@ -1176,7 +1202,7 @@ pub enum Event {
11761202
/// The channel value of the requested channel.
11771203
funding_satoshis: u64,
11781204
/// Our starting balance in the channel if the request is accepted, in milli-satoshi.
1179-
push_msat: u64,
1205+
acceptor_funds: InboundChannelFunds,
11801206
/// The features that this channel will operate with. If you reject the channel, a
11811207
/// well-behaved counterparty may automatically re-attempt the channel with a new set of
11821208
/// feature flags.

0 commit comments

Comments
 (0)