1
0
Commit Graph

14341 Commits

Author SHA1 Message Date
SomberNight
7f876e46fb hw plugins: (follow-up) rm some more dead code
follow-up 30623c3529
2022-05-11 19:41:25 +02:00
SomberNight
6c50d3b0a3 hw plugins: (cleanup) rm no-op clear_client argument from keystore.give_error
The keystore does not have a "client" field.
One is supposed to use the "get_client" method instead (the generic API is `plugin.get_client(keystore)`)
Remnants of old code.
2022-05-11 19:30:14 +02:00
SomberNight
aab8e664ed hw plugins: (cleanup) Plugin objects should not have a Client field
Clients are per-connected-device, plugins are ~singletons.
These were mostly remnants of old code.
2022-05-11 19:16:18 +02:00
SomberNight
30623c3529 hw plugins: (cleanup) Plugin objects should not have a Handler field
Handlers are per-client (connected device), plugins are ~singletons.
These were mostly remnants of old code.
2022-05-11 19:13:00 +02:00
SomberNight
1fedb23946 appimage: update package (libdbus-1-3) in dockerfile 2022-05-11 18:08:36 +02:00
SomberNight
d499dde811 addr_sync: get_balance change cache_key to have delimiters
re https://github.com/spesmilo/electrum/pull/7807/files#r870482609
2022-05-11 17:54:33 +02:00
ThomasV
0d66409fbd follow-up prev commit 2022-05-11 09:43:10 +02:00
ThomasV
a8fc0a8f81 Qt: move open_channel_dialog code in separate module
(no functional change in this commit)
2022-05-11 09:39:45 +02:00
ThomasV
1d498eeefc Change the semantics of get_balance:
It does not make sense to count change outputs in our unconfirmed balance,
because our balance will not be negatively affected if the transaction does
not get confirmed.

It is also incorrect to add signed values of get_addr_balance in order to compute
the balance over a domain. For example, this leads to incoming and outgoing
transactions cancelling out in our total unconfirmed balance.

This commit looks at the coins that are spent by a transaction. If those
coins belong to us and are confirmed, we do not count the transaction outputs
in our unconfirmed balance.

