A bitcoin transaction script language / vm implementation in python.
Python
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Guide
bitrans-test
btct
scripts
.gitignore
README.org
bytestream.py
client.py
compile.py
machine.py
opfns.py
ops.py
parameters.py
rpc.py
script.py
transaction.py

README.org

Bitrans

A bitcoin transaction script language / vm implementation in python. Built based on info from the bitcoin wiki.

Getting it running

  • Install bitcoind
    • Guide for installing using Macports on Maverick guide
  • Enable the bitcoin rpc server and historical transaction indexing in ~/bitcoin.conf by adding/uncommenting the following lines and replacing bracketed things:
    • txindex=1
    • server=1
    • rpcuser=[yourUser]
    • rpcpassword=[yourPass]
    • rpcport=8332
    • rpcconnect=127.0.0.1
  • Spin up a bitcoind daemon, rebuilding the historical index. This will take some time to complete; about a day for all transactions. You will be able to work with the current state of the index, though, so transactions from early blocks should work pretty quickly.
bitcoind -conf=/path/to/your/bitcoin.conf -daemon -reindex
  • Get bitrans:
git clone https://github.com/hackscience/bitrans.git
cd bitrans
  • Install the python ecdsa lib.
  • Fire up python:
python
  • Establish a connection to the bitcoind daemon
>>> import rpc
>>> s = rpc.jsonrpc("yourUser","yourPass")
  • Grab a transaction
    • the transaction id could be found in https://blockchain.info/
    • for testing, we use txid = ‘fff2525b8931402dd09222c50775608f75787bd2b87e56995a7bdd30f79702c4’.
    • Note that if your bitcoind hasn’t finished reindex, the current rpcserver will just return NoneType Error.Just grab a different txid or wait until reindex finishes.
>>> import transaction
>>> t = transaction.transaction('fff2525b8931402dd09222c50775608f75787bd2b87e56995a7bdd30f79702c4',s)
  • Verify the transaction:
t.verify()

Running tests

Install and run nose:

pip install nose
nosetests