"Mastering Bitcoin" by Antonopoulos in its P2SH section describes how the unlocking and locking scripts are executed and evaluated by nodes. The author gives this as example of an unlocking script:
<Sig1> <Sig2> <redeem-script>
and the locking script:
HASH160 <20-byte hash of redeem script> EQUAL
Then there's this:
The two scripts are combined in two stages. First, the redeem script is checked against the locking script to make sure the hash matches: [...]
- Does that mean that not all validations follow just plain "concatenate unlocking and locking script and execute' method of validation? As a beginner I'd expect that for uniformity and security all transactions should follow this same uniform rule. Based on the quote, it looks like the P2SH (or possibly other types) scripts are evaluated in a different manner?
- If the answer is yes, how does the Bitcoin node know which type of unlocking/locking script type should be applied for each particular transaction?
- Also, if the answer is yes, are there other deviations from the plain "concatenate and execute" rule?
- Say there's a very old legacy node that's not P2SH enabled. The transaction above would still evaluate to true (if the provided redeem script is right) as the stack would have a TRUE on top at the end of execution?