Vertcoin (#13)

* Initial vertcoin backend commit

* Readme vertcoin ports

* Fix bin

* Vertcoin blockbook initial commit

* Vertcoin fix services port, faked magic due duplicity
pull/18/head
Petr Kracík 2018-06-22 13:11:07 +02:00 committed by Martin
parent 4107f3e350
commit cb7c54ff21
41 changed files with 558 additions and 1 deletions

View File

@ -146,12 +146,14 @@ The data are separated to different column families:
| Ethereum Classic | 9037 | 9137 | 8037 | 38337* |
| Dogecoin | 9038 | 9138 | 8038 | 38338 |
| Namecoin | 9039 | 9139 | 8039 | 38339 |
| Vertcoin | 9040 | 9140 | 8040 | 38340 |
| Bitcoin Testnet | 19030 | 19130 | 18030 | 48330 |
| Bcash Testnet | 19031 | 19131 | 18031 | 48331 |
| Zcash Testnet | 19032 | 19132 | 18032 | 48332 |
| Dash Testnet | 19033 | 19133 | 18033 | 48333 |
| Litecoin Testnet | 19034 | 19134 | 18034 | 48334 |
| Ethereum Testnet Ropsten | 19036 | 19136 | 18036 | 48336* |
| Vertcoin Testnet | 19040 | 19140 | 18040 | 48340 |
\* geth listens on this port, however not as zmq service

View File

@ -9,6 +9,7 @@ import (
"blockbook/bchain/coins/dogecoin"
"blockbook/bchain/coins/eth"
"blockbook/bchain/coins/litecoin"
"blockbook/bchain/coins/vertcoin"
"blockbook/bchain/coins/namecoin"
"blockbook/bchain/coins/zec"
"blockbook/common"
@ -41,6 +42,8 @@ func init() {
blockChainFactories["Litecoin"] = litecoin.NewLitecoinRPC
blockChainFactories["Litecoin Testnet"] = litecoin.NewLitecoinRPC
blockChainFactories["Dogecoin"] = dogecoin.NewDogecoinRPC
blockChainFactories["Vertcoin"] = vertcoin.NewVertcoinRPC
blockChainFactories["Vertcoin Testnet"] = vertcoin.NewVertcoinRPC
blockChainFactories["Namecoin"] = namecoin.NewNamecoinRPC
}

View File

@ -0,0 +1,62 @@
package vertcoin
import (
"blockbook/bchain/coins/btc"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/wire"
)
const (
MainnetMagic wire.BitcoinNet = 0xdab5bffb
TestnetMagic wire.BitcoinNet = 0x74726576 // "vert" word
RegtestMagic wire.BitcoinNet = 0xdab5bffc
)
var (
MainNetParams chaincfg.Params
TestNetParams chaincfg.Params
)
func init() {
MainNetParams = chaincfg.MainNetParams
MainNetParams.Net = MainnetMagic
MainNetParams.PubKeyHashAddrID = 71
MainNetParams.ScriptHashAddrID = 5
MainNetParams.Bech32HRPSegwit = "vtc"
TestNetParams = chaincfg.TestNet3Params
TestNetParams.Net = TestnetMagic
TestNetParams.PubKeyHashAddrID = 74
TestNetParams.ScriptHashAddrID = 196
TestNetParams.Bech32HRPSegwit = "tvtc"
err := chaincfg.Register(&MainNetParams)
if err == nil {
err = chaincfg.Register(&TestNetParams)
}
if err != nil {
panic(err)
}
}
// VertcoinParser handle
type VertcoinParser struct {
*btc.BitcoinParser
}
// NewVertcoinParser returns new VertcoinParser instance
func NewVertcoinParser(params *chaincfg.Params, c *btc.Configuration) *VertcoinParser {
return &VertcoinParser{BitcoinParser: btc.NewBitcoinParser(params, c)}
}
// GetChainParams contains network parameters for the main Vertcoin network,
// and the test Vertcoin network
func GetChainParams(chain string) *chaincfg.Params {
switch chain {
case "test":
return &TestNetParams
default:
return &MainNetParams
}
}

View File

@ -0,0 +1,61 @@
package vertcoin
import (
"blockbook/bchain"
"blockbook/bchain/coins/btc"
"encoding/json"
"github.com/golang/glog"
)
// VertcoinRPC is an interface to JSON-RPC bitcoind service.
type VertcoinRPC struct {
*btc.BitcoinRPC
}
// NewVertcoinRPC returns new VertcoinRPC instance.
func NewVertcoinRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) {
b, err := btc.NewBitcoinRPC(config, pushHandler)
if err != nil {
return nil, err
}
s := &VertcoinRPC{
b.(*btc.BitcoinRPC),
}
s.RPCMarshaler = btc.JSONMarshalerV2{}
return s, nil
}
// Initialize initializes VertcoinRPC instance.
func (b *VertcoinRPC) Initialize() error {
chainName, err := b.GetChainInfoAndInitializeMempool(b)
if err != nil {
return err
}
glog.Info("Chain name ", chainName)
params := GetChainParams(chainName)
// always create parser
b.Parser = NewVertcoinParser(params, b.ChainConfig)
// parameters for getInfo request
if params.Net == MainnetMagic {
b.Testnet = false
b.Network = "livenet"
} else {
b.Testnet = true
b.Network = "testnet"
}
glog.Info("rpc: block chain ", params.Name)
return nil
}
// EstimateFee returns fee estimation.
func (b *VertcoinRPC) EstimateFee(blocks int) (float64, error) {
return b.EstimateSmartFee(blocks, true)
}

View File

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

View File

@ -0,0 +1,2 @@
#!/bin/sh
/opt/coins/blockbook/vertcoin_testnet/bin/logrotate.sh

View File

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

View File

@ -0,0 +1,6 @@
#!/usr/bin/dh-exec
blockbook /opt/coins/blockbook/vertcoin_testnet/bin
cert /opt/coins/blockbook/vertcoin_testnet
static /opt/coins/blockbook/vertcoin_testnet
configs/vertcoin_testnet.json => /opt/coins/blockbook/vertcoin_testnet/config/blockchaincfg.json
logrotate.sh /opt/coins/blockbook/vertcoin_testnet/bin

View File

@ -0,0 +1,2 @@
/opt/coins/blockbook/vertcoin_testnet/cert/testcert.crt /opt/coins/blockbook/vertcoin_testnet/cert/blockbook.crt
/opt/coins/blockbook/vertcoin_testnet/cert/testcert.key /opt/coins/blockbook/vertcoin_testnet/cert/blockbook.key

View File

@ -0,0 +1,23 @@
#!/bin/bash
set -e
case "$1" in
configure)
if ! id -u blockbook-vertcoin &> /dev/null
then
useradd --system -M -U blockbook-vertcoin -s /bin/false
fi
for dir in /opt/coins/data/vertcoin_testnet/blockbook /opt/coins/blockbook/vertcoin_testnet/logs
do
if [ "$(stat -c '%U' $dir)" != "blockbook-vertcoin" ]
then
chown -R blockbook-vertcoin:blockbook-vertcoin $dir
fi
done
;;
esac
#DEBHELPER#

