wiccwallet

package module
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: MIT Imports: 11 Imported by: 0

README

wicc-wallet-utils-go

维基链go语言离线签名钱包库 (WaykiChain Wallet Library for Offline Operation written in golang)

下载(Install)

  • go get github.com/WaykiChain/wicc-wallet-utils-go
  • go get github.com/btcsuite

用法(Usage)

创建钱包(WaykiChain Create Wallet)

生成助记词和私钥管理你的钱包。
Generate mnemonics and private keys to manage your wallet.

func GenerateMnemonics() string

func GetPrivateKeyFromMnemonic(words string, netType int) string

func GetPubKeyFromPrivateKey(privKey string) (string,error) 

func GetAddressFromPrivateKey(privateKey string, netType int) string

func GetAddressFromMnemonic(words string, netType int) string
  • GenerateMnemonics.
    生成12个助记词
    (You will get 12 words).
  • GetPrivateKeyFromMnemonic.
    你提供你的助记词和网络类型(1 主网,2 测试网),函数会给你返回私钥,主网私钥大写P开头,测试网大写Y开头。
    (You should provide your mnemonic and network Type (1 MainNet,2 TestNet),function return private Key,MainNet Private key start with "P" ,TestNet private key start with "Y".)
  • GetPubKeyFromPrivateKey.
    (提供私钥获得公钥,获得公钥的16进制字符串)
    you should provide your Private Key,the function return wallet public key as hex string.
  • GetAddressFromPrivateKey.
    私钥获得钱包地址,地址是Base58编码的字符串,主网地址大写字母W开头,测试网地址小写字母w开头。
    you should provide your Private Key,the function return wallet Address as base58 encode string,MainNet Address start with "W",TestNet Address start with "w".
  • GetAddressFromMnemonic.
    从助记词获得地址。
    you should provide your mnemonic,the function return wallet Address as base58 encode string,MainNet Address start with "W",TestNet Address start with "w".

示例(Examples):

生成助记词(Generate mnemonic:)

mnemonic := GenerateMnemonics()

助记词生成钱包私钥(Get private key from mnemonic:)

mnemonic := "empty regular curve turtle student prize toy accuse develop spike scatter ginger"
privateKey := GetPrivateKeyFromMnemonic(mnemonic, WAYKI_MAINTNET)

私钥获得公钥(Get public key from private key:)

publicKey,_:=GetPubKeyFromPrivateKey("Y6J4aK6Wcs4A3Ex4HXdfjJ6ZsHpNZfjaS4B9w7xqEnmFEYMqQd13")

私钥获得钱包地址(Get address from private key:)

address := GetAddressFromPrivateKey(privateKey, WAYKI_MAINTNET)

助记词获得钱包地址(Get address from mnemonic:)

mnemonic := "empty regular curve turtle student prize toy accuse develop spike scatter ginger"
address := GetAddressFromMnemonic(mnemonic, WAYKI_MAINTNET)
维基链签名交易(WaykiChain Sign Transaction)

用私钥签名交易,你可以使用bass提交钱包库生成的rawtx字符串。
Signing a transaction with a private key,you can submit your offline signature rawtx transaction by bass.

BassNetwork Api
TestNet https://baas-test.wiccdev.org/v2/api/swagger-ui.html#!/
MainNet https://baas.wiccdev.org/v2/api/swagger-ui.html#!/

Submit raw string:

Mainnet https://baas.wiccdev.org/v2/api/swagger-ui.html#!/transaction-controller/offlinTransactionUsingPOST ,

TestNet https://baas-test.wiccdev.org/v2/api/swagger-ui.html#!/transaction-controller/offlinTransactionUsingPOST,

Get block height:

MainNethttps://baas.wiccdev.org/v2/api/swagger-ui.html#!/block-controller/getBlockCountUsingPOST,

TestNet https://baas-test.wiccdev.org/v2/api/swagger-ui.html#!/block-controller/getBlockCountUsingPOST

