NUT-04: add description (#613)

* NUT-04: add description

* skip test for deprecated api

* fix for lndgrpc

* add test for cli

* add two random tests

* add max length to request model validator

* skip cli test with description for deprecated api

* add cli test for invoice command

* default value to None
This commit is contained in:
callebtc
2024-09-09 11:50:02 +02:00
committed by GitHub
parent 0287c02f97
commit 637e4ba80c
19 changed files with 185 additions and 64 deletions

View File

@@ -283,11 +283,15 @@ class LedgerAPI(LedgerAPIDeprecated, object):
@async_set_httpx_client
@async_ensure_mint_loaded
async def mint_quote(self, amount: int, unit: Unit) -> PostMintQuoteResponse:
async def mint_quote(
self, amount: int, unit: Unit, memo: Optional[str] = None
) -> PostMintQuoteResponse:
"""Requests a mint quote from the server and returns a payment request.
Args:
amount (int): Amount of tokens to mint
unit (Unit): Unit of the amount
memo (Optional[str], optional): Memo to attach to Lightning invoice. Defaults to None.
Returns:
PostMintQuoteResponse: Mint Quote Response
@@ -296,7 +300,7 @@ class LedgerAPI(LedgerAPIDeprecated, object):
Exception: If the mint request fails
"""
logger.trace("Requesting mint: POST /v1/mint/bolt11")
payload = PostMintQuoteRequest(unit=unit.name, amount=amount)
payload = PostMintQuoteRequest(unit=unit.name, amount=amount, description=memo)
resp = await self.httpx.post(
join(self.url, "/v1/mint/quote/bolt11"), json=payload.dict()
)