openwsdk

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2020 License: GPL-3.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	/* 回调模式 */
	CallbackModeCurrentConnection = 1 //当前连接模式,长连接可以用当前连接,接收推送
	CallbackModeNewConnection     = 2 //新建连接模式,短连接可以采用建立回调服务接口接收推送
)
View Source
const (
	/* 汇总任务操作类型 */
	SummaryTaskOperateTypeReset = 0 //重置
	SummaryTaskOperateTypeAdd   = 1 //追加
)
View Source
const (
	SubscribeToAccount = "subscribeToAccount" //订阅余额更新通信
	SubscribeToTrade   = "subscribeToTrade"   //订阅新交易单通知
	SubscribeToBlock   = "subscribeToBlock"   //订阅新区块链头通知
)
View Source
const (
	HostNodeID = "openw-server"
)

Variables

This section is empty.

Functions

func GenTrustAddressID added in v1.3.8

func GenTrustAddressID(address, symbol string) string

func SignRawTransaction

func SignRawTransaction(rawTx *RawTransaction, key *hdkeystore.HDKey) error

SignRawTransaction 签名交易单

Types

type APINode

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

APINode APINode通信节点

func NewAPINode

func NewAPINode(config *APINodeConfig) *APINode

NewAPINode 创建API节点

func NewAPINodeWithError

func NewAPINodeWithError(config *APINodeConfig) (*APINode, error)

NewAPINodeWithError 创建API节点

func (*APINode) AddObserver

func (api *APINode) AddObserver(obj OpenwNotificationObject) error

AddObserver 添加观测者

func (*APINode) BindAppDevice

func (api *APINode) BindAppDevice() error

BindAppDevice 绑定通信节点 绑定节点ID成功,才能获得授权通信

func (*APINode) BindDevice added in v1.2.19

func (api *APINode) BindDevice(
	deviceID string,
	sync bool,
	reqFunc func(status uint64, msg string)) error

BindDevice 绑定设备ID

func (*APINode) CreateAddress

func (api *APINode) CreateAddress(
	walletID string,
	accountID string,
	count uint64,
	sync bool,
	reqFunc func(status uint64, msg string, addresses []*Address)) error

CreateAddress 创建资产账户的地址

func (*APINode) CreateBatchAddress

func (api *APINode) CreateBatchAddress(
	walletID string,
	accountID string,
	count uint64,
	sync bool,
	reqFunc func(status uint64, msg string, addresses []string)) error

CreateBatchAddress 批量创建资产账户的地址

func (*APINode) CreateNormalAccount

func (api *APINode) CreateNormalAccount(
	accountParam *Account,
	sync bool,
	reqFunc func(status uint64, msg string, account *Account, addresses []*Address)) error

CreateAccount 创建资产账户

func (*APINode) CreateSummaryTx

func (api *APINode) CreateSummaryTx(
	accountID string,
	sumAddress string,
	coin Coin,
	feeRate string,
	minTransfer string,
	retainedBalance string,
	addressStartIndex int,
	addressLimit int,
	confirms uint64,
	sid string,
	feesSupportAccount *FeesSupportAccount,
	memo string,
	sync bool,
	reqFunc func(status uint64, msg string, rawTxs []*RawTransaction)) error

CreateSummaryTx 创建汇总交易单

func (*APINode) CreateTrade

func (api *APINode) CreateTrade(
	accountID string,
	sid string,
	coin Coin,
	amount string,
	address string,
	feeRate string,
	memo string,
	sync bool,
	reqFunc func(status uint64, msg string, rawTx *RawTransaction),
) error

CreateTrade 创建转账交易订单

func (*APINode) CreateWallet

func (api *APINode) CreateWallet(wallet *Wallet, sync bool, reqFunc func(status uint64, msg string, wallet *Wallet)) error

CreateWallet 创建钱包

func (*APINode) FindAccountByAccountID

func (api *APINode) FindAccountByAccountID(accountID string, refresh int, sync bool, reqFunc func(status uint64, msg string, account *Account)) error

FindAccountByAccountID 通过资产账户ID获取资产账户信息

func (*APINode) FindAccountByParams added in v1.4.5

func (api *APINode) FindAccountByParams(
	params map[string]interface{},
	offset int,
	limit int,
	sync bool,
	reqFunc func(status uint64, msg string, accounts []*Account),
) error

FindAccountByParams 根据条件查询账户列表

func (*APINode) FindAccountByWalletID

func (api *APINode) FindAccountByWalletID(walletID string, sync bool, reqFunc func(status uint64, msg string, accounts []*Account)) error

FindAccountByWalletID 通过钱包ID获取资产账户列表信息

func (*APINode) FindAddressByAccountID

func (api *APINode) FindAddressByAccountID(accountID string, offset int, limit int, sync bool, reqFunc func(status uint64, msg string, addresses []*Address)) error

