refactor: Add missing explicit instantiations of function templates
What changed, and why it matters
This is a build-fixing code cleanup, not a security patch. It adds explicit template instantiations for two internal signature-calculation functions so that the project links correctly with newer Clang compilers. There is no change to behavior, no bug fix, and no security relevance.
No security action required. Treat as a normal build/maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit adds explicit template instantiations for SignatureHashSchnorr<CTransaction/CMutableTransaction> and SignatureHash<CTransaction/CMutableTransaction> in src/script/interpreter.cpp. These function templates are defined in this translation unit and used from others; previously the build relied on implicit instantiations being emitted, which the C++ standard does not guarantee. Clang 24’s module-local optimizer (from llvm/llvm-project#238529) exposed this as a linker error. The patch is purely a build/standards-compliance refactor with no functional change.
Changed components
src/script/interpreter.cppInspect captured patch +8 / −0
### src/script/interpreter.cpp
@@ -1575,6 +1575,10 @@ bool SignatureHashSchnorr(uint256& hash_out, ScriptExecutionData& execdata, cons
return true;
}
+// explicit instantiation
+template bool SignatureHashSchnorr<CTransaction>(uint256&, ScriptExecutionData&, const CTransaction&, uint32_t, uint8_t, SigVersion, const PrecomputedTransactionData&, MissingDataBehavior);
+template bool SignatureHashSchnorr<CMutableTransaction>(uint256&, ScriptExecutionData&, const CMutableTransaction&, uint32_t, uint8_t, SigVersion, const PrecomputedTransactionData&, MissingDataBehavior);
+
int SigHashCache::CacheIndex(int32_t hash_type) const noexcept
{
// Note that we do not distinguish between BASE and WITNESS_V0 to determine the cache index,
@@ -1682,6 +1686,10 @@ uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn
return ss.GetHash();
}
+// explicit instantiation
+template uint256 SignatureHash<CTransaction>(const CScript&, const CTransaction&, unsigned int, int32_t, const CAmount&, SigVersion, const PrecomputedTransactionData*, SigHashCache*);
+template uint256 SignatureHash<CMutableTransaction>(const CScript&, const CMutableTransaction&, unsigned int, int32_t, const CAmount&, SigVersion, const PrecomputedTransactionData*, SigHashCache*);
+
template <class T>
bool GenericTransactionSignatureChecker<T>::VerifyECDSASignature(const std::vector<unsigned char>& vchSig, const CPubKey& pubkey, const uint256& sighash) const
{Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.