@@ -9455,44 +9455,62 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
9455
9455
// Returns whether we should remove this channel as it's just been closed.
9456
9456
let unblock_chan = |phase: &mut Channel<SP>, pending_msg_events: &mut Vec<MessageSendEvent>| -> Option<ShutdownResult> {
9457
9457
let node_id = phase.context().get_counterparty_node_id();
9458
- match ( phase.signer_maybe_unblocked(self.chain_hash, &self.logger), phase.as_funded() ) {
9459
- (Some(msgs), Some(chan)) => {
9460
- let cu_msg = msgs.commitment_update.map(|updates| events::MessageSendEvent::UpdateHTLCs {
9458
+ if let Some(msgs) = phase.signer_maybe_unblocked(self.chain_hash, &self.logger) {
9459
+ if let Some(msg) = msgs.open_channel {
9460
+ pending_msg_events.push( events::MessageSendEvent::SendOpenChannel {
9461
9461
node_id,
9462
- updates ,
9462
+ msg ,
9463
9463
});
9464
- let raa_msg = msgs.revoke_and_ack.map(|msg| events::MessageSendEvent::SendRevokeAndACK {
9464
+ }
9465
+ if let Some(msg) = msgs.funding_created {
9466
+ pending_msg_events.push(events::MessageSendEvent::SendFundingCreated {
9465
9467
node_id,
9466
9468
msg,
9467
9469
});
9468
- match (cu_msg, raa_msg) {
9469
- (Some(cu), Some(raa)) if msgs.order == RAACommitmentOrder::CommitmentFirst => {
9470
- pending_msg_events.push(cu);
9471
- pending_msg_events.push(raa);
9472
- },
9473
- (Some(cu), Some(raa)) if msgs.order == RAACommitmentOrder::RevokeAndACKFirst => {
9474
- pending_msg_events.push(raa);
9475
- pending_msg_events.push(cu);
9476
- },
9477
- (Some(cu), _) => pending_msg_events.push(cu),
9478
- (_, Some(raa)) => pending_msg_events.push(raa),
9479
- (_, _) => {},
9480
- }
9481
- if let Some(msg) = msgs.funding_signed {
9482
- pending_msg_events.push(events::MessageSendEvent::SendFundingSigned {
9483
- node_id,
9484
- msg,
9485
- });
9486
- }
9470
+ }
9471
+ if let Some(msg) = msgs.accept_channel {
9472
+ pending_msg_events.push(events::MessageSendEvent::SendAcceptChannel {
9473
+ node_id,
9474
+ msg,
9475
+ });
9476
+ }
9477
+ let cu_msg = msgs.commitment_update.map(|updates| events::MessageSendEvent::UpdateHTLCs {
9478
+ node_id,
9479
+ updates,
9480
+ });
9481
+ let raa_msg = msgs.revoke_and_ack.map(|msg| events::MessageSendEvent::SendRevokeAndACK {
9482
+ node_id,
9483
+ msg,
9484
+ });
9485
+ match (cu_msg, raa_msg) {
9486
+ (Some(cu), Some(raa)) if msgs.order == RAACommitmentOrder::CommitmentFirst => {
9487
+ pending_msg_events.push(cu);
9488
+ pending_msg_events.push(raa);
9489
+ },
9490
+ (Some(cu), Some(raa)) if msgs.order == RAACommitmentOrder::RevokeAndACKFirst => {
9491
+ pending_msg_events.push(raa);
9492
+ pending_msg_events.push(cu);
9493
+ },
9494
+ (Some(cu), _) => pending_msg_events.push(cu),
9495
+ (_, Some(raa)) => pending_msg_events.push(raa),
9496
+ (_, _) => {},
9497
+ }
9498
+ if let Some(msg) = msgs.funding_signed {
9499
+ pending_msg_events.push(events::MessageSendEvent::SendFundingSigned {
9500
+ node_id,
9501
+ msg,
9502
+ });
9503
+ }
9504
+ if let Some(msg) = msgs.closing_signed {
9505
+ pending_msg_events.push(events::MessageSendEvent::SendClosingSigned {
9506
+ node_id,
9507
+ msg,
9508
+ });
9509
+ }
9510
+ if let Some(chan) = phase.as_funded() {
9487
9511
if let Some(msg) = msgs.channel_ready {
9488
9512
send_channel_ready!(self, pending_msg_events, chan, msg);
9489
9513
}
9490
- if let Some(msg) = msgs.closing_signed {
9491
- pending_msg_events.push(events::MessageSendEvent::SendClosingSigned {
9492
- node_id,
9493
- msg,
9494
- });
9495
- }
9496
9514
if let Some(broadcast_tx) = msgs.signed_closing_tx {
9497
9515
let channel_id = chan.context.channel_id();
9498
9516
let counterparty_node_id = chan.context.get_counterparty_node_id();
@@ -9506,30 +9524,15 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
9506
9524
});
9507
9525
}
9508
9526
}
9509
- msgs.shutdown_result
9510
- },
9511
- (Some(msgs), None) => {
9512
- if let Some(msg) = msgs.open_channel {
9513
- pending_msg_events.push(events::MessageSendEvent::SendOpenChannel {
9514
- node_id,
9515
- msg,
9516
- });
9517
- }
9518
- if let Some(msg) = msgs.funding_created {
9519
- pending_msg_events.push(events::MessageSendEvent::SendFundingCreated {
9520
- node_id,
9521
- msg,
9522
- });
9523
- }
9524
- if let Some(msg) = msgs.accept_channel {
9525
- pending_msg_events.push(events::MessageSendEvent::SendAcceptChannel {
9526
- node_id,
9527
- msg,
9528
- });
9529
- }
9530
- None
9527
+ } else {
9528
+ // We don't know how to handle a channel_ready or signed_closing_tx for a
9529
+ // non-funded channel.
9530
+ debug_assert!(msgs.channel_ready.is_none());
9531
+ debug_assert!(msgs.signed_closing_tx.is_none());
9531
9532
}
9532
- (None, _) => None,
9533
+ msgs.shutdown_result
9534
+ } else {
9535
+ None
9533
9536
}
9534
9537
};
9535
9538
0 commit comments