FindAccountByWalletID 通过资产账户ID获取交易地址列表

func (*APINode) FindAddressByAddress

func (api *APINode) FindAddressByAddress(address string, sync bool, reqFunc func(status uint64, msg string, address *Address)) error

FindAddressByAddress 通获取具体交易地址信息

func (*APINode) FindAddressByParams added in v1.4.5

func (api *APINode) FindAddressByParams(
	params map[string]interface{},
	offset int,
	limit int,
	sync bool,
	reqFunc func(status uint64, msg string, addresses []*Address),
) error

FindAddressByParams 过条件查询地址列表

func (*APINode) FindTradeLog

func (api *APINode) FindTradeLog(
	walletID string,
	accountID string,
	symbol string,
	txid string,
	address string,
	isTmp int,
	orderType int,
	start_height int64,
	end_height int64,
	height int64,
	isDesc bool,
	offset int,
	limit int,
	sync bool,
	reqFunc func(status uint64, msg string, tx []*Transaction),
) error

FindTradeLog 获取转账交易订单日志

func (*APINode) FindTradeLogByParams added in v1.2.0

func (api *APINode) FindTradeLogByParams(
	params map[string]interface{},
	offset int,
	limit int,
	sync bool,
	reqFunc func(status uint64, msg string, tx []*Transaction),
) error

new

func (*APINode) FindWalletByParams added in v1.4.5

func (api *APINode) FindWalletByParams(
	params map[string]interface{},
	offset int,
	limit int,
	sync bool,
	reqFunc func(status uint64, msg string, wallets []*Wallet),
) error

FindWalletByParams 查询钱包列表

func (*APINode) FindWalletByWalletID

func (api *APINode) FindWalletByWalletID(walletID string, sync bool, reqFunc func(status uint64, msg string, wallet *Wallet)) error

FindWalletByWalletID 通过钱包ID获取钱包信息

func (*APINode) GetAllTokenBalanceByAccount

func (api *APINode) GetAllTokenBalanceByAccount(
	accountID string,
	symbol string,
	sync bool,
	reqFunc func(status uint64, msg string, balance []*TokenBalance)) error

GetAllTokenBalanceByAccount 获取账户所有token余额接口

func (*APINode) GetAllTokenBalanceByAddress added in v1.2.16

func (api *APINode) GetAllTokenBalanceByAddress(
	accountID string,
	address string,
	symbol string,
	sync bool,
	reqFunc func(status uint64, msg string, balance []*TokenBalance)) error

GetAllTokenBalanceByAddress 获取地址的token余额接口

func (*APINode) GetContracts

func (api *APINode) GetContracts(
	symbol, contractID string,
	offset, limit int,
	sync bool,
	reqFunc func(status uint64, msg string, tokenContract []*TokenContract)) error

GetContracts 获取智能合约

func (*APINode) GetFeeRate

func (api *APINode) GetFeeRate(
	symbol string,
	sync bool,
	reqFunc func(status uint64, msg string, symbol, feeRate, unit string)) error

GetFeeRate 获取推荐手续费率接口

func (*APINode) GetFeeRateList added in v1.2.1

func (api *APINode) GetFeeRateList(
	sync bool,
	reqFunc func(status uint64, msg string, feeRates []SupportFeeRate),
) error

func (*APINode) GetNotifierNodeInfo added in v1.4.1

func (api *APINode) GetNotifierNodeInfo() (string, string, error)

GetNotifierNodeInfo 获取通知者节点信息

func (*APINode) GetSymbolBlockList added in v1.2.6

func (api *APINode) GetSymbolBlockList(
	symbol string,
	sync bool,
	reqFunc func(status uint64, msg string, blockHeaders []*BlockHeader)) error

GetSymbolBlockList 获取币种最大高度

func (*APINode) GetSymbolList

func (api *APINode) GetSymbolList(symbol string, offset, limit, hasRole int, sync bool, reqFunc func(status uint64, msg string, total int, symbols []*Symbol)) error

GetSymbolList 获取主链列表

func (*APINode) GetTokenBalanceByAccount

func (api *APINode) GetTokenBalanceByAccount(
	accountID string,
	contractID string,
	sync bool,
	reqFunc func(status uint64, msg string, balance *TokenBalance)) error

GetTokenBalanceByAccount 获取token余额接口

func (*APINode) ImportAccount added in v1.2.18

func (api *APINode) ImportAccount(
	accountParam *Account,
	sync bool,
	reqFunc func(status uint64, msg string, account *Account, addresses []*Address)) error

ImportAccount 导入第三方资产账户

func (*APINode) ImportBatchAddress added in v1.3.7

func (api *APINode) ImportBatchAddress(
	walletID, accountID, memo string,
	addressAndPubs map[string]string,
	updateBalance bool,
	sync bool,
	reqFunc func(status uint64, msg string, importAddresses []string)) error

