mirror of
https://github.com/aljazceru/plugins.git
synced 2026-01-01 20:34:21 +01:00
currencyconvert: raise more meaningful exception on unknown currencies.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
d0839ff1f9
commit
eb31bfdf2e
@@ -95,7 +95,10 @@ def currencyrate(plugin, currency):
|
||||
@plugin.method("currencyconvert")
|
||||
def currencyconvert(plugin, amount, currency):
|
||||
"""Converts currency using given APIs."""
|
||||
val = statistics.median([m.millisatoshis for m in get_rates(plugin, currency.upper()).values()]) * float(amount)
|
||||
rates = get_rates(plugin, currency.upper())
|
||||
if len(rates) == 0:
|
||||
raise Exception("No values available for currency {}".format(currency.upper()))
|
||||
val = statistics.median([m.millisatoshis for m in rates.values()]) * float(amount)
|
||||
return {"msat": Millisatoshi(round(val))}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user