openw

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 默认系统应用ID, 读取数据库
	OpenwalletSystemAppID = "10000"
)

Variables

View Source
var (
	PeriodOfTask = 5 * time.Second
)

Functions

func GetAssets

func GetAssets(symbol string) interface{}

GetAssets 根据币种类型获取已注册的管理者

func GetAssetsAdapter

func GetAssetsAdapter(symbol string) (openwallet.AssetsAdapter, error)

GetAssetsAdapter 获取资产控制器

func GetSymbolInfo

func GetSymbolInfo(symbol string) (openwallet.SymbolInfo, error)

GetSymbolInfo 获取资产的币种信息

func RegAssets

func RegAssets(name string, manager interface{}, config ...config.Configer)

RegAssets 注册资产 @param name 资产别名 @param manager 资产适配器或管理器 @param config 加载配置 资产适配器实现了openwallet.AssetsConfig,可以传入配置接口完成预加载配置 usage: RegAssets(cardano.Symbol, &cardano.WalletManager{}, c) RegAssets(bytom.Symbol, &bytom.WalletManager{}, c)

func ServeAPINode

func ServeAPINode(apiNode *owtp.OWTPNode, autoReconnect bool) error

func SetCallbackNode

func SetCallbackNode(node *owtp.OWTPNode)

Types

type AppID

type AppID string

type AppWrapper

type AppWrapper struct {
	*Wrapper
	// contains filtered or unexported fields
}

AppWrapper 应用装器,扩展应用功能

func NewAppWrapper

func NewAppWrapper(args ...interface{}) *AppWrapper

func (*AppWrapper) GetWalletInfo

func (wrapper *AppWrapper) GetWalletInfo(walletID string) (*openwallet.Wallet, error)

GetWalletInfo

func (*AppWrapper) GetWalletList

func (wrapper *AppWrapper) GetWalletList(offset, limit int) ([]*openwallet.Wallet, error)

GetWalletList

type Config

type Config struct {
	KeyDir          string   //钥匙备份路径
	DBPath          string   //本地数据库文件路径
	BackupDir       string   //备份路径
	SupportAssets   []string //支持的资产类型
	EnableBlockScan bool
	ConfigDir       string
}

func NewConfig

func NewConfig() *Config

type NotificationObject

type NotificationObject interface {

	//BlockScanNotify 新区块扫描完成通知
	BlockScanNotify(header *openwallet.BlockHeader) error

	//BlockTxExtractDataNotify 区块提取结果通知
	BlockTxExtractDataNotify(account *openwallet.AssetsAccount, data *openwallet.TxExtractData) 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.

type SupportFeeRate

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
}

type TransactionWrapper

type TransactionWrapper struct {
	*WalletWrapper
}

TransactionWrapper 交易包装器,扩展钱包交易单相关功能

func NewTransactionWrapper

func NewTransactionWrapper(args ...interface{}) *TransactionWrapper

func (*TransactionWrapper) DeleteBlockDataByHeight

func (wrapper *TransactionWrapper) DeleteBlockDataByHeight(height uint64) error

DeleteBlockDataByHeight 删除钱包中指定区块高度相关的交易记录

func (*TransactionWrapper) SaveBlockExtractData

func (wrapper *TransactionWrapper) SaveBlockExtractData(accountID string, data *openwallet.TxExtractData) error

SaveBlockExtractData 保存区块提取数据

type WalletDBFile

type WalletDBFile WrapperSourceFile

type WalletKeyFile

type WalletKeyFile string

type WalletManager

type WalletManager struct {
	AddressInScanning map[string]string //加入扫描的地址
	// contains filtered or unexported fields
}

WalletManager OpenWallet钱包管理器

func NewWalletManager

func NewWalletManager(config *Config) *WalletManager

NewWalletManager

func (*WalletManager) AddAddressForBlockScan

func (wm *WalletManager) AddAddressForBlockScan(address, sourceKey string) error

AddAddressForBlockScan 添加订阅地址

func (*WalletManager) AddObserver

func (wm *WalletManager) AddObserver(obj NotificationObject)

