mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-06-06 05:51:19 +08:00
feat: auto-reuse claw402 wallet for nofxos data — no extra config needed
When a trader uses claw402 as AI provider, the same wallet private key is now automatically used to route nofxos data API calls (AI500, OI, NetFlow, etc.) through claw402 payment as well. Users don't need to configure anything extra — if they already set up claw402 for AI, data APIs automatically go through claw402 too.
This commit is contained in:
@@ -186,8 +186,9 @@ type StrategyEngine struct {
|
||||
nofxosClient *nofxos.Client
|
||||
}
|
||||
|
||||
// NewStrategyEngine creates strategy execution engine
|
||||
func NewStrategyEngine(config *store.StrategyConfig) *StrategyEngine {
|
||||
// NewStrategyEngine creates strategy execution engine.
|
||||
// claw402WalletKey is optional — if provided, nofxos data requests are routed through claw402.
|
||||
func NewStrategyEngine(config *store.StrategyConfig, claw402WalletKey ...string) *StrategyEngine {
|
||||
// Create NofxOS client with API key from config
|
||||
apiKey := config.Indicators.NofxOSAPIKey
|
||||
if apiKey == "" {
|
||||
@@ -195,8 +196,15 @@ func NewStrategyEngine(config *store.StrategyConfig) *StrategyEngine {
|
||||
}
|
||||
client := nofxos.NewClient(nofxos.DefaultBaseURL, apiKey)
|
||||
|
||||
// If claw402 wallet key is available, route nofxos requests through claw402
|
||||
if walletKey := os.Getenv("CLAW402_WALLET_KEY"); walletKey != "" {
|
||||
// If claw402 wallet key is provided (from trader's AI config), route through claw402
|
||||
walletKey := ""
|
||||
if len(claw402WalletKey) > 0 {
|
||||
walletKey = claw402WalletKey[0]
|
||||
}
|
||||
if walletKey == "" {
|
||||
walletKey = os.Getenv("CLAW402_WALLET_KEY")
|
||||
}
|
||||
if walletKey != "" {
|
||||
claw402URL := os.Getenv("CLAW402_URL")
|
||||
if claw402URL == "" {
|
||||
claw402URL = "https://claw402.ai"
|
||||
|
||||
Reference in New Issue
Block a user