utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2019 License: Apache-2.0 Imports: 25 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// General settings
	DataDirFlag = DirectoryFlag{
		Name:  "datadir",
		Usage: "Data directory for the databases and keystore",
		Value: DirectoryString{filepath.Join(os.Getenv("HOME"), ".wallet")},
	}
	KeyStoreDirFlag = DirectoryFlag{
		Name:  "keystore",
		Usage: "Directory for the keystore (default = inside the datadir)",
	}
	PasswordFileFlag = cli.StringFlag{
		Name:  "password",
		Usage: "Password file to use for non-interactive password input",
		Value: "",
	}
	LightKDFFlag = cli.BoolFlag{
		Name:  "lightkdf",
		Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength",
	}
)

Functions

func AccountConfig

func AccountConfig(keystoreDir string) (int, int, string, error)

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf formats a message to standard error and exits the program. The message is also printed to standard output if standard error is redirected to a different file.

func Find

func Find(address string) (accounts.Account, error)

func FindByDir

func FindByDir(address string, keystoreDir string) (accounts.Account, error)

func GetUnlockedKey

func GetUnlockedKey(address string, passphrase string) (accounts.Account, *keystore.Key, error)

func GetUnlockedKeyByDir

func GetUnlockedKeyByDir(address string, passphrase string, keystoreDir string) (accounts.Account, *keystore.Key, error)

func ListAccounts

func ListAccounts(keyStoreDir string) error

func Lock

func Lock(ks *keystore.KeyStore, addr string) error

func MakeAccountManager

func MakeAccountManager(keystoreDir string) (*accounts.Manager, string, error)

func MakeAddress

func MakeAddress(ks *keystore.KeyStore, account string) (accounts.Account, error)

MakeAddress converts an account specified directly as a hex encoded string or a key index in the key store to an internal account representation.

func MakePasswordList

func MakePasswordList(ctx *cli.Context) []string

MakePasswordList reads password lines from the file specified by the global --password flag.

func MigrateFlags

func MigrateFlags(action func(ctx *cli.Context) error) func(*cli.Context) error

MigrateFlags sets the global flag from a local flag when it's set. This is a temporary function used for migrating old command/flags to the new format.

e.g. geth account new --keystore /tmp/mykeystore --lightkdf

is equivalent after calling this method with:

geth --keystore /tmp/mykeystore --lightkdf account new

This allows the use of the existing configuration functionality. When all flags are migrated this function can be removed and the existing configuration functionality must be changed that is uses local flags

func NewAccount

func NewAccount(keyStoreDir string, password string) (common.Address, error)

func NewApp

func NewApp(gitCommit, usage string) *cli.App

func NewWeb3

func NewWeb3(hostname string, port string, verbose bool) (*web3.Web3, error)

func SendRawTransaction

func SendRawTransaction(tx *types.Transaction) (common.Hash, error)

func SendRawTransactionWeb3

func SendRawTransactionWeb3(web *web3.Web3, txBytesStr string) (common.Hash, error)

func SendTransaction

func SendTransaction(tx *types.Transaction) (common.Hash, error)

Send a signed transaction

func SendTransactionWeb3

func SendTransactionWeb3(tx *web3cmn.TransactionRequest) (common.Hash, error)

func SignTx

func SignTx(address string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)

func SignTxByDir

func SignTxByDir(address string, tx *types.Transaction, chainID *big.Int, keystoreDir string, password *string) (*types.Transaction, error)

func SignTxByPassWord

func SignTxByPassWord(tx *types.Transaction, password string) (*types.Transaction, error)

func Unlock

func Unlock(ks *keystore.KeyStore, addr string, passphrase string) error

Types

type DirectoryFlag

type DirectoryFlag struct {
	Name  string
	Value DirectoryString
	Usage string
}

Custom cli.Flag type which expand the received string to an absolute path. e.g. ~/.wallet -> /home/username/.wallet

func (DirectoryFlag) Apply

func (self DirectoryFlag) Apply(set *flag.FlagSet)

called by cli library, grabs variable from environment (if in env) and adds variable to flag set for parsing.

func (DirectoryFlag) GetName

func (self DirectoryFlag) GetName() string

func (DirectoryFlag) String

func (self DirectoryFlag) String() string

type DirectoryString

type DirectoryString struct {
	Value string
}

Custom type which is registered in the flags library which cli uses for argument parsing. This allows us to expand Value to an absolute path when the argument is parsed

func (*DirectoryString) Set

func (self *DirectoryString) Set(value string) error

func (*DirectoryString) String

func (self *DirectoryString) String() string

Jump to

Keyboard shortcuts

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