nostr relay setting

This commit is contained in:
callebtc
2022-12-27 15:39:06 +01:00
parent 2defdf2e1a
commit 542f4c7141
5 changed files with 8 additions and 4 deletions

View File

@@ -7,9 +7,10 @@ from environs import Env # type: ignore
env = Env()
ENV_FILE = os.path.join(str(Path.home()), ".cashu", ".env")
# env file: default to current dir, else home dir
ENV_FILE = os.path.join(os.getcwd(), ".env")
if not os.path.isfile(ENV_FILE):
ENV_FILE = os.path.join(os.getcwd(), ".env")
ENV_FILE = os.path.join(str(Path.home()), ".cashu", ".env")
if os.path.isfile(ENV_FILE):
env.read_env(ENV_FILE)
else:
@@ -53,6 +54,7 @@ LNBITS_ENDPOINT = env.str("LNBITS_ENDPOINT", default=None)
LNBITS_KEY = env.str("LNBITS_KEY", default=None)
NOSTR_PRIVATE_KEY = env.str("NOSTR_PRIVATE_KEY", default=None)
NOSTR_RELAYS = env.list("NOSTR_RELAYS", default=["wss://nostr-pub.wellorder.net"])
MAX_ORDER = 64
VERSION = "0.7.0"

View File

@@ -29,6 +29,7 @@ from cashu.core.settings import (
LIGHTNING,
MINT_URL,
NOSTR_PRIVATE_KEY,
NOSTR_RELAYS,
SOCKS_HOST,
SOCKS_PORT,
TOR,
@@ -551,7 +552,7 @@ async def nsend(ctx, amount: int, pubkey: str, verbose: bool, yes: bool):
)
# we only use ephemeral private keys for sending
client = NostrClient()
client = NostrClient(relays=NOSTR_RELAYS)
if verbose:
print(f"Your ephemeral nostr private key: {client.private_key.hex()}")
await asyncio.sleep(1)
@@ -577,7 +578,7 @@ async def nreceive(ctx, verbose: bool):
"Warning: No nostr private key set! You don't have NOSTR_PRIVATE_KEY set in your .env file. I will create a random private key for this session but I will not remember it."
)
print("")
client = NostrClient(privatekey_hex=NOSTR_PRIVATE_KEY)
client = NostrClient(privatekey_hex=NOSTR_PRIVATE_KEY, relays=NOSTR_RELAYS)
print(f"Your nostr public key: {client.public_key.hex()}")
if verbose:
print(f"Your nostr private key (do not share!): {client.private_key.hex()}")
@@ -646,6 +647,7 @@ async def info(ctx):
if NOSTR_PRIVATE_KEY:
client = NostrClient(privatekey_hex=NOSTR_PRIVATE_KEY, connect=False)
print(f"Nostr public key: {client.public_key.hex()}")
print(f"Nostr relays: {NOSTR_RELAYS}")
if SOCKS_HOST:
print(f"Socks proxy: {SOCKS_HOST}:{SOCKS_PORT}")
print(f"Mint URL: {ctx.obj['HOST']}")

Binary file not shown.