Wireless Sensor Networks (WSNs) are broadly applied for various applications in tracking and surveillance due to their ease of use and other distinctive characteristics compelled by real-time cooperation among the sensor nodes. In WSNs, security is becoming a critical issue, as the techniques for malicious node detection adopt a one-time, centralized decision-making approach. With this paradigm, errors are difficult to avoid, and reproducibility and traceability are challenging. Hence, malicious node discovery technologies in conventional WSNs cannot assure traceability and fairness of the detection method. Herein, this paper discusses an in-depth survey of a blockchain-based approach for malicious node detection, an exhaustive examination of the integration of blockchain techniques with WSNs (BWSN), and insights into this novel concept. This survey discusses the architecture, sector-wise applications, and uses of BWSN. Moreover, this survey describes malicious node detection based on BWSN in two parts: 1) the BWSN architecture for detecting the malicious nodes and 2) the smart contract aspects in malicious node detection. Next, this survey explains the contributions of blockchain for WSN data management, which involves online information aggregation and may include auditing, event logs, and storage for information analysis and offline query processing. This survey first presents the conventional WSN solutions then the blockchain-based WSN solutions for data management. Additionally, this survey discusses the contributions of blockchain for WSN security management. It first examines the centralized WSN models for security problems, followed by a discussion of the blockchain-based WSN solutions for security management, such as offering access control, preserving information integrity, guaranteeing privacy, and ensuring WSNs' node longevity.