View File

@ -0,0 +1,43 @@
# 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-vertcoin-testnet.service
# See "man systemd.service" for details.
[Unit]
Description=Blockbook daemon (Vertcoin testnet)
After=network.target
Wants=backend-vertcoin-testnet.service
[Service]
ExecStart=/opt/coins/blockbook/vertcoin_testnet/bin/blockbook -blockchaincfg=/opt/coins/blockbook/vertcoin_testnet/config/blockchaincfg.json -datadir=/opt/coins/data/vertcoin_testnet/blockbook/db -sync -httpserver=:19040 -socketio=:19140 -certfile=/opt/coins/blockbook/vertcoin_testnet/cert/blockbook -explorer=http://explorer.vertcointools.com/ -log_dir=/opt/coins/blockbook/vertcoin_testnet/logs
User=blockbook-vertcoin
Type=simple
Restart=on-failure
WorkingDirectory=/opt/coins/blockbook/vertcoin_testnet
# Resource limits
LimitNOFILE=500000
# 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/coins/blockbook/vertcoin/config/blockchaincfg.json

View File

@ -0,0 +1,2 @@
#!/bin/sh
/opt/coins/blockbook/vertcoin/bin/logrotate.sh

View File

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

View File

@ -0,0 +1,6 @@
#!/usr/bin/dh-exec
blockbook /opt/coins/blockbook/vertcoin/bin
cert /opt/coins/blockbook/vertcoin
static /opt/coins/blockbook/vertcoin
configs/vertcoin.json => /opt/coins/blockbook/vertcoin/config/blockchaincfg.json
logrotate.sh /opt/coins/blockbook/vertcoin/bin

View File

@ -0,0 +1,2 @@
/opt/coins/blockbook/vertcoin/cert/testcert.crt /opt/coins/blockbook/vertcoin/cert/blockbook.crt
/opt/coins/blockbook/vertcoin/cert/testcert.key /opt/coins/blockbook/vertcoin/cert/blockbook.key

