kivy 2.1 seemingly became more sensitive to threading issues.
This used to work on kivy 2.0 and older, but 2.1 is complaining.
```
I | paymentrequest | Error while contacting payment URL: https://bitpay.com/i/... -- error type: <class 'aiohttp.client_exceptions.ClientResponseError'> -- Got HTTP status code 404.
E | util | Exception in get_payment_request: TypeError('Cannot create graphics instruction outside the main Kivy thread')
Traceback (most recent call last):
File "/home/user/wspace/electrum/electrum/util.py", line 1175, in wrapper
return await func(*args, **kwargs)
File "/home/user/wspace/electrum/electrum/util.py", line 1033, in get_payment_request
on_pr(request)
File "/home/user/wspace/electrum/electrum/gui/kivy/main_window.py", line 460, in on_pr
self.show_error("invoice error:" + pr.error)
File "/home/user/wspace/electrum/electrum/gui/kivy/main_window.py", line 1066, in show_error
self.show_info_bubble(text=error, icon=icon, width=width,
File "/home/user/wspace/electrum/electrum/gui/kivy/main_window.py", line 1092, in show_info_bubble
info_bubble = self.info_bubble = Factory.InfoBubble()
File "/usr/local/lib/python3.8/dist-packages/kivy/uix/bubble.py", line 199, in __init__
self._arrow_layout = BoxLayout()
File "/usr/local/lib/python3.8/dist-packages/kivy/uix/boxlayout.py", line 145, in __init__
super(BoxLayout, self).__init__(**kwargs)
File "/usr/local/lib/python3.8/dist-packages/kivy/uix/layout.py", line 76, in __init__
super(Layout, self).__init__(**kwargs)
File "/usr/local/lib/python3.8/dist-packages/kivy/uix/widget.py", line 361, in __init__
self.canvas = Canvas(opacity=self.opacity)
File "kivy/graphics/instructions.pyx", line 608, in kivy.graphics.instructions.Canvas.__init__
File "kivy/graphics/instructions.pyx", line 154, in kivy.graphics.instructions.InstructionGroup.__init__
File "kivy/graphics/instructions.pyx", line 60, in kivy.graphics.instructions.Instruction.__init__
TypeError: Cannot create graphics instruction outside the main Kivy thread
```
- Do not send ping if messages have been received recently.
- Do not send more than one ping.
- Await pong before sending commitment_signed (per BOLT-2)
- Lower ping time to 30s
closes https://github.com/spesmilo/electrum/issues/4072
(this fix AFAICT only works on Windows, and #4072 contains some macOS reports as well,
however all recent reports are for Windows and overall most reports are for Windows,
so let's close it optimistically for now)
protobuf 4.x introduced breaking changes compared to 3.20.
To adapt, we would have to regenerate paymentrequest_pb2.py, using protoc>=3.19.0, however ubuntu does not have new enough protoc.
Also, unsure if newly generated paymentrequest_pb2.py would be supported by older versions of protobuf.
Best to just wait for things to settle.
```
electrum/__init__.py:20: in <module>
from .wallet import Wallet
electrum/wallet.py:70: in <module>
from . import transaction, bitcoin, coinchooser, paymentrequest, ecc, bip32
electrum/paymentrequest.py:37: in <module>
from . import paymentrequest_pb2 as pb2
electrum/paymentrequest_pb2.py:36: in <module>
_descriptor.FieldDescriptor(
.tox/py3/lib/python3.9/site-packages/google/protobuf/descriptor.py:560: in __new__
_message.Message._CheckCalledFromGeneratedFile()
E TypeError: Descriptors cannot not be created directly.
E If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
E If you cannot immediately regenerate your protos, some other possible workarounds are:
E 1. Downgrade the protobuf package to 3.20.x or lower.
E 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
E
E More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
```
ceaae1b6a3/CHANGES.txt (L47)
```
E | gui.qt.exception_window.Exception_Hook | exception caught by crash reporter
Traceback (most recent call last):
File "...\electrum\electrum\gui\qt\channels_list.py", line 377, in new_channel_with_warning
self.new_channel_dialog()
File "...\electrum\electrum\gui\qt\channels_list.py", line 399, in new_channel_dialog
return d.run()
File "...\electrum\electrum\gui\qt\new_channel_dialog.py", line 133, in run
if self.min_amount_sat and funding_sat < self.min_amount_sat:
TypeError: '<' not supported between instances of 'str' and 'int'
```
When replaying messages during channel-reestablishment,
previously we first resent all update messages, along with potential commitment_signed messages,
and then we potentially resent a single revoke_and_ack.
This can result in incorrect behaviour in case both a commitment_signed and a revoke_and_ack needs to be resent.
When replaying messages, the relative order of commitment_signed and revoke_and_messages needs to be preserved.
(the order of updates (htlc/fee) in relation to the revack messages does not matter)
implements https://github.com/lightning/bolts/pull/810
The logic here is somewhat based on what c-lightning does:
01e5f1886e/channeld/channeld.c (L3059)
- use SetMinimumSize instead of sizeHint
(partially reverts 28f794b63b)
- to deal with small window sizes, set MinimumHeight of the
parent TabWidget (with a few extra pixels for margins)
- add an extra layout around address_help_text, so that it has
margins (margins were removed in 28f794b63b)
Previously the receive_tabs widget was allowed to be much smaller
than its inner main widget (e.g. truncating visible QR code).
A bit hackish to overwrite/monkeypatch sizeHint,
but I've tried a few approaches and this seems to work best.
Disable rebalance/swap suggestions attached to requests/invoices if there is an ongoing task.
Note: This assumes that all tasks are lightning payments, which is true for the moment.