From 6c6f929743f39658dd3760056967f37c1bd96a9f Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Tue, 22 May 2018 12:29:16 +0200 Subject: [PATCH 1/5] Fixed import of blocks with invalid transactions (genesis block) --- bchain/coins/zec/zcashrpc.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bchain/coins/zec/zcashrpc.go b/bchain/coins/zec/zcashrpc.go index 31d943f5..a5575a70 100644 --- a/bchain/coins/zec/zcashrpc.go +++ b/bchain/coins/zec/zcashrpc.go @@ -105,8 +105,8 @@ func (z *ZCashRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) { return nil, errors.Annotatef(res.Error, "hash %v", hash) } - txs := make([]bchain.Tx, len(res.Result.Txids)) - for i, txid := range res.Result.Txids { + txs := make([]bchain.Tx, 0, len(res.Result.Txids)) + for _, txid := range res.Result.Txids { tx, err := z.GetTransaction(txid) if err != nil { if isInvalidTx(err) { @@ -115,7 +115,7 @@ func (z *ZCashRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) { } return nil, err } - txs[i] = *tx + txs = append(txs, *tx) } block := &bchain.Block{ BlockHeader: res.Result.BlockHeader, From 58876150c3497a40e40cbff398a5b9b90f4be986 Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Tue, 22 May 2018 12:30:09 +0200 Subject: [PATCH 2/5] Removed unused code --- bchain/coins/bch/bcashrpc.go | 41 ---------------------------------- bchain/coins/btc/bitcoinrpc.go | 36 ----------------------------- 2 files changed, 77 deletions(-) diff --git a/bchain/coins/bch/bcashrpc.go b/bchain/coins/bch/bcashrpc.go index 8ccbe993..3bfb70c6 100644 --- a/bchain/coins/bch/bcashrpc.go +++ b/bchain/coins/bch/bcashrpc.go @@ -103,11 +103,6 @@ func (b *BCashRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) { return nil, err } } - // XXX - // // optimization - // if height > 0 { - // return b.getBlockWithoutHeader(hash, height) - // } header, err := b.GetBlockHeader(hash) if err != nil { return nil, err @@ -146,42 +141,6 @@ func (b *BCashRPC) GetBlockRaw(hash string) ([]byte, error) { return hex.DecodeString(res.Result) } -// GetBlockList returns block with given hash by downloading block -// transactions one by one. -func (b *BCashRPC) GetBlockList(hash string) (*bchain.Block, error) { - glog.V(1).Info("rpc: getblock (verbose=1) ", hash) - - res := resGetBlockThin{} - req := cmdGetBlock{Method: "getblock"} - req.Params.BlockHash = hash - req.Params.Verbose = true - err := b.Call(&req, &res) - - if err != nil { - return nil, errors.Annotatef(err, "hash %v", hash) - } - if res.Error != nil { - if isErrBlockNotFound(res.Error) { - return nil, bchain.ErrBlockNotFound - } - return nil, errors.Annotatef(res.Error, "hash %v", hash) - } - - txs := make([]bchain.Tx, len(res.Result.Txids)) - for i, txid := range res.Result.Txids { - tx, err := b.GetTransaction(txid) - if err != nil { - return nil, err - } - txs[i] = *tx - } - block := &bchain.Block{ - BlockHeader: res.Result.BlockHeader, - Txs: txs, - } - return block, nil -} - // GetBlockFull returns block with given hash. func (b *BCashRPC) GetBlockFull(hash string) (*bchain.Block, error) { return nil, errors.New("Not implemented") diff --git a/bchain/coins/btc/bitcoinrpc.go b/bchain/coins/btc/bitcoinrpc.go index 75617c95..d7c9b756 100644 --- a/bchain/coins/btc/bitcoinrpc.go +++ b/bchain/coins/btc/bitcoinrpc.go @@ -492,42 +492,6 @@ func (b *BitcoinRPC) GetBlockRaw(hash string) ([]byte, error) { return hex.DecodeString(res.Result) } -// GetBlockList returns block with given hash by downloading block -// transactions one by one. -func (b *BitcoinRPC) GetBlockList(hash string) (*bchain.Block, error) { - glog.V(1).Info("rpc: getblock (verbosity=1) ", hash) - - res := resGetBlockThin{} - req := cmdGetBlock{Method: "getblock"} - req.Params.BlockHash = hash - req.Params.Verbosity = 1 - err := b.Call(&req, &res) - - if err != nil { - return nil, errors.Annotatef(err, "hash %v", hash) - } - if res.Error != nil { - if isErrBlockNotFound(res.Error) { - return nil, bchain.ErrBlockNotFound - } - return nil, errors.Annotatef(res.Error, "hash %v", hash) - } - - txs := make([]bchain.Tx, len(res.Result.Txids)) - for i, txid := range res.Result.Txids { - tx, err := b.GetTransaction(txid) - if err != nil { - return nil, err - } - txs[i] = *tx - } - block := &bchain.Block{ - BlockHeader: res.Result.BlockHeader, - Txs: txs, - } - return block, nil -} - // GetBlockFull returns block with given hash. func (b *BitcoinRPC) GetBlockFull(hash string) (*bchain.Block, error) { glog.V(1).Info("rpc: getblock (verbosity=2) ", hash) From 110bd6f6a6ee923c7946b94c6d0ba7bdfd28c6a1 Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Tue, 22 May 2018 12:33:38 +0200 Subject: [PATCH 3/5] Added testnet for ZCash --- bchain/coins/blockchain.go | 1 + bchain/coins/zec/zcashparser.go | 29 +++++++++++ bchain/coins/zec/zcashrpc.go | 20 +++++--- .../debian/blockbook-zec-testnet.conffiles | 1 + .../debian/blockbook-zec-testnet.cron.daily | 2 + build/deb/debian/blockbook-zec-testnet.dirs | 2 + .../deb/debian/blockbook-zec-testnet.install | 6 +++ build/deb/debian/blockbook-zec-testnet.links | 2 + .../deb/debian/blockbook-zec-testnet.postinst | 23 +++++++++ .../deb/debian/blockbook-zec-testnet.service | 43 +++++++++++++++++ build/deb/debian/control | 5 ++ configs/zec-testnet.json | 8 ++++ contrib/backends/zcash/debian/control | 5 ++ .../zcash/debian/zcash-testnet.conffiles | 1 + .../backends/zcash/debian/zcash-testnet.dirs | 1 + .../zcash/debian/zcash-testnet.install | 2 + .../zcash/debian/zcash-testnet.logrotate | 10 ++++ .../zcash/debian/zcash-testnet.postinst | 22 +++++++++ .../zcash/debian/zcash-testnet.service | 48 +++++++++++++++++++ contrib/backends/zcash/zec-testnet.conf | 13 +++++ 20 files changed, 238 insertions(+), 6 deletions(-) create mode 100644 build/deb/debian/blockbook-zec-testnet.conffiles create mode 100644 build/deb/debian/blockbook-zec-testnet.cron.daily create mode 100644 build/deb/debian/blockbook-zec-testnet.dirs create mode 100755 build/deb/debian/blockbook-zec-testnet.install create mode 100644 build/deb/debian/blockbook-zec-testnet.links create mode 100644 build/deb/debian/blockbook-zec-testnet.postinst create mode 100644 build/deb/debian/blockbook-zec-testnet.service create mode 100644 configs/zec-testnet.json create mode 100644 contrib/backends/zcash/debian/zcash-testnet.conffiles create mode 100644 contrib/backends/zcash/debian/zcash-testnet.dirs create mode 100644 contrib/backends/zcash/debian/zcash-testnet.install create mode 100644 contrib/backends/zcash/debian/zcash-testnet.logrotate create mode 100644 contrib/backends/zcash/debian/zcash-testnet.postinst create mode 100644 contrib/backends/zcash/debian/zcash-testnet.service create mode 100644 contrib/backends/zcash/zec-testnet.conf diff --git a/bchain/coins/blockchain.go b/bchain/coins/blockchain.go index 59ff2777..5d3e1e90 100644 --- a/bchain/coins/blockchain.go +++ b/bchain/coins/blockchain.go @@ -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 diff --git a/bchain/coins/zec/zcashparser.go b/bchain/coins/zec/zcashparser.go index 039542ad..39f26e12 100644 --- a/bchain/coins/zec/zcashparser.go +++ b/bchain/coins/zec/zcashparser.go @@ -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 { diff --git a/bchain/coins/zec/zcashrpc.go b/bchain/coins/zec/zcashrpc.go index a5575a70..f347ef69 100644 --- a/bchain/coins/zec/zcashrpc.go +++ b/bchain/coins/zec/zcashrpc.go @@ -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{} diff --git a/build/deb/debian/blockbook-zec-testnet.conffiles b/build/deb/debian/blockbook-zec-testnet.conffiles new file mode 100644 index 00000000..e5212acb --- /dev/null +++ b/build/deb/debian/blockbook-zec-testnet.conffiles @@ -0,0 +1 @@ +/opt/coins/blockbook/zec-testnet/config/blockchaincfg.json diff --git a/build/deb/debian/blockbook-zec-testnet.cron.daily b/build/deb/debian/blockbook-zec-testnet.cron.daily new file mode 100644 index 00000000..4302f1a1 --- /dev/null +++ b/build/deb/debian/blockbook-zec-testnet.cron.daily @@ -0,0 +1,2 @@ +#!/bin/sh +/opt/coins/blockbook/zec-testnet/bin/logrotate.sh diff --git a/build/deb/debian/blockbook-zec-testnet.dirs b/build/deb/debian/blockbook-zec-testnet.dirs new file mode 100644 index 00000000..ae909942 --- /dev/null +++ b/build/deb/debian/blockbook-zec-testnet.dirs @@ -0,0 +1,2 @@ +/opt/coins/data/zec-testnet/blockbook +/opt/coins/blockbook/zec-testnet/logs diff --git a/build/deb/debian/blockbook-zec-testnet.install b/build/deb/debian/blockbook-zec-testnet.install new file mode 100755 index 00000000..f8640fdc --- /dev/null +++ b/build/deb/debian/blockbook-zec-testnet.install @@ -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 diff --git a/build/deb/debian/blockbook-zec-testnet.links b/build/deb/debian/blockbook-zec-testnet.links new file mode 100644 index 00000000..40a764a9 --- /dev/null +++ b/build/deb/debian/blockbook-zec-testnet.links @@ -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 diff --git a/build/deb/debian/blockbook-zec-testnet.postinst b/build/deb/debian/blockbook-zec-testnet.postinst new file mode 100644 index 00000000..fcbc854c --- /dev/null +++ b/build/deb/debian/blockbook-zec-testnet.postinst @@ -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# diff --git a/build/deb/debian/blockbook-zec-testnet.service b/build/deb/debian/blockbook-zec-testnet.service new file mode 100644 index 00000000..1521b6dd --- /dev/null +++ b/build/deb/debian/blockbook-zec-testnet.service @@ -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 diff --git a/build/deb/debian/control b/build/deb/debian/control index 424137cf..d2dc922e 100644 --- a/build/deb/debian/control +++ b/build/deb/debian/control @@ -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 diff --git a/configs/zec-testnet.json b/configs/zec-testnet.json new file mode 100644 index 00000000..747de52b --- /dev/null +++ b/configs/zec-testnet.json @@ -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" +} diff --git a/contrib/backends/zcash/debian/control b/contrib/backends/zcash/debian/control index 1f6e861c..aa94da62 100644 --- a/contrib/backends/zcash/debian/control +++ b/contrib/backends/zcash/debian/control @@ -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 diff --git a/contrib/backends/zcash/debian/zcash-testnet.conffiles b/contrib/backends/zcash/debian/zcash-testnet.conffiles new file mode 100644 index 00000000..0b9e398d --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-testnet.conffiles @@ -0,0 +1 @@ +/opt/coins/nodes/zcash/zec-testnet/zec-testnet.conf diff --git a/contrib/backends/zcash/debian/zcash-testnet.dirs b/contrib/backends/zcash/debian/zcash-testnet.dirs new file mode 100644 index 00000000..513c4b77 --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-testnet.dirs @@ -0,0 +1 @@ +/opt/coins/data/zec-testnet/zcash diff --git a/contrib/backends/zcash/debian/zcash-testnet.install b/contrib/backends/zcash/debian/zcash-testnet.install new file mode 100644 index 00000000..5f846680 --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-testnet.install @@ -0,0 +1,2 @@ +zcash/* /opt/coins/nodes/zcash/zec-testnet +zec-testnet.conf /opt/coins/nodes/zcash/zec-testnet diff --git a/contrib/backends/zcash/debian/zcash-testnet.logrotate b/contrib/backends/zcash/debian/zcash-testnet.logrotate new file mode 100644 index 00000000..8b075f62 --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-testnet.logrotate @@ -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 +} diff --git a/contrib/backends/zcash/debian/zcash-testnet.postinst b/contrib/backends/zcash/debian/zcash-testnet.postinst new file mode 100644 index 00000000..a5d155aa --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-testnet.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 -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# diff --git a/contrib/backends/zcash/debian/zcash-testnet.service b/contrib/backends/zcash/debian/zcash-testnet.service new file mode 100644 index 00000000..39b9fc31 --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-testnet.service @@ -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 diff --git a/contrib/backends/zcash/zec-testnet.conf b/contrib/backends/zcash/zec-testnet.conf new file mode 100644 index 00000000..114a3dc4 --- /dev/null +++ b/contrib/backends/zcash/zec-testnet.conf @@ -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 From 129160c48ad499d738d399a2c77891ff6992a324 Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Wed, 23 May 2018 13:01:21 +0200 Subject: [PATCH 4/5] Changed ports and added nolisten=1 option --- build/deb/debian/blockbook-zec-testnet.service | 2 +- configs/zec-testnet.json | 4 ++-- contrib/backends/zcash/zec-testnet.conf | 11 ++++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/build/deb/debian/blockbook-zec-testnet.service b/build/deb/debian/blockbook-zec-testnet.service index 1521b6dd..ec7449fa 100644 --- a/build/deb/debian/blockbook-zec-testnet.service +++ b/build/deb/debian/blockbook-zec-testnet.service @@ -10,7 +10,7 @@ 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 +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=:19032 -socketio=:19132 -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 diff --git a/configs/zec-testnet.json b/configs/zec-testnet.json index 747de52b..663b08c5 100644 --- a/configs/zec-testnet.json +++ b/configs/zec-testnet.json @@ -1,8 +1,8 @@ { - "rpcURL": "http://127.0.0.1:18232", + "rpcURL": "http://127.0.0.1:18032", "rpcUser": "rpc", "rpcPass": "rpc", "rpcTimeout": 25, "parse": true, - "zeroMQBinding": "tcp://127.0.0.1:18234" + "zeroMQBinding": "tcp://127.0.0.1:48332" } diff --git a/contrib/backends/zcash/zec-testnet.conf b/contrib/backends/zcash/zec-testnet.conf index 114a3dc4..100bd5b1 100644 --- a/contrib/backends/zcash/zec-testnet.conf +++ b/contrib/backends/zcash/zec-testnet.conf @@ -1,13 +1,14 @@ daemon=1 server=1 +nolisten=1 rpcuser=rpc rpcpassword=rpc -rpcport=18232 +rpcport=18032 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 +zmqpubhashtx=tcp://127.0.0.1:48332 +zmqpubhashblock=tcp://127.0.0.1:48332 +zmqpubrawblock=tcp://127.0.0.1:48332 +zmqpubrawtx=tcp://127.0.0.1:48332 From 9f3b1510b03d434ce036bf40d33305c0617f9cd8 Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Wed, 23 May 2018 16:13:06 +0200 Subject: [PATCH 5/5] Fixed empty Address field when transaction was unpacked from JSON --- bchain/coins/zec/zcashrpc.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bchain/coins/zec/zcashrpc.go b/bchain/coins/zec/zcashrpc.go index f347ef69..8eb271c5 100644 --- a/bchain/coins/zec/zcashrpc.go +++ b/bchain/coins/zec/zcashrpc.go @@ -72,7 +72,7 @@ type resGetBlockThin struct { type resGetRawTransaction struct { Error *bchain.RPCError `json:"error"` - Result bchain.Tx `json:"result"` + Result json.RawMessage `json:"result"` } // getblockheader @@ -168,7 +168,11 @@ func (z *ZCashRPC) GetTransaction(txid string) (*bchain.Tx, error) { if res.Error != nil { return nil, errors.Annotatef(res.Error, "txid %v", txid) } - return &res.Result, nil + tx, err := z.Parser.ParseTxFromJson(res.Result) + if err != nil { + return nil, errors.Annotatef(err, "txid %v", txid) + } + return tx, nil } // GetBlockHash returns hash of block in best-block-chain at given height.