Documentation ¶
Index ¶
- Constants
- Variables
- func A(o []int64, a []int64, b []int64)
- func AesDecrypt(key []byte, data []byte) (origData []byte, err error)
- func AesEncrypt(key []byte, data []byte) ([]byte, error)
- func Base58Decode(b string) []byte
- func Base58Encode(b []byte) string
- func BuildSeedHash(seed string, nonce int) []byte
- func ContractId2TokenId(contractId string, tokenIndex int) string
- func DecodeContractTexture(data string) string
- func GenerateSeed() string
- func HashChain(nonceSecret []byte) []byte
- func InitApi(nodeAddress string, network NetType)
- func IsValidateAddress(address string, network NetType) bool
- func IsValidatePhrase(phrase string) bool
- func Keccak256(data ...[]byte) []byte
- func M(o []int64, a []int64, b []int64)
- func Post(url string, data interface{}) (body []byte, err error)
- func PostWithTimeOut(url string, data interface{}, duration time.Duration) (body []byte, err error)
- func PublicKeyToAddress(publicKey string, network NetType) string
- func S(o []int64, a []int64)
- func SharedKey(secretKey []uint8, publicKey []uint8) []uint8
- func Sign(secretKey []uint8, msg []uint8, opt_random []uint8) []uint8
- func SignMessage(secretKey []uint8, msg []uint8, opt_random []uint8) []uint8
- func TokenId2ContractId(tokenId string) string
- func UrlGetContent(url string) (body []byte, err error)
- func Verify(publicKey []uint8, msg []uint8, signature []uint8) int
- func Z(o []int64, a []int64, b []int64)
- type Account
- func (acc *Account) AccountSeed() string
- func (acc *Account) Address() string
- func (acc *Account) BuildCancelLeasing(txId string) *Transaction
- func (acc *Account) BuildExecuteContract(contractId string, funcIdx int16, funcData []byte, attachment string) *Transaction
- func (acc *Account) BuildFromPrivateKey(privateKey string)
- func (acc *Account) BuildFromSeed(seed string, nonce int)
- func (acc *Account) BuildLeasing(recipient string, amount int64) *Transaction
- func (acc *Account) BuildPayment(recipient string, amount int64, attachment string) *Transaction
- func (acc *Account) BuildRegisterContract(contract string, max int64, unity int64, tokenDescription string, ...) *Transaction
- func (acc *Account) BuildSendTokenTransaction(tokenId string, recipient string, amount int64, isSplitSupported bool, ...) *Transaction
- func (acc *Account) GetInfo() (AccountInfo, error)
- func (acc *Account) GetTokenBalance(tokenId string) (TokenBalance, error)
- func (acc *Account) GetTransferHistory(limit int64, offset int64, txType int64) (TxHistoryList, error)
- func (acc *Account) PrivateKey() string
- func (acc *Account) PublicKey() string
- func (acc *Account) SignData(data []byte) string
- func (acc *Account) VerifySignature(data, signature []byte) bool
- type AccountInfo
- type CommonResp
- type Contract
- func (c *Contract) BuildDestroyData() []byte
- func (c *Contract) BuildIssueData() []byte
- func (c *Contract) BuildRegisterData() []byte
- func (c *Contract) BuildSendData() []byte
- func (c *Contract) BuildSplitData() []byte
- func (c *Contract) DecodeDestroy(data []byte)
- func (c *Contract) DecodeIssue(data []byte)
- func (c *Contract) DecodeRegister(data []byte)
- func (c *Contract) DecodeSend(data []byte)
- func (c *Contract) DecodeSplit(data []byte)
- func (c *Contract) DecodeSupersede(data []byte)
- func (c *Contract) DecodeTexture()
- type DataEncoder
- type DataEntry
- type Func
- type NetType
- type Proof
- type Textual
- type TokenBalance
- type TokenInfo
- type Transaction
- func NewCancelLeaseTransaction(txId string) *Transaction
- func NewExecuteTransaction(contractId string, funcIdx int16, funcData string, attachment string) *Transaction
- func NewLeaseTransaction(recipient string, amount int64) *Transaction
- func NewPaymentTransaction(recipient string, amount int64, attachment string) *Transaction
- func NewRegisterTransaction(contract string, data string, contractDescription string) *Transaction
- type TransactionResponse
- func SendCancelLeasingTx(tx *Transaction) (resp TransactionResponse, err error)
- func SendExecuteContractTx(tx *Transaction) (resp TransactionResponse, err error)
- func SendLeasingTx(tx *Transaction) (resp TransactionResponse, err error)
- func SendPaymentTx(tx *Transaction) (resp TransactionResponse, err error)
- func SendRegisterContractTx(tx *Transaction) (resp TransactionResponse, err error)
- type TxHistoryList
- type VsysApi
Constants ¶
const ( ApiNodeVersion = "/node/version" ApiBroadcastPayment = "/vsys/broadcast/payment" ApiBlockHeight = "/blocks/height" ApiGetBlockAt = "/blocks/at/%d" ApiGetBlockBySig = "/blocks/signature/%s" ApiBlocks = "/blocks/seq/%d/%d" // leasing ApiBroadcastLease = "/leasing/broadcast/lease" ApiBroadcastCancelLease = "/leasing/broadcast/cancel" // transactions ApiUnConfirmedTransaction = "/transactions/unconfirmed" ApiGetTransactionInfo = "/transactions/info/%s" ApiGetTransactionByAddress = "/transactions/address/%s/limit/%d" ApiGetTransactionList = "/transactions/list" // peers ApiGetPeersConnected = "/peers/connected" // consensus ApiGetAllSlotsInfo = "/consensus/allSlotsInfo" ApiGetConsensusAlgo = "/consensus/algo" // address ApiGetAddressDetail = "/addresses/balance/details/%s" ApiGetAddressValid = "/addresses/validate/%s" ApiGetAddressBalance = "/addresses/balance/%s" //contract ApiContractBroadcastRegister = "/contract/broadcast/register" ApiContractBroadcastExecute = "/contract/broadcast/execute" ApiContractInfo = "/contract/info/%s" ApiTokenInfo = "/contract/tokenInfo/%s" ApiContractTokenBalance = "/contract/balance/%s/%s" // /contract/balance/{address}/{tokenId} )
const ( Protocol = "v.systems" Api = 3 // Fee VsysPrecision int64 = 1e8 ContractExecFee int64 = 3e7 DefaultTxFee int64 = 1e7 DefaultFeeScale int16 = 100 // Network Testnet NetType = 'T' Mainnet NetType = 'M' // TX_TYPE TxTypePayment = 2 TxTypeLease = 3 TxTypeCancelLease = 4 TxTypeMinting = 5 TxTypeContractRegister = 8 TxTypeContractExecute = 9 //contract funcIdx variable ActionInit = "init" ActionSupersede = "supersede" ActionIssue = "issue" ActionDestroy = "destroy" ActionSplit = "split" ActionSend = "send" ActionTransfer = "transfer" ActionDeposit = "deposit" ActionWithdraw = "withdraw" // function index FuncidxSupersede = 0 FuncidxIssue = 1 FuncidxDestroy = 2 FuncidxSplit = 3 FuncidxSend = 3 FuncidxSendSplit = 4 FuncidxWithdraw = 6 FuncidxWithdrawSplit = 7 FuncidxDeposit = 5 FuncidxDepositSplit = 6 TokenContract = "" /* 1186-byte string literal not displayed */ TokenContractWithSplit = "" /* 1272-byte string literal not displayed */ ContractDescriptor = "" /* 570-byte string literal not displayed */ ContractWithSplitDescriptor = "" /* 615-byte string literal not displayed */ )
const ( DeTypePublicKey = 0x01 DeTypeAddress = 0x02 DeTypeAmount = 0x03 DeTypeInt32 = 0x04 DeTypeShortText = 0x05 DeTypeContractAccount = 0x06 DETypeAccount = 0x07 )
Variables ¶
var D = gf([]int64{0x78a3, 0x1359, 0x4dca, 0x75eb,
0xd8ab, 0x4141, 0x0a4d, 0x0070,
0xe898, 0x7779, 0x4079, 0x8cc7,
0xfe73, 0x2b6f, 0x6cee, 0x5203})
var D2 = gf([]int64{0xf159, 0x26b2, 0x9b94, 0xebd6,
0xb156, 0x8283, 0x149a, 0x00e0,
0xd130, 0xeef3, 0x80f2, 0x198e,
0xfce7, 0x56df, 0xd9dc, 0x2406})
var I = gf([]int64{0xa0b0, 0x4a0e, 0x1b27, 0xc4ee,
0xe478, 0xad2f, 0x1806, 0x2f43,
0xd7a7, 0x3dfb, 0x0099, 0x2b4d,
0xdf0b, 0x4fc1, 0x2480, 0x2b83})
var K = []int64{}/* 160 elements not displayed */
Constantes de cada ronda del SHA-512
var L = []int64{0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58,
0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10}
var X = gf([]int64{0xd51a, 0x8f25, 0x2d60, 0xc956,
0xa7b2, 0x9525, 0xc760, 0x692c,
0xdc5c, 0xfdd6, 0xe231, 0xc0a4,
0x53fe, 0xcd6e, 0x36d3, 0x2169})
var Y = gf([]int64{0x6658, 0x6666, 0x6666, 0x6666,
0x6666, 0x6666, 0x6666, 0x6666,
0x6666, 0x6666, 0x6666, 0x6666,
0x6666, 0x6666, 0x6666, 0x6666})
Functions ¶
func AesDecrypt ¶
AesDecrypt aes cbc PKCS5Padding
func AesEncrypt ¶
AesEncrypt is aes encrypt function key can be any length data can be any length iv is random,multi encrypt will get different result PKCS5Padding , CBC pattern
func Base58Decode ¶
Decode decodes a modified base58 string to a byte slice.
func Base58Encode ¶
Encode encodes a byte slice to a modified base58 string.
func BuildSeedHash ¶
func ContractId2TokenId ¶
func DecodeContractTexture ¶
func IsValidateAddress ¶
IsValidateAddress checks if address valid
func IsValidatePhrase ¶
IsValidatePhrase checks if phrase valid
func PostWithTimeOut ¶
func PublicKeyToAddress ¶
PublicKeyToAddress return address with base58 encoded
func TokenId2ContractId ¶
func UrlGetContent ¶
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
func GenerateKeyPair ¶
GenerateKeyPair generate Account using seed byte array
func InitAccount ¶
InitAccount return account with network initiated
func (*Account) AccountSeed ¶
func (*Account) BuildCancelLeasing ¶
func (acc *Account) BuildCancelLeasing(txId string) *Transaction
BuildCancelLeasing build Cancel transaction
func (*Account) BuildExecuteContract ¶
func (acc *Account) BuildExecuteContract(contractId string, funcIdx int16, funcData []byte, attachment string) *Transaction
BuildExecuteContract build ExecuteContract transaction
func (*Account) BuildFromPrivateKey ¶
BuildFromPrivateKey build account using privateKey
func (*Account) BuildFromSeed ¶
BuildFromPrivateKey build account using seed and nonce
func (*Account) BuildLeasing ¶
func (acc *Account) BuildLeasing(recipient string, amount int64) *Transaction
BuildLeasing build leasing transaction recipient should be address amount is in minimum unit
func (*Account) BuildPayment ¶
func (acc *Account) BuildPayment(recipient string, amount int64, attachment string) *Transaction
BuildPayment build payment transaction recipient should be address amount is in minimum unit attachment can be empty
func (*Account) BuildRegisterContract ¶
func (acc *Account) BuildRegisterContract(contract string, max int64, unity int64, tokenDescription string, contractDescription string) *Transaction
BuildRegisterContract build RegisterContract transaction
func (*Account) BuildSendTokenTransaction ¶
func (acc *Account) BuildSendTokenTransaction(tokenId string, recipient string, amount int64, isSplitSupported bool, attachment string) *Transaction
BuildExecuteContract build SendToken transaction
func (*Account) GetInfo ¶
func (acc *Account) GetInfo() (AccountInfo, error)
Get account V Coin balance
func (*Account) GetTokenBalance ¶
func (acc *Account) GetTokenBalance(tokenId string) (TokenBalance, error)
func (*Account) GetTransferHistory ¶
func (*Account) VerifySignature ¶
VerifySignature check if signature is correct
type AccountInfo ¶
type CommonResp ¶
type Contract ¶
type Contract struct { ContractId string Contract string Max int64 Unity int64 TokenDescription string ContractDescription string Amount int64 TokenIdx int32 // const 0 Recipient string SenderPublicKey string NewUnity int64 // split newUnity NewIssuer string // supersede newIssuer Textual Textual // [init func, user defined func, stateVar] Functions []Func }
func (*Contract) BuildDestroyData ¶
func (*Contract) BuildIssueData ¶
func (*Contract) BuildRegisterData ¶
func (*Contract) BuildSendData ¶
func (*Contract) BuildSplitData ¶
func (*Contract) DecodeDestroy ¶
func (*Contract) DecodeIssue ¶
func (*Contract) DecodeRegister ¶
func (*Contract) DecodeSend ¶
func (*Contract) DecodeSplit ¶
func (*Contract) DecodeSupersede ¶
func (*Contract) DecodeTexture ¶
func (c *Contract) DecodeTexture()
type DataEncoder ¶
type DataEncoder struct {
// contains filtered or unexported fields
}
func (*DataEncoder) Decode ¶
func (de *DataEncoder) Decode(data []byte) (list []DataEntry)
func (*DataEncoder) Encode ¶
func (de *DataEncoder) Encode(data interface{}, dataEntryType byte)
func (*DataEncoder) EncodeArgAmount ¶
func (de *DataEncoder) EncodeArgAmount(amount int16)
func (*DataEncoder) Result ¶
func (de *DataEncoder) Result() []byte
type TokenBalance ¶
type TokenInfo ¶
type Transaction ¶
type Transaction struct { TxId string `json:"txId,omitempty"` Timestamp int64 `json:"timestamp"` Fee int64 `json:"fee"` FeeScale int16 `json:"feeScale"` Amount int64 `json:"amount,omitempty"` SenderPublicKey string `json:"senderPublicKey"` Attachment string `json:"attachment,omitempty"` Recipient string `json:"recipient,omitempty"` Signature string `json:"signature"` // contract Contract string `json:"contract,omitempty"` InitData string `json:"initData,omitempty"` ContractId string `json:"contractId,omitempty"` TokenIdx int32 `json:"tokenIdx,omitempty"` Description string `json:"description,omitempty"` FunctionIndex int16 `json:"functionIndex,omitempty"` FunctionData string `json:"functionData,omitempty"` // contains filtered or unexported fields }
func NewCancelLeaseTransaction ¶
func NewCancelLeaseTransaction(txId string) *Transaction
func NewExecuteTransaction ¶
func NewExecuteTransaction(contractId string, funcIdx int16, funcData string, attachment string) *Transaction
func NewLeaseTransaction ¶
func NewLeaseTransaction(recipient string, amount int64) *Transaction
func NewPaymentTransaction ¶
func NewPaymentTransaction(recipient string, amount int64, attachment string) *Transaction
func NewRegisterTransaction ¶
func NewRegisterTransaction(contract string, data string, contractDescription string) *Transaction
func (*Transaction) BuildTxData ¶
func (tx *Transaction) BuildTxData() []byte
BuildTxData generate data which is used to be signed
func (*Transaction) TxType ¶
func (tx *Transaction) TxType() int
type TransactionResponse ¶
type TransactionResponse struct { Type uint8 `json:"type"` Id string `json:"id"` Fee int64 `json:"fee"` Timestamp int64 `json:"timestamp"` Proofs []Proof `json:"proofs"` Recipient string `json:"recipient"` FeeScale int16 `json:"feeScale"` Amount int64 `json:"amount"` Attachment string `json:"attachment"` CommonResp }
func SendCancelLeasingTx ¶
func SendCancelLeasingTx(tx *Transaction) (resp TransactionResponse, err error)
func SendExecuteContractTx ¶
func SendExecuteContractTx(tx *Transaction) (resp TransactionResponse, err error)
func SendLeasingTx ¶
func SendLeasingTx(tx *Transaction) (resp TransactionResponse, err error)
func SendPaymentTx ¶
func SendPaymentTx(tx *Transaction) (resp TransactionResponse, err error)
func SendRegisterContractTx ¶
func SendRegisterContractTx(tx *Transaction) (resp TransactionResponse, err error)
type TxHistoryList ¶
type TxHistoryList struct { Error int `json:"error"` Message string `json:"message"` TotalCount int64 `json:"totalCount"` Size int `json:"size"` Transactions []struct { Type int64 Id string Fee int64 FeeScale int64 `json:"feeScale"` Timestamp int64 `json:"timestamp"` Proofs []struct { ProofType string `json:"proofType"` PublicKey string `json:"publicKey"` Address string `json:"address"` Signature string `json:"signature"` } Recipient string `json:"recipient"` Amount int64 `json:"amount"` Attachment string `json:"attachment"` Status string `json:"status"` FeeCharged int64 `json:"feeCharged"` Height int64 `json:"height"` } `json:"transactions"` }
func GetTransactionList ¶
func GetTransactionList(address string, limit int64, offset int64, txType int64) (TxHistoryList, error)
txType eg: TxTypePayment | TxTypeLeasing txType <= 0 will return all kind of transactions