mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-08-09 08:22:23 +02:00
add function to create lnaddress with nostdress manually
This commit is contained in:
@@ -393,6 +393,44 @@ def make_ln_address_nostdress(identifier, npub, pin, nostdressdomain, newname="
|
|||||||
return "", ""
|
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):
|
def check_and_set_ln_bits_keys(identifier, npub):
|
||||||
if not os.getenv("LNBITS_INVOICE_KEY_" + identifier.upper()):
|
if not os.getenv("LNBITS_INVOICE_KEY_" + identifier.upper()):
|
||||||
invoicekey, adminkey, walletid, userid, success = create_lnbits_account(identifier)
|
invoicekey, adminkey, walletid, userid, success = create_lnbits_account(identifier)
|
||||||
|
11
tests/make_ln_address_lnbits.py
Normal file
11
tests/make_ln_address_lnbits.py
Normal 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)
|
Reference in New Issue
Block a user