2018-03-20 10:28:03 -06:00
|
|
|
package zec
|
|
|
|
|
|
|
|
import (
|
|
|
|
"blockbook/bchain"
|
|
|
|
"blockbook/bchain/coins/btc"
|
|
|
|
|
|
|
|
"github.com/btcsuite/btcd/chaincfg"
|
|
|
|
)
|
|
|
|
|
|
|
|
// bitcoinwire parsing
|
|
|
|
|
|
|
|
type ZCashBlockParser struct {
|
|
|
|
btc.BitcoinBlockParser
|
|
|
|
}
|
|
|
|
|
|
|
|
// getChainParams contains network parameters for the main Bitcoin network,
|
|
|
|
// the regression test Bitcoin network, the test Bitcoin network and
|
|
|
|
// the simulation test Bitcoin network, in this order
|
|
|
|
func GetChainParams(chain string) *chaincfg.Params {
|
|
|
|
switch chain {
|
|
|
|
case "test":
|
|
|
|
return &chaincfg.TestNet3Params
|
|
|
|
case "regtest":
|
|
|
|
return &chaincfg.RegressionNetParams
|
|
|
|
}
|
|
|
|
return &chaincfg.MainNetParams
|
|
|
|
}
|
|
|
|
|
2018-03-23 04:03:41 -06:00
|
|
|
func (p *ZCashBlockParser) GetAddrIDFromVout(output *bchain.Vout) string {
|
2018-03-20 10:28:03 -06:00
|
|
|
if len(output.ScriptPubKey.Addresses) != 1 {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
return output.ScriptPubKey.Addresses[0]
|
|
|
|
}
|
|
|
|
|
2018-03-23 04:03:41 -06:00
|
|
|
func (p *ZCashBlockParser) GetAddrIDFromAddress(address string) ([]byte, error) {
|
|
|
|
return p.PackAddrID(address)
|
2018-03-20 10:28:03 -06:00
|
|
|
}
|
|
|
|
|
2018-03-23 04:03:41 -06:00
|
|
|
func (p *ZCashBlockParser) PackAddrID(str string) ([]byte, error) {
|
2018-03-20 10:28:03 -06:00
|
|
|
return []byte(str), nil
|
|
|
|
}
|
|
|
|
|
2018-03-23 04:03:41 -06:00
|
|
|
func (p *ZCashBlockParser) UnpackAddrID(buf []byte) string {
|
2018-03-20 10:28:03 -06:00
|
|
|
return string(buf)
|
|
|
|
}
|