<|start_filename|>vendor/github.com/KuChainNetwork/kuchain/chain/constants/versions.go<|end_filename|>
package constants

import (
	"github.com/tendermint/tendermint/libs/log"
	"gopkg.in/yaml.v2"
)

var (
	KuchainBuildVersion    = ""
	KuchainBuildBranch     = ""
	KuchainBuildTime       = ""
	KuchainBuildSDKVersion = ""
)

// VersionInfo get Version Info
func VersionInfo() []byte {
	ver := struct {
		Version    string `json:"version" yaml:"version"`
		Branch     string `json:"branch" yaml:"branch"`
		BuildTime  string `json:"build_time" yaml:"build_time"`
		SDKVersion string `json:"sdk_version" yaml:"sdk_version"`
	}{
		Version:    KuchainBuildVersion,
		Branch:     KuchainBuildBranch,
		BuildTime:  KuchainBuildTime,
		SDKVersion: KuchainBuildSDKVersion,
	}

	res, _ := yaml.Marshal(ver)
	return res
}

// LogVersion log version info
func LogVersion(logger log.Logger) {
	logger.Info("Kuchain Version",
		"version", KuchainBuildVersion,
		"branch", KuchainBuildBranch,
		"time", KuchainBuildTime,
		"sdkVersion", KuchainBuildSDKVersion)
}


<|start_filename|>vendor/github.com/KuChainNetwork/kuchain/chain/msg/msg_create.go<|end_filename|>
package msg

import (
	"github.com/KuChainNetwork/kuchain/chain/types"
	"github.com/cosmos/cosmos-sdk/codec"
)

type Option interface {
	Op(msg *KuMsg) error
}

// WithData create kumsg with data and action
type withData struct {
	data  KuMsgData
	bytes []byte
}

func (k withData) Op(msg *KuMsg) error {
	msg.Action = k.data.Type()
	msg.Data = k.bytes

	return nil
}

// WithData create kumsg with data
func WithData(cdc *codec.Codec, data KuMsgData) Option {
	dataByte, err := cdc.MarshalBinaryLengthPrefixed(data)
	if err != nil {
		panic(err)
	}
	return withData{
		data:  data,
		bytes: dataByte,
	}
}

type withTransfer struct {
	From   AccountID
	To     AccountID
	Amount Coins
}

func (k withTransfer) Op(msg *KuMsg) error {
	msg.Transfers = append(msg.Transfers,
		types.KuMsgTransfer{
			From:   k.From,
			To:     k.To,
			Amount: k.Amount,
		})
	return nil
}

// WithTransfer create kumsg with transfer message
func WithTransfer(from, to AccountID, amount Coins) Option {
	return withTransfer{
		From:   from,
		To:     to,
		Amount: amount,
	}
}

type withAuth struct {
	Auth []AccAddress
}

func (k withAuth) Op(msg *KuMsg) error {
	if len(msg.Auth)+len(k.Auth) > KuMsgMaxAuth {
		return types.ErrKuMsgAuthCountTooLarge
	}

	msg.Auth = append(msg.Auth, k.Auth...)
	return nil
}

// WithAuth create kumsg with auth
func WithAuth(auth AccAddress) Option {
	return withAuth{
		Auth: []AccAddress{auth},
	}
}

// WithAuths create kumsg with auth
func WithAuths(auths []AccAddress) Option {
	return withAuth{
		Auth: auths,
	}
}


<|start_filename|>vendor/github.com/KuChainNetwork/kuchain/chain/ante/sigverify.go<|end_filename|>
package ante

import (
	"bytes"

	"github.com/KuChainNetwork/kuchain/chain/client/txutil"
	"github.com/KuChainNetwork/kuchain/chain/constants/keys"
	"github.com/KuChainNetwork/kuchain/chain/types"
	"github.com/KuChainNetwork/kuchain/x/account/keeper"
	"github.com/cosmos/cosmos-sdk/codec"
	sdk "github.com/cosmos/cosmos-sdk/types"
	sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
	"github.com/tendermint/tendermint/crypto"
	"github.com/tendermint/tendermint/crypto/ed25519"
	"github.com/tendermint/tendermint/crypto/multisig"
	"github.com/tendermint/tendermint/crypto/secp256k1"
)

// Verify all signatures for a tx and return an error if any are invalid. Note,
// the SigVerificationDecorator decorator will not get executed on ReCheck.
//
// CONTRACT: Pubkeys are set in context for all signers before this decorator runs
// CONTRACT: Tx must implement SigVerifiableTx interface
type SigVerificationDecorator struct {
	ak keeper.AccountKeeper
}

func NewSigVerificationDecorator(ak keeper.AccountKeeper) SigVerificationDecorator {
	return SigVerificationDecorator{
		ak: ak,
	}
}

func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
	// no need to verify signatures on recheck tx
	if ctx.IsReCheckTx() {
		return next(ctx, tx, simulate)
	}
	sigTx, ok := tx.(SigVerifiableTx)
	if !ok {
		return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type for SigVerifiableTx")
	}

	stdTx, ok := tx.(types.StdTx)
	if !ok {
		return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type for stdTx")
	}

	// stdSigs contains the sequence number, account number, and signatures.
	// When simulating, this would just be a 0-length slice.
	sigs := sigTx.GetSignatures()

	// stdSigs contains the sequence number, account number, and signatures.
	// When simulating, this would just be a 0-length slice.
	signerAddrs := sigTx.GetSigners()

	// check that signer length and signature length are the same
	if len(sigs) != len(signerAddrs) {
		return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "invalid number of signer;  expected: %d, got %d", len(signerAddrs), len(sigs))
	}

	for i, sig := range sigs {
		seq, num, err := svd.ak.GetAuthSequence(ctx, signerAddrs[i])
		if err != nil {
			return ctx, err
		}

		// retrieve signBytes of tx
		signBytes := txutil.GetSignBytes(ctx, &stdTx, num, seq)

		// retrieve pubkey
		pubKey := sig.PubKey
		if !simulate && pubKey == nil {
			return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, "pubkey on account is not set")
		}

		// verify signature
		if !simulate && !pubKey.VerifyBytes(signBytes, sig.Signature) {
			return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized,
				"signature verification failed; verify correct account sequence and chain-id: %s, seq: %d, num: %d.", ctx.ChainID(), seq, num)
		}
	}

	return next(ctx, tx, simulate)
}

type IncrementSequenceDecorator struct {
	ak keeper.AccountKeeper
}

func NewIncrementSequenceDecorator(ak keeper.AccountKeeper) IncrementSequenceDecorator {
	return IncrementSequenceDecorator{
		ak: ak,
	}
}

func (isd IncrementSequenceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
	// no need to increment sequence on CheckTx or RecheckTx
	if ctx.IsReCheckTx() && !simulate {
		return next(ctx, tx, simulate)
	}

	sigTx, ok := tx.(SigVerifiableTx)
	if !ok {
		return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type for SigVerifiableTx in inc seq")
	}

	// increment sequence of all signers
	for _, addr := range sigTx.GetSigners() {
		isd.ak.IncAuthSequence(ctx, addr)
	}

	return next(ctx, tx, simulate)
}

