Add a method to update the current `UserConfig` in `ChannelManager`
What changed, and why it matters
This commit is a routine feature addition and API cleanup. It adds a way to change the user's configuration while the Lightning node is running, and renames an existing getter method to match. There is no indication of a security bug being fixed.
No security action required. Treat as normal feature/API maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces ChannelManager::set_current_config(UserConfig) to allow runtime updates of UserConfig, which previously required a node restart. It renames get_current_default_configuration() to get_current_config() and updates documentation to reflect that UserConfig affects both new-channel defaults and some global ChannelManager behavior. All call sites in tests are updated to use the new method name. No security-sensitive logic changes are present.
Changed components
lightning/src/ln/channelmanager.rslightning/src/ln/dual_funding_tests.rslightning/src/ln/functional_test_utils.rslightning/src/ln/onion_route_tests.rslightning/src/ln/reorg_tests.rsInspect captured patch +15 / −8
diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index 72e85ea..cfef054 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -3801,11 +3801,18 @@ where
}
}
- /// Gets the current configuration applied to all new channels.
- pub fn get_current_default_configuration(&self) -> UserConfig {
+ /// Gets the current [`UserConfig`] which controls some global behavior and includes the
+ /// default configuration applied to all new channels.
+ pub fn get_current_config(&self) -> UserConfig {
self.config.read().unwrap().clone()
}
+ /// Updates the current [`UserConfig`] which controls some global behavior and includes the
+ /// default configuration applied to all new channels.
+ pub fn set_current_config(&self, new_config: UserConfig) {
+ *self.config.write().unwrap() = new_config;
+ }
+
#[cfg(test)]
pub fn create_and_insert_outbound_scid_alias_for_test(&self) -> u64 {
self.create_and_insert_outbound_scid_alias()
diff --git a/lightning/src/ln/dual_funding_tests.rs b/lightning/src/ln/dual_funding_tests.rs
index 4f47f47..e49a0f5 100644
--- a/lightning/src/ln/dual_funding_tests.rs
+++ b/lightning/src/ln/dual_funding_tests.rs
@@ -62,7 +62,7 @@ fn do_test_v2_channel_establishment(session: V2ChannelEstablishmentTestSession)
funding_satoshis,
initiator_funding_inputs.clone(),
42, /* user_channel_id */
- &nodes[0].node.get_current_default_configuration(),
+ &nodes[0].node.get_current_config(),
nodes[0].best_block_info().1,
nodes[0].node.create_and_insert_outbound_scid_alias_for_test(),
ConfirmationTarget::NonAnchorChannelFee,
diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs
index 7649bf8..53d5173 100644
--- a/lightning/src/ln/functional_test_utils.rs
+++ b/lightning/src/ln/functional_test_utils.rs
@@ -866,7 +866,7 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
)>::read(
&mut io::Cursor::new(w.0),
ChannelManagerReadArgs {
- config: self.node.get_current_default_configuration(),
+ config: self.node.get_current_config(),
entropy_source: self.keys_manager,
node_signer: self.keys_manager,
signer_provider: self.keys_manager,
@@ -1651,7 +1651,7 @@ pub fn exchange_open_accept_chan<'a, 'b, 'c>(
42
);
node_b.node.handle_open_channel(node_a_id, &open_channel_msg);
- if node_b.node.get_current_default_configuration().manually_accept_inbound_channels {
+ if node_b.node.get_current_config().manually_accept_inbound_channels {
let events = node_b.node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match &events[0] {
@@ -1830,7 +1830,7 @@ pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(
let node_a_id = nodes[a].node.get_our_node_id();
let node_b_id = nodes[b].node.get_our_node_id();
- let mut no_announce_cfg = nodes[a].node.get_current_default_configuration();
+ let mut no_announce_cfg = nodes[a].node.get_current_config();
no_announce_cfg.channel_handshake_config.announce_for_forwarding = false;
nodes[a]
.node
diff --git a/lightning/src/ln/onion_route_tests.rs b/lightning/src/ln/onion_route_tests.rs
index 315943e..28b2151 100644
--- a/lightning/src/ln/onion_route_tests.rs
+++ b/lightning/src/ln/onion_route_tests.rs
@@ -1776,7 +1776,7 @@ fn do_test_onion_failure_stale_channel_update(announce_for_forwarding: bool) {
let chan_2_monitor_serialized = get_monitor!(nodes[1], channel_to_update.0).encode();
reload_node!(
nodes[1],
- nodes[1].node.get_current_default_configuration().clone(),
+ nodes[1].node.get_current_config(),
&nodes[1].node.encode(),
&[&chan_1_monitor_serialized, &chan_2_monitor_serialized],
persister,
diff --git a/lightning/src/ln/reorg_tests.rs b/lightning/src/ln/reorg_tests.rs
index d85c95c..1c3ee82 100644
--- a/lightning/src/ln/reorg_tests.rs
+++ b/lightning/src/ln/reorg_tests.rs
@@ -323,7 +323,7 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, use_funding_
let nodes_0_serialized = nodes[0].node.encode();
let chan_0_monitor_serialized = get_monitor!(nodes[0], chan.2).encode();
- reload_node!(nodes[0], nodes[0].node.get_current_default_configuration().clone(), &nodes_0_serialized, &[&chan_0_monitor_serialized], persister, new_chain_monitor, nodes_0_deserialized);
+ reload_node!(nodes[0], nodes[0].node.get_current_config(), &nodes_0_serialized, &[&chan_0_monitor_serialized], persister, new_chain_monitor, nodes_0_deserialized);
}
if reorg_after_reload {
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.