Skip to content

Commit 080c01e

Browse files
committed
Make next_channel_counterparty_node_id non-optional
1 parent fcfc9b4 commit 080c01e

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

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

73537341
if definitely_duplicate && startup_replay {
73547342
// On startup we may get redundant claims which are related to
@@ -7380,7 +7368,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
73807368
prev_user_channel_id,
73817369
next_user_channel_id,
73827370
prev_node_id,
7383-
next_node_id: next_channel_counterparty_node_id,
7371+
next_node_id: Some(next_channel_counterparty_node_id),
73847372
total_fee_earned_msat,
73857373
skimmed_fee_msat,
73867374
claim_from_onchain_tx: from_onchain,
@@ -8789,7 +8777,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
87898777
}
87908778
};
87918779
self.claim_funds_internal(htlc_source, msg.payment_preimage.clone(),
8792-
Some(forwarded_htlc_value), skimmed_fee_msat, false, false, Some(*counterparty_node_id),
8780+
Some(forwarded_htlc_value), skimmed_fee_msat, false, false, *counterparty_node_id,
87938781
funding_txo, msg.channel_id, Some(next_user_channel_id),
87948782
);
87958783

@@ -9381,9 +9369,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
93819369
let logger = WithContext::from(&self.logger, Some(counterparty_node_id), Some(channel_id), Some(htlc_update.payment_hash));
93829370
if let Some(preimage) = htlc_update.payment_preimage {
93839371
log_trace!(logger, "Claiming HTLC with preimage {} from our monitor", preimage);
9384-
self.claim_funds_internal(htlc_update.source, preimage,
9372+
self.claim_funds_internal(
9373+
htlc_update.source, preimage,
93859374
htlc_update.htlc_value_satoshis.map(|v| v * 1000), None, true,
9386-
false, Some(counterparty_node_id), funding_outpoint, channel_id, None);
9375+
false, counterparty_node_id, funding_outpoint, channel_id, None,
9376+
);
93879377
} else {
93889378
log_trace!(logger, "Failing HTLC with hash {} from our monitor", &htlc_update.payment_hash);
93899379
let receiver = HTLCDestination::NextHopChannel { node_id: Some(counterparty_node_id), channel_id };
@@ -14258,7 +14248,7 @@ where
1425814248
}
1425914249

1426014250
Some((htlc_source, payment_preimage, htlc.amount_msat,
14261-
is_channel_closed, Some(monitor.get_counterparty_node_id()),
14251+
is_channel_closed, monitor.get_counterparty_node_id(),
1426214252
monitor.get_funding_txo(), monitor.channel_id()))
1426314253
} else { None }
1426414254
} else {

0 commit comments

Comments
 (0)