You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Req the counterparty node id when claiming against a closed chan
Currently we store in-flight `ChannelMonitorUpdate`s in the
per-peer structure in `ChannelManager`. This is nice and simple as
we're generally updating it when we're updating other per-peer
data, so we already have the relevant lock(s) and map entries.
Sadly, when we're claiming an HTLC against a closed channel, we
didn't have the `counterparty_node_id` available until it was
added in 0.0.124 (and now we only have it for HTLCs which were
forwarded in 0.0.124). This means we can't look up the per-peer
structure when claiming old HTLCs, making it difficult to track the
new `ChannelMonitorUpdate` as in-flight.
While we could transition the in-flight `ChannelMonitorUpdate`
tracking to a new global map indexed by `OutPoint`, doing so would
result in a major lock which would be highly contended across
channels with different peers.
Instead, as we move towards tracking in-flight
`ChannelMonitorUpdate`s for closed channels we'll keep our existing
storage, leaving only the `counterparty_node_id` issue to contend
with.
Here we simply accept the issue, requiring that
`counterparty_node_id` be available when claiming HTLCs against a
closed channel. On startup, we explicitly check for any forwarded
HTLCs which came from a closed channel where the forward happened
prior to 0.0.124, failing to deserialize, or logging an warning if
the channel is still open (implying things may work out, but panics
may occur if the channel closes prior to HTLC resolution).
While this is a somewhat dissapointing resolution, LDK nodes which
forward HTLCs are generally fairly well-upgraded, so it is not
anticipated to be an issue in practice.
use crate::chain::transaction::{OutPoint, TransactionData};
45
45
use crate::events;
46
46
use crate::events::{Event, EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination, PaymentFailureReason, ReplayEvent};
@@ -7082,6 +7082,16 @@ where
7082
7082
channel_id: Some(prev_hop.channel_id),
7083
7083
};
7084
7084
7085
+
if prev_hop.counterparty_node_id.is_none() {
7086
+
let payment_hash: PaymentHash = payment_preimage.into();
7087
+
panic!(
7088
+
"Prior to upgrading to LDK 0.1, all pending HTLCs must be resolved. It appears at least the HTLC with payment_hash {} (preimage {}) was not resolved. Please downgrade to LDK 0.0.124 and resolve the HTLC prior to upgrading.",
7089
+
payment_hash,
7090
+
payment_preimage,
7091
+
);
7092
+
}
7093
+
let counterparty_node_id = prev_hop.counterparty_node_id.expect("Checked immediately above");
7094
+
7085
7095
if !during_init {
7086
7096
// We update the ChannelMonitor on the backward link, after
7087
7097
// receiving an `update_fulfill_htlc` from the forward link.
@@ -7119,40 +7129,25 @@ where
7119
7129
let (action_opt, raa_blocker_opt) = completion_action(None, false);
7120
7130
7121
7131
if let Some(raa_blocker) = raa_blocker_opt {
7122
-
let counterparty_node_id = prev_hop.counterparty_node_id.or_else(||
7123
-
// prev_hop.counterparty_node_id is always available for payments received after
7124
-
// LDK 0.0.123, but for those received on 0.0.123 and claimed later, we need to
7125
-
// look up the counterparty in the `action_opt`, if possible.
7126
-
action_opt.as_ref().and_then(|action|
7127
-
if let MonitorUpdateCompletionAction::PaymentClaimed { pending_mpp_claim, .. } = action {
0 commit comments