package bucash

//"fmt"

var (
	ErrMsg map[int]string
)

const (
	OK       = 0
	TIME_OUT = iota + 20
	WALLETINFO_ERR
	INNER_ERR
	TRANSINFO_ERR
	AMOUNT_ERR
	SENDCOINS_ERR
	GETBALANCE_ERR
	GETUNCONFIRMEDBALANCE_ERR
	GETNEWADDRESS_ERR
	DUMPPRIVKEY_ERR
	GETCLOCKCOUNT_ERR
	GETBLOCKINFO_ERR
	LISTUNSPENT_ERR
	SEND_RAW_TRANSACTION_ERR
	PARM_ERR
	UNKNOWN_ERR
)

func initLiteErr() {
	ErrMsg = make(map[int]string)
	ErrMsg[0] = "成功"
	ErrMsg[22] = " 钱包信息查询错误"
	ErrMsg[23] = " 内部错误"
	ErrMsg[24] = " 获取交易信息出错"
	ErrMsg[25] = " 传入的转账金额不合法"
	ErrMsg[26] = " 发送数字币出错"
	ErrMsg[27] = " 获取已确认余额出错"
	ErrMsg[28] = " 获取未确认的余额出错"
	ErrMsg[29] = " 获取地址出错"
	ErrMsg[30] = " 获取私钥出错"
	ErrMsg[31] = " 获取当前区块链的高度出错"
	ErrMsg[32] = " 获取区块链信息出错"
	ErrMsg[33] = " 获取未使用的交易输出失败"
	ErrMsg[34] = " 发送原始交易信息出错"
	ErrMsg[35] = "传入参数错误"
}

func getErrMsg(ret int, data []byte) string {
	msg, ok := ErrMsg[ret]
	if ok {
		return msg
	}
	return string(data)
}
