Documentation ¶
Overview ¶
transaction record handling
contains types for each of the possible transaction records and methods to Pack and Unpack them for storage/transfer.
the transactions form a tree with the following limits 1. registration record (R) is a root and only one in a tree 2. registration transfer records (T) for a single chain trunk 3. bitmark transfer records (B) form single chain branches out from the bitmark transfer 4. there is only one trunk 5. any (T) can have multiple branches 6. new branches can only be added at the apex (T) 7. branches can only grow at their leaf (B)
(R)---(T1)---(T2)---(T3) <---{ Apex (T3) } | | | | | B B B B B | | | | | B B B B B <---{ Leaf nodes } (R)---(T1)---(T2)---(T3) | | | | |\ B B B B B B | | | | | \ B B B B B B <---{ New branch added at Apex (T3) } | | B B <---{ New bitmark transfers at any Leaf } (R)---(T1)---(T2)---(T3)---(T4) <---{ New Apex (T4) } | | | | |\ | B B B B B B B <---{ New branches only allowed from current Apex } | | | | | \ B B B B B B | | B B
Index ¶
- Constants
- func AssetIndexFromBytes(assetIndex *AssetIndex, buffer []byte) error
- func Finalise()
- func Initialise()
- func LinkFromBytes(link *Link, buffer []byte) error
- func LinkFromHexString(link *Link, hexWithPrefix string) error
- func ReadCounters(pending *uint64, verified *uint64)
- func RecordName(record interface{}) (string, bool)
- type Address
- type AddressInterface
- type AssetData
- type AssetIndex
- func (assetIndex AssetIndex) Bytes() []byte
- func (assetIndex AssetIndex) GoString() string
- func (assetIndex AssetIndex) MarshalJSON() ([]byte, error)
- func (assetIndex AssetIndex) MarshalText() ([]byte, error)
- func (asset AssetIndex) Read() (State, Link, bool)
- func (assetIndex *AssetIndex) Scan(state fmt.ScanState, verb rune) error
- func (assetIndex AssetIndex) String() string
- func (assetIndex *AssetIndex) UnmarshalJSON(s []byte) error
- func (assetIndex *AssetIndex) UnmarshalText(s []byte) error
- type AvailableCursor
- type BitmarkIssue
- type BitmarkTransfer
- type Decoded
- type ED25519Address
- func (address *ED25519Address) Bytes() []byte
- func (address *ED25519Address) CheckSignature(message []byte, signature Signature) error
- func (address *ED25519Address) KeyType() int
- func (address ED25519Address) MarshalJSON() ([]byte, error)
- func (address *ED25519Address) PublicKeyBytes() []byte
- func (address *ED25519Address) String() string
- type IndexCursor
- func (ic IndexCursor) Bytes() []byte
- func (cursor *IndexCursor) FetchPool(count int) []Decoded
- func (cursor *IndexCursor) FetchUnpaid(count int) []UnpaidResult
- func (ic IndexCursor) MarshalJSON() ([]byte, error)
- func (ic IndexCursor) MarshalText() ([]byte, error)
- func (ic *IndexCursor) NextBytes() []byte
- func (ic IndexCursor) String() string
- func (ic *IndexCursor) UnmarshalJSON(s []byte) error
- func (ic *IndexCursor) UnmarshalText(s []byte) error
- type Link
- func (link Link) Bytes() []byte
- func (link Link) GetState() (State, bool)
- func (link Link) GoString() string
- func (link Link) IsOwner(address *Address) bool
- func (link Link) MarshalJSON() ([]byte, error)
- func (link Link) MarshalText() ([]byte, error)
- func (link Link) Read() (State, Packed, bool)
- func (link *Link) Scan(state fmt.ScanState, verb rune) error
- func (link Link) SetState(newState State)
- func (link Link) String() string
- func (link *Link) UnmarshalJSON(s []byte) error
- func (link *Link) UnmarshalText(s []byte) error
- type NothingAddress
- func (address *NothingAddress) Bytes() []byte
- func (address *NothingAddress) CheckSignature(message []byte, signature Signature) error
- func (address *NothingAddress) KeyType() int
- func (address NothingAddress) MarshalJSON() ([]byte, error)
- func (address *NothingAddress) PublicKeyBytes() []byte
- func (address *NothingAddress) String() string
- type Ownership
- type Packed
- type Signature
- func (signature Signature) GoString() string
- func (signature Signature) MarshalJSON() ([]byte, error)
- func (signature Signature) MarshalText() ([]byte, error)
- func (signature *Signature) Scan(state fmt.ScanState, verb rune) error
- func (signature Signature) String() string
- func (signature *Signature) UnmarshalJSON(s []byte) error
- func (signature *Signature) UnmarshalText(s []byte) error
- type State
- type TagType
- type UnpaidResult
Constants ¶
const ( // list of valid algorithms Nothing = iota // zero keytype **Just for Testing** ED25519 = iota )
enumeration of supported key algorithms
const ( // null marks beginning of list - not used as a record type NullTag = TagType(iota) // valid record type 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"
const ( ExpiredTransaction = State('E') PendingTransaction = State('P') VerifiedTransaction = State('V') ConfirmedTransaction = State('C') )
possible states for a transaction
const (
AssetIndexSize = 64
)
limits
const (
LinkSize = block.DigestSize
)
a prefix for the client (for Bitcoin submission)
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 LinkFromBytes ¶
convert and validate little endian binary byte slice to a link
func LinkFromHexString ¶
convert and validate a little endian hex link string Notes: 1. hex code contains prefix at the beginning 2. this is hex code in same order as hex JSON above
func RecordName ¶ added in v0.1.2
get the name of a transaction record as a string
Types ¶
type Address ¶
type Address struct {
AddressInterface
}
base type for addresses
func AddressFromBase58 ¶
this converts a Base58 encoded string and returns an address
one of the specific address types are returned using the base "AddressInterface" interface type to allow individual methods to be called.
func AddressFromBytes ¶
this converts a byte encoded buffer and returns an address
one of the specific address types are returned using the base "AddressInterface" interface type to allow individual methods to be called.
func (*Address) UnmarshalJSON ¶
convert an address from its Base58 JSON form to binary
this cannot be forwarded by go compiler, since it needs to determine the the resulting interface type from the encoded data
type AddressInterface ¶
type AssetData ¶
type AssetData struct { Description string `json:"description"` // utf-8 Name string `json:"name"` // utf-8 Fingerprint string `json:"fingerprint"` // utf-8 Registrant *Address `json:"registrant"` // base58 Signature Signature `json:"signature"` // hex }
the unpacked Asset Data structure
func (*AssetData) AssetIndex ¶
func (assetData *AssetData) AssetIndex() AssetIndex
compute an asset index
type AssetIndex ¶
type AssetIndex [AssetIndexSize]byte
the type for an iasset index - same as block digest stored as little endian byte array represented as big endian hex value for print represented as little endian hex text for JSON encoding
func NewAssetIndex ¶
func NewAssetIndex(record []byte) AssetIndex
create an asset index from a byte slice
double SHA2-512 Hash
func (AssetIndex) Bytes ¶
func (assetIndex AssetIndex) Bytes() []byte
convert a binary assetIndex to byte slice
func (AssetIndex) GoString ¶
func (assetIndex AssetIndex) GoString() string
convert a binary assetIndex to big endian hex string for use by the fmt package (for %#v)
func (AssetIndex) MarshalJSON ¶
func (assetIndex AssetIndex) MarshalJSON() ([]byte, error)
convert a binary assetIndex to little endian hex text for JSON
***** possibly re-use MarshalText to save code duplication ***** but would that cost more buffer copying?
func (AssetIndex) MarshalText ¶
func (assetIndex AssetIndex) MarshalText() ([]byte, error)
convert assetIndex to little endian hex text
***** possibly use NewEncoder and byte buffer to save copy
func (AssetIndex) Read ¶
func (asset AssetIndex) Read() (State, Link, bool)
read an Asset from its assetIndex
returns:
state of record - see the const ExpiredTransaction,... above transaction ID - can be used in link.READ true if data was found
func (*AssetIndex) Scan ¶
func (assetIndex *AssetIndex) Scan(state fmt.ScanState, verb rune) error
convert a big 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 big endian hex string for use by the fmt package (for %s)
func (*AssetIndex) UnmarshalJSON ¶
func (assetIndex *AssetIndex) UnmarshalJSON(s []byte) error
convert a little endian hex string to a assetIndex for conversion from JSON
func (*AssetIndex) UnmarshalText ¶
func (assetIndex *AssetIndex) UnmarshalText(s []byte) error
convert little endian hex text into a assetIndex
type AvailableCursor ¶
type AvailableCursor struct {
// contains filtered or unexported fields
}
holds a cursor for fetching confirmed with associated assets
func NewAvailableCursor ¶
func NewAvailableCursor() *AvailableCursor
create a new cursor for FetchAvailable
func (*AvailableCursor) FetchAvailable ¶
func (cursor *AvailableCursor) FetchAvailable(count int) []block.Digest
fetch a list of transaction ids for miner
returns:
list of ids (as digests for merkle tree processing later)
note that an asset txId can be inserted just before an issue txId
if that asset was never seen before
type BitmarkIssue ¶
type BitmarkIssue struct { AssetIndex AssetIndex `json:"asset"` // previous record (or RegistrationTransfer if first record) Owner *Address `json:"owner"` // base58: the "destination" owner Nonce uint64 `json:"nonce"` // to allow for multiple issues at the same time Signature Signature `json:"signature"` // hex: corresponds to owner in linked record }
the unpacked BitmarkIssue structure
type BitmarkTransfer ¶
type BitmarkTransfer struct { Link Link `json:"link"` // previous record (or RegistrationTransfer if first record) Owner *Address `json:"owner"` // base58: the "destination" owner Signature Signature `json:"signature"` // hex: corresponds to owner in linked record }
the unpacked BitmarkTransfer structure
func (*BitmarkTransfer) Pack ¶
func (transfer *BitmarkTransfer) Pack(address *Address) (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 Decoded ¶
type Decoded struct { TxId Link `json:"txid"` Asset *AssetIndex `json:"asset"` Exists bool `json:"exists"` State State `json:"state"` Type string `json:"type"` Transaction interface{} `json:"transaction"` Timestamp *time.Time `json:"timestamp"` }
a decoded transaction type - for JSON conversion
type ED25519Address ¶
type ED25519Address struct { Test bool PublicKey *[ed25519.PublicKeySize]byte }
for ed25519 signatures
func (*ED25519Address) Bytes ¶
func (address *ED25519Address) Bytes() []byte
byte slice for encoded key
func (*ED25519Address) CheckSignature ¶
func (address *ED25519Address) CheckSignature(message []byte, signature Signature) error
check the signature of a message
func (*ED25519Address) KeyType ¶
func (address *ED25519Address) KeyType() int
key type code (see enumeration above)
func (ED25519Address) MarshalJSON ¶
func (address ED25519Address) MarshalJSON() ([]byte, error)
convert an address to its Base58 JSON form
func (*ED25519Address) PublicKeyBytes ¶
func (address *ED25519Address) PublicKeyBytes() []byte
fetch the public key as byte slice
func (*ED25519Address) String ¶
func (address *ED25519Address) String() string
base58 encoding of encoded key
type IndexCursor ¶
type IndexCursor uint64
type to denote a index in the unpaid, pending or confirmed pools just a 64 bit unsigned integer - big endian byte order (has a Bytes() to fetch the big endian representation
func (IndexCursor) Bytes ¶
func (ic IndexCursor) Bytes() []byte
convert a count to a byte slice (big endian)
func (*IndexCursor) FetchPool ¶
func (cursor *IndexCursor) FetchPool(count int) []Decoded
fetch some transaction ids from pool
returns:
list of ids cursor set to next start point
func (*IndexCursor) FetchUnpaid ¶
func (cursor *IndexCursor) FetchUnpaid(count int) []UnpaidResult
fetch some transaction ids for payment verification
returns:
list of ids next start point
func (IndexCursor) MarshalJSON ¶
func (ic IndexCursor) MarshalJSON() ([]byte, error)
convert to JSON
func (IndexCursor) MarshalText ¶
func (ic IndexCursor) MarshalText() ([]byte, error)
convert link to little endian hex text
func (*IndexCursor) NextBytes ¶
func (ic *IndexCursor) NextBytes() []byte
convert a next count to a byte slice (big endian)
func (*IndexCursor) UnmarshalJSON ¶
func (ic *IndexCursor) UnmarshalJSON(s []byte) error
convert from JSON
func (*IndexCursor) UnmarshalText ¶
func (ic *IndexCursor) UnmarshalText(s []byte) error
convert little endian hex text into a link
type Link ¶
the type for a link - same as block digest stored as little endian byte array represented as big endian hex value for print represented as little endian hex text for JSON encoding
func (Link) GetState ¶
state of a transaction
returns:
state of record - see the const ExpiredTransaction,... above true if data was found
func (Link) GoString ¶
convert a binary link to big endian hex string for use by the fmt package (for %#v)
func (Link) MarshalJSON ¶
convert a binary link to little endian hex text for JSON
***** possibly re-use MarshalText to save code duplication ***** but would that cost more buffer copying?
func (Link) MarshalText ¶
convert link to little endian hex text
***** possibly use NewEncoder and byte buffer to save copy
func (Link) Read ¶
read a transaction
returns:
state of record - see the const ExpiredTransaction,... above record data as Packed type - just a byte slice true if data was found
func (*Link) Scan ¶
convert a big endian hex text representation to a link for use by the format package scan routines
func (Link) String ¶
convert a binary link to big endian hex string for use by the fmt package (for %s)
func (*Link) UnmarshalJSON ¶
convert a little endian hex string to a link for conversion from JSON
func (*Link) UnmarshalText ¶
convert little endian hex text into a link
type NothingAddress ¶
just for debugging
func (*NothingAddress) Bytes ¶
func (address *NothingAddress) Bytes() []byte
byte slice for encoded key
func (*NothingAddress) CheckSignature ¶
func (address *NothingAddress) CheckSignature(message []byte, signature Signature) error
check the signature of a message
func (*NothingAddress) KeyType ¶
func (address *NothingAddress) KeyType() int
key type code (see enumeration above)
func (NothingAddress) MarshalJSON ¶
func (address NothingAddress) MarshalJSON() ([]byte, error)
convert an address to its Base58 JSON form
func (*NothingAddress) PublicKeyBytes ¶
func (address *NothingAddress) PublicKeyBytes() []byte
fetch the public key as byte slice
func (*NothingAddress) String ¶
func (address *NothingAddress) String() string
base58 encoding of encoded key
type Ownership ¶ added in v0.1.2
type Ownership struct { N uint64 `json:"n,string"` TxId Link `json:"txid"` IssueTxId Link `json:"issue"` AssetTxId Link `json:"asset"` }
type to represent an ownership record
type Packed ¶
type Packed []byte
packed records are just a byte slice
func (Packed) Exists ¶
see if a transaction already exists and compute its ID
note this will panic if database inconsistancy is detected
func (Packed) MarshalJSON ¶
convert a packed to its hex JSON form
type Signature ¶
type Signature []byte
the type for a signature
func (Signature) GoString ¶
convert a binary signature to hex string for use by the fmt package (for %#v)
func (Signature) MarshalJSON ¶
convert a binary signature to hex for unpacking record to JSON
func (Signature) MarshalText ¶
convert signature to text
func (*Signature) Scan ¶
convert a text representation to a signature for use by the format package scan routines
func (Signature) String ¶
convert a binary signature to hex string for use by the fmt package (for %s)
func (*Signature) UnmarshalJSON ¶
convert an hex string to a signature for conversion from JSON
func (*Signature) UnmarshalText ¶
convert text into a signature
type State ¶
type State byte
type for transaction state
func (State) CanChangeTo ¶
func (State) MarshalJSON ¶
convert a state to text for JSON
func (State) MarshalText ¶
convert state to text
Note: Each string _MUST_ start with a unique capital letter so client only need to test firrst character.
type UnpaidResult ¶
type to hold unpaid items