openwcli

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CLIBucket          = "CLIBucket"
	CurrentKeychainKey = "current_keychain"
	EnableTrustAddress = "enable_trust_address"
	InitTrustAddress   = "init_trust_address"
)

Variables

View Source
var (
	// 固定应用信息
	FixAppID  = ""
	FixAppKey = ""
	Version   = ""
	GitRev    = ""
	BuildTime = ""
)
View Source
var (
	ErrorAppIDIncorrect             = uint64(20001)
	ErrorSummaryTaskTimerIsRunning  = uint64(20002)
	ErrorSummaryTaskTimerIsNotStart = uint64(20003)
	ErrorNodeAbilityDisabled        = uint64(20004)
	ErrorSummarySettingFailed       = uint64(20005)
)

Functions

func CheckBackgroundProcess

func CheckBackgroundProcess(processName string) error

func FindExistedSummaryAccountTask

func FindExistedSummaryAccountTask(accountID string, tasks []*openwsdk.SummaryAccountTask) (int, *openwsdk.SummaryAccountTask)

func FindExistedSummaryWalletTask

func FindExistedSummaryWalletTask(walletID string, tasks []*openwsdk.SummaryWalletTask) (int, *openwsdk.SummaryWalletTask)

func GenKeychainFlow

func GenKeychainFlow() error

GenKeychainFlow 生成新的keychain流程

func ProcExsit

func ProcExsit(filePath string, processName string) error

判断进程是否启动

func SetupLog

func SetupLog(logDir, logFile string, debug bool)

SetupLog 配置日志

Types

type CLI

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

func NewCLI

func NewCLI(c *Config) (*CLI, error)

初始化工具

func (*CLI) APINode

func (cli *CLI) APINode() *openwsdk.APINode

APINode 返回CLI的API实例

func (*CLI) AddTrustAddress

func (cli *CLI) AddTrustAddress(trustAddress *openwsdk.TrustAddress) error

AddTrustAddress 添加白名单地址

func (*CLI) AddTrustAddressFlow

func (cli *CLI) AddTrustAddressFlow() error

AddTrustAddressFlow

func (*CLI) CallABI

func (cli *CLI) CallABI(account *openwsdk.Account, contractAddress string, abiParam []string) (*openwsdk.SmartContractCallResult, *openwallet.Error)

CallABI 直接调用ABI方法

func (*CLI) CallABIFlow

func (cli *CLI) CallABIFlow() error

CallABIFlow

func (*CLI) ChangePwdFlow added in v2.5.0

func (cli *CLI) ChangePwdFlow() error

ChangePwdFlow

func (*CLI) CreateAccountOnServer

func (cli *CLI) CreateAccountOnServer(name, password, symbol string, wallet *openwsdk.Wallet) (*openwsdk.Account, []*openwsdk.Address, error)

CreateAccountOnServer

func (*CLI) CreateAddressOnServer

func (cli *CLI) CreateAddressOnServer(walletID, accountID, symbol string, count uint64) error

CreateAddressOnServer

func (*CLI) CreateWalletOnServer

func (cli *CLI) CreateWalletOnServer(name, password string) (*openwsdk.Wallet, error)

CreateWalletOnServer

func (*CLI) DisableTrustAddress

func (cli *CLI) DisableTrustAddress() error

DisableTrustAddress

func (*CLI) DisableTrustAddressFlow

func (cli *CLI) DisableTrustAddressFlow() error

DisableTrustAddressFlow

func (*CLI) EnableTrustAddress

func (cli *CLI) EnableTrustAddress() error

EnableTrustAddress

func (*CLI) EnableTrustAddressFlow

func (cli *CLI) EnableTrustAddressFlow() error

EnableTrustAddressFlow

func (*CLI) GetAccountByAccountID

func (cli *CLI) GetAccountByAccountID(symbol, accountID string) (*openwsdk.Account, error)

GetAccountOnServerByAccountID 从服务器获取账户

func (*CLI) GetAccountsOnServer

func (cli *CLI) GetAccountsOnServer(walletID string) ([]*openwsdk.Account, error)

