Check if self.network before trying to access it. This would trigger an
exception when toggling the trampoline checkbox in offline mode:
```
29.13 | E | gui.qt.exception_window.Exception_Hook | exception caught by crash reporter
Traceback (most recent call last):
File "/home/user/Documents/electrum/electrum/gui/qt/settings_dialog.py", line 133, in on_trampoline_checked
self.network.run_from_another_thread(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'run_from_another_thread'
31.00 | E | gui.qt.exception_window.Exception_Hook | exception caught by crash reporter
Traceback (most recent call last):
File "/home/user/Documents/electrum/electrum/gui/qt/settings_dialog.py", line 131, in on_trampoline_checked
self.network.start_gossip()
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'start_gossip'
```
- could not find a single project that still actually cares about bip70 [0]
- well except maybe BitPay.
- but I cannot test with BitPay:
- they have a testnet3 staging environment on test.bitpay.com
- but the SSL cert they use for bip70 has expired in 2021
- the webUI probably also has not been updated since then...
- they claim to have added LN support in 2022 in a blog post,
but it's not there on test.bitpay.com
- on mainnet, they require KYC before payment
- < ... angry noises >
- their loss then, I don't care.
- this is code that no one wants to maintain
- this does not yet delete the signed bip70 payment data for historical txs
- but it is no longer possible to export it from the GUI
[0]: https://bitcoinops.org/en/topics/bip70-payment-protocol/
For multiple transactions, split summary in total sent/received and a balance change.
move duplicated code to wallet.get_user_notifications_for_new_txns()
Adds a link to the plugins.electrum.org website so users who open the
plugins dialog out of curiosity get guided to the website and can
discover other plugins and learn more about the system.
Waste less space in the dialog by limiting the stretch to 10px and
resize the servers_list with the dialog by setting stretch=1 so it can
be made larger.
Fixes https://github.com/spesmilo/electrum/issues/10519
Also stop timer when dialog is finished, to avoid re-generating txs with the same input coin set, which
results in an exception as these coins have signatures when the swap has started.
Stores the currently open (right-click) menu in MyTreeView
and adds a `close_menu()` method so inheritants can cleanly
close the menu again if the context it was opened upon has changed.
This is utilized by `AddressList` and `UTXOList` to close the menu
if a call to `update()` has chenged the address list in some way or
removed a utxo from the list to prevent the user from trying to use
a utxo that doesn't exist anymore.
Fixes#10464
otherwise, when selecting only frozen coins, the set of usable coins is empty, and the menu options
will instead fall back to using ALL coins without informing the user.
In the GUIs, on the language-select screen, show e.g.
Czech (100%), Danish (13%), Dutch (54%)
instead of
Czech, Danish, Dutch
- we count the source strings when creating the .pot PO-template file
and add an "X-Electrum-SourceStringCount" header to it, in the push_locale.py script that uploads the .pot file to crowdin.
- later, when we run electrum-locale/update.py to download the translations in .po files, these files will also contain the same header.
- then when the build_locale.sh script compiles those .po files, we can read the header and use it to populate a new "stats.json" file
that we place in electrum/locale/locale/ and bundle in the all release binaries/distributables.
- stats.json also includes the number of translated strings for each lang
- at runtime we simply read stats.json and use the values to calculate the percentages
- a prior implementation did not pre-calc stats.json but did all calculations at runtime (by opening all .mo translations)
- however that was deemed to slow, hence the build-time pre-calc
- runtime calc took 40 ms on my laptop, so I guess it could easily take 10x that on an old phone
- just as we have always been very tolerant of any locale files or even the whole locale/ dir missing, we also tolerate stats.json missing
Fix exception when clicking on "Donate to server" in offline mode by not
showing the "Donate to server" menu action when no network is set.
Raise CancelledError in `fetch_bitcoin_paper` as
`_fetch_tx_from_network` already shows an according error message so the
second, subsequent error message shown by `on_error` is not useful if
`_fetch_tx_from_network` already failed.
```
63.53 | E | gui.qt.exception_window.Exception_Hook | exception caught by crash reporter
Traceback (most recent call last):
File "/home/user/Documents/electrum/electrum/gui/qt/main_window.py", line 864, in donate_to_server
d = self.network.get_donation_address()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get_donation_address'
```
I tried to reproduce:
https://github.com/spesmilo/electrum/issues/8815#issuecomment-2094259186
which triggered the following exception for me:
```
Traceback (most recent call last):
File "/home/user/code/electrum-fork/electrum/gui/qt/__init__.py", line 409, in start_new_window
window = self._create_window_for_wallet(wallet)
File "/home/user/code/electrum-fork/electrum/gui/qt/__init__.py", line 329, in _create_window_for_wallet
w = ElectrumWindow(self, wallet)
File "/home/user/code/electrum-fork/electrum/gui/qt/main_window.py", line 290, in __init__
self.load_wallet(wallet)
~~~~~~~~~~~~~~~~^^^^^^^^
File "/home/user/code/electrum-fork/electrum/util.py", line 495, in do_profile
o = func(*args, **kw_args)
File "/home/user/code/electrum-fork/electrum/gui/qt/main_window.py", line 589, in load_wallet
self.update_recently_opened_menu()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/home/user/code/electrum-fork/electrum/gui/qt/main_window.py", line 741, in update_recently_opened_menu
for i, k in enumerate(recent):
~~~~~~~~~^^^^^^^^
TypeError: 'NoneType' object is not iterable
```
This happens because the trustedcoin wallet is loaded outside of
Daemon.load_wallet() so Daemon.update_recently_opened_wallets()
is not getting called and config.RECENTLY:_OPEN_WALLET_FILES is
still None when we try to iterate through it.
As fix i now use load_wallet() instead of manually
instantiating the Wallet
and additionally handle
RECENTLY_OPEN_WALLET_FILES being None in
ElectrumWindow.update_recently_opened_menu().
My pull request https://github.com/spesmilo/electrum/pull/10121
would have sent this exception to the crash reporter so we
might have noticed it earlier. I think we should not just catch
all exceptions in the wizard like on master as it causes us to
repeatedly miss regressions in the wizard that could be sent to
the crash reporter.
Differentiate between the `UserFacingException` and other exceptions
when creating the storage. Forward other exceptions to the reporter so
they can get fixed.
Change fees from sats to bitcoin so the fee value is consistent with the
other values.
Fixes#10445
Also adds a plugin hook so plugins can create fancy history exports.
And stops adding unconfirmed/local transactions to the history as they
are unordered and make the export non-deterministic. Also transactions
that haven't happened yet don't seem useful for accounting.
So it can be moved out of HistoryList, get unittested and potentially
used by QML too for example.
Also fix inconsistency between fiat_value and fees_fiat, sometimes if
fiat_value was `No Data` (value=None), fees_fiat was '0' as
fees_fiat.value was Decimal() instead of None.
The `ServerWidget` didn't validate the input of server_e, which allowed
the user to enter an invalid server connection string and exit the
dialog without knowing they entered an invalid string.
In the wizard this behavior is very misleading as the user explicitly
wanted to use a custom server, can click next after entering an invalid
server, and we will just silently fall back to automatic server selection.
This change will disable the "Next" button in the wizard if an invalid
address has been entered and show a red background in the server_e while
the input is not valid, so the user clearly sees that this input is not
going to be used.
Moves the logic requesting the forward swap into the TxEditor so it can
use the open transport and doesn't have to reconnect to the relays
again.
Also disables the "Preview" button in the TxEditor when the transaction will
send change to lightning.
This should prevent the user from saving the transaction to history and
broadcasting it later or exporting it and broadcasting it through some
external way.
Broadcasting needs to happen directly after the TxEditor so we can send
the second rpc call to the swapserver and await the incoming htlcs
before broadcasting the (funding-) transaction.
Update the TxEditor (onchain tab) if Send change to lightning is enabled
and the swap transport changes. Connect to swap transport if send change
to lightning gets enabled or if it is enabled and the TxEditor gets
opened.
This allows to nicely show the swap fees without blocking the UI to wait
until the swap manager gets initialized.
Separates the swap transport initialization logic from the submarine
payment tab logic so it can be used for the send change to lightning
functionality too.
Also makes the gui updates on transport establishment more thread safe
by using pyqtSignals instead of calling gui methods from the asyncio
thread.