@@ -7238,12 +7238,12 @@ where
7238
7238
fee_estimator,
7239
7239
logger,
7240
7240
) {
7241
- Ok(update_add_msg_opt ) => {
7242
- // `send_htlc` only returns `Ok(None )`, when an update goes into
7241
+ Ok(can_add_htlc ) => {
7242
+ // `send_htlc` only returns `Ok(false )`, when an update goes into
7243
7243
// the holding cell, but since we're currently freeing it, we should
7244
- // always expect to see the `update_add` go out .
7244
+ // always expect to see the htlc added .
7245
7245
debug_assert!(
7246
- update_add_msg_opt.is_some() ,
7246
+ can_add_htlc ,
7247
7247
"Must generate new update if we're freeing the holding cell"
7248
7248
);
7249
7249
update_add_count += 1;
@@ -10601,7 +10601,7 @@ where
10601
10601
fee_estimator,
10602
10602
logger,
10603
10603
)
10604
- .map(|msg_opt | assert!(msg_opt.is_none() , "We forced holding cell?"))
10604
+ .map(|can_add_htlc | assert!(!can_add_htlc , "We forced holding cell?"))
10605
10605
.map_err(|err| {
10606
10606
debug_assert!(err.0.is_temporary(), "Queuing HTLC should return temporary error");
10607
10607
err
@@ -10611,8 +10611,9 @@ where
10611
10611
/// Adds a pending outbound HTLC to this channel, note that you probably want
10612
10612
/// [`Self::send_htlc_and_commit`] instead cause you'll want both messages at once.
10613
10613
///
10614
- /// This returns an optional UpdateAddHTLC as we may be in a state where we cannot add HTLCs on
10615
- /// the wire:
10614
+ /// This returns a boolean indicating whether we are in a state where we can add HTLCs on the wire.
10615
+ /// Reasons we may not be able to add HTLCs on the wire include:
10616
+ ///
10616
10617
/// * In cases where we're waiting on the remote peer to send us a revoke_and_ack, we
10617
10618
/// wouldn't be able to determine what they actually ACK'ed if we have two sets of updates
10618
10619
/// awaiting ACK.
@@ -10629,7 +10630,7 @@ where
10629
10630
source: HTLCSource, onion_routing_packet: msgs::OnionPacket, mut force_holding_cell: bool,
10630
10631
skimmed_fee_msat: Option<u64>, blinding_point: Option<PublicKey>,
10631
10632
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
10632
- ) -> Result<Option<msgs::UpdateAddHTLC> , (LocalHTLCFailureReason, String)>
10633
+ ) -> Result<bool , (LocalHTLCFailureReason, String)>
10633
10634
where
10634
10635
F::Target: FeeEstimator,
10635
10636
L::Target: Logger,
@@ -10710,7 +10711,7 @@ where
10710
10711
skimmed_fee_msat,
10711
10712
blinding_point,
10712
10713
});
10713
- return Ok(None );
10714
+ return Ok(false );
10714
10715
}
10715
10716
10716
10717
// Record the approximate time when the HTLC is sent to the peer. This timestamp is later used to calculate the
@@ -10731,20 +10732,9 @@ where
10731
10732
skimmed_fee_msat,
10732
10733
send_timestamp,
10733
10734
});
10734
-
10735
- let res = msgs::UpdateAddHTLC {
10736
- channel_id: self.context.channel_id,
10737
- htlc_id: self.context.next_holder_htlc_id,
10738
- amount_msat,
10739
- payment_hash,
10740
- cltv_expiry,
10741
- onion_routing_packet,
10742
- skimmed_fee_msat,
10743
- blinding_point,
10744
- };
10745
10735
self.context.next_holder_htlc_id += 1;
10746
10736
10747
- Ok(Some(res) )
10737
+ Ok(true )
10748
10738
}
10749
10739
10750
10740
#[rustfmt::skip]
@@ -11003,20 +10993,13 @@ where
11003
10993
logger,
11004
10994
);
11005
10995
// All [`LocalHTLCFailureReason`] errors are temporary, so they are [`ChannelError::Ignore`].
11006
- match send_res.map_err(|(_, msg)| ChannelError::Ignore(msg))? {
11007
- Some(_) => {
11008
- let monitor_update = self.build_commitment_no_status_check(logger);
11009
- self.monitor_updating_paused(
11010
- false,
11011
- true,
11012
- false,
11013
- Vec::new(),
11014
- Vec::new(),
11015
- Vec::new(),
11016
- );
11017
- Ok(self.push_ret_blockable_mon_update(monitor_update))
11018
- },
11019
- None => Ok(None),
10996
+ let can_add_htlc = send_res.map_err(|(_, msg)| ChannelError::Ignore(msg))?;
10997
+ if can_add_htlc {
10998
+ let monitor_update = self.build_commitment_no_status_check(logger);
10999
+ self.monitor_updating_paused(false, true, false, Vec::new(), Vec::new(), Vec::new());
11000
+ Ok(self.push_ret_blockable_mon_update(monitor_update))
11001
+ } else {
11002
+ Ok(None)
11020
11003
}
11021
11004
}
11022
11005
0 commit comments