Documentation
¶
Index ¶
- func GenerateTransactionID(inputs []types.UTXO, outputs []types.UTXO, address string, amount, gasFee int) (string, error)
- func NewTransaction(id string, inputs, outputs []types.UTXO) *types.Transaction
- func NewTransactionContext(txn *badger.Txn) types.TransactionContext
- func SanitizeAndFormatAddress(address string) (string, error)
- func SerializeTransaction(tx *types.Transaction) ([]byte, error)
- func SerializeTransactionForSigning(tx *types.Transaction) ([]byte, error)
- func SerializeTransactionWithoutSignature(tx *types.Transaction) ([]byte, error)
- func UTXOToMap(utxo *types.UTXO) map[string]interface{}
- func UTXOsToMapSlice(utxos []*types.UTXO) []map[string]interface{}
- func UnserializeTransaction(data []byte) (*types.Transaction, error)
- func ValidateTransaction(tx *types.Transaction, availableUTXOs map[string][]types.UTXO) error
- func ValidateTransactionBalance(tx *types.Transaction) error
- func ValidateTransactionStructure(tx *types.Transaction) error
- func VerifyTransactionSignature(tx *types.Transaction) error
- type MessageBus
- type TransactionContextImpl
- func (tc *TransactionContextImpl) Commit() error
- func (tc *TransactionContextImpl) GetBadgerTxn() *badger.Txn
- func (tc *TransactionContextImpl) GetTransaction() *types.Transaction
- func (tc *TransactionContextImpl) GetUTXOs() map[string][]types.UTXO
- func (tc *TransactionContextImpl) IsModified(key string) bool
- func (tc *TransactionContextImpl) Rollback() error
- func (tc *TransactionContextImpl) SetModified(key string)
- func (tc *TransactionContextImpl) SetUTXOs(utxos map[string][]types.UTXO)
- type TransactionForSigning
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateTransactionID ¶
func GenerateTransactionID(inputs []types.UTXO, outputs []types.UTXO, address string, amount, gasFee int) (string, error)
GenerateTransactionID creates a unique identifier for a transaction based on its contents.
func NewTransaction ¶
func NewTransaction(id string, inputs, outputs []types.UTXO) *types.Transaction
Transaction creation and validation functions
func NewTransactionContext ¶
func NewTransactionContext(txn *badger.Txn) types.TransactionContext
Constructor
func SanitizeAndFormatAddress ¶
SanitizeAndFormatAddress cleans and validates blockchain addresses.
func SerializeTransaction ¶
func SerializeTransaction(tx *types.Transaction) ([]byte, error)
Transaction serialization functions
func SerializeTransactionForSigning ¶
func SerializeTransactionForSigning(tx *types.Transaction) ([]byte, error)
func SerializeTransactionWithoutSignature ¶
func SerializeTransactionWithoutSignature(tx *types.Transaction) ([]byte, error)
func UTXOsToMapSlice ¶
func UnserializeTransaction ¶
func UnserializeTransaction(data []byte) (*types.Transaction, error)
func ValidateTransaction ¶
func ValidateTransactionBalance ¶
func ValidateTransactionBalance(tx *types.Transaction) error
func ValidateTransactionStructure ¶
func ValidateTransactionStructure(tx *types.Transaction) error
ValidateTransactionStructure performs structural validation of the transaction
func VerifyTransactionSignature ¶
func VerifyTransactionSignature(tx *types.Transaction) error
VerifyTransactionSignature verifies the transaction signature
Types ¶
type MessageBus ¶
type MessageBus struct {
// contains filtered or unexported fields
}
MessageBus implementation
func GetMessageBus ¶
func GetMessageBus() *MessageBus
GetMessageBus returns the singleton message bus instance
func NewMessageBus ¶
func NewMessageBus() *MessageBus
NewMessageBus creates a new message bus (for testing purposes)
func (*MessageBus) Close ¶
func (mb *MessageBus) Close()
Close closes all subscriber channels and cleans up resources
func (*MessageBus) Publish ¶
func (mb *MessageBus) Publish(msg types.Message)
Publish a message to all subscribers
func (*MessageBus) Subscribe ¶
func (mb *MessageBus) Subscribe(msgType types.MessageType, ch chan types.Message)
Subscribe to specific message types
func (*MessageBus) Unsubscribe ¶
func (mb *MessageBus) Unsubscribe(msgType types.MessageType, ch chan types.Message)
Unsubscribe from a message type
type TransactionContextImpl ¶
type TransactionContextImpl struct {
// contains filtered or unexported fields
}
TransactionContextImpl implements the types.TransactionContext interface
func (*TransactionContextImpl) Commit ¶
func (tc *TransactionContextImpl) Commit() error
func (*TransactionContextImpl) GetBadgerTxn ¶
func (tc *TransactionContextImpl) GetBadgerTxn() *badger.Txn
func (*TransactionContextImpl) GetTransaction ¶
func (tc *TransactionContextImpl) GetTransaction() *types.Transaction
func (*TransactionContextImpl) GetUTXOs ¶
func (tc *TransactionContextImpl) GetUTXOs() map[string][]types.UTXO
Implement the TransactionContext interface
func (*TransactionContextImpl) IsModified ¶
func (tc *TransactionContextImpl) IsModified(key string) bool
func (*TransactionContextImpl) Rollback ¶
func (tc *TransactionContextImpl) Rollback() error
func (*TransactionContextImpl) SetModified ¶
func (tc *TransactionContextImpl) SetModified(key string)
type TransactionForSigning ¶
type TransactionForSigning struct {
ID string `json:"id"`
Timestamp int64 `json:"timestamp"`
Inputs []types.UTXO `json:"inputs"`
Outputs []types.UTXO `json:"outputs"`
EncryptedInputs []byte `json:"encryptedInputs,omitempty"`
EncryptedOutputs []byte `json:"encryptedOutputs,omitempty"`
EncryptedAESKey []byte `json:"encryptedAESKey,omitempty"`
PreviousTxIds []string `json:"previousTxIds,omitempty"`
Sender string `json:"sender"`
GasFee int `json:"gasFee"`
}