View File

@ -0,0 +1,23 @@
#!/bin/bash
set -e
case "$1" in
configure)
if ! id -u blockbook-vertcoin &> /dev/null
then
useradd --system -M -U blockbook-vertcoin -s /bin/false
fi
for dir in /opt/coins/data/vertcoin/blockbook /opt/coins/blockbook/vertcoin/logs
do
if [ "$(stat -c '%U' $dir)" != "blockbook-vertcoin" ]
then
chown -R blockbook-vertcoin:blockbook-vertcoin $dir
fi
done
;;
esac
#DEBHELPER#

View File

@ -0,0 +1,43 @@
# 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-vertcoin.service
# See "man systemd.service" for details.
[Unit]
Description=Blockbook daemon (Vertcoin mainnet)
After=network.target
Wants=backend-vertcoin.service
[Service]
ExecStart=/opt/coins/blockbook/vertcoin/bin/blockbook -blockchaincfg=/opt/coins/blockbook/vertcoin/config/blockchaincfg.json -datadir=/opt/coins/data/vertcoin/blockbook/db -sync -httpserver=:9040 -socketio=:9140 -certfile=/opt/coins/blockbook/vertcoin/cert/blockbook -explorer=https://insight.vertcoin.org/ -log_dir=/opt/coins/blockbook/vertcoin/logs
User=blockbook-vertcoin
Type=simple
Restart=on-failure
WorkingDirectory=/opt/coins/blockbook/vertcoin
# Resource limits
LimitNOFILE=500000
# 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

@ -80,6 +80,16 @@ Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils, psmisc, backend-dogecoin
Description: Satoshilabs blockbook server (Dogecoin mainnet)
Package: blockbook-vertcoin
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils, psmisc, backend-dogecoin
Description: Satoshilabs blockbook server (Vertcoin mainnet)
Package: blockbook-vertcoin-testnet
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils, psmisc, backend-dogecoin
Description: Satoshilabs blockbook server (Vertcoin testnet)
Package: blockbook-namecoin
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils, psmisc, backend-namecoin

View File

@ -0,0 +1,12 @@
{
"coin_name": "Vertcoin",
"rpcURL": "http://localhost:8040",
"rpcUser": "rpc",
"rpcPass": "rpc",
"rpcTimeout": 25,
"parse": true,
"zeroMQBinding": "tcp://localhost:38340",
"mempoolWorkers": 8,
"mempoolSubWorkers": 2,
"blockAddressesToKeep": 300
}

View File

@ -0,0 +1,12 @@
{
"coin_name": "Vertcoin Testnet",
"rpcURL": "http://localhost:18040",
"rpcUser": "rpc",
"rpcPass": "rpc",
"rpcTimeout": 25,
"parse": true,
"zeroMQBinding": "tcp://localhost:48340",
"mempoolWorkers": 8,
"mempoolSubWorkers": 2,
"blockAddressesToKeep": 300
}

View File

@ -1,4 +1,4 @@
TARGETS = bitcoin zcash bcash ethereum bgold dash litecoin dogecoin namecoin
TARGETS = bitcoin zcash bcash ethereum bgold dash litecoin dogecoin vertcoin namecoin
IMAGE = blockbook-backend-build-deb
NO_CACHE = false

View File

@ -0,0 +1,10 @@
VERTCOIN_VERSION := 0.13.2
all:
wget https://github.com/vertcoin-project/vertcoin-core/releases/download/${VERTCOIN_VERSION}/vertcoind-v${VERTCOIN_VERSION}-linux-amd64.zip
mkdir vertcoin
unzip vertcoind-v${VERTCOIN_VERSION}-linux-amd64.zip -d vertcoin/
clean:
rm -rf vertcoin
rm -f vertcoind-v${VERTCOIN_VERSION}-linux-amd64.zip

View File

@ -0,0 +1 @@
/opt/coins/nodes/vertcoin_testnet/vertcoin_testnet.conf

View File

@ -0,0 +1 @@
/opt/coins/data/vertcoin_testnet/backend

View File

