Documentation ¶
Index ¶
- func BalanceFor(addr string, tid *types.TokenID, db storage.Table) (uint64, error)
- func FetchUtxosOf(addr string, tid *types.TokenID, total uint64, forBalance bool, ...) ([]*rpcpb.Utxo, error)
- func ReadPassphraseStdin() (string, error)
- type Config
- type LiveUtxoCache
- func (cache *LiveUtxoCache) Add(op *types.OutPoint)
- func (cache *LiveUtxoCache) Contains(op *types.OutPoint) bool
- func (cache *LiveUtxoCache) Count() int
- func (cache *LiveUtxoCache) Del(op ...*types.OutPoint)
- func (cache *LiveUtxoCache) SetLiveDuration(expired int)
- func (cache *LiveUtxoCache) Shrink()
- type Manager
- func (wlt *Manager) DumpPrivKey(address, passphrase string) (string, error)
- func (wlt *Manager) GetAccount(pubKeyHash string) (account *acc.Account, exist bool)
- func (wlt *Manager) ListAccounts() []*acc.Account
- func (wlt *Manager) NewAccount(passphrase string) (string, error)
- func (wlt *Manager) NewAccountWithPrivKey(privKey *crypto.PrivateKey, passphrase string) (string, error)
- func (wlt *Manager) Sign(msg []byte, pubKeyHash, passphrase string) ([]byte, error)
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BalanceFor ¶ added in v0.3.0
BalanceFor returns balance amount of an address using balance index
func FetchUtxosOf ¶ added in v0.3.0
func FetchUtxosOf( addr string, tid *types.TokenID, total uint64, forBalance bool, db storage.Table, ) ([]*rpcpb.Utxo, error)
FetchUtxosOf fetches utxos from db NOTE: if total is 0, fetch all utxos NOTE: if tokenID is nil, fetch box utxos
func ReadPassphraseStdin ¶
ReadPassphraseStdin reads passphrase from stdin without echo passphrase into terminal
Types ¶
type Config ¶ added in v0.3.0
type Config struct { Enable bool `mapstructure:"enable"` CacheSize int `mapstructure:"cache_size"` UtxoCacheTime int `mapstructure:"utxo_cache_time"` }
Config contains config information for wallet server
type LiveUtxoCache ¶ added in v0.3.0
type LiveUtxoCache struct { sync.RWMutex Op2ts map[types.OutPoint]int64 // contains filtered or unexported fields }
LiveUtxoCache defines a cache in that utxos keep alive
func NewLiveUtxoCache ¶ added in v0.3.0
func NewLiveUtxoCache() *LiveUtxoCache
NewLiveUtxoCache new a LiveUtxoCache instance with expired seconds
func (*LiveUtxoCache) Add ¶ added in v0.3.0
func (cache *LiveUtxoCache) Add(op *types.OutPoint)
Add adds a OutPoint to cache
func (*LiveUtxoCache) Contains ¶ added in v0.3.0
func (cache *LiveUtxoCache) Contains(op *types.OutPoint) bool
Contains return whether OutPoint is in cache
func (*LiveUtxoCache) Count ¶ added in v0.3.0
func (cache *LiveUtxoCache) Count() int
Count returns OutPoint count
func (*LiveUtxoCache) Del ¶ added in v0.3.0
func (cache *LiveUtxoCache) Del(op ...*types.OutPoint)
Del deletes a OutPoint in cache
func (*LiveUtxoCache) SetLiveDuration ¶ added in v0.3.0
func (cache *LiveUtxoCache) SetLiveDuration(expired int)
SetLiveDuration sets live duration
func (*LiveUtxoCache) Shrink ¶ added in v0.3.0
func (cache *LiveUtxoCache) Shrink()
Shrink shrinks phase out OutPoints
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is a directory based type to manipulate account Operation add/delete/query, import/export and sign are supported
func NewWalletManager ¶
NewWalletManager creates a wallet manager from files in the path
func (*Manager) DumpPrivKey ¶
DumpPrivKey returns an account's private key bytes in hex string format
func (*Manager) GetAccount ¶
GetAccount checks if this Manager contains this public key and returns the related account if it exists
func (*Manager) ListAccounts ¶
ListAccounts returns all the addresses of keystore files in directory
func (*Manager) NewAccount ¶
NewAccount creates a ecdsa key pair and store them in a file encrypted by the passphrase user entered returns a hexstring format public key hash, address and error
func (*Manager) NewAccountWithPrivKey ¶
func (wlt *Manager) NewAccountWithPrivKey(privKey *crypto.PrivateKey, passphrase string) (string, error)
NewAccountWithPrivKey store the give private key in a file encrypted by the passphrase user entered returns a hexstring format public key hash, address and error
type Server ¶ added in v0.3.0
type Server struct {
// contains filtered or unexported fields
}
Server is the struct type of an wallet service
func NewServer ¶ added in v0.3.0
func NewServer(parent goprocess.Process, config *Config, s storage.Storage, bus eventbus.Bus) (*Server, error)
NewServer creates an Server instance using config and storage