user custom private key
This commit is contained in:
parent
b2f970fd66
commit
d7c0507407
1 changed files with 14 additions and 1 deletions
15
__init__.py
15
__init__.py
|
|
@ -12,8 +12,21 @@ from loguru import logger
|
|||
|
||||
from .nostr.event import Event
|
||||
from .nostr.key import PrivateKey, PublicKey
|
||||
from environs import Env
|
||||
|
||||
nostr_privatekey = PrivateKey()
|
||||
|
||||
def generate_keys(private_key: str = ""):
|
||||
if private_key.startswith("nsec"):
|
||||
return PrivateKey.from_nsec(private_key)
|
||||
elif private_key:
|
||||
return PrivateKey(bytes.fromhex(private_key))
|
||||
else:
|
||||
return PrivateKey() # generate random key
|
||||
|
||||
|
||||
env = Env()
|
||||
env.read_env()
|
||||
nostr_privatekey = generate_keys(env.str("LNURLP_ZAP_NOSTR_PRIVATEKEY", default=""))
|
||||
nostr_publickey: PublicKey = nostr_privatekey.public_key
|
||||
logger.debug(f"LNURLP Zaps Nostr pubkey: {nostr_publickey.hex()}")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue