We now describe the process of script execution in Bitcoin.
In order to validate a new transaction, the input (signature script) and the output of the former transaction (pubkey script) are concatenated. Once concatenated, the script is executed according to the scripting language. During execution, constants, denoted by <..> are pushed onto the stack, and opcodes execute their respective actions by taking into account the topmost stack value.
In Figure 3.4, we depict an example of the validation of transaction 2 that spends a former output of transaction 1. The output and input script are concatenated (signature script first and then the PubKey script). In a first step, the two constants
Figure 3.4 Script execution for a P2PKH transaction.
signature is valid, the script returns true, meaning that the input of transaction 2 is allowed to spent the output 1 of transaction 1.