AddObserver 添加观测者

func (*WalletManager) BlockExtractDataNotify

func (wm *WalletManager) BlockExtractDataNotify(sourceKey string, data *openwallet.TxExtractData) error

BlockExtractDataNotify 区块提取结果通知

func (*WalletManager) BlockScanNotify

func (wm *WalletManager) BlockScanNotify(header *openwallet.BlockHeader) error

blockScanNotify 区块扫描结果通知

func (*WalletManager) ClearAddressForBlockScan

func (wm *WalletManager) ClearAddressForBlockScan() error

ClearAddressForBlockScan 清理订阅扫描的内容

func (*WalletManager) CloseDB

func (wm *WalletManager) CloseDB(appID string) error

CloseDB 关闭应用数据库文件

func (*WalletManager) CreateAddress

func (wm *WalletManager) CreateAddress(appID, walletID string, accountID string, count uint64) ([]*openwallet.Address, error)

CreateAddress

func (*WalletManager) CreateAssetsAccount

func (wm *WalletManager) CreateAssetsAccount(appID, walletID, password string, account *openwallet.AssetsAccount, otherOwnerKeys []string) (*openwallet.AssetsAccount, *openwallet.Address, error)

CreateAssetsAccount

func (*WalletManager) CreateErc20TokenTransaction

func (wm *WalletManager) CreateErc20TokenTransaction(appID, walletID, accountID, amount, address, feeRate, memo,
	contractAddr, tokenName, tokenSymbol string, tokenDecimal uint64) (*openwallet.RawTransaction, error)

func (*WalletManager) CreateQrc20TokenTransaction

func (wm *WalletManager) CreateQrc20TokenTransaction(appID, walletID, accountID, sendAmount, toAddress, feeRate, memo,
	contractAddr, tokenName, tokenSymbol string, tokenDecimal uint64) (*openwallet.RawTransaction, error)

func (*WalletManager) CreateSummaryRawTransactionWithError

func (wm *WalletManager) CreateSummaryRawTransactionWithError(
	appID, walletID, accountID, summaryAddress, minTransfer, retainedBalance, feeRate string,
	start, limit int,
	contract *openwallet.SmartContract,
	feeSupportAccount *openwallet.FeesSupportAccount,
) ([]*openwallet.RawTransactionWithError, error)

CreateSummaryTransaction

func (*WalletManager) CreateSummaryTransaction

func (wm *WalletManager) CreateSummaryTransaction(
	appID, walletID, accountID, summaryAddress, minTransfer, retainedBalance, feeRate string,
	start, limit int,
	contract *openwallet.SmartContract) ([]*openwallet.RawTransaction, error)

CreateSummaryTransaction

func (*WalletManager) CreateTransaction

func (wm *WalletManager) CreateTransaction(appID, walletID, accountID, amount, address, feeRate, memo string, contract *openwallet.SmartContract) (*openwallet.RawTransaction, error)

CreateTransaction

func (*WalletManager) CreateWallet

func (wm *WalletManager) CreateWallet(appID string, wallet *openwallet.Wallet) (*openwallet.Wallet, *hdkeystore.HDKey, error)

CreateWallet 创建钱包

func (*WalletManager) DBFile

func (wm *WalletManager) DBFile(appID string) string

DBFile 应用数据库文件

func (*WalletManager) DeleteRechargesByHeight

func (wm *WalletManager) DeleteRechargesByHeight(height uint64) error

DeleteRechargesByHeight 删除某区块高度的充值记录

func (*WalletManager) FindTradeLog

func (wm *WalletManager) FindTradeLog(appID string, walletID string, offset int, limit int, cols ...interface{}) ([]*openwallet.Transaction, error)

FindTradeLog 获取交易记录

func (*WalletManager) GetAddress

func (wm *WalletManager) GetAddress(appID, walletID, accountID, address string) (*openwallet.Address, error)

GetAddress 获取单个地址信息

func (*WalletManager) GetAddressList

func (wm *WalletManager) GetAddressList(appID, walletID, accountID string, offset, limit int, watchOnly bool) ([]*openwallet.Address, error)

