Skip to content

Commit 01cc813

Browse files
committed
Make next_channel_counterparty_node_id non-optional
1 parent fa5b43b commit 01cc813

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
@@ -7320,16 +7320,14 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
73207320

73217321
fn claim_funds_internal(&self, source: HTLCSource, payment_preimage: PaymentPreimage,
73227322
forwarded_htlc_value_msat: Option<u64>, skimmed_fee_msat: Option<u64>, from_onchain: bool,
7323-
startup_replay: bool, next_channel_counterparty_node_id: Option<PublicKey>,
7323+
startup_replay: bool, next_channel_counterparty_node_id: PublicKey,
73247324
next_channel_outpoint: OutPoint, next_channel_id: ChannelId, next_user_channel_id: Option<u128>,
73257325
) {
73267326
match source {
73277327
HTLCSource::OutboundRoute { session_priv, payment_id, path, .. } => {
73287328
debug_assert!(self.background_events_processed_since_startup.load(Ordering::Acquire),
73297329
"We don't support claim_htlc claims during startup - monitors may not be available yet");
7330-
if let Some(pubkey) = next_channel_counterparty_node_id {
7331-
debug_assert_eq!(pubkey, path.hops[0].pubkey);
7332-
}
7330+
debug_assert_eq!(next_channel_counterparty_node_id, path.hops[0].pubkey);
73337331
let ev_completion_action = EventCompletionAction::ReleaseRAAChannelMonitorUpdate {
73347332
channel_funding_outpoint: next_channel_outpoint, channel_id: next_channel_id,
73357333
counterparty_node_id: path.hops[0].pubkey,
@@ -7345,22 +7343,12 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
73457343
let completed_blocker = RAAMonitorUpdateBlockingAction::from_prev_hop_data(&hop_data);
73467344
self.claim_funds_from_hop(hop_data, payment_preimage, None,
73477345
|htlc_claim_value_msat, definitely_duplicate| {
7348-
let chan_to_release =
7349-
if let Some(node_id) = next_channel_counterparty_node_id {
7350-
Some(EventUnblockedChannel {
7351-
counterparty_node_id: node_id,
7352-
funding_txo: next_channel_outpoint,
7353-
channel_id: next_channel_id,
7354-
blocking_action: completed_blocker
7355-
})
7356-
} else {
7357-
// We can only get `None` here if we are processing a
7358-
// `ChannelMonitor`-originated event, in which case we
7359-
// don't care about ensuring we wake the downstream
7360-
// channel's monitor updating - the channel is already
7361-
// closed.
7362-
None
7363-
};
7346+
let chan_to_release = Some(EventUnblockedChannel {
7347+
counterparty_node_id: next_channel_counterparty_node_id,
7348+
funding_txo: next_channel_outpoint,
7349+
channel_id: next_channel_id,
7350+
blocking_action: completed_blocker
7351+
});
73647352

73657353
if definitely_duplicate && startup_replay {
73667354
// On startup we may get redundant claims which are related to
@@ -7392,7 +7380,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
73927380
prev_user_channel_id,
73937381
next_user_channel_id,
73947382
prev_node_id,
7395-
next_node_id: next_channel_counterparty_node_id,
7383+
next_node_id: Some(next_channel_counterparty_node_id),
73967384
total_fee_earned_msat,
73977385
skimmed_fee_msat,
73987386
claim_from_onchain_tx: from_onchain,
@@ -8801,7 +8789,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
88018789
}
88028790
};
88038791
self.claim_funds_internal(htlc_source, msg.payment_preimage.clone(),
8804-
Some(forwarded_htlc_value), skimmed_fee_msat, false, false, Some(*counterparty_node_id),
8792+
Some(forwarded_htlc_value), skimmed_fee_msat, false, false, *counterparty_node_id,
88058793
funding_txo, msg.channel_id, Some(next_user_channel_id),
88068794
);
88078795

@@ -9393,9 +9381,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
93939381
let logger = WithContext::from(&self.logger, Some(counterparty_node_id), Some(channel_id), Some(htlc_update.payment_hash));
93949382
if let Some(preimage) = htlc_update.payment_preimage {
93959383
log_trace!(logger, "Claiming HTLC with preimage {} from our monitor", preimage);
9396-
self.claim_funds_internal(htlc_update.source, preimage,
9384+
self.claim_funds_internal(
9385+
htlc_update.source, preimage,
93979386
htlc_update.htlc_value_satoshis.map(|v| v * 1000), None, true,
9398-
false, Some(counterparty_node_id), funding_outpoint, channel_id, None);
9387+
false, counterparty_node_id, funding_outpoint, channel_id, None,
9388+
);
93999389
} else {
94009390
log_trace!(logger, "Failing HTLC with hash {} from our monitor", &htlc_update.payment_hash);
94019391
let receiver = HTLCDestination::NextHopChannel { node_id: Some(counterparty_node_id), channel_id };
@@ -14270,7 +14260,7 @@ where
1427014260
}
1427114261

1427214262
Some((htlc_source, payment_preimage, htlc.amount_msat,
14273-
is_channel_closed, Some(monitor.get_counterparty_node_id()),
14263+
is_channel_closed, monitor.get_counterparty_node_id(),
1427414264
monitor.get_funding_txo(), monitor.channel_id()))
1427514265
} else { None }
1427614266
} else {

0 commit comments

Comments
 (0)