func (p Pubkey) MarshalJSON() ([]byte, error) {
	return []byte(fmt.Sprintf("\"%s\"", p.String())), nil
}
MarshalJSON encodes Pubkey from to json format.
package types
import (
	"bytes"
	"encoding/binary"
	"encoding/hex"
	"fmt"
	"github.com/MinterTeam/minter-go-node/hexutil"
	"github.com/tendermint/tendermint/crypto/ed25519"
	"math/big"
	"math/rand"
	"reflect"
	"strconv"
	"strings"
)
const (
	HashLength              = 32
	AddressLength           = 20
	PubKeyLength            = 32
	CoinSymbolLength        = 10
	TendermintAddressLength = 20
)
const (
	BasecoinID = 0
)
var (
	hashT    = reflect.TypeOf(Hash{})
	addressT = reflect.TypeOf(Address{})
)
type Hash [HashLength]byte
func BytesToHash(b []byte) Hash {
	var h Hash
	h.SetBytes(b)
	return h
}
func (h Hash) Str() string { return string(h[:]) }
func (h Hash) Bytes() []byte { return h[:] }
func (h Hash) Big() *big.Int { return new(big.Int).SetBytes(h[:]) }
func (h Hash) Hex() string { return hexutil.Encode(h[:]) }
func (h Hash) TerminalString() string {
	return fmt.Sprintf("%x…%x", h[:3], h[29:])
}
func (h Hash) String() string {
	return h.Hex()
}
func (h Hash) Format(s fmt.State, c rune) {
	fmt.Fprintf(s, "%"+string(c), h[:])
}
func (h *Hash) UnmarshalText(input []byte) error {
	return hexutil.UnmarshalFixedText("Hash", input, h[:])
}
func (h *Hash) UnmarshalJSON(input []byte) error {
	return hexutil.UnmarshalFixedJSON(hashT, input, h[:])
}
func (h Hash) MarshalText() ([]byte, error) {
	return hexutil.Bytes(h[:]).MarshalText()
}
func (h *Hash) SetBytes(b []byte) {
	if len(b) > len(h) {
		b = b[len(b)-HashLength:]
	}
	copy(h[HashLength-len(b):], b)
}
func (h *Hash) SetString(s string) { h.SetBytes([]byte(s)) }
func (h *Hash) Set(other Hash) {
	for i, v := range other {
		h[i] = v
	}
}
func (h Hash) Generate(rand *rand.Rand, size int) reflect.Value {
	m := rand.Intn(len(h))
	for i := len(h) - 1; i > m; i-- {
		h[i] = byte(rand.Uint32())
	}
	return reflect.ValueOf(h)
}
func EmptyHash(h Hash) bool {
	return h == Hash{}
}
type UnprefixedHash Hash
func (h *UnprefixedHash) UnmarshalText(input []byte) error {
	return hexutil.UnmarshalFixedUnprefixedText("UnprefixedHash", input, h[:])
}
func (h UnprefixedHash) MarshalText() ([]byte, error) {
	return []byte(hex.EncodeToString(h[:])), nil
}
type CoinSymbol [CoinSymbolLength]byte
func (c CoinSymbol) String() string { return string(bytes.Trim(c[:], "\x00")) }
func (c CoinSymbol) Bytes() []byte { return c[:] }
func (c CoinSymbol) MarshalJSON() ([]byte, error) {
	buffer := bytes.NewBufferString("\"")
	buffer.WriteString(c.String())
	buffer.WriteString("\"")
	return buffer.Bytes(), nil
}
func (c *CoinSymbol) UnmarshalJSON(input []byte) error {
	*c = StrToCoinSymbol(string(input[1 : len(input)-1]))
	return nil
}
func (c CoinSymbol) Compare(c2 CoinSymbol) int {
	return bytes.Compare(c.Bytes(), c2.Bytes())
}
func (c CoinSymbol) IsBaseCoin() bool {
	return c.Compare(GetBaseCoin()) == 0
}
func StrToCoinSymbol(s string) CoinSymbol {
	var symbol CoinSymbol
	copy(symbol[:], s)
	return symbol
}
func StrToCoinBaseSymbol(s string) CoinSymbol {
	delimiter := strings.Index(s, "-")
	if delimiter > 3 {
		return StrToCoinSymbol(s[:delimiter])
	}
	return StrToCoinSymbol(s)
}
func GetVersionFromSymbol(s string) CoinVersion {
	parts := strings.Split(s, "-")
	if len(parts) == 1 {
		return 0
	}
	if len(parts[0]) < 3 {
		return 0
	}
	v, _ := strconv.ParseUint(parts[1], 10, 16)
	return CoinVersion(v)
}
type CoinID uint32
func (c CoinID) IsBaseCoin() bool {
	return c == GetBaseCoinID()
}
func (c CoinID) String() string {
	return strconv.Itoa(int(c))
}
func (c CoinID) Bytes() []byte {
	b := make([]byte, 4)
	binary.LittleEndian.PutUint32(b, c.Uint32())
	return b
}
func (c CoinID) Uint32() uint32 {
	return uint32(c)
}
func BytesToCoinID(bytes []byte) CoinID {
	return CoinID(binary.LittleEndian.Uint32(bytes))
}
type CoinVersion = uint16
type Address [AddressLength]byte
func BytesToAddress(b []byte) Address {
	var a Address
	a.SetBytes(b)
	return a
}
func StringToAddress(s string) Address { return BytesToAddress([]byte(s)) }
func BigToAddress(b *big.Int) Address { return BytesToAddress(b.Bytes()) }
func HexToAddress(s string) Address { return BytesToAddress(FromHex(s, "Mx")) }
func IsHexAddress(s string) bool {
	if hasHexPrefix(s, "Mx") {
		s = s[2:]
	}
	return len(s) == 2*AddressLength && isHex(s)
}
func (a Address) Str() string { return string(a[:]) }
func (a Address) Bytes() []byte { return a[:] }
func (a Address) Big() *big.Int { return new(big.Int).SetBytes(a[:]) }
func (a Address) Hash() Hash { return BytesToHash(a[:]) }
func (a Address) Hex() string {
	return "Mx" + hex.EncodeToString(a[:])
}
func (a Address) String() string {
	return a.Hex()
}
func (a Address) Format(s fmt.State, c rune) {
	fmt.Fprintf(s, "%"+string(c), a[:])
}
func (a *Address) SetBytes(b []byte) {
	if len(b) > len(a) {
		b = b[len(b)-AddressLength:]
	}
	copy(a[AddressLength-len(b):], b)
}
func (a *Address) SetString(s string) { a.SetBytes([]byte(s)) }
func (a *Address) Set(other Address) {
	for i, v := range other {
		a[i] = v
	}
}
func (a Address) MarshalText() ([]byte, error) {
	return hexutil.Bytes(a[:]).MarshalText()
}
func (a *Address) UnmarshalText(input []byte) error {
	return hexutil.UnmarshalFixedText("Address", input, a[:])
}
func (a *Address) Unmarshal(input []byte) error {
	copy(a[:], input)
	return nil
}
func (a Address) MarshalJSON() ([]byte, error) {
	return []byte(fmt.Sprintf("\"%s\"", a.String())), nil
}
func (a *Address) UnmarshalJSON(input []byte) error {
	return hexutil.UnmarshalFixedJSON(addressT, input, a[:])
}
func (a *Address) Compare(a2 Address) int {
	return bytes.Compare(a.Bytes(), a2.Bytes())
}
type Pubkey [PubKeyLength]byte
func HexToPubkey(s string) Pubkey { return BytesToPubkey(FromHex(s, "Mp")) }
func BytesToPubkey(b []byte) Pubkey {
	var p Pubkey
	p.SetBytes(b)
	return p
}
func (p *Pubkey) SetBytes(b []byte) {
	if len(b) > len(p) {
		b = b[len(b)-PubKeyLength:]
	}
	copy(p[PubKeyLength-len(b):], b)
}
func (p Pubkey) Bytes() []byte { return p[:] }
func (p Pubkey) String() string {
	return fmt.Sprintf("Mp%x", p[:])
}
func (p Pubkey) MarshalText() ([]byte, error) {
	return []byte(p.String()), nil
}