@@ -488,13 +488,13 @@ enum UpdateFulfillFetch {
488
488
}
489
489
490
490
/// The return type of get_update_fulfill_htlc_and_commit.
491
- pub enum UpdateFulfillCommitFetch<'a> {
491
+ pub enum UpdateFulfillCommitFetch {
492
492
/// Indicates the HTLC fulfill is new, and either generated an update_fulfill message, placed
493
493
/// it in the holding cell, or re-generated the update_fulfill message after the same claim was
494
494
/// previously placed in the holding cell (and has since been removed).
495
495
NewClaim {
496
496
/// The ChannelMonitorUpdate which places the new payment preimage in the channel monitor
497
- monitor_update: &'a ChannelMonitorUpdate,
497
+ monitor_update: ChannelMonitorUpdate,
498
498
/// The value of the HTLC which was claimed, in msat.
499
499
htlc_value_msat: u64,
500
500
},
@@ -2305,8 +2305,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
2305
2305
};
2306
2306
self.monitor_updating_paused(false, msg.is_some(), false, Vec::new(), Vec::new(), Vec::new());
2307
2307
UpdateFulfillCommitFetch::NewClaim {
2308
- monitor_update: & self.context.pending_monitor_updates.get(unblocked_update_pos)
2309
- .expect("We just pushed the monitor update").update,
2308
+ monitor_update: self.context.pending_monitor_updates.get(unblocked_update_pos)
2309
+ .expect("We just pushed the monitor update").update.clone() ,
2310
2310
htlc_value_msat,
2311
2311
}
2312
2312
},
@@ -2798,7 +2798,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
2798
2798
Ok(())
2799
2799
}
2800
2800
2801
- pub fn commitment_signed<L: Deref>(&mut self, msg: &msgs::CommitmentSigned, logger: &L) -> Result<Option<& ChannelMonitorUpdate>, ChannelError>
2801
+ pub fn commitment_signed<L: Deref>(&mut self, msg: &msgs::CommitmentSigned, logger: &L) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
2802
2802
where L::Target: Logger
2803
2803
{
2804
2804
if (self.context.channel_state & (ChannelState::ChannelReady as u32)) != (ChannelState::ChannelReady as u32) {
@@ -3022,7 +3022,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3022
3022
/// Public version of the below, checking relevant preconditions first.
3023
3023
/// If we're not in a state where freeing the holding cell makes sense, this is a no-op and
3024
3024
/// returns `(None, Vec::new())`.
3025
- pub fn maybe_free_holding_cell_htlcs<L: Deref>(&mut self, logger: &L) -> (Option<& ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>) where L::Target: Logger {
3025
+ pub fn maybe_free_holding_cell_htlcs<L: Deref>(&mut self, logger: &L) -> (Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>) where L::Target: Logger {
3026
3026
if self.context.channel_state >= ChannelState::ChannelReady as u32 &&
3027
3027
(self.context.channel_state & (ChannelState::AwaitingRemoteRevoke as u32 | ChannelState::PeerDisconnected as u32 | ChannelState::MonitorUpdateInProgress as u32)) == 0 {
3028
3028
self.free_holding_cell_htlcs(logger)
@@ -3031,7 +3031,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3031
3031
3032
3032
/// Frees any pending commitment updates in the holding cell, generating the relevant messages
3033
3033
/// for our counterparty.
3034
- fn free_holding_cell_htlcs<L: Deref>(&mut self, logger: &L) -> (Option<& ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>) where L::Target: Logger {
3034
+ fn free_holding_cell_htlcs<L: Deref>(&mut self, logger: &L) -> (Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>) where L::Target: Logger {
3035
3035
assert_eq!(self.context.channel_state & ChannelState::MonitorUpdateInProgress as u32, 0);
3036
3036
if self.context.holding_cell_htlc_updates.len() != 0 || self.context.holding_cell_update_fee.is_some() {
3037
3037
log_trace!(logger, "Freeing holding cell with {} HTLC updates{} in channel {}", self.context.holding_cell_htlc_updates.len(),
@@ -3147,7 +3147,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3147
3147
/// waiting on this revoke_and_ack. The generation of this new commitment_signed may also fail,
3148
3148
/// generating an appropriate error *after* the channel state has been updated based on the
3149
3149
/// revoke_and_ack message.
3150
- pub fn revoke_and_ack<L: Deref>(&mut self, msg: &msgs::RevokeAndACK, logger: &L) -> Result<(Vec<(HTLCSource, PaymentHash)>, Option<& ChannelMonitorUpdate>), ChannelError>
3150
+ pub fn revoke_and_ack<L: Deref>(&mut self, msg: &msgs::RevokeAndACK, logger: &L) -> Result<(Vec<(HTLCSource, PaymentHash)>, Option<ChannelMonitorUpdate>), ChannelError>
3151
3151
where L::Target: Logger,
3152
3152
{
3153
3153
if (self.context.channel_state & (ChannelState::ChannelReady as u32)) != (ChannelState::ChannelReady as u32) {
@@ -4075,7 +4075,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4075
4075
4076
4076
pub fn shutdown<SP: Deref>(
4077
4077
&mut self, signer_provider: &SP, their_features: &InitFeatures, msg: &msgs::Shutdown
4078
- ) -> Result<(Option<msgs::Shutdown>, Option<& ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>), ChannelError>
4078
+ ) -> Result<(Option<msgs::Shutdown>, Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>), ChannelError>
4079
4079
where SP::Target: SignerProvider
4080
4080
{
4081
4081
if self.context.channel_state & (ChannelState::PeerDisconnected as u32) == ChannelState::PeerDisconnected as u32 {
@@ -4141,9 +4141,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4141
4141
}],
4142
4142
};
4143
4143
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
4144
- if self.push_blockable_mon_update(monitor_update) {
4145
- self.context.pending_monitor_updates.last().map(|upd| &upd.update)
4146
- } else { None }
4144
+ self.push_ret_blockable_mon_update(monitor_update)
4147
4145
} else { None };
4148
4146
let shutdown = if send_shutdown {
4149
4147
Some(msgs::Shutdown {
@@ -4440,11 +4438,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4440
4438
4441
4439
/// Returns the next blocked monitor update, if one exists, and a bool which indicates a
4442
4440
/// further blocked monitor update exists after the next.
4443
- pub fn unblock_next_blocked_monitor_update(&mut self) -> Option<(& ChannelMonitorUpdate, bool)> {
4441
+ pub fn unblock_next_blocked_monitor_update(&mut self) -> Option<(ChannelMonitorUpdate, bool)> {
4444
4442
for i in 0..self.context.pending_monitor_updates.len() {
4445
4443
if self.context.pending_monitor_updates[i].blocked {
4446
4444
self.context.pending_monitor_updates[i].blocked = false;
4447
- return Some((& self.context.pending_monitor_updates[i].update,
4445
+ return Some((self.context.pending_monitor_updates[i].update.clone() ,
4448
4446
self.context.pending_monitor_updates.len() > i + 1));
4449
4447
}
4450
4448
}
@@ -4465,9 +4463,9 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4465
4463
/// it should be immediately given to the user for persisting or `None` if it should be held as
4466
4464
/// blocked.
4467
4465
fn push_ret_blockable_mon_update(&mut self, update: ChannelMonitorUpdate)
4468
- -> Option<& ChannelMonitorUpdate> {
4466
+ -> Option<ChannelMonitorUpdate> {
4469
4467
let release_monitor = self.push_blockable_mon_update(update);
4470
- if release_monitor { self.context.pending_monitor_updates.last().map(|upd| & upd.update) } else { None }
4468
+ if release_monitor { self.context.pending_monitor_updates.last().map(|upd| upd.update.clone() ) } else { None }
4471
4469
}
4472
4470
4473
4471
pub fn no_monitor_updates_pending(&self) -> bool {
@@ -5302,7 +5300,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5302
5300
pub fn send_htlc_and_commit<L: Deref>(
5303
5301
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
5304
5302
onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>, logger: &L
5305
- ) -> Result<Option<& ChannelMonitorUpdate>, ChannelError> where L::Target: Logger {
5303
+ ) -> Result<Option<ChannelMonitorUpdate>, ChannelError> where L::Target: Logger {
5306
5304
let send_res = self.send_htlc(amount_msat, payment_hash, cltv_expiry, source,
5307
5305
onion_routing_packet, false, skimmed_fee_msat, logger);
5308
5306
if let Err(e) = &send_res { if let ChannelError::Ignore(_) = e {} else { debug_assert!(false, "Sending cannot trigger channel failure"); } }
@@ -5336,7 +5334,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5336
5334
/// [`ChannelMonitorUpdate`] will be returned).
5337
5335
pub fn get_shutdown<SP: Deref>(&mut self, signer_provider: &SP, their_features: &InitFeatures,
5338
5336
target_feerate_sats_per_kw: Option<u32>, override_shutdown_script: Option<ShutdownScript>)
5339
- -> Result<(msgs::Shutdown, Option<& ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>), APIError>
5337
+ -> Result<(msgs::Shutdown, Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>), APIError>
5340
5338
where SP::Target: SignerProvider {
5341
5339
for htlc in self.context.pending_outbound_htlcs.iter() {
5342
5340
if let OutboundHTLCState::LocalAnnounced(_) = htlc.state {
@@ -5407,9 +5405,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5407
5405
}],
5408
5406
};
5409
5407
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
5410
- if self.push_blockable_mon_update(monitor_update) {
5411
- self.context.pending_monitor_updates.last().map(|upd| &upd.update)
5412
- } else { None }
5408
+ self.push_ret_blockable_mon_update(monitor_update)
5413
5409
} else { None };
5414
5410
let shutdown = msgs::Shutdown {
5415
5411
channel_id: self.context.channel_id,
0 commit comments