Commit Graph

191 Commits

Author SHA1 Message Date
SomberNight
05649861c8 qt gui: more resilient startup: catch more exceptions, better fallback
fixes https://github.com/spesmilo/electrum/issues/7447

Consider this trace for 4.2.0:
```
Traceback (most recent call last):
  File "electrum/gui/qt/__init__.py", line 332, in start_new_window
  File "electrum/gui/qt/__init__.py", line 363, in _start_wizard_to_select_or_create_wallet
  File "electrum/gui/qt/installwizard.py", line 302, in select_storage
  File "electrum/util.py", line 504, in get_new_wallet_name
PermissionError: [Errno 1] Operation not permitted: '/Users/admin/Documents/Peach/MS'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "electrum/gui/qt/__init__.py", line 426, in main
  File "electrum/gui/qt/__init__.py", line 307, in wrapper
  File "electrum/gui/qt/__init__.py", line 349, in start_new_window
  File "electrum/util.py", line 504, in get_new_wallet_name
PermissionError: [Errno 1] Operation not permitted: '/Users/admin/Documents/Peach/MS'
```

Note that `get_new_wallet_name` (os.listdir) can raise OSError,
and we were calling that on the main entrypoint codepath without exception-handling.
We were also calling it in the fallback codepath without exception-handling.
i.e. the GUI errored out on every startup for affected users, and without CLI usage
it was not possible to recover.
2022-03-23 03:58:33 +01:00
SomberNight
cf3f92531e aiorpcx: monkeypatch TimeoutAfter internals
see https://github.com/kyuupichan/aiorpcX/issues/44
2022-02-15 18:22:47 +01:00
SomberNight
c9c094cfab requirements: bump min aiorpcx to 0.22.0
aiorpcx 0.20 changed the behaviour/API of TaskGroups.
When used as a context manager, TaskGroups no longer propagate
exceptions raised by their tasks. Instead, the calling code has
to explicitly check the results of tasks and decide whether to re-raise
any exceptions.
This is a significant change, and so this commit introduces "OldTaskGroup",
which should behave as the TaskGroup class of old aiorpcx. All existing
usages of TaskGroup are replaced with OldTaskGroup.

closes https://github.com/spesmilo/electrum/issues/7446
2022-02-15 18:22:44 +01:00
SomberNight
c131831373 util: rm SilentTaskGroup. this does not seem to be needed anymore
I think this was originally needed due to incorrect management of group lifecycles,
which our current code is doing better.

