transaction

package
v0.0.0-...-bc1f52c Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithConfig

func WithConfig(cfg config.Transactions) func(*Transactions)

WithConfig

func WithEvents

func WithEvents(evt *event.Event) func(*Transactions)

WithEvents

func WithLogs

func WithLogs(logs *zap.Logger) func(*Transactions)

WithLogs

func WithPersistence

func WithPersistence(p persistenceadapter.Adapter) func(*Transactions)

WithPersistence

Types

type SendBlockInput

type SendBlockInput struct {
	From   []byte
	To     []byte
	Amount *big.Int
}

type Transactions

type Transactions struct {
	Reward *big.Int
	// contains filtered or unexported fields
}

Transactions represent a transactions adapter.

func New

func New(options ...func(*Transactions)) *Transactions

New define a new transaction adapter.

func (*Transactions) CoinBaseTx

func (t *Transactions) CoinBaseTx(privKey []byte) *blockchain.Transaction

CoinBaseTx is the function that will run when someone on a node succesfully "mines" a block. The reward inside as it were.

func (*Transactions) FindSpendableOutputs

func (t *Transactions) FindSpendableOutputs(pubKey []byte, amount *big.Int) (*big.Int, map[string][]int)

FindSpendableOutputs takes the address of an account and the amount we would like to spend. It returns a tuple that contains the amount we can spend and a map of the aggregate outputs that can get there.

func (*Transactions) FindUTXO

func (t *Transactions) FindUTXO(pubKey []byte) []blockchain.TxOutput

FindUTXO allow to find all unspent transactions, we can search for unspent outputs. Go through all the unspent transactions and see if we can unlock the outputs. Add them all to an array and return that array of TxOutputs.

func (*Transactions) FindUnspentTransactions

func (t *Transactions) FindUnspentTransactions(pubKey []byte) []blockchain.Transaction

FindUnspentTransactions allows to find all unspent transactions linked to a user.

func (*Transactions) FindUserBalance

func (t *Transactions) FindUserBalance(pubKey []byte) *big.Int

FindUserBalance retrieve a user balance.

func (*Transactions) FindUserTokensReceived

func (t *Transactions) FindUserTokensReceived(pubKey []byte) *big.Int

FindUserTokensReceived allows to find the tokens received by a user.

func (*Transactions) FindUserTokensSend

func (t *Transactions) FindUserTokensSend(pubKey []byte) *big.Int

FindUserTokensSend allows to find the tokens sent by a user.

func (*Transactions) GetLastBlock

func (t *Transactions) GetLastBlock() ([]byte, *big.Int, error)

func (*Transactions) New

func (t *Transactions) New(from, to []byte, amount *big.Int) (*blockchain.Transaction, error)

New instantiate a new transaction. from privkey to publickey

func (*Transactions) SendBlock

func (t *Transactions) SendBlock(input transaction.SendBlockInput) error

func (*Transactions) WriteBlock

func (t *Transactions) WriteBlock(privateKey []byte) (*blockchain.Block, error)

Jump to

Keyboard shortcuts

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