@@ -2685,13 +2685,11 @@ impl<Signer: Sign> Channel<Signer> {
2685
2685
/// implicitly dropping) and the payment_hashes of HTLCs we tried to add but are dropping.
2686
2686
/// No further message handling calls may be made until a channel_reestablish dance has
2687
2687
/// completed.
2688
- pub fn remove_uncommitted_htlcs_and_mark_paused < L : Deref > ( & mut self , logger : & L ) -> Vec < ( HTLCSource , PaymentHash ) > where L :: Target : Logger {
2689
- let mut outbound_drops = Vec :: new ( ) ;
2690
-
2688
+ pub fn remove_uncommitted_htlcs_and_mark_paused < L : Deref > ( & mut self , logger : & L ) where L :: Target : Logger {
2691
2689
assert_eq ! ( self . channel_state & ChannelState :: ShutdownComplete as u32 , 0 ) ;
2692
2690
if self . channel_state < ChannelState :: FundingSent as u32 {
2693
2691
self . channel_state = ChannelState :: ShutdownComplete as u32 ;
2694
- return outbound_drops ;
2692
+ return ;
2695
2693
}
2696
2694
// Upon reconnect we have to start the closing_signed dance over, but shutdown messages
2697
2695
// will be retransmitted.
@@ -2734,23 +2732,8 @@ impl<Signer: Sign> Channel<Signer> {
2734
2732
}
2735
2733
}
2736
2734
2737
- self . holding_cell_htlc_updates . retain ( |htlc_update| {
2738
- match htlc_update {
2739
- // Note that currently on channel reestablish we assert that there are
2740
- // no holding cell HTLC update_adds, so if in the future we stop
2741
- // dropping added HTLCs here and failing them backwards, then there will
2742
- // need to be corresponding changes made in the Channel's re-establish
2743
- // logic.
2744
- & HTLCUpdateAwaitingACK :: AddHTLC { ref payment_hash, ref source, .. } => {
2745
- outbound_drops. push ( ( source. clone ( ) , payment_hash. clone ( ) ) ) ;
2746
- false
2747
- } ,
2748
- & HTLCUpdateAwaitingACK :: ClaimHTLC { ..} | & HTLCUpdateAwaitingACK :: FailHTLC { ..} => true ,
2749
- }
2750
- } ) ;
2751
2735
self . channel_state |= ChannelState :: PeerDisconnected as u32 ;
2752
- 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( ) ) ) ;
2753
- outbound_drops
2736
+ log_debug ! ( logger, "Peer disconnection resulted in {} remote-announced HTLC drops on channel {}" , inbound_drop_count, log_bytes!( self . channel_id( ) ) ) ;
2754
2737
}
2755
2738
2756
2739
/// Indicates that a ChannelMonitor update failed to be stored by the client and further
@@ -2909,7 +2892,7 @@ impl<Signer: Sign> Channel<Signer> {
2909
2892
2910
2893
/// May panic if some calls other than message-handling calls (which will all Err immediately)
2911
2894
/// have been called between remove_uncommitted_htlcs_and_mark_paused and this call.
2912
- 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 {
2895
+ 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 {
2913
2896
if self . channel_state & ( ChannelState :: PeerDisconnected as u32 ) == 0 {
2914
2897
// While BOLT 2 doesn't indicate explicitly we should error this channel here, it
2915
2898
// almost certainly indicates we are going to end up out-of-sync in some way, so we
@@ -2960,15 +2943,15 @@ impl<Signer: Sign> Channel<Signer> {
2960
2943
return Err ( ChannelError :: Close ( "Peer claimed they saw a revoke_and_ack but we haven't sent funding_locked yet" . to_owned ( ) ) ) ;
2961
2944
}
2962
2945
// Short circuit the whole handler as there is nothing we can resend them
2963
- return Ok ( ( None , None , None , None , RAACommitmentOrder :: CommitmentFirst , shutdown_msg) ) ;
2946
+ return Ok ( ( None , None , None , None , RAACommitmentOrder :: CommitmentFirst , Vec :: new ( ) , shutdown_msg) ) ;
2964
2947
}
2965
2948
2966
2949
// We have OurFundingLocked set!
2967
2950
let next_per_commitment_point = self . holder_signer . get_per_commitment_point ( self . cur_holder_commitment_transaction_number , & self . secp_ctx ) ;
2968
2951
return Ok ( ( Some ( msgs:: FundingLocked {
2969
2952
channel_id : self . channel_id ( ) ,
2970
2953
next_per_commitment_point,
2971
- } ) , None , None , None , RAACommitmentOrder :: CommitmentFirst , shutdown_msg) ) ;
2954
+ } ) , None , None , None , RAACommitmentOrder :: CommitmentFirst , Vec :: new ( ) , shutdown_msg) ) ;
2972
2955
}
2973
2956
2974
2957
let required_revoke = if msg. next_remote_commitment_number + 1 == INITIAL_COMMITMENT_NUMBER - self . cur_holder_commitment_transaction_number {
@@ -3009,14 +2992,6 @@ impl<Signer: Sign> Channel<Signer> {
3009
2992
}
3010
2993
3011
2994
if ( self . channel_state & ( ChannelState :: AwaitingRemoteRevoke as u32 | ChannelState :: MonitorUpdateFailed as u32 ) ) == 0 {
3012
- // Note that if in the future we no longer drop holding cell update_adds on peer
3013
- // disconnect, this logic will need to be updated.
3014
- for htlc_update in self . holding_cell_htlc_updates . iter ( ) {
3015
- if let & HTLCUpdateAwaitingACK :: AddHTLC { .. } = htlc_update {
3016
- 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." ) ;
3017
- }
3018
- }
3019
-
3020
2995
// We're up-to-date and not waiting on a remote revoke (if we are our
3021
2996
// channel_reestablish should result in them sending a revoke_and_ack), but we may
3022
2997
// have received some updates while we were disconnected. Free the holding cell
@@ -3025,20 +3000,14 @@ impl<Signer: Sign> Channel<Signer> {
3025
3000
Err ( ChannelError :: Close ( msg) ) => return Err ( ChannelError :: Close ( msg) ) ,
3026
3001
Err ( ChannelError :: Ignore ( _) ) | Err ( ChannelError :: CloseDelayBroadcast ( _) ) => panic ! ( "Got non-channel-failing result from free_holding_cell_htlcs" ) ,
3027
3002
Ok ( ( Some ( ( commitment_update, monitor_update) ) , htlcs_to_fail) ) => {
3028
- // If in the future we no longer drop holding cell update_adds on peer
3029
- // disconnect, we may be handed some HTLCs to fail backwards here.
3030
- assert ! ( htlcs_to_fail. is_empty( ) ) ;
3031
- return Ok ( ( resend_funding_locked, required_revoke, Some ( commitment_update) , Some ( monitor_update) , self . resend_order . clone ( ) , shutdown_msg) ) ;
3003
+ return Ok ( ( resend_funding_locked, required_revoke, Some ( commitment_update) , Some ( monitor_update) , self . resend_order . clone ( ) , htlcs_to_fail, shutdown_msg) ) ;
3032
3004
} ,
3033
3005
Ok ( ( None , htlcs_to_fail) ) => {
3034
- // If in the future we no longer drop holding cell update_adds on peer
3035
- // disconnect, we may be handed some HTLCs to fail backwards here.
3036
- assert ! ( htlcs_to_fail. is_empty( ) ) ;
3037
- return Ok ( ( resend_funding_locked, required_revoke, None , None , self . resend_order . clone ( ) , shutdown_msg) ) ;
3006
+ return Ok ( ( resend_funding_locked, required_revoke, None , None , self . resend_order . clone ( ) , htlcs_to_fail, shutdown_msg) ) ;
3038
3007
} ,
3039
3008
}
3040
3009
} else {
3041
- return Ok ( ( resend_funding_locked, required_revoke, None , None , self . resend_order . clone ( ) , shutdown_msg) ) ;
3010
+ return Ok ( ( resend_funding_locked, required_revoke, None , None , self . resend_order . clone ( ) , Vec :: new ( ) , shutdown_msg) ) ;
3042
3011
}
3043
3012
} else if msg. next_local_commitment_number == next_counterparty_commitment_number - 1 {
3044
3013
if required_revoke. is_some ( ) {
@@ -3049,10 +3018,10 @@ impl<Signer: Sign> Channel<Signer> {
3049
3018
3050
3019
if self . channel_state & ( ChannelState :: MonitorUpdateFailed as u32 ) != 0 {
3051
3020
self . monitor_pending_commitment_signed = true ;
3052
- return Ok ( ( resend_funding_locked, None , None , None , self . resend_order . clone ( ) , shutdown_msg) ) ;
3021
+ return Ok ( ( resend_funding_locked, None , None , None , self . resend_order . clone ( ) , Vec :: new ( ) , shutdown_msg) ) ;
3053
3022
}
3054
3023
3055
- return Ok ( ( resend_funding_locked, required_revoke, Some ( self . get_last_commitment_update ( logger) ) , None , self . resend_order . clone ( ) , shutdown_msg) ) ;
3024
+ return Ok ( ( resend_funding_locked, required_revoke, Some ( self . get_last_commitment_update ( logger) ) , None , self . resend_order . clone ( ) , Vec :: new ( ) , shutdown_msg) ) ;
3056
3025
} else {
3057
3026
return Err ( ChannelError :: Close ( "Peer attempted to reestablish channel with a very old remote commitment transaction" . to_owned ( ) ) ) ;
3058
3027
}
@@ -4375,7 +4344,7 @@ impl Readable for InboundHTLCRemovalReason {
4375
4344
impl < Signer : Sign > Writeable for Channel < Signer > {
4376
4345
fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
4377
4346
// Note that we write out as if remove_uncommitted_htlcs_and_mark_paused had just been
4378
- // called but include holding cell updates (and obviously we don't modify self) .
4347
+ // called.
4379
4348
4380
4349
writer. write_all ( & [ SERIALIZATION_VERSION ; 1 ] ) ?;
4381
4350
writer. write_all ( & [ MIN_SERIALIZATION_VERSION ; 1 ] ) ?;
0 commit comments