zbxcat/README.md

117 lines
3.6 KiB
Markdown
Raw Normal View History

2017-08-01 13:25:50 -07:00
# Workflow for a new trade
2017-08-01 13:32:09 -07:00
Install our code as a python package in editable mode. Installing relative to the directory containing `setup.py` should work.
2017-08-01 13:33:01 -07:00
2017-08-01 13:32:09 -07:00
`pip install -e <directory that setup.py for xcat is in>`
### Seller:
2017-08-01 13:25:50 -07:00
To initiate a new trade, seller creates a trade and names it.
2017-08-01 13:33:01 -07:00
2017-08-01 13:25:50 -07:00
`xcat newtrade testtrade`
After creating, they are prompted to export it as hex, to transfer info to the buyer.
2017-08-01 13:33:01 -07:00
2017-08-01 13:25:50 -07:00
`xcat exporttrade testtrade`
2017-08-01 13:33:01 -07:00
2017-08-01 13:25:50 -07:00
Copy the resulting hex string and send it to the buyer.
2017-08-01 13:32:09 -07:00
### Buyer:
2017-08-01 13:33:24 -07:00
To examine trade, buyer imports it.
2017-08-01 13:25:50 -07:00
`xcat importttrade <hexstring> testtrade`
If it looks ok, inform seller to proceed.
2017-08-01 13:32:09 -07:00
### Seller:
2017-08-01 13:25:50 -07:00
Funds sell p2sh. They can use the checktrade command to automatically take the next step in this trade.
2017-08-01 13:33:01 -07:00
2017-08-01 13:25:50 -07:00
`xcat checktrade testtrade`
2017-08-01 13:32:09 -07:00
### Buyer:
2017-08-01 13:25:50 -07:00
Funds by p2sh. Also uses checktrade command locally.
2017-08-01 13:33:01 -07:00
2017-08-01 13:25:50 -07:00
`xcat checktrade testtrade`
2017-08-01 13:32:09 -07:00
### Seller:
2017-08-01 13:25:50 -07:00
Redeems buyer p2sh.
2017-08-01 13:33:01 -07:00
2017-08-01 13:25:50 -07:00
`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 seller, so they have the seller's redeem_tx. (this is a temporary measure)
2017-08-01 13:33:01 -07:00
2017-08-01 13:25:50 -07:00
`xcat exportrade testtrade`
2017-08-01 13:32:09 -07:00
### Buyer:
2017-08-01 13:25:50 -07:00
Imports exported trade.
2017-08-01 13:33:01 -07:00
2017-08-01 13:25:50 -07:00
`xcat importtrade <hexstring> testtrade`
Redeems seller p2sh.
2017-08-01 13:33:01 -07:00
2017-08-01 13:25:50 -07:00
`xcat checktrade testtrade`
Tx is done! Buyer or seller can check the trade again, but the status will indicate that it is complete.
# ZBXCAT
2017-06-15 10:58:22 -07:00
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.
2017-05-12 16:10:06 -07:00
Bitcoin scripts use the rpc proxy code in python-bitcoinlib, and Zcash script will use python-zcashlib (a Zcash fork of python-bitcoinlib).
2017-06-15 10:58:22 -07:00
## Setup
2017-06-15 10:58:22 -07:00
To successfully run this, you'll need python3, the dependencies installed, and a bitcoin daemon running in regtest mode.
2017-05-12 16:10:06 -07:00
To install python3 in a virtualenv, run this command from the top level of the directory:
```
virtualenv -p python3 venv
source venv/bin/activate
```
2017-05-12 16:10:06 -07:00
To install dependencies, run:
```
pip install -r requirements.txt
```
2017-05-12 16:34:30 -07:00
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.
2017-05-12 16:34:30 -07:00
```
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.
2017-05-12 16:34:30 -07:00
To install python-zcashlib from your local filesystem path in editable mode:
2017-05-12 16:34:30 -07:00
`pip install --editable (-e) <path-to-zcashlib-fork-of-python-bitcoinlib>`
2017-06-15 10:58:22 -07:00
## 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
```
2017-05-12 16:34:30 -07:00
Be sure to run a Zcash daemon in regtest mode.
```
zcashd -regtest -txindex=1 --daemon
```
2017-06-15 10:58:22 -07:00
## Misc
I used the module [future](http://python-future.org/futurize.html) to make existing python2 code for the rpc interface compatible with python3.