Skip to content

Commit

Permalink
added license and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge and Stefan committed Sep 6, 2016
1 parent 40bde07 commit d309d06
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 136 deletions.
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2016 Jorge Martinez Pizarro and Stefan Richter

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
1 change: 0 additions & 1 deletion README

This file was deleted.

145 changes: 145 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
* Bitcoin Graph Explorer

Probably the first project bringing together Scala and bitcoin, Bitcoin Graph
Explorer (BGE) parses the blockchain, stores the relevant data in databases, and gives
the user access to powerful analysis tools like the closure of an address with
regard to probable co-ownership. We offer a REST API for easy access.

Please see https://bitcoinprivacy.net/ for a reference project using BGE. There
you can also find a publicly running example of the API under
https://api.bitcoinprivacy.net.

** REQUIREMENTS

*** postgres

BGE uses [[https://www.postgresql.org/][postgres]] for storing its main database. Install and run the service
according to your OS.

*** bitcoind

BGE uses a locally running [[https://bitcoincore.org][bitcoin daemon]] in order to read its raw files and
connect to it via bitcoin protocol. Install, run and let sync before starting
BGE.

*** hardware

Using LMDB for UTXOs means that this should work ok even on machines with not
too much RAM. BGE is heavily disk bound, though:

We recommend an SSD with at least three times the space the raw blockchain
needs. At the moment that means about 270G including everything and takes about
24 hours to catch up.


** INSTALLATION

*** automatic

For easiest installation on linux 64-bit architectures use [[http://nixos.org/nix/][nix]]. Install nix
first (or use nixos), then

#+BEGIN_SRC sh
git clone https://github.com/bitcoinprivacy/nixpkgs
nix-env -f nixpkgs -i bge
#+END_SRC

*** manual

If you don't want nix or need this to run on a different architecure, you can
install bge manually. Install [[http://www.scala-sbt.org/][sbt]] first, then

#+BEGIN_SRC sh
git clone https://github.com/bitcoinprivacy/Bitcoin-Graph-Explorer bge
cd bge
#+END_SRC

Change build.sbt in order to import the correct [[https://github.com/deephacks/lmdbjni][LMDB JNI]] architecture library.
E.g., for mac use lmdbjni-osx64 instead of lmdbjni-linux64. Then

#+BEGIN_SRC sh
sbt assembly publish-local
cd api
sbt assembly
#+END_SRC

Modify the bge and api/bgeapi scripts such that they point at the correct jars
in target/scala-2.11/bge-assembly-3.0.jar and
api/target/scala-2.11/bgeapi-assembly-1.0.jar. Put these scripts somewhere in your
PATH.

LMDB JNI needs access to libstdc++.so.6, so set LD_LIBRARY_PATH accordingly
before running bge manually. Nix builds a wrapper script for this automatically.


** USAGE

*** Configuration

Per default, bge assumes user "postgres" with password "trivial" in psql. Either
configure psql like this or override configuration file reference.conf with
application.conf, changing this line
#+BEGIN_SRC
password = "trivial"
#+END_SRC
with the password you have defined in the psql installation. The configuration
is done via [[https://github.com/typesafehub/config][typesafe config]]. Read the doc for all the possibilities or simply
include -Dconfig.file=<your config file> in the java -jar call.

*** Start

#+BEGIN_SRC
bge start
#+END_SRC
initializes everything and begins populating the database with all blocks
available in the bitcoind raw data at the moment. When it is finished, it
automatically does

#+BEGIN_SRC
bge resume
#+END_SRC

to keep up with the incoming new blocks. If you just want to populate the DB, do

#+BEGIN_SRC
bge populate
#+END_SRC
.

*** API

#+BEGIN_SRC sh
bgeapi [port]
#+END_SRC

starts the api on localhost, default port is 8080.

These are all available queries:

#+BEGIN_SRC
GET /blocks/:from/:until
GET /blocks/summary
GET /distribution/:limit
GET /inputs/:tx/:from/:until
GET /inputs/:tx/summary
GET /movements/:ad/:from/:until
GET /movements/:ad/summary
GET /outputs/:tx/:from/:until
GET /outputs/:tx/summary
GET /richlist/addresses/:block_height/:from/:until
GET /richlist/addresses/:block_height/summary
GET /richlist/wallets/:block_height/:from/:until
GET /richlist/wallets/:block_height/summary
GET /stats
GET /stats/history
GET /tx_utxos/:tx/:from/:until
GET /tx_utxos/:tx/summary
GET /txs/:block_height/:from/:until
GET /txs/:block_height/summary
GET /utxos/:ad/:from/:until
GET /utxos/:ad/summary
GET /wallet/:ad/:from/:until
GET /wallet/:ad/summary
#+END_SRC


2 changes: 1 addition & 1 deletion api/src/main/scala/api/models/Block.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object Block extends db.BitcoinDB
DB withSession { implicit session =>

val max = stats.map(_.block_height).max.run.getOrElse(0)
val blockslist = for (b<- blockDB.filter(_.block_height < max).sortBy(_.block_height asc).drop(from).take(until-from))
val blockslist = for (b<- blockDB.filter(_.block_height <= max).sortBy(_.block_height asc).drop(from).take(until-from))
yield (b.hash, b.block_height, b.txs,b.btcs, b.tstamp)

blockslist.run map (p => Block(Hash(p._1).toString, p._2,p._3,p._4,p._5))
Expand Down
130 changes: 0 additions & 130 deletions bge_ng.org

This file was deleted.

2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "2.1.5" % "test",
"org.deephacks.lmdbjni" % "lmdbjni" % "0.4.6",
"org.deephacks.lmdbjni" % "lmdbjni-linux64" % "0.4.6",
// change here for different architectures
"com.typesafe.scala-logging" %% "scala-logging" % "3.4.0",
"ch.qos.logback" % "logback-classic" % "1.1.7"
// change here for different architectures
)

libraryDependencies ~= { _.map(_.exclude("org.slf4j", "slf4j-simple")) }
Expand Down
3 changes: 0 additions & 3 deletions todo.org

This file was deleted.

0 comments on commit d309d06

Please sign in to comment.