Documentation
¶
Index ¶
Constants ¶
const ExpirationTimeInDays = 7 // transaction validity expiration time in days. TODO: move to config
Variables ¶
var ( ErrTransactionHasAFutureTime = errors.New("transaction has a future time") ErrExpiredTransaction = errors.New("transaction has expired") ErrTransactionHashIsInvalid = errors.New("transaction hash is invalid") ErrSignatureNotValidOrDataCorrupted = errors.New("signature not valid or data are corrupted") ErrSubjectIsEmpty = errors.New("subject cannot be empty") ErrAddressIsInvalid = errors.New("address is invalid") )
Functions ¶
This section is empty.
Types ¶
type Transaction ¶
type Transaction struct { ID any `json:"-" bson:"_id" db:"id"` CreatedAt time.Time `json:"created_at" bson:"created_at" db:"created_at"` Hash [32]byte `json:"hash" bson:"hash" db:"hash"` IssuerAddress string `json:"issuer_address" bson:"issuer_address" db:"issuer_address"` ReceiverAddress string `json:"receiver_address" bson:"receiver_address" db:"receiver_address"` Subject string `json:"subject" bson:"subject" db:"subject"` Data []byte `json:"data" bson:"data" db:"data"` IssuerSignature []byte `json:"issuer_signature" bson:"issuer_signature" db:"issuer_signature"` ReceiverSignature []byte `json:"receiver_signature" bson:"receiver_signature" db:"receiver_signature"` }
Transaction contains transaction information, subject type, subject data, signatures and public keys. Transaction is valid for a week from being issued. Subject represents an information how to read the Data and / or how to decode them. Data is not validated by the computantis server, Ladger ior block. What is stored in Data is not important for the whole Computantis system. It is only important that the data are signed by the issuer and the receiver and both parties agreed on them.
func (*Transaction) GeMessage ¶
func (t *Transaction) GeMessage() []byte
GeMessage returns message used for signature validation.
type TransactionAwaitingReceiverSignature ¶
type TransactionAwaitingReceiverSignature struct { ID any `json:"-" bson:"_id,omitempty" db:"id"` ReceiverAddress string `json:"receiver_address" bson:"receiver_address" db:"receiver_address"` IssuerAddress string `json:"issuer_address" bson:"issuer_address" db:"issuer_address"` Transaction Transaction `json:"transaction" bson:"transaction" db:"-"` TransactionHash [32]byte `json:"transaction_hash" bson:"transaction_hash" db:"hash"` }
TransactionAwaitingReceiverSignature represents transaction awaiting receiver signature. It is as well the entity of all issued transactions that has not been signed by receiver yet.
type TransactionInBlock ¶
type TransactionInBlock struct { ID any `json:"-" bson:"_id,omitempty" db:"id"` BlockHash [32]byte `json:"-" bson:"block_hash" db:"block_hash"` TransactionHash [32]byte `json:"-" bson:"transaction_hash" db:"transaction_hash"` }
TransactionInBlock stores relation between Transaction and Block to which Transaction was added. It is stored for fast lookup only to allow to find Block hash in which Transaction was added.