mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-23 03:34:19 +01:00
Show all mints in cashu info (#299)
This commit is contained in:
@@ -74,7 +74,7 @@ class InfoResponse(BaseModel):
|
||||
wallet: str
|
||||
debug: bool
|
||||
cashu_dir: str
|
||||
mint_url: str
|
||||
mint_urls: List[str] = []
|
||||
settings: Optional[str]
|
||||
tor: bool
|
||||
nostr_public_key: Optional[str] = None
|
||||
|
||||
@@ -14,7 +14,13 @@ from ...core.settings import settings
|
||||
from ...nostr.nostr.client.client import NostrClient
|
||||
from ...tor.tor import TorProxy
|
||||
from ...wallet.crud import get_lightning_invoices, get_reserved_proofs, get_unused_locks
|
||||
from ...wallet.helpers import deserialize_token_from_string, init_wallet, receive, send
|
||||
from ...wallet.helpers import (
|
||||
deserialize_token_from_string,
|
||||
init_wallet,
|
||||
list_mints,
|
||||
receive,
|
||||
send,
|
||||
)
|
||||
from ...wallet.nostr import receive_nostr, send_nostr
|
||||
from ...wallet.wallet import Wallet as Wallet
|
||||
from .api_helpers import verify_mints
|
||||
@@ -427,12 +433,13 @@ async def info():
|
||||
else:
|
||||
nostr_public_key = None
|
||||
nostr_relays = []
|
||||
mint_list = await list_mints(wallet)
|
||||
return InfoResponse(
|
||||
version=settings.version,
|
||||
wallet=wallet.name,
|
||||
debug=settings.debug,
|
||||
cashu_dir=settings.cashu_dir,
|
||||
mint_url=settings.mint_url,
|
||||
mint_urls=mint_list,
|
||||
settings=settings.env_file,
|
||||
tor=settings.tor,
|
||||
nostr_public_key=nostr_public_key,
|
||||
|
||||
@@ -28,7 +28,13 @@ from ...wallet.crud import (
|
||||
from ...wallet.wallet import Wallet as Wallet
|
||||
from ..api.api_server import start_api_server
|
||||
from ..cli.cli_helpers import get_mint_wallet, print_mint_balances, verify_mint
|
||||
from ..helpers import deserialize_token_from_string, init_wallet, receive, send
|
||||
from ..helpers import (
|
||||
deserialize_token_from_string,
|
||||
init_wallet,
|
||||
list_mints,
|
||||
receive,
|
||||
send,
|
||||
)
|
||||
from ..nostr import receive_nostr, send_nostr
|
||||
|
||||
|
||||
@@ -708,26 +714,30 @@ async def info(ctx: Context, mint: bool, mnemonic: bool):
|
||||
print(f"Socks proxy: {settings.socks_proxy}")
|
||||
if settings.http_proxy:
|
||||
print(f"HTTP proxy: {settings.http_proxy}")
|
||||
print(f"Mint URL: {ctx.obj['HOST']}")
|
||||
mint_list = await list_mints(wallet)
|
||||
print(f"Mint URLs: {mint_list}")
|
||||
if mint:
|
||||
mint_info: dict = (await wallet._load_mint_info()).dict()
|
||||
print("")
|
||||
print("Mint information:")
|
||||
print("")
|
||||
if mint_info:
|
||||
print(f"Mint name: {mint_info['name']}")
|
||||
if mint_info["description"]:
|
||||
print(f"Description: {mint_info['description']}")
|
||||
if mint_info["description_long"]:
|
||||
print(f"Long description: {mint_info['description_long']}")
|
||||
if mint_info["contact"]:
|
||||
print(f"Contact: {mint_info['contact']}")
|
||||
if mint_info["version"]:
|
||||
print(f"Version: {mint_info['version']}")
|
||||
if mint_info["motd"]:
|
||||
print(f"Message of the day: {mint_info['motd']}")
|
||||
if mint_info["parameter"]:
|
||||
print(f"Parameter: {mint_info['parameter']}")
|
||||
for mint_url in mint_list:
|
||||
wallet.url = mint_url
|
||||
mint_info: dict = (await wallet._load_mint_info()).dict()
|
||||
print("")
|
||||
print("Mint information:")
|
||||
print("")
|
||||
print(f"Mint URL: {mint_url}")
|
||||
if mint_info:
|
||||
print(f"Mint name: {mint_info['name']}")
|
||||
if mint_info["description"]:
|
||||
print(f"Description: {mint_info['description']}")
|
||||
if mint_info["description_long"]:
|
||||
print(f"Long description: {mint_info['description_long']}")
|
||||
if mint_info["contact"]:
|
||||
print(f"Contact: {mint_info['contact']}")
|
||||
if mint_info["version"]:
|
||||
print(f"Version: {mint_info['version']}")
|
||||
if mint_info["motd"]:
|
||||
print(f"Message of the day: {mint_info['motd']}")
|
||||
if mint_info["parameter"]:
|
||||
print(f"Parameter: {mint_info['parameter']}")
|
||||
|
||||
if mnemonic:
|
||||
assert wallet.mnemonic
|
||||
|
||||
@@ -26,6 +26,15 @@ async def init_wallet(wallet: Wallet, load_proofs: bool = True):
|
||||
await wallet.load_proofs(reload=True)
|
||||
|
||||
|
||||
async def list_mints(wallet: Wallet):
|
||||
await wallet.load_proofs()
|
||||
balances = await wallet.balance_per_minturl()
|
||||
mints = list(balances.keys())
|
||||
if wallet.url not in mints:
|
||||
mints.append(wallet.url)
|
||||
return mints
|
||||
|
||||
|
||||
async def redeem_TokenV3_multimint(wallet: Wallet, token: TokenV3):
|
||||
"""
|
||||
Helper function to iterate thruogh a token with multiple mints and redeem them from
|
||||
|
||||
Reference in New Issue
Block a user