Added testnet for ZCash
parent
58876150c3
commit
110bd6f6a6
|
@ -24,6 +24,7 @@ func init() {
|
|||
blockChainFactories["btc"] = btc.NewBitcoinRPC
|
||||
blockChainFactories["btc-testnet"] = btc.NewBitcoinRPC
|
||||
blockChainFactories["zec"] = zec.NewZCashRPC
|
||||
blockChainFactories["zec-testnet"] = zec.NewZCashRPC
|
||||
blockChainFactories["eth"] = eth.NewEthereumRPC
|
||||
blockChainFactories["eth-testnet"] = eth.NewEthereumRPC
|
||||
blockChainFactories["bch"] = bch.NewBCashRPC
|
||||
|
|
|
@ -2,6 +2,15 @@ package zec
|
|||
|
||||
import (
|
||||
"blockbook/bchain"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
)
|
||||
|
||||
const (
|
||||
MainnetMagic wire.BitcoinNet = 0x6427e924
|
||||
TestnetMagic wire.BitcoinNet = 0xbff91afa
|
||||
RegtestMagic wire.BitcoinNet = 0x5f3fe8aa
|
||||
)
|
||||
|
||||
// ZCashParser handle
|
||||
|
@ -14,6 +23,26 @@ func NewZCashParser() *ZCashParser {
|
|||
return &ZCashParser{&bchain.BaseParser{AddressFactory: bchain.NewBaseAddress}}
|
||||
}
|
||||
|
||||
// GetChainParams contains network parameters for the main ZCash network,
|
||||
// the regression test ZCash network, the test ZCash network and
|
||||
// the simulation test ZCash network, in this order
|
||||
func GetChainParams(chain string) *chaincfg.Params {
|
||||
var params *chaincfg.Params
|
||||
switch chain {
|
||||
case "test":
|
||||
params = &chaincfg.TestNet3Params
|
||||
params.Net = TestnetMagic
|
||||
case "regtest":
|
||||
params = &chaincfg.RegressionNetParams
|
||||
params.Net = RegtestMagic
|
||||
default:
|
||||
params = &chaincfg.MainNetParams
|
||||
params.Net = MainnetMagic
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
// GetAddrIDFromVout returns internal address representation of given transaction output
|
||||
func (p *ZCashParser) GetAddrIDFromVout(output *bchain.Vout) ([]byte, error) {
|
||||
if len(output.ScriptPubKey.Addresses) != 1 {
|
||||
|
|
|
@ -26,16 +26,25 @@ func NewZCashRPC(config json.RawMessage, pushHandler func(bchain.NotificationTyp
|
|||
|
||||
// Initialize initializes ZCashRPC instance.
|
||||
func (z *ZCashRPC) Initialize() error {
|
||||
_, err := z.GetChainInfoAndInitializeMempool(z)
|
||||
chainName, err := z.GetChainInfoAndInitializeMempool(z)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
z.Parser = NewZCashParser()
|
||||
z.Testnet = false
|
||||
z.Network = "livenet"
|
||||
params := GetChainParams(chainName)
|
||||
|
||||
glog.Info("rpc: block chain mainnet")
|
||||
z.Parser = NewZCashParser()
|
||||
|
||||
// parameters for getInfo request
|
||||
if params.Net == MainnetMagic {
|
||||
z.Testnet = false
|
||||
z.Network = "livenet"
|
||||
} else {
|
||||
z.Testnet = true
|
||||
z.Network = "testnet"
|
||||
}
|
||||
|
||||
glog.Info("rpc: block chain ", params.Name)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -89,7 +98,6 @@ func (z *ZCashRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) {
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
glog.V(1).Info("rpc: getblock (verbosity=1) ", hash)
|
||||
|
||||
res := resGetBlockThin{}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/opt/coins/blockbook/zec-testnet/config/blockchaincfg.json
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
/opt/coins/blockbook/zec-testnet/bin/logrotate.sh
|
|
@ -0,0 +1,2 @@
|
|||
/opt/coins/data/zec-testnet/blockbook
|
||||
/opt/coins/blockbook/zec-testnet/logs
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/dh-exec --with=install
|
||||
blockbook /opt/coins/blockbook/zec-testnet/bin
|
||||
cert /opt/coins/blockbook/zec-testnet
|
||||
static /opt/coins/blockbook/zec-testnet
|
||||
configs/zec-testnet.json => /opt/coins/blockbook/zec-testnet/config/blockchaincfg.json
|
||||
logrotate.sh /opt/coins/blockbook/zec-testnet/bin
|
|
@ -0,0 +1,2 @@
|
|||
/opt/coins/blockbook/zec-testnet/cert/testcert.crt /opt/coins/blockbook/zec-testnet/cert/blockbook.crt
|
||||
/opt/coins/blockbook/zec-testnet/cert/testcert.key /opt/coins/blockbook/zec-testnet/cert/blockbook.key
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
|
||||
configure)
|
||||
if ! id -u blockbook-zec &> /dev/null
|
||||
then
|
||||
useradd --system -M -U blockbook-zec -s /bin/false
|
||||
fi
|
||||
|
||||
for dir in /opt/coins/data/zec-testnet/blockbook /opt/coins/blockbook/zec-testnet/logs
|
||||
do
|
||||
if [ "$(stat -c '%U' $dir)" != "blockbook-zec" ]
|
||||
then
|
||||
chown -R blockbook-zec:blockbook-zec $dir
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
#DEBHELPER#
|
|
@ -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-zec-testnet.service
|
||||
# See "man systemd.service" for details.
|
||||
|
||||
[Unit]
|
||||
Description=Blockbook daemon (ZEC testnet)
|
||||
After=network.target
|
||||
Wants=zcash-zec-testnet.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/opt/coins/blockbook/zec-testnet/bin/blockbook -coin=zec-testnet -blockchaincfg=/opt/coins/blockbook/zec-testnet/config/blockchaincfg.json -datadir=/opt/coins/data/zec-testnet/blockbook/db -sync -httpserver=:18235 -socketio=:18236 -certfile=/opt/coins/blockbook/zec-testnet/cert/blockbook -explorer=https://zec-testnet-bitcore1.trezor.io/ -log_dir=/opt/coins/blockbook/zec-testnet/logs
|
||||
User=blockbook-zec
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
WorkingDirectory=/opt/coins/blockbook/zec-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
|
|
@ -20,6 +20,11 @@ Architecture: amd64
|
|||
Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils, psmisc, zcash-zec
|
||||
Description: Satoshilabs blockbook server (ZCash mainnet)
|
||||
|
||||
Package: blockbook-zec-testnet
|
||||
Architecture: amd64
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils, psmisc, zcash-testnet
|
||||
Description: Satoshilabs blockbook server (ZCash testnet)
|
||||
|
||||
Package: blockbook-bch
|
||||
Architecture: amd64
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils, psmisc, bcash-bch
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"rpcURL": "http://127.0.0.1:18232",
|
||||
"rpcUser": "rpc",
|
||||
"rpcPass": "rpc",
|
||||
"rpcTimeout": 25,
|
||||
"parse": true,
|
||||
"zeroMQBinding": "tcp://127.0.0.1:18234"
|
||||
}
|
|
@ -9,3 +9,8 @@ Package: zcash-zec
|
|||
Architecture: amd64
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, logrotate
|
||||
Description: Satoshilabs packaged zcash server
|
||||
|
||||
Package: zcash-testnet
|
||||
Architecture: amd64
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, logrotate
|
||||
Description: Satoshilabs packaged zcash server
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/opt/coins/nodes/zcash/zec-testnet/zec-testnet.conf
|
|
@ -0,0 +1 @@
|
|||
/opt/coins/data/zec-testnet/zcash
|
|
@ -0,0 +1,2 @@
|
|||
zcash/* /opt/coins/nodes/zcash/zec-testnet
|
||||
zec-testnet.conf /opt/coins/nodes/zcash/zec-testnet
|
|
@ -0,0 +1,10 @@
|
|||
/opt/coins/data/zec-testnet/zcash/testnet3/debug.log
|
||||
/opt/coins/data/zec-testnet/zcash/testnet3/db.log
|
||||
{
|
||||
rotate 7
|
||||
daily
|
||||
compress
|
||||
missingok
|
||||
notifempty
|
||||
copytruncate
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
|
||||
configure)
|
||||
if ! id -u zcash &> /dev/null
|
||||
then
|
||||
useradd --system -M -U zcash -s /bin/false
|
||||
fi
|
||||
|
||||
if [ "$(stat -c '%U' /opt/coins/data/zec-testnet/zcash)" != "zcash" ]
|
||||
then
|
||||
chown -R zcash:zcash /opt/coins/data/zec-testnet/zcash
|
||||
fi
|
||||
|
||||
HOME=/opt/coins/data/zec-testnet/zcash /opt/coins/nodes/zcash/zec-testnet/bin/zcash-fetch-params
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
#DEBHELPER#
|
|
@ -0,0 +1,48 @@
|
|||
# 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-testnet.service
|
||||
# See "man systemd.service" for details.
|
||||
|
||||
# Note that almost all daemon options could be specified in
|
||||
# /opt/coins/nodes/zcash/zec-testnet/zec-testnet.conf
|
||||
|
||||
[Unit]
|
||||
Description=ZCash daemon (testnet)
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Environment="HOME=/opt/coins/data/zec-testnet/zcash"
|
||||
ExecStart=/opt/coins/nodes/zcash/zec-testnet/bin/zcashd -datadir=/opt/coins/data/zec-testnet/zcash -conf=/opt/coins/nodes/zcash/zec-testnet/zec-testnet.conf -pid=/run/zcashd/zec-testnet.pid
|
||||
# Creates /run/zcashd owned by zcash
|
||||
RuntimeDirectory=zcashd
|
||||
User=zcash
|
||||
Type=forking
|
||||
PIDFile=/run/zcashd/zec-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
|
|
@ -0,0 +1,13 @@
|
|||
daemon=1
|
||||
server=1
|
||||
rpcuser=rpc
|
||||
rpcpassword=rpc
|
||||
rpcport=18232
|
||||
txindex=1
|
||||
testnet=1
|
||||
addnode=testnet.z.cash
|
||||
rpcworkqueue=32
|
||||
zmqpubhashtx=tcp://127.0.0.1:18234
|
||||
zmqpubhashblock=tcp://127.0.0.1:18234
|
||||
zmqpubrawblock=tcp://127.0.0.1:18234
|
||||
zmqpubrawtx=tcp://127.0.0.1:18234
|
Loading…
Reference in New Issue