Skip to content

Commit 2d24a89

Browse files
committed
Make next_channel_counterparty_node_id non-optional
1 parent d9721e6 commit 2d24a89

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

73367336
fn claim_funds_internal(&self, source: HTLCSource, payment_preimage: PaymentPreimage,
73377337
forwarded_htlc_value_msat: Option<u64>, skimmed_fee_msat: Option<u64>, from_onchain: bool,
7338-
startup_replay: bool, next_channel_counterparty_node_id: Option<PublicKey>,
7338+
startup_replay: bool, next_channel_counterparty_node_id: PublicKey,
73397339
next_channel_outpoint: OutPoint, next_channel_id: ChannelId, next_user_channel_id: Option<u128>,
73407340
) {
73417341
match source {
73427342
HTLCSource::OutboundRoute { session_priv, payment_id, path, .. } => {
73437343
debug_assert!(self.background_events_processed_since_startup.load(Ordering::Acquire),
73447344
"We don't support claim_htlc claims during startup - monitors may not be available yet");
7345-
if let Some(pubkey) = next_channel_counterparty_node_id {
7346-
debug_assert_eq!(pubkey, path.hops[0].pubkey);
7347-
}
7345+
debug_assert_eq!(next_channel_counterparty_node_id, path.hops[0].pubkey);
73487346
let ev_completion_action = EventCompletionAction::ReleaseRAAChannelMonitorUpdate {
73497347
channel_funding_outpoint: next_channel_outpoint, channel_id: next_channel_id,
73507348
counterparty_node_id: path.hops[0].pubkey,
@@ -7360,22 +7358,12 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
73607358
let completed_blocker = RAAMonitorUpdateBlockingAction::from_prev_hop_data(&hop_data);
73617359
self.claim_funds_from_hop(hop_data, payment_preimage, None,
73627360
|htlc_claim_value_msat, definitely_duplicate| {
7363-
let chan_to_release =
7364-
if let Some(node_id) = next_channel_counterparty_node_id {
7365-
Some(EventUnblockedChannel {
7366-
counterparty_node_id: node_id,
7367-
funding_txo: next_channel_outpoint,
7368-
channel_id: next_channel_id,
7369-
blocking_action: completed_blocker
7370-
})
7371-
} else {
7372-
// We can only get `None` here if we are processing a
7373-
// `ChannelMonitor`-originated event, in which case we
7374-
// don't care about ensuring we wake the downstream
7375-
// channel's monitor updating - the channel is already
7376-
// closed.
7377-
None
7378-
};
7361+
let chan_to_release = Some(EventUnblockedChannel {
7362+
counterparty_node_id: next_channel_counterparty_node_id,
7363+
funding_txo: next_channel_outpoint,
7364+
channel_id: next_channel_id,
7365+
blocking_action: completed_blocker
7366+
});
73797367

73807368
if definitely_duplicate && startup_replay {
73817369
// On startup we may get redundant claims which are related to
@@ -7407,7 +7395,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
74077395
prev_user_channel_id,
74087396
next_user_channel_id,
74097397
prev_node_id,
7410-
next_node_id: next_channel_counterparty_node_id,
7398+
next_node_id: Some(next_channel_counterparty_node_id),
74117399
total_fee_earned_msat,
74127400
skimmed_fee_msat,
74137401
claim_from_onchain_tx: from_onchain,
@@ -8816,7 +8804,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
88168804
}
88178805
};
88188806
self.claim_funds_internal(htlc_source, msg.payment_preimage.clone(),
8819-
Some(forwarded_htlc_value), skimmed_fee_msat, false, false, Some(*counterparty_node_id),
8807+
Some(forwarded_htlc_value), skimmed_fee_msat, false, false, *counterparty_node_id,
88208808
funding_txo, msg.channel_id, Some(next_user_channel_id),
88218809
);
88228810

@@ -9408,9 +9396,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
94089396
let logger = WithContext::from(&self.logger, Some(counterparty_node_id), Some(channel_id), Some(htlc_update.payment_hash));
94099397
if let Some(preimage) = htlc_update.payment_preimage {
94109398
log_trace!(logger, "Claiming HTLC with preimage {} from our monitor", preimage);
9411-
self.claim_funds_internal(htlc_update.source, preimage,
9399+
self.claim_funds_internal(
9400+
htlc_update.source, preimage,
94129401
htlc_update.htlc_value_satoshis.map(|v| v * 1000), None, true,
9413-
false, Some(counterparty_node_id), funding_outpoint, channel_id, None);
9402+
false, counterparty_node_id, funding_outpoint, channel_id, None,
9403+
);
94149404
} else {
94159405
log_trace!(logger, "Failing HTLC with hash {} from our monitor", &htlc_update.payment_hash);
94169406
let receiver = HTLCDestination::NextHopChannel { node_id: Some(counterparty_node_id), channel_id };
@@ -14285,7 +14275,7 @@ where
1428514275
}
1428614276

1428714277
Some((htlc_source, payment_preimage, htlc.amount_msat,
14288-
is_channel_closed, Some(monitor.get_counterparty_node_id()),
14278+
is_channel_closed, monitor.get_counterparty_node_id(),
1428914279
monitor.get_funding_txo(), monitor.channel_id()))
1429014280
} else { None }
1429114281
} else {

0 commit comments

Comments
 (0)