blockbook/bchain/coins/zec/zcashparser.go

47 lines
1.1 KiB
Go
Raw Normal View History

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
}
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]
}
func (p *ZCashBlockParser) GetAddrIDFromAddress(address string) ([]byte, error) {
return p.PackAddrID(address)
2018-03-20 10:28:03 -06:00
}
func (p *ZCashBlockParser) PackAddrID(str string) ([]byte, error) {
2018-03-20 10:28:03 -06:00
return []byte(str), nil
}
func (p *ZCashBlockParser) UnpackAddrID(buf []byte) string {
2018-03-20 10:28:03 -06:00
return string(buf)
}