feat: added models

This commit is contained in:
darwincereska
2025-12-20 04:21:13 -05:00
parent f5f40eb79c
commit 59adb32e68
13 changed files with 154 additions and 0 deletions

3
server/.gitignore vendored
View File

@@ -1,3 +1,6 @@
# Go files
ccoin
# Compiled class file # Compiled class file
*.class *.class

0
server/Dockerfile Normal file
View File

View File

@@ -0,0 +1,2 @@
package tables

View File

3
server/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module ccoin
go 1.25.5

View File

@@ -0,0 +1,70 @@
package api
type ApiResponse[T any] struct {
Success bool `json:"success"`
Data *T `json:"data,omitempty"` // Nullable data
Error *string `json:"error,omitempty"` // Nullable error message
Timestamp int64 `json:"timestamp"`
}
type ErrorResponse struct {
Error string `json:"error"`
Code *string `json:"code,omitempty"`
Details map[string]string `json:"details,omitempty"`
Timestamp int64 `json:"timestamp"`
}
type SuccessResponse struct {
Message string `json:"message"`
Timestamp int64 `json:"timestamp"`
}
type HealthResponse struct {
Status string `json:"status"`
Version string `json:"version"`
Uptime int64 `json:"uptime"`
Database DatabaseHealth `json:"database"`
BlockChain BlockChainHealth `json:"blockchain"`
}
type DatabaseHealth struct {
Connected bool `json:"connected"`
ResponseTime int64 `json:"response_time"`
ActiveConnections int `json:"active_connections"`
MaxConnections int `json:"max_connections"`
}
type BlockChainHealth struct {
LatestBlock int `json:"latest_block"`
PendingTransactions int `json:"pending_transactions"`
NetworkHashRate float64 `json:"network_hash_rate"`
AverageBlockTime int64 `json:"average_block_time"`
}
type PaginationRequest struct {
Page int `json:"page"`
PageSize int `json:"page_size"`
SortBy *string `json:"sort_by,omitempty"`
SortOrder SortOrder `json:"sort_order"`
}
type PaginatedResponse[T any] struct {
Data []T `json:"data"`
Pagination PaginationInfo `json:"pagination"`
}
type PaginationInfo struct {
CurrentPage int `json:"current_page"`
PageSize int `json:"page_size"`
TotalItems int `json:"total_items"`
TotalPages int `json:"total_pages"`
HasNext bool `json:"has_next"`
HasPrevious bool `json:"has_previous"`
}
type SortOrder string
const (
ASC SortOrder = "ASC"
DESC SortOrder = "DESC"
)

View File

@@ -0,0 +1,2 @@
package block

View File

@@ -0,0 +1,39 @@
package transaction
type SendTransactionRequest struct {
FromAddress string `json:"from_address"`
ToAddress string `json:"to_address"`
Amount float64 `json:"amount"`
Fee float64 `json:"fee"`
Memo *string `json:"memo,omitempty"`
Password string `json:"password"`
}
type TransactionResponse struct {
Hash string `json:"hash"`
FromAddress *string `json:"from_address,omitempty"`
ToAddress string `json:"to_address"`
Amount float64 `json:"amount"`
Fee float64 `json:"fee"`
Memo *string `json:"memo,omitempty"`
BlockHash string `json:"block_hash"`
Timestamp int64 `json:"timestamp"`
Status string `json:"status"`
Confirmations int `json:"confirmations"`
}
type TransactionHistoryResponse struct {
Transactions []TransactionResponse `json:"transactions"`
TotalCount int `json:"total_count"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
type TransactionStatus string
const (
PENDING TransactionStatus = "PENDING"
CONFIRMED TransactionStatus = "CONFIRMED"
FAILED TransactionStatus = "FAILED"
CANCELLED TransactionStatus = "CANCELLED"
)

View File

@@ -0,0 +1,24 @@
package wallet
type CreateWalletRequest struct {
Label *string `json:"label,omitempty"`
Password string `json:"password"`
}
type WalletResponse struct {
Address string `json:"address"` // Format: "random_word:123456" (e.g. "cave:595462")
Balance float64 `json:"balance"`
Label *string `json:"label,omitempty"`
PasswordHash string `json:"password_hash"`
CreatedAt int64 `json:"created_at"`
LastActivity *int64 `json:"last_activity,omitempty"`
}
type BalanceResponse struct {
Address string `json:"address"`
Balance float64 `json:"balance"`
}
type UpdateWalletRequest struct {
Label *string `json:"label,omitempty"`
}

5
server/server.go Normal file
View File

@@ -0,0 +1,5 @@
package main
func main() {
println("Hello world")
}

View File

@@ -0,0 +1,2 @@
package crypto

View File

@@ -0,0 +1,2 @@
package utils

View File

@@ -0,0 +1,2 @@
package hash