Skip to content

Commit 54ae5e3

Browse files
author
Antoine Riard
committed
Extend MsgHandleErrInternal with a new chan_id field Option<[u8; 32]>
This field is used in next commit to generate appropriate ChannelClosed event at `handle_error()` processing.
1 parent 65cdf15 commit 54ae5e3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ type ShutdownResult = (Option<(OutPoint, ChannelMonitorUpdate)>, Vec<(HTLCSource
242242
243243
struct MsgHandleErrInternal {
244244
err: msgs::LightningError,
245+
chan_id: Option<[u8; 32]>, // If Some a channel of ours has been closed
245246
shutdown_finish: Option<(ShutdownResult, Option<msgs::ChannelUpdate>)>,
246247
}
247248
impl MsgHandleErrInternal {
@@ -257,6 +258,7 @@ impl MsgHandleErrInternal {
257258
},
258259
},
259260
},
261+
chan_id: None,
260262
shutdown_finish: None,
261263
}
262264
}
@@ -267,12 +269,13 @@ impl MsgHandleErrInternal {
267269
err,
268270
action: msgs::ErrorAction::IgnoreError,
269271
},
272+
chan_id: None,
270273
shutdown_finish: None,
271274
}
272275
}
273276
#[inline]
274277
fn from_no_close(err: msgs::LightningError) -> Self {
275-
Self { err, shutdown_finish: None }
278+
Self { err, chan_id: None, shutdown_finish: None }
276279
}
277280
#[inline]
278281
fn from_finish_shutdown(err: String, channel_id: [u8; 32], shutdown_res: ShutdownResult, channel_update: Option<msgs::ChannelUpdate>) -> Self {
@@ -286,6 +289,7 @@ impl MsgHandleErrInternal {
286289
},
287290
},
288291
},
292+
chan_id: Some(channel_id),
289293
shutdown_finish: Some((shutdown_res, channel_update)),
290294
}
291295
}
@@ -320,6 +324,7 @@ impl MsgHandleErrInternal {
320324
},
321325
},
322326
},
327+
chan_id: None,
323328
shutdown_finish: None,
324329
}
325330
}
@@ -813,7 +818,7 @@ macro_rules! handle_error {
813818
($self: ident, $internal: expr, $counterparty_node_id: expr) => {
814819
match $internal {
815820
Ok(msg) => Ok(msg),
816-
Err(MsgHandleErrInternal { err, shutdown_finish }) => {
821+
Err(MsgHandleErrInternal { err, chan_id, shutdown_finish }) => {
817822
#[cfg(debug_assertions)]
818823
{
819824
// In testing, ensure there are no deadlocks where the lock is already held upon

0 commit comments

Comments
 (0)