I have been looking into the same thing lately to build a "Bitcoin Bestiary" with strange transactions. I have downloaded bitcoin tools (
https://github.com/gavinandresen/bitcointools ). It has an option to trace non-standard transactions:
I have built on that a python program to study my local blk000x.dat files with the blockchain info. BCDataStream and deserialize come from bitcoin tools.
from BCDataStream import *
for t in d['transactions']:
for txOut in t['txOut']:
print "Prev hash: "+(d['hashPrev'][::-1]).encode('hex')+" Script: "+deserialize.decode_script(txOut['scriptPubKey'])+'\n'
f = open(filename, 'r')
blk = deserialize.BCDataStream()
if __name__ == '__main__':
The program dumps the Script in all transactions with the previous block number (I have to improve that, but you can later find the right block). The whole file is about 3 GB.
In my Linux terminal I redirect the output to a scripts.txt file and then use grep to find commands, like:
grep 'IF ' scripts.txt > IF.txt
MIN, IF, DROP, SWAP, for instance, show interesting things. Some of them are errors (see https://bitcointalk.org/index.php?topic=67158.0), some I don't know.