ImportBatchAddress 批量导入地址

func (*APINode) NodeID

func (api *APINode) NodeID() string

NodeID

func (*APINode) OWTPNode

func (api *APINode) OWTPNode() *owtp.OWTPNode

OWTPNode

func (*APINode) ProxyNode added in v1.3.9

func (api *APINode) ProxyNode() (*ProxyNode, error)

ProxyNode 代理节点

func (*APINode) RemoveObserver

func (api *APINode) RemoveObserver(obj OpenwNotificationObject) error

RemoveObserver 移除观测者

func (*APINode) ServeNotification

func (api *APINode) ServeNotification(listenAddr string, connectType string) error

ServeNotification 开启监听服务,接收通知

func (*APINode) ServeProxyNode added in v1.3.9

func (api *APINode) ServeProxyNode(address string) (*ProxyNode, error)

ServeProxyNode 开启代理服务

func (*APINode) ServeTransmitNode

func (api *APINode) ServeTransmitNode(address string) error

ServeTransmitNode 启动转发服务节点

func (*APINode) StopProxyNode added in v1.3.9

func (api *APINode) StopProxyNode() error

StopProxyNode 停止代理节点

func (*APINode) StopServeNotification

func (api *APINode) StopServeNotification(connectType string)

StopServeNotification 关闭监听通知

func (*APINode) StopTransmitNode

func (api *APINode) StopTransmitNode(port int) error

StopTransmitNode 停止转发服务节点

func (*APINode) SubmitTrade

func (api *APINode) SubmitTrade(
	rawTx []*RawTransaction,
	sync bool,
	reqFunc func(status uint64, msg string, successTx []*Transaction, failedRawTxs []*FailedRawTransaction),
) error

SubmitTrade 广播转账交易订单

func (*APINode) Subscribe

func (api *APINode) Subscribe(subscribeMethod []string, listenAddr string, callbackMode int, callbackNode CallbackNode, subscribeToken string) error

Subscribe 订阅

func (*APINode) TransmitNode

func (api *APINode) TransmitNode() (*TransmitNode, error)

TransmitNode 转发节点

func (*APINode) VerifyAddress added in v1.6.0

func (api *APINode) VerifyAddress(symbol, address string, sync bool,
	reqFunc func(status uint64, msg string, flag bool),
) error

VerifyAddress 地址校验

type APINodeConfig

type APINodeConfig struct {
	Host               string           `json:"host"`
	AppID              string           `json:"appid"`
	AppKey             string           `json:"appkey"`
	ConnectType        string           `json:"connectType"`
	EnableKeyAgreement bool             `json:"enableKeyAgreement"`
	EnableSSL          bool             `json:"enableSSL"`
	EnableSignature    bool             `json:"enableSignature"`
	Cert               owtp.Certificate `json:"cert"`
	TimeoutSEC         int              `json:"timeoutSEC"`
}

type Account

type Account struct {
	AppID            string   `json:"appID" bson:"appID"`
	WalletID         string   `json:"walletID" bson:"walletID"`
	AccountID        string   `json:"accountID" bson:"accountID"`
	Alias            string   `json:"alias" bson:"alias"`
	Symbol           string   `json:"symbol" bson:"symbol"`
	OtherOwnerKeys   []string `json:"otherOwnerKeys" bson:"otherOwnerKeys"`
	ReqSigs          int64    `json:"reqSigs" bson:"reqSigs"`
	IsTrust          int64    `json:"isTrust" bson:"isTrust"`
	Password         string   `json:"password" bson:"password"`
	PublicKey        string   `json:"publicKey" bson:"publicKey"`
	HdPath           string   `json:"hdPath" bson:"hdPath"`
	ContractAddress  string   `json:"contractAddress" bson:"contractAddress"`
	AccountIndex     int64    `json:"accountIndex" bson:"accountIndex"`
	Balance          string   `json:"balance" bson:"balance"`
	ConfirmBalance   string   `json:"confirmBalance" bson:"confirmBalance"`
	UnconfirmBalance string   `json:"unconfirmBalance" bson:"unconfirmBalance"`
	ExtInfo          string   `json:"extInfo" bson:"extInfo"`
	AddressIndex     int64    `json:"addressIndex" bson:"addressIndex"`
	Applytime        int64    `json:"applytime" bson:"applytime"`
	Dealstate        int64    `json:"dealstate" bson:"dealstate"`
}

type Address

