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,
@@ -8214,16 +8221,13 @@ where
8214
8221
8215
8222
// Note here that `peer_state_opt` is always `Some` if `prev_hop.counterparty_node_id` is
8216
8223
// `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;
8229
+
{
8230
+
let peer_state = &mut *peer_state_lock;
8227
8231
if let hash_map::Entry::Occupied(mut chan_entry) =
8228
8232
peer_state.channel_by_id.entry(chan_id)
8229
8233
{
@@ -8261,7 +8265,7 @@ where
8261
8265
self,
8262
8266
prev_hop.funding_txo,
8263
8267
monitor_update,
8264
-
peer_state_opt,
8268
+
peer_state_lock,
8265
8269
peer_state,
8266
8270
per_peer_state,
8267
8271
chan
@@ -8293,7 +8297,7 @@ where
8293
8297
return;
8294
8298
};
8295
8299
8296
-
mem::drop(peer_state_opt);
8300
+
mem::drop(peer_state_lock);
8297
8301
8298
8302
log_trace!(logger, "Completing monitor update completion action for channel {} as claim was redundant: {:?}",
8299
8303
chan_id, action);
@@ -8346,18 +8350,7 @@ where
8346
8350
}
8347
8351
}
8348
8352
8349
-
if prev_hop.counterparty_node_id.is_none() {
8350
-
let payment_hash: PaymentHash = payment_preimage.into();
8351
-
panic!(
8352
-
"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