wallet

package
v0.0.0-...-da742fc Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2018 License: MIT Imports: 24 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// SiaClassicgFileExtension is the file extension to be used for siaclassicg files
	SiaClassicgFileExtension = ".siaclassickey"

	// SiaClassicgFileHeader is the header for all siaclassicg files. Do not change. Because siaclassicg was created
	// early in development, compatibility with siaclassicg requires manually handling
	// the headers and version instead of using the persist package.
	SiaClassicgFileHeader = "siaclassicg"

	// SiaClassicgFileVersion is the version number to be used for siaclassicg files
	SiaClassicgFileVersion = "1.0"
)
View Source
const (
	// RespendTimeout records the number of blocks that the wallet will wait
	// before spending an output that has been spent in the past. If the
	// transaction spending the output has not made it to the transaction pool
	// after the limit, the assumption is that it never will.
	RespendTimeout = 40
)

Variables

View Source
var (

	// ErrInconsistentKeys is the error when keyfiles provided are for different addresses
	ErrInconsistentKeys = errors.New("keyfiles provided that are for different addresses")
	// ErrInsufficientKeys is the error when there's not enough keys provided to spend the siaclassicfunds
	ErrInsufficientKeys = errors.New("not enough keys provided to spend the siaclassicfunds")
	// ErrNoKeyfile is the error when no keyfile has been presented
	ErrNoKeyfile = errors.New("no keyfile has been presented")
	// ErrUnknownHeader is the error when file contains wrong header
	ErrUnknownHeader = errors.New("file contains the wrong header")
	// ErrUnknownVersion is the error when the file has an unknown version number
	ErrUnknownVersion = errors.New("file has an unknown version number")
)

Functions

This section is empty.

Types

type Wallet

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

Wallet is an object that tracks balances, creates keys and addresses, manages building and sending transactions.

func New

func New(cs modules.ConsensusSet, tpool modules.TransactionPool, persistDir string) (*Wallet, error)

New creates a new wallet, loading any known addresses from the input file name and then using the file to save in the future. Keys and addresses are not loaded into the wallet during the call to 'new', but rather during the call to 'Unlock'.

func NewCustomWallet

func NewCustomWallet(cs modules.ConsensusSet, tpool modules.TransactionPool, persistDir string, deps modules.Dependencies) (*Wallet, error)

NewCustomWallet creates a new wallet using custom dependencies.

func (*Wallet) AddressTransactions

func (w *Wallet) AddressTransactions(uh types.UnlockHash) (pts []modules.ProcessedTransaction, err error)

AddressTransactions returns all of the wallet transactions associated with a single unlock hash.

func (*Wallet) AddressUnconfirmedTransactions

func (w *Wallet) AddressUnconfirmedTransactions(uh types.UnlockHash) (pts []modules.ProcessedTransaction, err error)

AddressUnconfirmedTransactions returns all of the unconfirmed wallet transactions related to a specific address.

func (*Wallet) AllAddresses

func (w *Wallet) AllAddresses() ([]types.UnlockHash, error)

AllAddresses returns all addresses that the wallet is able to spend from, including unseeded addresses. Addresses are returned sorted in byte-order.

func (*Wallet) AllSeeds

func (w *Wallet) AllSeeds() ([]modules.Seed, error)

AllSeeds returns a list of all seeds known to and used by the wallet.

func (*Wallet) ChangeKey

func (w *Wallet) ChangeKey(masterKey crypto.TwofishKey, newKey crypto.TwofishKey) error

ChangeKey changes the wallet's encryption key from masterKey to newKey.

func (*Wallet) Close

func (w *Wallet) Close() error

Close terminates all ongoing processes involving the wallet, enabling garbage collection.

func (*Wallet) ConfirmedBalance

func (w *Wallet) ConfirmedBalance() (siaclassiccoinBalance types.Currency, siaclassicfundBalance types.Currency, siaclassicfundClaimBalance types.Currency, err error)

ConfirmedBalance returns the balance of the wallet according to all of the confirmed transactions.

