@@ -2517,13 +2517,11 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
2517
2517
/// implicitly dropping) and the payment_hashes of HTLCs we tried to add but are dropping.
2518
2518
/// No further message handling calls may be made until a channel_reestablish dance has
2519
2519
/// completed.
2520
- pub fn remove_uncommitted_htlcs_and_mark_paused < L : Deref > ( & mut self , logger : & L ) -> Vec < ( HTLCSource , PaymentHash ) > where L :: Target : Logger {
2521
- let mut outbound_drops = Vec :: new ( ) ;
2522
-
2520
+ pub fn remove_uncommitted_htlcs_and_mark_paused < L : Deref > ( & mut self , logger : & L ) where L :: Target : Logger {
2523
2521
assert_eq ! ( self . channel_state & ChannelState :: ShutdownComplete as u32 , 0 ) ;
2524
2522
if self . channel_state < ChannelState :: FundingSent as u32 {
2525
2523
self . channel_state = ChannelState :: ShutdownComplete as u32 ;
2526
- return outbound_drops ;
2524
+ return ;
2527
2525
}
2528
2526
// Upon reconnect we have to start the closing_signed dance over, but shutdown messages
2529
2527
// will be retransmitted.
@@ -2566,23 +2564,8 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
2566
2564
}
2567
2565
}
2568
2566
2569
- self . holding_cell_htlc_updates . retain ( |htlc_update| {
2570
- match htlc_update {
2571
- // Note that currently on channel reestablish we assert that there are
2572
- // no holding cell HTLC update_adds, so if in the future we stop
2573
- // dropping added HTLCs here and failing them backwards, then there will
2574
- // need to be corresponding changes made in the Channel's re-establish
2575
- // logic.
2576
- & HTLCUpdateAwaitingACK :: AddHTLC { ref payment_hash, ref source, .. } => {
2577
- outbound_drops. push ( ( source. clone ( ) , payment_hash. clone ( ) ) ) ;
2578
- false
2579
- } ,
2580
- & HTLCUpdateAwaitingACK :: ClaimHTLC { ..} | & HTLCUpdateAwaitingACK :: FailHTLC { ..} => true ,
2581
- }
2582
- } ) ;
2583
2567
self . channel_state |= ChannelState :: PeerDisconnected as u32 ;
2584
- log_debug ! ( logger, "Peer disconnection resulted in {} remote-announced HTLC drops and {} waiting-to-locally-announced HTLC drops on channel {}" , outbound_drops. len( ) , inbound_drop_count, log_bytes!( self . channel_id( ) ) ) ;
2585
- outbound_drops
2568
+ log_debug ! ( logger, "Peer disconnection resulted in {} waiting-to-locally-announced HTLC drops on channel {}" , inbound_drop_count, log_bytes!( self . channel_id( ) ) ) ;
2586
2569
}
2587
2570
2588
2571
/// Indicates that a ChannelMonitor update failed to be stored by the client and further
@@ -2757,7 +2740,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
2757
2740
2758
2741
/// May panic if some calls other than message-handling calls (which will all Err immediately)
2759
2742
/// have been called between remove_uncommitted_htlcs_and_mark_paused and this call.
2760
- pub fn channel_reestablish < L : Deref > ( & mut self , msg : & msgs:: ChannelReestablish , logger : & L ) -> Result < ( Option < msgs:: FundingLocked > , Option < msgs:: RevokeAndACK > , Option < msgs:: CommitmentUpdate > , Option < ChannelMonitorUpdate > , RAACommitmentOrder , Option < msgs:: Shutdown > ) , ChannelError > where L :: Target : Logger {
2743
+ pub fn channel_reestablish < L : Deref > ( & mut self , msg : & msgs:: ChannelReestablish , logger : & L ) -> Result < ( Option < msgs:: FundingLocked > , Option < msgs:: RevokeAndACK > , Option < msgs:: CommitmentUpdate > , Option < ChannelMonitorUpdate > , RAACommitmentOrder , Vec < ( HTLCSource , PaymentHash ) > , Option < msgs:: Shutdown > ) , ChannelError > where L :: Target : Logger {
2761
2744
if self . channel_state & ( ChannelState :: PeerDisconnected as u32 ) == 0 {
2762
2745
// While BOLT 2 doesn't indicate explicitly we should error this channel here, it
2763
2746
// almost certainly indicates we are going to end up out-of-sync in some way, so we
@@ -2808,15 +2791,15 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
2808
2791
return Err ( ChannelError :: Close ( "Peer claimed they saw a revoke_and_ack but we haven't sent funding_locked yet" . to_owned ( ) ) ) ;
2809
2792
}
2810
2793
// Short circuit the whole handler as there is nothing we can resend them
2811
- return Ok ( ( None , None , None , None , RAACommitmentOrder :: CommitmentFirst , shutdown_msg) ) ;
2794
+ return Ok ( ( None , None , None , None , RAACommitmentOrder :: CommitmentFirst , Vec :: new ( ) , shutdown_msg) ) ;
2812
2795
}
2813
2796
2814
2797
// We have OurFundingLocked set!
2815
2798
let next_per_commitment_point = self . holder_keys . get_per_commitment_point ( self . cur_holder_commitment_transaction_number , & self . secp_ctx ) ;
2816
2799
return Ok ( ( Some ( msgs:: FundingLocked {
2817
2800
channel_id : self . channel_id ( ) ,
2818
2801
next_per_commitment_point,
2819
- } ) , None , None , None , RAACommitmentOrder :: CommitmentFirst , shutdown_msg) ) ;
2802
+ } ) , None , None , None , RAACommitmentOrder :: CommitmentFirst , Vec :: new ( ) , shutdown_msg) ) ;
2820
2803
}
2821
2804
2822
2805
let required_revoke = if msg. next_remote_commitment_number + 1 == INITIAL_COMMITMENT_NUMBER - self . cur_holder_commitment_transaction_number {
@@ -2857,14 +2840,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
2857
2840
}
2858
2841
2859
2842
if ( self . channel_state & ( ChannelState :: AwaitingRemoteRevoke as u32 | ChannelState :: MonitorUpdateFailed as u32 ) ) == 0 {
2860
- // Note that if in the future we no longer drop holding cell update_adds on peer
2861
- // disconnect, this logic will need to be updated.
2862
- for htlc_update in self . holding_cell_htlc_updates . iter ( ) {
2863
- if let & HTLCUpdateAwaitingACK :: AddHTLC { .. } = htlc_update {
2864
- debug_assert ! ( false , "There shouldn't be any add-HTLCs in the holding cell now because they should have been dropped on peer disconnect. Panic here because said HTLCs won't be handled correctly." ) ;
2865
- }
2866
- }
2867
-
2868
2843
// We're up-to-date and not waiting on a remote revoke (if we are our
2869
2844
// channel_reestablish should result in them sending a revoke_and_ack), but we may
2870
2845
// have received some updates while we were disconnected. Free the holding cell
@@ -2873,20 +2848,14 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
2873
2848
Err ( ChannelError :: Close ( msg) ) => return Err ( ChannelError :: Close ( msg) ) ,
2874
2849
Err ( ChannelError :: Ignore ( _) ) | Err ( ChannelError :: CloseDelayBroadcast ( _) ) => panic ! ( "Got non-channel-failing result from free_holding_cell_htlcs" ) ,
2875
2850
Ok ( ( Some ( ( commitment_update, monitor_update) ) , htlcs_to_fail) ) => {
2876
- // If in the future we no longer drop holding cell update_adds on peer
2877
- // disconnect, we may be handed some HTLCs to fail backwards here.
2878
- assert ! ( htlcs_to_fail. is_empty( ) ) ;
2879
- return Ok ( ( resend_funding_locked, required_revoke, Some ( commitment_update) , Some ( monitor_update) , self . resend_order . clone ( ) , shutdown_msg) ) ;
2851
+ return Ok ( ( resend_funding_locked, required_revoke, Some ( commitment_update) , Some ( monitor_update) , self . resend_order . clone ( ) , htlcs_to_fail, shutdown_msg) ) ;
2880
2852
} ,
2881
2853
Ok ( ( None , htlcs_to_fail) ) => {
2882
- // If in the future we no longer drop holding cell update_adds on peer
2883
- // disconnect, we may be handed some HTLCs to fail backwards here.
2884
- assert ! ( htlcs_to_fail. is_empty( ) ) ;
2885
- return Ok ( ( resend_funding_locked, required_revoke, None , None , self . resend_order . clone ( ) , shutdown_msg) ) ;
2854
+ return Ok ( ( resend_funding_locked, required_revoke, None , None , self . resend_order . clone ( ) , htlcs_to_fail, shutdown_msg) ) ;
2886
2855
} ,
2887
2856
}
2888
2857
} else {
2889
- return Ok ( ( resend_funding_locked, required_revoke, None , None , self . resend_order . clone ( ) , shutdown_msg) ) ;
2858
+ return Ok ( ( resend_funding_locked, required_revoke, None , None , self . resend_order . clone ( ) , Vec :: new ( ) , shutdown_msg) ) ;
2890
2859
}
2891
2860
} else if msg. next_local_commitment_number == next_counterparty_commitment_number - 1 {
2892
2861
if required_revoke. is_some ( ) {
@@ -2897,10 +2866,10 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
2897
2866
2898
2867
if self . channel_state & ( ChannelState :: MonitorUpdateFailed as u32 ) != 0 {
2899
2868
self . monitor_pending_commitment_signed = true ;
2900
- return Ok ( ( resend_funding_locked, None , None , None , self . resend_order . clone ( ) , shutdown_msg) ) ;
2869
+ return Ok ( ( resend_funding_locked, None , None , None , self . resend_order . clone ( ) , Vec :: new ( ) , shutdown_msg) ) ;
2901
2870
}
2902
2871
2903
- return Ok ( ( resend_funding_locked, required_revoke, Some ( self . get_last_commitment_update ( logger) ) , None , self . resend_order . clone ( ) , shutdown_msg) ) ;
2872
+ return Ok ( ( resend_funding_locked, required_revoke, Some ( self . get_last_commitment_update ( logger) ) , None , self . resend_order . clone ( ) , Vec :: new ( ) , shutdown_msg) ) ;
2904
2873
} else {
2905
2874
return Err ( ChannelError :: Close ( "Peer attempted to reestablish channel with a very old remote commitment transaction" . to_owned ( ) ) ) ;
2906
2875
}
@@ -4094,7 +4063,7 @@ impl Readable for InboundHTLCRemovalReason {
4094
4063
impl < ChanSigner : ChannelKeys + Writeable > Writeable for Channel < ChanSigner > {
4095
4064
fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
4096
4065
// Note that we write out as if remove_uncommitted_htlcs_and_mark_paused had just been
4097
- // called but include holding cell updates (and obviously we don't modify self) .
4066
+ // called.
4098
4067
4099
4068
writer. write_all ( & [ SERIALIZATION_VERSION ; 1 ] ) ?;
4100
4069
writer. write_all ( & [ MIN_SERIALIZATION_VERSION ; 1 ] ) ?;
0 commit comments