Skip to content

Commit e092228

Browse files
committed
Handle sending open_channel when signer is unblocked
1 parent 0a01e41 commit e092228

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

lightning/src/ln/channel.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7734,11 +7734,26 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
77347734
/// Indicates that the signer may have some signatures for us, so we should retry if we're
77357735
/// blocked.
77367736
#[cfg(async_signing)]
7737-
pub fn signer_maybe_unblocked<L: Deref>(&mut self, logger: &L) -> Option<msgs::FundingCreated> where L::Target: Logger {
7738-
if self.context.signer_pending_funding && self.context.is_outbound() {
7737+
pub fn signer_maybe_unblocked<L: Deref>(&mut self, chain_hash: ChainHash, logger: &L) -> (Option<msgs::OpenChannel>, Option<msgs::FundingCreated>)
7738+
where L::Target: Logger
7739+
{
7740+
// If we were pending a commitment point, retry the signer and advance to an
7741+
// available state.
7742+
if !self.context.holder_commitment_point.is_available() {
7743+
self.context.holder_commitment_point.advance(&self.context.holder_signer, &self.context.secp_ctx, logger);
7744+
}
7745+
let open_channel = if self.signer_pending_open_channel && self.context.holder_commitment_point.is_available() {
7746+
self.get_open_channel(chain_hash, logger).map(|msg| {
7747+
log_trace!(logger, "Signer unblocked an open_channel; clearing signer_pending_open_channel");
7748+
self.signer_pending_open_channel = false;
7749+
msg
7750+
})
7751+
} else { None };
7752+
let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
77397753
log_trace!(logger, "Signer unblocked a funding_created");
77407754
self.get_funding_created_msg(logger)
7741-
} else { None }
7755+
} else { None };
7756+
(open_channel, funding_created)
77427757
}
77437758
}
77447759

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8126,7 +8126,14 @@ where
81268126
}
81278127
}
81288128
ChannelPhase::UnfundedOutboundV1(chan) => {
8129-
if let Some(msg) = chan.signer_maybe_unblocked(&self.logger) {
8129+
let (open_channel, funding_created) = chan.signer_maybe_unblocked(self.chain_hash.clone(), &self.logger);
8130+
if let Some(msg) = open_channel {
8131+
pending_msg_events.push(events::MessageSendEvent::SendOpenChannel {
8132+
node_id,
8133+
msg,
8134+
});
8135+
}
8136+
if let Some(msg) = funding_created {
81308137
pending_msg_events.push(events::MessageSendEvent::SendFundingCreated {
81318138
node_id,
81328139
msg,

0 commit comments

Comments
 (0)