add function to create lnaddress with nostdress manually

This commit is contained in:
dbth 2025-01-03 16:38:07 +01:00
parent 9626c08201
commit 7c8931c40b
2 changed files with 49 additions and 0 deletions

View File

@ -393,6 +393,44 @@ def make_ln_address_nostdress(identifier, npub, pin, nostdressdomain, newname="
return "", ""
def make_ln_address_nostdress_manual_lnbits(new_name, invoice_key, npub, nostdress_domain, lnbits_domain, pin = " ", currentname= " "):
data = {
'name': new_name,
'domain': nostdress_domain,
'kind': "lnbits",
'host': lnbits_domain,
'key': invoice_key,
'pin': pin,
'npub': npub,
'currentname': currentname
}
try:
url = "https://" + nostdress_domain + "/api/easy/"
res = requests.post(url, data=data)
print(res.text)
obj = json.loads(res.text)
if obj.get("ok"):
return data["name"] + "@" + nostdress_domain, obj["pin"]
except Exception as e:
print("Creating random name..")
data["name"] = data["name"] + "_" + randomword(10)
try:
url = "https://" + nostdress_domain + "/api/easy/"
res = requests.post(url, data=data)
print(res.text)
obj = json.loads(res.text)
if obj.get("ok"):
return data["name"] + "@" + nostdress_domain, obj["pin"]
except Exception as e:
return "", ""
def check_and_set_ln_bits_keys(identifier, npub):
if not os.getenv("LNBITS_INVOICE_KEY_" + identifier.upper()):
invoicekey, adminkey, walletid, userid, success = create_lnbits_account(identifier)

View File

@ -0,0 +1,11 @@
from nostr_dvm.utils.zap_utils import make_ln_address_nostdress_manual_lnbits
name = ""
invoice_key = ""
npub = ""
nostdress_domain = ""
lnbits_domain = "https://demo.lnbits.com"
lnaddress, pin = make_ln_address_nostdress_manual_lnbits("_", invoice_key, npub, nostdress_domain, lnbits_domain, pin = " ", currentname= " ")
print(lnaddress)
print(pin)