Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement accepting dual-funded channels without contributing #3137

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ check-cfg = [
"cfg(taproot)",
"cfg(async_signing)",
"cfg(require_route_graph_test)",
"cfg(dual_funding)",
"cfg(splicing)",
"cfg(async_payments)",
]
2 changes: 0 additions & 2 deletions ci/ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ RUSTFLAGS="--cfg=taproot" cargo test --verbose --color always -p lightning
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
RUSTFLAGS="--cfg=async_signing" cargo test --verbose --color always -p lightning
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
RUSTFLAGS="--cfg=dual_funding" cargo test --verbose --color always -p lightning
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
RUSTFLAGS="--cfg=splicing" cargo test --verbose --color always -p lightning
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
RUSTFLAGS="--cfg=async_payments" cargo test --verbose --color always -p lightning
16 changes: 14 additions & 2 deletions lightning-types/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md#route-blinding) for more information).
//! - `ShutdownAnySegwit` - requires/supports that future segwit versions are allowed in `shutdown`
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information).
//! - `DualFund` - requires/supports V2 channel establishment
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#channel-establishment-v2) for more information).
//! - `OnionMessages` - requires/supports forwarding onion messages
//! (see [BOLT-7](https://github.com/lightning/bolts/pull/759/files) for more information).
// TODO: update link
Expand Down Expand Up @@ -147,7 +149,7 @@ mod sealed {
// Byte 2
BasicMPP | Wumbo | AnchorsNonzeroFeeHtlcTx | AnchorsZeroFeeHtlcTx,
// Byte 3
RouteBlinding | ShutdownAnySegwit | Taproot,
RouteBlinding | ShutdownAnySegwit | DualFund | Taproot,
// Byte 4
OnionMessages,
// Byte 5
Expand All @@ -168,7 +170,7 @@ mod sealed {
// Byte 2
BasicMPP | Wumbo | AnchorsNonzeroFeeHtlcTx | AnchorsZeroFeeHtlcTx,
// Byte 3
RouteBlinding | ShutdownAnySegwit | Taproot,
RouteBlinding | ShutdownAnySegwit | DualFund | Taproot,
// Byte 4
OnionMessages,
// Byte 5
Expand Down Expand Up @@ -499,6 +501,16 @@ mod sealed {
supports_shutdown_anysegwit,
requires_shutdown_anysegwit
);
define_feature!(
29,
DualFund,
[InitContext, NodeContext],
"Feature flags for `option_dual_fund`.",
set_dual_fund_optional,
set_dual_fund_required,
supports_dual_fund,
requires_dual_fund
);
define_feature!(
31,
Taproot,
Expand Down
31 changes: 26 additions & 5 deletions lightning/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,20 @@ impl_writeable_tlv_based_enum_upgradable!(PaymentFailureReason,
(10, UnexpectedError) => {},
);

/// Used to indicate the kind of funding for this channel by the channel acceptor (us).
///
/// Allows the differentiation between a request for a dual-funded and non-dual-funded channel.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum InboundChannelFunds {
/// For a non-dual-funded channel, the `push_msat` value from the channel initiator to us.
PushMsat(u64),
/// Indicates the open request is for a dual funded channel.
dunxen marked this conversation as resolved.
Show resolved Hide resolved
///
/// Note that these channels do not support starting with initial funds pushed from the counterparty,
/// who is the channel opener in this case.
DualFunded,
}

/// An Event which you should probably take some action in response to.
///
/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
Expand Down Expand Up @@ -1293,9 +1307,14 @@ pub enum Event {
},
/// Indicates a request to open a new channel by a peer.
///
/// To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the request,
/// call [`ChannelManager::force_close_without_broadcasting_txn`]. Note that a ['ChannelClosed`]
/// event will _not_ be triggered if the channel is rejected.
/// If `channel_negotiation_type` is `InboundChannelFunds::DualFunded`, this indicates that the peer wishes to
/// open a dual-funded channel. Otherwise, this field will be `InboundChannelFunds::PushMsats`,
/// indicating the `push_msats` value our peer is pushing to us for a non-dual-funded channel.
///
/// To accept the request (and in the case of a dual-funded channel, not contribute funds),
/// call [`ChannelManager::accept_inbound_channel`].
/// To reject the request, call [`ChannelManager::force_close_without_broadcasting_txn`].
/// Note that a ['ChannelClosed`] event will _not_ be triggered if the channel is rejected.
///
/// The event is only triggered when a new open channel request is received and the
/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
Expand Down Expand Up @@ -1329,8 +1348,10 @@ pub enum Event {
counterparty_node_id: PublicKey,
/// The channel value of the requested channel.
funding_satoshis: u64,
/// Our starting balance in the channel if the request is accepted, in milli-satoshi.
push_msat: u64,
/// If `channel_negotiation_type` is `InboundChannelFunds::DualFunded`, this indicates that the peer wishes to
/// open a dual-funded channel. Otherwise, this field will be `InboundChannelFunds::PushMsats`,
/// indicating the `push_msats` value our peer is pushing to us for a non-dual-funded channel.
channel_negotiation_type: InboundChannelFunds,
/// The features that this channel will operate with. If you reject the channel, a
/// well-behaved counterparty may automatically re-attempt the channel with a new set of
/// feature flags.
Expand Down
Loading
Loading