Skip to content

Commit 7f02198

Browse files
committed
Return early on duplicate calls to funding_transaction_signed
We may produce duplicate `FundingTransactionReadyForSigning` events if the user has processed an initial event but has not yet called back with `funding_transaction_signed` and a peer reconnection occurs. If the user also handles the duplicate events, any duplicate calls to `funding_transaction_signed` after an initial successful one would return an error. This doesn't make sense, as the API should remain idempotent, so we return early on any duplicate calls.
1 parent fec434b commit 7f02198

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8678,8 +8678,19 @@ where
86788678
.unwrap_or(false));
86798679
}
86808680

8681+
if signing_session.holder_tx_signatures().is_some() {
8682+
// Our `tx_signatures` either should've been the first time we processed them,
8683+
// or we're waiting for our counterparty to send theirs first.
8684+
return Ok((None, None));
8685+
}
8686+
86818687
signing_session
86828688
} else {
8689+
if Some(funding_txid_signed) == self.funding.get_funding_txid() {
8690+
// We may be handling a duplicate call and the funding was already locked so we
8691+
// no longer have the signing session present.
8692+
return Ok((None, None));
8693+
}
86838694
let err =
86848695
format!("Channel {} not expecting funding signatures", self.context.channel_id);
86858696
return Err(APIError::APIMisuseError { err });

0 commit comments

Comments
 (0)