GetAddressList

func (*WalletManager) GetAllTokenBalanceByAccount

func (wm *WalletManager) GetAllTokenBalanceByAccount(appID string, walletID string, accountID string, symbol string) ([]*openwallet.TokenBalance, error)

func (*WalletManager) GetAllTokenBalanceByAddress

func (wm *WalletManager) GetAllTokenBalanceByAddress(appID, accountID string, symbol string, address string) ([]*openwallet.TokenBalance, error)

GetTokenBalanceByAddress 根据地址获取代币余额

func (*WalletManager) GetAssetsAccountBalance

func (wm *WalletManager) GetAssetsAccountBalance(appID, walletID, accountID string) (*openwallet.Balance, error)

GetAssetsAccountBalance 获取账户余额

func (*WalletManager) GetAssetsAccountInfo

func (wm *WalletManager) GetAssetsAccountInfo(appID, walletID, accountID string) (*openwallet.AssetsAccount, error)

GetAssetsAccountInfo

func (*WalletManager) GetAssetsAccountList

func (wm *WalletManager) GetAssetsAccountList(appID, walletID string, offset, limit int) ([]*openwallet.AssetsAccount, error)

GetAssetsAccountList

func (*WalletManager) GetAssetsAccountTokenBalance

func (wm *WalletManager) GetAssetsAccountTokenBalance(appID, walletID, accountID string, contract openwallet.SmartContract) (*openwallet.TokenBalance, error)

GetAssetsAccountTokenBalance 获取账户Token余额

func (*WalletManager) GetBlockList

func (wm *WalletManager) GetBlockList(symbol string) (*openwallet.BlockHeader, uint64, error)

GetBlockList 获取当前区块,(当前区块,全网最大高度)

func (*WalletManager) GetContracts

func (wm *WalletManager) GetContracts(appID string, symbol string, offset int, limit int) ([]*openwallet.SmartContract, int, error)

func (*WalletManager) GetEstimateFeeRate

func (wm *WalletManager) GetEstimateFeeRate(coin openwallet.Coin) (feeRate string, unit string, err error)

GetEstimateFeeRate 获取币种推荐手续费

func (*WalletManager) GetNewBlockHeight

func (wm *WalletManager) GetNewBlockHeight(symbol string) (uint64, uint64, error)

GetNewBlockHeight 获取区块高度,(最新高度,已扫描高度)

func (*WalletManager) GetSourceKeyByAddressForBlockScan

func (wm *WalletManager) GetSourceKeyByAddressForBlockScan(address string) (string, bool)

GetSourceKeyByAddressForBlockScan 获取地址对应的数据源标识

func (*WalletManager) GetTransactionByWxID

func (wm *WalletManager) GetTransactionByWxID(appID, wxID string) (*openwallet.Transaction, error)

GetTransactionByWxID 通过WxID获取交易单

func (*WalletManager) GetTransactions

func (wm *WalletManager) GetTransactions(appID string, offset, limit int, cols ...interface{}) ([]*openwallet.Transaction, error)

GetTransactions

func (*WalletManager) GetTxSpent

func (wm *WalletManager) GetTxSpent(appID string, offset, limit int, cols ...interface{}) ([]*openwallet.TxInput, error)

GetTxSpent

func (*WalletManager) GetTxUnspent

func (wm *WalletManager) GetTxUnspent(appID string, offset, limit int, cols ...interface{}) ([]*openwallet.TxOutPut, error)

GetTxUnspent

func (*WalletManager) GetWalletInfo

func (wm *WalletManager) GetWalletInfo(appID string, walletID string) (*openwallet.Wallet, error)

GetWalletInfo

func (*WalletManager) GetWalletList

func (wm *WalletManager) GetWalletList(appID string, offset, limit int) ([]*openwallet.Wallet, error)

GetWalletList

func (*WalletManager) ImportWatchOnlyAddress

func (wm *WalletManager) ImportWatchOnlyAddress(appID, walletID, accountID string, addresses []*openwallet.Address) error

ImportWatchOnlyAddress

func (*WalletManager) Init