转账交易
合约交易(部署、调用)
CDP交易(CDP Transaction)

用户可以通过抵押WICC获得WUSD,一个用户只能拥有一个cdp,除非之前的cdp已经关闭。
Any user holding a WICC can send a WICC to the CDP (Collaterized Debt Position) to obtain a certain percentage of WUSD.a user can only have one cdp unless the previous cdp has been destroyed.

func SignCdpStakeTx(privateKey string, param *CdpStakeTxParam) (string, error) 

func SignCdpRedeemTx(privateKey string, param *CdpRedeemTxParam) (string, error) 

func SignCdpLiquidateTx(privateKey string, param *CdpLiquidateTxParam) (string, error)
  • SignCdpStakeTx.
    CDP抵押交易签名。
    sign cdp stake transaction with a private key , return the rawtx string.
  • SignCdpRedeemTx.
    cdp赎回交易签名。
    sign cdp redeem transaction with a private key , return the rawtx string.
  • SignCdpLiquidateTx.
    CDP清算交易签名。
    sign cdp liquidate transaction with a private key , return the rawtx string.

示例(Example:)

Sign cdp stake transaction:

    privateKey := "Y6J4aK6Wcs4A3Ex4HXdfjJ6ZsHpNZfjaS4B9w7xqEnmFEYMqQd13"
	var txParam CdpStakeTxParam
	txParam.CdpTxid = "0b9734e5db3cfa38e76bb273dba4f65a210cc76ca2cf739f3c131d0b24ff89c1"  //user cdp transaction hash,If the user has not created a cdp, then do not fill out
	txParam.BcoinSymbol = string(commons.WICC)   //pay WICC
	txParam.ScoinSymbol = string(commons.WUSD)   //get WUSD
	txParam.FeeSymbol = string(commons.WICC)    //fee symbol (WICC/WUSD)
	txParam.BcoinStake = 100000000
	txParam.ScoinMint = 50000000
	txParam.Fees = 100000                       //Miner fee,minimum 100000sawi
	txParam.ValidHeight = 283308
	txParam.SrcRegId = "0-1"
	txParam.PubKey = "03e93e7d870ce6f1c9997076c56fc24e6381c612662cd9a5a59294fac9ba7d21d7"

	hash, err := SignCdpStakeTx(privateKey, &txParam)
	if err != nil {
		t.Error("SignCdpStakeTx err: ", err)
	}

Sign cdp redeem transaction:

    privateKey := "Y6J4aK6Wcs4A3Ex4HXdfjJ6ZsHpNZfjaS4B9w7xqEnmFEYMqQd13"
	var txParam CdpRedeemTxParam
	txParam.CdpTxid = "0b9734e5db3cfa38e76bb273dba4f65a210cc76ca2cf739f3c131d0b24ff89c1"//user cdp create transaction hash
	txParam.FeeSymbol = string(commons.WICC)
	txParam.ScoinsToRepay = 20000000
	txParam.BcoinsToRedeem = 100000000
	txParam.Fees = 100000                                     //Miner fee,minimum 100000sawi
	txParam.ValidHeight = 25
	txParam.SrcRegId = "0-1"
	txParam.PubKey = "03e93e7d870ce6f1c9997076c56fc24e6381c612662cd9a5a59294fac9ba7d21d7"

	hash, err := SignCdpRedeemTx(privateKey, &txParam)
	if err != nil {
		t.Error("SignCdpStakeTx err: ", err)
	}

