mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-20 02:24:20 +01:00
Mint: Turn off locking by default (#662)
* turn off locking by default * fix test
This commit is contained in:
@@ -62,6 +62,7 @@ class MintSettings(CashuSettings):
|
|||||||
mint_max_secret_length: int = Field(default=512)
|
mint_max_secret_length: int = Field(default=512)
|
||||||
|
|
||||||
mint_input_fee_ppk: int = Field(default=0)
|
mint_input_fee_ppk: int = Field(default=0)
|
||||||
|
mint_disable_melt_on_error: bool = Field(default=False)
|
||||||
|
|
||||||
|
|
||||||
class MintDeprecationFlags(MintSettings):
|
class MintDeprecationFlags(MintSettings):
|
||||||
|
|||||||
@@ -882,7 +882,7 @@ class Ledger(LedgerVerification, LedgerSpendingConditions, LedgerTasks, LedgerFe
|
|||||||
Tuple[str, List[BlindedMessage]]: Proof of payment and signed outputs for returning overpaid fees to wallet.
|
Tuple[str, List[BlindedMessage]]: Proof of payment and signed outputs for returning overpaid fees to wallet.
|
||||||
"""
|
"""
|
||||||
# make sure we're allowed to melt
|
# make sure we're allowed to melt
|
||||||
if self.disable_melt:
|
if self.disable_melt and settings.mint_disable_melt_on_error:
|
||||||
raise NotAllowedError("Melt is disabled. Please contact the operator.")
|
raise NotAllowedError("Melt is disabled. Please contact the operator.")
|
||||||
|
|
||||||
# get melt quote and check if it was already paid
|
# get melt quote and check if it was already paid
|
||||||
@@ -978,7 +978,7 @@ class Ledger(LedgerVerification, LedgerSpendingConditions, LedgerTasks, LedgerFe
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Something went wrong. We might have lost connection to the backend. Keep transaction pending and return.
|
# Something went wrong. We might have lost connection to the backend. Keep transaction pending and return.
|
||||||
logger.error(
|
logger.error(
|
||||||
f"Lightning backend error: could not check payment status. Proofs for melt quote {melt_quote.quote} are stuck as PENDING. Disabling melt. Fix your Lightning backend and restart the mint.\nError: {e}"
|
f"Lightning backend error: could not check payment status. Proofs for melt quote {melt_quote.quote} are stuck as PENDING.\nError: {e}"
|
||||||
)
|
)
|
||||||
self.disable_melt = True
|
self.disable_melt = True
|
||||||
return PostMeltQuoteResponse.from_melt_quote(melt_quote)
|
return PostMeltQuoteResponse.from_melt_quote(melt_quote)
|
||||||
@@ -1000,7 +1000,7 @@ class Ledger(LedgerVerification, LedgerSpendingConditions, LedgerTasks, LedgerFe
|
|||||||
case _:
|
case _:
|
||||||
# Something went wrong with our implementation or the backend. Status check returned different result than payment. Keep transaction pending and return.
|
# Something went wrong with our implementation or the backend. Status check returned different result than payment. Keep transaction pending and return.
|
||||||
logger.error(
|
logger.error(
|
||||||
f"Payment state is {status.result.name} and payment was {payment.result}. Proofs for melt quote {melt_quote.quote} are stuck as PENDING. Disabling melt. Fix your Lightning backend and restart the mint."
|
f"Payment state was {payment.result} but additional payment state check returned {status.result.name}. Proofs for melt quote {melt_quote.quote} are stuck as PENDING."
|
||||||
)
|
)
|
||||||
self.disable_melt = True
|
self.disable_melt = True
|
||||||
return PostMeltQuoteResponse.from_melt_quote(melt_quote)
|
return PostMeltQuoteResponse.from_melt_quote(melt_quote)
|
||||||
|
|||||||
@@ -303,6 +303,7 @@ async def test_melt_lightning_pay_invoice_exception_exception(
|
|||||||
ledger: Ledger, wallet: Wallet
|
ledger: Ledger, wallet: Wallet
|
||||||
):
|
):
|
||||||
"""Simulates the case where pay_invoice and get_payment_status raise an exception (due to network issues for example)."""
|
"""Simulates the case where pay_invoice and get_payment_status raise an exception (due to network issues for example)."""
|
||||||
|
settings.mint_disable_melt_on_error = True
|
||||||
mint_quote = await wallet.request_mint(64)
|
mint_quote = await wallet.request_mint(64)
|
||||||
await ledger.get_mint_quote(mint_quote.quote) # fakewallet: set the quote to paid
|
await ledger.get_mint_quote(mint_quote.quote) # fakewallet: set the quote to paid
|
||||||
await wallet.mint(64, quote_id=mint_quote.quote)
|
await wallet.mint(64, quote_id=mint_quote.quote)
|
||||||
|
|||||||
Reference in New Issue
Block a user