type Address struct {
	AppID            string `json:"appID" bson:"appID"`
	WalletID         string `json:"walletID" bson:"walletID"`
	AccountID        string `json:"accountID" bson:"accountID"`
	Alias            string `json:"alias" bson:"alias"`
	Symbol           string `json:"symbol" bson:"symbol"`
	AddrIndex        int64  `json:"addrIndex" bson:"addrIndex"`
	Address          string `json:"address" bson:"address"`
	Balance          string `json:"balance" bson:"balance"`
	ConfirmBalance   string `json:"confirmBalance" bson:"confirmBalance"`
	UnconfirmBalance string `json:"unconfirmBalance" bson:"unconfirmBalance"`
	IsMemo           int64  `json:"isMemo" bson:"isMemo"`
	Memo             string `json:"memo" bson:"memo"`
	WatchOnly        int64  `json:"watchOnly" bson:"watchOnly"`
	PublicKey        string `json:"publicKey" bson:"publicKey"`
	CreatedAt        int64  `json:"createdAt" bson:"createdAt"`
	Num              int64  `json:"num" bson:"num"`
	Tag              string `json:"tag" bson:"tag"`
	HdPath           string `json:"hdPath" bson:"hdPath"`
	IsChange         int64  `json:"isChange" bson:"isChange"`
	Applytime        int64  `json:"applytime" bson:"applytime"`
	Dealstate        int64  `json:"dealstate" bson:"dealstate"`
}

type Balance

type Balance struct {
	Symbol           string `json:"symbol" bson:"symbol"`
	AccountID        string `json:"accountID" bson:"accountID"`
	Address          string `json:"address" bson:"address"`
	BalanceType      int64  `json:"type" bson:"type"`
	Balance          string `json:"balance" bson:"balance"`
	ConfirmBalance   string `json:"confirmBalance" bson:"confirmBalance"`
	UnconfirmBalance string `json:"unconfirmBalance" bson:"unconfirmBalance"`
}

func NewBalance added in v1.3.5

func NewBalance(result gjson.Result) *Balance

type BlockHeader

type BlockHeader struct {
	Hash              string `json:"hash"`
	Confirmations     uint64 `json:"confirmations"`
	Merkleroot        string `json:"merkleroot"`
	Previousblockhash string `json:"previousblockhash"`
	Height            uint64 `json:"height"`
	Version           uint64 `json:"version"`
	Time              uint64 `json:"time"`
	Fork              bool   `json:"fork"`
	Symbol            string `json:"symbol"`
}

func NewBlockHeader added in v1.2.6

func NewBlockHeader(result gjson.Result) *BlockHeader

type CallbackNode

type CallbackNode struct {
	NodeID             string `json:"nodeID"`             //@required 节点ID
	Address            string `json:"address"`            //@required 连接IP地址
	ConnectType        string `json:"connectType"`        //@required 连接方式
	EnableKeyAgreement bool   `json:"enableKeyAgreement"` //是否开启owtp协议协商密码
	EnableSSL          bool   `json:"enableSSL"`          //是否开启链接SSL,https,wss
	EnableSignature    bool   `json:"enableSignature"`    //是否开启owtp协议内签名,防重放
	// contains filtered or unexported fields
}

func NewCallbackNode

func NewCallbackNode(result gjson.Result) *CallbackNode

type Coin

type Coin struct {
	Symbol     string `json:"symbol"`
	IsContract bool   `json:"isContract"`
	ContractID string `json:"contractID"`
}

func NewCoin

func NewCoin(result gjson.Result) *Coin

type ErrorMsg added in v1.1.5

type ErrorMsg struct {
	Code uint64 `json:"code"`
	Err  string `json:"err"`
}

type FailedRawTransaction

type FailedRawTransaction struct {
	RawTx  *RawTransaction `json:"rawTx"`
	Reason string          `json:"error"`
}

type FeesSupportAccount added in v1.1.4

type FeesSupportAccount struct {
	AccountID         string `json:"accountID"`         //手续费账户ID
	LowBalanceWarning string `json:"lowBalanceWarning"` //余额过低报警值
	LowBalanceStop    string `json:"lowBalanceStop"`    //余额过低停止手续费支持
	FixSupportAmount  string `json:"fixSupportAmount"`
	FeesScale         string `json:"feesScale"`
	IsTokenContract   bool   `json:"isTokenContract"` //手续费是否合约代币
	ContractAddress   string `json:"contractAddress"` //合约地址
}

FeesSupportAccount 主币余额不足时,可选择一个账户提供手续费

type KeySignature

type KeySignature struct {
	EccType     uint32 `json:"eccType"`     //曲线类型
	RSV         bool   `json:"rsv"`         //签名是否需要拼接V
	Nonce       string `json:"nonce"`       //nonce
	Address     string `json:"address"`     //提供签名的地址
	Signature   string `json:"signed"`      //未花签名
	Message     string `json:"msg"`         //被签消息
	DerivedPath string `json:"derivedPath"` //密钥路径
	WalletID    string `json:"walletID"`    //钱包ID
	InputIndex  uint32 `json:"inputIndex"`  //input索引位
}

type OpenwNotificationObject

