Skip to content

Commit

Permalink
Get correct source node id in do_chain_event
Browse files Browse the repository at this point in the history
  • Loading branch information
jurvis committed May 7, 2022
1 parent c45a3d0 commit b611687
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5534,6 +5534,7 @@ where
});

if let Some(height) = height_opt {
let chan_by_id = &channel_state.by_id;
channel_state.claimable_htlcs.retain(|payment_hash, htlcs| {
htlcs.retain(|htlc| {
// If height is approaching the number of blocks we think it takes us to get
Expand All @@ -5543,10 +5544,21 @@ where
if height >= htlc.cltv_expiry - HTLC_FAIL_BACK_BUFFER {
let mut htlc_msat_height_data = byte_utils::be64_to_array(htlc.value).to_vec();
htlc_msat_height_data.extend_from_slice(&byte_utils::be32_to_array(height));

let node_id = match short_to_id.get(&htlc.prev_hop.short_channel_id) {
None => None,
Some(chan_id) => {
match &chan_by_id.get(chan_id) {
None => None,
Some(chan) => Some(chan.get_counterparty_node_id())
}
},
};

timed_out_htlcs.push((HTLCSource::PreviousHopData(htlc.prev_hop.clone()), payment_hash.clone(), HTLCFailReason::Reason {
failure_code: 0x4000 | 15,
data: htlc_msat_height_data
}));
}, node_id));
false
} else { true }
});
Expand Down

0 comments on commit b611687

Please sign in to comment.