Sign cdp liquidate transaction:

    privateKey := "Y6J4aK6Wcs4A3Ex4HXdfjJ6ZsHpNZfjaS4B9w7xqEnmFEYMqQd13"
	var txParam CdpLiquidateTxParam
	txParam.CdpTxid = "0b9734e5db3cfa38e76bb273dba4f65a210cc76ca2cf739f3c131d0b24ff89c1"//Liquidated cdp transaction hash id
	txParam.FeeSymbol = string(commons.WICC)
	txParam.ScoinsLiquidate = 100000000
	txParam.Fees = 100000                                                    //Miner fee,minimum 100000sawi
	txParam.ValidHeight = 25
	txParam.SrcRegId = "0-1"
	txParam.PubKey = "03e93e7d870ce6f1c9997076c56fc24e6381c612662cd9a5a59294fac9ba7d21d7"

	hash, err := SignCdpLiquidateTx(privateKey, &txParam)
	if err != nil {
		t.Error("SignCdpStakeTx err: ", err)
	}
DEX Transaction

维基链去中心化交易所。
WaykiChain decentralized exchange.

func SignDexSellLimitTx(privateKey string, param *DexLimitTxParam) (string, error)

func SignDexMarketSellTx(privateKey string, param *DexMarketTxParam) (string, error)

func SignDexBuyLimitTx(privateKey string, param *DexLimitTxParam) (string, error)

func SignDexMarketBuyTx(privateKey string, param *DexMarketTxParam) (string, error)

func SignDexCancelTx(privateKey string, param *DexCancelTxParam) (string, error)
  • SignDexSellLimitTx.
    限价卖单。 sign dex sell limit price transaction with a private key , return the rawtx string.
  • SignDexMarketSellTx.
    市价卖单。
    sign dex sell market price transaction with a private key , return the rawtx string.
  • SignDexBuyLimitTx.
    限价买单。
    sign dex buy limit price transaction with a private key , return the rawtx string.
  • SignDexMarketBuyTx.
    市价买单。
    sign dex buy market price transaction with a private key , return the rawtx string.
  • SignDexCancelTx.
    取消挂单。
    sign cancel dex order transaction with a private key , return the rawtx string.

Sign dex Buy limit price transaction:

	privateKey := "Y6J4aK6Wcs4A3Ex4HXdfjJ6ZsHpNZfjaS4B9w7xqEnmFEYMqQd13"
	var txParam DexLimitTxParam
	txParam.FeeSymbol = string(commons.WICC)
	txParam.Fees = 100000
	txParam.CoinSymbol = string(commons.WUSD)
	txParam.AssetSymbol = string(commons.WICC)
	txParam.AssetAmount = 10000
	txParam.ValidHeight = 25
	txParam.Price = 25                      
	txParam.SrcRegId = "0-1"
	txParam.PubKey = "03e93e7d870ce6f1c9997076c56fc24e6381c612662cd9a5a59294fac9ba7d21d7"

	hash, err := SignDexBuyLimitTx(privateKey, &txParam)
	if err != nil {
		t.Error("SignCdpStakeTx err: ", err)
	}

Sign dex sell limit price transaction:

    privateKey := "Y6J4aK6Wcs4A3Ex4HXdfjJ6ZsHpNZfjaS4B9w7xqEnmFEYMqQd13"
	var txParam DexLimitTxParam
	txParam.FeeSymbol = string(commons.WICC)
	txParam.Fees = 10000
	txParam.CoinSymbol = string(commons.WUSD)
	txParam.AssetSymbol = string(commons.WICC)
	txParam.AssetAmount = 1000000
	txParam.ValidHeight = 282956
	txParam.Price = 200000000
	txParam.SrcRegId = "0-1"
	txParam.PubKey = "03e93e7d870ce6f1c9997076c56fc24e6381c612662cd9a5a59294fac9ba7d21d7"

	hash, err := SignDexSellLimitTx(privateKey, &txParam)
	if err != nil {
		t.Error("SignCdpStakeTx err: ", err)
	}

