diff --git a/Gopkg.lock b/Gopkg.lock index 4bab6d77..1cac8e92 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -5,7 +5,7 @@ branch = "master" name = "github.com/beorn7/perks" packages = ["quantile"] - revision = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9" + revision = "3a771d992973f24aa725d07868b467d1ddfceafb" [[projects]] branch = "master" @@ -34,8 +34,8 @@ [[projects]] name = "github.com/ethereum/go-ethereum" packages = [".","common","common/hexutil","common/math","core/types","crypto","crypto/secp256k1","crypto/sha3","ethclient","ethdb","log","metrics","params","rlp","rpc","trie"] - revision = "b8b9f7f4476a30a0aaf6077daade6ae77f969960" - version = "v1.8.2" + revision = "329ac18ef617d0238f71637bffe78f028b0f13f7" + version = "v1.8.3" [[projects]] name = "github.com/go-stack/stack" @@ -43,6 +43,12 @@ revision = "259ab82a6cad3992b4e21ff5cac294ccb06474bc" version = "v1.7.0" +[[projects]] + name = "github.com/gogo/protobuf" + packages = ["proto"] + revision = "1adfc126b41513cc696b209667c8656ea7aac67c" + version = "v1.0.0" + [[projects]] branch = "master" name = "github.com/golang/glog" @@ -67,12 +73,6 @@ revision = "1ea25387ff6f684839d82767c1733ff4d4d15d0a" version = "v1.1" -[[projects]] - name = "github.com/gorilla/handlers" - packages = ["."] - revision = "90663712d74cb411cbef281bc1e08c19d1a76145" - version = "v1.3.0" - [[projects]] name = "github.com/gorilla/mux" packages = ["."] @@ -107,7 +107,7 @@ branch = "master" name = "github.com/pebbe/zmq4" packages = ["."] - revision = "6decad45434f1cddeccf1dc5d9d86d8249decd19" + revision = "5b443b6471cea4b4f9f85025530c04c93233f76a" [[projects]] name = "github.com/prometheus/client_golang" @@ -125,13 +125,13 @@ branch = "master" name = "github.com/prometheus/common" packages = ["expfmt","internal/bitbucket.org/ww/goautoneg","model"] - revision = "e4aa40a9169a88835b849a6efb71e05dc04b88f0" + revision = "38c53a9f4bfcd932d1b00bfc65e256a7fba6b37a" [[projects]] branch = "master" name = "github.com/prometheus/procfs" packages = [".","internal/util","nfs","xfs"] - revision = "54d17b57dd7d4a3aa092476596b3f8a933bde349" + revision = "8b1c2da0d56deffdbb9e48d4414b4e674bd8083e" [[projects]] name = "github.com/rs/cors" @@ -143,7 +143,7 @@ branch = "master" name = "github.com/syndtr/goleveldb" packages = ["leveldb","leveldb/cache","leveldb/comparer","leveldb/errors","leveldb/filter","leveldb/iterator","leveldb/journal","leveldb/memdb","leveldb/opt","leveldb/storage","leveldb/table","leveldb/util"] - revision = "169b1b37be738edb2813dab48c97a549bcf99bb5" + revision = "714f901b98fdb3aa954b4193d8cbd64a28d80cad" [[projects]] branch = "master" @@ -155,13 +155,13 @@ branch = "master" name = "golang.org/x/crypto" packages = ["ripemd160"] - revision = "182114d582623c1caa54f73de9c7224e23a48487" + revision = "d6449816ce06963d9d136eee5a56fca5b0616e7e" [[projects]] branch = "master" name = "golang.org/x/net" packages = ["websocket"] - revision = "e0c57d8f86c17f0724497efcb3bc617e82834821" + revision = "61147c48b25b599e5b561d2e9c4f3e1ef489ca41" [[projects]] name = "gopkg.in/fatih/set.v0" @@ -184,6 +184,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "4b02d441181efce194d638a8c5ca005955d5cc4e4ff1f23d304429d415339ec7" + inputs-digest = "a463c234bc11d9917876a827f692392845ed89571edc1484ae3e932f555d484b" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..00e051c8 --- /dev/null +++ b/Makefile @@ -0,0 +1,50 @@ +BIN_IMAGE = blockbook-build +DEB_IMAGE = blockbook-build-deb +PACKAGER = $(shell id -u):$(shell id -g) +NO_CACHE = false + +.PHONY: build build-debug test deb + +build: .bin-image + docker run -t --rm -e PACKAGER=$(PACKAGER) -v $(CURDIR):/src -v $(CURDIR)/build:/out $(BIN_IMAGE) make build + +build-debug: .bin-image + docker run -t --rm -e PACKAGER=$(PACKAGER) -v $(CURDIR):/src -v $(CURDIR)/build:/out $(BIN_IMAGE) make build-debug + +test: .bin-image + docker run -t --rm -e PACKAGER=$(PACKAGER) -v $(CURDIR):/src $(BIN_IMAGE) make test + +deb: .deb-image + docker run -t --rm -e PACKAGER=$(PACKAGER) -v $(CURDIR):/src -v $(CURDIR)/build:/out $(DEB_IMAGE) + +build-images: + rm -f .bin-image .deb-image + $(MAKE) .bin-image .deb-image + +.bin-image: + docker build --no-cache=$(NO_CACHE) -t $(BIN_IMAGE) build/bin + @ docker images -q $(BIN_IMAGE) > $@ + +.deb-image: + docker build --no-cache=$(NO_CACHE) -t $(DEB_IMAGE) build/deb + @ docker images -q $(DEB_IMAGE) > $@ + +clean: clean-bin clean-deb + +clean-all: clean clean-images + +clean-bin: + rm -f build/blockbook + +clean-deb: + rm -f build/*.deb + +clean-images: clean-bin-image clean-deb-image + +clean-bin-image: + - docker rmi $(BIN_IMAGE) + @ rm -f .bin-image + +clean-deb-image: + - docker rmi $(DEB_IMAGE) + @ rm -f .deb-image diff --git a/blockbook.go b/blockbook.go index 280f61ba..9df288f1 100644 --- a/blockbook.go +++ b/blockbook.go @@ -79,12 +79,14 @@ var ( chanOsSignal chan os.Signal ) +func init() { + glog.MaxSize = 1024 * 1024 + glog.CopyStandardLogTo("INFO") +} + func main() { flag.Parse() - // override setting for glog to log only to stderr, to match the http handler - flag.Lookup("logtostderr").Value.Set("true") - defer glog.Flush() chanOsSignal = make(chan os.Signal, 1) diff --git a/docker/Dockerfile b/build/bin/Dockerfile similarity index 53% rename from docker/Dockerfile rename to build/bin/Dockerfile index 380128b6..a84074e2 100644 --- a/docker/Dockerfile +++ b/build/bin/Dockerfile @@ -2,9 +2,11 @@ FROM debian:9 -RUN apt-get update && apt-get install -y \ - build-essential git wget pkg-config lxc-dev libzmq3-dev libgflags-dev \ - libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev graphviz +RUN apt-get update && \ + apt-get install -y build-essential git wget pkg-config lxc-dev libzmq3-dev \ + libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev \ + liblz4-dev graphviz && \ + apt-get clean ENV GOLANG_VERSION=go1.10.linux-amd64 ENV GOPATH=/go @@ -22,18 +24,12 @@ RUN echo -n "GOPATH: " && echo $GOPATH # install rocksdb RUN cd /opt && git clone https://github.com/facebook/rocksdb.git -RUN cd /opt/rocksdb && CFLAGS=-fPIC CXXFLAGS=-fPIC make static_lib +RUN cd /opt/rocksdb && CFLAGS=-fPIC CXXFLAGS=-fPIC make -j 4 static_lib RUN go get github.com/golang/dep/cmd/dep -# clone repo and ensure dependencies -RUN cd $GOPATH/src && git clone https://github.com/jpochyla/blockbook.git -RUN cd $GOPATH/src/blockbook && dep ensure +ADD Makefile /build/Makefile -# install gorocksdb -RUN cd $GOPATH/src/blockbook/vendor/github.com/tecbot/gorocksdb && \ - go install . +VOLUME /out -WORKDIR $GOPATH/src/blockbook - -CMD go build -o /out/blockbook +WORKDIR /build diff --git a/build/bin/Makefile b/build/bin/Makefile new file mode 100644 index 00000000..7d4efd84 --- /dev/null +++ b/build/bin/Makefile @@ -0,0 +1,17 @@ +build: prepare-sources + cd $(GOPATH)/src/blockbook && go build -o $(CURDIR)/blockbook -ldflags="-s -w" + cp $(CURDIR)/blockbook /out/blockbook + chown $(PACKAGER) /out/blockbook + +build-debug: prepare-sources + cd $(GOPATH)/src/blockbook && go build -o $(CURDIR)/blockbook + cp $(CURDIR)/blockbook /out/blockbook + chown $(PACKAGER) /out/blockbook + +test: prepare-sources + cd $(GOPATH)/src/blockbook && go test -v ./... + +prepare-sources: + @ [ -n "`ls /src 2> /dev/null`" ] || (echo "/src doesn't exist or is empty" 1>&2 && exit 1) + cp -r /src $(GOPATH)/src/blockbook + cd $(GOPATH)/src/blockbook && dep ensure -vendor-only diff --git a/build/deb/Dockerfile b/build/deb/Dockerfile new file mode 100644 index 00000000..bb0f3d56 --- /dev/null +++ b/build/deb/Dockerfile @@ -0,0 +1,13 @@ +# initialize from the image + +FROM blockbook-build:latest + +RUN apt-get update && \ + apt-get install -y devscripts debhelper make dh-systemd dh-exec && \ + apt-get clean + +ADD build-deb.sh /build/build-deb.sh + +WORKDIR /build + +CMD /build/build-deb.sh diff --git a/build/deb/build-deb.sh b/build/deb/build-deb.sh new file mode 100755 index 00000000..21aabdde --- /dev/null +++ b/build/deb/build-deb.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +cp -r /src/build/deb/debian . +cp -r /src/configs . +mkdir server && cp -r /src/server/testcert.* /src/server/static server + +dpkg-buildpackage -us -uc +mv ../*.deb /out +chown $PACKAGER /out/*.deb diff --git a/build/deb/debian/blockbook-btc-testnet.conffiles b/build/deb/debian/blockbook-btc-testnet.conffiles new file mode 100644 index 00000000..354f62ae --- /dev/null +++ b/build/deb/debian/blockbook-btc-testnet.conffiles @@ -0,0 +1 @@ +/opt/blockbook/btc-testnet/config/blockchaincfg.json diff --git a/build/deb/debian/blockbook-btc-testnet.dirs b/build/deb/debian/blockbook-btc-testnet.dirs new file mode 100644 index 00000000..e1d51287 --- /dev/null +++ b/build/deb/debian/blockbook-btc-testnet.dirs @@ -0,0 +1,2 @@ +/data/btc-testnet/blockbook +/opt/blockbook/btc-testnet/logs diff --git a/build/deb/debian/blockbook-btc-testnet.install b/build/deb/debian/blockbook-btc-testnet.install new file mode 100755 index 00000000..cc143232 --- /dev/null +++ b/build/deb/debian/blockbook-btc-testnet.install @@ -0,0 +1,5 @@ +#!/usr/bin/dh-exec +blockbook /opt/blockbook/btc-testnet/bin +server/testcert.* /opt/blockbook/btc-testnet/cert +server/static /opt/blockbook/btc-testnet +configs/btc-testnet.json => /opt/blockbook/btc-testnet/config/blockchaincfg.json diff --git a/build/deb/debian/blockbook-btc-testnet.links b/build/deb/debian/blockbook-btc-testnet.links new file mode 100644 index 00000000..d8166b72 --- /dev/null +++ b/build/deb/debian/blockbook-btc-testnet.links @@ -0,0 +1,2 @@ +/opt/blockbook/btc-testnet/cert/testcert.crt /opt/blockbook/btc-testnet/cert/blockbook.crt +/opt/blockbook/btc-testnet/cert/testcert.key /opt/blockbook/btc-testnet/cert/blockbook.key diff --git a/build/deb/debian/blockbook-btc-testnet.postinst b/build/deb/debian/blockbook-btc-testnet.postinst new file mode 100644 index 00000000..f7bfccbc --- /dev/null +++ b/build/deb/debian/blockbook-btc-testnet.postinst @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +case "$1" in + + configure) + if ! id -u blockbook &> /dev/null + then + useradd --system -M -U blockbook + fi + + for dir in /data/btc-testnet/blockbook /opt/blockbook/btc-testnet/logs + do + if [ "$(stat -c '%U' $dir)" != "blockbook" ] + then + chown -R blockbook:blockbook $dir + fi + done + ;; + +esac + +#DEBHELPER# diff --git a/build/deb/debian/blockbook-btc-testnet.service b/build/deb/debian/blockbook-btc-testnet.service new file mode 100644 index 00000000..38fa52ad --- /dev/null +++ b/build/deb/debian/blockbook-btc-testnet.service @@ -0,0 +1,39 @@ +# It is not recommended to modify this file in-place, because it will +# be overwritten during package upgrades. If you want to add further +# options or overwrite existing ones then use +# $ systemctl edit blockbook-btc-testnet.service +# See "man systemd.service" for details. + +[Unit] +Description=Blockbook daemon (BTC testnet) +After=network.target + +[Service] +ExecStart=/opt/blockbook/btc-testnet/bin/blockbook -coin=btc-testnet -blockchaincfg=/opt/blockbook/btc-testnet/config/blockchaincfg.json -datadir=/data/btc-testnet/blockbook/db -sync -httpserver=:18335 -socketio=:18336 -certfile=/opt/blockbook/btc-testnet/cert/blockbook -explorer=https://bitcore1.trezor.io/ -log_dir=/opt/blockbook/btc-testnet/logs +User=blockbook +Type=simple +Restart=on-failure +WorkingDirectory=/opt/blockbook/btc-testnet + +# Hardening measures +#################### + +# Provide a private /tmp and /var/tmp. +PrivateTmp=true + +# Mount /usr, /boot/ and /etc read-only for the process. +ProtectSystem=full + +# Disallow the process and all of its children to gain +# new privileges through execve(). +NoNewPrivileges=true + +# Use a new /dev namespace only populated with API pseudo devices +# such as /dev/null, /dev/zero and /dev/random. +PrivateDevices=true + +# Deny the creation of writable and executable memory mappings. +MemoryDenyWriteExecute=true + +[Install] +WantedBy=multi-user.target diff --git a/build/deb/debian/blockbook-btc.conffiles b/build/deb/debian/blockbook-btc.conffiles new file mode 100644 index 00000000..1714ce0f --- /dev/null +++ b/build/deb/debian/blockbook-btc.conffiles @@ -0,0 +1 @@ +/opt/blockbook/btc/config/blockchaincfg.json diff --git a/build/deb/debian/blockbook-btc.dirs b/build/deb/debian/blockbook-btc.dirs new file mode 100644 index 00000000..907b5d84 --- /dev/null +++ b/build/deb/debian/blockbook-btc.dirs @@ -0,0 +1,2 @@ +/data/btc/blockbook +/opt/blockbook/btc/logs diff --git a/build/deb/debian/blockbook-btc.install b/build/deb/debian/blockbook-btc.install new file mode 100755 index 00000000..29961515 --- /dev/null +++ b/build/deb/debian/blockbook-btc.install @@ -0,0 +1,5 @@ +#!/usr/bin/dh-exec +blockbook /opt/blockbook/btc/bin +server/testcert.* /opt/blockbook/btc/cert +server/static /opt/blockbook/btc +configs/btc.json => /opt/blockbook/btc/config/blockchaincfg.json diff --git a/build/deb/debian/blockbook-btc.links b/build/deb/debian/blockbook-btc.links new file mode 100644 index 00000000..519988cb --- /dev/null +++ b/build/deb/debian/blockbook-btc.links @@ -0,0 +1,2 @@ +/opt/blockbook/btc/cert/testcert.crt /opt/blockbook/btc/cert/blockbook.crt +/opt/blockbook/btc/cert/testcert.key /opt/blockbook/btc/cert/blockbook.key diff --git a/build/deb/debian/blockbook-btc.postinst b/build/deb/debian/blockbook-btc.postinst new file mode 100644 index 00000000..29b2c0fd --- /dev/null +++ b/build/deb/debian/blockbook-btc.postinst @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +case "$1" in + + configure) + if ! id -u blockbook &> /dev/null + then + useradd --system -M -U blockbook + fi + + for dir in /data/btc/blockbook /opt/blockbook/btc/logs + do + if [ "$(stat -c '%U' $dir)" != "blockbook" ] + then + chown -R blockbook:blockbook $dir + fi + done + ;; + +esac + +#DEBHELPER# diff --git a/build/deb/debian/blockbook-btc.service b/build/deb/debian/blockbook-btc.service new file mode 100644 index 00000000..4eaad785 --- /dev/null +++ b/build/deb/debian/blockbook-btc.service @@ -0,0 +1,39 @@ +# It is not recommended to modify this file in-place, because it will +# be overwritten during package upgrades. If you want to add further +# options or overwrite existing ones then use +# $ systemctl edit blockbook-btc.service +# See "man systemd.service" for details. + +[Unit] +Description=Blockbook daemon (BTC mainnet) +After=network.target + +[Service] +ExecStart=/opt/blockbook/btc/bin/blockbook -coin=btc -blockchaincfg=/opt/blockbook/btc/config/blockchaincfg.json -datadir=/data/btc/blockbook/db -sync -httpserver=:8335 -socketio=:8336 -certfile=/opt/blockbook/btc/cert/blockbook -explorer=https://bitcore1.trezor.io/ -log_dir=/opt/blockbook/btc/logs +User=blockbook +Type=simple +Restart=on-failure +WorkingDirectory=/opt/blockbook/btc + +# Hardening measures +#################### + +# Provide a private /tmp and /var/tmp. +PrivateTmp=true + +# Mount /usr, /boot/ and /etc read-only for the process. +ProtectSystem=full + +# Disallow the process and all of its children to gain +# new privileges through execve(). +NoNewPrivileges=true + +# Use a new /dev namespace only populated with API pseudo devices +# such as /dev/null, /dev/zero and /dev/random. +PrivateDevices=true + +# Deny the creation of writable and executable memory mappings. +MemoryDenyWriteExecute=true + +[Install] +WantedBy=multi-user.target diff --git a/build/deb/debian/blockbook-zec.conffiles b/build/deb/debian/blockbook-zec.conffiles new file mode 100644 index 00000000..d3e9eb1c --- /dev/null +++ b/build/deb/debian/blockbook-zec.conffiles @@ -0,0 +1 @@ +/opt/blockbook/zec/config/blockchaincfg.json diff --git a/build/deb/debian/blockbook-zec.dirs b/build/deb/debian/blockbook-zec.dirs new file mode 100644 index 00000000..6d0f5523 --- /dev/null +++ b/build/deb/debian/blockbook-zec.dirs @@ -0,0 +1,2 @@ +/data/zec/blockbook +/opt/blockbook/zec/logs diff --git a/build/deb/debian/blockbook-zec.install b/build/deb/debian/blockbook-zec.install new file mode 100755 index 00000000..d34066f5 --- /dev/null +++ b/build/deb/debian/blockbook-zec.install @@ -0,0 +1,5 @@ +#!/usr/bin/dh-exec --with=install +blockbook /opt/blockbook/zec/bin +server/testcert.* /opt/blockbook/zec/cert +server/static /opt/blockbook/zec +configs/zec.json => /opt/blockbook/zec/config/blockchaincfg.json diff --git a/build/deb/debian/blockbook-zec.links b/build/deb/debian/blockbook-zec.links new file mode 100644 index 00000000..251168f7 --- /dev/null +++ b/build/deb/debian/blockbook-zec.links @@ -0,0 +1,2 @@ +/opt/blockbook/zec/cert/testcert.crt /opt/blockbook/zec/cert/blockbook.crt +/opt/blockbook/zec/cert/testcert.key /opt/blockbook/zec/cert/blockbook.key diff --git a/build/deb/debian/blockbook-zec.postinst b/build/deb/debian/blockbook-zec.postinst new file mode 100644 index 00000000..271b4603 --- /dev/null +++ b/build/deb/debian/blockbook-zec.postinst @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +case "$1" in + + configure) + if ! id -u blockbook &> /dev/null + then + useradd --system -M -U blockbook + fi + + for dir in /data/zec/blockbook /opt/blockbook/zec/logs + do + if [ "$(stat -c '%U' $dir)" != "blockbook" ] + then + chown -R blockbook:blockbook $dir + fi + done + ;; + +esac + +#DEBHELPER# diff --git a/build/deb/debian/blockbook-zec.service b/build/deb/debian/blockbook-zec.service new file mode 100644 index 00000000..9db3aed7 --- /dev/null +++ b/build/deb/debian/blockbook-zec.service @@ -0,0 +1,39 @@ +# It is not recommended to modify this file in-place, because it will +# be overwritten during package upgrades. If you want to add further +# options or overwrite existing ones then use +# $ systemctl edit blockbook-zec.service +# See "man systemd.service" for details. + +[Unit] +Description=Blockbook daemon (ZEC mainnet) +After=network.target + +[Service] +ExecStart=/opt/blockbook/zec/bin/blockbook -coin=zec -blockchaincfg=/opt/blockbook/zec/config/blockchaincfg.json -datadir=/data/zec/blockbook/db -sync -httpserver=:8235 -socketio=:8236 -certfile=/opt/blockbook/zec/cert/blockbook -explorer=https://zec-bitcore1.trezor.io/ -log_dir=/opt/blockbook/zec/logs +User=blockbook +Type=simple +Restart=on-failure +WorkingDirectory=/opt/blockbook/zec + +# Hardening measures +#################### + +# Provide a private /tmp and /var/tmp. +PrivateTmp=true + +# Mount /usr, /boot/ and /etc read-only for the process. +ProtectSystem=full + +# Disallow the process and all of its children to gain +# new privileges through execve(). +NoNewPrivileges=true + +# Use a new /dev namespace only populated with API pseudo devices +# such as /dev/null, /dev/zero and /dev/random. +PrivateDevices=true + +# Deny the creation of writable and executable memory mappings. +MemoryDenyWriteExecute=true + +[Install] +WantedBy=multi-user.target diff --git a/build/deb/debian/changelog b/build/deb/debian/changelog new file mode 100644 index 00000000..900e7276 --- /dev/null +++ b/build/deb/debian/changelog @@ -0,0 +1,5 @@ +blockbook (0.0.1-satoshilabs1) unstable; urgency=medium + + * Initial build + + -- Jakub Matys Fri, 06 Apr 2018 12:44:25 +0200 diff --git a/build/deb/debian/compat b/build/deb/debian/compat new file mode 100644 index 00000000..ec635144 --- /dev/null +++ b/build/deb/debian/compat @@ -0,0 +1 @@ +9 diff --git a/build/deb/debian/control b/build/deb/debian/control new file mode 100644 index 00000000..5ab64d64 --- /dev/null +++ b/build/deb/debian/control @@ -0,0 +1,21 @@ +Source: blockbook +Section: satoshilabs +Priority: optional +Maintainer: jakub.matys@satoshilabs.com +Build-Depends: debhelper, dh-systemd, dh-exec +Standards-Version: 3.9.5 + +Package: blockbook-btc +Architecture: amd64 +Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils +Description: Satoshilabs blockbook server + +Package: blockbook-btc-testnet +Architecture: amd64 +Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils +Description: Satoshilabs blockbook server + +Package: blockbook-zec +Architecture: amd64 +Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils +Description: Satoshilabs blockbook server diff --git a/build/deb/debian/rules b/build/deb/debian/rules new file mode 100755 index 00000000..29e4409f --- /dev/null +++ b/build/deb/debian/rules @@ -0,0 +1,8 @@ +#!/usr/bin/make -f + +DH_VERBOSE = 1 + +%: + dh $@ --with=systemd + +override_dh_strip: diff --git a/configs/btc-testnet.json b/configs/btc-testnet.json index 17275838..a58b662a 100644 --- a/configs/btc-testnet.json +++ b/configs/btc-testnet.json @@ -1,8 +1,8 @@ { - "rpcURL": "http://localhost:8332", + "rpcURL": "http://localhost:18332", "rpcUser": "rpc", "rpcPass": "rpc", "rpcTimeout": 25, "parse": true, - "zeroMQBinding": "tcp://127.0.0.1:28332" -} \ No newline at end of file + "zeroMQBinding": "tcp://127.0.0.1:18334" +} diff --git a/configs/btc.json b/configs/btc.json new file mode 100644 index 00000000..754f04b1 --- /dev/null +++ b/configs/btc.json @@ -0,0 +1,8 @@ +{ + "rpcURL": "http://127.0.0.1:8332", + "rpcUser": "rpc", + "rpcPass": "rpc", + "rpcTimeout": 25, + "parse": true, + "zeroMQBinding": "tcp://127.0.0.1:8334" +} diff --git a/configs/zec.json b/configs/zec.json new file mode 100644 index 00000000..e99cbf54 --- /dev/null +++ b/configs/zec.json @@ -0,0 +1,8 @@ +{ + "rpcURL": "http://127.0.0.1:8232", + "rpcUser": "rpc", + "rpcPass": "rpc", + "rpcTimeout": 25, + "parse": true, + "zeroMQBinding": "tcp://127.0.0.1:8234" +} diff --git a/contrib/backends/Makefile b/contrib/backends/Makefile new file mode 100644 index 00000000..1d3e964c --- /dev/null +++ b/contrib/backends/Makefile @@ -0,0 +1,28 @@ +TARGETS = bitcoin zcash +IMAGE = blockbook-backend-build-deb +NO_CACHE = false + +.PHONY: $(TARGETS) + +all: $(TARGETS) + +$(TARGETS): .docker-image + docker run -t --rm -e PACKAGER="`id -u`:`id -g`" -v $(CURDIR)/$@:/deb/$@ $(IMAGE) $@ + mv $@/*.deb . + +build-image: + rm -f .docker-image + $(MAKE) .docker-image + +.docker-image: + docker build --no-cache=$(NO_CACHE) -t $(IMAGE) docker + @ docker images -q $(IMAGE) > $@ + +clean: clean-packages clean-image + +clean-packages: + rm -f *.deb + +clean-image: + - docker rmi $(IMAGE) + @ rm -f .docker-image diff --git a/contrib/backends/bitcoin/Makefile b/contrib/backends/bitcoin/Makefile new file mode 100644 index 00000000..1061ac82 --- /dev/null +++ b/contrib/backends/bitcoin/Makefile @@ -0,0 +1,13 @@ +BITCOIN_VERSION := 0.16.0 + +all: + wget https://bitcoin.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz + tar -xf bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz + mv bitcoin-${BITCOIN_VERSION} bitcoin + rm bitcoin/bin/bitcoin-qt + rm bitcoin/bin/bitcoin-tx + rm bitcoin/bin/test_bitcoin + +clean: + rm -rf bitcoin + rm -f bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz* diff --git a/contrib/backends/bitcoin/btc-testnet.conf b/contrib/backends/bitcoin/btc-testnet.conf new file mode 100644 index 00000000..cb3d8033 --- /dev/null +++ b/contrib/backends/bitcoin/btc-testnet.conf @@ -0,0 +1,12 @@ +daemon=1 +server=1 +testnet=1 +rpcuser=rpc +rpcpassword=rpc +rpcport=18332 +txindex=1 +rpcworkqueue=32 +zmqpubhashtx=tcp://127.0.0.1:18334 +zmqpubhashblock=tcp://127.0.0.1:18334 +zmqpubrawblock=tcp://127.0.0.1:18334 +zmqpubrawtx=tcp://127.0.0.1:18334 diff --git a/contrib/backends/bitcoin/btc.conf b/contrib/backends/bitcoin/btc.conf new file mode 100644 index 00000000..faa23bbd --- /dev/null +++ b/contrib/backends/bitcoin/btc.conf @@ -0,0 +1,11 @@ +daemon=1 +server=1 +rpcuser=rpc +rpcpassword=rpc +rpcport=8332 +txindex=1 +rpcworkqueue=32 +zmqpubhashtx=tcp://127.0.0.1:8334 +zmqpubhashblock=tcp://127.0.0.1:8334 +zmqpubrawblock=tcp://127.0.0.1:8334 +zmqpubrawtx=tcp://127.0.0.1:8334 diff --git a/contrib/backends/bitcoin/debian/bitcoin-btc.conffiles b/contrib/backends/bitcoin/debian/bitcoin-btc.conffiles new file mode 100644 index 00000000..d18f88ce --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-btc.conffiles @@ -0,0 +1 @@ +/opt/bitcoin/btc/btc.conf diff --git a/contrib/backends/bitcoin/debian/bitcoin-btc.dirs b/contrib/backends/bitcoin/debian/bitcoin-btc.dirs new file mode 100644 index 00000000..4195abd8 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-btc.dirs @@ -0,0 +1 @@ +/data/btc/bitcoin diff --git a/contrib/backends/bitcoin/debian/bitcoin-btc.install b/contrib/backends/bitcoin/debian/bitcoin-btc.install new file mode 100644 index 00000000..fe2df203 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-btc.install @@ -0,0 +1,2 @@ +bitcoin/* /opt/bitcoin/btc +btc.conf /opt/bitcoin/btc diff --git a/contrib/backends/bitcoin/debian/bitcoin-btc.logrotate b/contrib/backends/bitcoin/debian/bitcoin-btc.logrotate new file mode 100644 index 00000000..9f8bd435 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-btc.logrotate @@ -0,0 +1,10 @@ +/data/btc/bitcoin/debug.log +/data/btc/bitcoin/db.log +{ + rotate 7 + daily + compress + missingok + notifempty + copytruncate +} diff --git a/contrib/backends/bitcoin/debian/bitcoin-btc.postinst b/contrib/backends/bitcoin/debian/bitcoin-btc.postinst new file mode 100644 index 00000000..e22a02e6 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-btc.postinst @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +case "$1" in + + configure) + if ! id -u bitcoin &> /dev/null + then + useradd --system -M -U bitcoin + fi + + if [ "$(stat -c '%U' /data/btc/bitcoin)" != "bitcoin" ] + then + chown bitcoin:bitcoin /data/btc/bitcoin + fi + ;; + +esac + +#DEBHELPER# diff --git a/contrib/backends/bitcoin/debian/bitcoin-btc.service b/contrib/backends/bitcoin/debian/bitcoin-btc.service new file mode 100644 index 00000000..25f02d8e --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-btc.service @@ -0,0 +1,44 @@ +# It is not recommended to modify this file in-place, because it will +# be overwritten during package upgrades. If you want to add further +# options or overwrite existing ones then use +# $ systemctl edit bitcoin-btc.service +# See "man systemd.service" for details. + +# Note that almost all daemon options could be specified in +# /opt/bitcoin/btc/btc.conf + +[Unit] +Description=Bitcoin daemon (mainnet) +After=network.target + +[Service] +ExecStart=/opt/bitcoin/btc/bin/bitcoind -datadir=/data/btc/bitcoin -conf=/opt/bitcoin/btc/btc.conf -pid=/run/bitcoind/btc.pid +# Creates /run/bitcoind owned by bitcoin +RuntimeDirectory=bitcoind +User=bitcoin +Type=forking +PIDFile=/run/bitcoind/btc.pid +Restart=on-failure + +# Hardening measures +#################### + +# Provide a private /tmp and /var/tmp. +PrivateTmp=true + +# Mount /usr, /boot/ and /etc read-only for the process. +ProtectSystem=full + +# Disallow the process and all of its children to gain +# new privileges through execve(). +NoNewPrivileges=true + +# Use a new /dev namespace only populated with API pseudo devices +# such as /dev/null, /dev/zero and /dev/random. +PrivateDevices=true + +# Deny the creation of writable and executable memory mappings. +MemoryDenyWriteExecute=true + +[Install] +WantedBy=multi-user.target diff --git a/contrib/backends/bitcoin/debian/bitcoin-testnet.conffiles b/contrib/backends/bitcoin/debian/bitcoin-testnet.conffiles new file mode 100644 index 00000000..2f410641 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-testnet.conffiles @@ -0,0 +1 @@ +/opt/bitcoin/btc-testnet/btc-testnet.conf diff --git a/contrib/backends/bitcoin/debian/bitcoin-testnet.dirs b/contrib/backends/bitcoin/debian/bitcoin-testnet.dirs new file mode 100644 index 00000000..26b686f8 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-testnet.dirs @@ -0,0 +1 @@ +/data/btc-testnet/bitcoin diff --git a/contrib/backends/bitcoin/debian/bitcoin-testnet.install b/contrib/backends/bitcoin/debian/bitcoin-testnet.install new file mode 100644 index 00000000..a9124874 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-testnet.install @@ -0,0 +1,2 @@ +bitcoin/* /opt/bitcoin/btc-testnet +btc-testnet.conf /opt/bitcoin/btc-testnet diff --git a/contrib/backends/bitcoin/debian/bitcoin-testnet.logrotate b/contrib/backends/bitcoin/debian/bitcoin-testnet.logrotate new file mode 100644 index 00000000..f718ec24 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-testnet.logrotate @@ -0,0 +1,10 @@ +/data/btc-testnet/bitcoin/testnet3/debug.log +/data/btc-testnet/bitcoin/testnet3/db.log +{ + rotate 7 + daily + compress + missingok + notifempty + copytruncate +} diff --git a/contrib/backends/bitcoin/debian/bitcoin-testnet.postinst b/contrib/backends/bitcoin/debian/bitcoin-testnet.postinst new file mode 100644 index 00000000..ebadd9ae --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-testnet.postinst @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +case "$1" in + + configure) + if ! id -u bitcoin &> /dev/null + then + useradd --system -M -U bitcoin + fi + + if [ "$(stat -c '%U' /data/btc-testnet/bitcoin)" != "bitcoin" ] + then + chown bitcoin:bitcoin /data/btc-testnet/bitcoin + fi + ;; + +esac + +#DEBHELPER# diff --git a/contrib/backends/bitcoin/debian/bitcoin-testnet.service b/contrib/backends/bitcoin/debian/bitcoin-testnet.service new file mode 100644 index 00000000..431fe84d --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-testnet.service @@ -0,0 +1,44 @@ +# It is not recommended to modify this file in-place, because it will +# be overwritten during package upgrades. If you want to add further +# options or overwrite existing ones then use +# $ systemctl edit bitcoin-testnet.service +# See "man systemd.service" for details. + +# Note that almost all daemon options could be specified in +# /opt/bitcoin/btc-testnet/btc-testnet.conf + +[Unit] +Description=Bitcoin daemon (testnet) +After=network.target + +[Service] +ExecStart=/opt/bitcoin/btc-testnet/bin/bitcoind -datadir=/data/btc-testnet/bitcoin -conf=/opt/bitcoin/btc-testnet/btc-testnet.conf -pid=/run/bitcoind/testnet.pid +# Creates /run/bitcoind owned by bitcoin +RuntimeDirectory=bitcoind +User=bitcoin +Type=forking +PIDFile=/run/bitcoind/testnet.pid +Restart=on-failure + +# Hardening measures +#################### + +# Provide a private /tmp and /var/tmp. +PrivateTmp=true + +# Mount /usr, /boot/ and /etc read-only for the process. +ProtectSystem=full + +# Disallow the process and all of its children to gain +# new privileges through execve(). +NoNewPrivileges=true + +# Use a new /dev namespace only populated with API pseudo devices +# such as /dev/null, /dev/zero and /dev/random. +PrivateDevices=true + +# Deny the creation of writable and executable memory mappings. +MemoryDenyWriteExecute=true + +[Install] +WantedBy=multi-user.target diff --git a/contrib/backends/bitcoin/debian/changelog b/contrib/backends/bitcoin/debian/changelog new file mode 100644 index 00000000..cdfa9ad8 --- /dev/null +++ b/contrib/backends/bitcoin/debian/changelog @@ -0,0 +1,5 @@ +bitcoin (0.16.0-satoshilabs1) unstable; urgency=medium + + * Initial build + + -- Jakub Matys Thu, 05 Apr 2018 08:40:39 +0200 diff --git a/contrib/backends/bitcoin/debian/compat b/contrib/backends/bitcoin/debian/compat new file mode 100644 index 00000000..ec635144 --- /dev/null +++ b/contrib/backends/bitcoin/debian/compat @@ -0,0 +1 @@ +9 diff --git a/contrib/backends/bitcoin/debian/control b/contrib/backends/bitcoin/debian/control new file mode 100644 index 00000000..b53f5d77 --- /dev/null +++ b/contrib/backends/bitcoin/debian/control @@ -0,0 +1,16 @@ +Source: bitcoin +Section: satoshilabs +Priority: optional +Maintainer: jakub.matys@satoshilabs.com +Build-Depends: debhelper, wget, tar, gzip, make, dh-systemd, dh-exec +Standards-Version: 3.9.5 + +Package: bitcoin-btc +Architecture: amd64 +Depends: ${shlibs:Depends}, ${misc:Depends}, logrotate +Description: Satoshilabs packaged bitcoin server + +Package: bitcoin-testnet +Architecture: amd64 +Depends: ${shlibs:Depends}, ${misc:Depends}, logrotate +Description: Satoshilabs packaged bitcoin server diff --git a/contrib/backends/bitcoin/debian/rules b/contrib/backends/bitcoin/debian/rules new file mode 100755 index 00000000..e9b6951b --- /dev/null +++ b/contrib/backends/bitcoin/debian/rules @@ -0,0 +1,6 @@ +#!/usr/bin/make -f + +DH_VERBOSE = 1 + +%: + dh $@ --with=systemd diff --git a/contrib/backends/docker/Dockerfile b/contrib/backends/docker/Dockerfile new file mode 100644 index 00000000..75e94805 --- /dev/null +++ b/contrib/backends/docker/Dockerfile @@ -0,0 +1,13 @@ +FROM debian:9 + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update && \ + apt-get install -y devscripts debhelper wget tar gzip make dh-systemd && \ + apt-get clean + +ADD build.sh /deb/build.sh + +WORKDIR /deb + +ENTRYPOINT ["/deb/build.sh"] diff --git a/contrib/backends/docker/build.sh b/contrib/backends/docker/build.sh new file mode 100755 index 00000000..8402eb7e --- /dev/null +++ b/contrib/backends/docker/build.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +if [ $# -ne 1 ] +then + echo "Usage: $(basename $0) target" > /dev/stderr + exit 1 +fi + +cd $1 + +mk-build-deps -ir -t "apt-get -qq --no-install-recommends" +dpkg-buildpackage -us -uc +mv ../*.deb . +chown $PACKAGER *.deb diff --git a/contrib/backends/zcash/Makefile b/contrib/backends/zcash/Makefile new file mode 100644 index 00000000..02b06991 --- /dev/null +++ b/contrib/backends/zcash/Makefile @@ -0,0 +1,11 @@ +ZCASH_VERSION := 1.0.15 + +all: + wget https://z.cash/downloads/zcash-${ZCASH_VERSION}-linux64.tar.gz + tar -xf zcash-${ZCASH_VERSION}-linux64.tar.gz + mv zcash-${ZCASH_VERSION} zcash + rm zcash/bin/zcash-tx + +clean: + rm -rf zcash + rm -f zcash-${ZCASH_VERSION}-linux64.tar.gz* diff --git a/contrib/backends/zcash/debian/changelog b/contrib/backends/zcash/debian/changelog new file mode 100644 index 00000000..6f9495d0 --- /dev/null +++ b/contrib/backends/zcash/debian/changelog @@ -0,0 +1,5 @@ +zcash (1.0.15-satoshilabs1) unstable; urgency=medium + + * Initial build + + -- Jakub Matys Thu, 05 Apr 2018 08:40:39 +0200 diff --git a/contrib/backends/zcash/debian/compat b/contrib/backends/zcash/debian/compat new file mode 100644 index 00000000..ec635144 --- /dev/null +++ b/contrib/backends/zcash/debian/compat @@ -0,0 +1 @@ +9 diff --git a/contrib/backends/zcash/debian/control b/contrib/backends/zcash/debian/control new file mode 100644 index 00000000..1f6e861c --- /dev/null +++ b/contrib/backends/zcash/debian/control @@ -0,0 +1,11 @@ +Source: zcash +Section: satoshilabs +Priority: optional +Maintainer: jakub.matys@satoshilabs.com +Build-Depends: debhelper, wget, tar, gzip, make, dh-systemd, dh-exec +Standards-Version: 3.9.5 + +Package: zcash-zec +Architecture: amd64 +Depends: ${shlibs:Depends}, ${misc:Depends}, logrotate +Description: Satoshilabs packaged zcash server diff --git a/contrib/backends/zcash/debian/rules b/contrib/backends/zcash/debian/rules new file mode 100755 index 00000000..e9b6951b --- /dev/null +++ b/contrib/backends/zcash/debian/rules @@ -0,0 +1,6 @@ +#!/usr/bin/make -f + +DH_VERBOSE = 1 + +%: + dh $@ --with=systemd diff --git a/contrib/backends/zcash/debian/zcash-zec.conffiles b/contrib/backends/zcash/debian/zcash-zec.conffiles new file mode 100644 index 00000000..b67eba29 --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-zec.conffiles @@ -0,0 +1 @@ +/opt/zcash/zec/zec.conf diff --git a/contrib/backends/zcash/debian/zcash-zec.dirs b/contrib/backends/zcash/debian/zcash-zec.dirs new file mode 100644 index 00000000..5f8be1f2 --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-zec.dirs @@ -0,0 +1 @@ +/data/zec/zcash diff --git a/contrib/backends/zcash/debian/zcash-zec.install b/contrib/backends/zcash/debian/zcash-zec.install new file mode 100644 index 00000000..0bdf2442 --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-zec.install @@ -0,0 +1,2 @@ +zcash/* /opt/zcash/zec +zec.conf /opt/zcash/zec diff --git a/contrib/backends/zcash/debian/zcash-zec.logrotate b/contrib/backends/zcash/debian/zcash-zec.logrotate new file mode 100644 index 00000000..536cdeab --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-zec.logrotate @@ -0,0 +1,10 @@ +/data/zec/zcash/debug.log +/data/zec/zcash/db.log +{ + rotate 7 + daily + compress + missingok + notifempty + copytruncate +} diff --git a/contrib/backends/zcash/debian/zcash-zec.postinst b/contrib/backends/zcash/debian/zcash-zec.postinst new file mode 100644 index 00000000..4ca85d19 --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-zec.postinst @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +case "$1" in + + configure) + if ! id -u zcash &> /dev/null + then + useradd --system -M -U zcash + fi + + if [ "$(stat -c '%U' /data/zec/zcash)" != "zcash" ] + then + chown zcash:zcash /data/zec/zcash + fi + + HOME=/data/zec/zcash /opt/zcash/zec/bin/zcash-fetch-params + ;; + +esac + +#DEBHELPER# diff --git a/contrib/backends/zcash/debian/zcash-zec.service b/contrib/backends/zcash/debian/zcash-zec.service new file mode 100644 index 00000000..a232480d --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-zec.service @@ -0,0 +1,45 @@ +# It is not recommended to modify this file in-place, because it will +# be overwritten during package upgrades. If you want to add further +# options or overwrite existing ones then use +# $ systemctl edit zcash-zec.service +# See "man systemd.service" for details. + +# Note that almost all daemon options could be specified in +# /opt/zcash/zec/zec.conf + +[Unit] +Description=ZCash daemon (mainnet) +After=network.target + +[Service] +Environment="HOME=/data/zec/zcash" +ExecStart=/opt/zcash/zec/bin/zcashd -datadir=/data/zec/zcash -conf=/opt/zcash/zec/zec.conf -pid=/run/zcashd/zec.pid +# Creates /run/zcashd owned by zcash +RuntimeDirectory=zcashd +User=zcash +Type=forking +PIDFile=/run/zcashd/zec.pid +Restart=on-failure + +# Hardening measures +#################### + +# Provide a private /tmp and /var/tmp. +PrivateTmp=true + +# Mount /usr, /boot/ and /etc read-only for the process. +ProtectSystem=full + +# Disallow the process and all of its children to gain +# new privileges through execve(). +NoNewPrivileges=true + +# Use a new /dev namespace only populated with API pseudo devices +# such as /dev/null, /dev/zero and /dev/random. +PrivateDevices=true + +# Deny the creation of writable and executable memory mappings. +# MemoryDenyWriteExecute=true + +[Install] +WantedBy=multi-user.target diff --git a/contrib/backends/zcash/zec.conf b/contrib/backends/zcash/zec.conf new file mode 100644 index 00000000..7498f754 --- /dev/null +++ b/contrib/backends/zcash/zec.conf @@ -0,0 +1,13 @@ +daemon=1 +server=1 +rpcuser=rpc +rpcpassword=rpc +rpcport=8232 +txindex=1 +mainnet=1 +addnode=mainnet.z.cash +rpcworkqueue=32 +zmqpubhashtx=tcp://127.0.0.1:8234 +zmqpubhashblock=tcp://127.0.0.1:8234 +zmqpubrawblock=tcp://127.0.0.1:8234 +zmqpubrawtx=tcp://127.0.0.1:8234 diff --git a/docker/build.sh b/docker/build.sh deleted file mode 100755 index 106f3bef..00000000 --- a/docker/build.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -set -e - -cd `dirname $0` - -# prepare build image -docker build -t blockbook-build . - -if [ "$1" == "local" ]; then - SRC_BIND="-v $(pwd)/..:/go/src/blockbook" -fi - -# build binary -docker run -t --rm -v $(pwd):/out $SRC_BIND blockbook-build - -strip blockbook diff --git a/server/https.go b/server/https.go index e135818d..cf073e9e 100644 --- a/server/https.go +++ b/server/https.go @@ -8,12 +8,10 @@ import ( "errors" "fmt" "net/http" - "os" "strconv" "github.com/golang/glog" - "github.com/gorilla/handlers" "github.com/gorilla/mux" "github.com/prometheus/client_golang/prometheus/promhttp" ) @@ -30,8 +28,10 @@ type HTTPServer struct { // NewHTTPServer creates new REST interface to blockbook and returns its handle func NewHTTPServer(httpServerBinding string, certFiles string, db *db.RocksDB, chain bchain.BlockChain, txCache *db.TxCache) (*HTTPServer, error) { + r := mux.NewRouter() https := &http.Server{ - Addr: httpServerBinding, + Addr: httpServerBinding, + Handler: r, } s := &HTTPServer{ https: https, @@ -42,7 +42,6 @@ func NewHTTPServer(httpServerBinding string, certFiles string, db *db.RocksDB, c chainParser: chain.GetChainParser(), } - r := mux.NewRouter() r.HandleFunc("/", s.info) r.HandleFunc("/bestBlockHash", s.bestBlockHash) r.HandleFunc("/blockHash/{height}", s.blockHash) @@ -51,10 +50,6 @@ func NewHTTPServer(httpServerBinding string, certFiles string, db *db.RocksDB, c r.HandleFunc("/unconfirmedTransactions/{address}", s.unconfirmedTransactions) r.HandleFunc("/metrics", promhttp.Handler().ServeHTTP) - var h http.Handler = r - h = handlers.LoggingHandler(os.Stderr, h) - https.Handler = h - return s, nil } diff --git a/server/socketio.go b/server/socketio.go index 2e91a3bc..dc84af64 100644 --- a/server/socketio.go +++ b/server/socketio.go @@ -76,7 +76,7 @@ func NewSocketIoServer(binding string, certFiles string, db *db.RocksDB, chain b } // support for tests of socket.io interface - serveMux.Handle(path+"test.html", http.FileServer(http.Dir("./server/static/"))) + serveMux.Handle(path+"test.html", http.FileServer(http.Dir("./static/"))) // redirect to Bitcore for details of transaction serveMux.HandleFunc(path+"tx/", s.txRedirect) // handle socket.io