also note that if we needed this, in newer aiorpcx, the name of
the field was ~changed from `_closed` to `joined`:
239002689a
2022-02-15 18:22:40 +01:00
SomberNight
3f3212e94d some clean-ups now that we require python 3.8
In particular, asyncio.CancelledError no longer inherits Exception (it inherits BaseException directly)
2022-02-15 18:22:36 +01:00
SomberNight
88a1c1a618 python 3.10: fix some deprecation warnings and compat with 3.10 2021-11-09 01:02:57 +01:00
SomberNight
c331c311db crash reporter: add EarlyExceptionsQueue
`util.send_exception_to_crash_reporter` is now useful and can be transparently
used even before the exception hook is set up.
2021-11-05 20:01:43 +01:00
SomberNight
acbb363240 follow-up prev: some clean-ups
re https://github.com/spesmilo/electrum/pull/7492
2021-09-15 16:41:41 +02:00
Siddhant Chawla
65c3a892cf Multiple max spends functionality added (#7492)
this implements https://github.com/spesmilo/electrum/issues/7054
2021-09-15 14:35:15 +00:00
SomberNight
9f5370f9c6 util.format_satoshis: fix (add_thousands_sep & whitespaces) param combo 2021-07-28 15:29:12 +02:00
djboi
6a431aab8c Fixed issue with thousands separator for better readability (#7427)
util.format_satoshis: introduce new option to add thousands separators
2021-07-28 13:26:30 +00:00
SomberNight
18c9a1af10 kivy: format_amount: minor clean-up 2021-07-21 18:35:06 +02:00
SomberNight
46badd128e util.format_satoshis: fix whitespaces param for non-zero precision 2021-07-20 20:31:48 +02:00
SomberNight
5c80293696 util.format_satoshis: fix for amounts with higher than sat precision
Previously, msat precision was leaking through format_satoshis if the
user's base unit was set to "sat". This was a bug.
Some features of format_satoshis did not work well with such values, such
as the "whitespaces" param.

Old code:

>>> util.format_satoshis(Decimal('45831275.748'), decimal_point=2)
'458312.76'
>>> util.format_satoshis(Decimal('45831275.748'), decimal_point=0)
'45831275.748'

New code:

>>> util.format_satoshis(Decimal('45831275.748'), decimal_point=2)
'458312.76'
>>> util.format_satoshis(Decimal('45831275.748'), decimal_point=0)
'45831276.'
2021-07-20 20:02:45 +02:00
MrNaif2018
aafa74ed08 Improve _mythread checks (#7403)
* Improve _mythread checks

* Create get_running_loop util
2021-07-15 14:52:25 +00:00
SomberNight
57e52da77f lnaddr: clean-up SEGWIT_HRP vs BOLT11_HRP confusion
With signet, SEGWIT_HRP != BOLT11_HRP, so the previous "currency" string
became a flawed concept. Instead we pass around net objects now.
2021-06-22 16:16:21 +02:00
ghost43
5dff461aaa Merge pull request #7282 from wakiyamap/add_signet
add signet support
2021-06-22 16:15:38 +02:00
bitromortac
6ce96306ca util: check bip21 url for amount 2021-05-06 15:37:17 +02:00
wakiyamap
639cd94dcb add signet support 2021-05-06 19:47:22 +09:00
bitromortac
63308f94a0 reorganize with_lock decorator 2021-04-02 09:38:39 +02:00
ThomasV
18d7db12da Change warning shown on first channel creation
Qt: if created channel is not recoverable, show channel backup after creation
2021-03-24 10:24:14 +01:00
Benoit Verret
f731c38293 Minor style changes 2021-03-21 00:36:23 -04:00
ThomasV
2fee920f43 On Android, if channels are not recoverable, display channel backup when a new channel is created.
Remove the 'android_backups' setting, which was unpractical.
2021-03-19 13:17:58 +01:00
SomberNight
1ba5997238 qt lightning_tx_dialog: use historical fx rate for fiat amounts 2021-03-12 18:29:00 +01:00
SomberNight
28a7d204ad util: document CallbackManager behaviour 2021-03-11 18:50:59 +01:00
SomberNight
05fd424548 tests: maybe fix tearDown() issue in test_storage_upgrade.py
from travis logs:

--- Logging error ---

Traceback (most recent call last):
  File "/opt/python/3.7.6/lib/python3.7/logging/__init__.py", line 1028, in emit
    stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.

Call stack:
  File "/opt/python/3.7.6/lib/python3.7/threading.py", line 890, in _bootstrap
    self._bootstrap_inner()
  File "/opt/python/3.7.6/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/home/travis/build/spesmilo/electrum/electrum/plugin.py", line 213, in run
    self.run_jobs()
  File "/home/travis/build/spesmilo/electrum/electrum/util.py", line 359, in on_stop
    self.logger.info("stopped")
Message: 'stopped'
2021-03-10 20:16:25 +01:00
SomberNight
5339e0054c network.stop: clean-up 2021-03-10 19:01:30 +01:00
SomberNight
3c019c2f9c daemon/wallet/network: make stop() methods async 2021-03-09 17:52:36 +01:00
SomberNight
1dbff51fce synchronizer: fix rare race where synchronizer could get stuck 2021-03-05 20:46:41 +01:00
SomberNight
ff485cee62 use functools.wraps() for some wrappers
to help debugging
2021-03-04 16:44:13 +01:00
SomberNight
bf7129d57e synchronizer/verifier: ensure fairness between wallets (follow-up)
follow-up to 4346d2fc76

It's not just about the Synchronizer, the Verifier should not starve other jobs either...
(previously I thought the Verifier is not too important as it only makes
requests if there are new txs; however with LNWatcher its progress is not persisted)
2021-03-01 13:08:01 +01:00
SomberNight
24d47022b4 util: assert that Decimal precision is sufficient
Just for sanity... e.g. when importing electrum as a python library,
the calling code could have changed the precision.

related: #5223
2021-02-18 03:02:25 +01:00
SomberNight
7294613447 util.is_hex_str: forbid whitespaces 2021-01-27 20:46:46 +01:00
SomberNight
1abecf25c9 qt block explorer: allow custom URL
The QTextEdit expects values such as (one per line):
```
https://blockstream.info/testnet/
https://192.168.0.38:3021/
("https://blockstream.info/testnet/", {'tx': 'tx/', 'addr': 'address/'})
```

closes #4831
2021-01-24 07:11:11 +01:00
SomberNight
d40bedb2ac also support uppercase bip21 URIs
related https://github.com/btcpayserver/btcpayserver/issues/2110
2020-12-09 16:09:12 +01:00
SomberNight
8c5601a172 dnspython: fix deprecation warnings when using dnspython 2.0
related: #6828
2020-12-09 09:04:04 +01:00
SomberNight
dbb7d7ce4d network: set _loop_thread again as it helps debugging
related: #6825
2020-12-08 11:48:01 +01:00
Stephan Oeste
a5acb7d695 add mempool.emzy.de
Same software as mempool.space other operator.
2020-11-22 01:43:47 +01:00
SomberNight
57768244bb qt history list: fix #6746 2020-11-18 23:50:08 +01:00
SomberNight
120da2783b util.randrange: use stdlib 'secrets' module instead of 'python-ecdsa' 2020-11-07 19:26:30 +01:00
SomberNight
c5da22a9dd network: tighten checks of server responses for type/sanity 2020-10-16 19:30:42 +02:00
bitromortac
193b17f0e4 util: move json_normalize to util 2020-09-24 07:32:18 +02:00
SomberNight
ea3e3ddbb8 lnpeer: handle cooperative close edge-case
fix #6317
2020-09-13 16:55:37 +02:00
SomberNight
5d723401f8 util.NetworkRetryManager: fix potential overflow
e.g. consider:
>>> 1.5 * 2 ** 2000
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: int too large to convert to float
2020-08-27 17:57:19 +02:00
SomberNight
36178df875 sql: test read-write permissions for given path and raise early
maybe fix #6485
2020-08-25 18:18:07 +02:00
Tigerix
8539beb75e Update util.py
Fixed Blockchain.com Testnet-URL
2020-07-05 12:59:09 +02:00
SomberNight
d19ff43266 interface: check server response for some methods
some basic sanity checks

Previously if the server sent back a malformed response, it could partially corrupt a wallet file.
(as sometimes the response would get persisted, and issues would only arise later when the values were used)
2020-07-02 15:41:39 +02:00
richard
b1a70be079 Add mempool.space option for mainnet block explorer (#6261)
* Add mempool.space

* Adds mempool.space testnet explorer

Didn't realize they had testnet as well - added
2020-06-25 17:00:20 +00:00
SomberNight
662d0d92bd remote watchtower: enforce that SSL is used, on the client-side 2020-06-24 16:57:50 +02:00
SomberNight
d5f368c584 LN invoices: support msat precision
fixes #6250
2020-06-22 22:48:13 +02:00