I agree that the fact that this part of the transaction process is located in the qt/ directory is somehow confusing, since as you mentionned, we can compile without the wallet. This means that a node running without the wallet would not have the code to change the transaction status.
Two more interesting bit of code are located in /primitives/ and are worth reading and understanding. They are small but essential.
/primitives/block.cpp is what creates the block, block.h has the block structure header, which is one of the most important part of the blockchain, less than 200 lines of code, but very interesting.
/primitives/transactions.cpp is even more critical, it is where the transactions are serialized and broacasted to the network.
I would point out that there is almost no comments in these source and that's is lacking to to their abstract nature.
The transactions, and transaction NumConfirmations = 6; is located in src/qt/transaction.cpp for a long time, Bitcoin 14.0 has it, and even Dash version 10 (first version have it in the same place). I guess it is there forever.
When you are doing an altcoin or playing with the Bitcoin source, it is essential to change this value to something like 1 or 2, otherwise the transactions never change status.
As for a mature coin, of course 6+ confirmation is as you demonstrated a bare minimum to insure the security of the blockchain. But when you are playing with the core, it is a pita to have 6 node running
The number of confirmation is coded in /src/qt/transactionrecord.h
I am completely unaware of this, anyway thanks for pointing it out. I am confused right now!
Is qt code related to the bitcoin network? What is the use of coding number of confirmations in the wallet code? AFAIK, we can create our own bitcoin client which is not at all related to qt wallet! I believe this code is like a safe limit for accepting transactions and has nothing to do with confirmations.
We also need to note that, satoshi in his whitepaper has clearly said that these 6 confirmations are enough to prevent the double spending, that's the reason why this isn't present in the main code and wouldn't make sense if it is present so. Let me quote the lines from his paper
P < 0.001
q=0.10 z=5
q=0.15 z=8
q=0.20 z=11
q=0.25 z=15
q=0.30 z=24
q=0.35 z=41
q=0.40 z=89
q=0.45 z=340
Here
p is the chance of an attacker leading the longest chain and trying to double spend.
q is the hashing power that a miner controls
z is the number of blocks required by miner to overtake the chain and double spend the tx.
When a miner for instance controls 10% of total hashing power, he needs to overtake 5 blocks for him to reverse. Even though he passes then the probability is just 0.1%
So for safe terms, the 6 confirmations should be coded in the qt client. It has nothing to do with bitcoin network as far as I know.