// SetPubKeyDecorator sets PubKeys in context for any signer which does not already have pubkey set
// PubKeys must be set in context for all signers before any other sigverify decorators run
// CONTRACT: Tx must implement SigVerifiableTx interface
type SetPubKeyDecorator struct {
	ak keeper.AccountKeeper
}

func NewSetPubKeyDecorator(ak keeper.AccountKeeper) SetPubKeyDecorator {
	return SetPubKeyDecorator{
		ak: ak,
	}
}

func (spkd SetPubKeyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
	sigTx, ok := tx.(SigVerifiableTx)
	if !ok {
		return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid tx type")
	}

	signatures := sigTx.GetSignatures()
	signers := sigTx.GetSigners()

	for i, sig := range signatures {
		// PublicKey was omitted from slice since it has already been set in context
		if sig.PubKey == nil {
			if !simulate {
				continue
			}
			// sig.PubKey = simSecp256k1Pubkey
		}
		// Only make check if simulate=false
		if !simulate && !bytes.Equal(sig.PubKey.Address(), signers[i]) {
			return ctx, sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey,
				"pubKey does not match signer address %s with signer index: %d", signers[i], i)
		}

		spkd.ak.SetPubKey(ctx, signers[i], sig.PubKey)
	}

	return next(ctx, tx, simulate)
}

// DefaultSigVerificationGasConsumer is the default implementation of SignatureVerificationGasConsumer. It consumes gas
// for signature verification based upon the public key type. The cost is fetched from the given params and is matched
// by the concrete type.
func DefaultSigVerificationGasConsumer(
	meter sdk.GasMeter, sig []byte, pubkey crypto.PubKey,
) error {
	switch pubkey := pubkey.(type) {
	case ed25519.PubKeyEd25519:
		meter.ConsumeGas(keys.DefaultSigVerifyCostED25519, "ante verify: ed25519")
		return sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, "ED25519 public keys are unsupported")

	case secp256k1.PubKeySecp256k1:
		meter.ConsumeGas(keys.DefaultSigVerifyCostSecp256k1, "ante verify: secp256k1")
		return nil

	case multisig.PubKeyMultisigThreshold:
		var multisignature multisig.Multisignature
		codec.Cdc.MustUnmarshalBinaryBare(sig, &multisignature)

		ConsumeMultisignatureVerificationGas(meter, multisignature, pubkey)
		return nil

	default:
		return sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey)
	}
}

// ConsumeMultisignatureVerificationGas consumes gas from a GasMeter for verifying a multisig pubkey signature
func ConsumeMultisignatureVerificationGas(meter sdk.GasMeter,
	sig multisig.Multisignature, pubkey multisig.PubKeyMultisigThreshold) {
	size := sig.BitArray.Size()
	sigIndex := 0
	for i := 0; i < size; i++ {
		if sig.BitArray.GetIndex(i) {
			DefaultSigVerificationGasConsumer(meter, sig.Sigs[sigIndex], pubkey.PubKeys[i])
			sigIndex++
		}
	}
}


<|start_filename|>vendor/github.com/KuChainNetwork/kuchain/chain/msg/msg_test.go<|end_filename|>
package msg_test

import (
	"testing"

	"github.com/KuChainNetwork/kuchain/chain/constants"
	"github.com/KuChainNetwork/kuchain/chain/msg"
	"github.com/KuChainNetwork/kuchain/chain/types"
	"github.com/KuChainNetwork/kuchain/test/simapp"
	assetTypes "github.com/KuChainNetwork/kuchain/x/asset/types"
	sdk "github.com/cosmos/cosmos-sdk/types"
	abci "github.com/tendermint/tendermint/abci/types"

	. "github.com/smartystreets/goconvey/convey"
)

var (
	routerKeyName = types.MustName(assetTypes.RouterKey)
)

var (
	// values for test
	wallet      = simapp.NewWallet()
	addr1       = wallet.NewAccAddressByName(name1)
	addr2       = wallet.NewAccAddressByName(name2)
	addr3       = wallet.NewAccAddressByName(name3)
	addr4       = wallet.NewAccAddressByName(name4)
	addr5       = wallet.NewAccAddressByName(name5)
	name1       = types.MustName("test01@chain")
	name2       = types.MustName("aaaeeebbbccc")
	name3       = types.MustName("aaaeeebbbcc2")
	name4       = types.MustName("test")
	name5       = types.MustName("foo")
	account1    = types.NewAccountIDFromName(name1)
	account2    = types.NewAccountIDFromName(name2)
	account3    = types.NewAccountIDFromName(name3)
	account4    = types.NewAccountIDFromName(name4)
	account5    = types.NewAccountIDFromName(name5)
	addAccount1 = types.NewAccountIDFromAccAdd(addr1)
	denom       = types.CoinDenom(name5, name4)
)

func createAppForTest() (*simapp.SimApp, sdk.Context) {
	asset1 := types.NewCoins(
		types.NewInt64Coin(denom, 10000000),
		types.NewInt64Coin(constants.DefaultBondDenom, 10000000000))
	asset2 := types.NewCoins(
		types.NewInt64Coin(constants.DefaultBondDenom, 10000000000))
	asset3 := types.NewCoins(
		types.NewInt64Coin(denom, 100000),
		types.NewInt64Coin(constants.DefaultBondDenom, 10000000000))

	genAccs := simapp.NewGenesisAccounts(wallet.GetRootAuth(),
		simapp.NewSimGenesisAccount(account1, addr1).WithAsset(asset1),
		simapp.NewSimGenesisAccount(account2, addr2).WithAsset(asset2),
		simapp.NewSimGenesisAccount(account3, addr3).WithAsset(asset3),
		simapp.NewSimGenesisAccount(account4, addr4).WithAsset(asset2),
		simapp.NewSimGenesisAccount(account5, addr5).WithAsset(asset2),
	)
	app := simapp.SetupWithGenesisAccounts(genAccs)

	ctxCheck := app.BaseApp.NewContext(true, abci.Header{Height: app.LastBlockHeight() + 1})
	return app, ctxCheck
}

