diff --git a/cashu/lightning/fake.py b/cashu/lightning/fake.py index 564c000d..f5b5fe1b 100644 --- a/cashu/lightning/fake.py +++ b/cashu/lightning/fake.py @@ -42,7 +42,7 @@ class FakeWallet(LightningBackend): 32, ).hex() - supported_units = set([Unit.sat, Unit.msat, Unit.usd]) + supported_units = set([Unit.sat, Unit.msat, Unit.usd, Unit.eur]) unit = Unit.sat def __init__(self, unit: Unit = Unit.sat, **kwargs): @@ -87,13 +87,16 @@ async def create_invoice( tags.add(TagChar.payment_hash, payment_hash) self.payment_secrets[payment_hash] = secret - amount_msat = 0 if self.unit == Unit.sat: amount_msat = MilliSatoshi(amount.to(Unit.msat, round="up").amount) elif self.unit == Unit.usd: amount_msat = MilliSatoshi( - math.ceil(amount.amount / self.fake_btc_price * 1e9) + math.ceil(amount.amount / self.fake_btcusd_price * 1e9) + ) + elif self.unit == Unit.eur: + amount_msat = MilliSatoshi( + math.ceil(amount.amount / self.fake_btceur_price * 1e9) ) else: raise NotImplementedError() @@ -162,9 +165,14 @@ async def get_payment_quote(self, bolt11: str) -> PaymentQuoteResponse: fees = Amount(unit=Unit.msat, amount=fees_msat) amount = Amount(unit=Unit.msat, amount=amount_msat) elif self.unit == Unit.usd: - amount_usd = math.ceil(invoice_obj.amount_msat / 1e9 * self.fake_btc_price) + amount_usd = math.ceil(invoice_obj.amount_msat / 1e9 * self.fake_btcusd_price) amount = Amount(unit=Unit.usd, amount=amount_usd) fees = Amount(unit=Unit.usd, amount=2) + elif self.unit == Unit.eur: + amount_eur = math.ceil(invoice_obj.amount_msat / 1e9 * self.fake_btceur_price) + amount = Amount(unit=Unit.eur, amount=amount_eur) + fees = Amount(unit=Unit.eur, amount=2) + else: raise NotImplementedError()