mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-23 19:54:18 +01:00
Allow to start wallet API by cashu --daemon (#243)
* Allow to start wallet API by cashu --daemon * Provide access to wallet name via settings * Make format * Use flag is_eager for daemon option * add setting api_host --------- Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
@@ -20,6 +20,7 @@ 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.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 ..nostr import receive_nostr, send_nostr
|
||||
@@ -32,6 +33,13 @@ class NaturalOrderGroup(click.Group):
|
||||
return self.commands.keys()
|
||||
|
||||
|
||||
def run_api_server(ctx, param, daemon):
|
||||
if not daemon:
|
||||
return
|
||||
start_api_server()
|
||||
ctx.exit()
|
||||
|
||||
|
||||
@click.group(cls=NaturalOrderGroup)
|
||||
@click.option(
|
||||
"--host",
|
||||
@@ -43,8 +51,17 @@ class NaturalOrderGroup(click.Group):
|
||||
"--wallet",
|
||||
"-w",
|
||||
"walletname",
|
||||
default="wallet",
|
||||
help="Wallet name (default: wallet).",
|
||||
default=settings.wallet_name,
|
||||
help=f"Wallet name (default: {settings.wallet_name}).",
|
||||
)
|
||||
@click.option(
|
||||
"--daemon",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
is_eager=True,
|
||||
expose_value=False,
|
||||
callback=run_api_server,
|
||||
help="Start server for wallet REST API",
|
||||
)
|
||||
@click.pass_context
|
||||
def cli(ctx: Context, host: str, walletname: str):
|
||||
|
||||
Reference in New Issue
Block a user