wallet

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WalletRepo  = "keystore"
	KNamePrefix = "wallet-"
)

Variables

View Source
var (
	ErrKeyInfoNotFound = fmt.Errorf("key info not found")
	ErrKeyExists       = fmt.Errorf("key already exists")
)

Functions

func Balance

func Balance(ctx context.Context, client *ethclient.Client, addr string) (string, error)

func Sign

func Sign(privatekey string, msg []byte) ([]byte, error)

Sign takes in signature type, private key and message. Returns a signature for that message.

func ToPublic

func ToPublic(priv string) (string, *ecdsa.PublicKey, error)

ToPublic converts private key to public key

func Verify

func Verify(addr string, signature, dataHash []byte) (bool, error)

Verify verifies signatures

Types

type DiskKeyStore

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

func OpenOrInitKeystore

func OpenOrInitKeystore(p string) (*DiskKeyStore, error)

func (*DiskKeyStore) Delete

func (dks *DiskKeyStore) Delete(key string) error

func (*DiskKeyStore) Get

func (dks *DiskKeyStore) Get(name string) (KeyInfo, error)

Get gets a key out of keystore and returns KeyInfo coresponding to named key

func (*DiskKeyStore) List

func (dks *DiskKeyStore) List() ([]string, error)

List lists all the keys stored in the KeyStore

func (*DiskKeyStore) Put

func (dks *DiskKeyStore) Put(key string, info KeyInfo) error

Put saves key info under given name

type KeyInfo

type KeyInfo struct {
	PrivateKey string
}

KeyInfo is used for storing keys in KeyStore

type KeyStore

type KeyStore interface {
	// List lists all the keys stored in the KeyStore
	List() ([]string, error)
	// Get gets a key out of keystore and returns KeyInfo corresponding to named key
	Get(string) (KeyInfo, error)
	// Put saves a key info under given name
	Put(string, KeyInfo) error
	// Delete removes a key from keystore
	Delete(string) error
}

KeyStore is used for storing secret keys

type LocalWallet

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

func NewWallet

func NewWallet(keystore KeyStore) *LocalWallet

func SetupWallet

func SetupWallet(dir string) (*LocalWallet, error)

func (*LocalWallet) CollateralInfo

func (w *LocalWallet) CollateralInfo(ctx context.Context, chainName string) error

func (*LocalWallet) CollateralSendCmd

func (w *LocalWallet) CollateralSendCmd(ctx context.Context, from, to string, amount string) (string, error)

func (*LocalWallet) CollateralWithdraw

func (w *LocalWallet) CollateralWithdraw(ctx context.Context, chainName string, to string, amount string) (string, error)

func (*LocalWallet) FindKey

func (w *LocalWallet) FindKey(addr string) (*KeyInfo, error)

func (*LocalWallet) WalletCollateral

func (w *LocalWallet) WalletCollateral(ctx context.Context, chainName string, from string, amount string) (string, error)

func (*LocalWallet) WalletDelete

func (w *LocalWallet) WalletDelete(ctx context.Context, addr string) error

func (*LocalWallet) WalletExport

func (w *LocalWallet) WalletExport(ctx context.Context, addr string) (*KeyInfo, error)

func (*LocalWallet) WalletImport

func (w *LocalWallet) WalletImport(ctx context.Context, ki *KeyInfo) (string, error)

func (*LocalWallet) WalletList

func (w *LocalWallet) WalletList(ctx context.Context, chainName string, contractFlag bool) error

func (*LocalWallet) WalletNew

func (w *LocalWallet) WalletNew(ctx context.Context) (string, error)

func (*LocalWallet) WalletSend

func (w *LocalWallet) WalletSend(ctx context.Context, chainName string, from, to string, amount string) (string, error)

func (*LocalWallet) WalletSign

func (w *LocalWallet) WalletSign(ctx context.Context, addr string, msg []byte) (string, error)

func (*LocalWallet) WalletVerify

func (w *LocalWallet) WalletVerify(ctx context.Context, addr string, sigByte []byte, data string) (bool, error)

type Signature

type Signature struct {
	Data []byte
}

Directories

Path Synopsis
contract

Jump to

Keyboard shortcuts

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