wallet

package
v0.0.0-...-f7c9202 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppInput

type AppInput struct {
	Command   string
	Address   string
	ToAddress string
	Amount    float64
	NodePort  int
	NodeHost  string
	DataDir   string
	Nodes     []net.NodeAddr
	LogDest   string
}

type Wallet

type Wallet struct {
	PrivateKey ecdsa.PrivateKey
	PublicKey  []byte
}

Wallet stores private and public keys

func (*Wallet) Deserialize

func (w *Wallet) Deserialize(data []byte) error

func (Wallet) GetAddress

func (w Wallet) GetAddress() []byte

GetAddress returns wallet address

func (Wallet) GetPrivateKey

func (w Wallet) GetPrivateKey() ecdsa.PrivateKey

Reurns private key of a wallet

func (Wallet) GetPublicKey

func (w Wallet) GetPublicKey() []byte

Returns public key of a wallet

func (*Wallet) MakeWallet

func (w *Wallet) MakeWallet()

MakeWallet creates Wallet. It generates new keys pair and assign to the object

func (Wallet) Serialize

func (w Wallet) Serialize() ([]byte, error)

func (Wallet) ValidateAddress

func (w Wallet) ValidateAddress(address string) bool

ValidateAddress check if address is valid, has valid format

type WalletBalance

type WalletBalance struct {
	Total    float64
	Approved float64
	Pending  float64
}

type WalletCLI

type WalletCLI struct {
	Input      AppInput
	Node       net.NodeAddr
	DataDir    string
	Nodes      []net.NodeAddr
	NodeCLI    *nodeclient.NodeClient
	WalletsObj *Wallets
	NodeMode   bool
	Logger     *utils.LoggerMan
}

func (*WalletCLI) ExecuteCommand

func (wc *WalletCLI) ExecuteCommand() error

Executes command based on input arguments

func (*WalletCLI) Init

func (wc *WalletCLI) Init(logger *utils.LoggerMan, input AppInput)

Init wallet client object. This will manage execution of tasks related to a wallet

type Wallets

type Wallets struct {
	DataDir string

	Wallets map[string]*Wallet

	Logger *utils.LoggerMan

	WalletsFile string
}

Wallets stores a collection of wallets

func (*Wallets) CreateWallet

func (ws *Wallets) CreateWallet() (string, error)

CreateWallet adds a Wallet to Wallets

func (*Wallets) GetAddresses

func (ws *Wallets) GetAddresses() []string

GetAddresses returns an array of addresses stored in the wallet file

func (Wallets) GetWallet

func (ws Wallets) GetWallet(address string) (Wallet, error)

GetWallet returns a Wallet by its address

func (*Wallets) LoadFromFile

func (ws *Wallets) LoadFromFile() error

LoadFromFile loads wallets from the file

func (Wallets) SaveToFile

func (ws Wallets) SaveToFile() error

SaveToFile saves wallets to a file

type WalletsFile

type WalletsFile struct {
	Wallets map[string]*Wallet
}

Jump to

Keyboard shortcuts

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