Documentation ¶
Index ¶
- func WithConfig(cfg config.Transactions) func(*Transactions)
- func WithEvents(evt *event.Event) func(*Transactions)
- func WithLogs(logs *zap.Logger) func(*Transactions)
- func WithPersistence(p persistenceadapter.Adapter) func(*Transactions)
- type SendBlockInput
- type Transactions
- func (t *Transactions) CoinBaseTx(privKey []byte) *blockchain.Transaction
- func (t *Transactions) FindSpendableOutputs(pubKey []byte, amount *big.Int) (*big.Int, map[string][]int)
- func (t *Transactions) FindUTXO(pubKey []byte) []blockchain.TxOutput
- func (t *Transactions) FindUnspentTransactions(pubKey []byte) []blockchain.Transaction
- func (t *Transactions) FindUserBalance(pubKey []byte) *big.Int
- func (t *Transactions) FindUserTokensReceived(pubKey []byte) *big.Int
- func (t *Transactions) FindUserTokensSend(pubKey []byte) *big.Int
- func (t *Transactions) GetLastBlock() ([]byte, *big.Int, error)
- func (t *Transactions) New(from, to []byte, amount *big.Int) (*blockchain.Transaction, error)
- func (t *Transactions) SendBlock(input transaction.SendBlockInput) error
- func (t *Transactions) WriteBlock(privateKey []byte) (*blockchain.Block, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithPersistence ¶
func WithPersistence(p persistenceadapter.Adapter) func(*Transactions)
WithPersistence
Types ¶
type Transactions ¶
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)