@@ -485,13 +485,13 @@ enum UpdateFulfillFetch {
485
485
}
486
486
487
487
/// The return type of get_update_fulfill_htlc_and_commit.
488
- pub enum UpdateFulfillCommitFetch < ' a > {
488
+ pub enum UpdateFulfillCommitFetch {
489
489
/// Indicates the HTLC fulfill is new, and either generated an update_fulfill message, placed
490
490
/// it in the holding cell, or re-generated the update_fulfill message after the same claim was
491
491
/// previously placed in the holding cell (and has since been removed).
492
492
NewClaim {
493
493
/// The ChannelMonitorUpdate which places the new payment preimage in the channel monitor
494
- monitor_update : & ' a ChannelMonitorUpdate ,
494
+ monitor_update : ChannelMonitorUpdate ,
495
495
/// The value of the HTLC which was claimed, in msat.
496
496
htlc_value_msat : u64 ,
497
497
} ,
@@ -2302,8 +2302,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
2302
2302
} ;
2303
2303
self . monitor_updating_paused ( false , msg. is_some ( ) , false , Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ;
2304
2304
UpdateFulfillCommitFetch :: NewClaim {
2305
- monitor_update : & self . context . pending_monitor_updates . get ( unblocked_update_pos)
2306
- . expect ( "We just pushed the monitor update" ) . update ,
2305
+ monitor_update : self . context . pending_monitor_updates . get ( unblocked_update_pos)
2306
+ . expect ( "We just pushed the monitor update" ) . update . clone ( ) ,
2307
2307
htlc_value_msat,
2308
2308
}
2309
2309
} ,
@@ -2795,7 +2795,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
2795
2795
Ok ( ( ) )
2796
2796
}
2797
2797
2798
- pub fn commitment_signed < L : Deref > ( & mut self , msg : & msgs:: CommitmentSigned , logger : & L ) -> Result < Option < & ChannelMonitorUpdate > , ChannelError >
2798
+ pub fn commitment_signed < L : Deref > ( & mut self , msg : & msgs:: CommitmentSigned , logger : & L ) -> Result < Option < ChannelMonitorUpdate > , ChannelError >
2799
2799
where L :: Target : Logger
2800
2800
{
2801
2801
if ( self . context . channel_state & ( ChannelState :: ChannelReady as u32 ) ) != ( ChannelState :: ChannelReady as u32 ) {
@@ -3019,7 +3019,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3019
3019
/// Public version of the below, checking relevant preconditions first.
3020
3020
/// If we're not in a state where freeing the holding cell makes sense, this is a no-op and
3021
3021
/// returns `(None, Vec::new())`.
3022
- pub fn maybe_free_holding_cell_htlcs < L : Deref > ( & mut self , logger : & L ) -> ( Option < & ChannelMonitorUpdate > , Vec < ( HTLCSource , PaymentHash ) > ) where L :: Target : Logger {
3022
+ pub fn maybe_free_holding_cell_htlcs < L : Deref > ( & mut self , logger : & L ) -> ( Option < ChannelMonitorUpdate > , Vec < ( HTLCSource , PaymentHash ) > ) where L :: Target : Logger {
3023
3023
if self . context . channel_state >= ChannelState :: ChannelReady as u32 &&
3024
3024
( self . context . channel_state & ( ChannelState :: AwaitingRemoteRevoke as u32 | ChannelState :: PeerDisconnected as u32 | ChannelState :: MonitorUpdateInProgress as u32 ) ) == 0 {
3025
3025
self . free_holding_cell_htlcs ( logger)
@@ -3028,7 +3028,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3028
3028
3029
3029
/// Frees any pending commitment updates in the holding cell, generating the relevant messages
3030
3030
/// for our counterparty.
3031
- fn free_holding_cell_htlcs < L : Deref > ( & mut self , logger : & L ) -> ( Option < & ChannelMonitorUpdate > , Vec < ( HTLCSource , PaymentHash ) > ) where L :: Target : Logger {
3031
+ fn free_holding_cell_htlcs < L : Deref > ( & mut self , logger : & L ) -> ( Option < ChannelMonitorUpdate > , Vec < ( HTLCSource , PaymentHash ) > ) where L :: Target : Logger {
3032
3032
assert_eq ! ( self . context. channel_state & ChannelState :: MonitorUpdateInProgress as u32 , 0 ) ;
3033
3033
if self . context . holding_cell_htlc_updates . len ( ) != 0 || self . context . holding_cell_update_fee . is_some ( ) {
3034
3034
log_trace ! ( logger, "Freeing holding cell with {} HTLC updates{} in channel {}" , self . context. holding_cell_htlc_updates. len( ) ,
@@ -3139,7 +3139,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3139
3139
/// waiting on this revoke_and_ack. The generation of this new commitment_signed may also fail,
3140
3140
/// generating an appropriate error *after* the channel state has been updated based on the
3141
3141
/// revoke_and_ack message.
3142
- pub fn revoke_and_ack < L : Deref > ( & mut self , msg : & msgs:: RevokeAndACK , logger : & L ) -> Result < ( Vec < ( HTLCSource , PaymentHash ) > , Option < & ChannelMonitorUpdate > ) , ChannelError >
3142
+ pub fn revoke_and_ack < L : Deref > ( & mut self , msg : & msgs:: RevokeAndACK , logger : & L ) -> Result < ( Vec < ( HTLCSource , PaymentHash ) > , Option < ChannelMonitorUpdate > ) , ChannelError >
3143
3143
where L :: Target : Logger ,
3144
3144
{
3145
3145
if ( self . context . channel_state & ( ChannelState :: ChannelReady as u32 ) ) != ( ChannelState :: ChannelReady as u32 ) {
@@ -4066,7 +4066,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4066
4066
4067
4067
pub fn shutdown < SP : Deref > (
4068
4068
& mut self , signer_provider : & SP , their_features : & InitFeatures , msg : & msgs:: Shutdown
4069
- ) -> Result < ( Option < msgs:: Shutdown > , Option < & ChannelMonitorUpdate > , Vec < ( HTLCSource , PaymentHash ) > ) , ChannelError >
4069
+ ) -> Result < ( Option < msgs:: Shutdown > , Option < ChannelMonitorUpdate > , Vec < ( HTLCSource , PaymentHash ) > ) , ChannelError >
4070
4070
where SP :: Target : SignerProvider
4071
4071
{
4072
4072
if self . context . channel_state & ( ChannelState :: PeerDisconnected as u32 ) == ChannelState :: PeerDisconnected as u32 {
@@ -4132,9 +4132,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4132
4132
} ] ,
4133
4133
} ;
4134
4134
self . monitor_updating_paused ( false , false , false , Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ;
4135
- if self . push_blockable_mon_update ( monitor_update) {
4136
- self . context . pending_monitor_updates . last ( ) . map ( |upd| & upd. update )
4137
- } else { None }
4135
+ self . push_ret_blockable_mon_update ( monitor_update)
4138
4136
} else { None } ;
4139
4137
let shutdown = if send_shutdown {
4140
4138
Some ( msgs:: Shutdown {
@@ -4431,11 +4429,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4431
4429
4432
4430
/// Returns the next blocked monitor update, if one exists, and a bool which indicates a
4433
4431
/// further blocked monitor update exists after the next.
4434
- pub fn unblock_next_blocked_monitor_update ( & mut self ) -> Option < ( & ChannelMonitorUpdate , bool ) > {
4432
+ pub fn unblock_next_blocked_monitor_update ( & mut self ) -> Option < ( ChannelMonitorUpdate , bool ) > {
4435
4433
for i in 0 ..self . context . pending_monitor_updates . len ( ) {
4436
4434
if self . context . pending_monitor_updates [ i] . blocked {
4437
4435
self . context . pending_monitor_updates [ i] . blocked = false ;
4438
- return Some ( ( & self . context . pending_monitor_updates [ i] . update ,
4436
+ return Some ( ( self . context . pending_monitor_updates [ i] . update . clone ( ) ,
4439
4437
self . context . pending_monitor_updates . len ( ) > i + 1 ) ) ;
4440
4438
}
4441
4439
}
@@ -4456,9 +4454,9 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4456
4454
/// it should be immediately given to the user for persisting or `None` if it should be held as
4457
4455
/// blocked.
4458
4456
fn push_ret_blockable_mon_update ( & mut self , update : ChannelMonitorUpdate )
4459
- -> Option < & ChannelMonitorUpdate > {
4457
+ -> Option < ChannelMonitorUpdate > {
4460
4458
let release_monitor = self . push_blockable_mon_update ( update) ;
4461
- if release_monitor { self . context . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None }
4459
+ if release_monitor { self . context . pending_monitor_updates . last ( ) . map ( |upd| upd. update . clone ( ) ) } else { None }
4462
4460
}
4463
4461
4464
4462
pub fn no_monitor_updates_pending ( & self ) -> bool {
@@ -5283,7 +5281,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5283
5281
///
5284
5282
/// Shorthand for calling [`Self::send_htlc`] followed by a commitment update, see docs on
5285
5283
/// [`Self::send_htlc`] and [`Self::build_commitment_no_state_update`] for more info.
5286
- pub fn send_htlc_and_commit < L : Deref > ( & mut self , amount_msat : u64 , payment_hash : PaymentHash , cltv_expiry : u32 , source : HTLCSource , onion_routing_packet : msgs:: OnionPacket , logger : & L ) -> Result < Option < & ChannelMonitorUpdate > , ChannelError > where L :: Target : Logger {
5284
+ pub fn send_htlc_and_commit < L : Deref > ( & mut self , amount_msat : u64 , payment_hash : PaymentHash , cltv_expiry : u32 , source : HTLCSource , onion_routing_packet : msgs:: OnionPacket , logger : & L ) -> Result < Option < ChannelMonitorUpdate > , ChannelError > where L :: Target : Logger {
5287
5285
let send_res = self . send_htlc ( amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, false , logger) ;
5288
5286
if let Err ( e) = & send_res { if let ChannelError :: Ignore ( _) = e { } else { debug_assert ! ( false , "Sending cannot trigger channel failure" ) ; } }
5289
5287
match send_res? {
@@ -5316,7 +5314,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5316
5314
/// [`ChannelMonitorUpdate`] will be returned).
5317
5315
pub fn get_shutdown < SP : Deref > ( & mut self , signer_provider : & SP , their_features : & InitFeatures ,
5318
5316
target_feerate_sats_per_kw : Option < u32 > , override_shutdown_script : Option < ShutdownScript > )
5319
- -> Result < ( msgs:: Shutdown , Option < & ChannelMonitorUpdate > , Vec < ( HTLCSource , PaymentHash ) > ) , APIError >
5317
+ -> Result < ( msgs:: Shutdown , Option < ChannelMonitorUpdate > , Vec < ( HTLCSource , PaymentHash ) > ) , APIError >
5320
5318
where SP :: Target : SignerProvider {
5321
5319
for htlc in self . context . pending_outbound_htlcs . iter ( ) {
5322
5320
if let OutboundHTLCState :: LocalAnnounced ( _) = htlc. state {
@@ -5387,9 +5385,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5387
5385
} ] ,
5388
5386
} ;
5389
5387
self . monitor_updating_paused ( false , false , false , Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ;
5390
- if self . push_blockable_mon_update ( monitor_update) {
5391
- self . context . pending_monitor_updates . last ( ) . map ( |upd| & upd. update )
5392
- } else { None }
5388
+ self . push_ret_blockable_mon_update ( monitor_update)
5393
5389
} else { None } ;
5394
5390
let shutdown = msgs:: Shutdown {
5395
5391
channel_id : self . context . channel_id ,
0 commit comments