@@ -4859,12 +4859,8 @@ where
4859
4859
prng_seed,
4860
4860
)
4861
4861
.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));
4868
4864
log_error!(
4869
4865
logger,
4870
4866
"Failed to build an onion for path for payment hash {}",
@@ -4874,19 +4870,17 @@ where
4874
4870
})?;
4875
4871
4876
4872
let err: Result<(), _> = loop {
4873
+ let first_chan_id = &path.hops.first().unwrap().short_channel_id;
4877
4874
let (counterparty_node_id, id) = match self
4878
4875
.short_to_chan_info
4879
4876
.read()
4880
4877
.unwrap()
4881
- .get(&path.hops.first().unwrap().short_channel_id )
4878
+ .get(first_chan_id )
4882
4879
{
4883
4880
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));
4890
4884
log_error!(
4891
4885
logger,
4892
4886
"Failed to find first-hop for payment hash {}",
@@ -4909,7 +4903,7 @@ where
4909
4903
logger,
4910
4904
"Attempting to send payment with payment hash {} along path with next hop {}",
4911
4905
payment_hash,
4912
- path.hops.first().unwrap().short_channel_id
4906
+ first_chan_id,
4913
4907
);
4914
4908
4915
4909
let per_peer_state = self.per_peer_state.read().unwrap();
@@ -4934,43 +4928,42 @@ where
4934
4928
&chan.context,
4935
4929
Some(*payment_hash),
4936
4930
);
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
+ };
4937
4938
let send_res = chan.send_htlc_and_commit(
4938
4939
htlc_msat,
4939
4940
payment_hash.clone(),
4940
4941
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,
4948
4943
onion_packet,
4949
4944
None,
4950
4945
&self.fee_estimator,
4951
4946
&&logger,
4952
4947
);
4953
4948
match break_channel_entry!(self, peer_state, send_res, chan_entry) {
4954
4949
Some(monitor_update) => {
4955
- match handle_new_monitor_update!(
4950
+ let ok = handle_new_monitor_update!(
4956
4951
self,
4957
4952
funding_txo,
4958
4953
monitor_update,
4959
4954
peer_state_lock,
4960
4955
peer_state,
4961
4956
per_peer_state,
4962
4957
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);
4974
4967
}
4975
4968
},
4976
4969
None => {},
0 commit comments