GetAccountsOnServer 从服务器获取账户列表

func (*CLI) GetAddressesBalance added in v2.4.6

func (cli *CLI) GetAddressesBalance(walletID, accountID, symbol string, opType, lastId, limit int) ([]*openwsdk.BalanceResult, error)

GetAddressesBalance

func (*CLI) GetAddressesOnServer

func (cli *CLI) GetAddressesOnServer(walletID, accountID, symbol string, lastId, limit int64) ([]*openwsdk.Address, error)

GetAddressesOnServer

func (*CLI) GetAllTokenContractBalance

func (cli *CLI) GetAllTokenContractBalance(walletID, accountID string, symbol string) ([]*openwsdk.BalanceResult, error)

GetAllTokenContractBalance 查询账户合约余额

func (*CLI) GetAllTokenContractBalanceByAddress

func (cli *CLI) GetAllTokenContractBalanceByAddress(walletID, accountID, address, symbol string) ([]*openwsdk.BalanceResult, error)

GetAllTokenContractBalanceByAddress 查询地址合约余额

func (*CLI) GetConfig

func (cli *CLI) GetConfig() *Config

GetConfig 返回CLI配置

func (*CLI) GetKeychain

func (cli *CLI) GetKeychain() (*Keychain, error)

GetKeychain

func (*CLI) GetNodeInfoFlow

func (cli *CLI) GetNodeInfoFlow() error

GetNodeInfo 获取节点信息

func (*CLI) GetSummaryTaskLog

func (cli *CLI) GetSummaryTaskLog(offset, limit int64) ([]*openwsdk.SummaryTaskLog, error)

func (*CLI) GetSymbolInfo

func (cli *CLI) GetSymbolInfo(symbol string) (*openwsdk.Symbol, error)

GetLocalSymbolInfo 查询本地主链信息

func (*CLI) GetSymbolList

func (cli *CLI) GetSymbolList() ([]*openwsdk.Symbol, error)

GetLocalSymbolList 查询本地保存主链

func (*CLI) GetTokenBalance

func (cli *CLI) GetTokenBalance(account *openwsdk.Account, contractID string) string

GetTokenBalance 获取代币余额

func (*CLI) GetTokenBalanceByContractAddress

func (cli *CLI) GetTokenBalanceByContractAddress(account *openwsdk.Account, symbol, address string) (*openwsdk.BalanceResult, error)

GetTokenBalanceByContractAddress 通过代币合约的地址获取代币余额

func (*CLI) GetTokenContractInfo

func (cli *CLI) GetTokenContractInfo(contractID string) (*openwsdk.TokenContract, error)

GetTokenContractInfo 查询单个合约信息

func (*CLI) GetTokenContractList

func (cli *CLI) GetTokenContractList(cols ...interface{}) ([]*openwsdk.TokenContract, error)

GetContractList 查询本地保存代币合约信息

func (*CLI) GetWalletByWalletID

func (cli *CLI) GetWalletByWalletID(walletID string) (*openwsdk.Wallet, error)

GetWalletByWalletID 查找本地且线上有的钱包对象

func (*CLI) GetWalletByWalletIDOnLocal

func (cli *CLI) GetWalletByWalletIDOnLocal(walletID string) (*openwsdk.Wallet, error)

GetWalletByWalletIDOnLocal 查找本地种子目录的钱包对象

func (*CLI) GetWalletsOnServer

func (cli *CLI) GetWalletsOnServer() ([]*openwsdk.Wallet, error)

GetWalletsByKeyDir 通过给定的文件路径加载keystore文件得到钱包列表

func (*CLI) IsTrustAddress

func (cli *CLI) IsTrustAddress(address, symbol string) bool

IsTrustAddress

func (*CLI) ListAccountFlow

func (cli *CLI) ListAccountFlow() error

ListAccountFlow

func (*CLI) ListAddressBalanceFlow added in v2.4.6

func (cli *CLI) ListAddressBalanceFlow() error

ListAddressBalanceFlow

func (*CLI) ListAddressFlow

