Skip to content

Commit 423a1b6

Browse files
committed
Handle sending open_channel when signer is unblocked
1 parent c6d76c9 commit 423a1b6

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

lightning/src/ln/channel.rs

+25-4
Original file line numberDiff line numberDiff line change
@@ -7966,11 +7966,32 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
79667966
/// Indicates that the signer may have some signatures for us, so we should retry if we're
79677967
/// blocked.
79687968
#[cfg(async_signing)]
7969-
pub fn signer_maybe_unblocked<L: Deref>(&mut self, logger: &L) -> Option<msgs::FundingCreated> where L::Target: Logger {
7970-
if self.context.signer_pending_funding && self.context.is_outbound() {
7971-
log_trace!(logger, "Signer unblocked a funding_created");
7969+
pub fn signer_maybe_unblocked<L: Deref>(&mut self, chain_hash: ChainHash, logger: &L) -> (Option<msgs::OpenChannel>, Option<msgs::FundingCreated>)
7970+
where L::Target: Logger
7971+
{
7972+
// If we were pending a commitment point, retry the signer and advance to an
7973+
// available state.
7974+
if self.unfunded_context.holder_commitment_point.is_none() {
7975+
self.unfunded_context.holder_commitment_point = HolderCommitmentPoint::new(&self.context.holder_signer, &self.context.secp_ctx);
7976+
}
7977+
if let Some(ref mut point) = self.unfunded_context.holder_commitment_point {
7978+
if !point.is_available() {
7979+
point.try_resolve_pending(&self.context.holder_signer, &self.context.secp_ctx, logger);
7980+
}
7981+
}
7982+
let open_channel = match self.unfunded_context.holder_commitment_point {
7983+
Some(ref mut point) if point.is_available() && self.signer_pending_open_channel => {
7984+
log_trace!(logger, "Attempting to generate open_channel...");
7985+
self.get_open_channel(chain_hash, logger)
7986+
}
7987+
_ => None
7988+
};
7989+
let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
7990+
log_trace!(logger, "Attempting to generate pending funding created...");
7991+
self.context.signer_pending_funding = false;
79727992
self.get_funding_created_msg(logger)
7973-
} else { None }
7993+
} else { None };
7994+
(open_channel, funding_created)
79747995
}
79757996
}
79767997

lightning/src/ln/channelmanager.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -8866,7 +8866,14 @@ where
88668866
msgs.shutdown_result
88678867
}
88688868
ChannelPhase::UnfundedOutboundV1(chan) => {
8869-
if let Some(msg) = chan.signer_maybe_unblocked(&self.logger) {
8869+
let (open_channel, funding_created) = chan.signer_maybe_unblocked(self.chain_hash.clone(), &self.logger);
8870+
if let Some(msg) = open_channel {
8871+
pending_msg_events.push(events::MessageSendEvent::SendOpenChannel {
8872+
node_id,
8873+
msg,
8874+
});
8875+
}
8876+
if let Some(msg) = funding_created {
88708877
pending_msg_events.push(events::MessageSendEvent::SendFundingCreated {
88718878
node_id,
88728879
msg,

0 commit comments

Comments
 (0)