Documentation ¶
Overview ¶
Package jingtumlib Request类主管GET请求,包括获得服务器、账号、挂单、路径等信息。请求时不需要提供密 钥,且对所有用户公开。所有的请求是异步的,会提供一个回调函数。每个回调函数有两个参数,一个是错误,另一个是结果。 @FileName: request.go @Auther : 13851485286 @Email : yangxuebo@yeah.net @CreateTime: 2018-05-28 10:44:32 @UpdateTime: 2018-05-28 10:44:54
Package jingtumlib 底层区块链网络通信服务类,不对外部提供方法。 @FileName: server.go @Auther : 杨雪波 @Email : yangxuebo@yeah.net @CreateTime: 2018-07-31 14:44:32 @UpdateTime: 2018-07-31 14:44:54
Package jingtumlib Transaction类主管POST请求,包括组装交易和交易参数。请求时需要提供密钥,且交易可以 进行本地签名和服务器签名。目前支持服务器签名,本地签名支持主要的交易,还有部分参数 不支持。所有的请求是异步的,会提供一个回调函数。每个回调函数有两个参数,一个是错误,另一个是结果。 @FileName: transaction.go @Auther : 杨雪波 @Email : yangxuebo@yeah.net @CreateTime: 2018-05-28 10:44:32 @UpdateTime: 2018-05-28 10:44:54
Package jingtumlib 钱包类,用于创建和导入钱包等功能。 @FileName: wallet.go @Auther : 杨雪波 @Email : yangxuebo@yeah.net @CreateTime: 2018-07-26 10:44:32 @UpdateTime: 2018-07-26 10:44:54
Index ¶
- Variables
- func Exits()
- func Init() error
- func InitConfig() error
- func IsValidAddress(address string) bool
- func IsValidSecret(secret string) bool
- type AccountSet
- type Amount
- type ArgInfo
- type Config
- type Filter
- type FlagClass
- type ParameterInfo
- type Remote
- func (remote *Remote) BuildAccountSet(options map[string]interface{}, tx *Transaction) error
- func (remote *Remote) BuildAccountSetTx(options map[string]interface{}) (*Transaction, error)
- func (remote *Remote) BuildDelegateKeySet(options map[string]interface{}, tx *Transaction) error
- func (remote *Remote) BuildOfferCancelTx(options map[string]interface{}) (*Transaction, error)
- func (remote *Remote) BuildOfferCreateTx(options map[string]interface{}) (*Transaction, error)
- func (remote *Remote) BuildPaymentTx(account string, to string, amount Amount) (*Transaction, error)
- func (remote *Remote) BuildRelationSet(options map[string]interface{}, tx *Transaction) error
- func (remote *Remote) BuildRelationTx(options map[string]interface{}) (*Transaction, error)
- func (remote *Remote) BuildSignerSet(options map[string]interface{}, tx *Transaction) error
- func (remote *Remote) BuildTrustSet(options map[string]interface{}, tx *Transaction) error
- func (remote *Remote) CallContractTx(options map[string]interface{}) (*Transaction, error)
- func (remote *Remote) Connect(callback func(err error, result interface{})) error
- func (remote *Remote) DeployContractTx(options map[string]interface{}) (*Transaction, error)
- func (remote *Remote) Disconnect()
- func (remote *Remote) GetNowTime() string
- func (remote *Remote) On(eventName string, callback func(data interface{}))
- func (remote *Remote) RequestAccountInfo(options map[string]interface{}) (*Request, error)
- func (remote *Remote) RequestAccountOffers(options map[string]interface{}) (*Request, error)
- func (remote *Remote) RequestAccountRelations(options map[string]interface{}) (*Request, error)
- func (remote *Remote) RequestAccountTums(options map[string]interface{}) (*Request, error)
- func (remote *Remote) RequestAccountTx(options map[string]interface{}) (*Request, error)
- func (remote *Remote) RequestLedger(options map[string]interface{}) (*Request, error)
- func (remote *Remote) RequestLedgerClosed() (*Request, error)
- func (remote *Remote) RequestOrderBook(options map[string]interface{}) (*Request, error)
- func (remote *Remote) RequestServerInfo() (*Request, error)
- func (remote *Remote) RequestTx(hash string) (*Request, error)
- func (remote *Remote) Submit(command string, data map[string]interface{}, filter Filter, ...)
- func (remote *Remote) Subscribe(streams []string) *Request
- func (remote *Remote) UnSubscribe(streams []string) *Request
- type Remoter
- type ReqCtx
- type Request
- type ResData
- type Server
- type Transaction
- func (tx *Transaction) AddMemo(memo string)
- func (tx *Transaction) AddTxJSON(key string, value interface{}) bool
- func (tx *Transaction) GetAccount() string
- func (tx *Transaction) GetTransactionType() string
- func (tx *Transaction) GetTxJSON(key string) interface{}
- func (tx *Transaction) SetFlags(flags interface{})
- func (tx *Transaction) SetPath(key string)
- func (tx *Transaction) SetSecret(secret string)
- func (tx *Transaction) SetSendMax(amount constant.Amount)
- func (tx *Transaction) SetTransferRate(rate float32)
- func (tx *Transaction) Submit(callback func(err error, result interface{}))
- type Wallet
Constants ¶
This section is empty.
Variables ¶
var ( //JTConfig JTConfig JTConfig = new(Config) //Seq Seq Seq = 1 )
var ( //TransactionFlags 交易标识 TransactionFlags = map[string]FlagClass{"Universal": {"FullyCanonicalSig": 0x00010000}, "AccountSet": {"RequireDestTag": 0x00010000, "OptionalDestTag": 0x00020000, "RequireAuth": 0x00040000, "OptionalAuth": 0x00080000, "DisallowSWT": 0x00100000, "AllowSWT": 0x00200000}, "TrustSet": {"SetAuth": 0x00010000, "NoSkywell": 0x00020000, "SetNoSkywell": 0x00020000, "ClearNoSkywell": 0x00040000, "SetFreeze": 0x00100000, "ClearFreeze": 0x00200000}, "OfferCreate": {"Passive": 0x00010000, "ImmediateOrCancel": 0x00020000, "FillOrKill": 0x00040000, "Sell": 0x00080000}, "Payment": {"NoSkywellDirect": 0x00010000, "PartialPayment": 0x00020000, "LimitQuality": 0x00040000}, "RelationSet": {"Authorize": 0x00000001, "Freeze": 0x00000011}, "RelationDel": {}} //SetClearFlags 清除标识 SetClearFlags = map[uint32]AccountSet{uint32(1): {"asfRequireDest": uint32(1), "asfRequireAuth": uint32(2), "asfDisallowSWT": uint32(3), "asfDisableMaster": uint32(4), "asfNoFreeze": uint32(5), "asfGlobalFreeze": uint32(6)}} )
var AccountSetTypes = map[string]int{"property": 1, "delegate": 2, "signer": 3}
AccountSetTypes account type 映射
var (
//MaxReciveLen 接收最长报文
MaxReciveLen = 4096000
)
var OfferTypes = map[string]int{"Sell": 1, "Buy": 2}
OfferTypes offer type 映射
var RelationTypes = map[string]int{"trust": 1, "authorize": 2, "freeze": 3, "unfreeze": 4}
RelationTypes relation type 映射
Functions ¶
Types ¶
type Remote ¶
Remote 是跟井通底层交互最主要的类,它可以组装交易发送到底层、订阅事件及从底层拉取数据。
func (*Remote) BuildAccountSet ¶
func (remote *Remote) BuildAccountSet(options map[string]interface{}, tx *Transaction) error
BuildAccountSet BuildAccountSet
func (*Remote) BuildAccountSetTx ¶
func (remote *Remote) BuildAccountSetTx(options map[string]interface{}) (*Transaction, error)
BuildAccountSetTx 创建属性对象
func (*Remote) BuildDelegateKeySet ¶
func (remote *Remote) BuildDelegateKeySet(options map[string]interface{}, tx *Transaction) error
BuildDelegateKeySet BuildDelegateKeySet
func (*Remote) BuildOfferCancelTx ¶
func (remote *Remote) BuildOfferCancelTx(options map[string]interface{}) (*Transaction, error)
BuildOfferCancelTx 取消挂单
func (*Remote) BuildOfferCreateTx ¶
func (remote *Remote) BuildOfferCreateTx(options map[string]interface{}) (*Transaction, error)
BuildOfferCreateTx 挂单
func (*Remote) BuildPaymentTx ¶
func (remote *Remote) BuildPaymentTx(account string, to string, amount Amount) (*Transaction, error)
BuildPaymentTx 创建支付对象
func (*Remote) BuildRelationSet ¶
func (remote *Remote) BuildRelationSet(options map[string]interface{}, tx *Transaction) error
BuildRelationSet BuildRelationSet
func (*Remote) BuildRelationTx ¶
func (remote *Remote) BuildRelationTx(options map[string]interface{}) (*Transaction, error)
BuildRelationTx 创建关系对象
func (*Remote) BuildSignerSet ¶
func (remote *Remote) BuildSignerSet(options map[string]interface{}, tx *Transaction) error
BuildSignerSet BuildSignerSet
func (*Remote) BuildTrustSet ¶
func (remote *Remote) BuildTrustSet(options map[string]interface{}, tx *Transaction) error
BuildTrustSet BuildTrustSet
func (*Remote) CallContractTx ¶
func (remote *Remote) CallContractTx(options map[string]interface{}) (*Transaction, error)
CallContractTx 执行合约
func (*Remote) DeployContractTx ¶
func (remote *Remote) DeployContractTx(options map[string]interface{}) (*Transaction, error)
DeployContractTx 部署合约
func (*Remote) GetNowTime ¶
GetNowTime 获取当前时间。格式(2006-01-02 15:04:05)
func (*Remote) RequestAccountInfo ¶
RequestAccountInfo 请求账号信息
func (*Remote) RequestAccountOffers ¶
RequestAccountOffers 获得账号挂单
func (*Remote) RequestAccountRelations ¶
RequestAccountRelations 获得账号关系
func (*Remote) RequestAccountTums ¶
RequestAccountTums 获得账号可接收和发送的货币
func (*Remote) RequestAccountTx ¶
RequestAccountTx 获得账号交易列表
func (*Remote) RequestLedger ¶
RequestLedger 获取某一账本具体信息.
func (*Remote) RequestLedgerClosed ¶
RequestLedgerClosed 获取最新账本信息
func (*Remote) RequestOrderBook ¶
RequestOrderBook 获得市场挂单列表
func (*Remote) RequestServerInfo ¶
RequestServerInfo 请求底层服务器信息
func (*Remote) Submit ¶
func (remote *Remote) Submit(command string, data map[string]interface{}, filter Filter, callback func(err error, data interface{}))
Submit 提交请求
func (*Remote) UnSubscribe ¶
UnSubscribe 退订服务
type Remoter ¶
type Remoter interface { //Connect 连接 Connect(callback func(err error, result interface{})) error //GetNowTime 获取当前时间 GetNowTime() string //断开连接 Disconnect() //RequestServerInfo 请求底层服务器信息 RequestServerInfo() (*Request, error) //RequestLedgerClosed 获取最新账本信息 RequestLedgerClosed() (*Request, error) //获取某一账本具体信息 RequestLedger(options map[string]interface{}) (*Request, error) //RequestTx 询某一交易具体信息 RequestTx(hash string) (*Request, error) //请求账号信息 RequestAccountInfo(options map[string]interface{}) (*Request, error) //RequestAccountTums 得账号可接收和发送的货币 RequestAccountTums(options map[string]interface{}) (*Request, error) //RequestAccountRelations 得账号关系 RequestAccountRelations(options map[string]interface{}) (*Request, error) //RequestAccountOffers 获得账号挂单 RequestAccountOffers(options map[string]interface{}) (*Request, error) //RequestAccountTx 获得账号交易列表 RequestAccountTx(options map[string]interface{}) (*Request, error) //RequestOrderBook 获得市场挂单列表 RequestOrderBook(options map[string]interface{}) (*Request, error) //BuildPaymentTx 创建支付对象 BuildPaymentTx(account string, to string, amount constant.Amount) (*Transaction, error) //BuildRelationSet BuildRelationSet(options map[string]interface{}, tx *Transaction) error //BuildTrustSet BuildTrustSet(options map[string]interface{}, tx *Transaction) error //建关系对象 BuildRelationTx(options map[string]interface{}) (*Transaction, error) //BuildAccountSet BuildAccountSet(options map[string]interface{}, tx *Transaction) error //BuildDelegateKeySet BuildDelegateKeySet(options map[string]interface{}, tx *Transaction) error //BuildSignerSet BuildSignerSet(options map[string]interface{}, tx *Transaction) error //创建属性对象 BuildAccountSetTx(options map[string]interface{}) (*Transaction, error) //挂单 BuildOfferCreateTx(options map[string]interface{}) (*Transaction, error) //取消挂单 BuildOfferCancelTx(options map[string]interface{}) (*Transaction, error) //DeployContractTx 部署合约 DeployContractTx(options map[string]interface{}) (*Transaction, error) //CallContractTx 执行合约 CallContractTx(options map[string]interface{}) (*Transaction, error) }
Remoter 提供以下方法:
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request 请求结构
func NewRequest ¶
NewRequest 创建请求对象
func (*Request) SelectLedger ¶
func (req *Request) SelectLedger(ledger interface{})
SelectLedger 选择账本
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server 区块链网络通信服务结构体。
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction 交易结构体
func NewTransaction ¶
func NewTransaction(remote *Remote, filter Filter) (*Transaction, error)
NewTransaction 构造Transaction对象
func (*Transaction) AddTxJSON ¶
func (tx *Transaction) AddTxJSON(key string, value interface{}) bool
AddTxJSON 添加交易参数
func (*Transaction) GetTransactionType ¶
func (tx *Transaction) GetTransactionType() string
GetTransactionType 获得交易类型
func (*Transaction) GetTxJSON ¶
func (tx *Transaction) GetTxJSON(key string) interface{}
GetTxJSON 获取交易参数
func (*Transaction) SetFlags ¶
func (tx *Transaction) SetFlags(flags interface{})
SetFlags flags 数据类型:uint32或[]string
func (*Transaction) SetSecret ¶
func (tx *Transaction) SetSecret(secret string)
SetSecret 本地签名时需要设置私钥
func (*Transaction) SetSendMax ¶
func (tx *Transaction) SetSendMax(amount constant.Amount)
SetSendMax limit send max amount
func (*Transaction) SetTransferRate ¶
func (tx *Transaction) SetTransferRate(rate float32)
SetTransferRate 设置手续费汇率
func (*Transaction) Submit ¶
func (tx *Transaction) Submit(callback func(err error, result interface{}))
Submit 提交交易数据