fat0

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package fat0 provides data types corresponding to valid FAT-0 entries for Transaction and Issuance as well as methods for validating the structure and content of the factom entry.

Index

Constants

View Source
const Type = fat.Type(0)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressAmountMap

type AddressAmountMap map[factom.FAAddress]uint64

AddressAmountMap relates a factom.FAAddress to its amount for the Inputs and Outputs of a Transaction.

func (AddressAmountMap) MarshalJSON

func (m AddressAmountMap) MarshalJSON() ([]byte, error)

MarshalJSON marshals a list of addresses and amounts used in the inputs or outputs of a transaction. Addresses with a 0 amount are omitted.

func (AddressAmountMap) NoAddressIntersection

func (m AddressAmountMap) NoAddressIntersection(n AddressAmountMap) error

func (AddressAmountMap) Sum

func (m AddressAmountMap) Sum() uint64

Sum returns the sum of all amount values.

func (*AddressAmountMap) UnmarshalJSON

func (m *AddressAmountMap) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a list of addresses and amounts used in the inputs or outputs of a transaction. Duplicate addresses or addresses with a 0 amount cause an error.

type Transaction

type Transaction struct {
	Inputs  AddressAmountMap `json:"inputs"`
	Outputs AddressAmountMap `json:"outputs"`
	fat.Entry
}

Transaction represents a fat0 transaction, which can be a normal account transaction or a coinbase transaction depending on the Inputs and the RCD/signature pair.

func NewTransaction

func NewTransaction(entry factom.Entry) Transaction

NewTransaction returns a Transaction initialized with the given entry.

func (Transaction) IsCoinbase

func (t Transaction) IsCoinbase() bool

IsCoinbase returns true if the coinbase address is in t.Input. This does not necessarily mean that t is a valid coinbase transaction.

func (*Transaction) MarshalEntry

func (t *Transaction) MarshalEntry() error

MarshalEntry marshals the Transaction into the Entry content.

func (Transaction) MarshalJSON

func (t Transaction) MarshalJSON() ([]byte, error)

func (Transaction) String added in v0.5.0

func (t Transaction) String() string

func (*Transaction) UnmarshalEntry

func (t *Transaction) UnmarshalEntry() error

UnmarshalEntry unmarshals the entry content as a Transaction.

func (*Transaction) UnmarshalJSON

func (t *Transaction) UnmarshalJSON(data []byte) error

func (*Transaction) Valid

func (t *Transaction) Valid(idKey factom.IDKey) error

Valid performs all validation checks and returns nil if t is a valid Transaction. If t is a coinbase transaction then idKey is used to validate the RCD. Otherwise RCDs are checked against the input addresses.

func (Transaction) ValidData

func (t Transaction) ValidData() error

ValidData validates the Transaction data and returns nil if no errors are present. ValidData assumes that the entry content has been unmarshaled.

func (Transaction) ValidExtIDs

func (t Transaction) ValidExtIDs() error

ValidExtIDs validates the structure of the external IDs of the entry to make sure that it has the correct number of RCD/signature pairs. ValidExtIDs does not validate the content of the RCD or signature. ValidExtIDs assumes that the entry content has been unmarshaled and that ValidData returns nil.

func (Transaction) ValidRCDs

func (t Transaction) ValidRCDs() bool

Jump to

Keyboard shortcuts

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