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
Marginally simplify types for req'd counterparty_node_id in claim
In 0.1 we started requiring `counterparty_node_id` to be filled in
in various previous-hop datastructures when claiming HTLCs. While
we can't switch `HTLCSource`'s
`HTLCPreviousHopData::counterparty_node_id` to required (as it
might cause us to fail to read old `ChannelMonitor`s which still
hold `HTLCSource`s we no longer need to claim), we can at least
start requiring the field in `PendingAddHTLCInfo` and
`HTLCClaimSource`. This simplifies `claim_mpp_part` marginally.
let counterparty_id = htlc.prev_hop.counterparty_node_id;
8085
+
let counterparty_id = counterparty_id
8086
+
.expect("Prior to upgrading to LDK 0.1, all pending HTLCs forwarded by LDK 0.0.123 or before must be resolved. It appears at least one claimable payment was not resolved. Please downgrade to LDK 0.0.125 and resolve the HTLC by claiming the payment prior to upgrading.");
8087
+
let claim_ptr = PendingMPPClaimPointer(Arc::clone(pending_mpp_claim));
let counterparty_node_id = if let Some(node_id) = counterparty_node_id {
8171
+
node_id
8172
+
} else {
8173
+
let payment_hash: PaymentHash = payment_preimage.into();
8174
+
panic!(
8175
+
"Prior to upgrading to LDK 0.1, all pending HTLCs forwarded by LDK 0.0.123 or before must be resolved. It appears at least the HTLC with payment_hash {payment_hash} (preimage {payment_preimage}) was not resolved. Please downgrade to LDK 0.0.125 and resolve the HTLC prior to upgrading.",
8176
+
);
8177
+
};
8171
8178
8172
8179
let htlc_source = HTLCClaimSource {
8173
8180
counterparty_node_id,
@@ -8212,18 +8219,13 @@ where
8212
8219
const MISSING_MON_ERROR: &'static str =
8213
8220
"If we're going to claim an HTLC against a channel, we should always have *some* state for the channel, even if just the latest ChannelMonitor update_id. This failure indicates we need to claim an HTLC from a channel for which we did not have a ChannelMonitor at startup and didn't create one while running.";
8214
8221
8215
-
// Note here that `peer_state_opt` is always `Some` if `prev_hop.counterparty_node_id` is
8216
-
// `Some`. This is relied on in the closed-channel case below.
if let Some(peer_state_lock) = peer_state_opt.as_mut() {
8226
-
let peer_state = &mut **peer_state_lock;
8227
+
{
8228
+
let peer_state = &mut *peer_state_lock;
8227
8229
if let hash_map::Entry::Occupied(mut chan_entry) =
8228
8230
peer_state.channel_by_id.entry(chan_id)
8229
8231
{
@@ -8261,7 +8263,7 @@ where
8261
8263
self,
8262
8264
prev_hop.funding_txo,
8263
8265
monitor_update,
8264
-
peer_state_opt,
8266
+
peer_state_lock,
8265
8267
peer_state,
8266
8268
per_peer_state,
8267
8269
chan
@@ -8312,7 +8314,7 @@ where
8312
8314
return;
8313
8315
}
8314
8316
8315
-
mem::drop(peer_state_opt);
8317
+
mem::drop(peer_state_lock);
8316
8318
8317
8319
log_trace!(logger, "Completing monitor update completion action for channel {} as claim was redundant: {:?}",
8318
8320
chan_id, action);
@@ -8365,18 +8367,7 @@ where
8365
8367
}
8366
8368
}
8367
8369
8368
-
if prev_hop.counterparty_node_id.is_none() {
8369
-
let payment_hash: PaymentHash = payment_preimage.into();
8370
-
panic!(
8371
-
"Prior to upgrading to LDK 0.1, all pending HTLCs forwarded by LDK 0.0.123 or before must be resolved. It appears at least the HTLC with payment_hash {} (preimage {}) was not resolved. Please downgrade to LDK 0.0.125 and resolve the HTLC prior to upgrading.",
0 commit comments