Skip to content

Commit

Permalink
remove msat conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Nov 21, 2023
1 parent 9f21cbd commit 1746a12
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cashu/mint/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.")
Expand Down

0 comments on commit 1746a12

Please sign in to comment.