Skip to content

Commit 45652fd

Browse files
committed
Make next_channel_counterparty_node_id non-optional
1 parent a71cc4b commit 45652fd

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7307,16 +7307,14 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
73077307

73087308
fn claim_funds_internal(&self, source: HTLCSource, payment_preimage: PaymentPreimage,
73097309
forwarded_htlc_value_msat: Option<u64>, skimmed_fee_msat: Option<u64>, from_onchain: bool,
7310-
startup_replay: bool, next_channel_counterparty_node_id: Option<PublicKey>,
7310+
startup_replay: bool, next_channel_counterparty_node_id: PublicKey,
73117311
next_channel_outpoint: OutPoint, next_channel_id: ChannelId, next_user_channel_id: Option<u128>,
73127312
) {
73137313
match source {
73147314
HTLCSource::OutboundRoute { session_priv, payment_id, path, .. } => {
73157315
debug_assert!(self.background_events_processed_since_startup.load(Ordering::Acquire),
73167316
"We don't support claim_htlc claims during startup - monitors may not be available yet");
7317-
if let Some(pubkey) = next_channel_counterparty_node_id {
7318-
debug_assert_eq!(pubkey, path.hops[0].pubkey);
7319-
}
7317+
debug_assert_eq!(next_channel_counterparty_node_id, path.hops[0].pubkey);
73207318
let ev_completion_action = EventCompletionAction::ReleaseRAAChannelMonitorUpdate {
73217319
channel_funding_outpoint: next_channel_outpoint, channel_id: next_channel_id,
73227320
counterparty_node_id: path.hops[0].pubkey,
@@ -7332,22 +7330,12 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
73327330
let completed_blocker = RAAMonitorUpdateBlockingAction::from_prev_hop_data(&hop_data);
73337331
self.claim_funds_from_hop(hop_data, payment_preimage, None,
73347332
|htlc_claim_value_msat, definitely_duplicate| {
7335-
let chan_to_release =
7336-
if let Some(node_id) = next_channel_counterparty_node_id {
7337-
Some(EventUnblockedChannel {
7338-
counterparty_node_id: node_id,
7339-
funding_txo: next_channel_outpoint,
7340-
channel_id: next_channel_id,
7341-
blocking_action: completed_blocker
7342-
})
7343-
} else {
7344-
// We can only get `None` here if we are processing a
7345-
// `ChannelMonitor`-originated event, in which case we
7346-
// don't care about ensuring we wake the downstream
7347-
// channel's monitor updating - the channel is already
7348-
// closed.
7349-
None
7350-
};
7333+
let chan_to_release = Some(EventUnblockedChannel {
7334+
counterparty_node_id: next_channel_counterparty_node_id,
7335+
funding_txo: next_channel_outpoint,
7336+
channel_id: next_channel_id,
7337+
blocking_action: completed_blocker
7338+
});
73517339

73527340
if definitely_duplicate && startup_replay {
73537341
// On startup we may get redundant claims which are related to
@@ -7379,7 +7367,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
73797367
prev_user_channel_id,
73807368
next_user_channel_id,
73817369
prev_node_id,
7382-
next_node_id: next_channel_counterparty_node_id,
7370+
next_node_id: Some(next_channel_counterparty_node_id),
73837371
total_fee_earned_msat,
73847372
skimmed_fee_msat,
73857373
claim_from_onchain_tx: from_onchain,
@@ -8788,7 +8776,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
87888776
}
87898777
};
87908778
self.claim_funds_internal(htlc_source, msg.payment_preimage.clone(),
8791-
Some(forwarded_htlc_value), skimmed_fee_msat, false, false, Some(*counterparty_node_id),
8779+
Some(forwarded_htlc_value), skimmed_fee_msat, false, false, *counterparty_node_id,
87928780
funding_txo, msg.channel_id, Some(next_user_channel_id),
87938781
);
87948782

@@ -9380,9 +9368,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
93809368
let logger = WithContext::from(&self.logger, Some(counterparty_node_id), Some(channel_id), Some(htlc_update.payment_hash));
93819369
if let Some(preimage) = htlc_update.payment_preimage {
93829370
log_trace!(logger, "Claiming HTLC with preimage {} from our monitor", preimage);
9383-
self.claim_funds_internal(htlc_update.source, preimage,
9371+
self.claim_funds_internal(
9372+
htlc_update.source, preimage,
93849373
htlc_update.htlc_value_satoshis.map(|v| v * 1000), None, true,
9385-
false, Some(counterparty_node_id), funding_outpoint, channel_id, None);
9374+
false, counterparty_node_id, funding_outpoint, channel_id, None,
9375+
);
93869376
} else {
93879377
log_trace!(logger, "Failing HTLC with hash {} from our monitor", &htlc_update.payment_hash);
93889378
let receiver = HTLCDestination::NextHopChannel { node_id: Some(counterparty_node_id), channel_id };
@@ -14257,7 +14247,7 @@ where
1425714247
}
1425814248

1425914249
Some((htlc_source, payment_preimage, htlc.amount_msat,
14260-
is_channel_closed, Some(monitor.get_counterparty_node_id()),
14250+
is_channel_closed, monitor.get_counterparty_node_id(),
1426114251
monitor.get_funding_txo(), monitor.channel_id()))
1426214252
} else { None }
1426314253
} else {

0 commit comments

Comments
 (0)