wallet

package
v0.0.0-...-91a82d4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: LGPL-3.0 Imports: 23 Imported by: 3

README

wallet

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMatch = errors.New("no key for given address or file")
	ErrDecrypt = errors.New("could not decrypt key with given passphrase")
)

Functions

func AesCTRXOR

func AesCTRXOR(key, inText, iv []byte) ([]byte, error)

AesCTRXOR encrypts data with CTRXOR

func EncryptKey

func EncryptKey(account Account, auth string) ([]byte, error)

EncryptKey encrypt the key via auth

Types

type Account

type Account struct {
	Address    utils.Address     `json:"address"`
	PrivateKey *ecdsa.PrivateKey `json:"privatekey,omitempty" `
	FileName   string            `json:"filename"`
}

Account represents an uranus account.

func DecryptKey

func DecryptKey(keyjson []byte, auth string) (*Account, error)

DecryptKey returns the decrypted key via auth

func (Account) Cmp

func (a Account) Cmp(account Account) int

Cmp compares x and y and returns:

-1 if x <  y
 0 if x == y
+1 if x >  y

type Accounts

type Accounts []Account

Accounts is a Account slice type.

func (Accounts) Len

func (as Accounts) Len() int

func (Accounts) Less

func (as Accounts) Less(i, j int) bool

func (Accounts) Swap

func (as Accounts) Swap(i, j int)

type KeyStore

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

KeyStore definition

func NewKeyStore

func NewKeyStore(keydir string) *KeyStore

NewKeyStore new a KeyStore instance

func (KeyStore) GetKey

func (ks KeyStore) GetKey(addr utils.Address, filename, auth string) (*Account, error)

GetKey returns the key by the specified addr

func (KeyStore) JoinPath

func (ks KeyStore) JoinPath(filename string) string

JoinPath returns the abs path of the keystore file

func (KeyStore) PutKey

func (ks KeyStore) PutKey(account Account, path string, auth string) error

PutKey stores the specified key

type Wallet

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

Wallet represents a software wallet.

func NewWallet

func NewWallet(ksdir string) *Wallet

NewWallet initialize wallet.

func (*Wallet) Accounts

func (w *Wallet) Accounts() (Accounts, error)

Accounts list all account.

func (*Wallet) Delete

func (w *Wallet) Delete(account Account, passphrase string) error

Delete removes the speciified account

func (*Wallet) ExportRawKey

func (w *Wallet) ExportRawKey(addr utils.Address, passphrase string) (string, error)

ExportRawKey returns key hex.

func (*Wallet) Find

func (w *Wallet) Find(addr utils.Address, passphrase string) (Account, error)

Find resolves the given account into a unique entry in the keystore.

func (*Wallet) ImportRawKey

func (w *Wallet) ImportRawKey(privkey string, passphrase string) (utils.Address, error)

ImportRawKey import key in to key store.

func (*Wallet) NewAccount

func (w *Wallet) NewAccount(passphrase string) (Account, error)

NewAccount creates a new account

func (*Wallet) SignHash

func (w *Wallet) SignHash(addr utils.Address, passphrase string, hash []byte) ([]byte, error)

SignHash signs hash if the private key matching the given address can be decrypted with the given passphrase.

func (*Wallet) SignTx

func (w *Wallet) SignTx(addr utils.Address, tx *types.Transaction, passphrase string) (*types.Transaction, error)

SignTx sign the specified transaction

func (*Wallet) Update

func (w *Wallet) Update(account Account, passphrase, newPassphrase string) error

Update update the specified account

Jump to

Keyboard shortcuts

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