diff --git a/cashu/core/settings.py b/cashu/core/settings.py index f28bb4b4..3e09a6dd 100644 --- a/cashu/core/settings.py +++ b/cashu/core/settings.py @@ -64,6 +64,7 @@ class MintBackends(MintSettings): mint_lightning_backend: str = Field(default="") # deprecated mint_backend_bolt11_sat: str = Field(default="") mint_backend_bolt11_usd: str = Field(default="") + mint_backend_bolt11_eur: str = Field(default="") mint_lnbits_endpoint: str = Field(default=None) mint_lnbits_key: str = Field(default=None) diff --git a/cashu/lightning/fake.py b/cashu/lightning/fake.py index 5a8bcdcf..af00adce 100644 --- a/cashu/lightning/fake.py +++ b/cashu/lightning/fake.py @@ -29,7 +29,8 @@ class FakeWallet(LightningBackend): - fake_btc_price = 1e8 / 1337 + fake_btcusd_price = 1e8 / 1556 + fake_btceur_price = 1e8 / 1672 queue: asyncio.Queue[Bolt11] = asyncio.Queue(0) payment_secrets: Dict[str, str] = dict() paid_invoices: Set[str] = set() @@ -42,7 +43,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 +88,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() @@ -164,9 +168,14 @@ async def get_payment_quote( 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() diff --git a/cashu/mint/startup.py b/cashu/mint/startup.py index e66be504..7b2175bf 100644 --- a/cashu/mint/startup.py +++ b/cashu/mint/startup.py @@ -55,6 +55,11 @@ unit=Unit.usd ) backends.setdefault(Method.bolt11, {})[Unit.usd] = backend_bolt11_usd +if settings.mint_backend_bolt11_eur: + backend_bolt11_eur = getattr(wallets_module, settings.mint_backend_bolt11_eur)( + unit=Unit.eur + ) + backends.setdefault(Method.bolt11, {})[Unit.eur] = backend_bolt11_eur if not backends: raise Exception("No backends are set.")