transaction

package
v0.0.0-...-eb21b60 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BaseFee is the minimum pee paid for each transaction
	BaseFee = 2 << 8
	// FeeSizeScalar that scales up with transaction size
	FeeSizeScalar = 2 << 4
	// FeeComplexityScalar that scales up with block complexity
	FeeComplexityScalar = 2 << 6
	// AddressSize is the amount of bytes reserved for an account address
	AddressSize = 32
	// KeyPairSize is the amount of bytes reserved for a key pair proof
	KeyPairSize = 64
	// FeeEpoch is the block epoch size
	FeeEpoch = 64.0
)
View Source
const (
	// TypeCoinbase announces a valid block on the network
	TypeCoinbase uint64 = iota
	// TypeAccount announces the account on the network
	TypeAccount
	// TypeTransfer transfers a specified amount of value from the sender to the receiver
	TypeTransfer
)

Variables

This section is empty.

Functions

func CalculateFee

func CalculateFee(size, complexity uint64) uint64

CalculateFee calculates the fees required for a block of the given size and complexity.

Types

type TX

type TX struct {
	Chain             uint64
	Type              uint64
	Sender, Recipient []byte
	Amount, Fee       uint64
	Timestamp         uint64
	Proof             []byte
	Data              []byte
}

TX is the transaction storage structure

func New

func New() TX

New creates a new empty transaction.

func NewAccount

func NewAccount(chain uint64, priv *account.Private) TX

NewAccount announces a new account on the given chain.

func NewCoinbase

func NewCoinbase(chain uint64, priv *account.Private, amount uint64) TX

NewCoinbase creates a new coinbase on the given chain and miner.

func NewTransfer

func NewTransfer(chain, amount, fee uint64, from *account.Private, to account.Account) TX

NewTransfer creates a new transfer of the given amount of value.

func (TX) Apply

func (tx TX) Apply(addresses *btree.BTree) bool

Apply applies the transaction to the address database.

func (TX) Bytes

func (tx TX) Bytes() []byte

Bytes serializes the transaction to a binary format.

func (TX) Hash

func (tx TX) Hash() []byte

Hash generates a transaction hash from the partial hash and the proof data.

func (TX) PartialHash

func (tx TX) PartialHash() []byte

PartialHash generates a hash excluding the proof data.

func (TX) SetBytes

func (tx TX) SetBytes(b []byte) TX

SetBytes retrieves the transaction from the given binary data.

func (TX) String

func (tx TX) String() string

func (TX) VerifyFees

func (tx TX) VerifyFees(reward, complexity uint64) bool

VerifyFees checks if the fee requirements have been satisfied.

func (TX) VerifyProof

func (tx TX) VerifyProof(addresses *btree.BTree) bool

VerifyProof checks that the transaction has been created with the permission of the sender.

Jump to

Keyboard shortcuts

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