Skip to content

Commit e6b1635

Browse files
committed
f use channel monitor update logic from reestablish, not monitor success
1 parent dec719f commit e6b1635

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -913,23 +913,30 @@ macro_rules! handle_chan_restoration_locked {
913913
}
914914

915915
let funding_broadcastable: Option<Transaction> = $funding_broadcastable; // Force type-checking to resolve
916-
macro_rules! handle_cs { () => {
917-
if let Some(monitor_update) = chanmon_update {
918-
assert!($order == RAACommitmentOrder::RevokeAndACKFirst);
919-
// We only ever broadcast a funding transaction in response to a funding_signed
920-
// message and the resulting monitor update. Thus, on channel_reestablish
921-
// message handling we can't have a funding transaction to broadcast. When
922-
// processing a monitor update finishing resulting in a funding broadcast, we
923-
// cannot have a second monitor update, thus this case would indicate a bug.
924-
assert!(funding_broadcastable.is_none());
925-
// Given we were just reconnected or finished updating a channel monitor, the
926-
// only case where we can get a new ChannelMonitorUpdate would be if we also
927-
// have some commitment updates to send as well.
928-
assert!($commitment_update.is_some());
929-
if let Err(e) = $self.chain_monitor.update_channel($channel_entry.get().get_funding_txo().unwrap(), monitor_update) {
930-
break handle_monitor_err!($self, e, $channel_state, $channel_entry, RAACommitmentOrder::CommitmentFirst, false, true);
916+
if let Some(monitor_update) = chanmon_update {
917+
// We only ever broadcast a funding transaction in response to a funding_signed
918+
// message and the resulting monitor update. Thus, on channel_reestablish
919+
// message handling we can't have a funding transaction to broadcast. When
920+
// processing a monitor update finishing resulting in a funding broadcast, we
921+
// cannot have a second monitor update, thus this case would indicate a bug.
922+
assert!(funding_broadcastable.is_none());
923+
// Given we were just reconnected or finished updating a channel monitor, the
924+
// only case where we can get a new ChannelMonitorUpdate would be if we also
925+
// have some commitment updates to send as well.
926+
assert!($commitment_update.is_some());
927+
if let Err(e) = $self.chain_monitor.update_channel($channel_entry.get().get_funding_txo().unwrap(), monitor_update) {
928+
// channel_reestablish doesn't guarantee the order it returns is sensical
929+
// for the messages it returns, but if we're setting what messages to
930+
// re-transmit on monitor update success, we need to make sure it is sane.
931+
let mut order = $order;
932+
if $raa.is_none() {
933+
order = RAACommitmentOrder::CommitmentFirst;
931934
}
935+
break handle_monitor_err!($self, e, $channel_state, $channel_entry, order, $raa.is_some(), true);
932936
}
937+
}
938+
939+
macro_rules! handle_cs { () => {
933940
if let Some(update) = $commitment_update {
934941
$channel_state.pending_msg_events.push(events::MessageSendEvent::UpdateHTLCs {
935942
node_id: counterparty_node_id,

0 commit comments

Comments
 (0)