@@ -9400,49 +9400,65 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
9400
9400
9401
9401
// Returns whether we should remove this channel as it's just been closed.
9402
9402
let unblock_chan = |chan: &mut Channel<SP>, pending_msg_events: &mut Vec<MessageSendEvent>| -> Option<ShutdownResult> {
9403
+ let logger = WithChannelContext::from(&self.logger, &chan.context(), None);
9403
9404
let node_id = chan.context().get_counterparty_node_id();
9404
- match ( chan.signer_maybe_unblocked(self.chain_hash, &self. logger), chan.as_funded() ) {
9405
- (Some(msgs), Some(funded_chan)) => {
9406
- let cu_msg = msgs.commitment_update.map(|updates| events::MessageSendEvent::UpdateHTLCs {
9405
+ if let Some(msgs) = chan.signer_maybe_unblocked(self.chain_hash, && logger) {
9406
+ if let Some(msg) = msgs.open_channel {
9407
+ pending_msg_events.push( events::MessageSendEvent::SendOpenChannel {
9407
9408
node_id,
9408
- updates ,
9409
+ msg ,
9409
9410
});
9410
- let raa_msg = msgs.revoke_and_ack.map(|msg| events::MessageSendEvent::SendRevokeAndACK {
9411
+ }
9412
+ if let Some(msg) = msgs.funding_created {
9413
+ pending_msg_events.push(events::MessageSendEvent::SendFundingCreated {
9411
9414
node_id,
9412
9415
msg,
9413
9416
});
9414
- match (cu_msg, raa_msg) {
9415
- (Some(cu), Some(raa)) if msgs.order == RAACommitmentOrder::CommitmentFirst => {
9416
- pending_msg_events.push(cu);
9417
- pending_msg_events.push(raa);
9418
- },
9419
- (Some(cu), Some(raa)) if msgs.order == RAACommitmentOrder::RevokeAndACKFirst => {
9420
- pending_msg_events.push(raa);
9421
- pending_msg_events.push(cu);
9422
- },
9423
- (Some(cu), _) => pending_msg_events.push(cu),
9424
- (_, Some(raa)) => pending_msg_events.push(raa),
9425
- (_, _) => {},
9426
- }
9427
- if let Some(msg) = msgs.funding_signed {
9428
- pending_msg_events.push(events::MessageSendEvent::SendFundingSigned {
9429
- node_id,
9430
- msg,
9431
- });
9432
- }
9417
+ }
9418
+ if let Some(msg) = msgs.accept_channel {
9419
+ pending_msg_events.push(events::MessageSendEvent::SendAcceptChannel {
9420
+ node_id,
9421
+ msg,
9422
+ });
9423
+ }
9424
+ let cu_msg = msgs.commitment_update.map(|updates| events::MessageSendEvent::UpdateHTLCs {
9425
+ node_id,
9426
+ updates,
9427
+ });
9428
+ let raa_msg = msgs.revoke_and_ack.map(|msg| events::MessageSendEvent::SendRevokeAndACK {
9429
+ node_id,
9430
+ msg,
9431
+ });
9432
+ match (cu_msg, raa_msg) {
9433
+ (Some(cu), Some(raa)) if msgs.order == RAACommitmentOrder::CommitmentFirst => {
9434
+ pending_msg_events.push(cu);
9435
+ pending_msg_events.push(raa);
9436
+ },
9437
+ (Some(cu), Some(raa)) if msgs.order == RAACommitmentOrder::RevokeAndACKFirst => {
9438
+ pending_msg_events.push(raa);
9439
+ pending_msg_events.push(cu);
9440
+ },
9441
+ (Some(cu), _) => pending_msg_events.push(cu),
9442
+ (_, Some(raa)) => pending_msg_events.push(raa),
9443
+ (_, _) => {},
9444
+ }
9445
+ if let Some(msg) = msgs.funding_signed {
9446
+ pending_msg_events.push(events::MessageSendEvent::SendFundingSigned {
9447
+ node_id,
9448
+ msg,
9449
+ });
9450
+ }
9451
+ if let Some(msg) = msgs.closing_signed {
9452
+ pending_msg_events.push(events::MessageSendEvent::SendClosingSigned {
9453
+ node_id,
9454
+ msg,
9455
+ });
9456
+ }
9457
+ if let Some(funded_chan) = chan.as_funded() {
9433
9458
if let Some(msg) = msgs.channel_ready {
9434
9459
send_channel_ready!(self, pending_msg_events, funded_chan, msg);
9435
9460
}
9436
- if let Some(msg) = msgs.closing_signed {
9437
- pending_msg_events.push(events::MessageSendEvent::SendClosingSigned {
9438
- node_id,
9439
- msg,
9440
- });
9441
- }
9442
9461
if let Some(broadcast_tx) = msgs.signed_closing_tx {
9443
- let channel_id = funded_chan.context.channel_id();
9444
- let counterparty_node_id = funded_chan.context.get_counterparty_node_id();
9445
- let logger = WithContext::from(&self.logger, Some(counterparty_node_id), Some(channel_id), None);
9446
9462
log_info!(logger, "Broadcasting closing tx {}", log_tx!(broadcast_tx));
9447
9463
self.tx_broadcaster.broadcast_transactions(&[&broadcast_tx]);
9448
9464
@@ -9452,30 +9468,15 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
9452
9468
});
9453
9469
}
9454
9470
}
9455
- msgs.shutdown_result
9456
- },
9457
- (Some(msgs), None) => {
9458
- if let Some(msg) = msgs.open_channel {
9459
- pending_msg_events.push(events::MessageSendEvent::SendOpenChannel {
9460
- node_id,
9461
- msg,
9462
- });
9463
- }
9464
- if let Some(msg) = msgs.funding_created {
9465
- pending_msg_events.push(events::MessageSendEvent::SendFundingCreated {
9466
- node_id,
9467
- msg,
9468
- });
9469
- }
9470
- if let Some(msg) = msgs.accept_channel {
9471
- pending_msg_events.push(events::MessageSendEvent::SendAcceptChannel {
9472
- node_id,
9473
- msg,
9474
- });
9475
- }
9476
- None
9471
+ } else {
9472
+ // We don't know how to handle a channel_ready or signed_closing_tx for a
9473
+ // non-funded channel.
9474
+ debug_assert!(msgs.channel_ready.is_none());
9475
+ debug_assert!(msgs.signed_closing_tx.is_none());
9477
9476
}
9478
- (None, _) => None,
9477
+ msgs.shutdown_result
9478
+ } else {
9479
+ None
9479
9480
}
9480
9481
};
9481
9482
0 commit comments