func (cli *CLI) ListAddressFlow() error

ListAddressFlow

func (*CLI) ListSumInfoFlow

func (cli *CLI) ListSumInfoFlow() error

ListSumInfoFlow

func (*CLI) ListSymbolFlow

func (cli *CLI) ListSymbolFlow() error

ListSymbolFlow

func (*CLI) ListTokenBalanceFlow

func (cli *CLI) ListTokenBalanceFlow() error

ListTokenBalanceFlow

func (*CLI) ListTokenContractFlow

func (cli *CLI) ListTokenContractFlow() error

ListTokenContractFlow

func (*CLI) ListTrustAddress

func (cli *CLI) ListTrustAddress(symbol string) ([]*openwsdk.TrustAddress, error)

ListTrustAddress 白名单地址列表

func (*CLI) ListTrustAddressFlow

func (cli *CLI) ListTrustAddressFlow() error

ListTrustAddressFlow

func (*CLI) ListWalletFlow

func (cli *CLI) ListWalletFlow() error

ListWalletFlow

func (*CLI) NewAccountFlow

func (cli *CLI) NewAccountFlow() error

NewAccountFlow

func (*CLI) NewAddressFlow

func (cli *CLI) NewAddressFlow() error

NewAddressFlow

func (*CLI) NewWalletFlow

func (cli *CLI) NewWalletFlow() error

NewWalletFlow 创建钱包流程

func (*CLI) RegisterFlow

func (cli *CLI) RegisterFlow() error

RegisterFlow 注册节点流程

func (*CLI) RegisterOnServer

func (cli *CLI) RegisterOnServer() error

RegisterOnServer 注册节点到openw-server

func (*CLI) SaveCurrentKeychain

func (cli *CLI) SaveCurrentKeychain(keychain *Keychain) error

SaveCurrentKeychain 保存新密钥对到本地缓存

func (*CLI) SearchAddressFlow

func (cli *CLI) SearchAddressFlow() error

SearchAddressFlow

func (*CLI) SearchAddressOnServer

func (cli *CLI) SearchAddressOnServer(symbol, address string) (*openwsdk.Address, error)

SearchAddressOnServer

func (*CLI) SelectAccountStep added in v2.3.2

func (cli *CLI) SelectAccountStep(walletID string) (*openwsdk.Account, error)

SelectAccountStep 选择资产账户操作

func (*CLI) SelectWalletStep

func (cli *CLI) SelectWalletStep() (*openwsdk.Wallet, error)

SelectWalletStep 选择钱包操作

func (*CLI) ServeTransmitNode

func (cli *CLI) ServeTransmitNode(autoReconnect bool) error

func (*CLI) SetSignTxHashFunc

func (cli *CLI) SetSignTxHashFunc(txSigner SignTxHashFunc) error

SetSignTxHashFunc 设置签名方法

func (*CLI) SetSumFlow

func (cli *CLI) SetSumFlow() error

SetSumFlow

func (*CLI) SetSummaryInfo

func (cli *CLI) SetSummaryInfo(obj *openwsdk.SummarySetting) error

SetSummaryInfo 设置账户的汇总设置

func (*CLI) SignHash added in v2.2.2

func (cli *CLI) SignHash(address *openwsdk.Address, symbol, message, password string, appendV bool) (string, error)

SignHash 哈希消息签名

func (*CLI) SignHashFlow added in v2.3.0

func (cli *CLI) SignHashFlow() error

SignHashFlow 消息签名

func (*CLI) StartSumFlow

func (cli *CLI) StartSumFlow(file string) error

StartSumFlow

func (*CLI) StartTrustServerFlow

func (cli *CLI) StartTrustServerFlow() error

StartTrustServerFlow

func (*CLI) SummaryAccountMainCoin

func (cli *CLI) SummaryAccountMainCoin(accountTask *openwsdk.SummaryAccountTask, account *openwsdk.Account, key *hdkeystore.HDKey) error

SummaryAccountMainCoin 汇总账户主币

func (*CLI) SummaryAccountTokenContracts

