A working reference implementation of Coin Join that can easily be ported to any language.
- RegTest Setup
- Maturing Coins
- Install
- Running the Demo
- Troubleshooting
- Roadmap
You will need:
- Build Tools
- Docker
- Dashmate
- RegTest
See #12.
Before running the demo, generate some blocks:
./bin/dash-cli-generateblocks 20
You'll get some errors the first time you try to run the demo, generate even more blocks:
./bin/dash-cli-generateblocks 105
If you still get some errors on the 3rd run, just generate a few more for good measure:
./bin/dash-cli-generateblocks 10
git clone https://github.com/dashhive/DashJoin.js.git
pushd ./DashJoin.js/
npm ci --only=production
-
Make sure the tests still pass:
(the tests replay known-good transactions from scratch)npm run test
-
Then run the demo in two different screens:
# in the FIRST screen node ./demo.js 'foo'
# in the SECOND screen node ./demo.js 'bar'
-
You may need to watch the logs on each of the
dashd
instances to find which one has been chosen for the coinjoin service (the ids are non-deterministic / random):docker ps | grep 'dashd:' | grep '_local_[1-3]' docker logs --since 1m -f e04133d8696b
There are two categories you're likely to encounter:
- Coins / Coinbase / Block Height isn't mature.
For these, the solution is to generate more transactions, and try again:
(this functionality is documented only to work on Linux)./bin/dash-cli-generateblocks 100
- Disk space (or other system resources) is/are low.
All sorts of strange things will happen. Doing a reset may help.~/dashmate/bin/dashmate group stop docker ps -aq | xargs docker stop
~/dashmate/bin/dashmate group reset
You may need to~/dashmate/bin/dashmate group start
stop
andstart
a second time to get everything to come back up - it's not entirely deterministic. That said, just onereset
should do.
Example immature coinbase error:
{
"code": -26,
"message": "bad-txns-premature-spend-of-coinbase, tried to spend coinbase at depth 10"
}
Low disk space (below 90% or below 4gb free) can cause seemingly random and uncorrelatable errors, hangups, etc.
demo.js
still has a lot of business logic that will need to be carefully
teased out and abstracted to turn this into a library.
The parsers and packers are a good chunk of it, but the networking is all in
demo.js
for now.
The actual signing logic is in dashtx
and the wallet logic is built from the
other dash*
libraries, which are complete and fit for general use.