func (*Wallet) CreateBackup

func (w *Wallet) CreateBackup(backupFilepath string) error

CreateBackup creates a backup file at the desired filepath.

func (*Wallet) DustThreshold

func (w *Wallet) DustThreshold() (types.Currency, error)

DustThreshold returns the quantity per byte below which a Currency is considered to be Dust.

func (*Wallet) Encrypt

func (w *Wallet) Encrypt(masterKey crypto.TwofishKey) (modules.Seed, error)

Encrypt will create a primary seed for the wallet and encrypt it using masterKey. If masterKey is blank, then the hash of the primary seed will be used instead. The wallet will still be locked after Encrypt is called.

Encrypt can only be called once throughout the life of the wallet, and will return an error on subsequent calls (even after restarting the wallet). To reset the wallet, the wallet files must be moved to a different directory or deleted.

func (*Wallet) Encrypted

func (w *Wallet) Encrypted() (bool, error)

Encrypted returns whether or not the wallet has been encrypted.

func (*Wallet) Height

func (w *Wallet) Height() (types.BlockHeight, error)

Height return the internal processed consensus height of the wallet

func (*Wallet) InitFromSeed

func (w *Wallet) InitFromSeed(masterKey crypto.TwofishKey, seed modules.Seed) error

InitFromSeed functions like Init, but using a specified seed. Unlike Init, the blockchain will be scanned to determine the seed's progress. For this reason, InitFromSeed should not be called until the blockchain is fully synced.

func (*Wallet) Load033xWallet

func (w *Wallet) Load033xWallet(masterKey crypto.TwofishKey, filepath033x string) error

Load033xWallet loads a v0.3.3.x wallet as an unseeded key, such that the funds become spendable to the current wallet.

func (*Wallet) LoadSeed

func (w *Wallet) LoadSeed(masterKey crypto.TwofishKey, seed modules.Seed) error

LoadSeed will track all of the addresses generated by the input seed, reclaiming any funds that were lost due to a deleted file or lost encryption key. An error will be returned if the seed has already been integrated with the wallet.

func (*Wallet) LoadSiaClassicgKeys

func (w *Wallet) LoadSiaClassicgKeys(masterKey crypto.TwofishKey, keyfiles []string) error

LoadSiaClassicgKeys loads a set of siaclassicg-generated keys into the wallet.

func (*Wallet) Lock

func (w *Wallet) Lock() error

Lock will erase all keys from memory and prevent the wallet from spending coins until it is unlocked.

func (*Wallet) NextAddress

func (w *Wallet) NextAddress() (types.UnlockConditions, error)

NextAddress returns an unlock hash that is ready to receive siaclassiccoins or siaclassicfunds. The address is generated using the primary address seed.

func (*Wallet) NextAddresses

func (w *Wallet) NextAddresses(n uint64) ([]types.UnlockConditions, error)

NextAddresses returns n unlock hashes that are ready to receive siaclassiccoins or siaclassicfunds. The addresses are generated using the primary address seed.

Warning: If this function is used to generate large numbers of addresses, those addresses should be used. Otherwise the lookahead might not be able to keep up and multiple wallets with the same seed might desync.

func (*Wallet) PrimarySeed

func (w *Wallet) PrimarySeed() (modules.Seed, uint64, error)

PrimarySeed returns the decrypted primary seed of the wallet, as well as the number of addresses that the seed can be safely used to generate.

func (*Wallet) ProcessConsensusChange

func (w *Wallet) ProcessConsensusChange(cc modules.ConsensusChange)

ProcessConsensusChange parses a consensus change to update the set of confirmed outputs known to the wallet.

func (*Wallet) ReceiveUpdatedUnconfirmedTransactions

func (w *Wallet) ReceiveUpdatedUnconfirmedTransactions(diff *modules.TransactionPoolDiff)

ReceiveUpdatedUnconfirmedTransactions updates the wallet's unconfirmed transaction set.

func (*Wallet) RegisterTransaction

