transaction

package
v0.0.0-...-8e21be9 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Transaction

type Transaction struct {
	// Token data of the transaction.
	TokenHash eocrypt.Hash `json:"TokenHash"`
	Amount    *big.Int     `json:"Amount"`

	// From who and where to?
	To        []byte `json:"To"`
	From      []byte `json:"From"`
	Signature []byte `json:"Signature"`

	// Where are you getting the tokens from?
	BlockFrom []eocrypt.Hash `json:"BlockFromHash"`
	TxFrom    []eocrypt.Hash `json:"TransactionFromHash"`

	// Basic but otherwise needed data.
	ThreadId *big.Int `json:"Thread"`
	Gas      gas.Gas  `json:"Gas"`
	GasPrice *big.Int `json:"GasPrice"`

	// When did the node get this transaction?
	ReceivedTime time.Time `json:"Time"`
}

A Transaction simply represents a token being sent from one party to another (not even the native token).

func Decode

func Decode(b *bytes.Buffer) (*Transaction, error)

Trys to decode the given Bytes Buffer (suppose to be the encoded form by gob). Returns the decoded transaction and any errors.

func DecodeJSON

func DecodeJSON(b *bytes.Buffer) (*Transaction, error)

Trys to decode the given Bytes Buffer (suppose to be encoded JSON form). Returns the decoded transaction and any errors.

func NewTransaction

func NewTransaction(TokenHash eocrypt.Hash, Amount *big.Int, To []byte, From []byte, Signature []byte,
	BlockFrom []eocrypt.Hash, TxFrom []eocrypt.Hash, ChainId *big.Int, Gas gas.Gas, GasPrice big.Int,
	ReceivedTime time.Time) *Transaction

func (*Transaction) BlockFromRoot

func (t *Transaction) BlockFromRoot() *eocrypt.Hash

Gets the merkle root of the block from hashes, aka the block hashes of the blocks you are pointing to in the transaction to show where the token being spent is coming from.

func (*Transaction) EncodeJSON

func (t *Transaction) EncodeJSON() (*bytes.Buffer, error)

Encode the transaction into JSON format. Returns the encoded bytes in a Bytes Buffer.

func (*Transaction) EncodeJSONwithBuff

func (t *Transaction) EncodeJSONwithBuff(b *bytes.Buffer) error

Encode the transaction with the provided Bytes Buffer. The encoded bytes will reside there.

func (*Transaction) EncodeToBuffer

func (t *Transaction) EncodeToBuffer() (*bytes.Buffer, error)

Uses the gob encoder to encode and return the transaction as a Bytes Buffer.

func (*Transaction) EncodeWithBuffer

func (t *Transaction) EncodeWithBuffer(b *bytes.Buffer) error

Uses the gob encoder with a provided Bytes Buffer to encode the transaction into that Buffer.

func (*Transaction) GetAmount

func (t *Transaction) GetAmount() big.Int

func (*Transaction) GetBlockFrom

func (t *Transaction) GetBlockFrom() []eocrypt.Hash

func (*Transaction) GetChainId

func (t *Transaction) GetChainId() big.Int

func (*Transaction) GetFrom

func (t *Transaction) GetFrom() []byte

func (*Transaction) GetGas

func (t *Transaction) GetGas() gas.Gas

func (*Transaction) GetGasPrice

func (t *Transaction) GetGasPrice() big.Int

func (*Transaction) GetReceivedTime

func (t *Transaction) GetReceivedTime() time.Time

func (*Transaction) GetTo

func (t *Transaction) GetTo() []byte

func (*Transaction) GetTokenHash

func (t *Transaction) GetTokenHash() eocrypt.Hash

func (*Transaction) GetTxFrom

func (t *Transaction) GetTxFrom() []eocrypt.Hash

func (*Transaction) Hash

func (t *Transaction) Hash() *eocrypt.Hash

Get the hash of the transaction. Will be whats signed by the transaction sender.

func (*Transaction) Print

func (t *Transaction) Print()

Prints the main important information about the transaction.

func (*Transaction) SetAmount

func (t *Transaction) SetAmount(b big.Int)

func (*Transaction) SetBlockFrom

func (t *Transaction) SetBlockFrom(h []eocrypt.Hash)

func (*Transaction) SetChainId

func (t *Transaction) SetChainId(b big.Int)

func (*Transaction) SetFrom

func (t *Transaction) SetFrom(p []byte)

func (*Transaction) SetGas

func (t *Transaction) SetGas(g gas.Gas)

func (*Transaction) SetGasPrice

func (t *Transaction) SetGasPrice(g big.Int)

func (*Transaction) SetReceivedTime

func (t *Transaction) SetReceivedTime(time time.Time)

func (*Transaction) SetSignature

func (t *Transaction) SetSignature(sig []byte)

func (*Transaction) SetTo

func (t *Transaction) SetTo(p []byte)

func (*Transaction) SetTokenHash

func (t *Transaction) SetTokenHash(h eocrypt.Hash)

func (*Transaction) SetTxFrom

func (t *Transaction) SetTxFrom(h []eocrypt.Hash)

func (*Transaction) TxFromRoot

func (t *Transaction) TxFromRoot() *eocrypt.Hash

Get the merkle root from the tx hashes included in the tx, aka which transaction are you getting the token from.

Jump to

Keyboard shortcuts

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