From 1746a1257ae7edc2a7a0e05c1d32130617e01a8f Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Tue, 21 Nov 2023 13:53:22 -0300 Subject: [PATCH] remove msat conversion --- cashu/mint/ledger.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cashu/mint/ledger.py b/cashu/mint/ledger.py index 36f01046..69332846 100644 --- a/cashu/mint/ledger.py +++ b/cashu/mint/ledger.py @@ -288,9 +288,8 @@ async def mint_quote(self, quote_request: PostMintQuoteRequest) -> MintQuote: unit = Unit[quote_request.unit] method = Method["bolt11"] requested_amount_sat = quote_request.amount - if unit == Unit.msat: - requested_amount_sat = math.ceil(quote_request.amount / 1000) - logger.trace(f"requesting invoice for {requested_amount_sat} satoshis") + + logger.trace(f"requesting invoice for {unit.str(quote_request.amount)}") invoice_response: InvoiceResponse = await self.backends[method][ unit ].create_invoice(requested_amount_sat) @@ -383,10 +382,10 @@ async def mint( async def melt_quote( self, melt_quote: PostMeltQuoteRequest ) -> PostMeltQuoteResponse: - invoice_obj = bolt11.decode(melt_quote.request) - assert invoice_obj.amount_msat, "invoice has no amount." unit = Unit[melt_quote.unit] method = Method["bolt11"] + invoice_obj = bolt11.decode(melt_quote.request) + assert invoice_obj.amount_msat, "invoice has no amount." payment_quote: PaymentQuoteResponse = await self.backends[method][ unit ].get_payment_quote(melt_quote.request) @@ -501,7 +500,7 @@ async def melt( logger.debug( f"Melt status: {payment.ok}: preimage: {payment.preimage}," - f" fee_msat: {payment.fee_msat}" + f" fee: {unit.str(payment.fee_msat) if payment.fee_msat else 0}" ) if not payment.ok: raise LightningError("Lightning payment unsuccessful.")