slim

package
v0.0.0-...-da2935b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2023 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Bech32 prefixes
	//Bech32PrefixAccPub = "cosmosaccpub"
	AccountResultType = "local"
	DenomQOS          = "qos"
	PREF_ADD          = "address"
)
View Source
const (
	AccountMapperName = "acc" // 用户获取账户存储的store的键名

	MaxGas = 20000
)
View Source
const (
	ResultCodeSuccess       = "0"
	ResultCodeQstarsTimeout = "-2"
	ResultCodeQOSTimeout    = "-1"
	ResultCodeInternalError = "500"
)

Variables

View Source
var (
	Shost         string
	Mhost         string
	QSCAccounturl string
	QOSAccounturl string
	Accounturl    string
	KVurl         string
	QResulturl    string
	TRurl         string
	RPC           rpcclient.Client
)

IP initialization

Functions

func AccountCreateFromSeed

func AccountCreateFromSeed(mncode string) string

add new function for Account Creation with seed input

func AccountCreateStr

func AccountCreateStr(password string) string

convert the output to json string format

func AccountRecoverStr

func AccountRecoverStr(mncode, password string) string

func AcutionAd

func AcutionAd(articleHash, privatekey, coinsType, coinAmount, qscchainid string) string

AcutionAd 竞拍广告 articleHash //广告位标识 privatekey //用户私钥 coinsType //竞拍币种 coinAmount //竞拍数量 qscchainid //chainid

func AddressStoreKey

func AddressStoreKey(addr Address) []byte

AddressStoreKey 将地址转换成存储通用的key

func Advertisers

func Advertisers(amount, privatekey, cointype, isDeposit, qscchainid string) string

广告商押金或赎回

func AdvertisersFalse

func AdvertisersFalse(privatekey, coinsType, coinAmount, qscchainid string) string

AdvertisersFalse 成为非广告商 赎回押金 privatekey //用户私钥 coinsType //押金币种 coinAmount //押金数量 qscchainid //chainid

func AdvertisersTrue

func AdvertisersTrue(privatekey, coinsType, coinAmount, qscchainid string) string

AdvertisersTrue 成为广告商 privatekey //用户私钥 coinsType //押金币种 coinAmount //押金数量 qscchainid //chainid

func AesDecrypt

func AesDecrypt(keystring, cryptoText string) string

func AesEncrypt

func AesEncrypt(keystring, text string) string

func BroadcastTransferTxToQSC

func BroadcastTransferTxToQSC(txb string, broadcastModes string) string

BroadcastTransferTxToQSC 提交到联盟链上

func CommHandler

func CommHandler(funcName, privatekey, argstr, qscchainid string) string

func Extract

func Extract(amount, privatekey, cointype, qscchainid string) string

Extract 广告商押金或赎回

func GetTx

func GetTx(tx string) string

func Int2Byte

func Int2Byte(in int64) []byte

Int2Byte 函数:int64 转化为 []byte

func JQInvestAd

func JQInvestAd(QOSchainId, QSCchainId, articleHash, coins, privatekey string) string

func LocalTxGen

func LocalTxGen(fromStr, toStr, coinstr, chainid, privkey string, nonce int64) []byte

Local Tx generation

func NewParseCoins

func NewParseCoins(str string) (BigInt, QSCs, error)

NewParseCoins Parse QOS and QSCs from string str example : 100qos,100qstar

func PubAddrRetrievalStr

func PubAddrRetrievalStr(s string) string

func QOSCommitResultCheck

func QOSCommitResultCheck(txhash, height string) string

QOSCommitResultCheck for QOSCommitResultCheck Restful interface

func QOSQueryAccountGet

func QOSQueryAccountGet(addr string) string

QOSQueryAccountGet for QOS account query function

func QSCCreateSignedTransfer

func QSCCreateSignedTransfer(addrto, coinstr, privkey, chainid string) (string, error)

func QSCKVStoreGetQuery

func QSCKVStoreGetQuery(k string) string

func QSCKVStoreSetPost

func QSCKVStoreSetPost(k, v, privkey, chain string) (result string)

func QSCQueryAccountGet

func QSCQueryAccountGet(addr string) string

func QSCtransferSendStr

func QSCtransferSendStr(addrto, coinstr, privkey, chainid string) string

