mirror of
https://github.com/lightningd/plugins.git
synced 2026-08-14 12:43:18 +02:00
currencyconvert: raise more meaningful exception on unknown currencies.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
d0839ff1f9
commit
eb31bfdf2e
1 changed files with 4 additions and 1 deletions
|
|
@ -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))}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue