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
|
wallet: str
|
||||||
debug: bool
|
debug: bool
|
||||||
cashu_dir: str
|
cashu_dir: str
|
||||||
mint_url: str
|
mint_urls: List[str] = []
|
||||||
settings: Optional[str]
|
settings: Optional[str]
|
||||||
tor: bool
|
tor: bool
|
||||||
nostr_public_key: Optional[str] = None
|
nostr_public_key: Optional[str] = None
|
||||||
|
|||||||
@@ -14,7 +14,13 @@ from ...core.settings import settings
|
|||||||
from ...nostr.nostr.client.client import NostrClient
|
from ...nostr.nostr.client.client import NostrClient
|
||||||
from ...tor.tor import TorProxy
|
from ...tor.tor import TorProxy
|
||||||
from ...wallet.crud import get_lightning_invoices, get_reserved_proofs, get_unused_locks
|
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.nostr import receive_nostr, send_nostr
|
||||||
from ...wallet.wallet import Wallet as Wallet
|
from ...wallet.wallet import Wallet as Wallet
|
||||||
from .api_helpers import verify_mints
|
from .api_helpers import verify_mints
|
||||||
@@ -427,12 +433,13 @@ async def info():
|
|||||||
else:
|
else:
|
||||||
nostr_public_key = None
|
nostr_public_key = None
|
||||||
nostr_relays = []
|
nostr_relays = []
|
||||||
|
mint_list = await list_mints(wallet)
|
||||||
return InfoResponse(
|
return InfoResponse(
|
||||||
version=settings.version,
|
version=settings.version,
|
||||||
wallet=wallet.name,
|
wallet=wallet.name,
|
||||||
debug=settings.debug,
|
debug=settings.debug,
|
||||||
cashu_dir=settings.cashu_dir,
|
cashu_dir=settings.cashu_dir,
|
||||||
mint_url=settings.mint_url,
|
mint_urls=mint_list,
|
||||||
settings=settings.env_file,
|
settings=settings.env_file,
|
||||||
tor=settings.tor,
|
tor=settings.tor,
|
||||||
nostr_public_key=nostr_public_key,
|
nostr_public_key=nostr_public_key,
|
||||||
|
|||||||
@@ -28,7 +28,13 @@ from ...wallet.crud import (
|
|||||||
from ...wallet.wallet import Wallet as Wallet
|
from ...wallet.wallet import Wallet as Wallet
|
||||||
from ..api.api_server import start_api_server
|
from ..api.api_server import start_api_server
|
||||||
from ..cli.cli_helpers import get_mint_wallet, print_mint_balances, verify_mint
|
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
|
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}")
|
print(f"Socks proxy: {settings.socks_proxy}")
|
||||||
if settings.http_proxy:
|
if settings.http_proxy:
|
||||||
print(f"HTTP proxy: {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:
|
if mint:
|
||||||
mint_info: dict = (await wallet._load_mint_info()).dict()
|
for mint_url in mint_list:
|
||||||
print("")
|
wallet.url = mint_url
|
||||||
print("Mint information:")
|
mint_info: dict = (await wallet._load_mint_info()).dict()
|
||||||
print("")
|
print("")
|
||||||
if mint_info:
|
print("Mint information:")
|
||||||
print(f"Mint name: {mint_info['name']}")
|
print("")
|
||||||
if mint_info["description"]:
|
print(f"Mint URL: {mint_url}")
|
||||||
print(f"Description: {mint_info['description']}")
|
if mint_info:
|
||||||
if mint_info["description_long"]:
|
print(f"Mint name: {mint_info['name']}")
|
||||||
print(f"Long description: {mint_info['description_long']}")
|
if mint_info["description"]:
|
||||||
if mint_info["contact"]:
|
print(f"Description: {mint_info['description']}")
|
||||||
print(f"Contact: {mint_info['contact']}")
|
if mint_info["description_long"]:
|
||||||
if mint_info["version"]:
|
print(f"Long description: {mint_info['description_long']}")
|
||||||
print(f"Version: {mint_info['version']}")
|
if mint_info["contact"]:
|
||||||
if mint_info["motd"]:
|
print(f"Contact: {mint_info['contact']}")
|
||||||
print(f"Message of the day: {mint_info['motd']}")
|
if mint_info["version"]:
|
||||||
if mint_info["parameter"]:
|
print(f"Version: {mint_info['version']}")
|
||||||
print(f"Parameter: {mint_info['parameter']}")
|
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:
|
if mnemonic:
|
||||||
assert wallet.mnemonic
|
assert wallet.mnemonic
|
||||||
|
|||||||
@@ -26,6 +26,15 @@ async def init_wallet(wallet: Wallet, load_proofs: bool = True):
|
|||||||
await wallet.load_proofs(reload=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):
|
async def redeem_TokenV3_multimint(wallet: Wallet, token: TokenV3):
|
||||||
"""
|
"""
|
||||||
Helper function to iterate thruogh a token with multiple mints and redeem them from
|
Helper function to iterate thruogh a token with multiple mints and redeem them from
|
||||||
|
|||||||
Reference in New Issue
Block a user