type OpenwNotificationObject interface {

	//OpenwNewTransactionNotify openw新交易单通知
	OpenwNewTransactionNotify(transaction *Transaction, subscribeToken string) (bool, error)

	//OpenwNewBlockNotify openw新区块头通知
	OpenwNewBlockNotify(blockHeader *BlockHeader, subscribeToken string) (bool, error)

	//OpenwBalanceUpdateNotify openw余额更新
	OpenwBalanceUpdateNotify(balance *Balance, tokenBalance *TokenBalance, subscribeToken string) (bool, error)
}

OpenwNotificationObject openw-server的通知对象

type ProxyNode added in v1.3.9

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

ProxyNode 代理节点,用于承担转发客户端的请求到openw-server,返回结果给客户端

func NewProxyNode added in v1.3.9

func NewProxyNode(config *APINodeConfig) *ProxyNode

NewProxyNode 创建一个代理节点实例

func (*ProxyNode) APINode added in v1.3.9

func (proxyNode *ProxyNode) APINode() (*APINode, error)

APINode

func (*ProxyNode) Close added in v1.3.9

func (proxyNode *ProxyNode) Close()

Close 关闭监听

func (*ProxyNode) Listen added in v1.3.9

func (proxyNode *ProxyNode) Listen()

Listen 启动监听

func (*ProxyNode) OWTPNode added in v1.3.9

func (proxyNode *ProxyNode) OWTPNode() (*owtp.OWTPNode, error)

OWTPNode

func (*ProxyNode) SetProxyRequestHandler added in v1.3.9

func (proxyNode *ProxyNode) SetProxyRequestHandler(h func(ctx *owtp.Context) bool)

SetProxyRequestHandler 通过设置请求处理器,你可以在请求被中转前进行一些自定义操作

func (*ProxyNode) SetProxyResponseHandler added in v1.3.9

func (proxyNode *ProxyNode) SetProxyResponseHandler(h func(ctx *owtp.Context) bool)

SetProxyResponseHandler 通过设置响应处理器,你可以在响应被中转前进行一些自定义操作

type RawTransaction

type RawTransaction struct {
	Coin       Coin                       `json:"coin"`      //@required 区块链类型标识
	TxID       string                     `json:"txID"`      //交易单ID,广播后会生成
	Sid        string                     `json:"sid"`       //业务订单号,保证业务不重复交易而用
	RawHex     string                     `json:"rawHex"`    //区块链协议构造的交易原生数据
	FeeRate    string                     `json:"feeRate"`   //自定义费率
	To         map[string]string          `json:"to"`        //@required 目的地址:转账数量
	AccountID  string                     `json:"accountID"` //@required 创建交易单的账户
	Signatures map[string][]*KeySignature `json:"sigParts"`  //拥有者accountID: []未花签名
	Required   uint64                     `json:"reqSigs"`   //必要签名
	Fees       string                     `json:"fees"`      //手续费
	ErrorMsg   *ErrorMsg                  `json:"errorMsg"`
}

type SummaryAccountTask

type SummaryAccountTask struct {
	AccountID          string                          `json:"accountID"`
	Contracts          map[string]*SummaryContractTask `json:"contracts"`
	FeeRate            string                          `json:"feeRate"`
	OnlyContracts      bool                            `json:"onlyContracts"`
	FeesSupportAccount *FeesSupportAccount             `json:"feesSupportAccount"`
	SwitchSymbol       string                          `json:"switchSymbol"`
	Memo               string                          `json:"memo"`
	*SummarySetting
}

type SummaryContractTask added in v1.1.4

type SummaryContractTask struct {
	*SummarySetting
}

type SummarySetting

type SummarySetting struct {
	WalletID        string `json:"walletID"`
	AccountID       string `json:"accountID" storm:"id"`
	SumAddress      string `json:"sumAddress"`
	Threshold       string `json:"threshold"`
	MinTransfer     string `json:"minTransfer"`
	RetainedBalance string `json:"retainedBalance"`
	Confirms        uint64 `json:"confirms"`
	AddressLimit    uint64 `json:"addressLimit"`
}

SummarySetting 汇总设置信息

func NewSummarySetting

func NewSummarySetting(result gjson.Result) *SummarySetting

type SummaryTask

type SummaryTask struct {
	Wallets []*SummaryWalletTask `json:"wallets"`
}

func NewSummaryTask

func NewSummaryTask(result gjson.Result) *SummaryTask

type SummaryTaskLog

type SummaryTaskLog struct {
	Sid            string   `json:"sid" storm:"id"`           //汇总执行批次号
	WalletID       string   `json:"walletID"`                 //汇总钱包ID
	AccountID      string   `json:"accountID"`                //汇总资产账户ID
	StartAddrIndex int      `json:"startAddrIndex"`           //账户汇总起始的地址索引位
	EndAddrIndex   int      `json:"endAddrIndex"`             //账户汇总结束的地址索引位
	Coin           Coin     `json:"coin"`                     //汇总的币种信息
	SuccessCount   int      `json:"successCount"`             //汇总交易发送的成功个数
	FailCount      int      `json:"failCount"`                //汇总交易发送的失败个数
	TxIDs          []string `json:"txIDs"`                    //汇总交易成功的txid
	Sids           []string `json:"sids"`                     //汇总交易成功批次号
	TotalSumAmount string   `json:"sumAmount"`                //这次汇总总数
	TotalCostFees  string   `json:"sumFees"`                  //这次汇总总消费手续费
	CreateTime     int64    `json:"createTime" storm:"index"` //汇总时间
}

