<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>C++ &#8211; @Forensicxs</title>
	<atom:link href="https://www.forensicxs.com/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.forensicxs.com</link>
	<description>Ethical Hacking &#124; Cybersecurity</description>
	<lastBuildDate>Fri, 09 Aug 2024 10:43:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Bitcoin Core v0.1 : a code walkthrough</title>
		<link>https://www.forensicxs.com/bitcoin-core-v0-1-a-code-walkthrough/</link>
					<comments>https://www.forensicxs.com/bitcoin-core-v0-1-a-code-walkthrough/#respond</comments>
		
		<dc:creator><![CDATA[Forensicxs]]></dc:creator>
		<pubDate>Tue, 06 Aug 2024 14:56:38 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Bitcoin]]></category>
		<category><![CDATA[Bitcoin Core v0.1]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Satoshi Nakamoto]]></category>
		<guid isPermaLink="false">https://www.forensicxs.com/?p=3112</guid>

					<description><![CDATA[I have chosen to write a code explanation of the initial version of bitcoin, akka bitcoin v0.1. I hope it helps you to understand better the fundational concepts behind bitcoin, and get an overview how bitcoin actually works behind the scene. Thus, I hope it helps to provide you the necessary confidence to become a &#8230; <p class="link-more"><a href="https://www.forensicxs.com/bitcoin-core-v0-1-a-code-walkthrough/" class="more-link">Continue reading<span class="screen-reader-text"> "Bitcoin Core v0.1 : a code walkthrough"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<p style="font-size:17px">I have chosen to write a code explanation of the initial version of bitcoin, akka <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bitcoin v0.1</mark></strong>. I hope it helps you to understand better the fundational concepts behind bitcoin, and get an overview how bitcoin actually works behind the scene. Thus, I hope it helps to provide you the necessary confidence to become a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">long term investor</mark></strong> in bitcoin</p>



<p style="font-size:17px">The bitcoin v0.1 code is available here : <a href="https://tinyurl.com/k24m7p9c">https://tinyurl.com/k24m7p9c</a>. It is written mainly in <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">C++</mark></strong></p>



<p>It is released under the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">MIT X11 licence</mark></strong>, that means anyone can copy and modify it</p>



<figure class="wp-block-image size-full is-resized"><img fetchpriority="high" decoding="async" width="901" height="253" src="https://www.forensicxs.com/wp-content/uploads/2024/07/image.png" alt="" class="wp-image-3117" style="width:495px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/07/image.png 901w, https://www.forensicxs.com/wp-content/uploads/2024/07/image-300x84.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/07/image-768x216.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p style="font-size:17px">The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bitcoin Core</mark></strong> software <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">.exe</mark></strong> can be launched here : <a href="https://tinyurl.com/3ttejt9w">https://tinyurl.com/3ttejt9w</a></p>



<p>There are two <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">.dll</mark></strong> files included : </p>



<ul class="wp-block-list">
<li>libeay32.dll -&gt; this is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">OpenSSL</mark></strong> encryption library, used by the .exe to create the encryption keys</li>



<li>mingwm10.dll -&gt; it is a free and open source Windows port of the GCC compiler. It is necessary to launch <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Qt</mark></strong>, which powers the GUI &#8220;Graphical User Interface&#8221; engine used by the .exe</li>
</ul>



<p>The bitcoin Core is mainly usefull to send bitcoin from one address to another address, without any intermediary</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="859" height="596" src="https://www.forensicxs.com/wp-content/uploads/2024/07/image-1.png" alt="" class="wp-image-3118" style="width:534px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/07/image-1.png 859w, https://www.forensicxs.com/wp-content/uploads/2024/07/image-1-300x208.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/07/image-1-768x533.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">Code summary</mark></strong></p>



<p>Now let&#8217;s go through the code. I have created a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">summary table</mark></strong>, to provide an overview, before going into the details of each file</p>



<p>Overall, bitcoin core v0.1 has <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">31 794 lines of code</mark></strong>. The biggest files being the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">GUI</mark></strong> management (Graphical User Interface) &#8211; by far the biggest &#8211; and the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">blockchain</mark></strong> operation (blocks, proof of work, cryptography). All the other files are much smaller but also an essential part of the software</p>



<figure class="wp-block-table is-style-regular has-small-font-size"><table><thead><tr><th class="has-text-align-center" data-align="center">          File</th><th class="has-text-align-center" data-align="center">                 Lines</th><th class="has-text-align-left" data-align="left">                                                                                  Purpose</th><th class="has-text-align-center" data-align="center">% of total lines</th></tr></thead><tbody><tr><td class="has-text-align-center" data-align="center">base58.h</td><td class="has-text-align-center" data-align="center">201</td><td class="has-text-align-left" data-align="left">Implements <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">base58</mark></strong> encoding and decoding functionalities specifically used for bitcoin addresses. base58 is a specific variant of base64 encoding that avoids visually similar characters and aims to produce more user-friendly output. The code includes methods for encoding and decoding both standard and checksum-enhanced base58 representations of bitcoin<mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-black-color"> </mark><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">addresses</mark></strong></td><td class="has-text-align-center" data-align="center">1%</td></tr><tr><td class="has-text-align-center" data-align="center">bignum.h</td><td class="has-text-align-center" data-align="center">498</td><td class="has-text-align-left" data-align="left">This code involves the definition and implementation of several classes and functions that deal with precision arithmetics for cryptographic applications. This kind of functionality is critical in blockchain technology, cryptocurrencies, and any applications that require handling<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"> large integers</mark></strong>, such as those used in cryptography</td><td class="has-text-align-center" data-align="center">2%</td></tr><tr><td class="has-text-align-center" data-align="center">db.cpp</td><td class="has-text-align-center" data-align="center">604</td><td class="has-text-align-left" data-align="left">This code focuses on<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"> database </mark></strong>operations for managing transactions, addresses, and wallets. It includes functionality for initializing the database, reading and writing to it, and managing the wallet&#8217;s state</td><td class="has-text-align-center" data-align="center">2%</td></tr><tr><td class="has-text-align-center" data-align="center">db.h</td><td class="has-text-align-center" data-align="center">420</td><td class="has-text-align-left" data-align="left">This code focuses on <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">database </mark></strong>operations for managing transactions, addresses, and wallets. It includes functionality for initializing the database, reading and writing to it, and managing the wallet&#8217;s state</td><td class="has-text-align-center" data-align="center">1%</td></tr><tr><td class="has-text-align-center" data-align="center">headers.h</td><td class="has-text-align-center" data-align="center">71</td><td class="has-text-align-left" data-align="left">This code <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">imports</mark></strong> many important <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">libraries</mark></strong> and links the .h files together. It is a small file but an essential part</td><td class="has-text-align-center" data-align="center">0%</td></tr><tr><td class="has-text-align-center" data-align="center">irc.cpp</td><td class="has-text-align-center" data-align="center"><br>265<br></td><td class="has-text-align-left" data-align="left">This code provides the infrastructure for managing <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">network </mark></strong>communications using <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">IRC</mark></strong>. The encoding and decoding functions ensure that addresses are processed safely and effectively, while the variant functions for sending and receiving data handle the specifics of socket communication. The threaded operation allows for asynchronous processing of network events, necessary in the context of real time and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">peer to peer</mark></strong> transactions</td><td class="has-text-align-center" data-align="center">1%<br></td></tr><tr><td class="has-text-align-center" data-align="center">irc.h</td><td class="has-text-align-center" data-align="center">7</td><td class="has-text-align-left" data-align="left">This code is the header file of irc.cpp and is important to implement <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">asynchronous</mark></strong> connections and the network <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">decentralization</mark></strong></td><td class="has-text-align-center" data-align="center">0%</td></tr><tr><td class="has-text-align-center" data-align="center">key.h</td><td class="has-text-align-center" data-align="center">156</td><td class="has-text-align-left" data-align="left">This code defines the cryptographic key management system, using <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">elliptic curve</mark></strong> digital signature algorithm (ECDSA)</td><td class="has-text-align-center" data-align="center">0%</td></tr><tr><td class="has-text-align-center" data-align="center">main.cpp</td><td class="has-text-align-center" data-align="center">2660</td><td class="has-text-align-left" data-align="left">This code implements the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">blockchain</mark></strong> management of transactions, wallets, and blocks. It employs locking mechanisms to prevent data corruption in concurrent environments and maintains an <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">in-memory</mark></strong> database to facilitate quick access and updates</td><td class="has-text-align-center" data-align="center">8%</td></tr><tr><td class="has-text-align-center" data-align="center">main.h</td><td class="has-text-align-center" data-align="center">1297</td><td class="has-text-align-left" data-align="left">This code is the header file of main.cpp. The implementation includes mechanisms for <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">memory</mark></strong> management, transaction validation, and persistence in a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">database</mark></strong></td><td class="has-text-align-center" data-align="center">4%</td></tr><tr><td class="has-text-align-center" data-align="center">makefile</td><td class="has-text-align-center" data-align="center">83</td><td class="has-text-align-left" data-align="left">The provided code is designed to automate the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">compilation</mark></strong> and linking process, defining how to build the application, manage dependencies, and specify settings for the compiler</td><td class="has-text-align-center" data-align="center">0%</td></tr><tr><td class="has-text-align-center" data-align="center">makefile.vc</td><td class="has-text-align-center" data-align="center">77</td><td class="has-text-align-left" data-align="left">This file is used by makefile for building the bitcoin Windows application. It uses Microsoft Visual C++ compiler commands, preprocessor directives, and settings for linking with various libraries such as OpenSSL, wxWidgets, and Berkeley DB</td><td class="has-text-align-center" data-align="center">0%</td></tr><tr><td class="has-text-align-center" data-align="center">market.cpp</td><td class="has-text-align-center" data-align="center">264</td><td class="has-text-align-left" data-align="left">This is a partially completed distributed <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">market place</mark></strong>. It was not implemented in later versions of bitcoin core</td><td class="has-text-align-center" data-align="center">1%</td></tr><tr><td class="has-text-align-center" data-align="center">market.h</td><td class="has-text-align-center" data-align="center">182</td><td class="has-text-align-left" data-align="left">It is the header file of market.cpp. It ensures the market place can <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">securely</mark></strong> identify users and verify actions within the application</td><td class="has-text-align-center" data-align="center">1%</td></tr><tr><td class="has-text-align-center" data-align="center">net.cpp</td><td class="has-text-align-center" data-align="center">1020</td><td class="has-text-align-left" data-align="left">The code ensures that the application can reliably communicate over the peer to peer <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">network</mark></strong>, establish connection threads, and terminate operations when required</td><td class="has-text-align-center" data-align="center">3%</td></tr><tr><td class="has-text-align-center" data-align="center">net.h</td><td class="has-text-align-center" data-align="center">856</td><td class="has-text-align-left" data-align="left">This is the header file of net.cpp, implementing the communication between network <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">nodes</mark></strong></td><td class="has-text-align-center" data-align="center">3%</td></tr><tr><td class="has-text-align-center" data-align="center">script.cpp</td><td class="has-text-align-center" data-align="center">1127</td><td class="has-text-align-left" data-align="left">Bitcoin is programmable money. Bitcoin core uses <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">scripts</mark></strong> that are run into a stack, and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">opcodes</mark></strong> are the underlying operations that help build the bitcoin scripts</td><td class="has-text-align-center" data-align="center">4%</td></tr><tr><td class="has-text-align-center" data-align="center">script.h</td><td class="has-text-align-center" data-align="center">597</td><td class="has-text-align-left" data-align="left">This is the header file of script.cpp. It defines the conditions under which <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">funds</mark></strong> can be unlocked and spent</td><td class="has-text-align-center" data-align="center">2%</td></tr><tr><td class="has-text-align-center" data-align="center">serialize.h</td><td class="has-text-align-center" data-align="center">1151</td><td class="has-text-align-left" data-align="left">This code implements <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">serialization</mark></strong>. The code converts objects of a particular class into a stream of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bytes</mark></strong>. It is used to store it in memory or transmit it over the network</td><td class="has-text-align-center" data-align="center">4%</td></tr><tr><td class="has-text-align-center" data-align="center">shap.cpp</td><td class="has-text-align-center" data-align="center">554</td><td class="has-text-align-left" data-align="left">This code is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hashing</mark></strong> utility and the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">cryptographic</mark></strong> foundation of bitcoin. Hash functions ensure that data is secure and allow users to verify the integrity of transaction data</td><td class="has-text-align-center" data-align="center">2%</td></tr><tr><td class="has-text-align-center" data-align="center">sha.h</td><td class="has-text-align-center" data-align="center">177</td><td class="has-text-align-left" data-align="left">This is the header file of sha.cpp. It is essential for initializing <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hash states</mark></strong>, transforming data for hashing, and byte order manipulation</td><td class="has-text-align-center" data-align="center">1%</td></tr><tr><td class="has-text-align-center" data-align="center">ui.cpp</td><td class="has-text-align-center" data-align="center">3228</td><td class="has-text-align-left" data-align="left">This code implements the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">GUI</mark></strong> (Graphical User Interface). It uses the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">wxWidgets</mark></strong> library. The code includes several classes that represent different dialogs and interactions within the application, such as sending money and managing an address book</td><td class="has-text-align-center" data-align="center">10%</td></tr><tr><td class="has-text-align-center" data-align="center">ui.h</td><td class="has-text-align-center" data-align="center">412</td><td class="has-text-align-left" data-align="left">This is the header file of ui.cpp</td><td class="has-text-align-center" data-align="center">1%</td></tr><tr><td class="has-text-align-center" data-align="center">ui.rc</td><td class="has-text-align-center" data-align="center">14</td><td class="has-text-align-left" data-align="left">This resource file declares various <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">graphical</mark></strong> assets utilized in wxWidgets</td><td class="has-text-align-center" data-align="center">0%</td></tr><tr><td class="has-text-align-center" data-align="center">uibase.cpp</td><td class="has-text-align-center" data-align="center">1806</td><td class="has-text-align-left" data-align="left">This file structures the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">GUI </mark></strong>elements, manages events and functionalities related to user inputs, such as sending bitcoin</td><td class="has-text-align-center" data-align="center">6%</td></tr><tr><td class="has-text-align-center" data-align="center">uibase.h</td><td class="has-text-align-center" data-align="center">720</td><td class="has-text-align-left" data-align="left">This header file defines several base dialog classes generated with <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">wxFormBuilder</mark></strong></td><td class="has-text-align-center" data-align="center">2%</td></tr><tr><td class="has-text-align-center" data-align="center">unint256.h</td><td class="has-text-align-center" data-align="center">750</td><td class="has-text-align-left" data-align="left">This code includes definitions for handling large integers using the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">uint256</mark></strong> class. This class is necessary for managing values that exceed the size of standard built-in data types, as is the case for bitcoin hashes and addresses</td><td class="has-text-align-center" data-align="center">2%</td></tr><tr><td class="has-text-align-center" data-align="center">uiproject.fbp</td><td class="has-text-align-center" data-align="center">11825</td><td class="has-text-align-left" data-align="left">This code is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">XML</mark></strong> representation of the wxWidgets. The XML format is used to describe various objects, properties, and events</td><td class="has-text-align-center" data-align="center">37%</td></tr><tr><td class="has-text-align-center" data-align="center">util.cpp</td><td class="has-text-align-center" data-align="center">373</td><td class="has-text-align-left" data-align="left">The code is responsible for various <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">utilities</mark></strong> in bitcoin, such as multithreading support for OpenSSL, generating random numbers, file management, time synchronization, and custom error handling</td><td class="has-text-align-center" data-align="center">1%</td></tr><tr><td class="has-text-align-center" data-align="center">util.h</td><td class="has-text-align-center" data-align="center">399</td><td class="has-text-align-left" data-align="left">This is the header file of util.cpp. It covers <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">type</mark></strong> definitions, error handling, hash functions, and more</td><td class="has-text-align-center" data-align="center">1%</td></tr></tbody></table></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">base58.h</mark></strong></p>



<p>This file implements base58 encoding and decoding functionalities specifically used for bitcoin addresses. Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">base58.h</mark></strong> : <a href="https://tinyurl.com/4j2rdrvj">https://tinyurl.com/4j2rdrvj</a></p>



<p>The first line defines the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">character set</mark></strong> for Base58 encoding. The characters&nbsp;<code>0</code>,&nbsp;<code>O</code>,&nbsp;<code>I</code>, and&nbsp;<code>l</code>&nbsp;are excluded to avoid visual ambiguity</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="926" height="57" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-31.png" alt="" class="wp-image-3174" style="width:640px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-31.png 926w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-31-300x18.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-31-768x47.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">EncodeBase58</mark></strong> encodes data into <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">base58</mark></strong> string format</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="788" height="26" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-32.png" alt="" class="wp-image-3175" style="width:642px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-32.png 788w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-32-300x10.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-32-768x25.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">EncodeBase58check</mark></strong> extends EncodeBase58 by appending a 4-byte hash (checksum) to the end of the data before encoding. This helps in verifying the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">integrity</mark></strong> of the address</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="749" height="201" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-33.png" alt="" class="wp-image-3176" style="width:548px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-33.png 749w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-33-300x81.png 300w" sizes="(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Hash160ToAddress</mark></strong> takes a hashed public key and prefixes it with a version byte before producing a Base58Check encoded string (<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bitcoin address</mark></strong>)</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="620" height="224" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-34.png" alt="" class="wp-image-3177" style="width:429px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-34.png 620w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-34-300x108.png 300w" sizes="(max-width: 620px) 100vw, 620px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">IsValidBitcoinAddress</mark></strong> checks whether a given address is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">valid</mark></strong> by attempting to decode it</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="603" height="250" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-35.png" alt="" class="wp-image-3178" style="width:447px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-35.png 603w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-35-300x124.png 300w" sizes="(max-width: 603px) 100vw, 603px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">PubKeyToAddress</mark></strong> converts a public key into its corresponding bitcoin <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">address</mark></strong> using Hash160 and Hash160ToAddress</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="704" height="103" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-36.png" alt="" class="wp-image-3179" style="width:556px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-36.png 704w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-36-300x44.png 300w" sizes="(max-width: 704px) 100vw, 704px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">bignum.h</mark></strong></p>



<p>This code is implemented to manage large integers in the cryptography component of bitcoin. Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">bignum.h</mark></strong> : <a href="https://tinyurl.com/43y92jb2">https://tinyurl.com/43y92jb2</a></p>



<ul class="wp-block-list">
<li>The code utilizes <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">OpenSSL big numbers</mark></strong> functionality</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="380" height="78" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-37.png" alt="" class="wp-image-3181" style="width:300px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-37.png 380w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-37-300x62.png 300w" sizes="(max-width: 380px) 100vw, 380px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CBigNum</mark></strong> is a custom class that inherits from OpenSSL bignum. It includes some important methods (constructors, arithmetic operations, conversion methods,&#8230;), and also operators overload and bitwise operations</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="431" height="181" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-38.png" alt="" class="wp-image-3182" style="width:308px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-38.png 431w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-38-300x126.png 300w" sizes="(max-width: 431px) 100vw, 431px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">serialize</mark></strong> methods allow for serialization and deserialization of CBigNum objects</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="693" height="328" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-39.png" alt="" class="wp-image-3183" style="width:530px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-39.png 693w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-39-300x142.png 300w" sizes="(max-width: 693px) 100vw, 693px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">db.cpp, db.h</mark></strong></p>



<p>This code focuses on database operations for managing transactions, addresses, and wallets. It includes functionality for initializing the database, reading and writing to it, and managing the wallet&#8217;s state. The database is based upon <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Berkeley DB</mark></strong> (<a href="https://tinyurl.com/mr2zb4hw">https://tinyurl.com/mr2zb4hw</a>)</p>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">db.cpp</mark></strong> file is here : <a href="https://tinyurl.com/3zfe8x4t">https://tinyurl.com/3zfe8x4t</a></p>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">DbEnv</mark></strong> is an object representing the Berkeley DB environmnt</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="261" height="29" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-40.png" alt="" class="wp-image-3184" style="width:193px;height:auto"/></figure>



<ul class="wp-block-list">
<li> The class <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CDBInit</mark></strong> <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">initializes</mark></strong> the database environment in its constructor</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="514" height="403" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-41.png" alt="" class="wp-image-3185" style="width:329px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-41.png 514w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-41-300x235.png 300w" sizes="(max-width: 514px) 100vw, 514px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CDB constructor</mark></strong> tries to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">open</mark></strong> a database file with the specified mode (r, w, c, etc.) and initializes various settings associated with the BDB environment</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="725" height="376" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-42.png" alt="" class="wp-image-3187" style="width:502px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-42.png 725w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-42-300x156.png 300w" sizes="(max-width: 725px) 100vw, 725px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CTxDB class</mark></strong> handles <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">transaction</mark></strong> data in the database (reading, updating, deleting transaction entries based on their hashes)</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="662" height="153" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-43.png" alt="" class="wp-image-3188" style="width:505px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-43.png 662w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-43-300x69.png 300w" sizes="(max-width: 662px) 100vw, 662px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CAddrDB</mark></strong> class is responsible to manage addresses in the database (write new addresses, load existing ones)</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="672" height="625" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-44.png" alt="" class="wp-image-3189" style="width:512px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-44.png 672w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-44-300x279.png 300w" sizes="(max-width: 672px) 100vw, 672px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CWalletDB</mark></strong> class manages <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">wallet</mark></strong> data, including reading and writing wallet entries, such as addresses and transactions</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="514" height="104" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-45.png" alt="" class="wp-image-3190" style="width:414px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-45.png 514w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-45-300x61.png 300w" sizes="(max-width: 514px) 100vw, 514px" /></figure>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">db.h</mark></strong> file is here : <a href="https://tinyurl.com/ea39pj4s">https://tinyurl.com/ea39pj4s</a></p>



<ul class="wp-block-list">
<li>The code starts by including the Berkeley DB <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">header</mark></strong> and classes used throughout the database operations. It uses several external variables for managing the address book, client status, and database environment configuration</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="617" height="427" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-46.png" alt="" class="wp-image-3191" style="width:446px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-46.png 617w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-46-300x208.png 300w" sizes="(max-width: 617px) 100vw, 617px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CDB class</mark></strong> is defined, with a constructor taking the file name and opening the BD database, and handling transactions in argument, and with a destructor closing the database. </li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="782" height="354" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-47.png" alt="" class="wp-image-3192" style="width:519px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-47.png 782w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-47-300x136.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-47-768x348.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CTxDB</mark></strong> class manages transaction metadata</li>
</ul>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="602" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-48-1024x602.png" alt="" class="wp-image-3193" style="width:636px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-48-1024x602.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-48-300x176.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-48-768x452.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-48.png 1029w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">headers.h</mark></strong></p>



<p>This code <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">imports</mark></strong> many important <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">libraries</mark></strong> and links the .h files together. Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">headers.h</mark></strong> :  <a href="https://tinyurl.com/yerp5r9s">https://tinyurl.com/yerp5r9s</a></p>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Preprocessor</mark></strong> directives</li>
</ul>



<p>Theses <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">directives </mark></strong>check if the code is compiled with Microsoft Visual C++ and disable specific compiler warnings</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="381" height="125" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-49.png" alt="" class="wp-image-3194" style="width:295px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-49.png 381w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-49-300x98.png 300w" sizes="(max-width: 381px) 100vw, 381px" /></figure>



<p>It is also targeting <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Windows 95</mark></strong> (0x0400) instead of a later version</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="368" height="101" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-51.png" alt="" class="wp-image-3196" style="width:296px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-51.png 368w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-51-300x82.png 300w" sizes="(max-width: 368px) 100vw, 368px" /></figure>



<ul class="wp-block-list">
<li>These <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">libraries</mark></strong> provide a wide range of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">functionalities</mark></strong>, from UI components and cryptography to standard I/O operations and memory management</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="543" height="525" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-52.png" alt="" class="wp-image-3197" style="width:408px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-52.png 543w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-52-300x290.png 300w" sizes="(max-width: 543px) 100vw, 543px" /></figure>



<ul class="wp-block-list">
<li>Additional <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">libraries</mark></strong> are included, to perform operations on data <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">structures</mark></strong> and algorithms. The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">boost</mark></strong> library is also used (<a href="https://www.boost.org/">https://www.boost.org/</a>)</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="471" height="375" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-53.png" alt="" class="wp-image-3198" style="width:360px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-53.png 471w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-53-300x239.png 300w" sizes="(max-width: 471px) 100vw, 471px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">local headers</mark></strong> are also included, that contain <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">application-specific</mark></strong> code that deals with serialization, cryptography, transaction handling, user interface, and networking features</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="318" height="352" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-54.png" alt="" class="wp-image-3199" style="width:251px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-54.png 318w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-54-271x300.png 271w" sizes="(max-width: 318px) 100vw, 318px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">irc.cpp, irc.h</mark></strong></p>



<p>Support for the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">IRC</mark></strong> communication chanel was <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">removed</mark></strong> from bitcoin core in March 2014 (see this Wiki about IRC : <a href="https://en.wikipedia.org/wiki/IRC">https://en.wikipedia.org/wiki/IRC</a>)</p>



<p>Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">irc.cpp</mark></strong> : <a href="https://tinyurl.com/yvw3xnz2">https://tinyurl.com/yvw3xnz2</a></p>



<p>It enables the software to connect with other nodes using <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">IRC</mark></strong>, allowing for the exchange of information. Key functionalities include encoding and decoding addresses, sending and receiving messages, handling connections, and managing the state of sockets</p>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">ThreadIRCSeed</mark></strong> handles the connection to an IRC server for broadcasting and receiving bitcoin node messages. It processes various IRC commands, enabling interaction with other nodes in the network via IRC</li>
</ul>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="446" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-29-1024x446.png" alt="" class="wp-image-3158" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-29-1024x446.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-29-300x131.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-29-768x335.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-29.png 1377w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">irc.h</mark></strong> : <a href="https://tinyurl.com/mrypzyt2">https://tinyurl.com/mrypzyt2</a></p>



<ul class="wp-block-list">
<li>It is used for the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">setup</mark></strong> of the network <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">socket</mark></strong> connection, and the corresponding <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">IRC thread</mark></strong></li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="714" height="181" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-30.png" alt="" class="wp-image-3172" style="width:460px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-30.png 714w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-30-300x76.png 300w" sizes="(max-width: 714px) 100vw, 714px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">key.h</mark></strong></p>



<p>This file is an implementation of key management and cryptographic operations using Elliptic Curve Cryptography (ECC), specifically bitcoin publick-key cryptography <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">secp256k1 </mark></strong>(<a href="https://en.bitcoin.it/wiki/Secp256k1">https://en.bitcoin.it/wiki/Secp256k1</a>), which is now commonly used in cryptocurrencies</p>



<p>Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">key.h</mark></strong> : <a href="https://tinyurl.com/3c3tc377">https://tinyurl.com/3c3tc377</a></p>



<ul class="wp-block-list">
<li>The code contains <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">commented constants</mark></strong> representing the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">sizes</mark></strong> of private keys, public keys, and signatures for elliptic curves</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="552" height="150" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-55.png" alt="" class="wp-image-3201" style="width:389px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-55.png 552w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-55-300x82.png 300w" sizes="(max-width: 552px) 100vw, 552px" /></figure>



<p>A secure_allocator is designed to manage sensitive data like <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">private keys</mark></strong>. The vector part represents a dynamic array that can hold bytes. This byte array is used to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">store binary data</mark></strong>, such as private keys, serialized objects, or any byte sequence</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="773" height="54" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-56.png" alt="" class="wp-image-3202" style="width:528px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-56.png 773w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-56-300x21.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-56-768x54.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Ckey class</mark></strong> contains many important <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">methods</mark></strong> : constructor and desctructor, key management, public key management, signature operations, static signature methods</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="788" height="305" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-57.png" alt="" class="wp-image-3203" style="width:526px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-57.png 788w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-57-300x116.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-57-768x297.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">main.cpp</mark></strong></p>



<p>This code implements the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">blockchain</mark></strong> management of transactions, wallets, and blocks. Here is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">main.cpp</mark></strong> : <a href="https://tinyurl.com/ujf6u85z">https://tinyurl.com/ujf6u85z</a></p>



<p>As the code is very long, I provide a summary table of each function or method. I then provide a few more detailed analysis</p>



<figure class="wp-block-table"><table><thead><tr><th>Function name</th><th>Start line</th><th>Purpose</th></tr></thead><tbody><tr><td>AddKey</td><td>65</td><td>Add a cryptographic <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">key</mark></strong> to the wallet, which will be used to handle Bitcoin transactions</td></tr><tr><td>GenerateNewKey</td><td>75</td><td>Generates a key, adds it to the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">wallet</mark></strong>, and returns the public part of the key</td></tr><tr><td>AddToWallet</td><td>92</td><td>Adds a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">transaction</mark></strong> (CWalletTx) to a Bitcoin wallet. It handles both inserting new transactions and updating existing transactions</td></tr><tr><td>AddToWalletIfMine</td><td>149</td><td>Adds a transaction to a wallet if it is determined that the wallet owns the corresponding coins (the transaction is &#8220;mine&#8221;). If the transaction is already present in the wallet, it ensures that it is updated appropriately</td></tr><tr><td>EraseFromWallet</td><td>162</td><td>Removes a transaction from a Bitcoin wallet based on its transaction hash. This function ensures that both the in-memory representation and persistent storage are updated</td></tr><tr><td>AddOrphanTx</td><td>185</td><td>Adds a transaction to a collection of orphan transactions in a Bitcoin wallet or node. Orphan transactions are those that cannot be fully processed because they depend on inputs that are not currently available in the local node&#8217;s memory</td></tr><tr><td>EraseOrphanTx</td><td>197</td><td>Removes a specified orphan transaction from the collection of orphan transactions in a Bitcoin wallet or node. This function ensures that orphan transactions are properly removed from memory when they are no longer needed</td></tr><tr><td>CTxIn::IsMine</td><td>231</td><td>Member function of the CTxIn class, which represents an input in a Bitcoin transaction. This function determines whether the output being referenced by the transaction input belongs to the wallet, meaning it checks if the wallet controls that specific input</td></tr><tr><td>CTxIn::GetDebit</td><td>247</td><td>Member function of the CTxIn class, which represents an input in a Bitcoin transaction. This function is used to calculate the debit amount for that specific transaction input, effectively determining how much currency is being spent from the wallet</td></tr><tr><td>CWalletTx::GetTxTime</td><td>263</td><td>Member function of the CWalletTx class, which represents a transaction in a wallet. This function determines the time associated with the transaction, either by using the time it was received or, if it wasn&#8217;t received directly, by using the time of the block in which it was included</td></tr><tr><td>CMerkleTx::<br>SetMerkleBranch</td><td>286</td><td>Sets the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Merkle branch</mark></strong> for a given transaction within a block in a Bitcoin wallet or node implementation. This branch allows the transaction to be verified as part of a block&#8217;s Merkle tree, which ensures the integrity and inclusion of the transaction in that block</td></tr><tr><td>CWalletTx::<br>AddSupportingTransactions</td><td>339</td><td>Retrieves and manages the supporting transactions that are associated with a given transaction (represented by CWalletTx). It gathers transactions that are inputs to the current transaction, enabling the wallet to maintain a complete context of the transactions involved</td></tr><tr><td>CTransaction::<br>AcceptTransaction</td><td>406</td><td>Validates and accepts a new transaction into memory or the transaction pool. It checks for errors, conflicts with existing transactions, and dependencies on previous transactions</td></tr><tr><td>CTransaction::<br>AddToMemoryPool</td><td>481</td><td>Adds a transaction to the in-memory transaction pool (<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">mempool</mark></strong>). This function is designed to be called only by other functions (like AcceptTransaction), which ensures that the transaction is valid before it is added</td></tr><tr><td>CTransaction::<br>RemoveFromMemoryPool</td><td>497</td><td>Removes a transaction from the in-memory transaction pool (mempool)</td></tr><tr><td>CMerkleTx::<br>GetDepthInMainChain</td><td>515</td><td>Assesses where the transaction is within the blockchain, based on its position in the tree structure of blocks (and their associated transactions) and ensures that it is indeed part of the main chain</td></tr><tr><td>CMerkleTx::<br>GetBlocksToMaturity</td><td>540</td><td>Determines how many additional blocks need to be mined before a coinbase transaction (the first transaction in a block that creates new coins) can be considered mature and the funds can be spent</td></tr><tr><td>CMerkleTx::<br>AcceptTransaction</td><td>548</td><td>Accepts a transaction while considering whether it is being processed in a client mode or a full node mode</td></tr><tr><td>CWalletTx::<br>AcceptWalletTransaction</td><td>564</td><td>Accepts transactions into the wallet while checking any associated previous transactions (inputs) that the current transaction depends on</td></tr><tr><td>ReacceptWalletTransactions</td><td>583</td><td>Re-accepts transactions that belong to the wallet but are not currently associated with any blocks on the blockchain. This function loops through all transactions in the wallet and ensures they remain valid and are accepted into the wallet&#8217;s transaction pool again</td></tr><tr><td>CWalletTx::<br>RelayWalletTransaction</td><td>599</td><td>Broadcasts a wallet transaction and its associated previous transactions across the network to ensure that they are relayed to other nodes, as transactions need to be propagated for inclusion in blocks</td></tr><tr><td>RelayWalletTransactions</td><td>621</td><td>Relays transactions within the decentralized Bitcoin network</td></tr><tr><td>CBlock::ReadFromDisk</td><td>662</td><td>Member function of the CBlock class, responsible for reading a block from disk storage based on its index information</td></tr><tr><td>GetOrphanRoot</td><td>667</td><td>Determines the original block that is at the base of an orphan block tree</td></tr><tr><td>CBlock::GetBlockValue</td><td>675</td><td>Calculates the total value (or <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">reward</mark></strong>) that a block provides to the miner who successfully creates it, taking into account both the block subsidy and the transaction fees associated with the transactions included in the block</td></tr><tr><td>GetNextWorkRequired</td><td>685</td><td>Calculates the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">difficulty</mark></strong> target for the next block based on the time taken to mine previous blocks, ensuring that new blocks continue to be produced at a steady rate</td></tr><tr><td>CTransaction::<br>DisconnectInputs</td><td>739</td><td>Responsible for undoing the effects of a transaction, when a block is confirmed or re-processed. This function effectively &#8220;disconnects&#8221; a transaction by marking its inputs as unspent, allowing those outputs to be reused in future transactions</td></tr><tr><td>CTransaction::<br>ConnectInputs</td><td>772</td><td>Validates that the inputs of the transaction can be connected to the Bitcoin network by ensuring that they are currently unspent and that all signatures and conditions are met</td></tr><tr><td>CTransaction::<br>ClientConnectInputs</td><td>873</td><td>Checks and validates the inputs of a transaction specifically for a client (such as a lightweight client that does not have a full transaction database)</td></tr><tr><td>CBlock::DisconnectBlock</td><td>918</td><td>Removes the transactions contained in the block and updates the disk index accordingly</td></tr><tr><td>CBlock::ConnectBlock</td><td>937</td><td>Accepts a block and processes its transactions, ensuring they are valid and updating the blockchain state accordingly</td></tr><tr><td>Reorganize</td><td>974</td><td>Handles the transition between different branches of the blockchain. When the blockchain experiences a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">fork</mark></strong> (due to conflicting blocks), this function will reorganize the blockchain to ensure the longest valid chain is retained and that the state of transactions is accurately reflected</td></tr><tr><td>CBlock::AddToBlockIndex</td><td>1072</td><td>Adds a new <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">block</mark></strong> to the blockchain index, ensuring that the block&#8217;s information is properly recorded, and manages the relationships between different blocks in the blockchain</td></tr><tr><td>CBlock::CheckBlock</td><td>1154</td><td>Validates a block&#8217;s integrity and compliance with the protocol&#8217;s rules before it can be added to the blockchain, or even stored as an orphan block</td></tr><tr><td>CBlock::AcceptBlock</td><td>1194</td><td>Validates and accepts a block into the blockchain. It performs various essential checks and operations to ensure the integrity of the blockchain structure</td></tr><tr><td>ProcessBlock</td><td>1236</td><td>Handles incoming blocks from peers, validates them, and integrates them into the blockchain. This function first checks for duplicates, validates the block, and handles orphan blocks that depend on it</td></tr><tr><td>ScanMessageStart</td><td>1304</td><td>Scans a data stream for a specific message start prefix, which is a critical part of the Bitcoin protocol for ensuring that communications between nodes are properly formatted</td></tr><tr><td>GetAppDir</td><td>1344</td><td>Determines the application directory for the Bitcoin wallet application, returning a string that represents the path where the application data should be stored. It checks various locations, including environment variables, to set this directory</td></tr><tr><td>OpenBlockFile</td><td>1379</td><td>Handles reading and writing blocks to disk while ensuring that they fit within storage limits and perform necessary operations safely</td></tr><tr><td>AppendBlockFile</td><td>1399</td><td>Handles reading and writing blocks to disk while ensuring that they fit within storage limits and perform necessary operations safely</td></tr><tr><td>LoadBlockIndex</td><td>1420</td><td>Loads existing blocks from the transaction database but also handles the creation and addition of the genesis block, which is the very first block in the Bitcoin blockchain</td></tr><tr><td>PrintBlockTree</td><td>1496</td><td>Designed to visualize the structure of the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">blockchain</mark></strong> by printing the relationships between blocks in a tree-like format. It allows users or developers to see how blocks are linked in terms of their parent-child relationships, along with other relevant information such as transaction counts and timestamps</td></tr><tr><td>AlreadyHave</td><td>1592</td><td>Checks whether a specific item (transaction, block, review, or product) is already known to the node, allowing it to avoid reprocessing or requesting the same item again. This function is part of the inventory management aspect of a Bitcoin node, which helps optimize communication and bandwidth usage</td></tr><tr><td>ProcessMessages</td><td>1611</td><td>Handles incoming messages from other nodes in the Bitcoin network. It reads and processes messages, ensuring they conform to the expected format while efficiently managing the message buffer</td></tr><tr><td>ProcessMessage</td><td>1690</td><td>Processes incoming messages from other nodes, interprets them according to the command they represent, and performs the necessary actions based on the command type</td></tr><tr><td>SendMessages</td><td>2056</td><td>Sends various types of messages to a connected <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">peer node</mark></strong> in the Bitcoin network. It handles several tasks, including ensuring that only validated data is sent, managing inventory updates, and handling address propagation</td></tr><tr><td>FormatHashBlocks</td><td>2138</td><td>Prepares a byte buffer for hashing by ensuring it conforms to the requirements of the hashing algorithm used in Bitcoin (such as SHA-256). It properly pads and formats the input data for efficient hashing</td></tr><tr><td>BlockSHA256</td><td>2156</td><td>Computes the SHA-256 <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hash</mark></strong> for a specified number of data blocks using the crypto library. It takes an array of input data, processes it in blocks, and outputs the resulting SHA-256 hash in a specified buffer</td></tr><tr><td>BitcoinMiner</td><td>2183</td><td>Responsible for the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">mining</mark></strong> process in the Bitcoin software. It works by repeatedly attempting to create a valid block by solving a computational puzzle known as proof-of-work</td></tr><tr><td>GetBalance</td><td>2386</td><td>Calculates the total <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">balance</mark></strong> of a Bitcoin wallet by summing the values of the unspent transactions that belong to the wallet</td></tr><tr><td>SelectCoins</td><td>2410</td><td>Selects a set of wallet transactions that meet a specified target value, which is crucial for constructing a new transaction with sufficient funds. This function attempts to find the optimal subset of Unspent Transaction Outputs (<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">UTXO</mark></strong>s) that total close to the target value while also considering various conditions</td></tr><tr><td>CreateTransaction</td><td>2514</td><td>Facilitate the creation of a new transaction by selecting appropriate unspent transaction outputs (UTXOs), calculating <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">fees</mark></strong>, preparing inputs and outputs, and signing the transaction</td></tr><tr><td>CommitTransactionSpent</td><td>2595</td><td>Updates the wallet&#8217;s state after a transaction has been committed. Specifically, it marks the inputs of the newly added transaction as spent and updates the wallet&#8217;s transaction history, utilizing a critical section to ensure thread safety during concurrent access to shared data</td></tr><tr><td>SendMoney</td><td>2625</td><td>Handles the process of creating and sending transactions. It involves transaction creation, validation, fee calculations, modifications to the wallet state, and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">broadcasting</mark></strong> the transaction across the network</td></tr></tbody></table></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">GetBlockValue</mark></strong> function is part of the CBlock class. This function calculates the total value of a newly created block, considering its subsidy and transaction fees</li>
</ul>



<p>int64 nFees  represents the total <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">transaction fees</mark></strong> included in the block.<br>Local Variable nSubsidy is initially set as 50 * COIN, which means that the standard subsidy for a new coinbase block is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">50 bitcoin</mark></strong> (50 coins)</p>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">subsidy</mark></strong> is designed to be <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">halved approximately every four years</mark></strong>. The condition nBestHeight / 210000 calculates how many 210,000 block intervals have been mined (since 210,000 blocks roughly correspond to four years at 10-minute block intervals). The expression nSubsidy &gt;&gt;= (nBestHeight / 210000) uses a right <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bitwise shift operator</mark></strong> (&gt;&gt;=), effectively halving the subsidy for each completed interval of 210,000 blocks. This implements bitcoin&#8217;s block reward <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">halving</mark></strong> mechanism</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="560" height="228" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-69.png" alt="" class="wp-image-3217" style="width:390px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-69.png 560w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-69-300x122.png 300w" sizes="(max-width: 560px) 100vw, 560px" /></figure>



<p>The total <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">value of the block</mark></strong> is the sum of the current subsidy (after accounting for halvings) and any transaction fees associated with the transactions included in the block</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="393" height="27" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-70.png" alt="" class="wp-image-3218" style="width:340px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-70.png 393w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-70-300x21.png 300w" sizes="(max-width: 393px) 100vw, 393px" /></figure>



<p>The table below helps visualize the evolution of block subsidy rewards after each halving. From this table, the 21 000 000 bitcoin maximum quantity can be derived. That means that the hard cap of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">21 million bitcoin is an implicit</mark></strong> <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">limit</mark></strong>, not an explicit limit</p>



<figure class="wp-block-image size-full"><img decoding="async" width="526" height="798" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-72.png" alt="" class="wp-image-3220" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-72.png 526w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-72-198x300.png 198w" sizes="(max-width: 526px) 100vw, 526px" /></figure>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">halving curve</mark></strong> can be visualized with this graph :</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="758" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-71-1024x758.png" alt="" class="wp-image-3219" style="width:575px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-71-1024x758.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-71-300x222.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-71-768x569.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-71.png 1051w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">GetNextWorkRequired</mark></strong> function is responsible for adjusting the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">mining difficulty</mark></strong> based on the time it took to mine the last set of blocks</li>
</ul>



<p>nTargetTimespan sets the ideal duration for mining 2016 blocks, which is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">two weeks</mark></strong></p>



<p>nTargetSpacing defines the desired time between blocks, set to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">10 minutes</mark></strong></p>



<p>nInterval calculates the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">number of blocks</mark></strong> that should be adjusted for difficulty (2016 blocks in this case)</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="718" height="77" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-64.png" alt="" class="wp-image-3211" style="width:502px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-64.png 718w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-64-300x32.png 300w" sizes="(max-width: 718px) 100vw, 718px" /></figure>



<p>The lines below check if the current block height (nHeight) plus one is not a multiple of nInterval. If it isn&#8217;t, the function returns the current difficulty (nBits) without making any changes. This ensures that the difficulty is adjusted <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">only once every 2016 blocks</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="561" height="77" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-65.png" alt="" class="wp-image-3212" style="width:444px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-65.png 561w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-65-300x41.png 300w" sizes="(max-width: 561px) 100vw, 561px" /></figure>



<p>The function below calculates the actual time taken to mine the last nInterval blocks by subtracting the time of pindexFirst from pindexLast. This actual time span (nActualTimespan) is then <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">forced</mark></strong> to a minimum of 25% of the target timespan and a maximum of 400% to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">prevent extreme adjustments in difficulty</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="719" height="178" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-66.png" alt="" class="wp-image-3213" style="width:503px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-66.png 719w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-66-300x74.png 300w" sizes="(max-width: 719px) 100vw, 719px" /></figure>



<p>The lines below create a new difficulty target (bnNew) based on the previous difficulty and the actual time span compared to the target timespan. If the new difficulty exceeds the defined proof-of-work limit, it caps it to the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">maximum allowable difficulty</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="523" height="204" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-67.png" alt="" class="wp-image-3214" style="width:359px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-67.png 523w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-67-300x117.png 300w" sizes="(max-width: 523px) 100vw, 523px" /></figure>



<p>Here below the evolution of the real network difficulty</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="594" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-74-1024x594.png" alt="" class="wp-image-3225" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-74-1024x594.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-74-300x174.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-74-768x445.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-74.png 1257w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CheckBlock</mark></strong> function validates a block before it is processed further. It conducts several checks on the block&#8217;s properties to ensure that it adheres to the rules defined by the blockchain protocol</li>
</ul>



<p>It verifies that the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">block size</mark></strong> is valid</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="88" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-76-1024x88.png" alt="" class="wp-image-3228" style="width:619px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-76-1024x88.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-76-300x26.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-76-768x66.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-76.png 1128w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>It verifies that the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">timestamp</mark></strong> of the block is valid (not too far in the future as compared with the current time)</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="923" height="102" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-77.png" alt="" class="wp-image-3229" style="width:620px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-77.png 923w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-77-300x33.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-77-768x85.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>It verifies that the first transaction in the block is a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">coinbase</mark></strong> transaction (the special transaction that rewards miners for adding a block), and that there is only one coinbase transaction</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="965" height="193" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-78.png" alt="" class="wp-image-3230" style="width:546px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-78.png 965w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-78-300x60.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-78-768x154.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>It iterates through all <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">transactions</mark></strong> in the block (vtx) and calls the CheckTransaction() method on each. If any transaction fails its validity check, it returns an error</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="849" height="127" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-79.png" alt="" class="wp-image-3231" style="width:548px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-79.png 849w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-79-300x45.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-79-768x115.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>It validates the block&#8217;s <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">proof of work</mark></strong> (POW)</p>



<p>nBits value (which indicates the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">difficulty</mark></strong> of the proof of work) shall not exceed the predefined limit (bnProofOfWorkLimit)</p>



<p>Block&#8217;s <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hash</mark></strong> (calculated by the GetHash() method) is less than or equal to the target dictated by nBits</p>



<p>If these checks fail, it returns an error</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="820" height="156" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-80.png" alt="" class="wp-image-3233" style="width:557px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-80.png 820w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-80-300x57.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-80-768x146.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>It validates that the hashMerkleRoot stored in the block matches the hash generated from the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Merkle tree</mark></strong> of the transactions in the block. If they don&#8217;t match, it returns an error</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="875" height="97" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-81.png" alt="" class="wp-image-3234" style="width:559px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-81.png 875w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-81-300x33.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-81-768x85.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>In the bitcoin protocol, a transaction will be stored in the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">mempool</mark></strong> (memory pool) until it is duly validated. You can visualize the live mempool size : <a href="https://tinyurl.com/2z8zujvk">https://tinyurl.com/2z8zujvk</a></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="376" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-86-1024x376.png" alt="" class="wp-image-3259" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-86-1024x376.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-86-300x110.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-86-768x282.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-86-1536x564.png 1536w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-86.png 1881w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">main.h</mark></strong></p>



<p>This file defines constants, classes, methods used in main.cpp. I&#8217;m not going to detail the content, and just provide informations about important constants used in the program</p>



<p>Here is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">main.h</mark></strong> : <a href="https://tinyurl.com/z8y66m7y">https://tinyurl.com/z8y66m7y</a></p>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Constant</mark></strong> definitions</li>
</ul>



<p>The maximum <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">block size</mark></strong> in bytes is 0x02000000, or equivalent to about <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">32 MB</mark></strong> (32 * 1024 * 1024 bytes). In the bitcoin context, this can restrict the maximum block size to maintain efficiency and performance</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="543" height="31" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-59.png" alt="" class="wp-image-3206" style="width:398px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-59.png 543w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-59-300x17.png 300w" sizes="(max-width: 543px) 100vw, 543px" /></figure>



<p>In practice, the real block size is much lower, as can be seen on the graph below. The real block size usage has increased following an increase in the blockchain transactions</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="606" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-73-1024x606.png" alt="" class="wp-image-3224" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-73-1024x606.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-73-300x177.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-73-768x454.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-73.png 1261w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Coin</mark></strong> represents the base unit for a cryptocurrency, here defined as 1 Bitcoin being equal to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">100,000,000 satoshis</mark></strong>. It allows for smaller denominations of Bitcoin to be used in transactions</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="408" height="27" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-60.png" alt="" class="wp-image-3207" style="width:331px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-60.png 408w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-60-300x20.png 300w" sizes="(max-width: 408px) 100vw, 408px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Cent</mark></strong> represents a smaller unit equivalent to one hundredth of a Bitcoin, or  1 Cent = <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">1,000,000 satoshis</mark></strong>, further allowing the representation of transactions in finer detail. It helps in calculations involving cents</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="416" height="26" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-61.png" alt="" class="wp-image-3208" style="width:331px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-61.png 416w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-61-300x19.png 300w" sizes="(max-width: 416px) 100vw, 416px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Coinbase maturity</mark></strong> indicates that newly mined coins (the output of a coinbase transaction) cannot be spent until a certain number of blocks (in this case, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">100 blocks</mark></strong>) have been confirmed after the block containing the coinbase transaction. This rule is implemented to prevent <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">double-spending</mark></strong> in the case of newly created coins</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="468" height="27" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-62.png" alt="" class="wp-image-3209" style="width:370px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-62.png 468w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-62-300x17.png 300w" sizes="(max-width: 468px) 100vw, 468px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bnProofOfWorkLimit</mark></strong> sets the limit for the proof of work <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">difficulty</mark></strong>. uint256(0) creates a value that represents the maximum possible value for a 256-bit unsigned integer (i.e., all bits are set). Shifting this value right by 32 bits effectively reduces the maximum target value by a factor of (2^{32}).</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="636" height="29" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-63.png" alt="" class="wp-image-3210" style="width:494px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-63.png 636w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-63-300x14.png 300w" sizes="(max-width: 636px) 100vw, 636px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">makefile, makefile.vc</mark></strong></p>



<p>Makefile is used by the make build automation tool to manage the compilation of the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bitcoin.exe</mark></strong> target. The paths where the compiler will look for <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">header files</mark></strong> and where it will look for <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">libraries </mark></strong>are defined</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">makefile</mark></strong> is here : <a href="https://tinyurl.com/yah6ap9c">https://tinyurl.com/yah6ap9c</a></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="420" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-82-1024x420.png" alt="" class="wp-image-3238" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-82-1024x420.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-82-300x123.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-82-768x315.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-82.png 1468w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">market.cpp, market.h</mark></strong></p>



<p>This is a partially completed distributed <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">market place</mark></strong>. It was not implemented in later versions of bitcoin core, so I&#8217;m not going to detail anything</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">market.cpp</mark></strong> is here : <a href="https://tinyurl.com/3u5x88cc">https://tinyurl.com/3u5x88cc</a></p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">net.cpp, net.h</mark></strong></p>



<p>We all know that bitcoin is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">decentralized</mark></strong>, and based upon the synchronization of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">nodes</mark></strong> (mainly operated by miners). net.cpp is an important file for the execution of this network layer</p>



<p>Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">net.cpp</mark></strong> : <a href="https://tinyurl.com/yju4rp55">https://tinyurl.com/yju4rp55</a></p>



<p>It manages <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">network</mark></strong> connections and threading in a Bitcoin node. This code handles aspects like network socket creation, listening for incoming connections, sending and receiving messages, handling of issues like connection failures and data integrity, and proper cleanup during shutdown</p>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Global variables</mark></strong></li>
</ul>



<p>Here you find <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">address definitions</mark></strong>, flags, primitives. For example, vNodes keeps track of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">connected nodes</mark></strong>, and mapAddresses stores <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">known network addresses</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="900" height="471" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-23.png" alt="" class="wp-image-3151" style="width:506px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-23.png 900w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-23-300x157.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-23-768x402.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">ConnectSocket function</mark></strong></li>
</ul>



<p>This function establishes a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">socket connection</mark></strong> to the specified address (addrConnect).<br>The function creates a socket, and attempts to connect. If successful, it returns true and sets hSocketRet to the connected socket</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="407" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-24-1024x407.png" alt="" class="wp-image-3152" style="width:715px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-24-1024x407.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-24-300x119.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-24-768x305.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-24.png 1349w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">GetMyExternalIP function</mark></strong></li>
</ul>



<p>This function attempts to determine the external IP address of the machine by connecting to a known address. After establishing a socket connection, it sends an <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">HTTP GET</mark></strong> request to retrieve the external IP and then processes the response. If successful, it sets ipRet to the detected external IP address</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="456" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-25-1024x456.png" alt="" class="wp-image-3154" style="width:715px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-25-1024x456.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-25-300x133.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-25-768x342.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-25.png 1209w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">ThreadSocketHandler</mark></strong>&nbsp;and&nbsp;<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">ThreadOpenConnections</mark></strong>&nbsp;represent functions handling <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">socket connections</mark></strong> and messages, running indefinitely in their respective threads</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="708" height="538" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-26.png" alt="" class="wp-image-3155" style="width:415px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-26.png 708w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-26-300x228.png 300w" sizes="(max-width: 708px) 100vw, 708px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">ThreadMessageHandler</mark></strong></li>
</ul>



<p>This function is responsible for processing incoming and outgoing messages to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">connected nodes</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="726" height="536" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-27.png" alt="" class="wp-image-3156" style="width:412px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-27.png 726w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-27-300x221.png 300w" sizes="(max-width: 726px) 100vw, 726px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">StartNode and StopNode functions</mark></strong></li>
</ul>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">StartNode</mark></strong> : this function initializes the networking components, binds to a local address, listens for incoming connections, and starts necessary threads<br><br><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">StopNode</mark></strong> : this function shuts down the node, marking a shutdown flag and ensuring all threads are complete before cleanup</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="338" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-28-1024x338.png" alt="" class="wp-image-3157" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-28-1024x338.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-28-300x99.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-28-768x254.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-28.png 1316w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">script.cpp, script.h</mark></strong></p>



<p>Bitcoin is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">programmable money</mark></strong>, and like any program, you can add commands to it to execute certain actions</p>



<p>For this purpose, bitcoin Core uses <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">scripts</mark></strong> that are run into a stack, and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">opcodes</mark></strong> are the underlying operations that help build the bitcoin scripts</p>



<p>Technically, the scripting language is based upon <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Forth</mark></strong> : <a href="https://tinyurl.com/43tpat57">https://tinyurl.com/43tpat57</a></p>



<p>The use of such a scripting language is like having an embedded, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">assembly-like language</mark></strong>, to use for specific tasks inside the application. As such, the opcodes are similar to the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">mnemonics</mark></strong> used in assembly programming</p>



<p>You can find a complete list of opcodes here : <a href="https://tinyurl.com/5e8kaypr">https://tinyurl.com/5e8kaypr</a></p>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">script.h</mark></strong> file can be found here : <a href="https://tinyurl.com/b9u8s2bd">https://tinyurl.com/b9u8s2bd</a>. You will find inside :</p>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Opcode enumeration</mark></strong></li>
</ul>



<p>The enum contains different opcodes representing <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">operations</mark></strong> in bitcoin script. They include commands for pushing data, control flow, stack manipulation, bitwise operations, cryptography, and more</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="544" height="398" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-2.png" alt="" class="wp-image-3127" style="width:331px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-2.png 544w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-2-300x219.png 300w" sizes="(max-width: 544px) 100vw, 544px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Function to get opcode names</mark></strong></li>
</ul>



<p>This function returns a string representation of an opcode based on its <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">enum value</mark></strong>. If the opcode doesn&#8217;t match any known type, it returns &#8220;UNKNOWN_OPCODE&#8221;</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="696" height="392" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-1.png" alt="" class="wp-image-3126" style="width:400px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-1.png 696w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-1-300x169.png 300w" sizes="(max-width: 696px) 100vw, 696px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CScript Class</mark></strong></li>
</ul>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">class</mark></strong> CScript is used for <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">script management and manipulation</mark></strong>. It has various constructors and operator overloads</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="967" height="333" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-5.png" alt="" class="wp-image-3130" style="width:555px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-5.png 967w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-5-300x103.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-5-768x264.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>These operators can handle different data types and build scripts, and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">pushing values</mark></strong> onto the stack</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="623" height="422" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-4.png" alt="" class="wp-image-3129" style="width:380px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-4.png 623w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-4-300x203.png 300w" sizes="(max-width: 623px) 100vw, 623px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Script parsing</mark></strong></li>
</ul>



<p>This method retrieves the next opcode from the script and updates the program counter</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="450" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-6-1024x450.png" alt="" class="wp-image-3131" style="width:711px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-6-1024x450.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-6-300x132.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-6-768x337.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-6.png 1166w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">script.cpp</mark></strong> file can be found here : <a href="https://tinyurl.com/mt29va73">https://tinyurl.com/mt29va73</a></p>



<p>This file includes functions that are important and used for <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">transaction verification and execution</mark></strong>. They are used extensively within the Bitcoin network, for verifying transactions and ensuring that they are executed correctly according to the provided scripts</p>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">EvalScript</mark></strong> is essential for executing and validating Bitcoin scripts. It processes opcodes sequentially, modifying the execution stack as required and handles both control flow and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">cryptographic</mark></strong> operations to ensure each script fulfills its intended purpose correctly. Each opcode has specific logic that defines how it interacts with the stack and how it affects the program&#8217;s flow</li>
</ul>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="338" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-15-1024x338.png" alt="" class="wp-image-3143" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-15-1024x338.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-15-300x99.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-15-768x253.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-15.png 1152w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">SignatureHash</mark></strong> is a crucial part of Bitcoin&#8217;s transaction model, responsible for generating a hash of a transaction input that includes the signature data. This <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hash</mark></strong> is what is actually signed by the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">private key</mark></strong>, ensuring that the signature is uniquely associated with a specific transaction input state</li>
</ul>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="216" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-16-1024x216.png" alt="" class="wp-image-3144" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-16-1024x216.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-16-300x63.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-16-768x162.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-16.png 1205w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">IsMine</mark></strong> checks whether the provided public key script (scriptPubKey) belongs to the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">wallet </mark></strong>(i.e., whether the wallet holds the corresponding private key)</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="706" height="162" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-21.png" alt="" class="wp-image-3149" style="width:414px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-21.png 706w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-21-300x69.png 300w" sizes="(max-width: 706px) 100vw, 706px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">ExtractPubKey</mark></strong> extracts the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">public key</mark></strong> from the public key script (scriptPubKey). It optionally checks if the public key belongs to the wallet</li>
</ul>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="191" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-22-1024x191.png" alt="" class="wp-image-3150" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-22-1024x191.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-22-300x56.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-22-768x143.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-22.png 1198w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">ExtractHash160</mark></strong> is designed to extract the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hash</mark></strong> of a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">public key</mark></strong> (specifically, the result of a RIPEMD-160 hashing operation on a SHA-256 hash of the public key) from a given script. This hash is used in Bitcoin transactions as a means of identifying addresses uniquely</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="877" height="569" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-17.png" alt="" class="wp-image-3145" style="width:500px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-17.png 877w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-17-300x195.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-17-768x498.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">SignSignature</mark></strong> generates a digital signature for a transaction input. It combines the transaction data with the relevant script and signs it using the private key associated with the corresponding public key</li>
</ul>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="532" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-19-1024x532.png" alt="" class="wp-image-3147" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-19-1024x532.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-19-300x156.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-19-768x399.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-19.png 1390w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">VerifySignature</mark></strong> checks if the input is valid. It confirms that the transaction hash <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">matches</mark></strong> the expected hash. Finally, it verifies the signature using the script evaluation process</li>
</ul>



<p>This function is important for maintaining the security and integrity of the Bitcoin network, ensuring that <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">funds</mark></strong> can only be spent by their rightful owners. If any of the checks fail, it ensures that the transaction cannot proceed</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="328" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-20-1024x328.png" alt="" class="wp-image-3148" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-20-1024x328.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-20-300x96.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-20-768x246.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-20.png 1272w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">serialize.h</mark></strong></p>



<p>This code implements <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">serialization</mark></strong> : <a href="https://en.wikipedia.org/wiki/Serialization">https://en.wikipedia.org/wiki/Serialization</a></p>



<p>The code converts objects of a particular class into a stream of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bytes</mark></strong>. It is used to store it in memory or transmit it over the network</p>



<p>Here is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">serialize.h</mark></strong> : <a href="https://tinyurl.com/msmd2r3k">https://tinyurl.com/msmd2r3k</a></p>



<p>For example, the WriteCompactSize function is designed to serialize a size value (of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">type uint64</mark></strong>) into a compact format for efficient storage and transmission. It uses a specific encoding scheme that optimizes for smaller sizes when possible, making it important for handling variable-length data</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="558" height="725" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-83.png" alt="" class="wp-image-3240" style="width:367px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-83.png 558w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-83-231x300.png 231w" sizes="(max-width: 558px) 100vw, 558px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">sha.cpp, sha.h</mark></strong></p>



<p>Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">sha.cpp</mark></strong> : <a href="https://tinyurl.com/mvhzu39d">https://tinyurl.com/mvhzu39d</a></p>



<p>The provided code implements the SHA1, SHA224, SHA256, SHA384, SHA512 <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hashing </mark></strong>algorithm</p>



<p>It also includes an accelerated version of SHA52, written in <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">assembly</mark></strong> language, for compatible hardware</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="70" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-84-1024x70.png" alt="" class="wp-image-3241" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-84-1024x70.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-84-300x20.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-84-768x52.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-84.png 1159w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">ui.cpp, ui.h, ui.rc, uibase.cpp, uibase.h, uiproject.fbp</mark></strong></p>



<p>All these files are here to implement the user interface of the bitcoin application</p>



<p>It is based upon the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Qt framework</mark></strong> : <a href="https://www.qt.io/product/framework">https://www.qt.io/product/framework</a></p>



<p>It uses <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">wxFormbuilder</mark></strong> widgets, to hep create the user interface (example below)</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="620" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-85-1024x620.png" alt="" class="wp-image-3242" style="width:581px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-85-1024x620.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-85-300x182.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-85-768x465.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-85.png 1437w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>The volume of code is important : about 18 000 lines of code. We can imagine the time spent on this if bitcoin was developped by a single person !</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">uint256.h</mark></strong></p>



<p>This file defines two custom data types, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">uint160</mark></strong> and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">uint256</mark></strong>, for handling <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">160-bit</mark></strong> and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">256-bit</mark></strong> unsigned integers, respectively. These types are commonly used in blockchain and cryptocurrency applications, to represent data like <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hashes</mark></strong> (SHA-256 outputs) and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">addresses</mark></strong></p>



<p>Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">uint256.h</mark></strong> : <a href="https://tinyurl.com/5bfnp858">https://tinyurl.com/5bfnp858</a></p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">util.cpp, util.h</mark></strong></p>



<p>This code implements several utilities : random cryptographic <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">seed</mark></strong> generation, exceptions, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">parser</mark></strong>, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">time</mark></strong> management. They are quite standard but essential components, for the cryptography processes and the block <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">timestamp</mark></strong></p>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.forensicxs.com/bitcoin-core-v0-1-a-code-walkthrough/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Database Caching 1/47 queries in 0.024 seconds using Disk

Served from: www.forensicxs.com @ 2025-12-29 17:45:44 by W3 Total Cache
-->