func TestMsgMultiSend(t *testing.T) {
	msgTest := assetTypes.MsgTransfer{
		*msg.MustNewKuMsg(
			routerKeyName,
			msg.WithAuths([]types.AccAddress{addr1, addr2, addr3}),
			msg.WithTransfer(account2, account4, types.NewInt64Coins(constants.DefaultBondDenom, 2222)),
			msg.WithTransfer(account3, account5, types.NewInt64Coins(denom, 1111)),
		)}

	Convey("test msg with multiple send", t, func() {
		So(len(msgTest.Transfers), ShouldEqual, 2)

		auths := msgTest.GetSigners()

		So(len(auths), ShouldEqual, 3)
		So(auths[0], simapp.ShouldEq, addr1)
		So(auths[1], simapp.ShouldEq, addr2)
		So(auths[2], simapp.ShouldEq, addr3)
	})

	app, ctx := createAppForTest()

	Convey("test msg handler", t, func() {
		var (
			coins1 = app.AssetKeeper().GetAllBalances(ctx, account1)
			coins2 = app.AssetKeeper().GetAllBalances(ctx, account2)
			coins3 = app.AssetKeeper().GetAllBalances(ctx, account3)
			coins4 = app.AssetKeeper().GetAllBalances(ctx, account4)
			coins5 = app.AssetKeeper().GetAllBalances(ctx, account5)
		)

		tx := simapp.NewTxForTest(
			account1,
			[]sdk.Msg{
				&msgTest,
			}, wallet.PrivKey(addr1), wallet.PrivKey(addr2), wallet.PrivKey(addr3))

		So(simapp.CheckTxs(t, app, ctx, tx), ShouldBeNil)

		ctx = app.NewTestContext()
		var (
			coins1curr = app.AssetKeeper().GetAllBalances(ctx, account1)
			coins2curr = app.AssetKeeper().GetAllBalances(ctx, account2)
			coins3curr = app.AssetKeeper().GetAllBalances(ctx, account3)
			coins4curr = app.AssetKeeper().GetAllBalances(ctx, account4)
			coins5curr = app.AssetKeeper().GetAllBalances(ctx, account5)
		)

		So(coins1curr, simapp.ShouldEq, coins1.Sub(simapp.DefaultTestFee))
		So(coins2curr, simapp.ShouldEq, coins2.Sub(types.NewInt64Coins(constants.DefaultBondDenom, 2222)))
		So(coins3curr, simapp.ShouldEq, coins3.Sub(types.NewInt64Coins(denom, 1111)))
		So(coins4curr, simapp.ShouldEq, coins4.Add(types.NewInt64Coin(constants.DefaultBondDenom, 2222)))
		So(coins5curr, simapp.ShouldEq, coins5.Add(types.NewInt64Coin(denom, 1111)))
	})
}


<|start_filename|>vendor/github.com/KuChainNetwork/kuchain/x/params/types/proposal/types.pb.go<|end_filename|>
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: x/params/types/proposal/types.proto

package proposal

import (
	fmt "fmt"
	_ "github.com/gogo/protobuf/gogoproto"
	proto "github.com/gogo/protobuf/proto"
	io "io"
	math "math"
	math_bits "math/bits"
)

// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf

// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package

// ParameterChangeProposal defines a proposal which contains multiple parameter
// changes.
type ParameterChangeProposal struct {
	Title       string        `json:"title,omitempty" yaml:"title"`
	Description string        `json:"description,omitempty" yaml:"description"`
	Changes     []ParamChange `json:"changes" yaml:"changes"`
}

func (m *ParameterChangeProposal) Reset()      { *m = ParameterChangeProposal{} }
func (*ParameterChangeProposal) ProtoMessage() {}
func (*ParameterChangeProposal) Descriptor() ([]byte, []int) {
	return fileDescriptor_0ab50f1d22a2cb61, []int{0}
}
func (m *ParameterChangeProposal) XXX_Unmarshal(b []byte) error {
	return m.Unmarshal(b)
}
func (m *ParameterChangeProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	if deterministic {
		return xxx_messageInfo_ParameterChangeProposal.Marshal(b, m, deterministic)
	} else {
		b = b[:cap(b)]
		n, err := m.MarshalToSizedBuffer(b)
		if err != nil {
			return nil, err
		}
		return b[:n], nil
	}
}
func (m *ParameterChangeProposal) XXX_Merge(src proto.Message) {
	xxx_messageInfo_ParameterChangeProposal.Merge(m, src)
}
func (m *ParameterChangeProposal) XXX_Size() int {
	return m.Size()
}
func (m *ParameterChangeProposal) XXX_DiscardUnknown() {
	xxx_messageInfo_ParameterChangeProposal.DiscardUnknown(m)
}

var xxx_messageInfo_ParameterChangeProposal proto.InternalMessageInfo

// ParamChange defines a parameter change.
type ParamChange struct {
	Subspace string `json:"subspace,omitempty" yaml:"subspace"`
	Key      string `json:"key,omitempty" yaml:"key"`
	Value    string `json:"value,omitempty" yaml:"value"`
}

func (m *ParamChange) Reset()      { *m = ParamChange{} }
func (*ParamChange) ProtoMessage() {}
func (*ParamChange) Descriptor() ([]byte, []int) {
	return fileDescriptor_0ab50f1d22a2cb61, []int{1}
}
func (m *ParamChange) XXX_Unmarshal(b []byte) error {
	return m.Unmarshal(b)
}
func (m *ParamChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	if deterministic {
		return xxx_messageInfo_ParamChange.Marshal(b, m, deterministic)
	} else {
		b = b[:cap(b)]
		n, err := m.MarshalToSizedBuffer(b)
		if err != nil {
			return nil, err
		}
		return b[:n], nil
	}
}
func (m *ParamChange) XXX_Merge(src proto.Message) {
	xxx_messageInfo_ParamChange.Merge(m, src)
}
func (m *ParamChange) XXX_Size() int {
	return m.Size()
}
func (m *ParamChange) XXX_DiscardUnknown() {
	xxx_messageInfo_ParamChange.DiscardUnknown(m)
}

var xxx_messageInfo_ParamChange proto.InternalMessageInfo

func (m *ParamChange) GetSubspace() string {
	if m != nil {
		return m.Subspace
	}
	return ""
}

func (m *ParamChange) GetKey() string {
	if m != nil {
		return m.Key
	}
	return ""
}

func (m *ParamChange) GetValue() string {
	if m != nil {
		return m.Value
	}
	return ""
}

func init() {
	proto.RegisterType((*ParameterChangeProposal)(nil), "kuchain.x.params.v1.ParameterChangeProposal")
	proto.RegisterType((*ParamChange)(nil), "kuchain.x.params.v1.ParamChange")
}

func init() {
	proto.RegisterFile("x/params/types/proposal/types.proto", fileDescriptor_0ab50f1d22a2cb61)
}

