Documentation ¶
Index ¶
Constants ¶
const RFC3339MicroZeroPadded = "2006-01-02T15:04:05.000000Z07:00"
Variables ¶
var AvailableTxDataTypes = map[string]reflect.Type{ certify.GetCertificateRawV1Type(): reflect.TypeOf(certify.CertificateRawV1{}), certify.GetCertificateEd25519V1Type(): reflect.TypeOf(certify.CertificateEd25519V1{}), certify.GetSecretNaclBoxV1Type(): reflect.TypeOf(certify.SecretNaclBoxV1{}), account.GetKeyCreateV1Type(): reflect.TypeOf(account.KeyCreateV1{}), account.GetKeyRotateV1Type(): reflect.TypeOf(account.KeyRotateV1{}), account.GetKeyRevokeV1Type(): reflect.TypeOf(account.KeyRevokeV1{}), }
Functions ¶
Types ¶
type HexBytes ¶ added in v1.3.0
type HexBytes []byte
HexBytes allows to json marshal/unmarshal a byte array into an hex encoded string.
func (HexBytes) MarshalJSON ¶ added in v1.3.0
MarshalJSON encodes a byte array to an hex string.
func (HexBytes) String ¶ added in v1.3.0
String returns the hex string representation of a byte array.
func (*HexBytes) UnmarshalJSON ¶ added in v1.3.0
UnmarshalJSON converts an hex encoded string into a byte array.
type Time ¶
Time is a time.Time wrapper.
func GetCurrentTime ¶ added in v1.1.0
func GetCurrentTime() Time
GetCurrentTime returns a well formatted custom time.Now()
func (Time) MarshalJSON ¶
MarshalJSON converts a Time into a time.Time and marshals its UTC value with a microseconds precision.
type Tx ¶
type Tx struct { // To avoid replay attack, this value is checked in the replay protector. NonceTime Time `json:"nonce_time" validate:"required"` // Transaction data, this value is handled by the application. Data TxData `json:"data" validate:"required"` // Transaction signer and signature info to identify the sender. SignerFqId string `json:"signer_fqid" validate:"required,fqid"` Signature ed25519.Signature `json:"signature" validate:"required,len=64"` }
Tx wraps a TxData with its signature, its signer id and a nonce time.
func (Tx) MarshalJSON ¶
MarshalJSON encodes a Tx to add the TxData type information.
func (*Tx) UnmarshalJSON ¶
UnmarshalJSON converts an encoded Tx and create the concrete TxData according to its type information.
type TxAlias ¶
type TxAlias Tx
TxAlias is useful to avoid triggering the custom Tx MarshalJSON method.
type TxData ¶
type TxData interface { // To fetch all the entity state ids a TxData can create/update/delete. // This is also used to index Txs. GetStateIds(signerCompanyBcId string) map[string]string // To identify which plugin should handle this TxData. GetNamespace() string // To identify its subtype. GetType() string }
TxData interface defines the methods a concrete TxData must implement.
func UnmarshalTxData ¶ added in v1.3.10
func UnmarshalTxData(txDataWrapper *serializer.UnmarshalWrapper) (TxData, error)
UnmarshalTxData accepts a wrapper and tries to unmarshal its value according to its string type.
type TxSigner ¶ added in v1.3.0
type TxSigner struct { FqId string PrivateKey *ed25519.PrivateKey }
TxSigner contains all information about a Tx signer.
func NewTxSigner ¶ added in v1.3.0
func NewTxSigner(fqId string, privateKey *ed25519.PrivateKey) *TxSigner
TxSigner constructor.
type UnknownTxData ¶ added in v1.3.9
type UnknownTxData struct { Type string `json:"-"` json.RawMessage }
UnknownTxData is useful to unmarshal and marshal back a tx data of unknown type.
func (UnknownTxData) GetNamespace ¶ added in v1.3.9
func (utd UnknownTxData) GetNamespace() string
func (UnknownTxData) GetStateIds ¶ added in v1.3.9
func (utd UnknownTxData) GetStateIds(signerCompanyBcId string) map[string]string
func (UnknownTxData) GetType ¶ added in v1.3.9
func (utd UnknownTxData) GetType() string