wallet

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const DUSK = uint64(100000000)

DUSK is one whole unit of DUSK.

Variables

View Source
var ErrSeedFileExists = fmt.Errorf("wallet seed file already exists")

ErrSeedFileExists is returned if the seed file already exists

Functions

func GenerateDecoys

func GenerateDecoys(numMixins int) []mlsag.PubKeys

GenerateDecoys creates the ring signature

func GenerateInputs

func GenerateInputs(_ byte, db *database.DB, totalAmount int64, key *key.Key) ([]*transactions.Input, int64, error)

GenerateInputs generates inputs

Types

type FetchInputs

type FetchInputs func(netPrefix byte, db *database.DB, totalAmount int64, key *key.Key) ([]*transactions.Input, int64, error)

FetchInputs returns a slice of inputs such that Sum(Inputs)- Sum(Outputs) >= 0 If > 0, then a change address is created for the remaining amount

type SignableTx

type SignableTx interface {
	AddDecoys(numMixins int, f transactions.FetchDecoys) error
	Prove() error
	StandardTx() *transactions.Standard
}

SignableTx is a signable transaction

type TxInChecker

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

TxInChecker contains the necessary information to deduce whether a user has spent a tx. This is just the keyImage.

func NewTxInChecker

func NewTxInChecker(txs []transactions.Transaction) []TxInChecker

NewTxInChecker creates a slice of TXInChecker

type Wallet

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

Wallet encapsulates the wallet Deprecated: use the phoenix wallet

func LoadFromFile

func LoadFromFile(netPrefix byte, db *database.DB, fDecoys transactions.FetchDecoys, fInputs FetchInputs, password string, file string) (*Wallet, error)

LoadFromFile loads a wallet from a .dat file

func LoadFromSeed

func LoadFromSeed(seed []byte, netPrefix byte, db *database.DB, fDecoys transactions.FetchDecoys, fInputs FetchInputs, password string, file string) (*Wallet, error)

LoadFromSeed loads a wallet from the seed

func New

func New(Read func(buf []byte) (n int, err error), netPrefix byte, db *database.DB, fDecoys transactions.FetchDecoys, fInputs FetchInputs, password string, file string) (*Wallet, error)

New creates a wallet instance

func (*Wallet) AddInputs

func (w *Wallet) AddInputs(tx *transactions.Standard) error

AddInputs adds up the total outputs and fee then fetches inputs to consolidate this

func (*Wallet) Balance

func (w *Wallet) Balance() (uint64, uint64, error)

Balance calculates and returns the wallet balance for confirmed transactions

func (*Wallet) CheckUnconfirmedBalance

func (w *Wallet) CheckUnconfirmedBalance(txs []transactions.Transaction) (uint64, error)

CheckUnconfirmedBalance calculates balance including the unconfirmed transactions from a slice of transactions

func (*Wallet) CheckWireBlock

func (w *Wallet) CheckWireBlock(blk block.Block) (uint64, uint64, error)

CheckWireBlock check a block

func (*Wallet) CheckWireBlockReceived

func (w *Wallet) CheckWireBlockReceived(blk block.Block) (uint64, error)

CheckWireBlockReceived checks if the wire block has transactions for this wallet Returns the number of tx's that the receiver received funds in

func (*Wallet) CheckWireBlockSpent

func (w *Wallet) CheckWireBlockSpent(blk block.Block) (uint64, error)

CheckWireBlockSpent checks if the block has any outputs spent by this wallet Returns the number of txs that the sender spent funds in

func (*Wallet) ClearDatabase

func (w *Wallet) ClearDatabase() error

ClearDatabase will remove all info from the database.

func (*Wallet) FetchTxHistory

func (w *Wallet) FetchTxHistory() ([]txrecords.TxRecord, error)

FetchTxHistory will return a slice containing information about all transactions made and received with this wallet.

func (*Wallet) GetSavedHeight

func (w *Wallet) GetSavedHeight() (uint64, error)

GetSavedHeight returns the saved height

func (*Wallet) Keys

func (w *Wallet) Keys() consensuskey.Keys

Keys returns the BLS keys

func (*Wallet) NewBidTx

func (w *Wallet) NewBidTx(fee int64, lockTime uint64, amount ristretto.Scalar) (*transactions.Bid, error)

NewBidTx creates a new bid transaction

func (*Wallet) NewStakeTx

func (w *Wallet) NewStakeTx(fee int64, lockTime uint64, amount ristretto.Scalar) (*transactions.Stake, error)

NewStakeTx creates a new Stake transaction

func (*Wallet) NewStandardTx

func (w *Wallet) NewStandardTx(fee int64) (*transactions.Standard, error)

NewStandardTx creates a new standard transaction

func (*Wallet) PrivateSpend

func (w *Wallet) PrivateSpend() ([]byte, error)

PrivateSpend calls the PrivateSpend method on the keypair

func (*Wallet) PublicAddress

func (w *Wallet) PublicAddress() (string, error)

PublicAddress returns the wallet public address

func (*Wallet) PublicKey

func (w *Wallet) PublicKey() key.PublicKey

PublicKey returns the wallet public key

func (*Wallet) ReconstructK

func (w *Wallet) ReconstructK() (ristretto.Scalar, error)

ReconstructK reconstructs the secret K from a scalar Deprecated: we are not using ristretto anymore as we moved to PLONK on jubjub

func (*Wallet) Sign

func (w *Wallet) Sign(tx SignableTx) error

Sign a transaction

func (*Wallet) UpdateWalletHeight

func (w *Wallet) UpdateWalletHeight(newHeight uint64) error

UpdateWalletHeight update the wallet to the new height

Jump to

Keyboard shortcuts

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