func NewBitpayAddressPubKeyHash(pkHash []byte, net *chaincfg.Params) (*BitpayAddressPubKeyHash, error) {
	var v byte
	if net.Name == chaincfg.MainNetParams.Name {
		v = bitpayP2PkH
	} else {
		v = net.PubKeyHashAddrID
	}
	return newBitpayAddressPubKeyHash(pkHash, v)
}
NewAddressPubKeyHash returns a new AddressPubKeyHash.  pkHash mustbe 20
bytes.
package bchutil
import (
	"errors"
	"fmt"
	"github.com/btcsuite/btcd/chaincfg"
	"github.com/btcsuite/btcutil"
	"github.com/btcsuite/btcutil/base58"
	"golang.org/x/crypto/ripemd160"
)
var (
	bitpayP2PkH = byte(0x1C)
	bitpayP2SH  = byte(0x28)
)
type UnsupportedWitnessVerError byte
func (e UnsupportedWitnessVerError) Error() string {
	return "unsupported witness version: " + string(e)
}
type UnsupportedWitnessProgLenError int
func (e UnsupportedWitnessProgLenError) Error() string {
	return "unsupported witness program length: " + string(e)
}
func encodeBitpayAddress(hash160 []byte, netID byte) string {
	return base58.CheckEncode(hash160[:ripemd160.Size], netID)
}
func DecodeBitpay(addr string, defaultNet *chaincfg.Params) (btcutil.Address, error) {
	decoded, netID, err := base58.CheckDecode(addr)
	if err != nil {
		if err == base58.ErrChecksum {
			return nil, ErrChecksumMismatch
		}
		return nil, errors.New("decoded address is of unknown format")
	}
	switch len(decoded) {
	case ripemd160.Size:  
		isP2PKH := chaincfg.IsPubKeyHashAddrID(netID) || netID == bitpayP2PkH
		isP2SH := chaincfg.IsScriptHashAddrID(netID) || netID == bitpayP2SH
		switch hash160 := decoded; {
		case isP2PKH && isP2SH:
			return nil, ErrAddressCollision
		case isP2PKH:
			return newBitpayAddressPubKeyHash(hash160, netID)
		case isP2SH:
			return newBitpayAddressScriptHashFromHash(hash160, netID)
		default:
			return nil, ErrUnknownAddressType
		}
	default:
		return nil, errors.New("decoded address is of unknown size")
	}
}
type BitpayAddressPubKeyHash struct {
	hash  [ripemd160.Size]byte
	netID byte
}