This paper presents a comprehensive survey of the security and privacy aspects of Bitcoin, a popular cryptocurrency that operates on a distributed blockchain. Bitcoin's security relies on the incentive-compatible proof-of-work (PoW) consensus protocol, which is maintained by network nodes called miners. The paper begins by providing an overview of the Bitcoin protocol and its major components, including transactions, blockchain, and consensus mechanisms. It then reviews existing vulnerabilities in Bitcoin and its underlying technologies, such as blockchain and PoW-based consensus, which can lead to various security threats. The paper discusses the feasibility and robustness of state-of-the-art security solutions and current privacy considerations in Bitcoin, including the analysis of privacy-preserving solutions. Finally, it summarizes critical open challenges and suggests directions for future research to enhance Bitcoin's security and privacy. The contributions of the paper include a detailed background on Bitcoin, a systematic discussion of security and privacy threats, and an analysis of existing solutions. The paper aims to assist readers in understanding the scope and impact of security and privacy challenges in Bitcoin and to provide insights into potential countermeasures.This paper presents a comprehensive survey of the security and privacy aspects of Bitcoin, a popular cryptocurrency that operates on a distributed blockchain. Bitcoin's security relies on the incentive-compatible proof-of-work (PoW) consensus protocol, which is maintained by network nodes called miners. The paper begins by providing an overview of the Bitcoin protocol and its major components, including transactions, blockchain, and consensus mechanisms. It then reviews existing vulnerabilities in Bitcoin and its underlying technologies, such as blockchain and PoW-based consensus, which can lead to various security threats. The paper discusses the feasibility and robustness of state-of-the-art security solutions and current privacy considerations in Bitcoin, including the analysis of privacy-preserving solutions. Finally, it summarizes critical open challenges and suggests directions for future research to enhance Bitcoin's security and privacy. The contributions of the paper include a detailed background on Bitcoin, a systematic discussion of security and privacy threats, and an analysis of existing solutions. The paper aims to assist readers in understanding the scope and impact of security and privacy challenges in Bitcoin and to provide insights into potential countermeasures.