Skip to content

Commit f3876b3

Browse files
committed
Implement support for accepting V2 channels
1 parent ce253d2 commit f3876b3

File tree

4 files changed

+846
-143
lines changed

4 files changed

+846
-143
lines changed

lightning/src/events/mod.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,20 @@ 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.
549+
///
550+
/// Note that these channels do not support starting with initial funds pushed from the counterparty,
551+
// who is the channel opener in this case.
552+
DualFunded,
553+
}
554+
541555
/// An Event which you should probably take some action in response to.
542556
///
543557
/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
@@ -1143,9 +1157,14 @@ pub enum Event {
11431157
},
11441158
/// Indicates a request to open a new channel by a peer.
11451159
///
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.
1160+
/// If `channel_negotiation_type` is `InboundChannelFunds::DualFunded`, this indicates that the peer wishes to
1161+
/// open a dual-funded channel. Otherwise, this field will be `InboundChannelFunds::PushMsats`,
1162+
/// indicating the `push_msats` value our peer is pushing to us for a non-dual-funded channel.
1163+
///
1164+
/// To accept the request (and in the case of a dual-funded channel, not contribute funds),
1165+
/// call [`ChannelManager::accept_inbound_channel`].
1166+
/// To reject the request, call [`ChannelManager::force_close_without_broadcasting_txn`].
1167+
/// Note that a ['ChannelClosed`] event will _not_ be triggered if the channel is rejected.
11491168
///
11501169
/// The event is only triggered when a new open channel request is received and the
11511170
/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
@@ -1175,8 +1194,10 @@ pub enum Event {
11751194
counterparty_node_id: PublicKey,
11761195
/// The channel value of the requested channel.
11771196
funding_satoshis: u64,
1178-
/// Our starting balance in the channel if the request is accepted, in milli-satoshi.
1179-
push_msat: u64,
1197+
/// If `channel_negotiation_type` is `InboundChannelFunds::DualFunded`, this indicates that the peer wishes to
1198+
/// open a dual-funded channel. Otherwise, this field will be `InboundChannelFunds::PushMsats`,
1199+
/// indicating the `push_msats` value our peer is pushing to us for a non-dual-funded channel.
1200+
channel_negotiation_type: InboundChannelFunds,
11801201
/// The features that this channel will operate with. If you reject the channel, a
11811202
/// well-behaved counterparty may automatically re-attempt the channel with a new set of
11821203
/// feature flags.

0 commit comments

Comments
 (0)