type SummaryWalletTask

type SummaryWalletTask struct {
	WalletID string                `json:"walletID"`
	Password string                `json:"password"`
	Accounts []*SummaryAccountTask `json:"accounts"`
	Wallet   *Wallet
}

func NewSummaryWalletTask

func NewSummaryWalletTask(result gjson.Result) *SummaryWalletTask

type SupportFeeRate added in v1.2.1

type SupportFeeRate struct {
	FeeRate string
	Symbol  string
	Unit    string
}

support feeRate

type Symbol

type Symbol struct {
	Name         string `json:"name" bson:"name" storm:"id"`
	Coin         string `json:"coin" bson:"coin"`
	Curve        int64  `json:"curve" bson:"curve"`
	Orderno      int64  `json:"orderno" bson:"orderno"`
	Confirm      int64  `json:"confirm" bson:"confirm"`
	Decimals     int64  `json:"decimals" bson:"decimals"`
	BalanceMode  uint64 `json:"balanceMode" bson:"balanceMode"`
	Icon         string `json:"icon"`
	SupportMemo  uint64 `json:"supportMemo"`  //交易是否支持memo, 0: false, 1: true
	OnlyContract uint64 `json:"onlyContract"` //支持合约代币, 0: false, 1: true
	WithdrawStop int64  `json:"withdrawStop"`
	BlockStop    int64  `json:"blockStop"`
}

type TokenBalance

type TokenBalance struct {
	ContractID string
	Token      string
	Address    string
	Balance    Balance
	IsContract int64
}

func NewTokenBalance

func NewTokenBalance(result gjson.Result) *TokenBalance

type TokenContract

type TokenContract struct {
	ContractID string `json:"contractID" bson:"contractID" storm:"id"`
	Symbol     string `json:"symbol" bson:"symbol"` //主链标记
	Name       string `json:"name" bson:"name"`
	Decimals   int64  `json:"decimals" bson:"decimals"`
	Address    string `json:"address" bson:"address"`
	Token      string `json:"token" bson:"token"` //token标记
	Protocol   string `json:"protocol" bson:"protocol"`
}

type Transaction

type Transaction struct {
	AppID        string                 `json:"appID" bson:"appID"`
	WalletID     string                 `json:"walletID" bson:"walletID"`
	AccountID    string                 `json:"accountID" bson:"accountID"`
	Sid          string                 `json:"sid" bson:"sid"`
	Txid         string                 `json:"txid" bson:"txid"`
	Wxid         string                 `json:"wxid" bson:"wxid"`
	FromAddress  []string               `json:"fromAddress" bson:"fromAddress"`
	FromAddressV []string               `json:"fromAddressV" bson:"fromAddressV"`
	ToAddress    []string               `json:"toAddress" bson:"toAddress"`
	ToAddressV   []string               `json:"toAddressV" bson:"toAddressV"`
	Amount       string                 `json:"amount" bson:"amount"`
	Fees         string                 `json:"fees" bson:"fees"`
	Type         int64                  `json:"type" bson:"type"`
	Symbol       string                 `json:"symbol" bson:"symbol"`
	ContractID   string                 `json:"contractID" bson:"contractID"`
	IsContract   int64                  `json:"isContract" bson:"isContract"`
	Confirm      int64                  `json:"confirm" bson:"confirm"`
	BlockHash    string                 `json:"blockHash" bson:"blockHash"`
	BlockHeight  int64                  `json:"blockHeight" bson:"blockHeight"`
	IsMemo       int64                  `json:"isMemo" bson:"isMemo"`
	IsMain       int64                  `json:"isMain" bson:"isMain"`
	Memo         string                 `json:"memo" bson:"memo"`
	Applytime    int64                  `json:"applytime" bson:"applytime"`
	SubmitTime   int64                  `json:"submitTime" bson:"submitTime"`
	ConfirmTime  int64                  `json:"confirmTime" bson:"confirmTime"`
	Decimals     int64                  `json:"decimals" bson:"decimals"`
	Succtime     int64                  `json:"succtime" bson:"succtime"`
	Dealstate    int64                  `json:"dealstate" bson:"dealstate"`
	Notifystate  int64                  `json:"notifystate" bson:"notifystate"`
	ContractID2  string                 `json:"contractID2" bson:"contractID2"`
	ContractName string                 `json:"contractName" bson:"contractName"`
	ContractAddr string                 `json:"contractAddr" bson:"contractAddr"`
	Contract     map[string]interface{} `json:"contract" bson:"contract"`
	Success      string                 `json:"success"`                        //用于判断交易单链上的真实状态,0:失败,1:成功
	TxType       int64                  `json:"txType"`                         //0:转账, 1:合约调用(发生于主链), >100: 自定义
	TxAction     string                 `json:"txAction"`                       //执行事件, 例如:合约的Transfer事
	BalanceMode  uint64                 `json:"balanceMode" bson:"balanceMode"` //余额模型 0.地址 1.账户
}

