Skip to content

Commit

Permalink
f Convert PaymentPreimage to PaymentHasH
Browse files Browse the repository at this point in the history
  • Loading branch information
jbesraa committed May 10, 2024
1 parent 5776c43 commit f2d9eb5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6511,7 +6511,7 @@ where
if let hash_map::Entry::Occupied(mut chan_phase_entry) = peer_state.channel_by_id.entry(chan_id) {
if let ChannelPhase::Funded(chan) = chan_phase_entry.get_mut() {
let counterparty_node_id = chan.context.get_counterparty_node_id();
let logger = WithChannelContext::from(&self.logger, &chan.context, None);
let logger = WithChannelContext::from(&self.logger, &chan.context, Some(PaymentHash(Sha256::hash(&payment_preimage.0).to_byte_array())));
let fulfill_res = chan.get_update_fulfill_htlc_and_commit(prev_hop.htlc_id, payment_preimage, &&logger);

match fulfill_res {
Expand Down Expand Up @@ -6604,7 +6604,8 @@ where
// with a preimage we *must* somehow manage to propagate it to the upstream
// channel, or we must have an ability to receive the same event and try
// again on restart.
log_error!(WithContext::from(&self.logger, None, Some(prev_hop.channel_id), None),
log_error!(WithContext::from(&self.logger, None, Some(prev_hop.channel_id), Some(
PaymentHash(Sha256::hash(&payment_preimage.0).to_byte_array()))),
"Critical error: failed to update channel monitor with preimage {:?}: {:?}",
payment_preimage, update_res);
}
Expand Down Expand Up @@ -7757,7 +7758,7 @@ where
if let ChannelPhase::Funded(chan) = chan_phase_entry.get_mut() {
let res = try_chan_phase_entry!(self, chan.update_fulfill_htlc(&msg), chan_phase_entry);
if let HTLCSource::PreviousHopData(prev_hop) = &res.0 {
let logger = WithChannelContext::from(&self.logger, &chan.context, None);
let logger = WithChannelContext::from(&self.logger, &chan.context, Some(PaymentHash(Sha256::hash(&msg.payment_preimage.0).to_byte_array())));
log_trace!(logger,
"Holding the next revoke_and_ack from {} until the preimage is durably persisted in the inbound edge's ChannelMonitor",
msg.channel_id);
Expand Down

0 comments on commit f2d9eb5

Please sign in to comment.