Skip to content

Commit 7feebc5

Browse files
committed
Add manually_broadcast_outbound_channels
Add a new flag to `UserConfig` and `ChannelContext` to allow users to broadcast an outbound channel funding transaction manually and halt the automatic broadcasting from LDK.
1 parent 8701b1b commit 7feebc5

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,16 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
15411541
/// If we can't release a [`ChannelMonitorUpdate`] until some external action completes, we
15421542
/// store it here and only release it to the `ChannelManager` once it asks for it.
15431543
blocked_monitor_updates: Vec<PendingChannelMonitorUpdate>,
1544+
1545+
/// Upon receving a `FundingSigned` message, if the channel is
1546+
/// outbound and we are ready to broadcast the funding
1547+
/// transaction, LDK will broadcast it and set the channel state
1548+
/// to `ChannelPending`.
1549+
///
1550+
/// Using this flag will allow you to halt the broadcast of the
1551+
/// funding transaction and the channel state will be set to
1552+
/// `FundingSigned`.
1553+
manually_broadcast_outbound_channels: Option<()>,
15441554
}
15451555

15461556
impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
@@ -1872,6 +1882,8 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
18721882
local_initiated_shutdown: None,
18731883

18741884
blocked_monitor_updates: Vec::new(),
1885+
1886+
manually_broadcast_outbound_channels: None,
18751887
};
18761888

18771889
Ok(channel_context)
@@ -2092,6 +2104,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
20922104

20932105
blocked_monitor_updates: Vec::new(),
20942106
local_initiated_shutdown: None,
2107+
manually_broadcast_outbound_channels: if config.manually_broadcast_outbound_channels { Some(()) } else { None }
20952108
})
20962109
}
20972110

@@ -2333,6 +2346,10 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
23332346
self.config.options.forwarding_fee_proportional_millionths
23342347
}
23352348

2349+
pub fn get_manually_broadcast_outbound_channels(&self) -> Option<()> {
2350+
self.manually_broadcast_outbound_channels
2351+
}
2352+
23362353
pub fn get_cltv_expiry_delta(&self) -> u16 {
23372354
cmp::max(self.config.options.cltv_expiry_delta, MIN_CLTV_EXPIRY_DELTA)
23382355
}
@@ -9047,6 +9064,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
90479064
let mut holding_cell_skimmed_fees_opt: Option<Vec<Option<u64>>> = None;
90489065

90499066
let mut is_batch_funding: Option<()> = None;
9067+
let mut manually_broadcast_outbound_channels: Option<()> = None;
90509068

90519069
let mut local_initiated_shutdown: Option<()> = None;
90529070

@@ -9088,6 +9106,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
90889106
(43, malformed_htlcs, optional_vec), // Added in 0.0.119
90899107
// 45 and 47 are reserved for async signing
90909108
(49, local_initiated_shutdown, option),
9109+
(51, manually_broadcast_outbound_channels, option),
90919110
});
90929111

90939112
let (channel_keys_id, holder_signer) = if let Some(channel_keys_id) = channel_keys_id {
@@ -9322,6 +9341,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
93229341
local_initiated_shutdown,
93239342

93249343
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
9344+
manually_broadcast_outbound_channels,
93259345
},
93269346
#[cfg(any(dual_funding, splicing))]
93279347
dual_funding_channel_context: None,

lightning/src/util/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,8 @@ pub struct UserConfig {
810810
///
811811
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
812812
pub accept_mpp_keysend: bool,
813+
/// broadcast funding transaction manually
814+
pub manually_broadcast_outbound_channels: bool,
813815
}
814816

815817
impl Default for UserConfig {
@@ -823,6 +825,7 @@ impl Default for UserConfig {
823825
manually_accept_inbound_channels: false,
824826
accept_intercept_htlcs: false,
825827
accept_mpp_keysend: false,
828+
manually_broadcast_outbound_channels: false,
826829
}
827830
}
828831
}
@@ -842,6 +845,7 @@ impl Readable for UserConfig {
842845
manually_accept_inbound_channels: Readable::read(reader)?,
843846
accept_intercept_htlcs: Readable::read(reader)?,
844847
accept_mpp_keysend: Readable::read(reader)?,
848+
manually_broadcast_outbound_channels: Readable::read(reader)?,
845849
})
846850
}
847851
}

0 commit comments

Comments
 (0)