Skip to main content
added 110 characters in body
Source Link
halftimepad
  • 1.4k
  • 11
  • 16

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 ) and. It has an option to trace non-standard transactions: dbdump.py --search-blocks=NONSTANDARD_CSCRIPTS

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.

#!/usr/bin/env python 

from BCDataStream import *
import deserialize

def extract_script(d):

 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'   
     
  
 return None


def findlock(filename):
  
    f = open(filename, 'r')
    
    magic=f.read(4)
    magicref='f9beb4d9'.decode('hex')

    while magic:
        size=f.read(4)[::-1].encode('hex')
        N=int(size,16)

        blk = deserialize.BCDataStream()
        blk.write(f.read(N))
        d=deserialize.parse_Block(blk)
        extract_script(d)
 
        magic=f.read(4)

    f.close()
    return None

def test():
     findlock('blk0001.dat')
     findlock('blk0002.dat')
     findlock('blk0003.dat')


if __name__ == '__main__':
    test()

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.

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 ) and built on that a python program to study my local blk000x.dat files with the blockchain info. BCDataStream and deserialize come from bitcoin tools.

#!/usr/bin/env python 

from BCDataStream import *
import deserialize

def extract_script(d):

 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'   
     
  
 return None


def findlock(filename):
  
    f = open(filename, 'r')
    
    magic=f.read(4)
    magicref='f9beb4d9'.decode('hex')

    while magic:
        size=f.read(4)[::-1].encode('hex')
        N=int(size,16)

        blk = deserialize.BCDataStream()
        blk.write(f.read(N))
        d=deserialize.parse_Block(blk)
        extract_script(d)
 
        magic=f.read(4)

    f.close()
    return None

def test():
     findlock('blk0001.dat')
     findlock('blk0002.dat')
     findlock('blk0003.dat')


if __name__ == '__main__':
    test()

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.

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: dbdump.py --search-blocks=NONSTANDARD_CSCRIPTS

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.

#!/usr/bin/env python 

from BCDataStream import *
import deserialize

def extract_script(d):

 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'   
     
  
 return None


def findlock(filename):
  
    f = open(filename, 'r')
    
    magic=f.read(4)
    magicref='f9beb4d9'.decode('hex')

    while magic:
        size=f.read(4)[::-1].encode('hex')
        N=int(size,16)

        blk = deserialize.BCDataStream()
        blk.write(f.read(N))
        d=deserialize.parse_Block(blk)
        extract_script(d)
 
        magic=f.read(4)

    f.close()
    return None

def test():
     findlock('blk0001.dat')
     findlock('blk0002.dat')
     findlock('blk0003.dat')


if __name__ == '__main__':
    test()

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.

Source Link
halftimepad
  • 1.4k
  • 11
  • 16

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 ) and built on that a python program to study my local blk000x.dat files with the blockchain info. BCDataStream and deserialize come from bitcoin tools.

#!/usr/bin/env python 

from BCDataStream import *
import deserialize

def extract_script(d):

 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'   
     
  
 return None


def findlock(filename):
  
    f = open(filename, 'r')
    
    magic=f.read(4)
    magicref='f9beb4d9'.decode('hex')

    while magic:
        size=f.read(4)[::-1].encode('hex')
        N=int(size,16)

        blk = deserialize.BCDataStream()
        blk.write(f.read(N))
        d=deserialize.parse_Block(blk)
        extract_script(d)
 
        magic=f.read(4)

    f.close()
    return None

def test():
     findlock('blk0001.dat')
     findlock('blk0002.dat')
     findlock('blk0003.dat')


if __name__ == '__main__':
    test()

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.