wallets

package
v0.0.0-...-ac55fdd Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorNotInitialized is returned when the database buckets are not created correctly
	ErrorNotInitialized = errors.New("database is not initialized")
)

Functions

This section is empty.

Types

type Balance

type Balance struct {
	Confirmed   uint64
	Unconfirmed uint64
	Locked      uint64
}

Balance is an struct to show the user balance

func (*Balance) Marshal

func (b *Balance) Marshal() []byte

Marshal encodes the data to a byte slice

func (*Balance) Unmarshal

func (b *Balance) Unmarshal(mb []byte)

Unmarshal decodes the byte slice to a data struct

type TxDetail

type TxDetail struct {
	Hash chainhash.Hash
}

TxDetail is a transaction that contains user readable data

func (*TxDetail) Marshal

func (t *TxDetail) Marshal() []byte

Marshal encodes the data to a byte slice

func (*TxDetail) Unmarshal

func (t *TxDetail) Unmarshal(b []byte) error

Unmarshal decodes the byte slice to a data struct

type Validator

type Validator struct {
	PubKey [48]byte
}

Validator is a struct that shows the user its validator information

func (*Validator) Marshal

func (v *Validator) Marshal() []byte

Marshal encodes the data to a byte slice

func (*Validator) Unmarshal

func (v *Validator) Unmarshal(b []byte) error

Unmarshal decodes the byte slice to a data struct

type WalletDB

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

WalletDB is a wrapper around a boltdb to store information to disk and track it on memory.

func CreateWallet

func CreateWallet(datapath string, name string, mnemonic, password string) (*WalletDB, error)

CreateWallet creates and loads a new wallet using the password passed

func OpenWallet

func OpenWallet(dbpath string, name string) (*WalletDB, error)

OpenWallet loads the wallet information

func (*WalletDB) AddTx

func (w *WalletDB) AddTx(txd *TxDetail) error

AddTx stores a TxDetail to de memory map and database

func (*WalletDB) AddValidator

func (w *WalletDB) AddValidator(val *Validator) error

AddValidator stores a Validator on the memory map and database

func (*WalletDB) Close

func (w *WalletDB) Close()

Close safely closes the wallet database.

func (*WalletDB) GetAccount

func (w *WalletDB) GetAccount() []byte

GetAccount returns the wallet account public key

func (*WalletDB) GetBalance

func (w *WalletDB) GetBalance() (*Balance, error)

GetBalance returns current loaded balance

func (*WalletDB) GetID

func (w *WalletDB) GetID() uuid.UUID

GetID returns the wallet UUID

func (*WalletDB) GetLastFinalizeHash

func (w *WalletDB) GetLastFinalizeHash() chainhash.Hash

GetLastFinalizeHash returns the last loaded finalized hash

func (*WalletDB) GetLastScanHash

func (w *WalletDB) GetLastScanHash() chainhash.Hash

GetLastScanHash returns the last loaded hash from which the wallet scanned

func (*WalletDB) GetMnemonic

func (w *WalletDB) GetMnemonic() string

GetMnemonic returns the loaded mnemonic phrase

func (*WalletDB) GetNonce

func (w *WalletDB) GetNonce() (uint64, error)

GetNonce returns current loaded nonce

func (*WalletDB) GetPasshash

func (w *WalletDB) GetPasshash() chainhash.Hash

GetPasshash returns the loaded password hash for fast verify password usage

func (*WalletDB) GetTxs

func (w *WalletDB) GetTxs() []*TxDetail

GetTxs returns a slice of TxDetail

func (*WalletDB) GetValidators

func (w *WalletDB) GetValidators() []*Validator

GetValidators returns a slice of Validator

func (*WalletDB) ProcessBlock

func (w *WalletDB) ProcessBlock(block *primitives.Block)

func (*WalletDB) RemoveValidator

func (w *WalletDB) RemoveValidator(pubkey [48]byte) error

RemoveValidator removes a Validator pubkey from the memory map and database

func (*WalletDB) SetBalance

func (w *WalletDB) SetBalance(b *Balance) error

SetBalance stores the balance to the memory and database

func (*WalletDB) SetLastFinalizeHash

func (w *WalletDB) SetLastFinalizeHash(hash chainhash.Hash) error

SetLastFinalizeHash sets the last finalized hash from which the wallet scanned to the memory and database

func (*WalletDB) SetLastScanHash

func (w *WalletDB) SetLastScanHash(hash chainhash.Hash) error

SetLastScanHash sets the last hash from which the wallet scanned to the memory and database

func (*WalletDB) SetNonce

func (w *WalletDB) SetNonce(nonce uint64) error

SetNonce stores the nonce to the memory and the database

type WalletMan

type WalletMan struct {
	Wallets map[uuid.UUID]*WalletDB

	CurrentWallet *WalletDB
	// contains filtered or unexported fields
}

WalletMan is a wallet manager that will track multiple wallets against the chain.

func NewWalletMan

func NewWalletMan(datapath string) (*WalletMan, error)

NewWalletMan creates a new wallets manager for multiple wallets tracking

func (*WalletMan) LoadWallets

func (w *WalletMan) LoadWallets() error

LoadWallets tries to load all files specified on the datapath as wallets and add id to the manager.

func (*WalletMan) NewWallet

func (w *WalletMan) NewWallet(name, mnemonic, password string) error

NewWallet creates a new wallet and add to the manager.

func (*WalletMan) ProcessBlock

func (w *WalletMan) ProcessBlock(block *primitives.Block)

ProcessBlock checks the block information to update all wallets being tracked

func (*WalletMan) SetWallet

func (w *WalletMan) SetWallet(id uuid.UUID) error

SetWallet changes the current usable wallet

Jump to

Keyboard shortcuts

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