Skip to content

Commit c761a59

Browse files
committed
Move clearing signer signer flags to signer_unblocked
This attempts to refine the signer pending flag mutations + move some signer flag logic into the `signer_unblocked` method instead of our other lightning logic. Before flow: - Call function that asks for signature - if absent, sets signer pending flag - if present, clear signer pending flag - Call `signer_unblocked` -> call the function again, and it'll set the flags again depending on the result After flow: - Call function that asks for signature - if absent, sets signer pending flag - Call `signer_unblocked` -> clear the signer pending flag -> call the function again, and it only resets the flag if unsuccessful This moves the logic for all async commitment signatures, i.e. funding_created, funding_signed, and commitment_signed.
1 parent 3ccf064 commit c761a59

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

lightning/src/ln/channel.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3473,9 +3473,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
34733473
log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
34743474
self.signer_pending_funding = true;
34753475
}
3476-
} else if self.signer_pending_funding {
3477-
log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding");
3478-
self.signer_pending_funding = false;
34793476
}
34803477

34813478
// We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
@@ -5377,9 +5374,13 @@ impl<SP: Deref> Channel<SP> where
53775374
#[cfg(async_signing)]
53785375
pub fn signer_maybe_unblocked<L: Deref>(&mut self, logger: &L) -> SignerResumeUpdates where L::Target: Logger {
53795376
let commitment_update = if self.context.signer_pending_commitment_update {
5377+
log_trace!(logger, "Attempting to generate pending commitment update...");
5378+
self.context.signer_pending_commitment_update = false;
53805379
self.get_last_commitment_update_for_send(logger).ok()
53815380
} else { None };
53825381
let funding_signed = if self.context.signer_pending_funding && !self.context.is_outbound() {
5382+
log_trace!(logger, "Attempting to generate pending funding signed...");
5383+
self.context.signer_pending_funding = false;
53835384
self.context.get_funding_signed_msg(logger).1
53845385
} else { None };
53855386
let channel_ready = if funding_signed.is_some() {
@@ -5475,10 +5476,6 @@ impl<SP: Deref> Channel<SP> where
54755476
&self.context.channel_id(), if update_fee.is_some() { " update_fee," } else { "" },
54765477
update_add_htlcs.len(), update_fulfill_htlcs.len(), update_fail_htlcs.len(), update_fail_malformed_htlcs.len());
54775478
let commitment_signed = if let Ok(update) = self.send_commitment_no_state_update(logger).map(|(cu, _)| cu) {
5478-
if self.context.signer_pending_commitment_update {
5479-
log_trace!(logger, "Commitment update generated: clearing signer_pending_commitment_update");
5480-
self.context.signer_pending_commitment_update = false;
5481-
}
54825479
update
54835480
} else {
54845481
#[cfg(not(async_signing))] {
@@ -7494,11 +7491,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
74947491
_ => todo!()
74957492
};
74967493

7497-
if self.context.signer_pending_funding {
7498-
log_trace!(logger, "Counterparty commitment signature ready for funding_created message: clearing signer_pending_funding");
7499-
self.context.signer_pending_funding = false;
7500-
}
7501-
75027494
Some(msgs::FundingCreated {
75037495
temporary_channel_id: self.context.temporary_channel_id.unwrap(),
75047496
funding_txid: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
@@ -7747,7 +7739,8 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
77477739
#[cfg(async_signing)]
77487740
pub fn signer_maybe_unblocked<L: Deref>(&mut self, logger: &L) -> Option<msgs::FundingCreated> where L::Target: Logger {
77497741
if self.context.signer_pending_funding && self.context.is_outbound() {
7750-
log_trace!(logger, "Signer unblocked a funding_created");
7742+
log_trace!(logger, "Attempting to generate pending funding created...");
7743+
self.context.signer_pending_funding = false;
77517744
self.get_funding_created_msg(logger)
77527745
} else { None }
77537746
}

0 commit comments

Comments
 (0)