Skip to content

Commit f999414

Browse files
committed
Implement support for accepting V2 channels
1 parent f22655d commit f999414

File tree

3 files changed

+628
-154
lines changed

3 files changed

+628
-154
lines changed

lightning/src/events/mod.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,20 @@ impl_writeable_tlv_based_enum_upgradable!(PaymentFailureReason,
591591
(10, UnexpectedError) => {},
592592
);
593593

594+
/// Used to indicate the kind of funding for this channel by the channel acceptor (us).
595+
///
596+
/// Allows the differentiation between a request for a dual-funded and non-dual-funded channel.
597+
#[derive(Clone, Debug, PartialEq, Eq)]
598+
pub enum InboundChannelFunds {
599+
/// For a non-dual-funded channel, the `push_msat` value from the channel initiator to us.
600+
PushMsat(u64),
601+
/// Indicates the open request is for a dual funded channel.
602+
///
603+
/// Note that these channels do not support starting with initial funds pushed from the counterparty,
604+
/// who is the channel opener in this case.
605+
DualFunded,
606+
}
607+
594608
/// An Event which you should probably take some action in response to.
595609
///
596610
/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
@@ -1322,9 +1336,10 @@ pub enum Event {
13221336
},
13231337
/// Indicates a request to open a new channel by a peer.
13241338
///
1325-
/// To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the request,
1326-
/// call [`ChannelManager::force_close_without_broadcasting_txn`]. Note that a ['ChannelClosed`]
1327-
/// event will _not_ be triggered if the channel is rejected.
1339+
/// To accept the request (and in the case of a dual-funded channel, not contribute funds),
1340+
/// call [`ChannelManager::accept_inbound_channel`].
1341+
/// To reject the request, call [`ChannelManager::force_close_without_broadcasting_txn`].
1342+
/// Note that a ['ChannelClosed`] event will _not_ be triggered if the channel is rejected.
13281343
///
13291344
/// The event is only triggered when a new open channel request is received and the
13301345
/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
@@ -1358,8 +1373,10 @@ pub enum Event {
13581373
counterparty_node_id: PublicKey,
13591374
/// The channel value of the requested channel.
13601375
funding_satoshis: u64,
1361-
/// Our starting balance in the channel if the request is accepted, in milli-satoshi.
1362-
push_msat: u64,
1376+
/// If `channel_negotiation_type` is `InboundChannelFunds::DualFunded`, this indicates that the peer wishes to
1377+
/// open a dual-funded channel. Otherwise, this field will be `InboundChannelFunds::PushMsats`,
1378+
/// indicating the `push_msats` value our peer is pushing to us for a non-dual-funded channel.
1379+
channel_negotiation_type: InboundChannelFunds,
13631380
/// The features that this channel will operate with. If you reject the channel, a
13641381
/// well-behaved counterparty may automatically re-attempt the channel with a new set of
13651382
/// feature flags.

0 commit comments

Comments
 (0)