Sign dex sell market price transaction:

    privateKey := "Y6J4aK6Wcs4A3Ex4HXdfjJ6ZsHpNZfjaS4B9w7xqEnmFEYMqQd13"
	var txParam DexMarketTxParam
	txParam.FeeSymbol = string(commons.WICC)
	txParam.Fees = 100000
	txParam.CoinSymbol = string(commons.WUSD)
	txParam.AssetSymbol = string(commons.WICC)
	txParam.AssetAmount = 10000
	txParam.ValidHeight = 25
	txParam.SrcRegId = "0-1"
	txParam.PubKey = "03e93e7d870ce6f1c9997076c56fc24e6381c612662cd9a5a59294fac9ba7d21d7"

	hash, err := SignDexMarketSellTx(privateKey, &txParam)
	if err != nil {
		t.Error("SignCdpStakeTx err: ", err)
	}

Sign dex buy market price transaction:

    privateKey := "Y6J4aK6Wcs4A3Ex4HXdfjJ6ZsHpNZfjaS4B9w7xqEnmFEYMqQd13"
	var txParam DexMarketTxParam
	txParam.FeeSymbol = string(commons.WICC)
	txParam.Fees = 100000
	txParam.CoinSymbol = string(commons.WUSD)
	txParam.AssetSymbol = string(commons.WICC)
	txParam.AssetAmount = 10000
	txParam.ValidHeight = 25
	txParam.SrcRegId = "0-1"
	txParam.PubKey = "03e93e7d870ce6f1c9997076c56fc24e6381c612662cd9a5a59294fac9ba7d21d7"

	hash, err := SignDexMarketBuyTx(privateKey, &txParam)
	if err != nil {
		t.Error("SignCdpStakeTx err: ", err)
	}

Sign dex cancel order transaction:

	privateKey := "Y6J4aK6Wcs4A3Ex4HXdfjJ6ZsHpNZfjaS4B9w7xqEnmFEYMqQd13"
	var txParam DexCancelTxParam
	txParam.FeeSymbol = string(commons.WICC)
	txParam.Fees = 100000
	txParam.DexTxid = "009c0e665acdd9e8ae754f9a51337b85bb8996980a93d6175b61edccd3cdc144"//dex transaction tx id
	txParam.ValidHeight = 25
	txParam.SrcRegId = "0-1"
	txParam.PubKey = "03e93e7d870ce6f1c9997076c56fc24e6381c612662cd9a5a59294fac9ba7d21d7"

	hash, err := SignDexCancelTx(privateKey, &txParam)
	if err != nil {
		t.Error("SignCdpStakeTx err: ", err)
	}

Documentation

Index

Constants

View Source
const (
	ENGLISH  string = "EN"
	JAPANESE        = "JP"
	FRENCH          = "FR"
	ITALIAN         = "IT"
	KOREAN          = "KR"
	SPANISH         = "ES"
)

List Mnemonic language support

View Source
const (
	// network type
	WAYKI_MAINTNET int = 1 // mainnet
	WAYKI_TESTNET  int = 2 // testnet

	// const for transactions
	TX_VERSION                    = 1                             // transaction version
	INITIAL_COIN                  = 210000000                     // initial coin, unit: wicc
	MONEY_PER_COIN                = 100000000                     // money per coin, unit: sawi
	MAX_MONEY                     = INITIAL_COIN * MONEY_PER_COIN // the max money in WaykiChain
	MIN_TX_FEE                    = 10000                         // tx fee min value, unit: sawi
	CONTRACT_SCRIPT_MAX_SIZE      = 65536                         //64 KB max for contract script size, unit: bytes
	CONTRACT_SCRIPT_DESC_MAX_SIZE = 512                           //max for contract script description size, unit: bytes
	MIN_TX_FEE_CDP                = 100000                        // cdp tx fee min value, unit: sawi
)

Variables

