transactionrecord

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2016 License: ISC Imports: 10 Imported by: 3

Documentation

Overview

the structure of the transaction records

includes functions to pack/unpack []byte form

Index

Constants

View Source
const (
	// null marks beginning of list - not used as a record type
	NullTag = TagType(iota)

	// valid record type
	BaseDataTag        = TagType(iota)
	AssetDataTag       = TagType(iota)
	BitmarkIssueTag    = TagType(iota)
	BitmarkTransferTag = TagType(iota)

	// this item must be last
	InvalidTag = TagType(iota)
)

enumerate the possible transaction record types this is encoded a Varint64 at start of "Packed"

View Source
const (
	AssetIndexLength = 64
)

limits

Variables

This section is empty.

Functions

func AssetIndexFromBytes

func AssetIndexFromBytes(assetIndex *AssetIndex, buffer []byte) error

convert and validate little endian binary byte slice to a assetIndex

func RecordName

func RecordName(record interface{}) (string, bool)

get the name of a transaction record as a string

Types

type AssetData

type AssetData struct {
	Name        string            `json:"name"`        // utf-8
	Fingerprint string            `json:"fingerprint"` // utf-8
	Metadata    string            `json:"metadata"`    // utf-8
	Registrant  *account.Account  `json:"registrant"`  // base58
	Signature   account.Signature `json:"signature"`   // hex
}

the unpacked Asset Data structure

func (*AssetData) AssetIndex

func (assetData *AssetData) AssetIndex() AssetIndex

compute an asset index

func (*AssetData) Pack

func (assetData *AssetData) Pack(address *account.Account) (Packed, error)

pack AssetData

Pack Varint64(tag) followed by fields in order as struct above with signature last.

Note: the metadata field consists of key value pairs each preceded

by its count (

NOTE: returns the "unsigned" message on signature failure - for

debugging/testing

type AssetIndex

type AssetIndex [AssetIndexLength]byte

the type for an asset index stored as little endian byte array represented as little endian hex text for JSON encoding convert a binary assetIndex to byte slice to get bytes value just use assetIndex[:]

func NewAssetIndex

func NewAssetIndex(record []byte) AssetIndex

create an asset index from a byte slice

SHA3-512 Hash

func (AssetIndex) GoString

func (assetIndex AssetIndex) GoString() string

convert a binary assetIndex to little endian hex string for use by the fmt package (for %#v)

func (AssetIndex) MarshalText

func (assetIndex AssetIndex) MarshalText() ([]byte, error)

convert assetIndex to little endian hex text

func (*AssetIndex) Scan

func (assetIndex *AssetIndex) Scan(state fmt.ScanState, verb rune) error

convert a little endian hex text representation to a assetIndex for use by the format package scan routines

func (AssetIndex) String

func (assetIndex AssetIndex) String() string

convert a binary assetIndex to little endian hex string for use by the fmt package (for %s)

func (*AssetIndex) UnmarshalText

func (assetIndex *AssetIndex) UnmarshalText(s []byte) error

convert little endian hex text into a assetIndex

type BaseData

type BaseData struct {
	Currency       currency.Currency `json:"currency"`       // utf-8 → Enum
	PaymentAddress string            `json:"paymentAddress"` // utf-8
	Owner          *account.Account  `json:"owner"`          // base58
	Nonce          uint64            `json:"nonce,string"`   // unsigned 0..N
	Signature      account.Signature `json:"signature,"`     // hex
}

the unpacked Proofer Data structure

func (*BaseData) Pack

func (baseData *BaseData) Pack(address *account.Account) (Packed, error)

pack BaseData

Pack Varint64(tag) followed by fields in order as struct above with signature last

NOTE: returns the "unsigned" message on signature failure - for

debugging/testing

type BitmarkIssue

type BitmarkIssue struct {
	AssetIndex AssetIndex        `json:"asset"`     // link to asset record
	Owner      *account.Account  `json:"owner"`     // base58: the "destination" owner
	Nonce      uint64            `json:"nonce"`     // to allow for multiple issues at the same time
	Signature  account.Signature `json:"signature"` // hex: corresponds to owner in linked record
}

the unpacked BitmarkIssue structure

func (*BitmarkIssue) Pack

func (issue *BitmarkIssue) Pack(address *account.Account) (Packed, error)

pack BitmarkIssue

Pack Varint64(tag) followed by fields in order as struct above with signature last

NOTE: returns the "unsigned" message on signature failure - for

debugging/testing

type BitmarkTransfer

type BitmarkTransfer struct {
	Link      merkle.Digest     `json:"link"`      // previous record
	Payment   *Payment          `json:"payment"`   // optional payment address
	Owner     *account.Account  `json:"owner"`     // base58: the "destination" owner
	Signature account.Signature `json:"signature"` // hex: corresponds to owner in linked record
}

the unpacked BitmarkTransfer structure

func (*BitmarkTransfer) Pack

func (transfer *BitmarkTransfer) Pack(address *account.Account) (Packed, error)

local function to pack BitmarkTransfer

Pack Varint64(tag) followed by fields in order as struct above with signature last

NOTE: returns the "unsigned" message on signature failure - for

debugging/testing

type Packed

type Packed []byte

packed records are just a byte slice

func (p Packed) MakeLink() merkle.Digest

Create an link for a packed record

func (Packed) MarshalText

func (p Packed) MarshalText() ([]byte, error)

convert a packed to its hex JSON form

func (Packed) Type

func (record Packed) Type() TagType

determine the record type code

func (Packed) Unpack

func (record Packed) Unpack() (Transaction, int, error)

turn a byte slice into a record

must cast result to correct type

e.g.

registration, ok := result.(*transaction.Registration)

or:

switch tx := result.(type) {
case *transaction.Registration:

type Payment

type Payment struct {
	Currency currency.Currency `json:"currency"`      // utf-8 → Enum
	Address  string            `json:"address"`       // utf-8
	Amount   uint64            `json:"amount,string"` // number as string, in terms of smallest currency unit
}

optional payment record

type TagType

type TagType uint64

type Transaction

type Transaction interface {
	Pack(account *account.Account) (Packed, error)
}

generic transaction interface

Jump to

Keyboard shortcuts

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