transactionrecord

package
v0.15.7 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: ISC Imports: 10 Imported by: 3

Documentation

Overview

Package transactionrecord - 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 types
	// OBSOLETE items must still be supported to process older blocks
	BaseDataTag                     = TagType(iota) // OBSOLETE: block owner
	AssetDataTag                    = TagType(iota) // create asset
	BitmarkIssueTag                 = TagType(iota) // issue asset
	BitmarkTransferUnratifiedTag    = TagType(iota) // single signed transfer
	BitmarkTransferCountersignedTag = TagType(iota) // two signature transfer
	BlockFoundationTag              = TagType(iota) // block owner
	BlockOwnerTransferTag           = TagType(iota) // block owner transfer
	BitmarkShareTag                 = TagType(iota) // convert bitmark to a quantity of shares
	ShareGrantTag                   = TagType(iota) // grant some value to another account
	ShareSwapTag                    = TagType(iota) // atomically swap shares between accounts

	// 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 (
	AssetIdentifierLength = 64
)

limits

View Source
const (
	FoundationVersion = 1
)

currently supported block foundation version (used by proofer)

Variables

This section is empty.

Functions

func AssetIdentifierFromBytes added in v0.8.0

func AssetIdentifierFromBytes(assetId *AssetIdentifier, buffer []byte) error

AssetIdentifierFromBytes - convert and validate little endian binary byte slice to a assetId

func CheckPayments added in v0.7.0

func CheckPayments(version uint64, testnet bool, payments currency.Map) error

CheckPayments - check all currency addresses for correct network and validity

func RecordName

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

RecordName - returns 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
}

AssetData - the unpacked Asset Data structure

func (*AssetData) AssetId added in v0.8.0

func (assetData *AssetData) AssetId() AssetIdentifier

AssetId - compute an asset id

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 AssetIdentifier added in v0.8.0

type AssetIdentifier [AssetIdentifierLength]byte

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

func NewAssetIdentifier added in v0.8.0

func NewAssetIdentifier(record []byte) AssetIdentifier

NewAssetIdentifier - create an asset id from a byte slice

SHA3-512 Hash

func (AssetIdentifier) GoString added in v0.8.0

func (assetId AssetIdentifier) GoString() string

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

func (AssetIdentifier) MarshalText added in v0.8.0

func (assetId AssetIdentifier) MarshalText() ([]byte, error)

MarshalText - convert assetId to little endian hex text

func (*AssetIdentifier) Scan added in v0.8.0

func (assetId *AssetIdentifier) Scan(state fmt.ScanState, verb rune) error

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

func (AssetIdentifier) String added in v0.8.0

func (assetId AssetIdentifier) String() string

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

func (*AssetIdentifier) UnmarshalText added in v0.8.0

func (assetId *AssetIdentifier) UnmarshalText(s []byte) error

UnmarshalText - convert little endian hex text into a assetId

type BitmarkIssue

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

BitmarkIssue - 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 BitmarkShare added in v0.10.0

type BitmarkShare struct {
	Link      merkle.Digest     `json:"link"`            // previous record
	Quantity  uint64            `json:"quantity,string"` // initial balance quantity
	Signature account.Signature `json:"signature"`       // hex
}

BitmarkShare - turn a bitmark provenance chain into a fungible share

func (*BitmarkShare) GetCountersignature added in v0.10.0

func (share *BitmarkShare) GetCountersignature() account.Signature

func (*BitmarkShare) GetCurrencies added in v0.10.0

func (share *BitmarkShare) GetCurrencies() currency.Map
func (share *BitmarkShare) GetLink() merkle.Digest

func (*BitmarkShare) GetOwner added in v0.10.0

func (share *BitmarkShare) GetOwner() *account.Account

func (*BitmarkShare) GetPayment added in v0.10.0

func (share *BitmarkShare) GetPayment() *Payment

func (*BitmarkShare) GetSignature added in v0.10.0

func (share *BitmarkShare) GetSignature() account.Signature

func (*BitmarkShare) Pack added in v0.10.0

func (share *BitmarkShare) Pack(address *account.Account) (Packed, error)

Pack - BitmarkShare

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 interface {
	Transaction
	GetLink() merkle.Digest
	GetPayment() *Payment
	GetOwner() *account.Account
	GetCurrencies() currency.Map
	GetSignature() account.Signature
	GetCountersignature() account.Signature
}

