Skip to content

Commit 9f8d30a

Browse files
authored
Merge pull request #461 from tnull/2025-02-bump-on-htlcresolution-nonetheless
Only skip bumping channel closes for trusted peers
2 parents f1fdee5 + 7a36e5b commit 9f8d30a

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

src/config.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,11 @@ pub struct AnchorChannelsConfig {
210210
/// on-chain.
211211
///
212212
/// Channels with these peers won't count towards the retained on-chain reserve and we won't
213-
/// take any action to get the required transactions confirmed ourselves.
213+
/// take any action to get the required channel closing transactions confirmed ourselves.
214214
///
215215
/// **Note:** Trusting the channel counterparty to take the necessary actions to get the
216-
/// required Anchor spending and HTLC transactions confirmed on-chain is potentially insecure
217-
/// as the channel may not be closed if they refuse to do so, potentially leaving the user
218-
/// funds stuck *or* even allow the counterparty to steal any in-flight funds after the
219-
/// corresponding HTLCs time out.
216+
/// required Anchor spending transactions confirmed on-chain is potentially insecure
217+
/// as the channel may not be closed if they refuse to do so.
220218
pub trusted_peers_no_reserve: Vec<PublicKey>,
221219
/// The amount of satoshis per anchors-negotiated channel with an untrusted peer that we keep
222220
/// as an emergency reserve in our on-chain wallet.
@@ -228,9 +226,9 @@ pub struct AnchorChannelsConfig {
228226
/// [`AnchorChannelsConfig::trusted_peers_no_reserve`], we will always try to spend the Anchor
229227
/// outputs with *any* on-chain funds available, i.e., the total reserve value as well as any
230228
/// spendable funds available in the on-chain wallet. Therefore, this per-channel multiplier is
231-
/// really a emergencey reserve that we maintain at all time to reduce reduce the risk of
229+
/// really a emergency reserve that we maintain at all time to reduce reduce the risk of
232230
/// insufficient funds at time of a channel closure. To this end, we will refuse to open
233-
/// outbound or accept inbound channels if we don't have sufficient on-chain funds availble to
231+
/// outbound or accept inbound channels if we don't have sufficient on-chain funds available to
234232
/// cover the additional reserve requirement.
235233
///
236234
/// **Note:** Depending on the fee market at the time of closure, this reserve amount might or

src/event.rs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,30 +1373,29 @@ where
13731373
}
13741374
},
13751375
LdkEvent::BumpTransaction(bte) => {
1376-
let (channel_id, counterparty_node_id) = match bte {
1376+
match bte {
13771377
BumpTransactionEvent::ChannelClose {
13781378
ref channel_id,
13791379
ref counterparty_node_id,
13801380
..
1381-
} => (channel_id, counterparty_node_id),
1382-
BumpTransactionEvent::HTLCResolution {
1383-
ref channel_id,
1384-
ref counterparty_node_id,
1385-
..
1386-
} => (channel_id, counterparty_node_id),
1387-
};
1388-
1389-
if let Some(anchor_channels_config) = self.config.anchor_channels_config.as_ref() {
1390-
if anchor_channels_config
1391-
.trusted_peers_no_reserve
1392-
.contains(counterparty_node_id)
1393-
{
1394-
log_debug!(self.logger,
1395-
"Ignoring BumpTransactionEvent for channel {} due to trusted counterparty {}",
1396-
channel_id, counterparty_node_id
1397-
);
1398-
return Ok(());
1399-
}
1381+
} => {
1382+
// Skip bumping channel closes if our counterparty is trusted.
1383+
if let Some(anchor_channels_config) =
1384+
self.config.anchor_channels_config.as_ref()
1385+
{
1386+
if anchor_channels_config
1387+
.trusted_peers_no_reserve
1388+
.contains(counterparty_node_id)
1389+
{
1390+
log_debug!(self.logger,
1391+
"Ignoring BumpTransactionEvent::ChannelClose for channel {} due to trusted counterparty {}",
1392+
channel_id, counterparty_node_id
1393+
);
1394+
return Ok(());
1395+
}
1396+
}
1397+
},
1398+
BumpTransactionEvent::HTLCResolution { .. } => {},
14001399
}
14011400

14021401
self.bump_tx_event_handler.handle_event(&bte);

0 commit comments

Comments
 (0)