utxodb

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: Apache-2.0, BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package utxodb mocks Value Tangle ledger by implementing fully synchronous in-memory database of GoShimmer value transactions. It ensures consistency of the ledger validity and all transactions added to the UTXODB by checking inputs, outputs and signatures.

Index

Constants

View Source
const (

	// RequestFundsAmount is how many iotas are returned from the faucet
	RequestFundsAmount = 1000000 // 1Mi
)

Variables

This section is empty.

Functions

This section is empty.

Types

type UtxoDB

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

UtxoDB is the structure which contains all UTXODB transactions and ledger

func New

func New(supply ...uint64) *UtxoDB

New creates new utxodb instance with predefined genesis seed and optional supply. Supply defaults to the standard IOTA supply

func NewRandom

func NewRandom(supply ...uint64) *UtxoDB

NewRandom creates utxodb with random genesis seed

func NewWithTimestamp

func NewWithTimestamp(timestamp time.Time, supply ...uint64) *UtxoDB

func (*UtxoDB) AddTransaction

func (u *UtxoDB) AddTransaction(tx *ledgerstate.Transaction) error

AddTransaction adds transaction to UTXODB or return an error. The function ensures consistency of the UTXODB ledger

func (*UtxoDB) Balance

func (u *UtxoDB) Balance(addr ledgerstate.Address, color ledgerstate.Color) uint64

Balance returns balances of specific color

func (*UtxoDB) BalanceIOTA

func (u *UtxoDB) BalanceIOTA(addr ledgerstate.Address) uint64

BalanceIOTA number of iotas in the address

func (*UtxoDB) CheckNewTransaction

func (u *UtxoDB) CheckNewTransaction(tx *ledgerstate.Transaction, lock ...bool) error

CheckNewTransaction checks consistency of the transaction the same way as ledgerstate

func (*UtxoDB) CollectUnspentOutputsFromInputs

func (u *UtxoDB) CollectUnspentOutputsFromInputs(essence *ledgerstate.TransactionEssence) ([]ledgerstate.Output, error)

CollectUnspentOutputsFromInputs returns unspent outputs by inputs of the transaction

func (*UtxoDB) GenesisTransactionID

func (u *UtxoDB) GenesisTransactionID() ledgerstate.TransactionID

func (*UtxoDB) GetAddressBalances

func (u *UtxoDB) GetAddressBalances(addr ledgerstate.Address) map[ledgerstate.Color]uint64

GetAddressBalances return all colored balances of the address

func (*UtxoDB) GetAddressOutputs

func (u *UtxoDB) GetAddressOutputs(addr ledgerstate.Address) []ledgerstate.Output

GetAddressOutputs returns unspent outputs contained in the address

func (*UtxoDB) GetAliasOutputs

func (u *UtxoDB) GetAliasOutputs(addr ledgerstate.Address) []*ledgerstate.AliasOutput

GetAliasOutputs collects all outputs of type ledgerstate.AliasOutput for the transaction

func (*UtxoDB) GetGenesisAddress

func (u *UtxoDB) GetGenesisAddress() ledgerstate.Address

GetGenesisAddress return address of genesis

func (*UtxoDB) GetGenesisKeyPair

func (u *UtxoDB) GetGenesisKeyPair() *ed25519.KeyPair

GetGenesisKeyPair return signature scheme used by creator of genesis

func (*UtxoDB) GetOutput

func (u *UtxoDB) GetOutput(outID ledgerstate.OutputID, f func(ledgerstate.Output)) bool

GetOutput finds an output by ID (either spent or unspent)

func (*UtxoDB) GetOutputMetadata

func (u *UtxoDB) GetOutputMetadata(outID ledgerstate.OutputID, f func(*ledgerstate.OutputMetadata)) bool

GetOutputMetadata finds an output by ID and returns its (mocked) metadata

func (*UtxoDB) GetTransaction

func (u *UtxoDB) GetTransaction(id ledgerstate.TransactionID) (*ledgerstate.Transaction, bool)

GetTransaction retrieves value transaction by its hash (ID)

func (*UtxoDB) IsConfirmed

func (u *UtxoDB) IsConfirmed(txid *ledgerstate.TransactionID) bool

IsConfirmed checks if the transaction is in the UTXODB ledger

func (*UtxoDB) MustGetTransaction

func (u *UtxoDB) MustGetTransaction(id ledgerstate.TransactionID) *ledgerstate.Transaction

MustGetTransaction same as GetTransaction only panics if transaction is not in UTXODB

func (*UtxoDB) NewKeyPairByIndex

func (u *UtxoDB) NewKeyPairByIndex(index int) (*ed25519.KeyPair, *ledgerstate.ED25519Address)

NewKeyPairByIndex creates key pair and address generated from the seed and the index

func (*UtxoDB) RequestFunds

func (u *UtxoDB) RequestFunds(target ledgerstate.Address, timestamp ...time.Time) (*ledgerstate.Transaction, error)

RequestFunds implements faucet: it sends 1337 IOTA tokens from genesis to the given address.

func (*UtxoDB) Supply

func (u *UtxoDB) Supply() uint64

Supply returns supply of the instance

Jump to

Keyboard shortcuts

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