BitmarkTransfer - to access field of various transfer types

type BitmarkTransferCountersigned added in v0.6.7

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

BitmarkTransferCountersigned - the unpacked Countersigned BitmarkTransfer structure

func (*BitmarkTransferCountersigned) GetCountersignature added in v0.6.8

func (transfer *BitmarkTransferCountersigned) GetCountersignature() account.Signature

func (*BitmarkTransferCountersigned) GetCurrencies added in v0.7.0

func (transfer *BitmarkTransferCountersigned) GetCurrencies() currency.Map
func (transfer *BitmarkTransferCountersigned) GetLink() merkle.Digest

func (*BitmarkTransferCountersigned) GetOwner added in v0.6.7

func (transfer *BitmarkTransferCountersigned) GetOwner() *account.Account

func (*BitmarkTransferCountersigned) GetPayment added in v0.6.7

func (transfer *BitmarkTransferCountersigned) GetPayment() *Payment

func (*BitmarkTransferCountersigned) GetSignature added in v0.6.8

func (transfer *BitmarkTransferCountersigned) GetSignature() account.Signature

func (*BitmarkTransferCountersigned) Pack added in v0.6.7

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

Pack - BitmarkTransferCountersigned

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 BitmarkTransferUnratified added in v0.6.7

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

BitmarkTransferUnratified - the unpacked BitmarkTransfer structure

func (*BitmarkTransferUnratified) GetCountersignature added in v0.6.8

func (transfer *BitmarkTransferUnratified) GetCountersignature() account.Signature

func (*BitmarkTransferUnratified) GetCurrencies added in v0.7.0

func (transfer *BitmarkTransferUnratified) GetCurrencies() currency.Map
func (transfer *BitmarkTransferUnratified) GetLink() merkle.Digest

func (*BitmarkTransferUnratified) GetOwner added in v0.6.7

func (transfer *BitmarkTransferUnratified) GetOwner() *account.Account

func (*BitmarkTransferUnratified) GetPayment added in v0.6.7

func (transfer *BitmarkTransferUnratified) GetPayment() *Payment

func (*BitmarkTransferUnratified) GetSignature added in v0.6.8

func (transfer *BitmarkTransferUnratified) GetSignature() account.Signature

func (*BitmarkTransferUnratified) Pack added in v0.6.7

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

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 BlockFoundation added in v0.7.0

type BlockFoundation struct {
	Version   uint64            `json:"version,string"` // reflects combination of supported currencies
	Payments  currency.Map      `json:"payments"`       // contents depend on version
	Owner     *account.Account  `json:"owner"`          // base58
	Nonce     uint64            `json:"nonce,string"`   // unsigned 0..N
	Signature account.Signature `json:"signature"`      // hex
}

BlockFoundation - the unpacked Proofer Data structure this is first tx in every block and can only be used there

func (*BlockFoundation) Pack added in v0.7.0

func (foundation *BlockFoundation) Pack(address *account.Account) (Packed, error)

Pack - BlockFoundation

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 BlockOwnerTransfer added in v0.7.0

type BlockOwnerTransfer struct {
	Link             merkle.Digest     `json:"link"`             // previous record
	Escrow           *Payment          `json:"escrow"`           // optional escrow payment address
	Version          uint64            `json:"version,string"`   // reflects combination of supported currencies
	Payments         currency.Map      `json:"payments"`         // require length and contents depend on version
	Owner            *account.Account  `json:"owner"`            // base58
	Signature        account.Signature `json:"signature"`        // hex
	Countersignature account.Signature `json:"countersignature"` // hex: corresponds to owner in this record
}

BlockOwnerTransfer - the unpacked Block Owner Transfer Data structure forms a chain that links back to a foundation record which has a TxId of: SHA3-256 . concat blockDigest leBlockNumberUint64

func (*BlockOwnerTransfer) GetCountersignature added in v0.7.0

func (transfer *BlockOwnerTransfer) GetCountersignature() account.Signature

func (*BlockOwnerTransfer) GetCurrencies added in v0.7.0

func (transfer *BlockOwnerTransfer) GetCurrencies() currency.Map
func (transfer *BlockOwnerTransfer) GetLink() merkle.Digest

