An implementation of Greg Maxwell's Merkle approach to proving Bitcoin liabilities, in Clojure.
An example partial graph from the [full example accounts list]
accounts-json, for satoshi
:
An example complete graph from a [simpler accounts list] trivial:
Here's how to reproduce the above graphs using the CLI. You'll need
[accounts-deterministic.json
] accounts-json and
[trivial-deterministic.json
] trivial to follow along. The output
is minimal (whitespace-light) so I'd recommend piping it through
[jq .
] jq if you want to read it, but the prettier way to view
results is to render them with [GraphViz] gv using the supplied
converter.
./poltree.sh completetree accounts-deterministic.json >complete-tree.json
# Or...
cat trivial-deterministic.json | ./poltree.sh completetree >trivial-complete.json
# Or if you've installed jq (Debian etc: jq) and prefer pretty JSON...
cat trivial-deterministic.json | ./poltree.sh completetree | jq .
# Or if you've installed extra bits (Debian etc: graphviz, libjson-perl)...
cat trivial-deterministic.json | ./poltree.sh completetree \
| perl tools/s11n-to-dot.pl | dot -Tpng >trivial-complete.png
./poltree.sh partialtree satoshi complete-tree.json >satoshi-partial.json
# You get the idea. Altogether now...
cat accounts-deterministic.json | ./poltree.sh completetree \
| ./poltree.sh partialtree satoshi | perl tools/s11n-to-dot.pl \
| dot -Tpng >satoshi-partial.png
Since I imagine this is most likely to be used directly from other Clojure code by exchanges if used at all, the command line interface only really supports simple testing (account list input, complete tree output) right now. The Clojure interface is in core.clj.
I don't do lein/maven/gradle. The libraries/versions I used were as follows (but earlier versions may very well work):
- Java 1.7 (Oracle's one)
- Clojure 1.4
- data.json (project;
.jar
direct from Maven: v0.2.4) - math.numeric-tower (project;
.jar
direct from Maven: v0.0.4)
Licence: the GPL-compatible (but less viral) [Mozilla Public License v2.0] MPL2, any exceptions being noted in the affected file(s).
- more validation of parameters
- more tests (including formally running on Olivier Lalonde's test data)