@@ -2181,6 +2181,9 @@ impl Channel {
2181
2181
if self . channel_outbound {
2182
2182
return Err ( ChannelError :: Close ( "Non-funding remote tried to update channel fee" ) ) ;
2183
2183
}
2184
+ if ( self . channel_state & ( ChannelState :: ChannelFunded as u32 | ChannelState :: RemoteShutdownSent as u32 ) ) != ( ChannelState :: ChannelFunded as u32 ) {
2185
+ return Err ( ChannelError :: Close ( "Got update_fee message when channel was not in an operational state" ) ) ;
2186
+ }
2184
2187
if self . channel_state & ( ChannelState :: PeerDisconnected as u32 ) == ChannelState :: PeerDisconnected as u32 {
2185
2188
return Err ( ChannelError :: Close ( "Peer sent update_fee when we needed a channel_reestablish" ) ) ;
2186
2189
}
@@ -2382,7 +2385,8 @@ impl Channel {
2382
2385
fn maybe_propose_first_closing_signed ( & mut self , fee_estimator : & FeeEstimator ) -> Option < msgs:: ClosingSigned > {
2383
2386
if !self . channel_outbound || !self . pending_inbound_htlcs . is_empty ( ) || !self . pending_outbound_htlcs . is_empty ( ) ||
2384
2387
self . channel_state & ( BOTH_SIDES_SHUTDOWN_MASK | ChannelState :: AwaitingRemoteRevoke as u32 ) != BOTH_SIDES_SHUTDOWN_MASK ||
2385
- self . last_sent_closing_fee . is_some ( ) {
2388
+ self . last_sent_closing_fee . is_some ( ) ||
2389
+ self . cur_remote_commitment_transaction_number != self . cur_local_commitment_transaction_number {
2386
2390
return None ;
2387
2391
}
2388
2392
@@ -2452,6 +2456,7 @@ impl Channel {
2452
2456
// We can't send our shutdown until we've committed all of our pending HTLCs, but the
2453
2457
// remote side is unlikely to accept any new HTLCs, so we go ahead and "free" any holding
2454
2458
// cell HTLCs and return them to fail the payment.
2459
+ self . holding_cell_update_fee = None ;
2455
2460
let mut dropped_outbound_htlcs = Vec :: with_capacity ( self . holding_cell_htlc_updates . len ( ) ) ;
2456
2461
self . holding_cell_htlc_updates . retain ( |htlc_update| {
2457
2462
match htlc_update {
@@ -3260,9 +3265,9 @@ impl Channel {
3260
3265
}
3261
3266
self . channel_update_count += 1 ;
3262
3267
3263
- // We can't send our shutdown until we've committed all of our pending HTLCs, but the
3264
- // remote side is unlikely to accept any new HTLCs, so we go ahead and "free" any holding
3265
- // cell HTLCs and return them to fail the payment.
3268
+ // Go ahead and drop holding cell updates as we'd rather fail payments than wait to send
3269
+ // our shutdown until we've committed all of the pending changes.
3270
+ self . holding_cell_update_fee = None ;
3266
3271
let mut dropped_outbound_htlcs = Vec :: with_capacity ( self . holding_cell_htlc_updates . len ( ) ) ;
3267
3272
self . holding_cell_htlc_updates . retain ( |htlc_update| {
3268
3273
match htlc_update {
0 commit comments