@ -0,0 +1,2 @@
vertcoin/* /opt/coins/nodes/vertcoin_testnet
vertcoin_testnet.conf /opt/coins/nodes/vertcoin_testnet

View File

@ -0,0 +1,10 @@
/opt/coins/data/vertcoin_testnet/backend/testnet3/debug.log
/opt/coins/data/vertcoin_testnet/backend/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 vertcoin &> /dev/null
then
useradd --system -M -U vertcoin -s /bin/false
fi
if [ "$(stat -c '%U' /opt/coins/data/vertcoin_testnet/backend)" != "vertcoin" ]
then
chown -R vertcoin:vertcoin /opt/coins/data/vertcoin_testnet/backend
fi
;;
esac
#DEBHELPER#

View File

@ -0,0 +1,47 @@
# 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 vertcoin-testnet.service
# See "man systemd.service" for details.
# Note that almost all daemon options could be specified in
# /opt/coins/nodes/vertcoin_testnet/vertcoin_testnet.conf
[Unit]
Description=vertcoin daemon (testnet)
After=network.target
[Service]
ExecStart=/opt/coins/nodes/vertcoin_testnet/vertcoind -datadir=/opt/coins/data/vertcoin_testnet/backend -conf=/opt/coins/nodes/vertcoin_testnet/vertcoin_testnet.conf -pid=/run/vertcoind/vertcoin_testnet.pid
# Creates /run/vertcoind owned by vertcoin
RuntimeDirectory=vertcoind
User=vertcoin
Type=forking
PIDFile=/run/vertcoind/vertcoin_testnet.pid
Restart=on-failure
# Resource limits
LimitNOFILE=500000
# 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/coins/nodes/vertcoin/vertcoin.conf

View File

@ -0,0 +1 @@
/opt/coins/data/vertcoin/backend

View File

@ -0,0 +1,2 @@
vertcoin/* /opt/coins/nodes/vertcoin
vertcoin.conf /opt/coins/nodes/vertcoin

View File

@ -0,0 +1,10 @@
/opt/coins/data/vertcoin/backend/debug.log
/opt/coins/data/vertcoin/backend/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 vertcoin &> /dev/null
then
useradd --system -M -U vertcoin -s /bin/false
fi
if [ "$(stat -c '%U' /opt/coins/data/vertcoin/backend)" != "vertcoin" ]
then
chown -R vertcoin:vertcoin /opt/coins/data/vertcoin/backend
fi
;;
esac
#DEBHELPER#

View File

@ -0,0 +1,47 @@
# 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 vertcoin.service
# See "man systemd.service" for details.
# Note that almost all daemon options could be specified in
# /opt/coins/nodes/vertcoin/vertcoin.conf
[Unit]
Description=vertcoin daemon (mainnet)
After=network.target
[Service]
ExecStart=/opt/coins/nodes/vertcoin/vertcoind -datadir=/opt/coins/data/vertcoin/backend -conf=/opt/coins/nodes/vertcoin/vertcoin.conf -pid=/run/vertcoind/vertcoin.pid
# Creates /run/vertcoind owned by vertcoin
RuntimeDirectory=vertcoind
User=vertcoin
Type=forking
PIDFile=/run/vertcoind/vertcoin.pid
Restart=on-failure
# Resource limits
LimitNOFILE=500000
# 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 @@
vertcoin (0.13.2-satoshilabs1) unstable; urgency=medium
* Initial build
-- Petr Kracik <petr.kracik@satoshilabs.com> Thu, 21 Jun 2018 11:42:00 +0200

View File

@ -0,0 +1 @@
9

View File

@ -0,0 +1,16 @@
Source: vertcoin
Section: satoshilabs
Priority: optional
Maintainer: petr.kracik@satoshilabs.com
Build-Depends: debhelper, wget, tar, gzip, make, dh-systemd, dh-exec
Standards-Version: 3.9.5
Package: backend-vertcoin
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, logrotate
Description: Satoshilabs packaged vertcoin server
Package: backend-vertcoin-testnet
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, logrotate
Description: Satoshilabs packaged vertcoin server

View File

@ -0,0 +1,11 @@
#!/usr/bin/make -f
DH_VERBOSE = 1
%:
dh $@ --with=systemd
override_dh_systemd_start:
dh_systemd_start --no-start
override_dh_installinit:

View File

@ -0,0 +1,17 @@
daemon=1
server=1
nolisten=1
rpcuser=rpc
rpcpassword=rpc
rpcport=8040
txindex=1
whitelist=127.0.0.1
zmqpubhashtx=tcp://127.0.0.1:38340
zmqpubhashblock=tcp://127.0.0.1:38340
rpcworkqueue=1100
maxmempool=2000
dbcache=1000

View File

@ -0,0 +1,15 @@
daemon=1
server=1
testnet=1
nolisten=1
rpcuser=rpc
rpcpassword=rpc
rpcport=18040
txindex=1
zmqpubhashtx=tcp://127.0.0.1:48340
zmqpubhashblock=tcp://127.0.0.1:48340
rpcworkqueue=1100
maxmempool=2000
dbcache=1000