account

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCreateAccountCmd

func NewCreateAccountCmd(option common.Options) *cobra.Command

NewCreateAccountCmd creates a new Cobra command for creating a new account with the given options. It returns the created command.

func NewDeleteAccountCmd

func NewDeleteAccountCmd(option common.Options) *cobra.Command

NewDeleteAccountCmd returns a new cobra command for deleting an account. option is used to pass in common.Options.

func NewGetAccountCmd

func NewGetAccountCmd(option common.Options) *cobra.Command

NewGetAccountCmd creates a new Cobra command for displaying account information according to wallet path.

Types

type Account

type Account struct {
	Address    string `json:"address"`
	PrivateKey []byte `json:"privKey"`
	// contains filtered or unexported fields
}

Account represents a user account with an address and private key

func NewAccount

func NewAccount() (*Account, error)

NewAccount generates a new account with a new public-private key pair Returns a new account and an error if the key generation fails

func (*Account) GenerateAndSignMessage

func (account *Account) GenerateAndSignMessage(nonce uint64, args ...string) (string, error)

GenerateAndSignMessage generates a context.Message and signs it with the account's signer. args is a variadic parameter that can take multiple strings. Returns the base64-encoded string representation of the message and an error, if any.

type AccountPrinter

type AccountPrinter string

func (AccountPrinter) GetByHeader

func (a AccountPrinter) GetByHeader(h string) string

type IWallet

type IWallet interface {
	StoreAccount(*Account) error
	GetAccount(string) (*Account, error)
	ListAccounts() ([]string, error)
	DeleteAccounts(...string) error
}

type LocalWallet

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

func NewLocalWallet

func NewLocalWallet(home string) (LocalWallet, error)

NewLocalWallet creates a new LocalWallet instance with the given home directory. If the directory does not exist, it will be created. The function returns a LocalWallet instance and an error if the directory creation fails.

func (*LocalWallet) DeleteAccounts

func (localWallet *LocalWallet) DeleteAccounts(accAddrs ...string) error

DeleteAccounts deletes the accounts with the given addresses from the local wallet.

func (*LocalWallet) GetAccount

func (localWallet *LocalWallet) GetAccount(accAddr string) (*Account, error)

GetAccount retrieves an account by its address.

func (*LocalWallet) ListAccounts

func (localWallet *LocalWallet) ListAccounts() ([]string, error)

ListAccounts returns a slice of account addresses stored in the local wallet directory. Each account address is represented as a string. An error is returned if the directory cannot be read.

func (*LocalWallet) StoreAccount

func (localWallet *LocalWallet) StoreAccount(account *Account) error

StoreAccount stores the account information in a file with the address as the filename

Jump to

Keyboard shortcuts

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