Documentation ¶
Index ¶
- Constants
- Variables
- func MarshalProtoTransaction(tx *ProtoTransaction) ([]byte, error)
- type DataPayload
- func (*DataPayload) Descriptor() ([]byte, []int)deprecated
- func (x *DataPayload) GetPayload() []byte
- func (x *DataPayload) GetType() DataType
- func (*DataPayload) ProtoMessage()
- func (x *DataPayload) ProtoReflect() protoreflect.Message
- func (x *DataPayload) Reset()
- func (x *DataPayload) String() string
- type DataType
- type ProtoTransaction
- func (*ProtoTransaction) Descriptor() ([]byte, []int)deprecated
- func (x *ProtoTransaction) GetChain() []byte
- func (x *ProtoTransaction) GetData() []byte
- func (x *ProtoTransaction) GetFrom() string
- func (x *ProtoTransaction) GetHash() []byte
- func (x *ProtoTransaction) GetNounce() []byte
- func (x *ProtoTransaction) GetPublicKey() []byte
- func (x *ProtoTransaction) GetSignature() []byte
- func (x *ProtoTransaction) GetTo() string
- func (x *ProtoTransaction) GetTransactionFees() string
- func (x *ProtoTransaction) GetValue() string
- func (*ProtoTransaction) ProtoMessage()
- func (x *ProtoTransaction) ProtoReflect() protoreflect.Message
- func (x *ProtoTransaction) Reset()
- func (x *ProtoTransaction) String() string
- type Transaction
- func (tx Transaction) CalculateHash() ([]byte, error)
- func (tx Transaction) Equals(other merkletree.Content) (bool, error)
- func (tx Transaction) Serialize() ([]byte, error)
- func (tx *Transaction) Sign(key crypto.PrivKey) error
- func (tx Transaction) Validate() (bool, error)
- func (tx Transaction) VerifyWithPublicKey(key crypto.PubKey) error
Constants ¶
const ChainID = "0x01"
ChainID represents the main-net chain id.
Variables ¶
var ( DataType_name = map[int32]string{ 0: "UNKNOWN", 1: "UPDATE_BLOCKCHAIN_SETTINGS", 2: "CREATE_NODE", 3: "UPDATE_NODE", 4: "DATA_CONTRACT", 5: "DATA_CONTRACT_RELEASE_HOSTER_FEES", } DataType_value = map[string]int32{ "UNKNOWN": 0, "UPDATE_BLOCKCHAIN_SETTINGS": 1, "CREATE_NODE": 2, "UPDATE_NODE": 3, "DATA_CONTRACT": 4, "DATA_CONTRACT_RELEASE_HOSTER_FEES": 5, } )
Enum value maps for DataType.
var File_internal_transaction_transaction_proto protoreflect.FileDescriptor
Functions ¶
func MarshalProtoTransaction ¶
func MarshalProtoTransaction(tx *ProtoTransaction) ([]byte, error)
MarshalProtoTransaction serializes a block to a protobuf message.
Types ¶
type DataPayload ¶
type DataPayload struct { // type defines the payload type inside a transaction. Type DataType `protobuf:"varint,1,opt,name=type,proto3,enum=transaction.DataType" json:"type,omitempty"` // payload contains the byte array of the transaction data. Payload []byte `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` // contains filtered or unexported fields }
DataPayload is the transaction data payload.
func (*DataPayload) Descriptor
deprecated
func (*DataPayload) Descriptor() ([]byte, []int)
Deprecated: Use DataPayload.ProtoReflect.Descriptor instead.
func (*DataPayload) GetPayload ¶
func (x *DataPayload) GetPayload() []byte
func (*DataPayload) GetType ¶
func (x *DataPayload) GetType() DataType
func (*DataPayload) ProtoMessage ¶
func (*DataPayload) ProtoMessage()
func (*DataPayload) ProtoReflect ¶
func (x *DataPayload) ProtoReflect() protoreflect.Message
func (*DataPayload) Reset ¶
func (x *DataPayload) Reset()
func (*DataPayload) String ¶
func (x *DataPayload) String() string
type DataType ¶
type DataType int32
DataType is the transaction data type.
func (DataType) Descriptor ¶
func (DataType) Descriptor() protoreflect.EnumDescriptor
func (DataType) EnumDescriptor
deprecated
func (DataType) Number ¶
func (x DataType) Number() protoreflect.EnumNumber
func (DataType) Type ¶
func (DataType) Type() protoreflect.EnumType
type ProtoTransaction ¶
type ProtoTransaction struct { // hash represents the block hash. Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` // signature of the block. Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` // public_key is the sender's pubkey. PublicKey []byte `protobuf:"bytes,3,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` // nounce of the transaction. Nounce []byte `protobuf:"bytes,4,opt,name=nounce,proto3" json:"nounce,omitempty"` // data attached to the transaction. Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` // from sender From string `protobuf:"bytes,6,opt,name=from,proto3" json:"from,omitempty"` // to receiver. To string `protobuf:"bytes,7,opt,name=to,proto3" json:"to,omitempty"` // value of the transaction. Value string `protobuf:"bytes,8,opt,name=value,proto3" json:"value,omitempty"` // transaction_fees is the fees attached to a transaction. TransactionFees string `protobuf:"bytes,9,opt,name=transaction_fees,json=transactionFees,proto3" json:"transaction_fees,omitempty"` // chain represents the network chain. Chain []byte `protobuf:"bytes,10,opt,name=chain,proto3" json:"chain,omitempty"` // contains filtered or unexported fields }
ProtoTransaction is the proto representation of a transaction.
func ToProtoTransaction ¶
func ToProtoTransaction(tx Transaction) *ProtoTransaction
ToProtoTransaction converts a transaction to protobuf message.
func UnmarshalProtoBlock ¶
func UnmarshalProtoBlock(data []byte) (*ProtoTransaction, error)
UnmarshalProtoBlock unserializes a byte array to a protobuf transaction.
func (*ProtoTransaction) Descriptor
deprecated
func (*ProtoTransaction) Descriptor() ([]byte, []int)
Deprecated: Use ProtoTransaction.ProtoReflect.Descriptor instead.
func (*ProtoTransaction) GetChain ¶
func (x *ProtoTransaction) GetChain() []byte
func (*ProtoTransaction) GetData ¶
func (x *ProtoTransaction) GetData() []byte
func (*ProtoTransaction) GetFrom ¶
func (x *ProtoTransaction) GetFrom() string
func (*ProtoTransaction) GetHash ¶
func (x *ProtoTransaction) GetHash() []byte
func (*ProtoTransaction) GetNounce ¶
func (x *ProtoTransaction) GetNounce() []byte
func (*ProtoTransaction) GetPublicKey ¶
func (x *ProtoTransaction) GetPublicKey() []byte
func (*ProtoTransaction) GetSignature ¶
func (x *ProtoTransaction) GetSignature() []byte
func (*ProtoTransaction) GetTo ¶
func (x *ProtoTransaction) GetTo() string
func (*ProtoTransaction) GetTransactionFees ¶
func (x *ProtoTransaction) GetTransactionFees() string
func (*ProtoTransaction) GetValue ¶
func (x *ProtoTransaction) GetValue() string
func (*ProtoTransaction) ProtoMessage ¶
func (*ProtoTransaction) ProtoMessage()
func (*ProtoTransaction) ProtoReflect ¶
func (x *ProtoTransaction) ProtoReflect() protoreflect.Message
func (*ProtoTransaction) Reset ¶
func (x *ProtoTransaction) Reset()
func (*ProtoTransaction) String ¶
func (x *ProtoTransaction) String() string
type Transaction ¶
type Transaction struct { // calculated after Hash []byte Signature []byte // required PublicKey []byte Nounce []byte Data []byte From string To string Value string TransactionFees string Chain []byte }
Transaction represents a transaction.
func ProtoTransactionToTransaction ¶
func ProtoTransactionToTransaction(ptx *ProtoTransaction) Transaction
ProtoTransactionToTransaction returns a domain transaction from a protobuf message.
func (Transaction) CalculateHash ¶
func (tx Transaction) CalculateHash() ([]byte, error)
CalculateHash gets a hash of a transaction.
func (Transaction) Equals ¶
func (tx Transaction) Equals(other merkletree.Content) (bool, error)
Equals tests for equality of two Contents.
func (Transaction) Serialize ¶
func (tx Transaction) Serialize() ([]byte, error)
Serialize the transaction to bytes.
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(key crypto.PrivKey) error
SignTransaction signs a transaction with a private key.
func (Transaction) Validate ¶
func (tx Transaction) Validate() (bool, error)
Validate a transaction.
func (Transaction) VerifyWithPublicKey ¶
func (tx Transaction) VerifyWithPublicKey(key crypto.PubKey) error
VerifyWithPublicKey verifies a transaction with a public key.