test: eth

This commit is contained in:
Ginta
2026-04-11 19:15:55 +08:00
parent 3f071e6c01
commit 93b32d38d9
11 changed files with 466 additions and 29 deletions
+12
View File
@@ -2,10 +2,22 @@ package telegram
import (
"crypto/sha256"
"encoding/hex"
"strings"
"github.com/btcsuite/btcutil/base58"
)
// isValidEthereumAddress 校验 0x + 20 字节十六进制(主网收款)。
func isValidEthereumAddress(addr string) bool {
addr = strings.TrimSpace(addr)
if len(addr) != 42 || !strings.HasPrefix(addr, "0x") {
return false
}
_, err := hex.DecodeString(addr[2:])
return err == nil
}
// isValidTronAddress 校验 Tron Base58Check 地址是否合法
func isValidTronAddress(addr string) bool {
// 基本过滤