var fileDescriptor_0ab50f1d22a2cb61 = []byte{
	// 318 bytes of a gzipped FileDescriptorProto
	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xae, 0xd0, 0x2f, 0x48,
	0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc8,
	0x2f, 0x4e, 0xcc, 0x81, 0x70, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x84, 0xb3, 0x4b, 0x93,
	0x33, 0x12, 0x33, 0xf3, 0xf4, 0x2a, 0xf4, 0x20, 0x8a, 0xf5, 0xca, 0x0c, 0xa5, 0xd4, 0x4a, 0x32,
	0x32, 0x8b, 0x52, 0xe2, 0x0b, 0x12, 0x8b, 0x4a, 0x2a, 0xf5, 0xc1, 0xea, 0xf4, 0xd3, 0xf3, 0xd3,
	0xf3, 0x11, 0x2c, 0x88, 0x66, 0xa5, 0xb9, 0x8c, 0x5c, 0xe2, 0x01, 0x20, 0x5d, 0xa9, 0x25, 0xa9,
	0x45, 0xce, 0x19, 0x89, 0x79, 0xe9, 0xa9, 0x01, 0x50, 0x4b, 0x84, 0x44, 0xb8, 0x58, 0x4b, 0x32,
	0x4b, 0x72, 0x52, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x20, 0x1c, 0x21, 0x05, 0x2e, 0xee,
	0x94, 0xd4, 0xe2, 0xe4, 0xa2, 0xcc, 0x82, 0x92, 0xcc, 0xfc, 0x3c, 0x09, 0x26, 0xb0, 0x1c, 0xb2,
	0x90, 0x90, 0x03, 0x17, 0x7b, 0x32, 0xd8, 0xa4, 0x62, 0x09, 0x66, 0x05, 0x66, 0x0d, 0x6e, 0x23,
	0x05, 0x3d, 0x2c, 0x4e, 0xd4, 0x03, 0x5b, 0x0b, 0xb1, 0xd2, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86,
	0x20, 0x98, 0x36, 0x2b, 0x8e, 0x8e, 0x05, 0xf2, 0x0c, 0x33, 0x16, 0xc8, 0x33, 0x28, 0x85, 0x73,
	0x71, 0x23, 0xa9, 0x13, 0x92, 0xe2, 0xe2, 0x28, 0x2e, 0x4d, 0x2a, 0x2e, 0x48, 0x4c, 0x86, 0xb9,
	0x0a, 0xce, 0x17, 0x12, 0xe0, 0x62, 0xce, 0x4e, 0xad, 0x84, 0x3a, 0x08, 0xc4, 0x04, 0x79, 0xa0,
	0x2c, 0x31, 0xa7, 0x34, 0x55, 0x82, 0x19, 0xe2, 0x01, 0x30, 0xc7, 0x8a, 0x05, 0x64, 0xb0, 0x53,
	0xf0, 0x8a, 0x47, 0x72, 0x8c, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91,
	0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65,
	0x9a, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0xef, 0x5d, 0xea, 0x0c, 0x72,
	0xbb, 0x6e, 0x66, 0xbe, 0x3e, 0xd4, 0x1b, 0xfa, 0x38, 0xa2, 0x25, 0x89, 0x0d, 0x1c, 0xa8, 0xc6,
	0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x21, 0x57, 0x20, 0x3b, 0xb8, 0x01, 0x00, 0x00,
}

func (this *ParameterChangeProposal) Equal(that interface{}) bool {
	if that == nil {
		return this == nil
	}

	that1, ok := that.(*ParameterChangeProposal)
	if !ok {
		that2, ok := that.(ParameterChangeProposal)
		if ok {
			that1 = &that2
		} else {
			return false
		}
	}
	if that1 == nil {
		return this == nil
	} else if this == nil {
		return false
	}
	if this.Title != that1.Title {
		return false
	}
	if this.Description != that1.Description {
		return false
	}
	if len(this.Changes) != len(that1.Changes) {
		return false
	}
	for i := range this.Changes {
		if !this.Changes[i].Equal(&that1.Changes[i]) {
			return false
		}
	}
	return true
}
func (this *ParamChange) Equal(that interface{}) bool {
	if that == nil {
		return this == nil
	}

	that1, ok := that.(*ParamChange)
	if !ok {
		that2, ok := that.(ParamChange)
		if ok {
			that1 = &that2
		} else {
			return false
		}
	}
	if that1 == nil {
		return this == nil
	} else if this == nil {
		return false
	}
	if this.Subspace != that1.Subspace {
		return false
	}
	if this.Key != that1.Key {
		return false
	}
	if this.Value != that1.Value {
		return false
	}
	return true
}
func (m *ParameterChangeProposal) Marshal() (dAtA []byte, err error) {
	size := m.Size()
	dAtA = make([]byte, size)
	n, err := m.MarshalToSizedBuffer(dAtA[:size])
	if err != nil {
		return nil, err
	}
	return dAtA[:n], nil
}

func (m *ParameterChangeProposal) MarshalTo(dAtA []byte) (int, error) {
	size := m.Size()
	return m.MarshalToSizedBuffer(dAtA[:size])
}

func (m *ParameterChangeProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) {
	i := len(dAtA)
	_ = i
	var l int
	_ = l
	if len(m.Changes) > 0 {
		for iNdEx := len(m.Changes) - 1; iNdEx >= 0; iNdEx-- {
			{
				size, err := m.Changes[iNdEx].MarshalToSizedBuffer(dAtA[:i])
				if err != nil {
					return 0, err
				}
				i -= size
				i = encodeVarintTypes(dAtA, i, uint64(size))
			}
			i--
			dAtA[i] = 0x1a
		}
	}
	if len(m.Description) > 0 {
		i -= len(m.Description)
		copy(dAtA[i:], m.Description)
		i = encodeVarintTypes(dAtA, i, uint64(len(m.Description)))
		i--
		dAtA[i] = 0x12
	}
	if len(m.Title) > 0 {
		i -= len(m.Title)
		copy(dAtA[i:], m.Title)
		i = encodeVarintTypes(dAtA, i, uint64(len(m.Title)))
		i--
		dAtA[i] = 0xa
	}
	return len(dAtA) - i, nil
}

func (m *ParamChange) Marshal() (dAtA []byte, err error) {
	size := m.Size()
	dAtA = make([]byte, size)
	n, err := m.MarshalToSizedBuffer(dAtA[:size])
	if err != nil {
		return nil, err
	}
	return dAtA[:n], nil
}

func (m *ParamChange) MarshalTo(dAtA []byte) (int, error) {
	size := m.Size()
	return m.MarshalToSizedBuffer(dAtA[:size])
}

func (m *ParamChange) MarshalToSizedBuffer(dAtA []byte) (int, error) {
	i := len(dAtA)
	_ = i
	var l int
	_ = l
	if len(m.Value) > 0 {
		i -= len(m.Value)
		copy(dAtA[i:], m.Value)
		i = encodeVarintTypes(dAtA, i, uint64(len(m.Value)))
		i--
		dAtA[i] = 0x1a
	}
	if len(m.Key) > 0 {
		i -= len(m.Key)
		copy(dAtA[i:], m.Key)
		i = encodeVarintTypes(dAtA, i, uint64(len(m.Key)))
		i--
		dAtA[i] = 0x12
	}
	if len(m.Subspace) > 0 {
		i -= len(m.Subspace)
		copy(dAtA[i:], m.Subspace)
		i = encodeVarintTypes(dAtA, i, uint64(len(m.Subspace)))
		i--
		dAtA[i] = 0xa
	}
	return len(dAtA) - i, nil
}

