-
Notifications
You must be signed in to change notification settings - Fork 421
Do not FC for outgoing payments #4140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5899,26 +5899,38 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> { | |
// chain when our counterparty is waiting for expiration to off-chain fail an HTLC | ||
// we give ourselves a few blocks of headroom after expiration before going | ||
// on-chain for an expired HTLC. | ||
let htlc_outbound = $holder_tx == htlc.offered; | ||
if ( htlc_outbound && htlc.cltv_expiry + LATENCY_GRACE_PERIOD_BLOCKS <= height) || | ||
(!htlc_outbound && htlc.cltv_expiry <= height + CLTV_CLAIM_BUFFER && self.payment_preimages.contains_key(&htlc.payment_hash)) { | ||
log_info!(logger, "Force-closing channel due to {} HTLC timeout - HTLC with payment hash {} expires at {}", if htlc_outbound { "outbound" } else { "inbound"}, htlc.payment_hash, htlc.cltv_expiry); | ||
return Some(htlc.payment_hash); | ||
let htlc_outbound = $holder_tx == htlc.0.offered; | ||
let has_incoming = if htlc_outbound { | ||
if let Some(source) = htlc.1.as_deref() { | ||
match *source { | ||
HTLCSource::OutboundRoute { .. } => false, | ||
HTLCSource::PreviousHopData(_) => true, | ||
} | ||
} else { | ||
panic!("Every offered non-dust HTLC should have a corresponding source"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this particular spot, dust offered HTLCs on So this would include all these cases too: "Every outbound HTLC should have a corresponding source" |
||
} | ||
} else { | ||
true | ||
}; | ||
if (htlc_outbound && has_incoming && htlc.0.cltv_expiry + LATENCY_GRACE_PERIOD_BLOCKS <= height) || | ||
(!htlc_outbound && htlc.0.cltv_expiry <= height + CLTV_CLAIM_BUFFER && self.payment_preimages.contains_key(&htlc.0.payment_hash)) { | ||
valentinewallace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
log_info!(logger, "Force-closing channel due to {} HTLC timeout - HTLC with payment hash {} expires at {}", if htlc_outbound { "outbound" } else { "inbound"}, htlc.0.payment_hash, htlc.0.cltv_expiry); | ||
return Some(htlc.0.payment_hash); | ||
Comment on lines
+5902
to
+5918
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've got this diff below on this section here, seems to me it reads better ? Feel free to edit diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs
index 5b9d7435d1..f364b25f0c 100644
--- a/lightning/src/chain/channelmonitor.rs
+++ b/lightning/src/chain/channelmonitor.rs
@@ -5887,7 +5887,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
let height = self.best_block.height;
macro_rules! scan_commitment {
($htlcs: expr, $holder_tx: expr) => {
- for ref htlc in $htlcs {
+ for (ref htlc, ref source) in $htlcs {
// For inbound HTLCs which we know the preimage for, we have to ensure we hit the
// chain with enough room to claim the HTLC without our counterparty being able to
// time out the HTLC first.
@@ -5899,23 +5899,13 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
// chain when our counterparty is waiting for expiration to off-chain fail an HTLC
// we give ourselves a few blocks of headroom after expiration before going
// on-chain for an expired HTLC.
- let htlc_outbound = $holder_tx == htlc.0.offered;
- let has_incoming = if htlc_outbound {
- if let Some(source) = htlc.1.as_deref() {
- match *source {
- HTLCSource::OutboundRoute { .. } => false,
- HTLCSource::PreviousHopData(_) => true,
- }
- } else {
- panic!("Every offered non-dust HTLC should have a corresponding source");
- }
- } else {
- true
- };
- if (htlc_outbound && has_incoming && htlc.0.cltv_expiry + LATENCY_GRACE_PERIOD_BLOCKS <= height) ||
- (!htlc_outbound && htlc.0.cltv_expiry <= height + CLTV_CLAIM_BUFFER && self.payment_preimages.contains_key(&htlc.0.payment_hash)) {
- log_info!(logger, "Force-closing channel due to {} HTLC timeout - HTLC with payment hash {} expires at {}", if htlc_outbound { "outbound" } else { "inbound"}, htlc.0.payment_hash, htlc.0.cltv_expiry);
- return Some(htlc.0.payment_hash);
+ let htlc_outbound = $holder_tx == htlc.offered;
+ let is_outbound_and_has_incoming = htlc_outbound
+ && matches!(source.as_deref().expect("Every outbound HTLC should have a corresponding source"), HTLCSource::PreviousHopData(_));
+ if (is_outbound_and_has_incoming && htlc.cltv_expiry + LATENCY_GRACE_PERIOD_BLOCKS <= height) ||
+ (!htlc_outbound && htlc.cltv_expiry <= height + CLTV_CLAIM_BUFFER && self.payment_preimages.contains_key(&htlc.payment_hash)) {
+ log_info!(logger, "Force-closing channel due to {} HTLC timeout - HTLC with payment hash {} expires at {}", if htlc_outbound { "outbound" } else { "inbound"}, htlc.payment_hash, htlc.cltv_expiry);
+ return Some(htlc.payment_hash);
}
}
} |
||
} | ||
} | ||
} | ||
} | ||
|
||
scan_commitment!(holder_commitment_htlcs!(self, CURRENT), true); | ||
scan_commitment!(holder_commitment_htlcs!(self, CURRENT_WITH_SOURCES), true); | ||
|
||
if let Some(ref txid) = self.funding.current_counterparty_commitment_txid { | ||
if let Some(ref htlc_outputs) = self.funding.counterparty_claimable_outpoints.get(txid) { | ||
scan_commitment!(htlc_outputs.iter().map(|&(ref a, _)| a), false); | ||
scan_commitment!(htlc_outputs.iter(), false); | ||
} | ||
} | ||
if let Some(ref txid) = self.funding.prev_counterparty_commitment_txid { | ||
if let Some(ref htlc_outputs) = self.funding.counterparty_claimable_outpoints.get(txid) { | ||
scan_commitment!(htlc_outputs.iter().map(|&(ref a, _)| a), false); | ||
scan_commitment!(htlc_outputs.iter(), false); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,11 @@ fn test_monitor_and_persister_update_fail() { | |
chain_mon | ||
.chain_monitor | ||
.block_connected(&create_dummy_block(BlockHash::all_zeros(), 42, Vec::new()), 200); | ||
chain_mon.chain_monitor.get_monitor(chan.2).unwrap().broadcast_latest_holder_commitment_txn( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: add a comment |
||
&&tx_broadcaster, | ||
&nodes[0].fee_estimator, | ||
&nodes[0].logger, | ||
); | ||
|
||
// Try to update ChannelMonitor | ||
nodes[1].node.claim_funds(preimage); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should update this comment for the new behavior