Skip to content

Commit e5dfc2c

Browse files
committed
Update for channel phase changes
Modifies `signer_unblocked` to use the phase rather than the channel: we only need to worry about the `Funded` phase right now.
1 parent 5ef97d2 commit e5dfc2c

File tree

2 files changed

+25
-28
lines changed

2 files changed

+25
-28
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6615,25 +6615,28 @@ where
66156615
pub fn signer_unblocked(&self, channel_opt: Option<(PublicKey, ChannelId)>) {
66166616
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
66176617

6618-
let unblock_chan = |chan: &mut Channel<SP>, pending_msg_events: &mut Vec<MessageSendEvent>| {
6619-
let msgs = chan.signer_maybe_unblocked(&self.logger);
6620-
if let Some(updates) = msgs.commitment_update {
6621-
pending_msg_events.push(events::MessageSendEvent::UpdateHTLCs {
6622-
node_id: chan.context.get_counterparty_node_id(),
6623-
updates,
6624-
});
6625-
}
6626-
if let Some(msg) = msgs.funding_signed {
6627-
pending_msg_events.push(events::MessageSendEvent::SendFundingSigned {
6628-
node_id: chan.context.get_counterparty_node_id(),
6629-
msg,
6630-
});
6631-
}
6632-
if let Some(msg) = msgs.funding_created {
6633-
pending_msg_events.push(events::MessageSendEvent::SendFundingCreated {
6634-
node_id: chan.context.get_counterparty_node_id(),
6635-
msg,
6636-
});
6618+
let unblock_chan = |phase: &mut ChannelPhase<SP>, pending_msg_events: &mut Vec<MessageSendEvent>| {
6619+
if let ChannelPhase::Funded(chan) = phase {
6620+
let msgs = chan.signer_maybe_unblocked(&self.logger);
6621+
let node_id = phase.context().get_counterparty_node_id();
6622+
if let Some(updates) = msgs.commitment_update {
6623+
pending_msg_events.push(events::MessageSendEvent::UpdateHTLCs {
6624+
node_id,
6625+
updates,
6626+
});
6627+
}
6628+
if let Some(msg) = msgs.funding_signed {
6629+
pending_msg_events.push(events::MessageSendEvent::SendFundingSigned {
6630+
node_id,
6631+
msg,
6632+
});
6633+
}
6634+
if let Some(msg) = msgs.funding_created {
6635+
pending_msg_events.push(events::MessageSendEvent::SendFundingCreated {
6636+
node_id,
6637+
msg,
6638+
});
6639+
}
66376640
}
66386641
};
66396642

lightning/src/ln/functional_test_utils.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -427,16 +427,10 @@ impl<'a, 'b, 'c> Node<'a, 'b, 'c> {
427427
let per_peer_state = self.node.per_peer_state.read().unwrap();
428428
let chan_lock = per_peer_state.get(peer_id).unwrap().lock().unwrap();
429429
let signer = (|| {
430-
if let Some(local_chan) = chan_lock.channel_by_id.get(chan_id) {
431-
return local_chan.get_signer();
430+
match chan_lock.channel_by_id.get(chan_id) {
431+
Some(phase) => phase.context().get_signer(),
432+
None => panic!("Couldn't find a channel with id {}", chan_id),
432433
}
433-
if let Some(local_chan) = chan_lock.inbound_v1_channel_by_id.get(chan_id) {
434-
return local_chan.context.get_signer();
435-
}
436-
if let Some(local_chan) = chan_lock.outbound_v1_channel_by_id.get(chan_id) {
437-
return local_chan.context.get_signer();
438-
}
439-
panic!("Couldn't find a channel with id {}", chan_id);
440434
})();
441435
log_debug!(self.logger, "Setting channel signer for {} as available={}", chan_id, available);
442436
signer.as_ecdsa().unwrap().set_available(available);

0 commit comments

Comments
 (0)