View Source
var (
	ERR_INVALID_MNEMONIC      = errors.New("Invalid Mnemonic")
	ERR_INVALID_NETWORK       = errors.New("Invalid Network type")
	ERR_INVALID_PRIVATE_KEY   = errors.New("privateKey invalid")
	ERR_NEGATIVE_VALID_HEIGHT = errors.New("ValidHeight can not be negative")
	ERR_INVALID_SRC_REG_ID    = errors.New("SrcRegId must be a valid RegID")
	ERR_INVALID_DEST_ADDR     = errors.New("DestAddr must be a valid RegID or Address")
	ERR_RANGE_VALUES          = errors.New("Values out of range")
	ERR_RANGE_FEE             = errors.New("Fees out of range")
	ERR_FEE_SMALLER_MIN       = errors.New("Fees smaller than MinTxFee")
	ERR_EMPTY_VOTES           = errors.New("Votes can be not empty")
	ERR_INVALID_VOTE_PUBKEY   = errors.New("Vote PubKey invalid, PubKey len must equal 33")
	ERR_RANGE_VOTE_VALUE      = errors.New("VoteValue out of range")
	ERR_INVALID_APP_ID        = errors.New("AppId must be a valid RegID")
	ERR_INVALID_CONTRACT_HEX  = errors.New("ContractHex must be valid hex format")
	ERR_INVALID_SCRIPT        = errors.New("Script can not be empty or is too large")
	ERR_INVALID_SCRIPT_DESC   = errors.New("Description of script is too large")

	ERR_CDP_TX_HASH      = errors.New("CDP tx hash error")
	ERR_CDP_STAKE_NUMBER = errors.New("CDP stake number error")
	ERR_COIN_TYPE        = errors.New("Coin type error")
	ERR_USER_PUBLICKEY   = errors.New("PublicKey invalid")

	ERR_ASK_PRICE                = errors.New("Ask Price invalid")
	ERR_SIGNATURE_ERROR          = errors.New("Signature error")
	ERR_SYMBOL_ERROR             = errors.New("Symbol Capital letter A-Z 6-7 digits [A_Z] error")
	ERR_ASSET_NAME_ERROR         = errors.New("Asset Name error")
	ERR_TOTAl_SUPPLY_ERROR       = errors.New("Asset Total Supply error")
	ERR_ASSET_UPDATE_TYPE_ERROR  = errors.New("Asset Update Type error")
	ERR_ASSET_UPDATE_OWNER_ERROR = errors.New("Asset Update Owner error")
)

errors

Functions

func CheckPrivateKey

func CheckPrivateKey(privateKey string, netType int) (bool, error)

func CheckWalletAddress

func CheckWalletAddress(address string, netType int) (bool, error)

func GenerateMnemonics

func GenerateMnemonics() string

Generate Mnemonics string, saprated by space, default language is EN(english)

func GetAddressFromMnemonic

func GetAddressFromMnemonic(words string, netType int) (string, error)

助记词转换地址 netType: WAYKI_TESTNET or WAYKI_MAINTNET

func GetAddressFromPrivateKey

func GetAddressFromPrivateKey(privateKey string, netType int) string

GetAddressFromPrivateKey get address from private key netType: WAYKI_TESTNET or WAYKI_MAINTNET

func GetPrivateKeyFromMnemonic

func GetPrivateKeyFromMnemonic(words string, netType int) (string, error)

助记词转私钥 netType: WAYKI_TESTNET or WAYKI_MAINTNET

func GetPubKeyFromPrivateKey

func GetPubKeyFromPrivateKey(privKey string) (string, error)

get publickey from privatekey

func SignAssetCreateTx

func SignAssetCreateTx(privateKey string, param *AssetIssueTxParam) (string, error)

SignAssetIssueTx sign returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignAssetUpdateTx

func SignAssetUpdateTx(privateKey string, param *AssetUpdateTxParam) (string, error)

SignAssetUpdateTx sign returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignCallContractTx

func SignCallContractTx(privateKey string, param *CallContractTxParam) (string, error)

SignCallContractTx sign for call contract tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignCdpLiquidateTx

func SignCdpLiquidateTx(privateKey string, param *CdpLiquidateTxParam) (string, error)

SignCdpLiquidateTx sign for liquidate a cdp tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignCdpRedeemTx

