Skip to content

Commit dec1184

Browse files
committed
Make next_channel_counterparty_node_id non-optional
1 parent a022f3c commit dec1184

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

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

73577345
if definitely_duplicate && startup_replay {
73587346
// On startup we may get redundant claims which are related to
@@ -7384,7 +7372,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
73847372
prev_user_channel_id,
73857373
next_user_channel_id,
73867374
prev_node_id,
7387-
next_node_id: next_channel_counterparty_node_id,
7375+
next_node_id: Some(next_channel_counterparty_node_id),
73887376
total_fee_earned_msat,
73897377
skimmed_fee_msat,
73907378
claim_from_onchain_tx: from_onchain,
@@ -8793,7 +8781,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
87938781
}
87948782
};
87958783
self.claim_funds_internal(htlc_source, msg.payment_preimage.clone(),
8796-
Some(forwarded_htlc_value), skimmed_fee_msat, false, false, Some(*counterparty_node_id),
8784+
Some(forwarded_htlc_value), skimmed_fee_msat, false, false, *counterparty_node_id,
87978785
funding_txo, msg.channel_id, Some(next_user_channel_id),
87988786
);
87998787

@@ -9385,9 +9373,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
93859373
let logger = WithContext::from(&self.logger, Some(counterparty_node_id), Some(channel_id), Some(htlc_update.payment_hash));
93869374
if let Some(preimage) = htlc_update.payment_preimage {
93879375
log_trace!(logger, "Claiming HTLC with preimage {} from our monitor", preimage);
9388-
self.claim_funds_internal(htlc_update.source, preimage,
9376+
self.claim_funds_internal(
9377+
htlc_update.source, preimage,
93899378
htlc_update.htlc_value_satoshis.map(|v| v * 1000), None, true,
9390-
false, Some(counterparty_node_id), funding_outpoint, channel_id, None);
9379+
false, counterparty_node_id, funding_outpoint, channel_id, None,
9380+
);
93919381
} else {
93929382
log_trace!(logger, "Failing HTLC with hash {} from our monitor", &htlc_update.payment_hash);
93939383
let receiver = HTLCDestination::NextHopChannel { node_id: Some(counterparty_node_id), channel_id };
@@ -14262,7 +14252,7 @@ where
1426214252
}
1426314253

1426414254
Some((htlc_source, payment_preimage, htlc.amount_msat,
14265-
is_channel_closed, Some(monitor.get_counterparty_node_id()),
14255+
is_channel_closed, monitor.get_counterparty_node_id(),
1426614256
monitor.get_funding_txo(), monitor.channel_id()))
1426714257
} else { None }
1426814258
} else {

0 commit comments

Comments
 (0)