func (wm *WalletManager) Init()

Init 初始化

func (*WalletManager) IsExistAddressForBlockScan

func (wm *WalletManager) IsExistAddressForBlockScan(address string) bool

IsExistAddressForBlockScan 指定地址是否已登记扫描

func (*WalletManager) NewWalletWrapper

func (wm *WalletManager) NewWalletWrapper(appID, walletID string) (*WalletWrapper, error)

NewWalletWrapper 创建App专用的包装器

func (*WalletManager) OpenDB

func (wm *WalletManager) OpenDB(appID string) (*StormDB, error)

OpenDB 打开应用数据库文件

func (*WalletManager) RemoveObserver

func (wm *WalletManager) RemoveObserver(obj NotificationObject)

RemoveObserver 移除观测者

func (*WalletManager) RescanBlockHeight

func (wm *WalletManager) RescanBlockHeight(symbol string, startHeight uint64, endHeight uint64) error

func (*WalletManager) SetRescanBlockHeight

func (wm *WalletManager) SetRescanBlockHeight(symbol string, height uint64) error

SetRescanBlockHeight 重置区块高度起扫描

func (*WalletManager) SignTransaction

func (wm *WalletManager) SignTransaction(appID, walletID, accountID, password string, rawTx *openwallet.RawTransaction) (*openwallet.RawTransaction, error)

SignTransaction

func (*WalletManager) SubmitTransaction

func (wm *WalletManager) SubmitTransaction(appID, walletID, accountID string, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)

SubmitTransaction

func (*WalletManager) VerifyTransaction

func (wm *WalletManager) VerifyTransaction(appID, walletID, accountID string, rawTx *openwallet.RawTransaction) (*openwallet.RawTransaction, error)

VerifyTransaction

type WalletWrapper

type WalletWrapper struct {
	*AppWrapper
	// contains filtered or unexported fields
}

WalletWrapper 钱包包装器,扩展钱包功能

func NewWalletWrapper

func NewWalletWrapper(args ...interface{}) *WalletWrapper

func (*WalletWrapper) CreateAddress

func (wrapper *WalletWrapper) CreateAddress(accountID string, count uint64, decoder openwallet.AddressDecoder, isChange bool, isTestNet bool) ([]*openwallet.Address, error)

CreateAddress 创建地址 @param accountID 指定账户 @param count 创建数量 @param decoder 地址解释器 @param isChange 是否找零地址 @param isTestNet 是否测试网

func (*WalletWrapper) FindTradeLog

func (wrapper *WalletWrapper) FindTradeLog(offset int, limit int, cols ...interface{}) ([]*openwallet.Transaction, error)

FindTradeLog 获取交易记录

func (*WalletWrapper) GetAddress

func (wrapper *WalletWrapper) GetAddress(address string) (*openwallet.Address, error)

GetAddress 通过地址字符串获取地址对象

func (*WalletWrapper) GetAddressExtParam

func (wrapper *WalletWrapper) GetAddressExtParam(address string, key string) (interface{}, error)

获取地址的扩展字段

func (*WalletWrapper) GetAddressList

func (wrapper *WalletWrapper) GetAddressList(offset, limit int, cols ...interface{}) ([]*openwallet.Address, error)

GetAddresses 获取资产账户地址列表

func (*WalletWrapper) GetAssetsAccountByAddress

func (wrapper *WalletWrapper) GetAssetsAccountByAddress(address string) (*openwallet.AssetsAccount, error)

GetAssetsAccountByAddress 通过地址获取资产账户对象

func (*WalletWrapper) GetAssetsAccountInfo

func (wrapper *WalletWrapper) GetAssetsAccountInfo(accountID string) (*openwallet.AssetsAccount, error)

GetAssetsAccountInfo 获取指定账户

func (*WalletWrapper) GetAssetsAccountList

func (wrapper *WalletWrapper) GetAssetsAccountList(offset, limit int, cols ...interface{}) ([]*openwallet.AssetsAccount, error)

GetAssetsAccounts 获取某种区块链的全部资产账户