func SignCdpRedeemTx(privateKey string, param *CdpRedeemTxParam) (string, error)

SignCdpRedeemTx sign for redeem a cdp tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignCdpStakeTx

func SignCdpStakeTx(privateKey string, param *CdpStakeTxParam) (string, error)

SignCdpStakeTx sign for create a cdp tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignCommonTx

func SignCommonTx(privateKey string, param *CommonTxParam) (string, error)

SignCommonTx sign for common tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignDelegateTx

func SignDelegateTx(privateKey string, param *DelegateTxParam) (string, error)

SignDelegateTx sign for delegate tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignDexBuyLimitTx

func SignDexBuyLimitTx(privateKey string, param *DexLimitTxParam) (string, error)

SignDexBuyLimitTx sign for dex buy limit Price tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignDexCancelTx

func SignDexCancelTx(privateKey string, param *DexCancelTxParam) (string, error)

SignDexMarketBuyTx sign for cancel dex tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignDexMarketBuyTx

func SignDexMarketBuyTx(privateKey string, param *DexMarketTxParam) (string, error)

SignDexMarketBuyTx sign for dex buy market price tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignDexMarketSellTx

func SignDexMarketSellTx(privateKey string, param *DexMarketTxParam) (string, error)

SignDexMarketSellTx sign for dex sell market price tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignDexSellLimitTx

func SignDexSellLimitTx(privateKey string, param *DexLimitTxParam) (string, error)

SignDexSellLimitTx sign for dex sell limit price tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignRegisterAccountTx

func SignRegisterAccountTx(privateKey string, param *RegisterAccountTxParam) (string, error)

SignRegisterAccountTx sign for register account tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignRegisterContractTx

func SignRegisterContractTx(privateKey string, param *RegisterContractTxParam) (string, error)

SignRegisterContractTx sign for call register contract tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignUCoinCallContractTx

func SignUCoinCallContractTx(privateKey string, param *UCoinContractTxParam) (string, error)

SignUCoinCallContractTx sign for call contract tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignUCoinRegisterContractTx

func SignUCoinRegisterContractTx(privateKey string, param *UCoinRegisterContractTxParam) (string, error)

SignUCoinRegisterContractTx sign for call register contract tx returns the signature hex string and nil error, or returns empty string and the error if it has error

func SignUCoinTransferTx

func SignUCoinTransferTx(privateKey string, param *UCoinTransferTxParam) (string, error)

SignUCoinTransferTx sign for Multi-currency transfer returns the signature hex string and nil error, or returns empty string and the error if it has error

func VerifyMsgSignature

func VerifyMsgSignature(signature string, publicKey string, msg string, netType int) (isRight bool, addr string)

Types

type AssetIssueTxParam

type AssetIssueTxParam struct {
	ValidHeight int64  // valid height Within the height of the latest block
	SrcRegId    string // the reg id of the register
	Fees        int64
	FeeSymbol   string //Fee Type (WICC/WUSD)
	AssetSymbol string //From Coin Type
	AssetName   string
	AssetTotal  int64
	AssetOwner  string //owner regid
	MinTable    bool
}

type AssetModel

type AssetModel struct {
	AssetAmount int64  //stake asset amount
	AssetSymbol string //stake asset symbol
}

cdp stake Asset

type AssetModels

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

cdp stake asset list

func NewCdpAssets

func NewCdpAssets() *AssetModels

func (*AssetModels) Add

func (assetModels *AssetModels) Add(model *AssetModel)

type AssetUpdateTxParam

type AssetUpdateTxParam struct {
	ValidHeight int64  // valid height Within the height of the latest block
	SrcRegId    string // the reg id of the register
	Fees        int64
	UpdateType  int
	FeeSymbol   string //Fee Type (WICC/WUSD)
	AssetSymbol string //From Coin Type
	AssetName   string
	AssetTotal  int64
	AssetOwner  string //owner regid
}

type CallContractTxParam

