I was wondering if it possible for a bitcoin script check part of the output of the transaction. Lets say, I want to check that the transaction is splited equaly between 3 outputs, I dont care which.
2 Answers
No. With current script. There is a locking script, and an unlocking script. Basically the locking script (scriptPubKey) in the old transaction puts down the condition to spend BTC. The scriptSig in the spending tx must provide the data to satisfy these conditions. Problem is, that current script language does not provide an access to data „outsides“ the scripting language. So you would have to define conditions in the locking script „upfront“, while creating the tx. But then the unlock script does not allow for operators, and only accepts „push data“, like pushing the signatures or pubkey. This might change in the future, discussions are running to implement a new scripting subsystem, which is currently checked in a side chain. This will allow to access oracle data (not with „simplicity“ though), which could be a previous tx as well.
Keywords: RSK Elements, Ivy, Simplicity, Bitcoin Smart Contracts, Scriptless Scripts and possibly some more.
Short answer: currently no.
No. Bitcoin script language does not have such instructions.