Documentation ¶
Overview ¶
Package fat2 provides data types corresponding to valid FAT-2 entries for PegNet Transactions and Conversions as well as methods for validating the structure and content of the factom entry.
Index ¶
- type AddressAmountTuple
- type PTicker
- type Transaction
- type TransactionBatch
- func (t *TransactionBatch) HasConversions() bool
- func (t *TransactionBatch) HasPEGRequest() bool
- func (t *TransactionBatch) MarshalEntry() error
- func (t TransactionBatch) MarshalJSON() ([]byte, error)
- func (t TransactionBatch) String() string
- func (t *TransactionBatch) UnmarshalEntry() error
- func (t *TransactionBatch) UnmarshalJSON(data []byte) error
- func (t *TransactionBatch) ValidData() error
- func (t TransactionBatch) ValidExtIDs() error
- func (t *TransactionBatch) Validate() error
- type TypedAddressAmountTuple
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressAmountTuple ¶
type AddressAmountTuple struct { Address factom.FAAddress `json:"address"` Amount uint64 `json:"amount"` }
TypedAddressAmountTuple represents a tuple of a Factoid address sending or receiving an Amount of funds of a type that is inferred based on outside context
func (*AddressAmountTuple) UnmarshalJSON ¶
func (t *AddressAmountTuple) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the bytes of JSON into a AddressAmountTuple ensuring that there are no duplicate JSON keys.
type PTicker ¶
type PTicker int
PPTicker is an internal representation of a PegNet asset type
const ( PTickerInvalid PTicker = iota PTickerPEG PTickerUSD PTickerEUR PTickerJPY PTickerGBP PTickerCAD PTickerCHF PTickerINR PTickerSGD PTickerCNY PTickerHKD PTickerKRW PTickerBRL PTickerPHP PTickerMXN PTickerXAU PTickerXAG PTickerXBT PTickerETH PTickerLTC PTickerRVN PTickerXBC PTickerFCT PTickerBNB PTickerXLM PTickerADA PTickerXMR PTickerDASH PTickerZEC PTickerDCR PTickerMax )
func StringToTicker ¶
func (PTicker) MarshalJSON ¶
MarshalJSON marshals the PTicker into the bytes that represent it in JSON
func (*PTicker) UnmarshalJSON ¶
UnmarshalJSON unmarshals the bytes into a PTicker and returns an error if the ticker is invalid
type Transaction ¶
type Transaction struct { Input TypedAddressAmountTuple `json:"input"` Transfers []AddressAmountTuple `json:"transfers,omitempty"` Conversion PTicker `json:"conversion,omitempty"` Metadata interface{} `json:"metadata,omitempty"` }
Transaction represents a fat2 transaction, which can be a value transfer or a conversion depending on present fields
func (*Transaction) IsConversion ¶
func (t *Transaction) IsConversion() bool
IsConversion returns true if this transaction has zero transfers and a valid conversion PTicker
func (*Transaction) IsPEGRequest ¶
func (t *Transaction) IsPEGRequest() bool
IsConversion returns true if this transaction has zero transfers and a valid conversion into PEG
func (*Transaction) UnmarshalJSON ¶
func (t *Transaction) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the bytes of JSON into a Transaction ensuring that there are no duplicate JSON keys.
func (*Transaction) Validate ¶
func (t *Transaction) Validate() error
Validate performs all validation checks and returns nil if t is a valid Transaction
type TransactionBatch ¶
type TransactionBatch struct { Version uint `json:"version"` Transactions []Transaction `json:"transactions"` fat.Entry }
TransactionBatch represents a fat2 entry, which can be a list of one or more transactions to be executed in order
func NewTransactionBatch ¶
func NewTransactionBatch(entry factom.Entry) *TransactionBatch
NewTransactionBatch returns a TransactionBatch initialized with the given entry.
func (*TransactionBatch) HasConversions ¶
func (t *TransactionBatch) HasConversions() bool
HasConversions returns true if this batch contains at least one transaction with a conversion input/output pair. This function assumes that TransactionBatch.Valid() returns nil
func (*TransactionBatch) HasPEGRequest ¶
func (t *TransactionBatch) HasPEGRequest() bool
HasPEGRequest returns if the tx batch has a conversion request into PEG
func (*TransactionBatch) MarshalEntry ¶
func (t *TransactionBatch) MarshalEntry() error
MarshalEntry marshals the TransactionBatch into the entry content
func (TransactionBatch) MarshalJSON ¶
func (t TransactionBatch) MarshalJSON() ([]byte, error)
MarshalJSON marshals the TransactionBatch content field as JSON, but will raise an error if the batch fails the checks in ValidData()
func (TransactionBatch) String ¶
func (t TransactionBatch) String() string
func (*TransactionBatch) UnmarshalEntry ¶
func (t *TransactionBatch) UnmarshalEntry() error
UnmarshalEntry unmarshals the Entry content as a TransactionBatch
func (*TransactionBatch) UnmarshalJSON ¶
func (t *TransactionBatch) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the bytes of JSON into a TransactionBatch ensuring that there are no duplicate JSON keys.
func (*TransactionBatch) ValidData ¶
func (t *TransactionBatch) ValidData() error
ValidData validates all Transaction data included in the batch and returns nil if it is valid. This function assumes that the entry content (or an independent JSON object) has been unmarshaled.
func (TransactionBatch) ValidExtIDs ¶
func (t TransactionBatch) 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. If no errors are found, it will then validate the content of the RCD/signature pair. This function assumes that the entry content has been unmarshaled and that ValidData returns nil.
func (*TransactionBatch) Validate ¶
func (t *TransactionBatch) Validate() error
Validate performs all validation checks and returns nil if it is a valid batch. This function assumes the struct's entry field is populated.
type TypedAddressAmountTuple ¶
type TypedAddressAmountTuple struct { Address factom.FAAddress `json:"address"` Amount uint64 `json:"amount"` Type PTicker `json:"type"` }
TypedAddressAmountTuple represents a 3-tuple of a Factoid address sending or receiving an Amount of funds of a given Type
func (*TypedAddressAmountTuple) UnmarshalJSON ¶
func (t *TypedAddressAmountTuple) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the bytes of JSON into a TypedAddressAmountTuple ensuring that there are no duplicate JSON keys.