func (*WalletWrapper) GetAssetsAccountsByWalletID

func (wrapper *WalletWrapper) GetAssetsAccountsByWalletID(walletID string) ([]openwallet.AssetsAccount, error)

GetAssetsAccountsByWalletID 获取钱包所有帐户

func (*WalletWrapper) GetContractById

func (wrapper *WalletWrapper) GetContractById(contractID string) (*openwallet.SmartContract, error)

func (*WalletWrapper) GetContracts

func (wrapper *WalletWrapper) GetContracts(offset int, limit int, cols ...interface{}) ([]*openwallet.SmartContract, int, error)

func (*WalletWrapper) GetContractsBySymbol

func (wrapper *WalletWrapper) GetContractsBySymbol(symbol string) ([]*openwallet.SmartContract, error)

func (*WalletWrapper) GetImportAddressList

func (wrapper *WalletWrapper) GetImportAddressList(offset, limit int, cols ...interface{}) ([]*openwallet.ImportAddress, error)

GetImportAddressList 获取待导入

func (*WalletWrapper) GetSymbolList

func (wrapper *WalletWrapper) GetSymbolList(hasRole, limit, offset int) ([]*Symbol, int, error)

GetSymbolList 获取所有主链

func (*WalletWrapper) GetTransactions

func (wrapper *WalletWrapper) GetTransactions(offset, limit int, cols ...interface{}) ([]*openwallet.Transaction, error)

GetTransactions 获取钱包的交易记录

func (*WalletWrapper) GetTxInputs

func (wrapper *WalletWrapper) GetTxInputs(offset, limit int, cols ...interface{}) ([]*openwallet.TxInput, error)

GetTxInputs 获取钱包的出账记录

func (*WalletWrapper) GetTxOutputs

func (wrapper *WalletWrapper) GetTxOutputs(offset, limit int, cols ...interface{}) ([]*openwallet.TxOutPut, error)

GetTxOutputs 获取钱包的入账记录

func (*WalletWrapper) GetWallet

func (wrapper *WalletWrapper) GetWallet() *openwallet.Wallet

GetWallet 获取钱包

func (*WalletWrapper) GetWalletByID

func (wrapper *WalletWrapper) GetWalletByID(walletID string) (*openwallet.Wallet, error)

GetWalletByID 通过钱包ID获取

func (*WalletWrapper) HDKey

func (wrapper *WalletWrapper) HDKey(password ...string) (*hdkeystore.HDKey, error)

HDKey 获取钱包密钥,需要密码

func (*WalletWrapper) ImportWatchOnlyAddress

func (wrapper *WalletWrapper) ImportWatchOnlyAddress(address ...*openwallet.Address) error

ImportWatchOnlyAddress 导入观测地址

func (*WalletWrapper) SaveAssetsAccount

func (wrapper *WalletWrapper) SaveAssetsAccount(account *openwallet.AssetsAccount) error

SaveAssetsAccount 更新账户信息

func (*WalletWrapper) SetAddressExtParam

func (wrapper *WalletWrapper) SetAddressExtParam(address string, key string, val interface{}) error

设置地址的扩展字段

func (*WalletWrapper) UnlockWallet

func (wrapper *WalletWrapper) UnlockWallet(password string, time time.Duration) error

type Wrapper

type Wrapper struct {
	openwallet.WalletDAIBase
	// contains filtered or unexported fields
}

Wrapper 基于OpenWallet钱包体系模型,专门处理钱包的持久化问题,关系数据查询

func NewWrapper

func NewWrapper(args ...interface{}) *Wrapper

func (*Wrapper) CloseDB

func (wrapper *Wrapper) CloseDB()

CloseDB 关闭数据库

func (*Wrapper) OpenStormDB

func (wrapper *Wrapper) OpenStormDB() (*StormDB, error)

OpenStormDB 打开数据库

func (*Wrapper) SetExternalDB

func (wrapper *Wrapper) SetExternalDB(db *StormDB) error

SetStormDB 设置钱包的应用数据库

type WrapperSourceFile

type WrapperSourceFile string

Jump to

Keyboard shortcuts

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