QSCtransferSendStr only need the following arguments, it`s enough!

func Query

func Query(path string, key common.HexBytes) (res []byte, err error)

func RPCCQSCQueryAccountGet

func RPCCQSCQueryAccountGet(addr string) string

func RegisterAmino

func RegisterAmino(cdc *amino.Codec)

RegisterAmino registers all crypto related types in the given (amino) codec.

func RegisterCodec

func RegisterCodec(cdc *amino.Codec)

func SetBlockchainEntrance

func SetBlockchainEntrance(qstarshost, qmoonhost string)

SetBlockchainEntrance set Block Chain entrance hosts for both Qstars and Qmoon

func TransferRecordsQuery

func TransferRecordsQuery(chainid, addr, cointype, offset, limit string) string

Types

type AccountKeyOut

type AccountKeyOut struct {
	PubKey   string `json:"pubKey"`
	PrivKey  string `json:"privKey"`
	Addr     string `json:"addr"`
	Mnemonic string `json:"mnemonic"`
	Type     string `json:"type"`
	Denom    string `json:"denom"`
}

new account result with field of Denom

type Address

type Address []byte

func (Address) Bytes

func (add Address) Bytes() []byte

func (Address) MarshalJSON

func (add Address) MarshalJSON() ([]byte, error)

func (Address) String

func (add Address) String() string

func (*Address) UnmarshalJSON

func (add *Address) UnmarshalJSON(bech32Addr []byte) error

UnmarshalJSON 将Bech32编码的地址Json进行UnMarshal

type AdvertisersTx

type AdvertisersTx struct {
	Tx *CoinsTx
}

func (AdvertisersTx) GetSignData

func (tx AdvertisersTx) GetSignData() (ret []byte)

type AuctionTx

type AuctionTx struct {
	ArticleHash string  // 文章hash
	Address     Address //qos地址
	CoinsType   string  //币种
	CoinAmount  BigInt  //数量
	Gas         BigInt
}

func (AuctionTx) GetSignData

func (tx AuctionTx) GetSignData() (ret []byte)

type BaseAccount

type BaseAccount struct {
	AccountAddress Address             `json:"account_address"` // account address
	Publickey      ed25519local.PubKey `json:"public_key"`      // public key
	Nonce          int64               `json:"nonce"`           // identifies tx_status of an account
}

type BaseCoin

type BaseCoin struct {
	Name   string `json:"coin_name"`
	Amount BigInt `json:"amount"`
}

func (*BaseCoin) String

func (coin *BaseCoin) String() string

type BaseCoins

type BaseCoins []*BaseCoin

func (BaseCoins) String

func (coins BaseCoins) String() string

type BigInt

type BigInt struct {
	// contains filtered or unexported fields
}

func NewBigInt

func NewBigInt(n int64) BigInt

func ZeroInt

func ZeroInt() BigInt

ZeroInt returns BigInt value with zero

func (BigInt) Add

func (i BigInt) Add(i2 BigInt) (res BigInt)

Add adds BigInt from another

func (BigInt) Int64

func (i BigInt) Int64() int64

func (BigInt) IsNil

func (bi BigInt) IsNil() bool

func (BigInt) MarshalAmino

func (i BigInt) MarshalAmino() (string, error)

MarshalAmino defines custom encoding scheme

func (BigInt) MarshalJSON

func (i BigInt) MarshalJSON() ([]byte, error)

MarshalJSON defines custom encoding scheme

func (BigInt) NilToZero

func (i BigInt) NilToZero() BigInt

func (BigInt) String

func (i BigInt) String() string

func (*BigInt) UnmarshalAmino

func (i *BigInt) UnmarshalAmino(text string) error

UnmarshalAmino defines custom decoding scheme

func (*BigInt) UnmarshalJSON

func (i *BigInt) UnmarshalJSON(bz []byte) error

UnmarshalJSON defines custom decoding scheme

type Codec

type Codec = amino.Codec
var Cdc *Codec

func NewCodec

func NewCodec() *Codec

type Coin

type Coin struct {
	Denom  string `json:"denom"`
	Amount Int    `json:"amount"`
}

func ParseCoin

func ParseCoin(coinStr string) (coin Coin, err error)

func (Coin) IsZero

func (coin Coin) IsZero() bool

type Coins

type Coins []Coin

func ParseCoins

func ParseCoins(coinsStr string) (coins Coins, err error)

func (Coins) IsValid

func (coins Coins) IsValid() bool

func (Coins) IsZero

func (coins Coins) IsZero() bool

func (Coins) Len

func (coins Coins) Len() int

func (Coins) Less

func (coins Coins) Less(i, j int) bool

func (Coins) Sort

func (coins Coins) Sort() Coins

func (Coins) Swap

func (coins Coins) Swap(i, j int)

type CoinsTx

type CoinsTx struct {
	Address    Address
	Cointype   string
	Amount     BigInt
	ChangeType string //0 plus  1 minus
}

type ExtractTx

type ExtractTx struct {
	Tx *CoinsTx
}

func (ExtractTx) GetSignData

func (tx ExtractTx) GetSignData() (ret []byte)

type ITx

type ITx interface {
	GetSignData() []byte //获取签名字段
}

type Int

type Int struct {
	// contains filtered or unexported fields
}

func NewInt

func NewInt(n int64) Int

NewInt constructs BigInt from int64 genStdSendTx for the Tx send operation

func (Int) Int64

func (i Int) Int64() int64

func (Int) IsZero

func (i Int) IsZero() bool

type InvestTx

type InvestTx struct {
	Address     Address `json:"address"`     // 投资者地址
	Invest      BigInt  `json:"investad"`    // 投资金额
	ArticleHash []byte  `json:"articleHash"` // 文章hash
	Gas         BigInt
	// contains filtered or unexported fields
}

func (InvestTx) GetSignData

func (it InvestTx) GetSignData() (ret []byte)

type JianQianTx

type JianQianTx struct {
	FuncName string    //方法名 路由用
	Address  []Address //签名者地址
	Args     []string  //参数列表
	Gas      BigInt
}

func (JianQianTx) GetSignData

func (it JianQianTx) GetSignData() (ret []byte)

type PrivkeyAmino

type PrivkeyAmino struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type PubAddrRetrieval

type PubAddrRetrieval struct {
	PubKey string `json:"pubKey"`
	Addr   string `json:"addr"`
}

type PubkeyAmino

type PubkeyAmino struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type QOSAccount

type QOSAccount struct {
	BaseAccount `json:"base_account"`
	QOS         BigInt `json:"qos"`  // coins in public chain
	QSCs        QSCs   `json:"qscs"` // varied QSCs
}

func RpcQueryAccount

func RpcQueryAccount(addr Address) (*QOSAccount, error)

type QSC

type QSC = BaseCoin

type QSCs

type QSCs = BaseCoins

type ResultCreateAccount

type ResultCreateAccount struct {
	PubKey   string `json:"pubKey"`
	PrivKey  string `json:"privKey"`
	Addr     string `json:"addr"`
	Mnemonic string `json:"mnemonic"`
	Type     string `json:"type"`
	Denom    string `json:"denom"`
}

func AccountCreate

func AccountCreate(password string) *ResultCreateAccount

type ResultInvest

type ResultInvest struct {
	Code   string          `json:"code"`
	Height int64           `json:"height"`
	Hash   string          `json:"hash,omitempty"`
	Reason string          `json:"reason,omitempty"`
	Result json.RawMessage `json:"result,omitempty"`
}

func InternalError

func InternalError(reason string) ResultInvest

func NewErrorResult

func NewErrorResult(code string, height int64, hash string, reason string) ResultInvest

func (ResultInvest) Marshal

func (ri ResultInvest) Marshal() string

type Signature

type Signature struct {
	Pubkey    ed25519local.PubKey `json:"pubkey"`    //可选
	Signature []byte              `json:"signature"` //签名内容
	Nonce     int64               `json:"nonce"`     //nonce的值
}

type TransItem

type TransItem struct {
	Address Address `json:"addr"` // 账户地址
	QOS     BigInt  `json:"qos"`  // QOS
	QSCs    QSCs    `json:"qscs"` // QSCs
}

type TransItems

type TransItems []TransItem

func ParseTransItem

func ParseTransItem(str string) (TransItems, error)

ParseTransItem Parse flags from string, Senders, eg: Arya,10qos,100qstar. multiple users separated by ';'

type TxStd

type TxStd struct {
	ITx       ITx         `json:"itx"`      //ITx接口,将被具体Tx结构实例化
	Signature []Signature `json:"sigature"` //签名数组
	ChainID   string      `json:"chainid"`  //ChainID: 执行ITx.exec方法的链ID
	MaxGas    BigInt      `json:"maxgas"`   //Gas消耗的最大值
}

func NewTxStd

func NewTxStd(itx ITx, cid string, mgas BigInt) (rTx *TxStd)

NewTxStd 调用 NewTxStd后,需调用TxStd.SignTx填充TxStd.Signature(每个TxStd.Signer())

func (*TxStd) BuildSignatureBytes

func (tx *TxStd) BuildSignatureBytes(nonce int64, qcpFromChainID string) []byte

func (*TxStd) GetSignData

func (tx *TxStd) GetSignData() []byte

func (*TxStd) SignTx

func (tx *TxStd) SignTx(privkey ed25519local.PrivKey, nonce int64, fromChainID string) (signedbyte []byte, err error)

SignTx 签名:每个签名者外部调用此方法

type TxTransfer

type TxTransfer struct {
	Senders   TransItems `json:"senders"`   // 发送集合
	Receivers TransItems `json:"receivers"` // 接收集合
}

func (TxTransfer) GetSignData

func (tx TxTransfer) GetSignData() (ret []byte)

GetSignData 签名字节

Directories

Path Synopsis
funcInlocal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL