cln/tests/plugins/currencyUSDAUD5000.py
Rusty Russell 446312cf1b offers: limit invoices to 10 minutes for recurring offers in other currencies.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-08-04 18:51:43 -03:00

27 lines
712 B
Python
Executable file

#!/usr/bin/env python3
"""
This plugin is used to test the currency command
"""
from pyln.client import Plugin, Millisatoshi
plugin = Plugin()
_rate = 5000 # msat per unit
@plugin.method("currencyconvert")
def currencyconvert(plugin, amount, currency):
"""Converts currency using given APIs."""
if currency in ('USD', 'AUD'):
return {"msat": Millisatoshi(round(amount * _rate))}
raise Exception("No values available for currency {}".format(currency.upper()))
@plugin.method("setcurrencyrate")
def setcurrencyrate(plugin, msat_per_unit):
"""Change the msat-per-unit rate (for testing)."""
global _rate
_rate = msat_per_unit
return {"msat_per_unit": _rate}
plugin.run()