mirror of
https://github.com/GMWalletApp/epusdt.git
synced 2026-07-07 10:16:15 +00:00
938396d82b
- Add multi-currency exchange rate API integration (GetRateForCoin) - Implement native TRX transfer detection alongside TRC20 USDT transfers - Replace deprecated Tronscan API with Trongrid API for better reliability - Add TRON Grid API key configuration support - Refactor order service to support multiple tokens and currencies - Update wallet address locking/unlocking to track token type - Add base58 and gjson dependencies for crypto operations - Optimize SQLite connection with WAL mode and busy timeout - Remove deprecated USDT rate job (replaced by dynamic rate API) - Update order data model to include currency and receive address fields - Enhance TRC20 callback with improved error handling and logging
31 lines
666 B
Go
31 lines
666 B
Go
package crypto
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
|
|
"github.com/shengdoushi/base58"
|
|
)
|
|
|
|
const AddressLength = 20
|
|
const PrefixMainnet = 0x41
|
|
|
|
// Encode returns the Base58 encoding of input using the Bitcoin alphabet.
|
|
func Encode(input []byte) string {
|
|
return base58.Encode(input, base58.BitcoinAlphabet)
|
|
}
|
|
|
|
// EncodeCheck returns the Base58Check encoding of input (Base58 with a 4-byte SHA-256d checksum).
|
|
func EncodeCheck(input []byte) string {
|
|
h256h0 := sha256.New()
|
|
h256h0.Write(input)
|
|
h0 := h256h0.Sum(nil)
|
|
|
|
h256h1 := sha256.New()
|
|
h256h1.Write(h0)
|
|
h1 := h256h1.Sum(nil)
|
|
|
|
inputCheck := append(append([]byte(nil), input...), h1[:4]...)
|
|
|
|
return Encode(inputCheck)
|
|
}
|