@@ -4859,12 +4859,8 @@ where
48594859 prng_seed,
48604860 )
48614861 .map_err(|e| {
4862- let logger = WithContext::from(
4863- &self.logger,
4864- Some(path.hops.first().unwrap().pubkey),
4865- None,
4866- Some(*payment_hash),
4867- );
4862+ let first_hop_key = Some(path.hops.first().unwrap().pubkey);
4863+ let logger = WithContext::from(&self.logger, first_hop_key, None, Some(*payment_hash));
48684864 log_error!(
48694865 logger,
48704866 "Failed to build an onion for path for payment hash {}",
@@ -4874,19 +4870,17 @@ where
48744870 })?;
48754871
48764872 let err: Result<(), _> = loop {
4873+ let first_chan_id = &path.hops.first().unwrap().short_channel_id;
48774874 let (counterparty_node_id, id) = match self
48784875 .short_to_chan_info
48794876 .read()
48804877 .unwrap()
4881- .get(&path.hops.first().unwrap().short_channel_id )
4878+ .get(first_chan_id )
48824879 {
48834880 None => {
4884- let logger = WithContext::from(
4885- &self.logger,
4886- Some(path.hops.first().unwrap().pubkey),
4887- None,
4888- Some(*payment_hash),
4889- );
4881+ let first_hop_key = Some(path.hops.first().unwrap().pubkey);
4882+ let logger =
4883+ WithContext::from(&self.logger, first_hop_key, None, Some(*payment_hash));
48904884 log_error!(
48914885 logger,
48924886 "Failed to find first-hop for payment hash {}",
@@ -4909,7 +4903,7 @@ where
49094903 logger,
49104904 "Attempting to send payment with payment hash {} along path with next hop {}",
49114905 payment_hash,
4912- path.hops.first().unwrap().short_channel_id
4906+ first_chan_id,
49134907 );
49144908
49154909 let per_peer_state = self.per_peer_state.read().unwrap();
@@ -4934,43 +4928,42 @@ where
49344928 &chan.context,
49354929 Some(*payment_hash),
49364930 );
4931+ let htlc_source = HTLCSource::OutboundRoute {
4932+ path: path.clone(),
4933+ session_priv: session_priv.clone(),
4934+ first_hop_htlc_msat: htlc_msat,
4935+ payment_id,
4936+ bolt12_invoice: bolt12_invoice.cloned(),
4937+ };
49374938 let send_res = chan.send_htlc_and_commit(
49384939 htlc_msat,
49394940 payment_hash.clone(),
49404941 htlc_cltv,
4941- HTLCSource::OutboundRoute {
4942- path: path.clone(),
4943- session_priv: session_priv.clone(),
4944- first_hop_htlc_msat: htlc_msat,
4945- payment_id,
4946- bolt12_invoice: bolt12_invoice.cloned(),
4947- },
4942+ htlc_source,
49484943 onion_packet,
49494944 None,
49504945 &self.fee_estimator,
49514946 &&logger,
49524947 );
49534948 match break_channel_entry!(self, peer_state, send_res, chan_entry) {
49544949 Some(monitor_update) => {
4955- match handle_new_monitor_update!(
4950+ let ok = handle_new_monitor_update!(
49564951 self,
49574952 funding_txo,
49584953 monitor_update,
49594954 peer_state_lock,
49604955 peer_state,
49614956 per_peer_state,
49624957 chan
4963- ) {
4964- false => {
4965- // Note that MonitorUpdateInProgress here indicates (per function
4966- // docs) that we will resend the commitment update once monitor
4967- // updating completes. Therefore, we must return an error
4968- // indicating that it is unsafe to retry the payment wholesale,
4969- // which we do in the send_payment check for
4970- // MonitorUpdateInProgress, below.
4971- return Err(APIError::MonitorUpdateInProgress);
4972- },
4973- true => {},
4958+ );
4959+ if !ok {
4960+ // Note that MonitorUpdateInProgress here indicates (per function
4961+ // docs) that we will resend the commitment update once monitor
4962+ // updating completes. Therefore, we must return an error
4963+ // indicating that it is unsafe to retry the payment wholesale,
4964+ // which we do in the send_payment check for
4965+ // MonitorUpdateInProgress, below.
4966+ return Err(APIError::MonitorUpdateInProgress);
49744967 }
49754968 },
49764969 None => {},
0 commit comments