wallet

package
v0.0.0-...-ef514fe Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides a clean interface for creating, saving and deleting Wallets.

func NewClient

func NewClient(opts *Options) *Client

NewClient builds a new Client using cardano-cli as the default connection to the Blockhain.

It uses BadgerDB as the default Wallet storage.

func (*Client) Close

func (c *Client) Close()

Close closes all the resources used by the Client.

func (*Client) CreateWallet

func (c *Client) CreateWallet(name, password string) (*Wallet, string, error)

CreateWallet creates a new Wallet using a secure entropy and password, returning a Wallet with its corresponding 24 word mnemonic

func (*Client) DeleteWallet

func (c *Client) DeleteWallet(id string) error

DeleteWallet removes a Wallet with the given id from the Client's storage.

func (*Client) RestoreWallet

func (c *Client) RestoreWallet(name, password, mnemonic string) (*Wallet, error)

RestoreWallet restores a Wallet from a mnemonic and password.

func (*Client) SaveWallet

func (c *Client) SaveWallet(w *Wallet) error

SaveWallet saves a Wallet in the Client's storage.

func (*Client) Wallet

func (c *Client) Wallet(id string) (*Wallet, error)

Wallet returns a Wallet with the given id from the Client's storage.

func (*Client) Wallets

func (c *Client) Wallets() ([]*Wallet, error)

Wallets returns the list of Wallets currently saved in the Client's storage.

type DB

type DB interface {
	Put(*Wallet) error
	Get() ([]*Wallet, error)
	Delete(string) error
	Close() error
}

type Options

type Options struct {
	Node cardano.Node
	DB   DB
}

type Wallet

type Wallet struct {
	ID   string
	Name string
	// contains filtered or unexported fields
}

func (*Wallet) AddAddress

func (w *Wallet) AddAddress() (cardano.Address, error)

AddAddress generates a new payment address and adds it to the wallet.

func (*Wallet) Addresses

func (w *Wallet) Addresses() ([]cardano.Address, error)

Addresses returns all wallet's addresss.

func (*Wallet) Balance

func (w *Wallet) Balance() (*cardano.Value, error)

Balance returns the total lovelace amount of the wallet.

func (*Wallet) Keys

func (w *Wallet) Keys() (crypto.PrvKey, crypto.PrvKey)

func (*Wallet) Transfer

func (w *Wallet) Transfer(receiver cardano.Address, amount *cardano.Value) (*cardano.Hash32, error)

Transfer sends an amount of lovelace to the receiver address and returns the transaction hash

Jump to

Keyboard shortcuts

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