diff --git a/README.md b/README.md index 1483663..c161aa7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,54 @@ -# Workflow for a new trade +# ZBXCAT + +A work-in-progress for Zcash Bitcoin Cross-Chain Atomic Transactions + +Bitcoin scripts use python-bitcoinlib, and Zcash scripts use python-zcashlib (a Zcash fork of python-bitcoinlib). + +## Setup + +To successfully run this, you'll need python3, the dependencies installed, and a bitcoin and zcash daemon synced on whichever chain you want to trade on. + +It's recommended that you install python3 in a virtualenv. Run this command from the top level of the directory: +``` +virtualenv -p python3 venv +source venv/bin/activate +``` + +To install dependencies, run: +``` +pip install -r requirements.txt +``` + +To install python-zcashlib for testing and editing, clone the repository to your local filesystem. + +``` +git clone https://github.com/arcalinea/python-zcashlib.git +``` + +# Testing + +Install modules locally in editable mode through pip, so that you can make changes to the code and they will be applied immediately. + +To use pip to install a package in editable mode, use the `-e` flag to pass in the path on your local filesystem: + +`pip install -e ` + +## Run Zcash and Bitcoin daemons locally + +To test, run a Zcash daemon and bitcoin daemon in regtest mode. + +To run a bitcoin daemon in regtest mode, with the ability to inspect transactions outside your wallet (useful for testing purposes), use the command +``` +bitcoind -regtest -txindex=1 -daemon +``` + +Be sure to run a Zcash daemon in regtest mode as well. +``` +zcashd -regtest -txindex=1 --daemon +``` + + +## Workflow for a new trade Install our code as a python package in editable mode. Installing relative to the directory containing `setup.py` should work. @@ -42,75 +92,10 @@ Redeems buyer p2sh. `xcat checktrade testtrade` -**At this stage, we need to manually export the trade again, because we haven't added the `walletnotify` functionality which will let the buyer determine what the seller's redeem tx was.** - -So seller exports trade again and sends to buyer, so they will have the seller's redeem_tx. (this is a temporary measure) - -`xcat exportrade testtrade` - ### Buyer: -Imports trade hexstring received from seller. - -`xcat importtrade testtrade` - -Redeems seller p2sh. +Redeems seller p2sh. The secret they need to redeem will be automatically parsed from the seller's redeemtx on the blockchain. `xcat checktrade testtrade` -Tx is done! Buyer or seller can check the trade again, but the status will indicate that it is complete. - -# ZBXCAT - -A work-in-progress for Zcash Bitcoin Cross-Chain Atomic Transactions - -Contains basic scripts we're still testing in regtest mode on both networks. This may all be refactored as we go. - -Bitcoin scripts use the rpc proxy code in python-bitcoinlib, and Zcash script will use python-zcashlib (a Zcash fork of python-bitcoinlib). - -## Setup - -To successfully run this, you'll need python3, the dependencies installed, and a bitcoin daemon running in regtest mode. - -To install python3 in a virtualenv, run this command from the top level of the directory: -``` -virtualenv -p python3 venv -source venv/bin/activate -``` - -To install dependencies, run: -``` -pip install -r requirements.txt -``` - -To install python-zcashlib for testing and editing, clone the repository to your local filesystem. It is currently on a branch of python-bitcoinlib maintained by @arcalinea. - -``` -git clone https://github.com/arcalinea/python-bitcoinlib.git -cd python-bitcoinlib -git checkout zcashlib -``` - -Then, install the module locally in editable mode through pip, so that you can make changes to the code of python-zcashlib and they will be applied immediately. It is necessary to install python-zcashlib this way for now because the fork of the library likely contains many bugs, which need to be fixed before `zec-p2sh-htlc.py` will work properly. - -To install python-zcashlib from your local filesystem path in editable mode: - -`pip install --editable (-e) ` - -## Run Zcash and Bitcoin daemons locally - -To test, run a Zcash daemon and bitcoin daemon in regtest mode. You may have to change the port one of them runs on, for example with the flag `-port=18445`. - -To run a bitcoin daemon in regtest mode, with the ability to inspect transactions outside your wallet (useful for testing purposes), use the command -``` -bitcoind -regtest -txindex=1 -daemon -port=18445 -``` - -Be sure to run a Zcash daemon in regtest mode. -``` -zcashd -regtest -txindex=1 --daemon -``` - -## Misc - -I used the module [future](http://python-future.org/futurize.html) to make existing python2 code for the rpc interface compatible with python3. +Trade is done! Buyer or seller can check the status again, but it will indicate that it is complete.