Browse Source

CLI: fix regression re handling "unknown command", re payment_identifiers

```
$ ./run_electrum sadasdasddsa
Traceback (most recent call last):
  File "/home/user/wspace/electrum/./run_electrum", line 532, in <module>
    main()
  File "/home/user/wspace/electrum/./run_electrum", line 398, in main
    if uri and not PaymentIdentifier(None, uri).is_valid():
  File "/home/user/wspace/electrum/electrum/payment_identifier.py", line 136, in __init__
    self.parse(text)
  File "/home/user/wspace/electrum/electrum/payment_identifier.py", line 265, in parse
    elif contact := self.contacts.by_name(text):
AttributeError: 'NoneType' object has no attribute 'by_name'
```
master
SomberNight 2 years ago
parent
commit
e38605c10a
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 4
      electrum/payment_identifier.py

4
electrum/payment_identifier.py

@ -104,7 +104,7 @@ class PaymentIdentifier(Logger):
* lightning address
"""
def __init__(self, wallet: 'Abstract_Wallet', text: str):
def __init__(self, wallet: Optional['Abstract_Wallet'], text: str):
Logger.__init__(self)
self._state = PaymentIdentifierState.EMPTY
self.wallet = wallet
@ -262,7 +262,7 @@ class PaymentIdentifier(Logger):
self._type = PaymentIdentifierType.SPK
self.spk = scriptpubkey
self.set_state(PaymentIdentifierState.AVAILABLE)
elif contact := self.contacts.by_name(text):
elif self.contacts and (contact := self.contacts.by_name(text)):
if contact['type'] == 'address':
self._type = PaymentIdentifierType.BIP21
self.bip21 = {

Loading…
Cancel
Save