As a result, get_balance always returns positive values for unconfirmed balance.
2022-05-11 08:50:09 +02:00
ThomasV
1274ec7655 Qt balance piechart: show lightning funds that are frozen 2022-05-10 20:07:30 +02:00
SomberNight
9599254d43 hw: rm dead code from Hardware_KeyStore subclasses
- force_watching_only is long since unused
- comment was just duplicated from the base class
2022-05-09 20:09:10 +02:00
SomberNight
3535eef8f8 (trivial) qt locktimeedit: fix a DeprecationWarning
/home/user/wspace/electrum/electrum/gui/qt/locktimeedit.py:145: DeprecationWarning: an integer is required (got type Alignment).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  painter.drawText(textRect, Qt.AlignRight | Qt.AlignVCenter, "height")
2022-05-09 19:50:38 +02:00
SomberNight
9e0a0af81a bip39_recovery: also scan change addresses
fixes https://github.com/spesmilo/electrum/issues/7804
2022-05-07 18:52:33 +02:00
ThomasV
dd43ccfda9 get_history: minor simplification 2022-05-07 18:46:28 +02:00
SomberNight
2e99ac9a94 qt preferences: fix "allow_instant_swaps" checkbox 2022-05-07 16:20:16 +02:00
ThomasV
2022b2e341 Merge pull request #7797 from SomberNight/202205_distutils
vendor a part of `distutils`, to be removed from stdlib in py3.12
2022-05-07 09:45:29 +02:00
SomberNight
37ba7277ae qt main_window: fix visual artifact when opening (re invoice lists)
InvoiceList.update() calls hide_if_empty(), which calls setVisible().
setVisible(True) should not be called before the widget is properly parented and put into a layout,
as that results in a blank window flashing up (appearing and disappearing) briefly.
2022-05-06 20:02:53 +02:00
SomberNight
a15ed939b7 setup.py: use relative paths in data_files
fixes https://github.com/spesmilo/electrum/issues/7787
fixes https://github.com/spesmilo/electrum/issues/5227
closes https://github.com/spesmilo/electrum/pull/5553
2022-05-06 16:32:06 +02:00
ThomasV
b0a6f895b2 Qt: add help text to receive address widget 2022-05-06 11:35:52 +02:00
ThomasV
ad70659a66 qr code widget: set margin to zero, print warning if cannot draw 2022-05-06 11:33:10 +02:00
gruve-p
eb66ed8e4b appimage: update libssl-dev libssl1.0.0 openssl libsqlite3-dev (#7798) 2022-05-05 14:57:35 +00:00
SomberNight
d5f987c9e9 hw keepkey: workaround protobuf weirdness
this adds a hackish workaround for https://github.com/spesmilo/electrum/issues/7779
2022-05-04 20:41:49 +02:00
SomberNight
d429b58168 vendor a part of distutils, to be removed from stdlib in py3.12
distutils (a module in the python standard library that we use) got deprecated in python 3.10,
and is planned to be removed from the stdlib in python 3.12.
see 9d38120e33/Lib/distutils/__init__.py (L16)
We only use it in the Qt update_checker (for signed version notifications), to compare version numbers.
That is, we only use a very small part of it (only `distutils.version.StrictVersion`).

```
.../electrum/electrum/gui/qt/update_checker.py:7: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.version import StrictVersion
```

Migration advice in PEP-632 suggests ( https://peps.python.org/pep-0632/#migration-advice ):
> `distutils.version` — use the `packaging` package

Note that `packaging` is a 3rd party package, i.e. it would be a new dependency.
Also, it does not provide an identical replacement for `distutils.version.StrictVersion`.

Care needs to be taken when changing the semantics of version numbers...
E.g. `packaging.parse` and `packaging.Version` are less strict than what we currently use.
We have to be careful that old code recognises new electrum version numbers as both valid
and numerically greater than their version.

I think the easiest approach is for us to vendor this small part of distutils.
Re directory structure, this is based on `pip`:
bab5bfce50/src/pip/_vendor
(although the approach here is much more naive ofc)
2022-05-04 19:59:59 +02:00
SomberNight
dbc695ba4a follow-up prev
The Windows build was failing due to the trailing slash in the path:
```
💬 INFO:  Pip installing Electrum. This might take a long time if the project folder is large.
Processing c:\electrum
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error

  python setup.py egg_info did not run successfully.
  exit code: 1

  [10 lines of output]
  Traceback (most recent call last):
    File "<string>", line 2, in <module>
    File "<pip-setuptools-caller>", line 34, in <module>
    File "C:\electrum\setup.py", line 75, in <module>
      find_packages('electrum/', exclude=["tests", "gui.kivy", "gui.kivy.*"])]),
    File "C:\python3\lib\site-packages\setuptools\discovery.py", line 103, in find
      convert_path(str(where)),
    File "C:\python3\lib\site-packages\setuptools\_distutils\util.py", line 130, in convert_path
      raise ValueError("path '%s' cannot end with '/'" % pathname)
  ValueError: path 'electrum/' cannot end with '/'
```
This is weird because I tested the setuptools.find_packages invocation on Linux, where it
has no issues with the trailing slash, but indeed it looks like on Windows it does.
Not sure why it behaves differently depending on the platform. Anyway, removing.
2022-05-04 19:58:16 +02:00
SomberNight
92ff7de756 setup.py: use find_packages more heavily
No change in behaviour as-is.
In the future, if we add a new folder with an __init__.py file, it will get included by default,
whereas in the past it would not.
i.e. this is changing what we manually have to specify from a whitelist to a blacklist.
2022-05-04 19:27:05 +02:00
SomberNight
443a76240d interface.get_block_header: assert height >= 0 2022-05-04 17:53:13 +02:00
ThomasV
6a9df7d827 Merge pull request #7792 from SomberNight/202204_asyncio_cleanups
asyncio: stop using get_event_loop(). introduce ~singleton loop.
2022-05-04 09:28:54 +02:00
SomberNight
872ce82418 tests: clean up event-loop creation 2022-05-04 01:53:21 +02:00
ThomasV
56124ad15a swap_dialog: raise recv_amount when min_mount is received 2022-04-30 15:23:47 +02:00
SomberNight
2c57c78ebe asyncio: stop using get_event_loop(). introduce ~singleton loop.
asyncio.get_event_loop() became deprecated in python3.10. (see https://github.com/python/cpython/issues/83710)
```
.../electrum/electrum/daemon.py:470: DeprecationWarning: There is no current event loop
  self.asyncio_loop = asyncio.get_event_loop()
.../electrum/electrum/network.py:276: DeprecationWarning: There is no current event loop
  self.asyncio_loop = asyncio.get_event_loop()
```
Also, according to that thread, "set_event_loop() [... is] not deprecated by oversight".
So, we stop using get_event_loop() and set_event_loop() in our own code.
Note that libraries we use (such as the stdlib for python <3.10), might call get_event_loop,
which then relies on us having called set_event_loop e.g. for the GUI thread. To work around
this, a custom event loop policy providing a get_event_loop implementation is used.

Previously, we have been using a single asyncio event loop, created with
util.create_and_start_event_loop, and code in many places got a reference to this loop
using asyncio.get_event_loop().
Now, we still use a single asyncio event loop, but it is now stored as a global in
util._asyncio_event_loop (access with util.get_asyncio_loop()).

I believe these changes also fix https://github.com/spesmilo/electrum/issues/5376
2022-04-29 18:49:07 +02:00
ThomasV
fdee31af05 Qt settings_dialog: use signals
- changes must apply to all windows
 - do not keep reference to the window object
2022-04-29 17:04:16 +02:00
ThomasV
334da245dc (minor) fix checkbox in qt settings 2022-04-29 13:03:33 +02:00
ThomasV
f4e902e907 LNWorker: give up payment after timeout, not number of attempts.
Limiting attempts may interrupt a MPP before we receive a MPP_timeout
The attempts parameter is still used in unit tests.
2022-04-29 12:17:38 +02:00
SomberNight
1182972be1 hardware wallets: mention keystore.label in select_device
Without it, it is not clear for which keystore the user is supposed to select the device.
(though note that not all plugins implement labels, e.g. ledger does not)

related: https://github.com/spesmilo/electrum/issues/4199#issuecomment-1112552416
2022-04-28 21:38:12 +02:00
SomberNight
238619f1ed hardware wallets: smarter pairing during sign_transaction
Scenario:
- 2of2 multisig wallet with device1 and device2
- disconnect all devices
- open wallet file
- fail all pairings at wallet-open
- connect device2
- try to sign a tx
At this point Electrum will try to find the device for keystore1 first, and there is only a single unpaired device: device2.
Automatic pairing of keystore1 and device2 will fail, due to device id mismatching compared to what is persisted on disk for keystore1, so the user is prompted for manual selection. The selection dialog is somewhat confusing as it is not clear that the app is asking to select a device for keystore1. Pairing would fail, so the user is expected to cancel the dialog. If they cancel, keystore1 is skipped, and we try to pair for keystore2 now, and device2 will pair with it automatically.

fixes https://github.com/spesmilo/electrum/issues/4199#issuecomment-1112552416
2022-04-28 21:38:08 +02:00
SomberNight
610dd7ce83 hardware wallets: redefine "id_" for hid devices to avoid collisions
I had a ledger nano S and a ledger nano S plus connected at the same time,
and the "id_"s were colliding resulting in weird behaviour. Multisig was pretty
much not usable with both devices connected simultaneously.

Example dicts returned by `hid.enumerate(0, 0)`:

{'path': b'\\\\?\\hid#vid_2c97&pid_1015&mi_00#a&2a30{REDACTED}&0&0000#{REDACTED_UUID}', 'vendor_id': 11415, 'product_id': 4117, 'serial_number': '0001', 'release_number': 513, 'manufacturer_string': 'Ledger', 'product_string': 'Nano S', 'usage_page': 65440, 'usage': 1, 'interface_number': 0},

{'path': b'\\\\?\\hid#vid_2c97&pid_5011&mi_00#a&28d{REDACTED}&0&0000#{REDACTED_UUID}', 'vendor_id': 11415, 'product_id': 20497, 'serial_number': '0001', 'release_number': 513, 'manufacturer_string': 'Ledger', 'product_string': 'Nano S Plus', 'usage_page': 65440, 'usage': 1, 'interface_number': 0}
2022-04-28 21:38:05 +02:00
ThomasV
3c7d5663fd Update SECURITY.md 2022-04-28 18:28:09 +02:00
ThomasV
90d2d826a4 Update SECURITY.md
updated email addresses
2022-04-28 18:27:34 +02:00
ThomasV
1f7ada3486 minor: fix #7789 2022-04-28 15:26:20 +02:00
ThomasV
96433ea2b4 Merge pull request #7778 from SomberNight/202204_invoice_recalc_ids
wallet_db upgrade: recalc keys of outgoing on-chain invoices
2022-04-28 15:12:29 +02:00
ThomasV
44f29331bf lnwatcher: in inspect_tx_candidate, match witness scripts against HTLC templates
fixes #7781
2022-04-28 13:21:10 +02:00
ThomasV
cbeea6e42a fix #7783 2022-04-27 10:06:05 +02:00
ThomasV
e3beae5c00 Merge pull request #7761 from SomberNight/202204_versioninfo_cmd
add `version_info` command
2022-04-27 09:59:27 +02:00
ghost43
c45170acfb Merge pull request #7785 from SomberNight/202204_bump_appimage
build appimage: bump pkg2appimage version
2022-04-26 18:29:10 +00:00
Michel van Kessel
54f5ad46b3 appimage: update package (git) in dockerfile (#7786)
https://launchpad.net/ubuntu/+source/git/1:2.17.1-1ubuntu0.11
2022-04-26 18:28:29 +00:00
SomberNight
de724a214d asyncio: addr_sync: maybe fix "no current event loop in thread"
see https://github.com/spesmilo/electrum/issues/5376
crash report for electrum 4.2.1:
```
Traceback (most recent call last):
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-arm64-v8a/build/python-installs/Electrum/kivy/base.py", line 347, in mainloop
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-arm64-v8a/build/python-installs/Electrum/kivy/base.py", line 391, in idle
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-arm64-v8a/build/python-installs/Electrum/kivy/base.py", line 342, in dispatch_input
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-arm64-v8a/build/python-installs/Electrum/kivy/base.py", line 308, in post_dispatch_input
  File "kivy/_event.pyx", line 724, in kivy._event.EventDispatcher.dispatch
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-arm64-v8a/build/python-installs/Electrum/kivy/uix/behaviors/button.py", line 179, in on_touch_up
  File "kivy/_event.pyx", line 720, in kivy._event.EventDispatcher.dispatch
  File "kivy/_event.pyx", line 1263, in kivy._event.EventObservers.dispatch
  File "kivy/_event.pyx", line 1147, in kivy._event.EventObservers._dispatch
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-arm64-v8a/build/python-installs/Electrum/kivy/lang/builder.py", line 57, in custom_callback
  File "<string>", line 42, in <module>
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/gui/kivy/uix/dialogs/wallets.py", line 70, in cb
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/gui/kivy/main_window.py", line 710, in load_wallet_by_name
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/gui/kivy/main_window.py", line 728, in on_open_wallet
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/gui/kivy/main_window.py", line 691, in on_wizard_success
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/wallet.py", line 3267, in __new__
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/wallet.py", line 3111, in __init__
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/wallet.py", line 2904, in __init__
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/wallet.py", line 288, in __init__
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/address_synchronizer.py", line 97, in __init__
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/wallet.py", line 402, in load_and_cleanup
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/address_synchronizer.py", line 106, in load_and_cleanup
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/util.py", line 439, in <lambda>
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/util.py", line 435, in do_profile
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/address_synchronizer.py", line 432, in load_local_history
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/address_synchronizer.py", line 533, in _add_tx_to_local_history
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/address_synchronizer.py", line 548, in _mark_address_history_changed
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-arm64-v8a/build/other_builds/python3/arm64-v8a__ndk_target_21/python3/Lib/asyncio/locks.py", line 260, in __init__
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-arm64-v8a/build/other_builds/python3/arm64-v8a__ndk_target_21/python3/Lib/asyncio/events.py", line 639, in get_event_loop
RuntimeError: There is no current event loop in thread 'GUI'.
```
2022-04-26 20:24:15 +02:00
SomberNight
1dd6a2019a asyncio: sql_db: maybe fix "no current event loop in thread"
see https://github.com/spesmilo/electrum/issues/5376
crash report for electrum 4.2.1:
```
Traceback (most recent call last):
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/Electrum/kivy/base.py", line 347, in mainloop
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/Electrum/kivy/base.py", line 391, in idle
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/Electrum/kivy/base.py", line 342, in dispatch_input
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/Electrum/kivy/base.py", line 308, in post_dispatch_input
  File "kivy/_event.pyx", line 724, in kivy._event.EventDispatcher.dispatch
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/Electrum/kivy/uix/behaviors/button.py", line 179, in on_touch_up
  File "kivy/_event.pyx", line 720, in kivy._event.EventDispatcher.dispatch
  File "kivy/_event.pyx", line 1263, in kivy._event.EventObservers.dispatch
  File "kivy/_event.pyx", line 1147, in kivy._event.EventObservers._dispatch
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/Electrum/kivy/lang/builder.py", line 57, in custom_callback
  File "<string>", line 39, in <module>
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/gui/kivy/uix/dialogs/settings.py", line 173, in cb
  File "kivy/properties.pyx", line 498, in kivy.properties.Property.__set__
  File "kivy/properties.pyx", line 545, in kivy.properties.Property.set
  File "kivy/properties.pyx", line 600, in kivy.properties.Property.dispatch
  File "kivy/_event.pyx", line 1263, in kivy._event.EventObservers.dispatch
  File "kivy/_event.pyx", line 1169, in kivy._event.EventObservers._dispatch
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/gui/kivy/main_window.py", line 206, in on_use_gossip
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/network.py", line 368, in start_gossip
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/channel_db.py", line 308, in __init__
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/sql_db.py", line 30, in __init__
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Lib/asyncio/locks.py", line 260, in __init__
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Lib/asyncio/events.py", line 639, in get_event_loop
RuntimeError: There is no current event loop in thread 'GUI'.
```
2022-04-26 20:24:11 +02:00
SomberNight
f10752b523 lnworker: LNWallet.start_network to call super().start_network
The call to super was removed in 4efcb53d24 ,
so that LNWallet's taskgroup would not run _maintain_connectivity, AFAICT.
The way it was done meant that "main_loop" itself would not run for LNWallet, only for LNGossip - very confusing.
It is only due to a quirk in the behaviour of TaskGroups that the group "started" at all.
2022-04-26 20:24:08 +02:00
SomberNight
b7dd51612e asyncio: use loop.create_future() instead of asyncio.Future()
from https://docs.python.org/3.10/library/asyncio-future.html#asyncio.Future :
> the recommended way to create a Future object is to call loop.create_future().
> This way alternative event loop implementations can inject their own optimized implementations of a Future object.
2022-04-26 20:24:04 +02:00
Rogach
6d049a30f2 fix typo in warning message shown when enabling lightning (#7782) 2022-04-25 21:35:42 +00:00