func (cli *CLI) SummaryAccountTokenContracts(accountTask *openwsdk.SummaryAccountTask, account *openwsdk.Account, key *hdkeystore.HDKey) error

SummaryAccountTokenContracts 汇总账户代币合约

func (*CLI) SummaryTask

func (cli *CLI) SummaryTask()

SummaryWallets 执行汇总流程

func (*CLI) Transfer

func (cli *CLI) Transfer(wallet *openwsdk.Wallet, account *openwsdk.Account, symbol, contractAddress, to, amount, sid, feeRate, memo, password string) ([]*openwsdk.Transaction, []*openwsdk.FailedRawTransaction, *openwallet.Error)

Transfer 转账交易

func (*CLI) TransferAll

func (cli *CLI) TransferAll(wallet *openwsdk.Wallet, account *openwsdk.Account, symbol, contractAddress, to, sid, feeRate, memo, password string) error

func (*CLI) TransferAllFlow

func (cli *CLI) TransferAllFlow() error

TransferAllFlow

func (*CLI) TransferExt added in v2.1.1

func (cli *CLI) TransferExt(wallet *openwsdk.Wallet, account *openwsdk.Account, symbol, contractAddress, to, amount, sid, feeRate, memo, extParam, password string) ([]*openwsdk.Transaction, []*openwsdk.FailedRawTransaction, *openwallet.Error)

TransferExt 转账交易 + 扩展参数

func (*CLI) TransferFlow

func (cli *CLI) TransferFlow() error

TransferFlow

func (*CLI) TriggerABI

func (cli *CLI) TriggerABI(wallet *openwsdk.Wallet, account *openwsdk.Account, symbol, contractAddress, contractABI, amount, sid, feeRate, password string, abiParam []string, raw string, rawType uint64, awaitResult bool) (*openwsdk.SmartContractReceipt, *openwallet.Error)

TriggerABI 触发合约ABI接口

func (*CLI) TriggerABIFlow

func (cli *CLI) TriggerABIFlow() error

TriggerABIFlow

func (*CLI) TrustAddressStatus

func (cli *CLI) TrustAddressStatus() bool

TrustAddressStatus

func (*CLI) UpdateInfoFlow

func (cli *CLI) UpdateInfoFlow() error

UpdateInfoFlow

func (*CLI) UpdateSymbols

func (cli *CLI) UpdateSymbols() error

UpdateSymbols 更新主链

func (*CLI) UpdateTokenContracts

func (cli *CLI) UpdateTokenContracts(symbol string) error

UpdateSymbols 更新主链

type Config

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

配置

func LoadConfig

func LoadConfig(path string) (*Config, error)

加载工具配置

func NewConfig

func NewConfig(c config.Configer) *Config

初始化一个配置对象

func (*Config) GetKeyDir

func (c *Config) GetKeyDir() string

GetKeyDir

type Keychain

type Keychain struct {
	NodeID     string `json:"nodeID" storm:"id"`
	PrivateKey string `json:"privateKey"`
	PublicKey  string `json:"publicKey"`
	// contains filtered or unexported fields
}

密钥对

func GenKeychain

func GenKeychain() (*Keychain, error)

GenKeychain 生成新密钥对

func NewKeychain

func NewKeychain(cert owtp.Certificate) *Keychain

初始化密钥对

func (*Keychain) Certificate

func (keychain *Keychain) Certificate() (owtp.Certificate, error)

type SignTxHashFunc

type SignTxHashFunc func(signatures map[string][]*openwsdk.KeySignature, key *hdkeystore.HDKey) (map[string][]*openwsdk.KeySignature, error)

type SignRawTransactionFunc func(rawTx *openwsdk.RawTransaction, key *hdkeystore.HDKey) error

type StormDB

type StormDB struct {
	*storm.DB
	FileName string
	Opened   bool
}

func OpenStormDB

func OpenStormDB(filename string, stormOptions ...func(*storm.Options) error) (*StormDB, error)

OpenStormDB

func (*StormDB) Close

func (db *StormDB) Close() error

Close closes the database.

Jump to

Keyboard shortcuts

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