Skip to content

Commit 157618a

Browse files
committed
Handle sending open_channel when signer is unblocked
1 parent 44f61af commit 157618a

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

lightning/src/ln/channel.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -7934,11 +7934,24 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
79347934
/// Indicates that the signer may have some signatures for us, so we should retry if we're
79357935
/// blocked.
79367936
#[cfg(async_signing)]
7937-
pub fn signer_maybe_unblocked<L: Deref>(&mut self, logger: &L) -> Option<msgs::FundingCreated> where L::Target: Logger {
7938-
if self.context.signer_pending_funding && self.context.is_outbound() {
7939-
log_trace!(logger, "Signer unblocked a funding_created");
7937+
pub fn signer_maybe_unblocked<L: Deref>(&mut self, chain_hash: ChainHash, logger: &L) -> (Option<msgs::OpenChannel>, Option<msgs::FundingCreated>)
7938+
where L::Target: Logger
7939+
{
7940+
// If we were pending a commitment point, retry the signer and advance to an
7941+
// available state.
7942+
if !self.context.holder_commitment_point.is_available() {
7943+
self.context.holder_commitment_point.try_resolve_pending(&self.context.holder_signer, &self.context.secp_ctx, logger);
7944+
}
7945+
let open_channel = if self.signer_pending_open_channel && self.context.holder_commitment_point.is_available() {
7946+
log_trace!(logger, "Attempting to generate open_channel...");
7947+
self.get_open_channel(chain_hash, logger)
7948+
} else { None };
7949+
let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
7950+
log_trace!(logger, "Attempting to generate pending funding created...");
7951+
self.context.signer_pending_funding = false;
79407952
self.get_funding_created_msg(logger)
7941-
} else { None }
7953+
} else { None };
7954+
(open_channel, funding_created)
79427955
}
79437956
}
79447957

lightning/src/ln/channelmanager.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -8499,7 +8499,14 @@ where
84998499
}
85008500
}
85018501
ChannelPhase::UnfundedOutboundV1(chan) => {
8502-
if let Some(msg) = chan.signer_maybe_unblocked(&self.logger) {
8502+
let (open_channel, funding_created) = chan.signer_maybe_unblocked(self.chain_hash.clone(), &self.logger);
8503+
if let Some(msg) = open_channel {
8504+
pending_msg_events.push(events::MessageSendEvent::SendOpenChannel {
8505+
node_id,
8506+
msg,
8507+
});
8508+
}
8509+
if let Some(msg) = funding_created {
85038510
pending_msg_events.push(events::MessageSendEvent::SendFundingCreated {
85048511
node_id,
85058512
msg,

0 commit comments

Comments
 (0)