14
votes
Accepted
Why many classes in the Bitcoin Core prefix with a `C` while it is prohibited in the developer notes?
These classes predate the coding style guidelines. Guidelines are a recommendation for newly added code and refactoring patches for the purpose of only changing the coding style are discouraged.
In ...
11
votes
How to understand Bitcoin source code
I have a different approach to it. You can use this too.
Bitcoin uses Doxygen comments to explain the code.
You can take the most recent copy of the code, build class hierarchy yourself using ...
9
votes
Accepted
How to understand Bitcoin source code
Recently I was in a situation where I had to work on Bitcoin-core c++ code base. Being from c# background, I had the same problem which you faced. I also looked into the solutions which everyone is ...
9
votes
Accepted
Is it doable to supplant the current Bitcoin Core implementation with another rewritten in a different language?
There are many implementations of the Bitcoin protocol written in other languages, e.g., Bcoin in JavaScript, btcd in Go, bitcoin-s in Scala, etc.
Bitcoin Core is widely considered as the "...
9
votes
Accepted
What version of C++ is used in Bitcoin Core?
Bitcoin Core:
v0.1.0...v0.12.x: C++03
v0.13.0...v0.21.x: C++11
v22.0...: C++17
9
votes
Was the addition of OP_NOP codes in Bitcoin 0.3.6 a hard or soft fork?
When the script interpreter encounters an unknown opcode (the default: case inside the switch statement), it returns false. That aborts verification and considers the transaction to be invalid. This ...
7
votes
Why Bitcoin Core source code use #include bracket syntax instead of quote syntax
Double quotes means that the compiler will search for the include relative to the source file. Angle brackets means the compiler will search only the include paths. By using angle brackets and ...
5
votes
Is it doable to supplant the current Bitcoin Core implementation with another rewritten in a different language?
It is extremely difficult to write a specification for a complex format that is 100% watertight and has no poorly defined corner cases. Further even if the specification itself is watertight it's ...
5
votes
Accepted
Why is CAmount a signed integer?
CAmount is used for multiple purposes in Bitcoin Core, not just in transaction validation logic. It is also used to represent the net effect transactions have on wallet balance, for example, and that ...
5
votes
What protocol do bitcoin nodes use to talk to each other?
What protocol do bitcoin nodes use to talk to each other?
Most Bitcoin nodes will primarily use:
Layer
Protocol
Application Layer
Bitcoin Protocol
Transport Layer
Transport Control Protocol (TCP)
...
4
votes
Accepted
Why future Bitcoin Core release shouldn't be in python?
Apart, from having to tear down the entire code, and re-write it in python and check for vulnerabilities,
This is what is known as a self-answering question. The obstacles you list are not trivial.
...
4
votes
Bitcoin value as int64_t or as double
I want to do program that doing some calculations with bitcoin values.
I know bitcoin have 8 digits after decimal point (please correct me).
There is no decimal in bitcoin at code level. There is no &...
3
votes
Accepted
Was libbitcoin a part of bitcoin core in the past?
libbitcoin is not, and was never a part of Bitcoin Core. Both are standalone implementations of the Bitcoin protocol.
Bitcoin Core, in its build process, will create a number of files named "...
3
votes
Accepted
Why does the chacha20 implemented in the Bitcoin Core use a 64 bit nonce?
It doesn't matter. The old version has a 64-bit nonce and 64-bit counter, while the new one replaces it with a 96-bit nonce and 32-bit counter. For our purposes however, they can reasonably both be ...
3
votes
Accepted
What is the actual working implementation code used in double hashing a block header in c++?
Note that I am analyzing your code as if I compiled it as is. That means anything that is commented out is ignored.
The first major issue is this line:
kk = GetBinaryStringFromHexString(...
3
votes
Was the addition of OP_NOP codes in Bitcoin 0.3.6 a hard or soft fork?
There is nothing to suggest in the code diff you linked to that older clients ignored unknown opcodes in script execution and effectively treated them as OP_NOPs. That doesn't guarantee they didn't of ...
3
votes
Accepted
What is the nBits field in the CBlockHeader class?
I interpret that it's a representation of the difficulty for the block. ... Is my understanding correct?
Yes, it is a compact representation of the network target for that block. The target being a ...
3
votes
Accepted
Is it possible to use the getboolarg function in interpreter.cpp
interpreter.cpp is part of the internal libbitcoin_consensus library, while GetBoolArg() is in common/args.{h/cpp} which is part of the internal libbitcoin_common library. The Makefile specifies a ...
2
votes
What is most efficient way to validate bitcoin target (difficulty) value in C++
Bitcoin Core has its own arith_uint256 class for calculations on 256-bit unsigned integers. Its code to convert "bits" (so-called compact format) to arith_uint256 can be found in arith_uint256::...
2
votes
How to debug bitcoin core in "real time"
There is no "makefile" command.
If you don't build the project, there is no way for you to debug it. The released binaries do not contain any debugging symbols so it will be very difficult for you to ...
2
votes
How to understand wallets?
The address 13ggzjqKyFGQZtxNWUoG4BFDPAgdBijUe4 is generated from a different word list, not the one you mentioned.
2
votes
Accepted
How to update an older C++ code from Antonopoulos' book to work with current libraries?
I just found out there is a github where the code is updated.
The specific code for addr.cpp is this.
Compilation works with --static e.g. g++ -o addr addr.cpp $(pkg-config --cflags --libs --static ...
2
votes
Accepted
What is cs_main? Why is it called cs_main?
What is cs_main?
cs_main is a recursive mutex which is used to ensure that validation is carried out in an atomic way. It guards access to validation specific variables (such as CChainState and CNode)...
2
votes
How to generate private/public key pairs in c++ using openssl
Usually you'd just pass around the EVP_PKEY structure to other OpenSSL calls.
To put the secret into memory, you can use
char* secret_key;
BIO* bio_priv = BIO_new(BIO_s_mem());
...
2
votes
Accepted
How does AttachChain function works in the Bitcoin Core?
ReadBestBlock doesn't look at the locator it is given, rather it reads a specific record from the wallet database and loads the data into the provided locator. locator is used as an output parameter.
...
2
votes
What protocol do bitcoin nodes use to talk to each other?
Bitcoin nodes use a custom tcp-based protocol to communicate with each other. There's a work in progress to deploy a new one with some privacy enhancements.
2
votes
How to get block height from CTransactionRef object in Bitcoin C++ code?
The block height for a transaction may be recorded in two different places: the txindex, or in the wallet. Both of these have functions that can take a transaction hash and return information about ...
1
vote
How do I hash header block with C++
I have a class/function which will format them into a hex string, which i get as
You don't format as hex-string, it's 80-bytes raw bytes, serialized as:
- version (4-bytes little-endian)
- ...
1
vote
Feasibility of using Ring Signatures with CoinJoin Technique
Using ring signatures off-chain to form a coinjoin transaction sounds hard, especially since because BTC doesn't have ring signature support without a hard fork or a soft fork.
You may find Cashfusion,...
1
vote
Accepted
How to get block height, if I have only block header?
It looks like this function from validation.h does the job:
CBlockIndex* LookupBlockIndex(const uint256& hash)
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
c++ × 94bitcoin-core-development × 26
bitcoin-core × 19
bitcoind × 12
blockchain × 6
cryptography × 6
compiling × 6
block × 5
libbitcoin × 5
altcoin × 4
sha256 × 4
validation × 4
block-header × 4
source-code × 4
message × 4
transactions × 3
mining-theory × 3
hash × 3
development × 3
linux × 3
p2p × 3
openssl × 3
c × 3
wallet × 2
private-key × 2