transaction

package
v0.9.24 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package transaction contains structs and functions for enabling transaction support. In order to send a transaction navigate your browser to localhost:8087/send-transaction after your node has concluded its initial sync.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TransactionListToMerkleTreeRootHash

func TransactionListToMerkleTreeRootHash(tList []Transaction) hash.Hash

TransactionListToMerkleTreeRootHash takes a slice of transactions, reconstructs the Merkle Tree and returns its root hash

Types

type Transaction

type Transaction struct {
	From      string // libp2p nodeid starts with 12D3Koo... and has length 52 chars
	TxTime    uint64
	To        string
	Value     float64
	Reference string    // sender is allowed to put arbitrary data in reference field (e.g. payment reference number, but could also be used as e.g. timestamping ideas by putting their hash) [length of string is limited to 64 characters]
	TxHash    hash.Hash // serves as unique transaction ID [serialize From,TxTime,To and Value with msgpack, then hash that value]
	Sig       []byte
	Nonce     int     // keeps track how many transactions an account performed in the past (protects against replay attacks)
	Fee       float64 // sender can freely decide how much tokens to burn to have RA prioritize the transaction (pending tx with highest fee will be included next in block), minimum fee is equal to winner.MinTransactionAmount)

}

Transaction contains fields such as From, TxTime, To, Value and txHash. txHash is a unique identifier that is used in Merkle Trees and Proofs.

func NewTransaction

func NewTransaction(from string, txTime uint64, to string, value float64, reference string, nonce int, fee float64, privKey crypto.PrivKey) Transaction

NewTransaction is the constructor function of Transaction. It serializes all fields (except txHash) and then hashes this value to determine txHash.

Jump to

Keyboard shortcuts

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