mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-24 03:54:21 +01:00
Allow setting mint as peg-out only (#160)
* Allow setting mint as peg-out only * Update cashu/mint/router.py * Update cashu/mint/router.py --------- Co-authored-by: calle <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
@@ -53,6 +53,7 @@ class MintSettings(CashuSettings):
|
||||
mint_listen_port: int = Field(default=3338)
|
||||
mint_lightning_backend: str = Field(default="LNbitsWallet")
|
||||
mint_database: str = Field(default="data/mint")
|
||||
mint_peg_out_only: bool = Field(default=False)
|
||||
|
||||
mint_lnbits_endpoint: str = Field(default=None)
|
||||
mint_lnbits_key: str = Field(default=None)
|
||||
|
||||
@@ -90,13 +90,15 @@ async def keysets() -> KeysetsResponse:
|
||||
|
||||
|
||||
@router.get("/mint", name="Request mint", summary="Request minting of new tokens")
|
||||
async def request_mint(amount: int = 0) -> GetMintResponse:
|
||||
async def request_mint(amount: int = 0) -> Union[GetMintResponse, CashuError]:
|
||||
"""
|
||||
Request minting of new tokens. The mint responds with a Lightning invoice.
|
||||
This endpoint can be used for a Lightning invoice UX flow.
|
||||
|
||||
Call `POST /mint` after paying the invoice.
|
||||
"""
|
||||
if settings.mint_peg_out_only:
|
||||
return CashuError(code=0, error="Mint does not allow minting new tokens.")
|
||||
payment_request, payment_hash = await ledger.request_mint(amount)
|
||||
print(f"Lightning invoice: {payment_request}")
|
||||
resp = GetMintResponse(pr=payment_request, hash=payment_hash)
|
||||
@@ -117,6 +119,8 @@ async def mint(
|
||||
|
||||
Call this endpoint after `GET /mint`.
|
||||
"""
|
||||
if settings.mint_peg_out_only:
|
||||
return CashuError(code=0, error="Mint does not allow minting new tokens.")
|
||||
try:
|
||||
promises = await ledger.mint(payload.outputs, payment_hash=payment_hash)
|
||||
blinded_signatures = PostMintResponse(promises=promises)
|
||||
|
||||
Reference in New Issue
Block a user