func (*BlockOwnerTransfer) GetOwner added in v0.7.0

func (transfer *BlockOwnerTransfer) GetOwner() *account.Account

func (*BlockOwnerTransfer) GetPayment added in v0.7.0

func (transfer *BlockOwnerTransfer) GetPayment() *Payment

func (*BlockOwnerTransfer) GetSignature added in v0.7.0

func (transfer *BlockOwnerTransfer) GetSignature() account.Signature

func (*BlockOwnerTransfer) Pack added in v0.7.0

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

Pack - BlockOwnerTransfer

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 OldBaseData added in v0.7.0

type OldBaseData 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
}

OldBaseData - the unpacked Proofer Data structure (OBSOLETE) this is first tx in every block and can only be used there

func (*OldBaseData) Pack added in v0.7.0

func (baseData *OldBaseData) 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 Packed

type Packed []byte

Packed - packed records are just a byte slice

func (record Packed) MakeLink() merkle.Digest

MakeLink - Create an link for a packed record

func (Packed) MarshalText

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

MarshalText - convert a packed to its hex JSON form

func (Packed) Type

func (record Packed) Type() TagType

Type - returns the record type code

func (*Packed) UnmarshalText added in v0.5.7

func (record *Packed) UnmarshalText(s []byte) error

UnmarshalText - convert a packed to its hex JSON form

func (Packed) Unpack

func (record Packed) Unpack(testnet bool) (t Transaction, n int, e error)

Unpack - turn a byte slice into a record Note: the unpacker will access the underlying array of the packed

record so p[x:y].Unpack() can read past p[y] and couldcontinue up to cap(p)
i.e p[x:cap(p)].Unpack() performs the same operation
elements beefore p[x] cannot be accessed
see: https://blog.golang.org/go-slices-usage-and-internals

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
}

Payment - optional payment record

type PaymentAlternative added in v0.5.0

type PaymentAlternative []*Payment

PaymentAlternative - a single payment possibility - for use in RPC layers up to entries:

  1. issue block owner payment
  2. last transfer block owner payment (can merge with 1 if same address)
  3. optional transfer payment

type ShareGrant added in v0.10.0

type ShareGrant struct {
	ShareId          merkle.Digest     `json:"shareId"`            // share = issue id
	Quantity         uint64            `json:"quantity,string"`    // shares to transfer > 0
	Owner            *account.Account  `json:"owner"`              // base58
	Recipient        *account.Account  `json:"recipient"`          // base58
	BeforeBlock      uint64            `json:"beforeBlock,string"` // expires when chain height > before block
	Signature        account.Signature `json:"signature"`          // hex
	Countersignature account.Signature `json:"countersignature"`   // hex: corresponds to owner in this record
}

ShareGrant - grant some shares to another (one way transfer)

func (*ShareGrant) Pack added in v0.10.0

func (grant *ShareGrant) Pack(address *account.Account) (Packed, error)

Pack - ShareGrant

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

NOTE: in this case address _MUST_ point to the record.Owner

type ShareSwap added in v0.10.0

type ShareSwap struct {
	ShareIdOne       merkle.Digest     `json:"shareIdOne"`         // share = issue id
	QuantityOne      uint64            `json:"quantityOne,string"` // shares to transfer > 0
	OwnerOne         *account.Account  `json:"ownerOne"`           // base58
	ShareIdTwo       merkle.Digest     `json:"shareIdTwo"`         // share = issue id
	QuantityTwo      uint64            `json:"quantityTwo,string"` // shares to transfer > 0
	OwnerTwo         *account.Account  `json:"ownerTwo"`           // base58
	BeforeBlock      uint64            `json:"beforeBlock,string"` // expires when chain height > before block
	Signature        account.Signature `json:"signature"`          // hex
	Countersignature account.Signature `json:"countersignature"`   // hex: corresponds to owner in this record
}

ShareSwap - swap some shares to another (two way transfer)

func (*ShareSwap) Pack added in v0.10.0

func (swap *ShareSwap) Pack(address *account.Account) (Packed, error)

Pack - ShareSwap

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

NOTE: in this case address _MUST_ point to the record.OwnerOne

type TagType

type TagType uint64

TagType - type code for transactions

type Transaction

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

Transaction - generic transaction interface

Jump to

Keyboard shortcuts

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