Skip to content

Commit 0c31021

Browse files
authored
Merge pull request #3137 from dunxen/2024-06-non-public-API-v2-channels
Implement accepting dual-funded channels without contributing
2 parents 8da30df + dd190ae commit 0c31021

13 files changed

+2029
-409
lines changed

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ check-cfg = [
6363
"cfg(taproot)",
6464
"cfg(async_signing)",
6565
"cfg(require_route_graph_test)",
66-
"cfg(dual_funding)",
6766
"cfg(splicing)",
6867
"cfg(async_payments)",
6968
]

ci/ci-tests.sh

-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ RUSTFLAGS="--cfg=taproot" cargo test --verbose --color always -p lightning
166166
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
167167
RUSTFLAGS="--cfg=async_signing" cargo test --verbose --color always -p lightning
168168
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
169-
RUSTFLAGS="--cfg=dual_funding" cargo test --verbose --color always -p lightning
170-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
171169
RUSTFLAGS="--cfg=splicing" cargo test --verbose --color always -p lightning
172170
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
173171
RUSTFLAGS="--cfg=async_payments" cargo test --verbose --color always -p lightning

lightning-types/src/features.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md#route-blinding) for more information).
5050
//! - `ShutdownAnySegwit` - requires/supports that future segwit versions are allowed in `shutdown`
5151
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information).
52+
//! - `DualFund` - requires/supports V2 channel establishment
53+
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#channel-establishment-v2) for more information).
5254
//! - `OnionMessages` - requires/supports forwarding onion messages
5355
//! (see [BOLT-7](https://github.com/lightning/bolts/pull/759/files) for more information).
5456
// TODO: update link
@@ -146,7 +148,7 @@ mod sealed {
146148
// Byte 2
147149
BasicMPP | Wumbo | AnchorsNonzeroFeeHtlcTx | AnchorsZeroFeeHtlcTx,
148150
// Byte 3
149-
RouteBlinding | ShutdownAnySegwit | Taproot,
151+
RouteBlinding | ShutdownAnySegwit | DualFund | Taproot,
150152
// Byte 4
151153
OnionMessages,
152154
// Byte 5
@@ -167,7 +169,7 @@ mod sealed {
167169
// Byte 2
168170
BasicMPP | Wumbo | AnchorsNonzeroFeeHtlcTx | AnchorsZeroFeeHtlcTx,
169171
// Byte 3
170-
RouteBlinding | ShutdownAnySegwit | Taproot,
172+
RouteBlinding | ShutdownAnySegwit | DualFund | Taproot,
171173
// Byte 4
172174
OnionMessages,
173175
// Byte 5
@@ -502,6 +504,16 @@ mod sealed {
502504
supports_shutdown_anysegwit,
503505
requires_shutdown_anysegwit
504506
);
507+
define_feature!(
508+
29,
509+
DualFund,
510+
[InitContext, NodeContext],
511+
"Feature flags for `option_dual_fund`.",
512+
set_dual_fund_optional,
513+
set_dual_fund_required,
514+
supports_dual_fund,
515+
requires_dual_fund
516+
);
505517
define_feature!(
506518
31,
507519
Taproot,

lightning/src/events/mod.rs

+23-6
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,20 @@ impl_writeable_tlv_based_enum_upgradable!(PaymentFailureReason,
606606
(10, UnexpectedError) => {},
607607
);
608608

609+
/// Used to indicate the kind of funding for this channel by the channel acceptor (us).
610+
///
611+
/// Allows the differentiation between a request for a dual-funded and non-dual-funded channel.
612+
#[derive(Clone, Debug, PartialEq, Eq)]
613+
pub enum InboundChannelFunds {
614+
/// For a non-dual-funded channel, the `push_msat` value from the channel initiator to us.
615+
PushMsat(u64),
616+
/// Indicates the open request is for a dual funded channel.
617+
///
618+
/// Note that these channels do not support starting with initial funds pushed from the counterparty,
619+
/// who is the channel opener in this case.
620+
DualFunded,
621+
}
622+
609623
/// An Event which you should probably take some action in response to.
610624
///
611625
/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
@@ -1337,16 +1351,17 @@ pub enum Event {
13371351
},
13381352
/// Indicates a request to open a new channel by a peer.
13391353
///
1340-
/// To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the request,
1341-
/// call [`ChannelManager::force_close_without_broadcasting_txn`]. Note that a ['ChannelClosed`]
1342-
/// event will _not_ be triggered if the channel is rejected.
1354+
/// To accept the request (and in the case of a dual-funded channel, not contribute funds),
1355+
/// call [`ChannelManager::accept_inbound_channel`].
1356+
/// To reject the request, call [`ChannelManager::force_close_without_broadcasting_txn`].
1357+
/// Note that a ['ChannelClosed`] event will _not_ be triggered if the channel is rejected.
13431358
///
13441359
/// The event is only triggered when a new open channel request is received and the
13451360
/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
13461361
///
13471362
/// # Failure Behavior and Persistence
13481363
/// This event will eventually be replayed after failures-to-handle (i.e., the event handler
1349-
/// returning `Err(ReplayEvent ())`) and will be persisted across restarts.
1364+
/// returning `Err(ReplayEvent ())`) and won't be persisted across restarts.
13501365
///
13511366
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
13521367
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
@@ -1373,8 +1388,10 @@ pub enum Event {
13731388
counterparty_node_id: PublicKey,
13741389
/// The channel value of the requested channel.
13751390
funding_satoshis: u64,
1376-
/// Our starting balance in the channel if the request is accepted, in milli-satoshi.
1377-
push_msat: u64,
1391+
/// If `channel_negotiation_type` is `InboundChannelFunds::DualFunded`, this indicates that the peer wishes to
1392+
/// open a dual-funded channel. Otherwise, this field will be `InboundChannelFunds::PushMsats`,
1393+
/// indicating the `push_msats` value our peer is pushing to us for a non-dual-funded channel.
1394+
channel_negotiation_type: InboundChannelFunds,
13781395
/// The features that this channel will operate with. If you reject the channel, a
13791396
/// well-behaved counterparty may automatically re-attempt the channel with a new set of
13801397
/// feature flags.

0 commit comments

Comments
 (0)