func (*Transaction) FromSID

func (tx *Transaction) FromSID(n int) string

func (*Transaction) ToSID

func (tx *Transaction) ToSID(n int) string

type TransmitNode

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

func NewTransmitNode

func NewTransmitNode(config *APINodeConfig) (*TransmitNode, error)

func (*TransmitNode) APINode

func (transmit *TransmitNode) APINode() (*APINode, error)

APINode

func (*TransmitNode) AppendSummaryTaskViaTrustNode

func (transmit *TransmitNode) AppendSummaryTaskViaTrustNode(
	nodeID string,
	summaryTask *SummaryTask,
	sync bool, reqFunc func(status uint64, msg string)) error

AppendSummaryTaskViaTrustNode 指定节点,追加汇总任务

func (*TransmitNode) Close

func (transmit *TransmitNode) Close()

Close 关闭监听

func (*TransmitNode) CreateAccountViaTrustNode

func (transmit *TransmitNode) CreateAccountViaTrustNode(
	nodeID, walletID, alias, password, symbol string, sync bool,
	reqFunc func(status uint64, msg string, account *Account, addresses []*Address)) error

CreateAccountViaTrustNode 指定节点,创建种子托管钱包

func (*TransmitNode) CreateWalletViaTrustNode

func (transmit *TransmitNode) CreateWalletViaTrustNode(nodeID, alias, password string,
	sync bool, reqFunc func(status uint64, msg string, wallet *Wallet)) error

CreateWalletViaTrustNode 指定节点,创建种子托管钱包

func (*TransmitNode) FindSummaryInfoByWalletIDViaTrustNode

func (transmit *TransmitNode) FindSummaryInfoByWalletIDViaTrustNode(
	nodeID string,
	walletID string,
	sync bool, reqFunc func(status uint64, msg string, summarySettings []*SummarySetting)) error

FindSummaryInfoByWalletIDViaTrustNode 指定节点,获取汇总设置信息

func (*TransmitNode) GetCurrentSummaryTaskViaTrustNode

func (transmit *TransmitNode) GetCurrentSummaryTaskViaTrustNode(
	nodeID string,
	sync bool, reqFunc func(status uint64, msg string, summaryTask *SummaryTask)) error

GetCurrentSummaryTaskViaTrustNode 指定节点,获取当前的执行中的汇总任务

func (*TransmitNode) GetLocalWalletListViaTrustNode added in v1.2.11

func (transmit *TransmitNode) GetLocalWalletListViaTrustNode(
	nodeID string,
	sync bool, reqFunc func(status uint64, msg string, wallets []*Wallet)) error

GetLocalWalletListViaTrustNode 指定节点,获取该节点创建的钱包

func (*TransmitNode) GetSummaryTaskLogViaTrustNode

func (transmit *TransmitNode) GetSummaryTaskLogViaTrustNode(
	nodeID string,
	offset int,
	limit int,
	sync bool, reqFunc func(status uint64, msg string, taskLog []*SummaryTaskLog)) error

GetSummaryTaskLogViaTrustNode 指定节点,获取汇总日志列表

func (*TransmitNode) GetTrustAddressListViaTrustNode added in v1.3.8

func (transmit *TransmitNode) GetTrustAddressListViaTrustNode(
	nodeID string,
	symbol string,
	sync bool, reqFunc func(status uint64, msg string, trustAddressList []*TrustAddress, enableTrustAddress bool)) error

GetTrustAddressListViaTrustNode 指定节点,获取信任地址列表

func (*TransmitNode) GetTrustNodeInfo

func (transmit *TransmitNode) GetTrustNodeInfo(nodeID string,
	sync bool, reqFunc func(status uint64, msg string, nodeInfo *TrustNodeInfo)) error

GetTrustNodeInfo 获取授信的托管节点信息

func (*TransmitNode) Listen

func (transmit *TransmitNode) Listen()

Listen 启动监听

func (*TransmitNode) OWTPNode added in v1.2.4

func (transmit *TransmitNode) OWTPNode() (*owtp.OWTPNode, error)

OWTPNode

func (*TransmitNode) RemoveSummaryTaskViaTrustNode

