Skip to content

Commit 986f3e3

Browse files
add manually_signal_channel_ready config option
1 parent ebcaaea commit 986f3e3

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,14 @@ pub(super) struct Channel<Signer: ChannelSigner> {
628628
/// `accept_inbound_channel`, and `funding_created` should therefore not execute successfully.
629629
inbound_awaiting_accept: bool,
630630

631+
/// A flag that indicates whether the channel requires the user to signal readiness to send
632+
/// the `msgs::ChannelReady` message. This is only set to true if the channel was created with a
633+
/// `ChannelHandshakeConfig::manually_signal_channel_ready` flag set to true.
634+
///
635+
/// When a user signals readiness via `ChannelManager::signal_channel_readiness` this flag is
636+
/// flipped to false.
637+
requires_manual_readiness_signal: bool,
638+
631639
/// The hash of the block in which the funding transaction was included.
632640
funding_tx_confirmed_in: Option<BlockHash>,
633641
funding_tx_confirmation_height: u32,
@@ -1065,6 +1073,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
10651073
target_closing_feerate_sats_per_kw: None,
10661074

10671075
inbound_awaiting_accept: false,
1076+
requires_manual_readiness_signal: config.channel_handshake_config.manually_signal_channel_ready,
10681077

10691078
funding_tx_confirmed_in: None,
10701079
funding_tx_confirmation_height: 0,
@@ -1409,6 +1418,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
14091418
target_closing_feerate_sats_per_kw: None,
14101419

14111420
inbound_awaiting_accept: true,
1421+
requires_manual_readiness_signal: config.channel_handshake_config.manually_signal_channel_ready,
14121422

14131423
funding_tx_confirmed_in: None,
14141424
funding_tx_confirmation_height: 0,
@@ -5305,6 +5315,10 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
53055315
self.inbound_awaiting_accept
53065316
}
53075317

5318+
pub fn requires_manual_readiness_signal(&self) -> bool {
5319+
self.requires_manual_readiness_signal
5320+
}
5321+
53085322
/// Sets this channel to accepting 0conf, must be done before `get_accept_channel`
53095323
pub fn set_0conf(&mut self) {
53105324
assert!(self.inbound_awaiting_accept);
@@ -6459,6 +6473,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Writeable for Channel<Signer> {
64596473
// we write the high bytes as an option here.
64606474
let user_id_high_opt = Some((self.user_id >> 64) as u64);
64616475

6476+
let requires_manual_readiness_signal = Some(self.requires_manual_readiness_signal);
6477+
64626478
write_tlv_fields!(writer, {
64636479
(0, self.announcement_sigs, option),
64646480
// minimum_depth and counterparty_selected_channel_reserve_satoshis used to have a
@@ -6484,6 +6500,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Writeable for Channel<Signer> {
64846500
(23, channel_ready_event_emitted, option),
64856501
(25, user_id_high_opt, option),
64866502
(27, self.channel_keys_id, required),
6503+
(29, requires_manual_readiness_signal, option)
64876504
});
64886505

64896506
Ok(())
@@ -6755,6 +6772,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
67556772

67566773
let mut user_id_high_opt: Option<u64> = None;
67576774
let mut channel_keys_id: Option<[u8; 32]> = None;
6775+
let mut requires_manual_readiness_signal: Option<bool> = Some(false);
67586776

67596777
read_tlv_fields!(reader, {
67606778
(0, announcement_sigs, option),
@@ -6775,6 +6793,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
67756793
(23, channel_ready_event_emitted, option),
67766794
(25, user_id_high_opt, option),
67776795
(27, channel_keys_id, option),
6796+
(29, requires_manual_readiness_signal, option),
67786797
});
67796798

67806799
let (channel_keys_id, holder_signer) = if let Some(channel_keys_id) = channel_keys_id {
@@ -6885,6 +6904,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
68856904
target_closing_feerate_sats_per_kw,
68866905

68876906
inbound_awaiting_accept: false,
6907+
requires_manual_readiness_signal: requires_manual_readiness_signal.unwrap(),
68886908

68896909
funding_tx_confirmed_in,
68906910
funding_tx_confirmation_height,

lightning/src/util/config.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ pub struct ChannelHandshakeConfig {
149149
/// Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%)
150150
/// instead, although channel negotiations will fail in that case.
151151
pub their_channel_reserve_proportional_millionths: u32,
152+
/// If this is set to true, the user needs to manually signal readiness for an inbound channel.
153+
///
154+
/// When set to true, [`Event::PendingChannelReady`] will be triggered once LDK has seen sufficient
155+
/// confirmations of the funding transaction. In that case, a [`msgs::ChannelReady`] message will not be
156+
/// sent to the counterparty node unless the user explicitly chooses to signal readiness.
157+
///
158+
/// Default value: false.
159+
///
160+
/// [`Event::PendingChannelReady`]: crate::util::events::Event::PendingChannelReady
161+
/// [`msgs::ChannelReady`]: crate::ln::msgs::ChannelReady
162+
pub manually_signal_channel_ready: bool,
152163
#[cfg(anchors)]
153164
/// If set, we attempt to negotiate the `anchors_zero_fee_htlc_tx`option for outbound channels.
154165
///
@@ -183,6 +194,7 @@ impl Default for ChannelHandshakeConfig {
183194
announced_channel: false,
184195
commit_upfront_shutdown_pubkey: true,
185196
their_channel_reserve_proportional_millionths: 10_000,
197+
manually_signal_channel_ready: false,
186198
#[cfg(anchors)]
187199
negotiate_anchors_zero_fee_htlc_tx: false,
188200
}

0 commit comments

Comments
 (0)