@@ -8241,44 +8241,44 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8241
8241
8242
8242
fn internal_tx_add_input(&self, counterparty_node_id: PublicKey, msg: &msgs::TxAddInput) -> Result<(), MsgHandleErrInternal> {
8243
8243
self.internal_tx_msg(&counterparty_node_id, msg.channel_id, |channel_phase: &mut ChannelPhase<SP>| {
8244
- match channel_phase {
8245
- ChannelPhase::UnfundedV2(ref mut channel) => {
8244
+ match channel_phase.as_unfunded_v2_mut() {
8245
+ Some( channel) => {
8246
8246
Ok(channel.tx_add_input(msg).into_msg_send_event(counterparty_node_id))
8247
8247
},
8248
- _ => Err("tx_add_input"),
8248
+ None => Err("tx_add_input"),
8249
8249
}
8250
8250
})
8251
8251
}
8252
8252
8253
8253
fn internal_tx_add_output(&self, counterparty_node_id: PublicKey, msg: &msgs::TxAddOutput) -> Result<(), MsgHandleErrInternal> {
8254
8254
self.internal_tx_msg(&counterparty_node_id, msg.channel_id, |channel_phase: &mut ChannelPhase<SP>| {
8255
- match channel_phase {
8256
- ChannelPhase::UnfundedV2(ref mut channel) => {
8255
+ match channel_phase.as_unfunded_v2_mut() {
8256
+ Some( channel) => {
8257
8257
Ok(channel.tx_add_output(msg).into_msg_send_event(counterparty_node_id))
8258
8258
},
8259
- _ => Err("tx_add_output"),
8259
+ None => Err("tx_add_output"),
8260
8260
}
8261
8261
})
8262
8262
}
8263
8263
8264
8264
fn internal_tx_remove_input(&self, counterparty_node_id: PublicKey, msg: &msgs::TxRemoveInput) -> Result<(), MsgHandleErrInternal> {
8265
8265
self.internal_tx_msg(&counterparty_node_id, msg.channel_id, |channel_phase: &mut ChannelPhase<SP>| {
8266
- match channel_phase {
8267
- ChannelPhase::UnfundedV2(ref mut channel) => {
8266
+ match channel_phase.as_unfunded_v2_mut() {
8267
+ Some( channel) => {
8268
8268
Ok(channel.tx_remove_input(msg).into_msg_send_event(counterparty_node_id))
8269
8269
},
8270
- _ => Err("tx_remove_input"),
8270
+ None => Err("tx_remove_input"),
8271
8271
}
8272
8272
})
8273
8273
}
8274
8274
8275
8275
fn internal_tx_remove_output(&self, counterparty_node_id: PublicKey, msg: &msgs::TxRemoveOutput) -> Result<(), MsgHandleErrInternal> {
8276
8276
self.internal_tx_msg(&counterparty_node_id, msg.channel_id, |channel_phase: &mut ChannelPhase<SP>| {
8277
- match channel_phase {
8278
- ChannelPhase::UnfundedV2(ref mut channel) => {
8277
+ match channel_phase.as_unfunded_v2_mut() {
8278
+ Some( channel) => {
8279
8279
Ok(channel.tx_remove_output(msg).into_msg_send_event(counterparty_node_id))
8280
8280
},
8281
- _ => Err("tx_remove_output"),
8281
+ None => Err("tx_remove_output"),
8282
8282
}
8283
8283
})
8284
8284
}
@@ -8297,10 +8297,10 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8297
8297
match peer_state.channel_by_id.entry(msg.channel_id) {
8298
8298
hash_map::Entry::Occupied(mut chan_phase_entry) => {
8299
8299
let channel_phase = chan_phase_entry.get_mut();
8300
- let (msg_send_event_opt, signing_session_opt) = match channel_phase {
8301
- ChannelPhase::UnfundedV2 (channel) => channel.tx_complete(msg)
8300
+ let (msg_send_event_opt, signing_session_opt) = match channel_phase.as_unfunded_v2_mut() {
8301
+ Some (channel) => channel.tx_complete(msg)
8302
8302
.into_msg_send_event_or_signing_session(counterparty_node_id),
8303
- _ => try_chan_phase_entry!(self, peer_state, Err(ChannelError::Close(
8303
+ None => try_chan_phase_entry!(self, peer_state, Err(ChannelError::Close(
8304
8304
(
8305
8305
"Got a tx_complete message with no interactive transaction construction expected or in-progress".into(),
8306
8306
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
@@ -8310,18 +8310,18 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8310
8310
peer_state.pending_msg_events.push(msg_send_event);
8311
8311
};
8312
8312
if let Some(mut signing_session) = signing_session_opt {
8313
- let (commitment_signed, funding_ready_for_sig_event_opt) = match chan_phase_entry.get_mut() {
8314
- ChannelPhase::UnfundedV2 (chan) => {
8313
+ let (commitment_signed, funding_ready_for_sig_event_opt) = match chan_phase_entry.get_mut().as_unfunded_v2_mut() {
8314
+ Some (chan) => {
8315
8315
chan.funding_tx_constructed(&mut signing_session, &self.logger)
8316
8316
},
8317
- _ => Err(ChannelError::Warn(
8317
+ None => Err(ChannelError::Warn(
8318
8318
"Got a tx_complete message with no interactive transaction construction expected or in-progress"
8319
8319
.into())),
8320
8320
}.map_err(|err| MsgHandleErrInternal::send_err_msg_no_close(format!("{}", err), msg.channel_id))?;
8321
8321
let (channel_id, channel_phase) = chan_phase_entry.remove_entry();
8322
- let channel = match channel_phase {
8323
- ChannelPhase::UnfundedV2 (chan) => chan.into_channel(signing_session),
8324
- _ => {
8322
+ let channel = match channel_phase.into_unfunded_v2() {
8323
+ Some (chan) => chan.into_channel(signing_session),
8324
+ None => {
8325
8325
debug_assert!(false); // It cannot be another variant as we are in the `Ok` branch of the above match.
8326
8326
Err(ChannelError::Warn(
8327
8327
"Got a tx_complete message with no interactive transaction construction expected or in-progress"
0 commit comments