type CallContractTxParam struct {
	ValidHeight int64  // valid height Within the height of the latest block
	SrcRegId    string // the reg id of the caller
	AppId       string // the reg id of the contract app
	Fees        int64  // fees for mining
	Values      int64  // the values send to the contract app
	ContractHex string // the command of contract, hex format
	PubKey      string
}

CallContractTxParam param of the call contract tx

type CdpLiquidateTxParam

type CdpLiquidateTxParam struct {
	ValidHeight     int64  // valid height Within the height of the latest block
	SrcRegId        string // the reg id of the register
	PubKey          string
	FeeSymbol       string
	Fees            int64  // fees for mining
	CdpTxid         string // target CDP to liquidate
	ScoinsLiquidate int64  // partial liquidation is allowed, must include penalty fees in
	AssetSymbol     string //stake asset symbol
}

Cdp Redeem param of the tx

type CdpRedeemTxParam

type CdpRedeemTxParam struct {
	ValidHeight   int64  // valid height Within the height of the latest block
	SrcRegId      string // the reg id of the register
	PubKey        string
	FeeSymbol     string
	Fees          int64 // fees for mining
	CdpTxid       string
	ScoinsToRepay int64 //repay coin number
	Assets        *AssetModels
}

Cdp Redeem param of the tx

type CdpStakeTxParam

type CdpStakeTxParam struct {
	ValidHeight int64  // valid height Within the height of the latest block
	SrcRegId    string // the reg id of the register
	PubKey      string
	FeeSymbol   string
	Fees        int64 // fees for mining
	CdpTxid     string
	ScoinSymbol string //get coin symbol
	ScoinMint   int64  // get coin amount
	Assets      *AssetModels
}

Cdp Stake param of the tx

type CommonTxParam

type CommonTxParam struct {
	ValidHeight int64  // valid height Within the height of the latest block
	SrcRegId    string // the source reg id that the transaction send from
	DestAddr    string // the dest address that the transaction send to
	Values      int64  // transfer values
	Fees        int64  // fees for mining
	PubKey      string
	Memo        string
}

type DelegateTxParam

type DelegateTxParam struct {
	ValidHeight int64          // valid height Within the height of the latest block
	SrcRegId    string         // the reg id of the voter
	Fees        int64          // fees for mining
	Votes       *OperVoteFunds // vote list
	PubKey      string
}

DelegateTxParam param of the delegate tx

type Dest

type Dest struct {
	CoinSymbol string //From Coin Type
	CoinAmount uint64
	DestAddr   string
}

type DestArr

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

func NewDestArr

func NewDestArr() *DestArr

func (*DestArr) Add

func (dests *DestArr) Add(dest *Dest)

type DexCancelTxParam

type DexCancelTxParam struct {
	ValidHeight int64  // valid height Within the height of the latest block
	SrcRegId    string // the reg id of the register
	PubKey      string
	FeeSymbol   string
	Fees        int64 // fees for mining
	DexTxid     string
}

type DexLimitTxParam

type DexLimitTxParam struct {
	ValidHeight int64  // valid height Within the height of the latest block
	SrcRegId    string // the reg id of the register
	PubKey      string
	FeeSymbol   string
	Fees        int64 // fees for mining
	AssetSymbol string
	CoinSymbol  string
	AssetAmount int64
	Price       int64
}

Dex Sell Limit param of the tx

type DexMarketTxParam

type DexMarketTxParam struct {
	ValidHeight int64  // valid height Within the height of the latest block
	SrcRegId    string // the reg id of the register
	PubKey      string
	FeeSymbol   string
	Fees        int64 // fees for mining
	AssetSymbol string
	CoinSymbol  string
	AssetAmount int64
}

Dex market Sell param of the tx

type Mnemonic

type Mnemonic struct {
	EntropySize int
	Password    string
}

func NewMnemonicWithDefaultOption

func NewMnemonicWithDefaultOption() *Mnemonic

