utxo

package
v0.0.0-...-c9d2d86 Latest Latest
Warning

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

Go to latest
Published: May 25, 2018 License: ISC Imports: 1 Imported by: 0

Documentation

Overview

Copyright (C) 2017, Zipper Team. All rights reserved.

This file is part of zipper

The zipper is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The zipper is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

type Hash [32]byte

type UtxoEntry

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

UtxoEntry contains contextual information about an unspent transaction such as which block it was found in, and the spent status of its outputs.

func (*UtxoEntry) AddressByIndex

func (entry *UtxoEntry) AddressByIndex(outputIndex int32) []byte

AddressByIndex returns the public key script for the provided output index.

Returns nil if the output index references an output that does not exist either due to it being invalid or because the output is not part of the view due to previously being spent/pruned.

func (*UtxoEntry) AmountByIndex

func (entry *UtxoEntry) AmountByIndex(outputIndex int32) int64

AmountByIndex returns the amount of the provided output index.

Returns 0 if the output index references an output that does not exist either due to it being invalid or because the output is not part of the view due to previously being spent/pruned.

func (*UtxoEntry) AssetByIndex

func (entry *UtxoEntry) AssetByIndex(outputIndex int32) int32

AssetByIndex returns the amount of the provided output index.

Returns 0 if the output index references an output that does not exist either due to it being invalid or because the output is not part of the view due to previously being spent/pruned.

func (*UtxoEntry) BlockHeight

func (entry *UtxoEntry) BlockHeight() int32

BlockHeight returns the height of the block containing the transaction the utxo entry represents.

func (*UtxoEntry) IsFullySpent

func (entry *UtxoEntry) IsFullySpent() bool

IsFullySpent returns whether or not the transaction the utxo entry represents is fully spent.

func (*UtxoEntry) IsOutputSpent

func (entry *UtxoEntry) IsOutputSpent(outputIndex int32) bool

IsOutputSpent returns whether or not the provided output index has been spent based upon the current state of the unspent transaction output view the entry was obtained from.

Returns true if the output index references an output that does not exist either due to it being invalid or because the output is not part of the view due to previously being spent/pruned.

func (*UtxoEntry) SpendOutput

func (entry *UtxoEntry) SpendOutput(outputIndex int32)

SpendOutput marks the output at the provided index as spent. Specifying an output index that does not exist will not have any effect.

func (*UtxoEntry) UnspendOutput

func (entry *UtxoEntry) UnspendOutput(outputIndex int32)

UnspendOutput marks the output at the provided index as unspent. Specifying an output index that does not exist will not have any effect.

func (*UtxoEntry) Version

func (entry *UtxoEntry) Version() int32

Version returns the version of the transaction the utxo represents.

type UtxoViewpoint

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

UtxoViewpoint represents a view into the set of unspent transaction outputs from a specific point of view in the chain. For example, it could be for the end of the main chain, some point in the history of the main chain, or down a side chain.

The unspent outputs are needed by other transactions for things such as script validation and double spend prevention.

func NewUtxoViewpoint

func NewUtxoViewpoint() *UtxoViewpoint

NewUtxoViewpoint returns a new empty unspent transaction output view.

func (*UtxoViewpoint) AddTxOuts

func (view *UtxoViewpoint) AddTxOuts(tx *proto.Transaction, blockHeight int32)

AddTxOuts adds all outputs in the passed transaction which are not provably unspendable to the view. When the view already has entries for any of the outputs, they are simply marked unspent. All fields will be updated for existing entries since it's possible it has changed during a reorg.

func (*UtxoViewpoint) Entries

func (view *UtxoViewpoint) Entries() map[Hash]*UtxoEntry

Entries returns the underlying map that stores of all the utxo entries.

func (*UtxoViewpoint) LookupEntry

func (view *UtxoViewpoint) LookupEntry(txHash *Hash) *UtxoEntry

LookupEntry returns information about a given transaction according to the current state of the view. It will return nil if the passed transaction hash does not exist in the view or is otherwise not available such as when it has been disconnected during a reorg.

Jump to

Keyboard shortcuts

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