mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-22 03:24:18 +01:00
Add get quote API to wallet + check proof states in batches (#637)
* add get quote api to wallet * wrong string * test before pushing * fix tests for deprecated api only * sigh
This commit is contained in:
@@ -170,7 +170,7 @@ class LedgerAPI(LedgerAPIDeprecated):
|
||||
keys_dict: dict = resp.json()
|
||||
assert len(keys_dict), Exception("did not receive any keys")
|
||||
keys = KeysResponse.parse_obj(keys_dict)
|
||||
keysets_str = ' '.join([f"{k.id} ({k.unit})" for k in keys.keysets])
|
||||
keysets_str = " ".join([f"{k.id} ({k.unit})" for k in keys.keysets])
|
||||
logger.debug(f"Received {len(keys.keysets)} keysets from mint: {keysets_str}.")
|
||||
ret = [
|
||||
WalletKeyset(
|
||||
@@ -312,6 +312,24 @@ class LedgerAPI(LedgerAPIDeprecated):
|
||||
return_dict = resp.json()
|
||||
return PostMintQuoteResponse.parse_obj(return_dict)
|
||||
|
||||
@async_set_httpx_client
|
||||
@async_ensure_mint_loaded
|
||||
async def get_mint_quote(self, quote: str) -> PostMintQuoteResponse:
|
||||
"""Returns an existing mint quote from the server.
|
||||
|
||||
Args:
|
||||
quote (str): Quote ID
|
||||
|
||||
Returns:
|
||||
PostMintQuoteResponse: Mint Quote Response
|
||||
"""
|
||||
resp = await self.httpx.get(
|
||||
join(self.url, f"/v1/mint/quote/bolt11/{quote}"),
|
||||
)
|
||||
self.raise_on_error_request(resp)
|
||||
return_dict = resp.json()
|
||||
return PostMintQuoteResponse.parse_obj(return_dict)
|
||||
|
||||
@async_set_httpx_client
|
||||
@async_ensure_mint_loaded
|
||||
async def mint(
|
||||
@@ -400,6 +418,24 @@ class LedgerAPI(LedgerAPIDeprecated):
|
||||
return_dict = resp.json()
|
||||
return PostMeltQuoteResponse.parse_obj(return_dict)
|
||||
|
||||
@async_set_httpx_client
|
||||
@async_ensure_mint_loaded
|
||||
async def get_melt_quote(self, quote: str) -> PostMeltQuoteResponse:
|
||||
"""Returns an existing melt quote from the server.
|
||||
|
||||
Args:
|
||||
quote (str): Quote ID
|
||||
|
||||
Returns:
|
||||
PostMeltQuoteResponse: Melt Quote Response
|
||||
"""
|
||||
resp = await self.httpx.get(
|
||||
join(self.url, f"/v1/melt/quote/bolt11/{quote}"),
|
||||
)
|
||||
self.raise_on_error_request(resp)
|
||||
return_dict = resp.json()
|
||||
return PostMeltQuoteResponse.parse_obj(return_dict)
|
||||
|
||||
@async_set_httpx_client
|
||||
@async_ensure_mint_loaded
|
||||
async def melt(
|
||||
|
||||
Reference in New Issue
Block a user