From 0fc0beca0e5995a515e2c36ee261c14642571dfb Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sat, 21 Dec 2024 01:35:15 +0300 Subject: [PATCH] fix: refuse to create new clsig if we switched to a different fork while we were signing --- src/llmq/chainlocks.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/llmq/chainlocks.cpp b/src/llmq/chainlocks.cpp index 1b6f56f5c8632..bdde25b2f646c 100644 --- a/src/llmq/chainlocks.cpp +++ b/src/llmq/chainlocks.cpp @@ -519,7 +519,11 @@ MessageProcessingResult CChainLocksHandler::HandleNewRecoveredSig(const llmq::CR // already got the same or a better CLSIG through the CLSIG message return {}; } - + const auto pindex = m_chainstate.m_chain.Tip()->GetAncestor(lastSignedHeight); + if (pindex == nullptr || pindex->GetBlockHash() != lastSignedMsgHash) { + // we switched to a different fork while we were signing + return {}; + } clsig = CChainLockSig(lastSignedHeight, lastSignedMsgHash, recoveredSig.sig.Get()); }