Claus Ibsen created CAMEL-27626:
-----------------------------------
Summary: camel-xchange: currencyPair option not validated, doc
promises trading, no API key options
Key: CAMEL-27626
URL: https://issues.apache.org/jira/browse/CAMEL-27626
Project: Camel
Issue Type: Bug
Components: camel-xchange
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while improving the option descriptions of camel-xchange for CAMEL-23832
(PR https://github.com/apache/camel/pull/30957).
These are separate problems of the component; the descriptions PR only
documents the current behavior.
h4. 1. The currencyPair option accepts an unknown currency, while the currency
option rejects it
The {{currency}} option is typed {{Currency}}. The generated configurer
converts its text with {{XChangeConverters.toCurrency(String)}}, so an unknown
currency fails when the endpoint is created.
The {{currencyPair}} option is a {{String}}.
{{XChangeConfiguration.getAsCurrencyPair()}} parses it with {{new
CurrencyPair(String)}} on every message, and that calls
{{Currency.getInstance(String)}}, which registers an unknown currency in the
JVM wide registry of XChange.
So a typo such as {{currencyPair=BTC/USTD}} is not reported when the route
starts. The request goes to the exchange and fails there, or returns null for
{{currencyPairMetaData}}.
Proposed change: convert {{currencyPair}} once, when the endpoint is created,
with {{XChangeConverters.toCurrencyPair(String)}}, so both options fail in the
same way.
{{XChangeConfiguration.setCurrency(String)}} is not called by the configurer,
and it silently sets null for an unknown currency
({{Currency.getInstanceNoCreate}}). It can be removed.
h4. 2. The doc page promises trading and historical data
{{xchange-component.adoc}} says that the component has "a consistent interface
for trading" and that Camel can "query historical data, place market orders and
much more".
The component has only the {{account}}, {{marketdata}} and {{metadata}}
services, with the methods {{balances}}, {{fundingHistory}}, {{wallets}},
{{ticker}}, {{currencies}}, {{currencyMetaData}}, {{currencyPairs}} and
{{currencyPairMetaData}}. There is no trade service and no method for
historical market data.
Proposed change: describe only what the component does, or add the trade
service of XChange.
h4. 3. The API keys can be set only through a file of the XChange module
{{XChangeComponent.getOrCreateXChange(String)}} creates the exchange with
{{ExchangeFactory.createExchange(Class)}}, which uses the default
{{ExchangeSpecification}} of the exchange module. The component has no option
for the API key and the secret key.
For Binance, {{BinanceExchange.getDefaultExchangeSpecification()}} reads them
with {{AuthUtils.setApiAndSecretKey}} from {{binance-secret.keys}} on the
classpath or in {{~/.ssh}}, which is what the doc page describes. An exchange
module that does not do this cannot be used with the {{account}} service at
all, and the keys cannot come from Camel properties or a vault.
Proposed change: add {{apiKey}} and {{secretKey}} options (marked {{secret =
true}}, label {{security}}) that the component sets on the
{{ExchangeSpecification}} when they are configured.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)