feat: added wallet service

This commit is contained in:
darwincereska
2025-12-23 17:38:27 -05:00
parent 23f6dba3f3
commit 99c5dba721
9 changed files with 527 additions and 5 deletions

48
server/utils/general.go Normal file
View File

@@ -0,0 +1,48 @@
package utils
import (
"crypto/rand"
"math/big"
"time"
)
// Generates a random integer in the range (min, max)
func RandInt(min, max int) int {
n, _ := rand.Int(rand.Reader, big.NewInt(int64(max-min)))
return int(n.Int64()) + min
}
// Get the current time in milliseconds
func GetCurrentTimeMillis() int64 {
return time.Now().UnixNano() / int64(time.Millisecond) // Convert nanoseconds to milliseconds
}
// IsAlpha checks if the string contains only alphabetic characters
func IsAlpha(s string) bool {
for _, r := range s {
if !('a' <= r && r <= 'z') && !('A' <= r && r <= 'Z') {
return false
}
}
return true
}
// IsDigit checks if the string contains only digits
func IsDigit(s string) bool {
for _, r := range s {
if !(r >= '0' && r <= '9') {
return false
}
}
return true
}
// IsHex checks if the string is a valid hexadecimal representation
func IsHex(s string) bool {
for _, r := range s {
if !((r >= '0' && r <= '9') || (r >= 'a' && r <= 'f') || (r >= 'A' && r <= 'F')) {
return false
}
}
return true
}