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