Today I reading bitcoind src, and try to find out where is pubkey script executed when node received new block with transaction, at example transaction from new block may not be exist in mempool
Find function that execute script:
https://github.com/bitcoin/bitcoin/search?utf8=%E2%9C%93&q=EvalScript src/script/interpreter.cpp in this file source code of EvalScript function
Used only in this 2 files:
src/policy/policy.cpp src/script/sign.cpp Review
sign.cppEvalscript -> CombineSignatures -> /src/bitcoin-tx.cpp: MutateTxSign -> MutateTx -> CommandLineRawTx -> main
This functions used when we create ne transactions
Review
policy.cppEvalscript -> AreInputsStandard -> /src/main.cpp: AcceptToMemoryPool
AcceptToMemoryPool
src/main.cpp later
src/wallet/wallet.cpp -> CommitTransaction - this is create own transaction functional
src/rpcrawtransaction.cpp -> sendrawtrnsaction - rpc function send rawtx
src/txmempool.cpp -> no calls only comments
Last one is
src/main.cppAcceptToMemoryPool -> ProcessMessage on message "tx" , new single tx to pool received AcceptToMemoryPool -> DisconnectTip
DisconnectTip -> InvalidateBlock invaludate block and send all transaction back to pool with all verifications and script eval
DisconnectTip -> ActivateBestChainStep :
// Disconnect active blocks which are no longer in the best chain.
bool fBlocksDisconnected = false;
while (chainActive.Tip() && chainActive.Tip() != pindexFork) {
if (!DisconnectTip(state))
return false;
fBlocksDisconnected = true;
}
If we have orphan tak out transactions from orphan to pool with all verifications
NO more other links found
From this I can conclude that in case node with bitcoind received new block with transactions that not in mempool we add this tx to blockchain without pubkeyscript execute.
Consequently if same "honest" miner include tx with invalid script, at example incorrect signature that spent same one coins, all bitcoind nodes add it to blockchain without eval script and not detect this
It is not posible to be true! Where is my error?