@@ -9372,49 +9372,65 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
9372
9372
9373
9373
// Returns whether we should remove this channel as it's just been closed.
9374
9374
let unblock_chan = |chan: &mut Channel<SP>, pending_msg_events: &mut Vec<MessageSendEvent>| -> Option<ShutdownResult> {
9375
+ let logger = WithChannelContext::from(&self.logger, &chan.context(), None);
9375
9376
let node_id = chan.context().get_counterparty_node_id();
9376
- match ( chan.signer_maybe_unblocked(self.chain_hash, &self. logger), chan.as_funded() ) {
9377
- (Some(msgs), Some(funded_chan)) => {
9378
- let cu_msg = msgs.commitment_update.map(|updates| events::MessageSendEvent::UpdateHTLCs {
9377
+ if let Some(msgs) = chan.signer_maybe_unblocked(self.chain_hash, && logger) {
9378
+ if let Some(msg) = msgs.open_channel {
9379
+ pending_msg_events.push( events::MessageSendEvent::SendOpenChannel {
9379
9380
node_id,
9380
- updates ,
9381
+ msg ,
9381
9382
});
9382
- let raa_msg = msgs.revoke_and_ack.map(|msg| events::MessageSendEvent::SendRevokeAndACK {
9383
+ }
9384
+ if let Some(msg) = msgs.funding_created {
9385
+ pending_msg_events.push(events::MessageSendEvent::SendFundingCreated {
9383
9386
node_id,
9384
9387
msg,
9385
9388
});
9386
- match (cu_msg, raa_msg) {
9387
- (Some(cu), Some(raa)) if msgs.order == RAACommitmentOrder::CommitmentFirst => {
9388
- pending_msg_events.push(cu);
9389
- pending_msg_events.push(raa);
9390
- },
9391
- (Some(cu), Some(raa)) if msgs.order == RAACommitmentOrder::RevokeAndACKFirst => {
9392
- pending_msg_events.push(raa);
9393
- pending_msg_events.push(cu);
9394
- },
9395
- (Some(cu), _) => pending_msg_events.push(cu),
9396
- (_, Some(raa)) => pending_msg_events.push(raa),
9397
- (_, _) => {},
9398
- }
9399
- if let Some(msg) = msgs.funding_signed {
9400
- pending_msg_events.push(events::MessageSendEvent::SendFundingSigned {
9401
- node_id,
9402
- msg,
9403
- });
9404
- }
9389
+ }
9390
+ if let Some(msg) = msgs.accept_channel {
9391
+ pending_msg_events.push(events::MessageSendEvent::SendAcceptChannel {
9392
+ node_id,
9393
+ msg,
9394
+ });
9395
+ }
9396
+ let cu_msg = msgs.commitment_update.map(|updates| events::MessageSendEvent::UpdateHTLCs {
9397
+ node_id,
9398
+ updates,
9399
+ });
9400
+ let raa_msg = msgs.revoke_and_ack.map(|msg| events::MessageSendEvent::SendRevokeAndACK {
9401
+ node_id,
9402
+ msg,
9403
+ });
9404
+ match (cu_msg, raa_msg) {
9405
+ (Some(cu), Some(raa)) if msgs.order == RAACommitmentOrder::CommitmentFirst => {
9406
+ pending_msg_events.push(cu);
9407
+ pending_msg_events.push(raa);
9408
+ },
9409
+ (Some(cu), Some(raa)) if msgs.order == RAACommitmentOrder::RevokeAndACKFirst => {
9410
+ pending_msg_events.push(raa);
9411
+ pending_msg_events.push(cu);
9412
+ },
9413
+ (Some(cu), _) => pending_msg_events.push(cu),
9414
+ (_, Some(raa)) => pending_msg_events.push(raa),
9415
+ (_, _) => {},
9416
+ }
9417
+ if let Some(msg) = msgs.funding_signed {
9418
+ pending_msg_events.push(events::MessageSendEvent::SendFundingSigned {
9419
+ node_id,
9420
+ msg,
9421
+ });
9422
+ }
9423
+ if let Some(msg) = msgs.closing_signed {
9424
+ pending_msg_events.push(events::MessageSendEvent::SendClosingSigned {
9425
+ node_id,
9426
+ msg,
9427
+ });
9428
+ }
9429
+ if let Some(funded_chan) = chan.as_funded() {
9405
9430
if let Some(msg) = msgs.channel_ready {
9406
9431
send_channel_ready!(self, pending_msg_events, funded_chan, msg);
9407
9432
}
9408
- if let Some(msg) = msgs.closing_signed {
9409
- pending_msg_events.push(events::MessageSendEvent::SendClosingSigned {
9410
- node_id,
9411
- msg,
9412
- });
9413
- }
9414
9433
if let Some(broadcast_tx) = msgs.signed_closing_tx {
9415
- let channel_id = funded_chan.context.channel_id();
9416
- let counterparty_node_id = funded_chan.context.get_counterparty_node_id();
9417
- let logger = WithContext::from(&self.logger, Some(counterparty_node_id), Some(channel_id), None);
9418
9434
log_info!(logger, "Broadcasting closing tx {}", log_tx!(broadcast_tx));
9419
9435
self.tx_broadcaster.broadcast_transactions(&[&broadcast_tx]);
9420
9436
@@ -9424,30 +9440,15 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
9424
9440
});
9425
9441
}
9426
9442
}
9427
- msgs.shutdown_result
9428
- },
9429
- (Some(msgs), None) => {
9430
- if let Some(msg) = msgs.open_channel {
9431
- pending_msg_events.push(events::MessageSendEvent::SendOpenChannel {
9432
- node_id,
9433
- msg,
9434
- });
9435
- }
9436
- if let Some(msg) = msgs.funding_created {
9437
- pending_msg_events.push(events::MessageSendEvent::SendFundingCreated {
9438
- node_id,
9439
- msg,
9440
- });
9441
- }
9442
- if let Some(msg) = msgs.accept_channel {
9443
- pending_msg_events.push(events::MessageSendEvent::SendAcceptChannel {
9444
- node_id,
9445
- msg,
9446
- });
9447
- }
9448
- None
9443
+ } else {
9444
+ // We don't know how to handle a channel_ready or signed_closing_tx for a
9445
+ // non-funded channel.
9446
+ debug_assert!(msgs.channel_ready.is_none());
9447
+ debug_assert!(msgs.signed_closing_tx.is_none());
9449
9448
}
9450
- (None, _) => None,
9449
+ msgs.shutdown_result
9450
+ } else {
9451
+ None
9451
9452
}
9452
9453
};
9453
9454
0 commit comments