Skip to content

Commit

Permalink
Merge pull request #461 from tnull/2025-02-bump-on-htlcresolution-non…
Browse files Browse the repository at this point in the history
…etheless

Only skip bumping channel closes for trusted peers
  • Loading branch information
tnull authored Feb 6, 2025
2 parents f1fdee5 + 7a36e5b commit 9f8d30a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
12 changes: 5 additions & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,11 @@ pub struct AnchorChannelsConfig {
/// on-chain.
///
/// Channels with these peers won't count towards the retained on-chain reserve and we won't
/// take any action to get the required transactions confirmed ourselves.
/// take any action to get the required channel closing transactions confirmed ourselves.
///
/// **Note:** Trusting the channel counterparty to take the necessary actions to get the
/// required Anchor spending and HTLC transactions confirmed on-chain is potentially insecure
/// as the channel may not be closed if they refuse to do so, potentially leaving the user
/// funds stuck *or* even allow the counterparty to steal any in-flight funds after the
/// corresponding HTLCs time out.
/// required Anchor spending transactions confirmed on-chain is potentially insecure
/// as the channel may not be closed if they refuse to do so.
pub trusted_peers_no_reserve: Vec<PublicKey>,
/// The amount of satoshis per anchors-negotiated channel with an untrusted peer that we keep
/// as an emergency reserve in our on-chain wallet.
Expand All @@ -228,9 +226,9 @@ pub struct AnchorChannelsConfig {
/// [`AnchorChannelsConfig::trusted_peers_no_reserve`], we will always try to spend the Anchor
/// outputs with *any* on-chain funds available, i.e., the total reserve value as well as any
/// spendable funds available in the on-chain wallet. Therefore, this per-channel multiplier is
/// really a emergencey reserve that we maintain at all time to reduce reduce the risk of
/// really a emergency reserve that we maintain at all time to reduce reduce the risk of
/// insufficient funds at time of a channel closure. To this end, we will refuse to open
/// outbound or accept inbound channels if we don't have sufficient on-chain funds availble to
/// outbound or accept inbound channels if we don't have sufficient on-chain funds available to
/// cover the additional reserve requirement.
///
/// **Note:** Depending on the fee market at the time of closure, this reserve amount might or
Expand Down
39 changes: 19 additions & 20 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1373,30 +1373,29 @@ where
}
},
LdkEvent::BumpTransaction(bte) => {
let (channel_id, counterparty_node_id) = match bte {
match bte {
BumpTransactionEvent::ChannelClose {
ref channel_id,
ref counterparty_node_id,
..
} => (channel_id, counterparty_node_id),
BumpTransactionEvent::HTLCResolution {
ref channel_id,
ref counterparty_node_id,
..
} => (channel_id, counterparty_node_id),
};

if let Some(anchor_channels_config) = self.config.anchor_channels_config.as_ref() {
if anchor_channels_config
.trusted_peers_no_reserve
.contains(counterparty_node_id)
{
log_debug!(self.logger,
"Ignoring BumpTransactionEvent for channel {} due to trusted counterparty {}",
channel_id, counterparty_node_id
);
return Ok(());
}
} => {
// Skip bumping channel closes if our counterparty is trusted.
if let Some(anchor_channels_config) =
self.config.anchor_channels_config.as_ref()
{
if anchor_channels_config
.trusted_peers_no_reserve
.contains(counterparty_node_id)
{
log_debug!(self.logger,
"Ignoring BumpTransactionEvent::ChannelClose for channel {} due to trusted counterparty {}",
channel_id, counterparty_node_id
);
return Ok(());
}
}
},
BumpTransactionEvent::HTLCResolution { .. } => {},
}

self.bump_tx_event_handler.handle_event(&bte);
Expand Down

0 comments on commit 9f8d30a

Please sign in to comment.