Go to file
Jay Graber 4ee91cc0f5 Update readme for magic-wormhole 2017-08-02 17:18:35 -07:00
xcat Modify cli to allow import and export to work with magic-wormhole transfer 2017-08-02 16:10:15 -07:00
.gitignore Repackage as python module 2017-07-28 17:23:32 -07:00
README.md Update readme for magic-wormhole 2017-08-02 17:18:35 -07:00
setup.py Repackage as python module 2017-07-28 17:23:32 -07:00
xcat-runner.py Repackage as python module 2017-07-28 17:23:32 -07:00

README.md

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 code, 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 this code, clone the repo and install as a python package.

git clone https://github.com/zcash/zbxcat.git
pip install zbxcat

To install dependencies, run:

pip install -r requirements.txt

You'll have to clone the repository to install python-zcashlib.

git clone https://github.com/arcalinea/python-zcashlib.git
pip install <path to python-zcashlib>

Run Zcash and Bitcoin daemons locally, on whichever network you want to trade on (recommended: testnet, regtest).

Make sure the rpcuser and rpcpassword values are set in your zcash.conf or bitcoin.conf files.

Example ~/.zcash/zcash.conf file:

rpcuser=user
rpcpassword=password

Example trade

You can try this on regtest on one computer, or on testnet across two computers.

Since this is beta software that is still under active development, we recommend that you do not trade more than you can afford to lose on mainnet.

We use the term "seller" for whoever initiates the trade, and "buyer" for whoever fulfills the other end.

Seller:

To initiate a new trade, the seller enters all the necessary trade data and saves it under a tradeid. We will use the tradeid "testtrade" for this example. The amounts being traded will have to be agreed upon in advance, and the seller will need the buyer's destination addresses on both chains.

xcat newtrade testtrade

After creating, the seller exports the trade data encoded as a hex string to transfer the terms of the trade to the buyer. They can send this hex string to the buyer through email or any other channel, but there is also built-in support to transfer the data directly between two computers through magic-wormhole.

A standard export. Returns a long hex string which the seller sends to the buyer.

xcat exporttrade testtrade

An export using magic-wormhole, which uses a short passphrase the seller must communicate to the buyer.

xcat -w exporttrade testtrade

Buyer:

To examine trade, buyer imports it. A standard import requires the full hex string.

xcat importttrade testtrade <hexstring>

An import using magic-wormhole, which prompts the user for the short passphrase generated by the seller.

xcat -w importtrade

If it looks ok, inform seller to proceed.

Seller:

Funds sell p2sh. They can use the checktrade command to automatically take the next step in this trade.

xcat checktrade testtrade

Buyer:

Funds buy p2sh, also by using checktrade command to automatically proceed.

xcat checktrade testtrade

Seller:

Redeems buyer p2sh.

xcat checktrade testtrade

Buyer:

Redeems seller p2sh. The secret they need to redeem will be automatically parsed from the seller's redeemtx on the blockchain.

xcat checktrade testtrade

Trade is done! Buyer or seller can check the status again, but it will indicate that it is complete.

Testing and Development

You can 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 <path-to-package-repo>

To install our code as a python package in editable mode, passing in the directory containing setup.py should work.

pip install -e <directory that setup.py for xcat is in>