Browse Source

lnworker.add_request: force keyword args

and change type-hint to reflect that fallback_address can be None
patch-4
SomberNight 3 years ago
parent
commit
cafd5c4af0
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 12
      electrum/lnworker.py
  2. 10
      electrum/wallet.py

12
electrum/lnworker.py

@ -1808,7 +1808,7 @@ class LNWallet(LNWorker):
amount_msat: Optional[int],
message: str,
expiry: int,
fallback_address: str,
fallback_address: Optional[str],
write_to_disk: bool = True,
channels: Optional[Sequence[Channel]] = None,
) -> Tuple[LnAddr, str]:
@ -1848,10 +1848,16 @@ class LNWallet(LNWorker):
self.wallet.save_db()
return lnaddr, invoice
def add_request(self, amount_sat: Optional[int], message:str, expiry: int, fallback_address:str) -> str:
def add_request(
self,
*,
amount_sat: Optional[int],
message: str,
expiry: int,
fallback_address: Optional[str],
) -> str:
# passed expiry is relative, it is absolute in the lightning invoice
amount_msat = amount_sat * 1000 if amount_sat else None
timestamp = int(time.time())
lnaddr, invoice = self.create_invoice(
amount_msat=amount_msat,
message=message,

10
electrum/wallet.py

@ -2438,7 +2438,15 @@ class Abstract_Wallet(ABC, Logger, EventListener):
exp_delay = exp_delay or 0
timestamp = int(time.time())
fallback_address = address if self.config.get('bolt11_fallback', True) else None
lightning_invoice = self.lnworker.add_request(amount_sat, message, exp_delay, fallback_address) if lightning else None
if lightning:
lightning_invoice = self.lnworker.add_request(
amount_sat=amount_sat,
message=message,
expiry=exp_delay,
fallback_address=fallback_address,
)
else:
lightning_invoice = None
outputs = [ PartialTxOutput.from_address_and_value(address, amount_sat)] if address else []
height = self.adb.get_local_height()
req = Invoice(

Loading…
Cancel
Save