with the Qt gui, the python process saturates one of my CPU cores to 100%.
This is because main_window.timer_actions() calls request_list.refresh_all()
every 0.5 seconds, which iterates over all unpaid payreqs, and does a
scriptpubkey->address->scriptpubkey conversion.
Trace of the hot path:
```
File "/home/user/wspace/electrum/./run_electrum", line 510, in <module>
main()
File "/home/user/wspace/electrum/./run_electrum", line 421, in main
handle_cmd(
File "/home/user/wspace/electrum/./run_electrum", line 439, in handle_cmd
d.run_gui(config, plugins)
File "/home/user/wspace/electrum/electrum/daemon.py", line 581, in run_gui
self.gui_object.main()
File "/home/user/wspace/electrum/electrum/gui/qt/__init__.py", line 469, in main
self.app.exec_()
File "/home/user/wspace/electrum/electrum/gui/qt/main_window.py", line 861, in timer_actions
self.receive_tab.request_list.refresh_all()
File "/home/user/wspace/electrum/electrum/gui/qt/util.py", line 821, in refresh_all
self.refresh_row(key, row)
File "/home/user/wspace/electrum/electrum/gui/qt/request_list.py", line 126, in refresh_row
status = self.wallet.get_invoice_status(request)
File "/home/user/wspace/electrum/electrum/wallet.py", line 2330, in get_invoice_status
paid, conf = self.is_onchain_invoice_paid(invoice)
File "/home/user/wspace/electrum/electrum/wallet.py", line 1118, in is_onchain_invoice_paid
is_paid, conf_needed, relevant_txs = self._is_onchain_invoice_paid(invoice)
File "/home/user/wspace/electrum/electrum/wallet.py", line 1085, in _is_onchain_invoice_paid
outputs = invoice.get_outputs()
File "/home/user/wspace/electrum/electrum/invoices.py", line 130, in get_outputs
traceback.print_stack()
```
These commits drastically reduce the CPU utilisation.
In particular, window.timer_actions() calls
request_list.refresh_all() and invoice_list.refresh_all(),
every 0.5 seconds.
We avoid doing this at least when those lists are not visible anyway.
In order to avoid repeatedly calling get_addr_from_output_script() on
every read of the "TxOutput.address" property, determine and cache it
only whenever the output script is created/changed.
I was calling methods from the Qt console (e.g. peer.pay()) and seeing weird behaviour...
htlc_switch() (running on asyncio thread) was racing with pay() (running on GUI thread).
```
Traceback (most recent call last):
File "/home/user/wspace/electrum/electrum/gui/qt/invoice_list.py", line 169, in <lambda>
menu.addAction(_("Pay") + "...", lambda: self.send_tab.do_pay_invoice(invoice))
File "/home/user/wspace/electrum/electrum/gui/qt/send_tab.py", line 585, in do_pay_invoice
self.pay_onchain_dialog(self.window.get_coins(), invoice.outputs)
File "/home/user/wspace/electrum/electrum/gui/qt/send_tab.py", line 271, in pay_onchain_dialog
preview_dlg = PreviewTxDialog(
File "/home/user/wspace/electrum/electrum/gui/qt/transaction_dialog.py", line 962, in __init__
self.update()
File "/home/user/wspace/electrum/electrum/gui/qt/transaction_dialog.py", line 658, in update
self.io_widget.update(self.tx)
File "/home/user/wspace/electrum/electrum/gui/qt/transaction_dialog.py", line 212, in update
tx_height, tx_pos = self.wallet.adb.get_txpos(self.tx.txid())
File "/home/user/wspace/electrum/electrum/address_synchronizer.py", line 483, in get_txpos
verified_tx_mined_info = self.db.get_verified_tx(tx_hash)
File "/home/user/wspace/electrum/electrum/json_db.py", line 44, in wrapper
return func(self, *args, **kwargs)
File "/home/user/wspace/electrum/electrum/wallet_db.py", line 1256, in get_verified_tx
assert isinstance(txid, str)
AssertionError
```
textedit.setMinimumWidth(950) (from 5af399d19639b0c141398db964270c4974f124acdoes) does not play well with the tx_dlg.setMinimumWidth(640)
when resizing. Make 950 only affect the default sizing of the textedit.