Documentation
¶
Overview ¶
Package store provides local keystore management for TRON accounts.
Index ¶
- Variables
- func AddressFromAccountName(name string) (string, error)
- func CloseAll()
- func DefaultLocation() string
- func DescribeLocalAccounts()
- func DoesNamedAccountExist(name string) bool
- func FromAccountName(name string) *keystore.KeyStore
- func FromAddress(addr string) *keystore.KeyStore
- func InitConfigDir()
- func LocalAccounts() []string
- func SetDefaultLocation(directory string)
- func SetKeystoreFactory(fn func(string) *keystore.KeyStore)
- func UnlockedKeystore(from, passphrase string) (*keystore.KeyStore, *keystore.Account, error)
- type Store
- func (s *Store) AddressFromAccountName(name string) (string, error)
- func (s *Store) CloseAll()
- func (s *Store) DefaultLocation() string
- func (s *Store) DescribeLocalAccounts()
- func (s *Store) DoesNamedAccountExist(name string) bool
- func (s *Store) Forget(ks *keystore.KeyStore)
- func (s *Store) FromAccountName(name string) *keystore.KeyStore
- func (s *Store) FromAddress(addr string) *keystore.KeyStore
- func (s *Store) InitConfigDir()
- func (s *Store) LocalAccounts() []string
- func (s *Store) SetDefaultLocation(directory string)
- func (s *Store) SetKeystoreFactory(fn func(string) *keystore.KeyStore)
- func (s *Store) UnlockedKeystore(from, passphrase string) (*keystore.KeyStore, *keystore.Account, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoUnlockBadPassphrase is returned when an account cannot be unlocked with the given passphrase. ErrNoUnlockBadPassphrase = fmt.Errorf("could not unlock account with passphrase, perhaps need different phrase") )
Functions ¶
func AddressFromAccountName ¶
AddressFromAccountName returns the Base58 address for the named account, or an error if not found.
func CloseAll ¶ added in v0.24.3
func CloseAll()
CloseAll closes all tracked keystores and resets the factory to production defaults. This is a safety net for test cleanup.
func DefaultLocation ¶
func DefaultLocation() string
DefaultLocation returns the current default keystore directory path.
func DescribeLocalAccounts ¶
func DescribeLocalAccounts()
DescribeLocalAccounts prints all account alias names and their addresses to stdout.
func DoesNamedAccountExist ¶
DoesNamedAccountExist reports whether an account alias with the given name exists locally.
func FromAccountName ¶
FromAccountName returns a KeyStore loaded from the named account's directory.
func FromAddress ¶
FromAddress will return nil if the Base58 string is not found in the imported accounts. Non-matching keystores are closed to prevent goroutine leaks.
func InitConfigDir ¶
func InitConfigDir()
InitConfigDir creates the account keystore directory if it does not exist.
func LocalAccounts ¶
func LocalAccounts() []string
LocalAccounts returns the alias names of all locally stored accounts.
func SetDefaultLocation ¶
func SetDefaultLocation(directory string)
SetDefaultLocation updates the default keystore directory and creates it if needed.
func SetKeystoreFactory ¶ added in v0.24.3
SetKeystoreFactory replaces the function used to create keystores. Pass keystore.ForPathLight in tests for faster key derivation.
Types ¶
type Store ¶ added in v0.26.0
type Store struct {
// contains filtered or unexported fields
}
Store manages keystores for TRON accounts.
func DefaultStoreInstance ¶ added in v0.26.0
func DefaultStoreInstance() *Store
DefaultStoreInstance creates a Store using the default ~/.tronctl directory.
func (*Store) AddressFromAccountName ¶ added in v0.26.0
AddressFromAccountName returns the Base58 address for the named account, or an error if not found.
func (*Store) CloseAll ¶ added in v0.26.0
func (s *Store) CloseAll()
CloseAll closes all tracked keystores and resets the factory to production defaults. This is a safety net for test cleanup.
func (*Store) DefaultLocation ¶ added in v0.26.0
DefaultLocation returns the current default keystore directory path.
func (*Store) DescribeLocalAccounts ¶ added in v0.26.0
func (s *Store) DescribeLocalAccounts()
DescribeLocalAccounts prints all account alias names and their addresses to stdout.
func (*Store) DoesNamedAccountExist ¶ added in v0.26.0
DoesNamedAccountExist reports whether an account alias with the given name exists locally.
func (*Store) Forget ¶ added in v0.26.0
Forget removes a keystore from the tracked set. Call this after closing a keystore obtained via FromAccountName to allow garbage collection.
func (*Store) FromAccountName ¶ added in v0.26.0
FromAccountName returns a KeyStore loaded from the named account's directory.
func (*Store) FromAddress ¶ added in v0.26.0
FromAddress will return nil if the Base58 string is not found in the imported accounts. Non-matching keystores are closed to prevent goroutine leaks.
func (*Store) InitConfigDir ¶ added in v0.26.0
func (s *Store) InitConfigDir()
InitConfigDir creates the account keystore directory if it does not exist.
func (*Store) LocalAccounts ¶ added in v0.26.0
LocalAccounts returns the alias names of all locally stored accounts.
func (*Store) SetDefaultLocation ¶ added in v0.26.0
SetDefaultLocation updates the config directory and creates the account-keys subdirectory if needed.
func (*Store) SetKeystoreFactory ¶ added in v0.26.0
SetKeystoreFactory replaces the function used to create keystores. Pass keystore.ForPathLight in tests for faster key derivation.