|
1 |
| -# DashJoin.js |
| 1 | +# [DashJoin.js](https://github.com/dashhive/DashJoin.js) |
| 2 | + |
| 3 | +A working reference implementation of Coin Join that can easily be ported to any |
| 4 | +language. |
| 5 | + |
| 6 | +# Table of Contents |
| 7 | + |
| 8 | +- RegTest Setup |
| 9 | +- Maturing Coins |
| 10 | +- Install |
| 11 | +- Running the Demo |
| 12 | +- Troubleshooting |
| 13 | +- Roadmap |
| 14 | + |
| 15 | +# Prerequisites (RegTest) |
| 16 | + |
| 17 | +## RegTest |
| 18 | + |
| 19 | +You will need: |
| 20 | + |
| 21 | +- Build Tools |
| 22 | +- Docker |
| 23 | +- Dashmate |
| 24 | +- RegTest |
| 25 | + |
| 26 | +See <https://github.com/dashhive/DashJoin.js/issues/12>. |
| 27 | + |
| 28 | +## Maturing the Coinbase |
| 29 | + |
| 30 | +Before running the demo, generate some blocks: |
| 31 | + |
| 32 | +```sh |
| 33 | +./bin/dash-cli-generateblocks 20 |
| 34 | +``` |
| 35 | + |
| 36 | +You'll get some errors the first time you try to run the demo, generate even |
| 37 | +more blocks: |
| 38 | + |
| 39 | +```sh |
| 40 | +./bin/dash-cli-generateblocks 105 |
| 41 | +``` |
| 42 | + |
| 43 | +If you still get some errors on the 3rd run, just generate a few more for good |
| 44 | +measure: |
| 45 | + |
| 46 | +```sh |
| 47 | +./bin/dash-cli-generateblocks 10 |
| 48 | +``` |
| 49 | + |
| 50 | +## Install |
| 51 | + |
| 52 | +```sh |
| 53 | +git clone https://github.com/dashhive/DashJoin.js.git |
| 54 | +pushd ./DashJoin.js/ |
| 55 | + |
| 56 | +npm ci --only=production |
| 57 | +``` |
| 58 | + |
| 59 | +## How to Run the Demo |
| 60 | + |
| 61 | +1. Make sure the tests still pass: \ |
| 62 | + (the tests replay known-good transactions from scratch) |
| 63 | + |
| 64 | + ```sh |
| 65 | + npm run test |
| 66 | + ``` |
| 67 | + |
| 68 | +2. Then run the demo in two different screens: |
| 69 | + |
| 70 | + ```sh |
| 71 | + # in the FIRST screen |
| 72 | + node ./demo.js 'foo' |
| 73 | + ``` |
| 74 | + |
| 75 | + ```sh |
| 76 | + # in the SECOND screen |
| 77 | + node ./demo.js 'bar' |
| 78 | + ``` |
| 79 | + |
| 80 | +3. You may need to watch the logs on each of the `dashd` instances to find |
| 81 | + which one has been chosen for the coinjoin service (the ids are |
| 82 | + non-deterministic / random): |
| 83 | + |
| 84 | + ```sh |
| 85 | + docker ps | grep 'dashd:' | grep '_local_[1-3]' |
| 86 | +
|
| 87 | + docker logs --since 1m -f e04133d8696b |
| 88 | + ``` |
| 89 | + |
| 90 | +## Troubleshooting |
| 91 | + |
| 92 | +There are two categories you're likely to encounter: |
| 93 | +
|
| 94 | +1. Coins / Coinbase / Block Height isn't mature. \ |
| 95 | + For these, the solution is to generate more transactions, and try again: \ |
| 96 | + (this functionality is documented only to work on Linux) |
| 97 | + ```sh |
| 98 | + ./bin/dash-cli-generateblocks 100 |
| 99 | + ``` |
| 100 | +2. Disk space (or other system resources) is/are low. \ |
| 101 | + All sorts of strange things will happen. Doing a reset may help. |
| 102 | + ```sh |
| 103 | + ~/dashmate/bin/dashmate group stop |
| 104 | + docker ps -aq | xargs docker stop |
| 105 | + ``` |
| 106 | + ```sh |
| 107 | + ~/dashmate/bin/dashmate group reset |
| 108 | + ``` |
| 109 | + ```sh |
| 110 | + ~/dashmate/bin/dashmate group start |
| 111 | + ``` |
| 112 | + You may need to `stop` and `start` a second time to get everything to come |
| 113 | + back up - it's not entirely deterministic. That said, just one `reset` should |
| 114 | + do. |
| 115 | +
|
| 116 | +Example immature coinbase error: |
| 117 | +
|
| 118 | +```json |
| 119 | +{ |
| 120 | + "code": -26, |
| 121 | + "message": "bad-txns-premature-spend-of-coinbase, tried to spend coinbase at depth 10" |
| 122 | +} |
| 123 | +``` |
| 124 | +
|
| 125 | +Low disk space (below 90% or below 4gb free) can cause seemingly random and |
| 126 | +uncorrelatable errors, hangups, etc. |
| 127 | +
|
| 128 | +## This isn't a library (yet) |
| 129 | + |
| 130 | +`demo.js` still has a lot of business logic that will need to be carefully |
| 131 | +teased out and abstracted to turn this into a library. |
| 132 | + |
| 133 | +The parsers and packers are a good chunk of it, but the networking is all in |
| 134 | +`demo.js` for now. |
| 135 | + |
| 136 | +The actual signing logic is in `dashtx` and the wallet logic is built from the |
| 137 | +other `dash*` libraries, which are complete and fit for general use. |
0 commit comments