@@ -1518,13 +1518,11 @@ macro_rules! emit_channel_ready_event {
1518
1518
}
1519
1519
1520
1520
macro_rules! handle_chan_restoration_locked {
1521
- ( $self: ident, $channel_lock : expr , $ channel_state: expr, $channel_entry: expr,
1522
- $raa: expr, $commitment_update: expr, $order: expr, $chanmon_update : expr ,
1521
+ ( $self: ident, $channel_state: expr, $channel_entry: expr,
1522
+ $raa: expr, $commitment_update: expr, $order: expr,
1523
1523
$pending_forwards: expr, $funding_broadcastable: expr, $channel_ready: expr, $announcement_sigs: expr) => { {
1524
1524
let mut htlc_forwards = None ;
1525
1525
1526
- let chanmon_update: Option <ChannelMonitorUpdate > = $chanmon_update; // Force type-checking to resolve
1527
- let chanmon_update_is_none = chanmon_update. is_none( ) ;
1528
1526
let counterparty_node_id = $channel_entry. get( ) . get_counterparty_node_id( ) ;
1529
1527
let res = loop {
1530
1528
let forwards: Vec <( PendingHTLCInfo , u64 ) > = $pending_forwards; // Force type-checking to resolve
@@ -1533,24 +1531,7 @@ macro_rules! handle_chan_restoration_locked {
1533
1531
$channel_entry. get( ) . get_funding_txo( ) . unwrap( ) , forwards) ) ;
1534
1532
}
1535
1533
1536
- if chanmon_update. is_some( ) {
1537
- // On reconnect, we, by definition, only resend a channel_ready if there have been
1538
- // no commitment updates, so the only channel monitor update which could also be
1539
- // associated with a channel_ready would be the funding_created/funding_signed
1540
- // monitor update. That monitor update failing implies that we won't send
1541
- // channel_ready until it's been updated, so we can't have a channel_ready and a
1542
- // monitor update here (so we don't bother to handle it correctly below).
1543
- assert!( $channel_ready. is_none( ) ) ;
1544
- // A channel monitor update makes no sense without either a channel_ready or a
1545
- // commitment update to process after it. Since we can't have a channel_ready, we
1546
- // only bother to handle the monitor-update + commitment_update case below.
1547
- assert!( $commitment_update. is_some( ) ) ;
1548
- }
1549
-
1550
1534
if let Some ( msg) = $channel_ready {
1551
- // Similar to the above, this implies that we're letting the channel_ready fly
1552
- // before it should be allowed to.
1553
- assert!( chanmon_update. is_none( ) ) ;
1554
1535
send_channel_ready!( $self, $channel_state. pending_msg_events, $channel_entry. get( ) , msg) ;
1555
1536
}
1556
1537
if let Some ( msg) = $announcement_sigs {
@@ -1562,33 +1543,6 @@ macro_rules! handle_chan_restoration_locked {
1562
1543
1563
1544
emit_channel_ready_event!( $self, $channel_entry. get_mut( ) ) ;
1564
1545
1565
- let funding_broadcastable: Option <Transaction > = $funding_broadcastable; // Force type-checking to resolve
1566
- if let Some ( monitor_update) = chanmon_update {
1567
- // We only ever broadcast a funding transaction in response to a funding_signed
1568
- // message and the resulting monitor update. Thus, on channel_reestablish
1569
- // message handling we can't have a funding transaction to broadcast. When
1570
- // processing a monitor update finishing resulting in a funding broadcast, we
1571
- // cannot have a second monitor update, thus this case would indicate a bug.
1572
- assert!( funding_broadcastable. is_none( ) ) ;
1573
- // Given we were just reconnected or finished updating a channel monitor, the
1574
- // only case where we can get a new ChannelMonitorUpdate would be if we also
1575
- // have some commitment updates to send as well.
1576
- assert!( $commitment_update. is_some( ) ) ;
1577
- match $self. chain_monitor. update_channel( $channel_entry. get( ) . get_funding_txo( ) . unwrap( ) , monitor_update) {
1578
- ChannelMonitorUpdateStatus :: Completed => { } ,
1579
- e => {
1580
- // channel_reestablish doesn't guarantee the order it returns is sensical
1581
- // for the messages it returns, but if we're setting what messages to
1582
- // re-transmit on monitor update success, we need to make sure it is sane.
1583
- let mut order = $order;
1584
- if $raa. is_none( ) {
1585
- order = RAACommitmentOrder :: CommitmentFirst ;
1586
- }
1587
- break handle_monitor_update_res!( $self, e, $channel_entry, order, $raa. is_some( ) , true ) ;
1588
- }
1589
- }
1590
- }
1591
-
1592
1546
macro_rules! handle_cs { ( ) => {
1593
1547
if let Some ( update) = $commitment_update {
1594
1548
$channel_state. pending_msg_events. push( events:: MessageSendEvent :: UpdateHTLCs {
@@ -1615,20 +1569,15 @@ macro_rules! handle_chan_restoration_locked {
1615
1569
handle_cs!( ) ;
1616
1570
} ,
1617
1571
}
1572
+
1573
+ let funding_broadcastable: Option <Transaction > = $funding_broadcastable; // Force type-checking to resolve
1618
1574
if let Some ( tx) = funding_broadcastable {
1619
1575
log_info!( $self. logger, "Broadcasting funding transaction with txid {}" , tx. txid( ) ) ;
1620
1576
$self. tx_broadcaster. broadcast_transaction( & tx) ;
1621
1577
}
1622
1578
break Ok ( ( ) ) ;
1623
1579
} ;
1624
1580
1625
- if chanmon_update_is_none {
1626
- // If there was no ChannelMonitorUpdate, we should never generate an Err in the res loop
1627
- // above. Doing so would imply calling handle_err!() from channel_monitor_updated() which
1628
- // should *never* end up calling back to `chain_monitor.update_channel()`.
1629
- assert!( res. is_ok( ) ) ;
1630
- }
1631
-
1632
1581
( htlc_forwards, res, counterparty_node_id)
1633
1582
} }
1634
1583
}
@@ -4520,7 +4469,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4520
4469
} )
4521
4470
} else { None }
4522
4471
} else { None } ;
4523
- chan_restoration_res = handle_chan_restoration_locked ! ( self , channel_lock , channel_state, channel, updates. raa, updates. commitment_update, updates. order, None , updates. accepted_htlcs, updates. funding_broadcastable, updates. channel_ready, updates. announcement_sigs) ;
4472
+ chan_restoration_res = handle_chan_restoration_locked ! ( self , channel_state, channel, updates. raa, updates. commitment_update, updates. order, updates. accepted_htlcs, updates. funding_broadcastable, updates. channel_ready, updates. announcement_sigs) ;
4524
4473
if let Some ( upd) = channel_update {
4525
4474
channel_state. pending_msg_events . push ( upd) ;
4526
4475
}
@@ -5279,7 +5228,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5279
5228
5280
5229
fn internal_channel_reestablish ( & self , counterparty_node_id : & PublicKey , msg : & msgs:: ChannelReestablish ) -> Result < ( ) , MsgHandleErrInternal > {
5281
5230
let chan_restoration_res;
5282
- let ( htlcs_failed_forward , need_lnd_workaround) = {
5231
+ let need_lnd_workaround = {
5283
5232
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
5284
5233
let channel_state = & mut * channel_state_lock;
5285
5234
@@ -5314,18 +5263,17 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5314
5263
}
5315
5264
let need_lnd_workaround = chan. get_mut ( ) . workaround_lnd_bug_4006 . take ( ) ;
5316
5265
chan_restoration_res = handle_chan_restoration_locked ! (
5317
- self , channel_state_lock , channel_state, chan, responses. raa, responses. commitment_update, responses. order,
5318
- responses . mon_update , Vec :: new( ) , None , responses. channel_ready, responses. announcement_sigs) ;
5266
+ self , channel_state, chan, responses. raa, responses. commitment_update, responses. order,
5267
+ Vec :: new( ) , None , responses. channel_ready, responses. announcement_sigs) ;
5319
5268
if let Some ( upd) = channel_update {
5320
5269
channel_state. pending_msg_events . push ( upd) ;
5321
5270
}
5322
- ( responses . holding_cell_failed_htlcs , need_lnd_workaround)
5271
+ need_lnd_workaround
5323
5272
} ,
5324
5273
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
5325
5274
}
5326
5275
} ;
5327
5276
post_handle_chan_restoration ! ( self , chan_restoration_res) ;
5328
- self . fail_holding_cell_htlcs ( htlcs_failed_forward, msg. channel_id , counterparty_node_id) ;
5329
5277
5330
5278
if let Some ( channel_ready_msg) = need_lnd_workaround {
5331
5279
self . internal_channel_ready ( counterparty_node_id, & channel_ready_msg) ?;
0 commit comments