utxo

package
v0.0.0-...-7abacdd Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Unlicense Imports: 8 Imported by: 0

Documentation

Overview

Package utxo implements operations related to unspent transaction outputs (UTXO), which allow us to check for the balance of every wallet of the network. When we look for our balance, we only need to find those that can be unlocked with our key.

"Unspent outputs" means that they haven't been referenced in any input, and thus, still belong to the person that received them.

The UTXO set is a cache that is built from all blockchain transactions, so we have to iterate over all of them just once to find an unspent output or an address balance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTx

func NewTx(account *wallet.Account, to string, amount, fee int, set *Set) (*tx.Tx, error)

NewTx creates a new transaction.

Types

type Set

type Set struct {
	Blockchain *block.Chain
}

Set represents a UTXO set and holds all the unspent transaction outputs of an address.

func (*Set) AccountUTXOs

func (s *Set) AccountUTXOs(account *wallet.Account, amount, fee int) (int, []UTXO, error)

AccountUTXOs returns an account's unspent outputs to be used in a new transaction.

It returns an error if the account doesn't have enough funds.

func (*Set) FindUTXOs

func (s *Set) FindUTXOs(pubKeyHash []byte) ([]tx.Output, error)

FindUTXOs finds UTXO for a public key hash.

func (*Set) Reindex

func (s *Set) Reindex() error

Reindex rebuilds the UTXO set.

func (*Set) Update

func (s *Set) Update(block block.Block) error

Update updates the UTXO set with transactions from the block received.

The block is considered to be the tip of a blockchain.

type UTXO

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

UTXO represents an output that has never been part of an input.

Jump to

Keyboard shortcuts

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