Documentation ¶
Overview ¶
Package nuls is Go bindings to the cryptocurrency nuls API
- Copyright (c) 2019. Dabank Authors
- All rights reserved.
Index ¶
- Constants
- func AmountToFloat64(xmr int64) float64
- func AmountToInt64(xmr float64) int64
- type AccountInfo
- type AccountList
- type Balance
- type BlockHeight
- type BlockInfo
- type Client
- func (c *Client) AddressBalance(address string) (info Balance, err error)
- func (c *Client) Block(startHeight, size int) (info BlockInfo, err error)
- func (c *Client) BlockHeight() (info BlockHeight, err error)
- func (c *Client) ContractTransfer(address, toAddress, password string, gasLimit, price int, amount int64) (info Transfer, err error)
- func (c *Client) CreateAccount(count int, password string) (info AccountList, err error)
- func (c *Client) GetAccount(account string) (info AccountInfo, err error)
- func (c *Client) GetTransaction(txId string) (info Transaction, err error)
- func (c *Client) MultipleAddressTransfer(inputs []Input, outPuts []OutPut) (info Transfer, err error)
- func (c *Client) Transfer(address, toAddress, password string, amount int64) (info Transfer, err error)
- func (c *Client) ValidateAddress(address string) (info ValidateAddress, err error)
- func (c *Client) ValidateContractAddress(address string) (info ValidateContract, err error)
- func (c *Client) WalletBalance() (info Balance, err error)
- type ErrorResponse
- type Input
- type M
- type OutPut
- type Transaction
- type Transfer
- type ValidateAddress
- type ValidateContract
Constants ¶
const ( // coinbase 交易 TxTypeCoinbase = iota + 1 // 转账交易 TxTypeTransfer // 设置别名 TxTypeAlias // 创建共识节点交易 TxTypeRegisterAgent // 委托交易(加入共识) TxTypeJoinConsensus // 取消委托交易(退出共识) TxTypeCancelDeposit // 黄牌惩罚 TxTypeYellowPunish // 红牌惩罚 TxTypeRedPunish // 停止节点(删除共识节点) TxTypeStopAgent // 跨链转账交易 TxTypeCrossChainTransfer // 注册链交易 TxTypeRegisterChainAndAsset // 销毁链 TxTypeDestroyChainAndAsset // 为链新增一种资产 TxTypeAddAssetToChain // 删除链上资产 TxTypeRemoveAssetFromChain )
const ( // 创建智能合约交易 TxTypeCreateContract = iota + 100 // 调用智能合约交易 TxTypeCallContract // 删除智能合约交易 TxTypeDeleteContract )
Variables ¶
This section is empty.
Functions ¶
func AmountToFloat64 ¶
AmountToFloat64 converts raw atomic NULS to a float64
func AmountToInt64 ¶
AmountToInt64 converts a raw atomic NULS balance to a more human readable format.
Types ¶
type AccountInfo ¶
type AccountInfo struct { Success bool `json:"success"` Data struct { PageNumber int `json:"pageNumber"` PageSize int `json:"pageSize"` Total int `json:"total"` Pages int `json:"pages"` List []struct { Address string `json:"address"` Alias string `json:"alias"` PubKey string `json:"pubKey"` // Extend interface{} `json:"extend"` CreateTime int64 `json:"createTime"` Encrypted bool `json:"encrypted"` Remark string `json:"remark"` Ok bool `json:"ok"` } `json:"list"` } `json:"data"` }
type AccountList ¶
type BlockHeight ¶
type BlockInfo ¶
type BlockInfo struct { Success bool `json:"success"` Data struct { List []struct { Hash string `json:"hash"` PreHash string `json:"preHash"` MerkleHash string `json:"merkleHash"` StateRoot string `json:"stateRoot"` Time int64 `json:"time"` Height int `json:"height"` TxCount int `json:"txCount"` PackingAddress string `json:"packingAddress"` Extend string `json:"extend"` RoundIndex int `json:"roundIndex"` ConsensusMemberCount int `json:"consensusMemberCount"` RoundStartTime int64 `json:"roundStartTime"` PackingIndexOfRound int `json:"packingIndexOfRound"` Reward int `json:"reward"` Fee int `json:"fee"` ConfirmCount int `json:"confirmCount"` Size int `json:"size"` TxList []transaction `json:"txList"` ScriptSig string `json:"scriptSig"` } `json:"list"` } `json:"data"` }
type Client ¶
type Client struct { // Verbose when true, talks a lot Verbose bool // BeforeRequest fires before every request, // can be used in rate limit. // request is aborted if there is an error BeforeRequest func(requestType string, option string, outcome interface{}) error // contains filtered or unexported fields }
Client nuls API client Clients are safe for concurrent use by multiple goroutines.
func (*Client) AddressBalance ¶
/api/accountledger/balance/{address} 账户地址查询账户余额
func (*Client) BlockHeight ¶
func (c *Client) BlockHeight() (info BlockHeight, err error)
"/api/block/newest/height" 查询最新区块高度
func (*Client) ContractTransfer ¶
func (c *Client) ContractTransfer(address, toAddress, password string, gasLimit, price int, amount int64) (info Transfer, err error)
/api/contract/transfer 向智能合约地址转账
func (*Client) CreateAccount ¶
func (c *Client) CreateAccount(count int, password string) (info AccountList, err error)
创建账户
func (*Client) GetAccount ¶
func (c *Client) GetAccount(account string) (info AccountInfo, err error)
GetAccount Get account information given an account ID.
func (*Client) GetTransaction ¶
func (c *Client) GetTransaction(txId string) (info Transaction, err error)
/api/tx/hash/{hash} 根据hash查询交易
func (*Client) MultipleAddressTransfer ¶
func (c *Client) MultipleAddressTransfer(inputs []Input, outPuts []OutPut) (info Transfer, err error)
/api/accountledger/multipleAddressTransfer 多地址转账
func (*Client) Transfer ¶
func (c *Client) Transfer(address, toAddress, password string, amount int64) (info Transfer, err error)
/api/accountledger/transfer 转账
func (*Client) ValidateAddress ¶
func (c *Client) ValidateAddress(address string) (info ValidateAddress, err error)
api/account/validate/{address} [验证地址格式是否正确]
func (*Client) ValidateContractAddress ¶
func (c *Client) ValidateContractAddress(address string) (info ValidateContract, err error)
/api/contract/{address} 验证是否为合约地址
func (*Client) WalletBalance ¶
[余额] 查询本地所有账户总余额
type ErrorResponse ¶
type ErrorResponse struct { Success bool `json:"success"` Data struct { Code string `json:"code"` Msg string `json:"msg"` } `json:"data"` }
Response shows up when there is something wrong.
type Transaction ¶
type Transaction struct { Success bool `json:"success"` Data transaction `json:"data"` }