wallet

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetKeystoreAddress

func GetKeystoreAddress(path string) (string, error)

GetKeystoreAddress gets the address info from a keystore json file

func ReadPassphraseStdin

func ReadPassphraseStdin() (string, error)

ReadPassphraseStdin reads passphrase from stdin without echo passphrase into terminal

Types

type Account

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

Account offers method to operate ecdsa keys stored in a keystore file path

func NewAccountFromFile

func NewAccountFromFile(filePath string) (*Account, error)

NewAccountFromFile create account from file.

func (*Account) Addr

func (acc *Account) Addr() string

Addr return addr

func (*Account) PrivateKey

func (acc *Account) PrivateKey() *crypto.PrivateKey

PrivateKey returns the accounts private key in compressed byte format

func (*Account) PubKeyHash

func (acc *Account) PubKeyHash() []byte

PubKeyHash returns Public Key Hash of the account

func (*Account) PublicKey

func (acc *Account) PublicKey() []byte

PublicKey returns the account's public key in compressed byte format

func (*Account) Sign

func (acc *Account) Sign(messageHash *crypto.HashType) (*crypto.Signature, error)

Sign calculates an ECDSA signature of messageHash using privateKey. returns error if account is locked or sign process failed

func (*Account) UnlockWithPassphrase

func (acc *Account) UnlockWithPassphrase(passphrase string) error

UnlockWithPassphrase unlocks an account and generate its private key

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

func NewWalletManager(path string) (*Manager, error)

NewWalletManager creates a wallet manager from files in the path

func (*Manager) DumpPrivKey

func (wlt *Manager) DumpPrivKey(address, passphrase string) (string, error)

DumpPrivKey returns an account's private key bytes in hex string format

func (*Manager) GetAccount

func (wlt *Manager) GetAccount(pubKeyHash string) (account *Account, exist bool)

GetAccount checks if this Manager contains this public key and returns the related account if it exists

func (*Manager) ListAccounts

func (wlt *Manager) ListAccounts() []*Account

ListAccounts returns all the addresses of keystore files in directory

func (*Manager) NewAccount

func (wlt *Manager) NewAccount(passphrase string) (string, string, error)

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, 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

func (*Manager) Sign

func (wlt *Manager) Sign(msg []byte, pubKeyHash, passphrase string) ([]byte, error)

Sign create signature of message bytes using private key related to input public key

Jump to

Keyboard shortcuts

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