mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-20 10:34:20 +01:00
Wallet: fix nostr receive (#460)
* fix wallet nostr receive * add log * add more relays and print info nicer
This commit is contained in:
@@ -132,9 +132,15 @@ class WalletSettings(CashuSettings):
|
|||||||
default=[
|
default=[
|
||||||
"wss://nostr-pub.wellorder.net",
|
"wss://nostr-pub.wellorder.net",
|
||||||
"wss://relay.damus.io",
|
"wss://relay.damus.io",
|
||||||
"wss://nostr.zebedee.cloud",
|
"wss://nostr.mom",
|
||||||
"wss://relay.snort.social",
|
"wss://relay.snort.social",
|
||||||
"wss://nostr.fmt.wiz.biz",
|
"wss://nostr.fmt.wiz.biz",
|
||||||
|
"wss://relay.minibits.cash",
|
||||||
|
"wss://nos.lol",
|
||||||
|
"wss://relay.nostr.band",
|
||||||
|
"wss://relay.bitcoiner.social",
|
||||||
|
"wss://140.f7z.io",
|
||||||
|
"wss://relayable.org",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -512,6 +512,11 @@ async def receive_cli(
|
|||||||
await receive(wallet, tokenObj)
|
await receive(wallet, tokenObj)
|
||||||
elif nostr:
|
elif nostr:
|
||||||
await receive_nostr(wallet)
|
await receive_nostr(wallet)
|
||||||
|
# exit on keypress
|
||||||
|
print("Press any key to exit.")
|
||||||
|
click.getchar()
|
||||||
|
print("Exiting.")
|
||||||
|
os._exit(0)
|
||||||
elif all:
|
elif all:
|
||||||
reserved_proofs = await get_reserved_proofs(wallet.db)
|
reserved_proofs = await get_reserved_proofs(wallet.db)
|
||||||
if len(reserved_proofs):
|
if len(reserved_proofs):
|
||||||
@@ -762,25 +767,11 @@ async def info(ctx: Context, mint: bool, mnemonic: bool):
|
|||||||
if settings.debug:
|
if settings.debug:
|
||||||
print(f"Debug: {settings.debug}")
|
print(f"Debug: {settings.debug}")
|
||||||
print(f"Cashu dir: {settings.cashu_dir}")
|
print(f"Cashu dir: {settings.cashu_dir}")
|
||||||
if settings.env_file:
|
|
||||||
print(f"Settings: {settings.env_file}")
|
|
||||||
if settings.tor:
|
|
||||||
print(f"Tor enabled: {settings.tor}")
|
|
||||||
if settings.nostr_private_key:
|
|
||||||
try:
|
|
||||||
client = NostrClient(private_key=settings.nostr_private_key, connect=False)
|
|
||||||
print(f"Nostr public key: {client.public_key.bech32()}")
|
|
||||||
print(f"Nostr relays: {settings.nostr_relays}")
|
|
||||||
except Exception:
|
|
||||||
print("Nostr: Error. Invalid key.")
|
|
||||||
if settings.socks_proxy:
|
|
||||||
print(f"Socks proxy: {settings.socks_proxy}")
|
|
||||||
if settings.http_proxy:
|
|
||||||
print(f"HTTP proxy: {settings.http_proxy}")
|
|
||||||
mint_list = await list_mints(wallet)
|
mint_list = await list_mints(wallet)
|
||||||
print(f"Mint URLs: {mint_list}")
|
print("Mints:")
|
||||||
if mint:
|
|
||||||
for mint_url in mint_list:
|
for mint_url in mint_list:
|
||||||
|
print(f" - {mint_url}")
|
||||||
|
if mint:
|
||||||
wallet.url = mint_url
|
wallet.url = mint_url
|
||||||
try:
|
try:
|
||||||
mint_info: dict = (await wallet._load_mint_info()).dict()
|
mint_info: dict = (await wallet._load_mint_info()).dict()
|
||||||
@@ -805,13 +796,29 @@ async def info(ctx: Context, mint: bool, mnemonic: bool):
|
|||||||
"Supported NUTS:"
|
"Supported NUTS:"
|
||||||
f" {', '.join(['NUT-'+str(k) for k in mint_info['nuts'].keys()])}"
|
f" {', '.join(['NUT-'+str(k) for k in mint_info['nuts'].keys()])}"
|
||||||
)
|
)
|
||||||
|
print("")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("")
|
print("")
|
||||||
print(f"Error fetching mint information for {mint_url}: {e}")
|
print(f"Error fetching mint information for {mint_url}: {e}")
|
||||||
|
|
||||||
if mnemonic:
|
if mnemonic:
|
||||||
assert wallet.mnemonic
|
assert wallet.mnemonic
|
||||||
print(f"Mnemonic: {wallet.mnemonic}")
|
print(f"Mnemonic:\n - {wallet.mnemonic}")
|
||||||
|
if settings.env_file:
|
||||||
|
print(f"Settings: {settings.env_file}")
|
||||||
|
if settings.tor:
|
||||||
|
print(f"Tor enabled: {settings.tor}")
|
||||||
|
if settings.nostr_private_key:
|
||||||
|
try:
|
||||||
|
client = NostrClient(private_key=settings.nostr_private_key, connect=False)
|
||||||
|
print(f"Nostr public key: {client.public_key.bech32()}")
|
||||||
|
print(f"Nostr relays: {', '.join(settings.nostr_relays)}")
|
||||||
|
except Exception:
|
||||||
|
print("Nostr: Error. Invalid key.")
|
||||||
|
if settings.socks_proxy:
|
||||||
|
print(f"Socks proxy: {settings.socks_proxy}")
|
||||||
|
if settings.http_proxy:
|
||||||
|
print(f"HTTP proxy: {settings.http_proxy}")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ async def receive_nostr(
|
|||||||
private_key=settings.nostr_private_key, relays=settings.nostr_relays
|
private_key=settings.nostr_private_key, relays=settings.nostr_relays
|
||||||
)
|
)
|
||||||
print(f"Your nostr public key: {client.public_key.bech32()}")
|
print(f"Your nostr public key: {client.public_key.bech32()}")
|
||||||
# print(f"Your nostr private key (do not share!): {client.private_key.bech32()}")
|
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
|
|
||||||
def get_token_callback(event: Event, decrypted_content: str):
|
def get_token_callback(event: Event, decrypted_content: str):
|
||||||
@@ -126,10 +126,6 @@ async def receive_nostr(
|
|||||||
words = decrypted_content.split(" ")
|
words = decrypted_content.split(" ")
|
||||||
for w in words:
|
for w in words:
|
||||||
try:
|
try:
|
||||||
logger.trace(
|
|
||||||
"Nostr: setting last check timestamp to"
|
|
||||||
f" {event.created_at} ({date_str})"
|
|
||||||
)
|
|
||||||
# call the receive method
|
# call the receive method
|
||||||
tokenObj: TokenV3 = deserialize_token_from_string(w)
|
tokenObj: TokenV3 = deserialize_token_from_string(w)
|
||||||
print(
|
print(
|
||||||
@@ -143,6 +139,10 @@ async def receive_nostr(
|
|||||||
tokenObj,
|
tokenObj,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
logger.trace(
|
||||||
|
"Nostr: setting last check timestamp to"
|
||||||
|
f" {event.created_at} ({date_str})"
|
||||||
|
)
|
||||||
asyncio.run(
|
asyncio.run(
|
||||||
set_nostr_last_check_timestamp(
|
set_nostr_last_check_timestamp(
|
||||||
timestamp=event.created_at, db=wallet.db
|
timestamp=event.created_at, db=wallet.db
|
||||||
|
|||||||
Reference in New Issue
Block a user