Skip to content

Commit 4cbfa72

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 30a01b1 commit 4cbfa72

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
@@ -207,6 +207,7 @@ type ShutdownResult = (Option<(OutPoint, ChannelMonitorUpdate)>, Vec<(HTLCSource
207207
208208
struct MsgHandleErrInternal {
209209
err: msgs::LightningError,
210+
chan_id: Option<[u8; 32]>,
210211
shutdown_finish: Option<(ShutdownResult, Option<msgs::ChannelUpdate>)>,
211212
}
212213
impl MsgHandleErrInternal {
@@ -222,6 +223,7 @@ impl MsgHandleErrInternal {
222223
},
223224
},
224225
},
226+
chan_id: Some(channel_id),
225227
shutdown_finish: None,
226228
}
227229
}
@@ -232,12 +234,13 @@ impl MsgHandleErrInternal {
232234
err,
233235
action: msgs::ErrorAction::IgnoreError,
234236
},
237+
chan_id: None,
235238
shutdown_finish: None,
236239
}
237240
}
238241
#[inline]
239242
fn from_no_close(err: msgs::LightningError) -> Self {
240-
Self { err, shutdown_finish: None }
243+
Self { err, chan_id: None, shutdown_finish: None }
241244
}
242245
#[inline]
243246
fn from_finish_shutdown(err: String, channel_id: [u8; 32], shutdown_res: ShutdownResult, channel_update: Option<msgs::ChannelUpdate>) -> Self {
@@ -251,6 +254,7 @@ impl MsgHandleErrInternal {
251254
},
252255
},
253256
},
257+
chan_id: Some(channel_id),
254258
shutdown_finish: Some((shutdown_res, channel_update)),
255259
}
256260
}
@@ -281,6 +285,7 @@ impl MsgHandleErrInternal {
281285
},
282286
},
283287
},
288+
chan_id: Some(channel_id),
284289
shutdown_finish: None,
285290
}
286291
}
@@ -756,7 +761,7 @@ macro_rules! handle_error {
756761
($self: ident, $internal: expr, $counterparty_node_id: expr) => {
757762
match $internal {
758763
Ok(msg) => Ok(msg),
759-
Err(MsgHandleErrInternal { err, shutdown_finish }) => {
764+
Err(MsgHandleErrInternal { err, chan_id, shutdown_finish }) => {
760765
#[cfg(debug_assertions)]
761766
{
762767
// In testing, ensure there are no deadlocks where the lock is already held upon

0 commit comments

Comments
 (0)