@@ -2701,13 +2701,11 @@ impl<Signer: Sign> Channel<Signer> {
2701
2701
/// implicitly dropping) and the payment_hashes of HTLCs we tried to add but are dropping.
2702
2702
/// No further message handling calls may be made until a channel_reestablish dance has
2703
2703
/// completed.
2704
- pub fn remove_uncommitted_htlcs_and_mark_paused < L : Deref > ( & mut self , logger : & L ) -> Vec < ( HTLCSource , PaymentHash ) > where L :: Target : Logger {
2705
- let mut outbound_drops = Vec :: new ( ) ;
2706
-
2704
+ pub fn remove_uncommitted_htlcs_and_mark_paused < L : Deref > ( & mut self , logger : & L ) where L :: Target : Logger {
2707
2705
assert_eq ! ( self . channel_state & ChannelState :: ShutdownComplete as u32 , 0 ) ;
2708
2706
if self . channel_state < ChannelState :: FundingSent as u32 {
2709
2707
self . channel_state = ChannelState :: ShutdownComplete as u32 ;
2710
- return outbound_drops ;
2708
+ return ;
2711
2709
}
2712
2710
// Upon reconnect we have to start the closing_signed dance over, but shutdown messages
2713
2711
// will be retransmitted.
@@ -2750,23 +2748,8 @@ impl<Signer: Sign> Channel<Signer> {
2750
2748
}
2751
2749
}
2752
2750
2753
- self . holding_cell_htlc_updates . retain ( |htlc_update| {
2754
- match htlc_update {
2755
- // Note that currently on channel reestablish we assert that there are
2756
- // no holding cell HTLC update_adds, so if in the future we stop
2757
- // dropping added HTLCs here and failing them backwards, then there will
2758
- // need to be corresponding changes made in the Channel's re-establish
2759
- // logic.
2760
- & HTLCUpdateAwaitingACK :: AddHTLC { ref payment_hash, ref source, .. } => {
2761
- outbound_drops. push ( ( source. clone ( ) , payment_hash. clone ( ) ) ) ;
2762
- false
2763
- } ,
2764
- & HTLCUpdateAwaitingACK :: ClaimHTLC { ..} | & HTLCUpdateAwaitingACK :: FailHTLC { ..} => true ,
2765
- }
2766
- } ) ;
2767
2751
self . channel_state |= ChannelState :: PeerDisconnected as u32 ;
2768
- 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( ) ) ) ;
2769
- outbound_drops
2752
+ log_debug ! ( logger, "Peer disconnection resulted in {} remote-announced HTLC drops on channel {}" , inbound_drop_count, log_bytes!( self . channel_id( ) ) ) ;
2770
2753
}
2771
2754
2772
2755
/// Indicates that a ChannelMonitor update failed to be stored by the client and further
@@ -2925,7 +2908,7 @@ impl<Signer: Sign> Channel<Signer> {
2925
2908
2926
2909
/// May panic if some calls other than message-handling calls (which will all Err immediately)
2927
2910
/// have been called between remove_uncommitted_htlcs_and_mark_paused and this call.
2928
- 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 {
2911
+ 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 {
2929
2912
if self . channel_state & ( ChannelState :: PeerDisconnected as u32 ) == 0 {
2930
2913
// While BOLT 2 doesn't indicate explicitly we should error this channel here, it
2931
2914
// almost certainly indicates we are going to end up out-of-sync in some way, so we
@@ -2976,15 +2959,15 @@ impl<Signer: Sign> Channel<Signer> {
2976
2959
return Err ( ChannelError :: Close ( "Peer claimed they saw a revoke_and_ack but we haven't sent funding_locked yet" . to_owned ( ) ) ) ;
2977
2960
}
2978
2961
// Short circuit the whole handler as there is nothing we can resend them
2979
- return Ok ( ( None , None , None , None , RAACommitmentOrder :: CommitmentFirst , shutdown_msg) ) ;
2962
+ return Ok ( ( None , None , None , None , RAACommitmentOrder :: CommitmentFirst , Vec :: new ( ) , shutdown_msg) ) ;
2980
2963
}
2981
2964
2982
2965
// We have OurFundingLocked set!
2983
2966
let next_per_commitment_point = self . holder_signer . get_per_commitment_point ( self . cur_holder_commitment_transaction_number , & self . secp_ctx ) ;
2984
2967
return Ok ( ( Some ( msgs:: FundingLocked {
2985
2968
channel_id : self . channel_id ( ) ,
2986
2969
next_per_commitment_point,
2987
- } ) , None , None , None , RAACommitmentOrder :: CommitmentFirst , shutdown_msg) ) ;
2970
+ } ) , None , None , None , RAACommitmentOrder :: CommitmentFirst , Vec :: new ( ) , shutdown_msg) ) ;
2988
2971
}
2989
2972
2990
2973
let required_revoke = if msg. next_remote_commitment_number + 1 == INITIAL_COMMITMENT_NUMBER - self . cur_holder_commitment_transaction_number {
@@ -3025,14 +3008,6 @@ impl<Signer: Sign> Channel<Signer> {
3025
3008
}
3026
3009
3027
3010
if ( self . channel_state & ( ChannelState :: AwaitingRemoteRevoke as u32 | ChannelState :: MonitorUpdateFailed as u32 ) ) == 0 {
3028
- // Note that if in the future we no longer drop holding cell update_adds on peer
3029
- // disconnect, this logic will need to be updated.
3030
- for htlc_update in self . holding_cell_htlc_updates . iter ( ) {
3031
- if let & HTLCUpdateAwaitingACK :: AddHTLC { .. } = htlc_update {
3032
- 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." ) ;
3033
- }
3034
- }
3035
-
3036
3011
// We're up-to-date and not waiting on a remote revoke (if we are our
3037
3012
// channel_reestablish should result in them sending a revoke_and_ack), but we may
3038
3013
// have received some updates while we were disconnected. Free the holding cell
@@ -3041,20 +3016,14 @@ impl<Signer: Sign> Channel<Signer> {
3041
3016
Err ( ChannelError :: Close ( msg) ) => return Err ( ChannelError :: Close ( msg) ) ,
3042
3017
Err ( ChannelError :: Ignore ( _) ) | Err ( ChannelError :: CloseDelayBroadcast ( _) ) => panic ! ( "Got non-channel-failing result from free_holding_cell_htlcs" ) ,
3043
3018
Ok ( ( Some ( ( commitment_update, monitor_update) ) , htlcs_to_fail) ) => {
3044
- // If in the future we no longer drop holding cell update_adds on peer
3045
- // disconnect, we may be handed some HTLCs to fail backwards here.
3046
- assert ! ( htlcs_to_fail. is_empty( ) ) ;
3047
- return Ok ( ( resend_funding_locked, required_revoke, Some ( commitment_update) , Some ( monitor_update) , self . resend_order . clone ( ) , shutdown_msg) ) ;
3019
+ return Ok ( ( resend_funding_locked, required_revoke, Some ( commitment_update) , Some ( monitor_update) , self . resend_order . clone ( ) , htlcs_to_fail, shutdown_msg) ) ;
3048
3020
} ,
3049
3021
Ok ( ( None , htlcs_to_fail) ) => {
3050
- // If in the future we no longer drop holding cell update_adds on peer
3051
- // disconnect, we may be handed some HTLCs to fail backwards here.
3052
- assert ! ( htlcs_to_fail. is_empty( ) ) ;
3053
- return Ok ( ( resend_funding_locked, required_revoke, None , None , self . resend_order . clone ( ) , shutdown_msg) ) ;
3022
+ return Ok ( ( resend_funding_locked, required_revoke, None , None , self . resend_order . clone ( ) , htlcs_to_fail, shutdown_msg) ) ;
3054
3023
} ,
3055
3024
}
3056
3025
} else {
3057
- return Ok ( ( resend_funding_locked, required_revoke, None , None , self . resend_order . clone ( ) , shutdown_msg) ) ;
3026
+ return Ok ( ( resend_funding_locked, required_revoke, None , None , self . resend_order . clone ( ) , Vec :: new ( ) , shutdown_msg) ) ;
3058
3027
}
3059
3028
} else if msg. next_local_commitment_number == next_counterparty_commitment_number - 1 {
3060
3029
if required_revoke. is_some ( ) {
@@ -3065,10 +3034,10 @@ impl<Signer: Sign> Channel<Signer> {
3065
3034
3066
3035
if self . channel_state & ( ChannelState :: MonitorUpdateFailed as u32 ) != 0 {
3067
3036
self . monitor_pending_commitment_signed = true ;
3068
- return Ok ( ( resend_funding_locked, None , None , None , self . resend_order . clone ( ) , shutdown_msg) ) ;
3037
+ return Ok ( ( resend_funding_locked, None , None , None , self . resend_order . clone ( ) , Vec :: new ( ) , shutdown_msg) ) ;
3069
3038
}
3070
3039
3071
- return Ok ( ( resend_funding_locked, required_revoke, Some ( self . get_last_commitment_update ( logger) ) , None , self . resend_order . clone ( ) , shutdown_msg) ) ;
3040
+ return Ok ( ( resend_funding_locked, required_revoke, Some ( self . get_last_commitment_update ( logger) ) , None , self . resend_order . clone ( ) , Vec :: new ( ) , shutdown_msg) ) ;
3072
3041
} else {
3073
3042
return Err ( ChannelError :: Close ( "Peer attempted to reestablish channel with a very old remote commitment transaction" . to_owned ( ) ) ) ;
3074
3043
}
@@ -4404,7 +4373,7 @@ impl Readable for ChannelUpdateStatus {
4404
4373
impl < Signer : Sign > Writeable for Channel < Signer > {
4405
4374
fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
4406
4375
// Note that we write out as if remove_uncommitted_htlcs_and_mark_paused had just been
4407
- // called but include holding cell updates (and obviously we don't modify self) .
4376
+ // called.
4408
4377
4409
4378
writer. write_all ( & [ SERIALIZATION_VERSION ; 1 ] ) ?;
4410
4379
writer. write_all ( & [ MIN_SERIALIZATION_VERSION ; 1 ] ) ?;
0 commit comments