From 32537623e9627be3534925ca58473091fa5dd08a Mon Sep 17 00:00:00 2001 From: Believethehype Date: Sat, 6 Jan 2024 17:47:22 +0100 Subject: [PATCH] Check lnaddress if lnbits is not set to always create bolt11 --- nostr_dvm/dvm.py | 17 +++++++++++++++-- nostr_dvm/utils/zap_utils.py | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/nostr_dvm/dvm.py b/nostr_dvm/dvm.py index 5191f98..9fd7677 100644 --- a/nostr_dvm/dvm.py +++ b/nostr_dvm/dvm.py @@ -18,7 +18,7 @@ from nostr_dvm.utils.mediasource_utils import input_data_file_duration from nostr_dvm.utils.nostr_utils import get_event_by_id, get_referenced_event_by_id, send_event, check_and_decrypt_tags from nostr_dvm.utils.output_utils import build_status_reaction from nostr_dvm.utils.zap_utils import check_bolt11_ln_bits_is_paid, create_bolt11_ln_bits, parse_zap_event_tags, \ - parse_amount_from_bolt11_invoice, zaprequest, pay_bolt11_ln_bits + parse_amount_from_bolt11_invoice, zaprequest, pay_bolt11_ln_bits, create_bolt11_lud16 from nostr_dvm.utils.cashu_utils import redeem_cashu use_logger = False @@ -419,10 +419,23 @@ class DVM: expires = original_event.created_at().as_secs() + (60 * 60 * 24) if status == "payment-required" or (status == "processing" and not is_paid): if dvm_config.LNBITS_INVOICE_KEY != "": + if dvm_config.LNBITS_INVOICE_KEY != "": 
 try: - bolt11, payment_hash = create_bolt11_ln_bits(amount, dvm_config) + bolt11, payment_hash = create_bolt11_ln_bits(amount,dvm_config) except Exception as e: print(e) + try: + bolt11, payment_hash = create_bolt11_lud16(dvm_config.LN_ADDRESS, + amount) + except Exception as e: + print(e) + bolt11 = None + elif dvm_config.LN_ADDRESS != "": + try: + bolt11, payment_hash = create_bolt11_lud16(dvm_config.LN_ADDRESS, amount) + except Exception as e: + print(e) + bolt11 = None if not any(x.event == original_event for x in self.job_list): self.job_list.append( diff --git a/nostr_dvm/utils/zap_utils.py b/nostr_dvm/utils/zap_utils.py index 01a1c24..6c1ea21 100644 --- a/nostr_dvm/utils/zap_utils.py +++ b/nostr_dvm/utils/zap_utils.py @@ -181,7 +181,7 @@ def pay_bolt11_ln_bits(bolt11: str, config): return "Error" except Exception as e: print("LNBITS: " + str(e)) - return None, None + return "Error" # DECRYPT ZAPS