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
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
2 changed files with
18 additions and
4 deletions
-
electrum/lnworker.py
-
electrum/wallet.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, |
|
|
|
|
|
@ -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( |
|
|
|