wallet

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWalletDoesNotExists = errors.New("wallet does not exist")
	ErrWalletAlreadyExists = errors.New("a wallet with the same name already exists")
)
View Source
var (
	ErrPubKeyDoesNotExist   = errors.New("public key does not exist")
	ErrPubKeyAlreadyTainted = errors.New("public key is already tainted")
)
View Source
var (
	ErrPubKeyIsTainted = errors.New("public key is tainted")
)

Functions

func CheckSubmitTransactionRequest added in v0.8.0

func CheckSubmitTransactionRequest(req *walletpb.SubmitTransactionRequest) commands.Errors

Types

type Handler

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

func NewHandler

func NewHandler(store Store) *Handler

func (*Handler) CreateWallet

func (h *Handler) CreateWallet(name, passphrase string) error

func (*Handler) GenerateKeyPair added in v0.8.0

func (h *Handler) GenerateKeyPair(name, passphrase string) (KeyPair, error)

func (*Handler) GetPublicKey

func (h *Handler) GetPublicKey(name, pubKey string) (*PublicKey, error)

func (*Handler) GetWalletPath added in v0.8.0

func (h *Handler) GetWalletPath(name string) (string, error)

func (*Handler) ListPublicKeys

func (h *Handler) ListPublicKeys(name string) ([]PublicKey, error)

func (*Handler) LoginWallet

func (h *Handler) LoginWallet(name, passphrase string) error

func (*Handler) LogoutWallet added in v0.8.0

func (h *Handler) LogoutWallet(name string)

func (*Handler) SecureGenerateKeyPair added in v0.8.0

func (h *Handler) SecureGenerateKeyPair(name, passphrase string) (string, error)

func (*Handler) SignAny added in v0.6.5

func (h *Handler) SignAny(name, inputData, pubKey string) ([]byte, error)

func (*Handler) SignTx

func (h *Handler) SignTx(name, tx, pubKey string, blockHeight uint64) (SignedBundle, error)

func (*Handler) SignTxV2 added in v0.8.0

func (h *Handler) SignTxV2(name string, req *walletpb.SubmitTransactionRequest, height uint64) (*commandspb.Transaction, error)

func (*Handler) TaintKey

func (h *Handler) TaintKey(name, pubKey, passphrase string) error

func (*Handler) UpdateMeta

func (h *Handler) UpdateMeta(name, pubKey, passphrase string, meta []Meta) error

func (*Handler) VerifyAny added in v0.8.0

func (h *Handler) VerifyAny(name, inputData, sig, pubKey string) (bool, error)

func (*Handler) WalletExists added in v0.8.0

func (h *Handler) WalletExists(name string) bool

type KeyPair added in v0.8.0

type KeyPair struct {
	Pub       string                    `json:"pub"`
	Priv      string                    `json:"priv,omitempty"`
	Algorithm crypto.SignatureAlgorithm `json:"algo"`
	Tainted   bool                      `json:"tainted"`
	Meta      []Meta                    `json:"meta"`
	// contains filtered or unexported fields
}

func GenKeypair

func GenKeypair(algorithm string) (*KeyPair, error)

func (*KeyPair) DeepCopy added in v0.8.0

func (k *KeyPair) DeepCopy() KeyPair

func (*KeyPair) MarshalJSON added in v0.8.0

func (k *KeyPair) MarshalJSON() ([]byte, error)

func (*KeyPair) Sign added in v0.8.0

func (k *KeyPair) Sign(marshalledData []byte) (*commandspb.Signature, error)

func (*KeyPair) Taint added in v0.8.0

func (k *KeyPair) Taint() error

func (*KeyPair) ToPublicKey added in v0.8.0

func (k *KeyPair) ToPublicKey() *PublicKey

ToPublicKey ensures the sensitive information doesn't leak outside.

func (*KeyPair) UnmarshalJSON added in v0.8.0

func (k *KeyPair) UnmarshalJSON(data []byte) error

type KeyRing added in v0.8.0

type KeyRing []KeyPair

func NewKeyRing added in v0.8.0

func NewKeyRing() KeyRing

func (KeyRing) FindPair added in v0.8.0

func (r KeyRing) FindPair(pubKey string) (KeyPair, error)

func (KeyRing) GetPublicKeys added in v0.8.0

func (r KeyRing) GetPublicKeys() []PublicKey

func (*KeyRing) Upsert added in v0.8.0

func (r *KeyRing) Upsert(pair KeyPair)

type Meta

type Meta struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type PublicKey added in v0.8.0

type PublicKey struct {
	Key       string                    `json:"pub"`
	Algorithm crypto.SignatureAlgorithm `json:"algo"`
	Tainted   bool                      `json:"tainted"`
	Meta      []Meta                    `json:"meta"`
}

type RSAKeys added in v0.8.0

type RSAKeys struct {
	Pub  []byte
	Priv []byte
}

func GenerateRSAKeys added in v0.8.0

func GenerateRSAKeys() (*RSAKeys, error)

type Signature

type Signature struct {
	Sig     []byte `json:"sig"`
	Algo    string `json:"algo"`
	Version uint32 `json:"version"`
}

type SignedBundle

type SignedBundle struct {
	Tx  []byte    `json:"tx"`
	Sig Signature `json:"sig"`
}

func (*SignedBundle) IntoProto

func (s *SignedBundle) IntoProto() *typespb.SignedBundle

func (SignedBundle) MarshalJSON

func (s SignedBundle) MarshalJSON() ([]byte, error)

type Store added in v0.8.0

type Store interface {
	WalletExists(name string) bool
	SaveWallet(w Wallet, passphrase string) error
	GetWallet(name, passphrase string) (Wallet, error)
	GetWalletPath(name string) string
}

Store abstracts the underlying storage for wallet data.

type Wallet

type Wallet struct {
	Owner   string
	KeyRing KeyRing `json:"Keypairs"`
}

func New

func New(owner string) Wallet

func NewWallet added in v0.8.0

func NewWallet(name string) *Wallet

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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