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