Merge branch 'packaging'

This commit is contained in:
Jakub Matys 2018-04-13 10:27:46 +02:00
commit 7b97f8a929
69 changed files with 798 additions and 60 deletions

32
Gopkg.lock generated
View File

@ -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

50
Makefile Normal file
View File

@ -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

View File

@ -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)

View File

@ -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

17
build/bin/Makefile Normal file
View File

@ -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

13
build/deb/Dockerfile Normal file
View File

@ -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

10
build/deb/build-deb.sh Executable file
View File

@ -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

View File

@ -0,0 +1 @@
/opt/blockbook/btc-testnet/config/blockchaincfg.json

View File

@ -0,0 +1,2 @@
/data/btc-testnet/blockbook
/opt/blockbook/btc-testnet/logs

View File

@ -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

View File

@ -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

View File

@ -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#

View File

@ -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

View File

@ -0,0 +1 @@
/opt/blockbook/btc/config/blockchaincfg.json

View File

@ -0,0 +1,2 @@
/data/btc/blockbook
/opt/blockbook/btc/logs

View File

@ -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

View File

@ -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

View File

@ -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#

View File

@ -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

View File

@ -0,0 +1 @@
/opt/blockbook/zec/config/blockchaincfg.json

View File

@ -0,0 +1,2 @@
/data/zec/blockbook
/opt/blockbook/zec/logs

View File

@ -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

View File

@ -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

View File

@ -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#

View File

@ -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

View File

@ -0,0 +1,5 @@
blockbook (0.0.1-satoshilabs1) unstable; urgency=medium
* Initial build
-- Jakub Matys <jakub.matys@satoshilabs.com> Fri, 06 Apr 2018 12:44:25 +0200

1
build/deb/debian/compat Normal file
View File

@ -0,0 +1 @@
9

21
build/deb/debian/control Normal file
View File

@ -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

8
build/deb/debian/rules Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/make -f
DH_VERBOSE = 1
%:
dh $@ --with=systemd
override_dh_strip:

View File

@ -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"
}
"zeroMQBinding": "tcp://127.0.0.1:18334"
}

8
configs/btc.json Normal file
View File

@ -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"
}

8
configs/zec.json Normal file
View File

@ -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"
}

28
contrib/backends/Makefile Normal file
View File

@ -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

View File

@ -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*

View File

@ -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

View File

@ -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

View File

@ -0,0 +1 @@
/opt/bitcoin/btc/btc.conf

View File

@ -0,0 +1 @@
/data/btc/bitcoin

View File

@ -0,0 +1,2 @@
bitcoin/* /opt/bitcoin/btc
btc.conf /opt/bitcoin/btc

View File

@ -0,0 +1,10 @@
/data/btc/bitcoin/debug.log
/data/btc/bitcoin/db.log
{
rotate 7
daily
compress
missingok
notifempty
copytruncate
}

View File

@ -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#

View File

@ -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

View File

@ -0,0 +1 @@
/opt/bitcoin/btc-testnet/btc-testnet.conf

View File

@ -0,0 +1 @@
/data/btc-testnet/bitcoin

View File

@ -0,0 +1,2 @@
bitcoin/* /opt/bitcoin/btc-testnet
btc-testnet.conf /opt/bitcoin/btc-testnet

View File

@ -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
}

View File

@ -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#

View File

@ -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

View File

@ -0,0 +1,5 @@
bitcoin (0.16.0-satoshilabs1) unstable; urgency=medium
* Initial build
-- Jakub Matys <jakub.matys@satoshilabs.com> Thu, 05 Apr 2018 08:40:39 +0200

View File

@ -0,0 +1 @@
9

View File

@ -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

View File

@ -0,0 +1,6 @@
#!/usr/bin/make -f
DH_VERBOSE = 1
%:
dh $@ --with=systemd

View File

@ -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"]

View File

@ -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

View File

@ -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*

View File

@ -0,0 +1,5 @@
zcash (1.0.15-satoshilabs1) unstable; urgency=medium
* Initial build
-- Jakub Matys <jakub.matys@satoshilabs.com> Thu, 05 Apr 2018 08:40:39 +0200

View File

@ -0,0 +1 @@
9

View File

@ -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

View File

@ -0,0 +1,6 @@
#!/usr/bin/make -f
DH_VERBOSE = 1
%:
dh $@ --with=systemd

View File

@ -0,0 +1 @@
/opt/zcash/zec/zec.conf

View File

@ -0,0 +1 @@
/data/zec/zcash

View File

@ -0,0 +1,2 @@
zcash/* /opt/zcash/zec
zec.conf /opt/zcash/zec

View File

@ -0,0 +1,10 @@
/data/zec/zcash/debug.log
/data/zec/zcash/db.log
{
rotate 7
daily
compress
missingok
notifempty
copytruncate
}

View File

@ -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#

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -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