func encodeVarintTypes(dAtA []byte, offset int, v uint64) int {
	offset -= sovTypes(v)
	base := offset
	for v >= 1<<7 {
		dAtA[offset] = uint8(v&0x7f | 0x80)
		v >>= 7
		offset++
	}
	dAtA[offset] = uint8(v)
	return base
}
func (m *ParameterChangeProposal) Size() (n int) {
	if m == nil {
		return 0
	}
	var l int
	_ = l
	l = len(m.Title)
	if l > 0 {
		n += 1 + l + sovTypes(uint64(l))
	}
	l = len(m.Description)
	if l > 0 {
		n += 1 + l + sovTypes(uint64(l))
	}
	if len(m.Changes) > 0 {
		for _, e := range m.Changes {
			l = e.Size()
			n += 1 + l + sovTypes(uint64(l))
		}
	}
	return n
}

func (m *ParamChange) Size() (n int) {
	if m == nil {
		return 0
	}
	var l int
	_ = l
	l = len(m.Subspace)
	if l > 0 {
		n += 1 + l + sovTypes(uint64(l))
	}
	l = len(m.Key)
	if l > 0 {
		n += 1 + l + sovTypes(uint64(l))
	}
	l = len(m.Value)
	if l > 0 {
		n += 1 + l + sovTypes(uint64(l))
	}
	return n
}