func (w *Wallet) RegisterTransaction(t types.Transaction, parents []types.Transaction) (modules.TransactionBuilder, error)

RegisterTransaction takes a transaction and its parents and returns a modules.TransactionBuilder which can be used to expand the transaction. The most typical call is 'RegisterTransaction(types.Transaction{}, nil)', which registers a new transaction without parents.

func (*Wallet) Rescanning

func (w *Wallet) Rescanning() (bool, error)

Rescanning reports whether the wallet is currently rescanning the blockchain.

func (*Wallet) Reset

func (w *Wallet) Reset() error

Reset will reset the wallet, clearing the database and returning it to the unencrypted state. Reset can only be called on a wallet that has already been encrypted.

func (*Wallet) SendSiaClassiccoins

func (w *Wallet) SendSiaClassiccoins(amount types.Currency, dest types.UnlockHash) (txns []types.Transaction, err error)

SendSiaClassiccoins creates a transaction sending 'amount' to 'dest'. The transaction is submitted to the transaction pool and is also returned.

func (*Wallet) SendSiaClassiccoinsMulti

func (w *Wallet) SendSiaClassiccoinsMulti(outputs []types.SiaClassiccoinOutput) (txns []types.Transaction, err error)

SendSiaClassiccoinsMulti creates a transaction that includes the specified outputs. The transaction is submitted to the transaction pool and is also returned.

func (*Wallet) SendSiaClassicfunds

func (w *Wallet) SendSiaClassicfunds(amount types.Currency, dest types.UnlockHash) (txns []types.Transaction, err error)

SendSiaClassicfunds creates a transaction sending 'amount' to 'dest'. The transaction is submitted to the transaction pool and is also returned.

func (*Wallet) SetSettings

func (w *Wallet) SetSettings(s modules.WalletSettings) error

SetSettings will update the settings for the wallet.

func (*Wallet) Settings

func (w *Wallet) Settings() (modules.WalletSettings, error)

Settings returns the wallet's current settings

func (*Wallet) StartTransaction

func (w *Wallet) StartTransaction() (modules.TransactionBuilder, error)

StartTransaction is a convenience function that calls RegisterTransaction(types.Transaction{}, nil).

func (*Wallet) SweepSeed

func (w *Wallet) SweepSeed(seed modules.Seed) (coins, funds types.Currency, err error)

SweepSeed scans the blockchain for outputs generated from seed and creates a transaction that transfers them to the wallet. Note that this incurs a transaction fee. It returns the total value of the outputs, minus the fee. If only siaclassicfunds were found, the fee is deducted from the wallet.

func (*Wallet) Transaction

func (w *Wallet) Transaction(txid types.TransactionID) (pt modules.ProcessedTransaction, found bool, err error)

Transaction returns the transaction with the given id. 'False' is returned if the transaction does not exist.

func (*Wallet) Transactions

func (w *Wallet) Transactions(startHeight, endHeight types.BlockHeight) (pts []modules.ProcessedTransaction, err error)

Transactions returns all transactions relevant to the wallet that were confirmed in the range [startHeight, endHeight].

func (*Wallet) UnconfirmedBalance

func (w *Wallet) UnconfirmedBalance() (outgoingSiaClassiccoins types.Currency, incomingSiaClassiccoins types.Currency, err error)

UnconfirmedBalance returns the number of outgoing and incoming siaclassiccoins in the unconfirmed transaction set. Refund outputs are included in this reporting.

func (*Wallet) UnconfirmedTransactions

func (w *Wallet) UnconfirmedTransactions() ([]modules.ProcessedTransaction, error)

UnconfirmedTransactions returns the set of unconfirmed transactions that are relevant to the wallet.

func (*Wallet) Unlock

func (w *Wallet) Unlock(masterKey crypto.TwofishKey) error

Unlock will decrypt the wallet seed and load all of the addresses into memory.

func (*Wallet) Unlocked

func (w *Wallet) Unlocked() (bool, error)

Unlocked indicates whether the wallet is locked or unlocked.

Jump to

Keyboard shortcuts

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