func NewMnemonicWithLanguage

func NewMnemonicWithLanguage(language string) *Mnemonic

func (*Mnemonic) GenerateMnemonic

func (m *Mnemonic) GenerateMnemonic() (string, error)

New mnemonic follow the wordlists

func (*Mnemonic) GenerateSeed

func (m *Mnemonic) GenerateSeed(mnemonic string) ([]byte, error)

Generate seed from mnemonic and pass( optional )

func (*Mnemonic) ListWord

func (m *Mnemonic) ListWord() []string

Get word list

type OperVoteFund

type OperVoteFund struct {
	PubKey    []byte //< public key, binary format
	VoteValue int64  //< add fund if >= 0, minus fund if < 0
}

OperVoteFund operation of vote fund

type OperVoteFunds

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

OperVoteFunds array of OperVoteFund

func NewOperVoteFunds

func NewOperVoteFunds() *OperVoteFunds

NewOperVoteFunds create new OperVoteFunds

func (*OperVoteFunds) Add

func (votes *OperVoteFunds) Add(fund *OperVoteFund)

Add element to OperVoteFund pubKey is binary bytes voteValue add fund if >= 0, minus fund if < 0

func (*OperVoteFunds) Get

func (votes *OperVoteFunds) Get(index int) *OperVoteFund

Get element of OperVoteFund by index

func (*OperVoteFunds) Len

func (votes *OperVoteFunds) Len(index int) int

Len get the length of OperVoteFunds

type RegisterAccountTxParam

type RegisterAccountTxParam struct {
	ValidHeight int64 // valid height Within the height of the latest block
	Fees        int64 // fees for mining
}

RegisterAccountTxParam register account tx param

type RegisterContractTxParam

type RegisterContractTxParam struct {
	ValidHeight int64  // valid height Within the height of the latest block
	SrcRegId    string // the reg id of the register
	Fees        int64  // fees for mining
	Script      []byte // the contract script, binary format
	Description string // description of contract
}

RegisterContractTxParam param of the register contract tx

type SignMessageParam

type SignMessageParam struct {
	PublicKey   string
	SignMessage string
}

func SignMessage

func SignMessage(privateKey string, message string) (*SignMessageParam, error)

Sign message by private Key

type UCoinContractTxParam

type UCoinContractTxParam struct {
	ValidHeight int64  // valid height Within the height of the latest block
	SrcRegId    string // the reg id of the caller
	AppId       string // the reg id of the contract app
	Fees        int64  // fees for mining
	CoinAmount  int64  // the values send to the contract app
	ContractHex string // the command of contract, hex format
	PubKey      string
	FeeSymbol   string //Fee Type (WICC/WUSD)
	CoinSymbol  string //From Coin Type
}

UCoin Contract param of the tx

type UCoinRegisterContractTxParam

type UCoinRegisterContractTxParam struct {
	ValidHeight int64  // valid height Within the height of the latest block
	SrcRegId    string // the reg id of the register
	Fees        int64  // fees for mining
	FeeSymbol   string //WICC/WUSD
	Script      []byte // the contract script, binary format
	Description string // description of contract
}

RegisterUCoinContractTxParam param of the register contract tx

type UCoinTransferTxParam

type UCoinTransferTxParam struct {
	ValidHeight int64  // valid height Within the height of the latest block
	SrcRegId    string // the reg id of the register
	PubKey      string
	FeeSymbol   string
	Fees        int64 // fees for mining
	Dests       *DestArr
	Memo        string
}

UCoin Transfer param of the tx

Directories

Path Synopsis
Package bip32 provides ...
Package bip32 provides ...
base58
Package base58 provides ...
Package base58 provides ...
bytes
Package bytes provides ...
Package bytes provides ...
ec
Package address provides ...
Package address provides ...
hash
Package utils provides ...
Package utils provides ...
wif
Package wif provides ...
Package wif provides ...

Jump to

Keyboard shortcuts

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