mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-03 11:00:58 +08:00
fix pk prefix handle
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/sonirico/go-hyperliquid"
|
||||
@@ -23,6 +24,9 @@ type HyperliquidTrader struct {
|
||||
|
||||
// NewHyperliquidTrader 创建Hyperliquid交易器
|
||||
func NewHyperliquidTrader(privateKeyHex string, walletAddr string, testnet bool) (*HyperliquidTrader, error) {
|
||||
// 去掉私钥的 0x 前缀(如果有,不区分大小写)
|
||||
privateKeyHex = strings.TrimPrefix(strings.ToLower(privateKeyHex), "0x")
|
||||
|
||||
// 解析私钥
|
||||
privateKey, err := crypto.HexToECDSA(privateKeyHex)
|
||||
if err != nil {
|
||||
|
||||
@@ -123,10 +123,9 @@ export function AITradersPage({ onTraderSelect }: AITradersPageProps) {
|
||||
e.asterPrivateKey && e.asterPrivateKey.trim() !== '';
|
||||
}
|
||||
|
||||
// Hyperliquid 只需要私钥(作为apiKey)和钱包地址
|
||||
// Hyperliquid 只需要私钥(作为apiKey),钱包地址会自动从私钥生成
|
||||
if (e.id === 'hyperliquid') {
|
||||
return e.apiKey && e.apiKey.trim() !== '' &&
|
||||
e.hyperliquidWalletAddr && e.hyperliquidWalletAddr.trim() !== '';
|
||||
return e.apiKey && e.apiKey.trim() !== '';
|
||||
}
|
||||
|
||||
// Binance 等其他交易所需要 apiKey 和 secretKey
|
||||
|
||||
Reference in New Issue
Block a user