Documentation ¶
Overview ¶
the structure of the transaction records
includes functions to pack/unpack []byte form
Index ¶
- Constants
- func AssetIdentifierFromBytes(assetId *AssetIdentifier, buffer []byte) error
- func CheckPayments(version uint64, testnet bool, payments currency.Map) error
- func RecordName(record interface{}) (string, bool)
- type AssetData
- type AssetIdentifier
- type BitmarkIssue
- type BitmarkShare
- func (share *BitmarkShare) GetCountersignature() account.Signature
- func (share *BitmarkShare) GetCurrencies() currency.Map
- func (share *BitmarkShare) GetLink() merkle.Digest
- func (share *BitmarkShare) GetOwner() *account.Account
- func (share *BitmarkShare) GetPayment() *Payment
- func (share *BitmarkShare) GetSignature() account.Signature
- func (share *BitmarkShare) Pack(address *account.Account) (Packed, error)
- type BitmarkTransfer
- type BitmarkTransferCountersigned
- func (transfer *BitmarkTransferCountersigned) GetCountersignature() account.Signature
- func (transfer *BitmarkTransferCountersigned) GetCurrencies() currency.Map
- func (transfer *BitmarkTransferCountersigned) GetLink() merkle.Digest
- func (transfer *BitmarkTransferCountersigned) GetOwner() *account.Account
- func (transfer *BitmarkTransferCountersigned) GetPayment() *Payment
- func (transfer *BitmarkTransferCountersigned) GetSignature() account.Signature
- func (transfer *BitmarkTransferCountersigned) Pack(address *account.Account) (Packed, error)
- type BitmarkTransferUnratified
- func (transfer *BitmarkTransferUnratified) GetCountersignature() account.Signature
- func (transfer *BitmarkTransferUnratified) GetCurrencies() currency.Map
- func (transfer *BitmarkTransferUnratified) GetLink() merkle.Digest
- func (transfer *BitmarkTransferUnratified) GetOwner() *account.Account
- func (transfer *BitmarkTransferUnratified) GetPayment() *Payment
- func (transfer *BitmarkTransferUnratified) GetSignature() account.Signature
- func (transfer *BitmarkTransferUnratified) Pack(address *account.Account) (Packed, error)
- type BlockFoundation
- type BlockOwnerTransfer
- func (transfer *BlockOwnerTransfer) GetCountersignature() account.Signature
- func (transfer *BlockOwnerTransfer) GetCurrencies() currency.Map
- func (transfer *BlockOwnerTransfer) GetLink() merkle.Digest
- func (transfer *BlockOwnerTransfer) GetOwner() *account.Account
- func (transfer *BlockOwnerTransfer) GetPayment() *Payment
- func (transfer *BlockOwnerTransfer) GetSignature() account.Signature
- func (transfer *BlockOwnerTransfer) Pack(address *account.Account) (Packed, error)
- type OldBaseData
- type Packed
- type Payment
- type PaymentAlternative
- type ShareGrant
- type ShareSwap
- type TagType
- type Transaction
Constants ¶
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 // this item must be last InvalidTag = TagType(iota) )
enumerate the possible transaction record types this is encoded a Varint64 at start of "Packed"
const (
AssetIdentifierLength = 64
)
limits
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
convert and validate little endian binary byte slice to a assetId
func CheckPayments ¶ added in v0.7.0
check all currency addresses for correct network and validity
func RecordName ¶
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) AssetId ¶ added in v0.8.0
func (assetData *AssetData) AssetId() AssetIdentifier
compute an asset id
type AssetIdentifier ¶ added in v0.8.0
type AssetIdentifier [AssetIdentifierLength]byte
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
create an asset id from a byte slice
SHA3-512 Hash
func (AssetIdentifier) GoString ¶ added in v0.8.0
func (assetId AssetIdentifier) GoString() string
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)
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
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
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
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"` // 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
type BitmarkShare ¶ added in v0.10.0
type BitmarkShare struct {}
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 (*BitmarkShare) GetLink ¶ added in v0.10.0
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 }
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 }
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 (*BitmarkTransferCountersigned) GetLink ¶ added in v0.6.7
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)
local function to 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 }
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 (*BitmarkTransferUnratified) GetLink ¶ added in v0.6.7
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)
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 BlockFoundation ¶ added in v0.7.0
type BlockFoundation struct { Version uint64 `json:"version"` // 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 }
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"` // 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 }
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 (*BlockOwnerTransfer) GetLink ¶ added in v0.7.0
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 }
the unpacked Proofer Data structure (OBSOLETE) this is first tx in every block and can only be used there
type Packed ¶
type Packed []byte
packed records are just a byte slice
func (Packed) MarshalText ¶
convert a packed to its hex JSON form
func (*Packed) UnmarshalText ¶ added in v0.5.7
convert a packed to its hex JSON form
func (Packed) Unpack ¶
func (record Packed) Unpack(testnet bool) (t Transaction, n int, e error)
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 }
optional payment record
type PaymentAlternative ¶ added in v0.5.0
type PaymentAlternative []*Payment
a single payment possibility - for use in RPC layers up to entries:
- issue block owner payment
- last transfer block owner payment (can merge with 1 if same address)
- optional transfer payment
type ShareGrant ¶ added in v0.10.0
type ShareGrant struct {}
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 {}
swap some shares to another (two way transfer)