func (transmit *TransmitNode) RemoveSummaryTaskViaTrustNode(
	nodeID string,
	walletID string,
	accountID string,
	sync bool, reqFunc func(status uint64, msg string)) error

RemoveSummaryTaskViaTrustNode 指定节点,移除汇总任务

func (*TransmitNode) SendTransactionViaTrustNode

func (transmit *TransmitNode) SendTransactionViaTrustNode(
	nodeID string,
	accountID string,
	password string,
	sid string,
	contractAddress string,
	amount string,
	address string,
	feeRate string,
	memo string,
	sync bool,
	reqFunc func(status uint64, msg string, successTx []*Transaction, failedRawTxs []*FailedRawTransaction),
) error

SendTransactionViaTrustNode 创建转账交易订单

func (*TransmitNode) SetConnectHandler

func (transmit *TransmitNode) SetConnectHandler(h func(transmitNode *TransmitNode, nodeInfo *TrustNodeInfo))

SetConnectHandler 设置托管节点断开连接后的通知

func (*TransmitNode) SetDisconnectHandler

func (transmit *TransmitNode) SetDisconnectHandler(h func(transmitNode *TransmitNode, nodeID string))

SetDisconnectHandler 设置托管节点连接成功的通知

func (*TransmitNode) SetSummaryInfoViaTrustNode

func (transmit *TransmitNode) SetSummaryInfoViaTrustNode(
	nodeID string,
	summarySetting *SummarySetting,
	sync bool, reqFunc func(status uint64, msg string)) error

SetSummaryInfoViaTrustNode 指定节点,设置汇总信息

func (*TransmitNode) SignTransactionViaTrustNode added in v1.4.0

func (transmit *TransmitNode) SignTransactionViaTrustNode(
	nodeID string,
	walletID string,
	rawTx *RawTransaction,
	password string,
	sync bool,
	reqFunc func(status uint64, msg string, signedRawTx *RawTransaction),
) error

SignTransactionViaTrustNode 指定节点,签名交易单

func (*TransmitNode) StartSummaryTaskViaTrustNode

func (transmit *TransmitNode) StartSummaryTaskViaTrustNode(
	nodeID string,
	cycleSec int,
	summaryTask *SummaryTask,
	operateType int,
	sync bool, reqFunc func(status uint64, msg string)) error

StartSummaryTaskViaTrustNode 指定节点,启动汇总任务 nodeID 节点ID cycleSec 任务周期间隔 summaryTask 汇总任务 operateType 操作类型:0:重置,1:追加

func (*TransmitNode) StopSummaryTaskViaTrustNode

func (transmit *TransmitNode) StopSummaryTaskViaTrustNode(
	nodeID string,
	sync bool, reqFunc func(status uint64, msg string)) error

StopSummaryTaskViaTrustNode 指定节点,停止汇总任务

func (*TransmitNode) UpdateInfoViaTrustNode

func (transmit *TransmitNode) UpdateInfoViaTrustNode(
	nodeID string,
	sync bool, reqFunc func(status uint64, msg string)) error

UpdateInfo UpdateInfoViaTrustNode,更新主链信息和合约资料

type TrustAddress added in v1.3.8

type TrustAddress struct {
	ID         string `json:"id" storm:"id"`
	Address    string `json:"address"`
	Symbol     string `json:"symbol"`
	Memo       string `json:"memo"`
	CreateTime int64  `json:"createTime"`
}

白名单地址

func NewTrustAddress added in v1.3.8

func NewTrustAddress(address, symbol, memo string) *TrustAddress

type TrustNodeInfo

type TrustNodeInfo struct {
	NodeID      string `json:"nodeID"` //@required 节点ID
	NodeName    string `json:"nodeName"`
	ConnectType string `json:"connectType"`
	Version     string `json:"version"`
	GitRev      string `json:"gitRev"`
	BuildTime   string `json:"buildTime"`
}

type Wallet

type Wallet struct {
	AppID        string `json:"appID" bson:"appID"`
	WalletID     string `json:"walletID" bson:"walletID"`
	Alias        string `json:"alias" bson:"alias"`
	IsTrust      int64  `json:"isTrust" bson:"isTrust"`
	PasswordType int64  `json:"passwordType" bson:"passwordType"`
	Password     string `json:"password" bson:"password"`
	AuthKey      string `json:"authKey" bson:"authKey"`
	RootPath     string `json:"rootPath" bson:"rootPath"`
	AccountIndex int64  `json:"accountIndex" bson:"accountIndex"`
	Keystore     string `json:"keystore" bson:"keystore"`
	Applytime    int64  `json:"applytime" bson:"applytime"`
	Dealstate    int64  `json:"dealstate" bson:"dealstate"`
}

func (*Wallet) CreateAccount

func (wallet *Wallet) CreateAccount(alias string, symbol *Symbol, key *hdkeystore.HDKey) (*Account, error)

Jump to

Keyboard shortcuts

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