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
- type UtxoDB
- func (u *UtxoDB) AddTransaction(tx *ledgerstate.Transaction) error
- func (u *UtxoDB) Balance(addr ledgerstate.Address, color ledgerstate.Color) uint64
- func (u *UtxoDB) BalanceIOTA(addr ledgerstate.Address) uint64
- func (u *UtxoDB) CheckNewTransaction(tx *ledgerstate.Transaction, lock ...bool) error
- func (u *UtxoDB) CollectUnspentOutputsFromInputs(essence *ledgerstate.TransactionEssence) ([]ledgerstate.Output, error)
- func (u *UtxoDB) GenesisTransactionID() ledgerstate.TransactionID
- func (u *UtxoDB) GetAddressBalances(addr ledgerstate.Address) map[ledgerstate.Color]uint64
- func (u *UtxoDB) GetAddressOutputs(addr ledgerstate.Address) []ledgerstate.Output
- func (u *UtxoDB) GetAliasOutputs(addr ledgerstate.Address) []*ledgerstate.AliasOutput
- func (u *UtxoDB) GetGenesisAddress() ledgerstate.Address
- func (u *UtxoDB) GetGenesisKeyPair() *ed25519.KeyPair
- func (u *UtxoDB) GetOutput(outID ledgerstate.OutputID, f func(ledgerstate.Output)) bool
- func (u *UtxoDB) GetOutputMetadata(outID ledgerstate.OutputID, f func(*ledgerstate.OutputMetadata)) bool
- func (u *UtxoDB) GetTransaction(id ledgerstate.TransactionID) (*ledgerstate.Transaction, bool)
- func (u *UtxoDB) IsConfirmed(txid *ledgerstate.TransactionID) bool
- func (u *UtxoDB) MustGetTransaction(id ledgerstate.TransactionID) *ledgerstate.Transaction
- func (u *UtxoDB) NewKeyPairByIndex(index int) (*ed25519.KeyPair, *ledgerstate.ED25519Address)
- func (u *UtxoDB) RequestFunds(target ledgerstate.Address, timestamp ...time.Time) (*ledgerstate.Transaction, error)
- func (u *UtxoDB) Supply() uint64
Constants ¶
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 ¶
New creates new utxodb instance with predefined genesis seed and optional supply. Supply defaults to the standard IOTA supply.
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 ¶
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.