-
Notifications
You must be signed in to change notification settings - Fork 416
Replay lost MonitorEvent
s in some cases for closed channels
#4004
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
Changes from all commits
0a6c3fb
a8ec966
8106dbf
3239d67
543cc85
9186900
f809e6c
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 |
---|---|---|
|
@@ -15804,7 +15804,7 @@ where | |
log_error!(logger, " The ChannelMonitor for channel {} is at counterparty commitment transaction number {} but the ChannelManager is at counterparty commitment transaction number {}.", | ||
&channel.context.channel_id(), monitor.get_cur_counterparty_commitment_number(), channel.get_cur_counterparty_commitment_transaction_number()); | ||
} | ||
let mut shutdown_result = | ||
let shutdown_result = | ||
channel.force_shutdown(ClosureReason::OutdatedChannelManager); | ||
if shutdown_result.unbroadcasted_batch_funding_txid.is_some() { | ||
return Err(DecodeError::InvalidValue); | ||
|
@@ -15836,7 +15836,10 @@ where | |
}, | ||
); | ||
} | ||
failed_htlcs.append(&mut shutdown_result.dropped_outbound_htlcs); | ||
for (source, hash, cp_id, chan_id) in shutdown_result.dropped_outbound_htlcs { | ||
let reason = LocalHTLCFailureReason::ChannelClosed; | ||
failed_htlcs.push((source, hash, cp_id, chan_id, reason)); | ||
} | ||
channel_closures.push_back(( | ||
events::Event::ChannelClosed { | ||
channel_id: channel.context.channel_id(), | ||
|
@@ -15878,6 +15881,7 @@ where | |
*payment_hash, | ||
channel.context.get_counterparty_node_id(), | ||
channel.context.channel_id(), | ||
LocalHTLCFailureReason::ChannelClosed, | ||
)); | ||
} | ||
} | ||
|
@@ -16451,8 +16455,11 @@ where | |
// payments which are still in-flight via their on-chain state. | ||
// We only rebuild the pending payments map if we were most recently serialized by | ||
// 0.0.102+ | ||
// | ||
// First we rebuild all pending payments, then separately re-claim and re-fail pending | ||
// payments. This avoids edge-cases around MPP payments resulting in redundant actions. | ||
for (channel_id, monitor) in args.channel_monitors.iter() { | ||
let mut is_channel_closed = false; | ||
let mut is_channel_closed = true; | ||
let counterparty_node_id = monitor.get_counterparty_node_id(); | ||
if let Some(peer_state_mtx) = per_peer_state.get(&counterparty_node_id) { | ||
let mut peer_state_lock = peer_state_mtx.lock().unwrap(); | ||
|
@@ -16489,6 +16496,18 @@ where | |
); | ||
} | ||
} | ||
} | ||
} | ||
for (channel_id, monitor) in args.channel_monitors.iter() { | ||
let mut is_channel_closed = true; | ||
let counterparty_node_id = monitor.get_counterparty_node_id(); | ||
if let Some(peer_state_mtx) = per_peer_state.get(&counterparty_node_id) { | ||
let mut peer_state_lock = peer_state_mtx.lock().unwrap(); | ||
let peer_state = &mut *peer_state_lock; | ||
is_channel_closed = !peer_state.channel_by_id.contains_key(channel_id); | ||
} | ||
|
||
if is_channel_closed { | ||
for (htlc_source, (htlc, preimage_opt)) in | ||
monitor.get_all_current_outbound_htlcs() | ||
{ | ||
|
@@ -16586,6 +16605,20 @@ where | |
}, | ||
} | ||
} | ||
for (htlc_source, payment_hash) in monitor.get_onchain_failed_outbound_htlcs() { | ||
log_info!( | ||
args.logger, | ||
"Failing HTLC with payment hash {} as it was resolved on-chain.", | ||
payment_hash | ||
); | ||
failed_htlcs.push(( | ||
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. Will we generate a 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. That's fixed in #3984 :) |
||
htlc_source, | ||
payment_hash, | ||
monitor.get_counterparty_node_id(), | ||
monitor.channel_id(), | ||
LocalHTLCFailureReason::OnChainTimeout, | ||
)); | ||
} | ||
} | ||
|
||
// Whether the downstream channel was closed or not, try to re-apply any payment | ||
|
@@ -17266,13 +17299,10 @@ where | |
} | ||
} | ||
|
||
for htlc_source in failed_htlcs.drain(..) { | ||
let (source, payment_hash, counterparty_node_id, channel_id) = htlc_source; | ||
let failure_reason = LocalHTLCFailureReason::ChannelClosed; | ||
let receiver = HTLCHandlingFailureType::Forward { | ||
node_id: Some(counterparty_node_id), | ||
channel_id, | ||
}; | ||
for htlc_source in failed_htlcs { | ||
let (source, payment_hash, counterparty_id, channel_id, failure_reason) = htlc_source; | ||
let receiver = | ||
HTLCHandlingFailureType::Forward { node_id: Some(counterparty_id), channel_id }; | ||
let reason = HTLCFailReason::from_failure_code(failure_reason); | ||
channel_manager.fail_htlc_backwards_internal(&source, &payment_hash, &reason, receiver); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.