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'
```
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user