Skip to content

Commit

Permalink
better naming of fee variables during melt
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Oct 18, 2023
1 parent 00db5a0 commit 7904861
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions cashu/mint/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,28 +451,31 @@ async def melt(
raise NotAllowedError(
f"Maximum melt amount is {settings.mint_max_peg_out} sat."
)
fees_sat = await self.get_melt_fees(invoice)
reserve_fees_sat = await self.get_melt_fees(invoice)
# verify overspending attempt
assert total_provided >= invoice_amount + fees_sat, TransactionError(
assert (
total_provided >= invoice_amount + reserve_fees_sat
), TransactionError(
"provided proofs not enough for Lightning payment. Provided:"
f" {total_provided}, needed: {invoice_amount + fees_sat}"
f" {total_provided}, needed: {invoice_amount + reserve_fees_sat}"
)

# verify spending inputs and their spending conditions
await self.verify_inputs_and_outputs(proofs)

if settings.lightning:
logger.trace(f"paying lightning invoice {invoice}")
status, preimage, fee_msat = await self._pay_lightning_invoice(
invoice, fees_sat * 1000
status, preimage, paid_fee_msat = await self._pay_lightning_invoice(
invoice, reserve_fees_sat * 1000
)
preimage = preimage or ""
logger.trace("paid lightning invoice")
else:
status, preimage, fee_msat = True, "preimage", 0
status, preimage, paid_fee_msat = True, "preimage", 0

logger.debug(
f"Melt status: {status}: preimage: {preimage}, fee_msat: {fee_msat}"
f"Melt status: {status}: preimage: {preimage}, fee_msat:"
f" {paid_fee_msat}"
)

if not status:
Expand All @@ -483,11 +486,11 @@ async def melt(

# prepare change to compensate wallet for overpaid fees
return_promises: List[BlindedSignature] = []
if outputs and fee_msat is not None:
if outputs and paid_fee_msat is not None:
return_promises = await self._generate_change_promises(
total_provided=total_provided,
invoice_amount=invoice_amount,
ln_fee_msat=fee_msat,
ln_fee_msat=paid_fee_msat,
outputs=outputs,
)

Expand Down

0 comments on commit 7904861

Please sign in to comment.