func sovTypes(x uint64) (n int) {
	return (math_bits.Len64(x|1) + 6) / 7
}
func sozTypes(x uint64) (n int) {
	return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *ParameterChangeProposal) Unmarshal(dAtA []byte) error {
	l := len(dAtA)
	iNdEx := 0
	for iNdEx < l {
		preIndex := iNdEx
		var wire uint64
		for shift := uint(0); ; shift += 7 {
			if shift >= 64 {
				return ErrIntOverflowTypes
			}
			if iNdEx >= l {
				return io.ErrUnexpectedEOF
			}
			b := dAtA[iNdEx]
			iNdEx++
			wire |= uint64(b&0x7F) << shift
			if b < 0x80 {
				break
			}
		}
		fieldNum := int32(wire >> 3)
		wireType := int(wire & 0x7)
		if wireType == 4 {
			return fmt.Errorf("proto: ParameterChangeProposal: wiretype end group for non-group")
		}
		if fieldNum <= 0 {
			return fmt.Errorf("proto: ParameterChangeProposal: illegal tag %d (wire type %d)", fieldNum, wire)
		}
		switch fieldNum {
		case 1:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType)
			}
			var stringLen uint64
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowTypes
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				stringLen |= uint64(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			intStringLen := int(stringLen)
			if intStringLen < 0 {
				return ErrInvalidLengthTypes
			}
			postIndex := iNdEx + intStringLen
			if postIndex < 0 {
				return ErrInvalidLengthTypes
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			m.Title = string(dAtA[iNdEx:postIndex])
			iNdEx = postIndex
		case 2:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType)
			}
			var stringLen uint64
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowTypes
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				stringLen |= uint64(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			intStringLen := int(stringLen)
			if intStringLen < 0 {
				return ErrInvalidLengthTypes
			}
			postIndex := iNdEx + intStringLen
			if postIndex < 0 {
				return ErrInvalidLengthTypes
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			m.Description = string(dAtA[iNdEx:postIndex])
			iNdEx = postIndex
		case 3:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field Changes", wireType)
			}
			var msglen int
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowTypes
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				msglen |= int(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			if msglen < 0 {
				return ErrInvalidLengthTypes
			}
			postIndex := iNdEx + msglen
			if postIndex < 0 {
				return ErrInvalidLengthTypes
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			m.Changes = append(m.Changes, ParamChange{})
			if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
				return err
			}
			iNdEx = postIndex
		default:
			iNdEx = preIndex
			skippy, err := skipTypes(dAtA[iNdEx:])
			if err != nil {
				return err
			}
			if skippy < 0 {
				return ErrInvalidLengthTypes
			}
			if (iNdEx + skippy) < 0 {
				return ErrInvalidLengthTypes
			}
			if (iNdEx + skippy) > l {
				return io.ErrUnexpectedEOF
			}
			iNdEx += skippy
		}
	}

	if iNdEx > l {
		return io.ErrUnexpectedEOF
	}
	return nil
}
func (m *ParamChange) Unmarshal(dAtA []byte) error {
	l := len(dAtA)
	iNdEx := 0
	for iNdEx < l {
		preIndex := iNdEx
		var wire uint64
		for shift := uint(0); ; shift += 7 {
			if shift >= 64 {
				return ErrIntOverflowTypes
			}
			if iNdEx >= l {
				return io.ErrUnexpectedEOF
			}
			b := dAtA[iNdEx]
			iNdEx++
			wire |= uint64(b&0x7F) << shift
			if b < 0x80 {
				break
			}
		}
		fieldNum := int32(wire >> 3)
		wireType := int(wire & 0x7)
		if wireType == 4 {
			return fmt.Errorf("proto: ParamChange: wiretype end group for non-group")
		}
		if fieldNum <= 0 {
			return fmt.Errorf("proto: ParamChange: illegal tag %d (wire type %d)", fieldNum, wire)
		}
		switch fieldNum {
		case 1:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field Subspace", wireType)
			}
			var stringLen uint64
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowTypes
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				stringLen |= uint64(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			intStringLen := int(stringLen)
			if intStringLen < 0 {
				return ErrInvalidLengthTypes
			}
			postIndex := iNdEx + intStringLen
			if postIndex < 0 {
				return ErrInvalidLengthTypes
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			m.Subspace = string(dAtA[iNdEx:postIndex])
			iNdEx = postIndex
		case 2:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
			}
			var stringLen uint64
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowTypes
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				stringLen |= uint64(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			intStringLen := int(stringLen)
			if intStringLen < 0 {
				return ErrInvalidLengthTypes
			}
			postIndex := iNdEx + intStringLen
			if postIndex < 0 {
				return ErrInvalidLengthTypes
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			m.Key = string(dAtA[iNdEx:postIndex])
			iNdEx = postIndex
		case 3:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
			}
			var stringLen uint64
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowTypes
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				stringLen |= uint64(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			intStringLen := int(stringLen)
			if intStringLen < 0 {
				return ErrInvalidLengthTypes
			}
			postIndex := iNdEx + intStringLen
			if postIndex < 0 {
				return ErrInvalidLengthTypes
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			m.Value = string(dAtA[iNdEx:postIndex])
			iNdEx = postIndex
		default:
			iNdEx = preIndex
			skippy, err := skipTypes(dAtA[iNdEx:])
			if err != nil {
				return err
			}
			if skippy < 0 {
				return ErrInvalidLengthTypes
			}
			if (iNdEx + skippy) < 0 {
				return ErrInvalidLengthTypes
			}
			if (iNdEx + skippy) > l {
				return io.ErrUnexpectedEOF
			}
			iNdEx += skippy
		}
	}

	if iNdEx > l {
		return io.ErrUnexpectedEOF
	}
	return nil
}
func skipTypes(dAtA []byte) (n int, err error) {
	l := len(dAtA)
	iNdEx := 0
	depth := 0
	for iNdEx < l {
		var wire uint64
		for shift := uint(0); ; shift += 7 {
			if shift >= 64 {
				return 0, ErrIntOverflowTypes
			}
			if iNdEx >= l {
				return 0, io.ErrUnexpectedEOF
			}
			b := dAtA[iNdEx]
			iNdEx++
			wire |= (uint64(b) & 0x7F) << shift
			if b < 0x80 {
				break
			}
		}
		wireType := int(wire & 0x7)
		switch wireType {
		case 0:
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return 0, ErrIntOverflowTypes
				}
				if iNdEx >= l {
					return 0, io.ErrUnexpectedEOF
				}
				iNdEx++
				if dAtA[iNdEx-1] < 0x80 {
					break
				}
			}
		case 1:
			iNdEx += 8
		case 2:
			var length int
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return 0, ErrIntOverflowTypes
				}
				if iNdEx >= l {
					return 0, io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				length |= (int(b) & 0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			if length < 0 {
				return 0, ErrInvalidLengthTypes
			}
			iNdEx += length
		case 3:
			depth++
		case 4:
			if depth == 0 {
				return 0, ErrUnexpectedEndOfGroupTypes
			}
			depth--
		case 5:
			iNdEx += 4
		default:
			return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
		}
		if iNdEx < 0 {
			return 0, ErrInvalidLengthTypes
		}
		if depth == 0 {
			return iNdEx, nil
		}
	}
	return 0, io.ErrUnexpectedEOF
}

var (
	ErrInvalidLengthTypes        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTypes          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group")
)


<|start_filename|>vendor/github.com/tendermint/tm-db/rocksdb.go<|end_filename|>
// +build rocksdb

package db

import (
	"fmt"
	"path/filepath"
	"runtime"

	"github.com/tecbot/gorocksdb"
)

func init() {
	dbCreator := func(name string, dir string) (DB, error) {
		return NewRocksDB(name, dir)
	}
	registerDBCreator(RocksDBBackend, dbCreator, false)
}

// RocksDB is a RocksDB backend.
type RocksDB struct {
	db     *gorocksdb.DB
	ro     *gorocksdb.ReadOptions
	wo     *gorocksdb.WriteOptions
	woSync *gorocksdb.WriteOptions
}

var _ DB = (*RocksDB)(nil)

func NewRocksDB(name string, dir string) (*RocksDB, error) {
	// default rocksdb option, good enough for most cases, including heavy workloads.
	// 1GB table cache, 512MB write buffer(may use 50% more on heavy workloads).
	// compression: snappy as default, need to -lsnappy to enable.
	bbto := gorocksdb.NewDefaultBlockBasedTableOptions()
	bbto.SetBlockCache(gorocksdb.NewLRUCache(1 << 30))
	bbto.SetFilterPolicy(gorocksdb.NewBloomFilter(10))

	opts := gorocksdb.NewDefaultOptions()
	opts.SetBlockBasedTableFactory(bbto)
	opts.SetCreateIfMissing(true)
	opts.IncreaseParallelism(runtime.NumCPU())
	// 1.5GB maximum memory use for writebuffer.
	opts.OptimizeLevelStyleCompaction(512 * 1024 * 1024)
	return NewRocksDBWithOptions(name, dir, opts)
}

func NewRocksDBWithOptions(name string, dir string, opts *gorocksdb.Options) (*RocksDB, error) {
	dbPath := filepath.Join(dir, name+".db")
	db, err := gorocksdb.OpenDb(opts, dbPath)
	if err != nil {
		return nil, err
	}
	ro := gorocksdb.NewDefaultReadOptions()
	wo := gorocksdb.NewDefaultWriteOptions()
	woSync := gorocksdb.NewDefaultWriteOptions()
	woSync.SetSync(true)
	database := &RocksDB{
		db:     db,
		ro:     ro,
		wo:     wo,
		woSync: woSync,
	}
	return database, nil
}

// Get implements DB.
func (db *RocksDB) Get(key []byte) ([]byte, error) {
	key = nonNilBytes(key)
	res, err := db.db.Get(db.ro, key)
	if err != nil {
		return nil, err
	}
	return moveSliceToBytes(res), nil
}

// Has implements DB.
func (db *RocksDB) Has(key []byte) (bool, error) {
	bytes, err := db.Get(key)
	if err != nil {
		return false, err
	}
	return bytes != nil, nil
}

// Set implements DB.
func (db *RocksDB) Set(key []byte, value []byte) error {
	key = nonNilBytes(key)
	value = nonNilBytes(value)
	err := db.db.Put(db.wo, key, value)
	if err != nil {
		return err
	}
	return nil
}

// SetSync implements DB.
func (db *RocksDB) SetSync(key []byte, value []byte) error {
	key = nonNilBytes(key)
	value = nonNilBytes(value)
	err := db.db.Put(db.woSync, key, value)
	if err != nil {
		return err
	}
	return nil
}

// Delete implements DB.
func (db *RocksDB) Delete(key []byte) error {
	key = nonNilBytes(key)
	err := db.db.Delete(db.wo, key)
	if err != nil {
		return err
	}
	return nil
}

// DeleteSync implements DB.
func (db *RocksDB) DeleteSync(key []byte) error {
	key = nonNilBytes(key)
	err := db.db.Delete(db.woSync, key)
	if err != nil {
		return nil
	}
	return nil
}

func (db *RocksDB) DB() *gorocksdb.DB {
	return db.db
}

// Close implements DB.
func (db *RocksDB) Close() error {
	db.ro.Destroy()
	db.wo.Destroy()
	db.woSync.Destroy()
	db.db.Close()
	return nil
}

// Print implements DB.
func (db *RocksDB) Print() error {
	itr, err := db.Iterator(nil, nil)
	if err != nil {
		return err
	}
	defer itr.Close()
	for ; itr.Valid(); itr.Next() {
		key := itr.Key()
		value := itr.Value()
		fmt.Printf("[%X]:\t[%X]\n", key, value)
	}
	return nil
}

// Stats implements DB.
func (db *RocksDB) Stats() map[string]string {
	keys := []string{"rocksdb.stats"}
	stats := make(map[string]string, len(keys))
	for _, key := range keys {
		stats[key] = db.db.GetProperty(key)
	}
	return stats
}

// NewBatch implements DB.
func (db *RocksDB) NewBatch() Batch {
	return newRocksDBBatch(db)
}

// Iterator implements DB.
func (db *RocksDB) Iterator(start, end []byte) (Iterator, error) {
	itr := db.db.NewIterator(db.ro)
	return newRocksDBIterator(itr, start, end, false), nil
}

// ReverseIterator implements DB.
func (db *RocksDB) ReverseIterator(start, end []byte) (Iterator, error) {
	itr := db.db.NewIterator(db.ro)
	return newRocksDBIterator(itr, start, end, true), nil
}


<|start_filename|>vendor/github.com/KuChainNetwork/kuchain/chain/constants/gas.go<|end_filename|>
package constants

import (
	"github.com/KuChainNetwork/kuchain/chain/types"
)

var (
	MinGasPriceString                  = "0.01" + DefaultBondDenom
	GasTxSizePrice              uint64 = 5
	EstimatedGasCreateAcc       uint64 = 40000
	EstimatedGasTransfer        uint64 = 40000
	EstimatedGasUpAuth          uint64 = 50000
	EstimatedGasCreateCoin      uint64 = 40000
	EstimatedGasIssueCoin       uint64 = 40000
	EstimatedGasLockCoin        uint64 = 40000
	EstimatedGasUnlockCoin      uint64 = 40000
	EstimatedGasBurnCoin        uint64 = 50000
	EstimatedGasDelegate        uint64 = 100000
	EstimatedGasUnBonding       uint64 = 150000
	EstimatedGasReDelegate      uint64 = 250000
	EstimatedGasCreateVal       uint64 = 70000
	EstimatedGasEditVal         uint64 = 50000
	EstimatedGasUnJail          uint64 = 50000
	EstimatedGasProposal        uint64 = 100000
	EstimatedGasDeposit         uint64 = 80000
	EstimatedGasVote            uint64 = 100000
	EstimatedGasRewards         uint64 = 100000
	EstimatedGasSetWithdrawAddr uint64 = 40000
)

var (
	MinGasPrice types.DecCoins
)

func init() {
	if minGasPrice, err := types.ParseDecCoins(MinGasPriceString); err != nil {
		panic(err)
	} else {
		MinGasPrice = minGasPrice
	}
}


<|start_filename|>vendor/github.com/KuChainNetwork/kuchain/chain/client/txutil/context.go<|end_filename|>
package txutil

import (
	"io"

	"github.com/KuChainNetwork/kuchain/chain/types"
	"github.com/KuChainNetwork/kuchain/x/account/exported"
	"github.com/cosmos/cosmos-sdk/client/context"
	"github.com/cosmos/cosmos-sdk/codec"
)

// KuCLIContext cli context for kuchain, add account info
type KuCLIContext struct {
	context.CLIContext

	FromAccount AccountID
}

// NewKuCLICtx creates a new KuCLIContext
func NewKuCLICtx(ctx context.CLIContext) KuCLIContext {
	return KuCLIContext{
		CLIContext: ctx,
	}.WithFromAccount(types.NewAccountIDFromAccAdd(ctx.GetFromAddress()))
}

func NewKuCLICtxNoFrom(ctx context.CLIContext) KuCLIContext {
	return KuCLIContext{
		CLIContext: ctx,
	}
}

// NewKuCLICtxByBuf creates a new KuCLIContext with cmd
func NewKuCLICtxByBuf(cdc *codec.Codec, inBuf io.Reader) KuCLIContext {
	return NewKuCLICtx(context.NewCLIContextWithInput(inBuf).WithCodec(cdc))
}

func NewKuCLICtxByBufNoFrom(cdc *codec.Codec, inBuf io.Reader) KuCLIContext {
	ctx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
	return NewKuCLICtxNoFrom(ctx)
}

// WithFromAccount with account from accountID
func (k KuCLIContext) WithFromAccount(from AccountID) KuCLIContext {
	k.FromAccount = from
	return k
}

// WithAccount with account name
func (k KuCLIContext) WithAccount(name Name) KuCLIContext {
	k.FromAccount = types.NewAccountIDFromName(name)
	return k
}

// GetAccountID get account id
func (k KuCLIContext) GetAccountID() AccountID {
	return k.FromAccount
}

// WithOutput returns a copy of the context with an updated output writer (e.g. stdout).
func (k KuCLIContext) WithOutput(w io.Writer) KuCLIContext {
	k.Output = w
	return k
}

// GetAccountInfo get account info by from account id
func (k KuCLIContext) GetAccountInfo() (exported.Account, error) {
	return NewAccountRetriever(k).GetAccount(k.GetAccountID())
}


<|start_filename|>vendor/github.com/KuChainNetwork/kuchain/x/asset/client/cli/create.go<|end_filename|>
package cli

import (
	"bufio"
	"fmt"
	"strconv"

	"github.com/KuChainNetwork/kuchain/chain/client/flags"
	"github.com/KuChainNetwork/kuchain/chain/client/txutil"
	chainTypes "github.com/KuChainNetwork/kuchain/chain/types"
	"github.com/KuChainNetwork/kuchain/x/asset/types"
	"github.com/cosmos/cosmos-sdk/client/context"
	"github.com/cosmos/cosmos-sdk/codec"
	sdk "github.com/cosmos/cosmos-sdk/types"
	sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
	"github.com/pkg/errors"
	"github.com/spf13/cobra"
)

// Create will create a account create tx and sign it with the given key.
func Create(cdc *codec.Codec) *cobra.Command {
	cmd := &cobra.Command{
		Use:   "create [creator] [symbol] [max_supply] [canIssue] [canLock] [canBurn] [issueToHeight] [initSupply] [desc]",
		Short: "Create coin, for canIssue, canLock and canBurn, the 1 means true.",
		Args:  cobra.ExactArgs(9),
		RunE: func(cmd *cobra.Command, args []string) error {
			inBuf := bufio.NewReader(cmd.InOrStdin())
			txBldr := txutil.NewTxBuilderFromCLI(inBuf).WithTxEncoder(txutil.GetTxEncoder(cdc))
			cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)

			creator, err := chainTypes.NewName(args[0])
			if err != nil {
				return err
			}

			creatorID := types.NewAccountIDFromName(creator)

			ctx := txutil.NewKuCLICtx(cliCtx).WithFromAccount(creatorID)
			auth, err := txutil.QueryAccountAuth(ctx, creatorID)
			if err != nil {
				return sdkerrors.Wrapf(err, "query account %s auth error", creatorID)
			}

			symbol, err := chainTypes.NewName(args[1])
			if err != nil {
				return err
			}

			maxSupply, err := chainTypes.ParseCoin(args[2])
			if err != nil {
				return err
			}

			isCanIssue := args[3] == "1"
			isCanLock := args[4] == "1"
			isCanBurn := args[5] == "1"
			issueToHeight, err := strconv.ParseInt(args[6], 10, 64)
			if err != nil {
				return err
			}

			initSupply, err := chainTypes.ParseCoin(args[7])
			if err != nil {
				return errors.Wrap(err, "init supply parse error")
			}

			if chainTypes.CoinDenom(creator, symbol) != maxSupply.Denom {
				return fmt.Errorf("coin denom should equal %s != %s",
					chainTypes.CoinDenom(creator, symbol), maxSupply.Denom)
			}

			if maxSupply.Denom != initSupply.Denom {
				return fmt.Errorf("init coin denom should equal %s != %s",
					initSupply.Denom, maxSupply.Denom)
			}

			desc := args[8]
			if len(desc) > types.CoinDescriptionLen {
				return fmt.Errorf("coin desc too long, should be less than %d", types.CoinDescriptionLen)
			}

			msg := types.NewMsgCreate(auth, creator, symbol, maxSupply, isCanIssue, isCanLock, isCanBurn, issueToHeight, initSupply, []byte(desc))
			return txutil.GenerateOrBroadcastMsgs(ctx, txBldr, []sdk.Msg{msg})
		},
	}

	cmd = flags.PostCommands(cmd)[0]

	return cmd
}


<|start_filename|>vendor/github.com/KuChainNetwork/kuchain/x/asset/burn_test.go<|end_filename|>
package asset_test

import (
	"testing"

	"github.com/KuChainNetwork/kuchain/chain/constants"
	"github.com/KuChainNetwork/kuchain/chain/types"
	"github.com/KuChainNetwork/kuchain/test/simapp"
	assetTypes "github.com/KuChainNetwork/kuchain/x/asset/types"
	. "github.com/smartystreets/goconvey/convey"
)

func checkBurnState(t *testing.T, app *simapp.SimApp, isSuccess bool, from types.AccountID, amt types.Coin) error {
	ctx := app.NewTestContext()

	creator, symbol, err := types.CoinAccountsFromDenom(amt.Denom)
	So(err, ShouldBeNil)

	amtOld := app.AssetKeeper().GetAllBalances(ctx, from)
	statOld, err := app.AssetKeeper().GetCoinStat(ctx, creator, symbol)
	So(err, ShouldBeNil)

	burnErr := BurnCoinTest(t, app, isSuccess, from, amt)

	currAmt := amtOld.Sub(simapp.DefaultTestFee)
	if isSuccess {
		currAmt = currAmt.Sub(types.NewCoins(amt))
	}

	ctx = app.NewTestContext()
	So(app.AssetKeeper().GetAllBalances(ctx, from), simapp.ShouldEq, currAmt)

	statNew, err := app.AssetKeeper().GetCoinStat(ctx, creator, symbol)
	So(err, ShouldBeNil)

	// should no core coin as it can issue per block
	if isSuccess {
		So(statOld.Supply.Sub(amt), simapp.ShouldEq, statNew.Supply)
	} else {
		So(statOld.Supply, simapp.ShouldEq, statNew.Supply)
	}

	return burnErr
}

func TestBurnCoreCoins(t *testing.T) {
	app, _ := createAppForTest()
	Convey("test core coins", t, func() {
		ctx := app.NewTestContext()
		acc1Coins := app.AssetKeeper().GetAllBalances(ctx, account1)
		burnCoin := types.NewInt64Coin(constants.DefaultBondDenom, 10000)

		So(BurnCoinTest(t, app, true, account1, burnCoin), ShouldBeNil)
		amt := acc1Coins.Sub(simapp.DefaultTestFee)
		ctx = app.NewTestContext()
		So(amt.Sub(types.NewCoins(burnCoin)), simapp.ShouldEq, app.AssetKeeper().GetAllBalances(ctx, account1))
	})

	Convey("test burn all core coins error by no fee", t, func() {
		ctx := app.NewTestContext()
		acc2Coins := app.AssetKeeper().GetAllBalances(ctx, account2)
		burnCoin := types.NewInt64CoreCoin(acc2Coins.AmountOf(constants.DefaultBondDenom).Int64())

		So(BurnCoinTest(t, app, false, account2, burnCoin), simapp.ShouldErrIs, assetTypes.ErrAssetCoinNoEnough)
		amt := acc2Coins.Sub(simapp.DefaultTestFee)
		ctx = app.NewTestContext()
		So(amt, simapp.ShouldEq, app.AssetKeeper().GetAllBalances(ctx, account2))
	})

	Convey("test burn all core coins", t, func() {
		ctx := app.NewTestContext()
		acc2Coins := app.AssetKeeper().GetAllBalances(ctx, account2)
		burnCoin := types.NewInt64CoreCoin(acc2Coins.AmountOf(constants.DefaultBondDenom).Int64())
		burnCoin = burnCoin.Sub(simapp.DefaultTestFee[0])

		So(BurnCoinTest(t, app, true, account2, burnCoin), ShouldBeNil)
		ctx = app.NewTestContext()
		So(types.NewCoins(), simapp.ShouldEq, app.AssetKeeper().GetAllBalances(ctx, account2))
	})
}

func TestBurnOtherCoins(t *testing.T) {
	app, _ := createAppForTest()

	var (
		symbol             = types.MustName("abc")
		denom              = types.CoinDenom(name4, symbol)
		maxSupplyAmt int64 = 10000000000000
		issueAmts          = types.NewInt64Coin(denom, maxSupplyAmt)
	)

	Convey("create coins to test at first", t, func() {
		So(createCoin(t, app, true, account4, symbol, maxSupplyAmt), ShouldBeNil)
		So(issueCoin(t, app, true, account4, symbol, issueAmts), ShouldBeNil)
		So(transfer(t, app, true, account4, account1, types.NewInt64Coins(denom, 1000000), account4), ShouldBeNil)
	})

	Convey("test other coins burn", t, func() {
		burnCoin := types.NewInt64Coin(denom, 10000)

		So(checkBurnState(t, app, true, account1, burnCoin), ShouldBeNil)
	})

	Convey("test burn no enough coins", t, func() {
		burnCoin := types.NewInt64Coin(denom, 1000000)

		So(checkBurnState(t, app, false, account1, burnCoin), simapp.ShouldErrIs, assetTypes.ErrAssetCoinNoEnough)
	})

	Convey("test burn all core coins", t, func() {
		ctx := app.NewTestContext()
		acc1Coins := app.AssetKeeper().GetAllBalances(ctx, account1)
		burnCoin := types.NewInt64Coin(denom, acc1Coins.AmountOf(denom).Int64())

		So(checkBurnState(t, app, true, account1, burnCoin), ShouldBeNil)
	})
}

func TestBurnNoCanBurnCoins(t *testing.T) {
	app, _ := createAppForTest()

	var (
		symbol             = types.MustName("abcd1")
		denom              = types.CoinDenom(name4, symbol) // create in last
		maxSupplyAmt int64 = 10000000000000
		issueAmts          = types.NewInt64Coin(denom, 10000000000000)
	)

	Convey("create coins to test at first", t, func() {
		So(createCoinExt(t, app, true,
			account4, symbol,
			types.NewInt64Coin(denom, maxSupplyAmt),
			true, true,
			false, // cannot burn
			0,
			types.NewInt64Coin(denom, 0), []byte("cannot issue")), ShouldBeNil)
		So(issueCoin(t, app, true, account4, symbol, issueAmts), ShouldBeNil)
		So(transfer(t, app, true, account4, account1, types.NewInt64Coins(denom, 1000000), account4), ShouldBeNil)
	})

	Convey("test other coins burn", t, func() {
		burnCoin := types.NewInt64Coin(denom, 10000)

		So(checkBurnState(t, app, false, account1, burnCoin), simapp.ShouldErrIs, assetTypes.ErrAssetCoinCannotBeBurn)
	})
}
