1
0
Commit Graph

18261 Commits

Author SHA1 Message Date
SomberNight
5c233ac325 ci: enable more flake8 stuff
```
$ export ELECTRUM_LINTERS=E9,E101,E129,E273,E274,E703,E71,E722,F5,F6,F7,F8,W191,W29,B
$ export ELECTRUM_LINTERS_IGNORE=B007,B009,B010,B019,B036,F541,F841
$ flake8 . --count --select="$ELECTRUM_LINTERS" --ignore="$ELECTRUM_LINTERS_IGNORE" --show-source --statistics --exclude "*_pb2.py,electrum/_vendor/"
./electrum/commands.py:98:1: F811 redefinition of unused 'format_satoshis' from line 48
def format_satoshis(x):
^
./electrum/commands.py:437:9: F811 redefinition of unused 'Mnemonic' from line 62
        from .mnemonic import Mnemonic
        ^
./electrum/gui/qt/wizard/wallet.py:37:5: F811 redefinition of unused 'Daemon' from line 14
    from electrum.daemon import Daemon
    ^
./electrum/lntransport.py:14:1: F811 redefinition of unused 'Optional' from line 12
from typing import NamedTuple, List, Tuple, Mapping, Optional, TYPE_CHECKING, Union, Dict, Set, Sequence
^
./electrum/lntransport.py:14:1: F811 redefinition of unused 'TYPE_CHECKING' from line 12
from typing import NamedTuple, List, Tuple, Mapping, Optional, TYPE_CHECKING, Union, Dict, Set, Sequence
^
./electrum/plugin.py:966:13: F811 redefinition of unused 'hid' from line 593
            import hid
            ^
./electrum/plugin.py:1040:13: F811 redefinition of unused 'hid' from line 593
            import hid
            ^
./electrum/util.py:44:1: F811 redefinition of unused 'json' from line 26
import json
^
./electrum/util.py:46:1: F811 redefinition of unused 'NamedTuple' from line 29
from typing import NamedTuple, Optional
^
./electrum/util.py:46:1: F811 redefinition of unused 'Optional' from line 29
from typing import NamedTuple, Optional
^
./electrum/util.py:1456:56: F811 redefinition of unused 'traceback' from line 34
        async def __aexit__(self, exc_type, exc_value, traceback):
                                                       ^
./electrum/wallet_db.py:536:9: F811 redefinition of unused 'LOCAL' from line 46
        LOCAL = 1
        ^
./electrum/wallet_db.py:537:9: F811 redefinition of unused 'REMOTE' from line 46
        REMOTE = -1
        ^
./tests/test_bitcoin.py:28:1: F811 redefinition of unused 'bitcoin' from line 9
from electrum import crypto, constants, bitcoin
^
./tests/test_txbatcher.py:11:1: F811 redefinition of unused 'Transaction' from line 7
from electrum.transaction import Transaction, PartialTxInput, PartialTxOutput, TxOutpoint
^
./tests/test_wallet_vertical.py:20:1: F811 redefinition of unused 'Transaction' from line 10
from electrum.transaction import Transaction, PartialTxOutput, tx_from_any, Sighash
^
16    F811 redefinition of unused 'format_satoshis' from line 48
16

```
2025-04-02 16:21:59 +00:00
SomberNight
55281295b7 ci: bump flake8 to new version
```
./electrum/commands.py:144:9: F824 `global known_commands` is unused: name is never assigned in scope
        global known_commands
        ^
./electrum/commands.py:1916:9: F824 `global known_commands` is unused: name is never assigned in scope
        global known_commands
        ^
./electrum/gui/qt/main_window.py:2405:13: F824 `nonlocal done` is unused: name is never assigned in scope
            nonlocal done
            ^
./electrum/i18n.py:52:5: F824 `global language` is unused: name is never assigned in scope
    global language
    ^
./electrum/plugin.py:189:9: F824 `global _root_permission_cache` is unused: name is never assigned in scope
        global _root_permission_cache
        ^
5     F824 `global known_commands` is unused: name is never assigned in scope
5

```
2025-04-02 14:56:53 +00:00
ThomasV
651e081b2f Merge pull request #9671 from accumulator/fix_lightning_can_receive_offline_peer
lnworker: take peer_state into account in get_channels_for_receiving
2025-04-02 14:33:45 +02:00
ghost43
bbea6223f1 Merge pull request #9692 from f321x/fix_channel_freezing
lightning: don't use frozen channels from route hint
2025-04-02 12:28:15 +00:00
f321x
964ffbd2c4 don't use route hint channels if they are frozen 2025-04-02 13:48:46 +02:00
Sander van Grieken
08e2970889 lnworker: add parameter include_disconnected for get_channels_for_receiving(),
allowing less strict filtering when building route hints (i.e. likely usable soon-ish)
2025-04-02 11:35:47 +02:00
ThomasV
ff3e70d743 psbt_nostr: fix for watch-only wallets 2025-04-02 11:31:08 +02:00
ghost43
edbb1f2a58 Merge pull request #9664 from SomberNight/202503_bump_freeze_packages
build: partial rerun freeze_packages
2025-04-01 17:01:02 +00:00
SomberNight
b70da1d3b9 build: set YARL_NO_EXTENSIONS for all builds
due to cython version mismatch -- easier to just disable the compilation for now
2025-04-01 16:59:26 +00:00
SomberNight
269a240fb9 build: partial rerun freeze_packages
update electrum-aionostr, aiorpcx, and aiohttp (and friends)
2025-04-01 16:59:22 +00:00
SomberNight
5f551183ae tests/test_txbatcher.py: fix race in network.next_tx()
With `txbatcher.SLEEP_INTERVAL = 0.01`, on my laptop, the batcher called try_broadcasting() even before next_tx() effectively awaited _tx_event.
This resulted in the test failing due to timeout.

Basically, if the txbatcher.SLEEP_INTERVAL was too low, the 2-4 event loop iterations needed to await _tx_event.wait() took too long.
(note that the exact number of event loop iterations needed depends on the python version and the OS)
2025-04-01 15:54:05 +00:00
SomberNight
2807be08c8 tests/test_txbatcher.py: de-duplicate "create wallet" logic 2025-04-01 15:00:23 +00:00
ghost43
664c4b25d1 Merge pull request #9689 from f321x/ln_disable_fallback_fee
lightning: don't use fallback feerates for lightning fee estimation
2025-04-01 12:20:32 +00:00
f321x
0b19b660c5 don't use fallback feerates in lightning by default 2025-04-01 14:12:02 +02:00
Sander van Grieken
1559129016 qml: properly destroy ExceptionDialog after close, improve encapsulation 2025-03-28 14:51:12 +01:00
Sander van Grieken
1d07895e8c qml: fix #9677 2025-03-27 19:16:29 +01:00
accumulator
bf317af30b Merge pull request #9672 from accumulator/qt_swaps_handle_usercancelled
qt: handle UserCancelled when initializing swapmanager and requesting…
2025-03-27 13:30:49 +01:00
accumulator
542897d067 Merge pull request #9668 from accumulator/qml_txdialog_sane_values
qml: ConfirmTxDialog: when finalizer is invalid, don't show input/out…
2025-03-27 12:44:49 +01:00
accumulator
8d044d43e0 Merge pull request #9661 from accumulator/qml_feebump_cancel_txmon_fixes
qml: detect transaction removed (e.g. replace-by-fee) for qetxdetails and qetxfinalizer
2025-03-26 14:41:05 +01:00
Sander van Grieken
9be6d6e732 small fixes, imports, whitespace 2025-03-25 16:50:37 +01:00
Sander van Grieken
f7c1b203b2 qt: handle UserCancelled when initializing swapmanager and requesting swap invoice
when sending change to lightning
2025-03-25 11:48:24 +01:00
accumulator
67171af4a5 Merge pull request #9663 from accumulator/qml_swap_success_popup
qml: swap: don't show long swap success message in info box, show in popup instead and close swap dialog after accept.
2025-03-24 19:59:41 +01:00
Sander van Grieken
2de11eac92 qml: ConfirmTxDialog: when finalizer is invalid, don't show input/outputs,
show requested amount instead of effectiveamount
2025-03-24 14:36:56 +01:00
ThomasV
1aa066ea19 wallet.py: rm unused imports 2025-03-22 13:54:29 +01:00
SomberNight
971d642c13 github: simplify issue template
it was annoying that the checkbox got included in the submitted issue

The "Description" text also gets included in the submitted issue, which is also annoying,
but I could not figure out how to remove that.
2025-03-21 17:41:45 +00:00
ThomasV
6e92a00ec4 Remove zeroconf option for submarine swaps
Since we now accept random swap providers, it is unreasonable
to keep that option.
2025-03-21 18:18:27 +01:00
Sander van Grieken
4494c3e2b5 qml: swap: don't show long swap success message in info box, show in popup instead
and close swap dialog after accept.
2025-03-21 18:16:57 +01:00
Sander van Grieken
f16efd759a qml: detect transaction removed (e.g. replace-by-fee) for qetxdetails and qetxfinalizer,
don't close active feebump/cancel dialogs, but invalidate them,
don't close TxDetails page, but show removed status,
show broadcast-failed status in TxDetails
2025-03-21 17:36:17 +01:00
Sander van Grieken
3db26c4ecb qml: correctly update mining fee for reverse swaps and inhibit delayed fwd swap ui update
when slider is on reverse swap side.
2025-03-21 16:32:13 +01:00
ThomasV
45b5bdca48 wallet: can_sign should return False for a swap claim tx, because it is handled by txbatcher 2025-03-21 16:31:11 +01:00
Sander van Grieken
91a72646ba qml: fix Open Channel button enable when amount changes 2025-03-21 15:49:34 +01:00
ThomasV
95a8959714 qt: add swap button to balance window 2025-03-21 14:09:11 +01:00
ThomasV
4aed77d101 qt: show error if we cannot contact swapserver while using http 2025-03-21 14:07:49 +01:00
SomberNight
937b157d29 qt: main_window: fix init_geometry
probably regression from qt6 migration

Don't use broad generic "except Exception" without at least logging the exception, please...
That's why this was not noticed before, the exception was being swallowed.

Nevertheless, on Linux with wayland, this still does not work (the geometry API is getting dumb values).
On x11 it now works again, as well as on Windows. (haven't tested macos)

```
  7.78 | I | gui.qt.main_window.[9dk] | using default geometry
Traceback (most recent call last):
  File "...\electrum\electrum\gui\qt\main_window.py", line 538, in init_geometry
    screen = self.app.desktop().screenGeometry()
AttributeError: 'QElectrumApplication' object has no attribute 'desktop'
```
2025-03-20 19:10:28 +00:00
ThomasV
e9335f5cc7 fix typo 2025-03-20 10:54:29 +01:00
ThomasV
707700d9f2 Merge pull request #9657 from f321x/use_ephemeral_dm
Use ephemeral event type for nostr swap request events
2025-03-20 10:18:55 +01:00
ThomasV
525e261520 lnworker: replace sometimes failing assert with print statement
this assert typically fails when a channel is force-closed and
the tx is unconfirmed
2025-03-20 10:09:04 +01:00
ThomasV
60338eba5d lnworker.handle_onchain_state early return if no network (follow-up fbebe7de1a) 2025-03-20 10:00:59 +01:00
f321x
9c7773c8db use ephemeral event type for nostr swap request events 2025-03-20 09:43:48 +01:00
ThomasV
4c14711dc7 Merge pull request #9656 from SomberNight/202503_configvar_plugins
plugin ConfigVars: define vars less dynamically
2025-03-20 08:45:40 +01:00
ThomasV
e7f9a213ad Merge pull request #9655 from SomberNight/202503_plugins_init_exception
plugins: better handle exceptions in `__init__`
2025-03-20 08:45:10 +01:00
SomberNight
245853ff4f plugins: ledger: bump max supported ledger_bitcoin version
ledger-bitcoin 0.4 was just released (seemingly without breaking changes)
the changelog claims they want to uphold semver
2025-03-19 17:29:40 +00:00
SomberNight
a99c454c00 plugin ConfigVars: enforce "key" starts with name of plugin 2025-03-19 16:49:56 +00:00
SomberNight
b132e357a3 plugin ConfigVars: define vars less dynamically
and restore ability to have different internal ConfigVar name and user-visible "key"
(Keys are hard to change as that breaks compat, but it is nice to be able to change
the internal var name, to reorganise stuff sometimes. After new ConfigVars are added,
sometimes we get better insight into how the older ones should have been named.)

follow-up https://github.com/spesmilo/electrum/pull/9648
2025-03-19 16:42:51 +00:00
SomberNight
83bf760c4a plugins: better handle exceptions in __init__
When importing a plugin, if it raised an exception in its `__init__` file, we
ignored it, and still loaded the plugin, in a potentially half-broken state.
This is because maybe_load_plugin_init_method only calls exec_module_from_spec
if the plugin is not already in sys.modules, but exec_module_from_spec
will put the plugin into sys.modules even if it errors.

Consider this patch to test with, enable the "labels" plugin:
```patch
diff --git a/electrum/plugins/labels/__init__.py b/electrum/plugins/labels/__init__.py
index b68127df8e..0d6d95abce 100644
--- a/electrum/plugins/labels/__init__.py
+++ b/electrum/plugins/labels/__init__.py
@@ -21,3 +21,5 @@ async def pull(self: 'Commands', plugin: 'LabelsPlugin' = None, wallet=None, for
     arg:bool:force:pull all labels
     """
     return await plugin.pull_thread(wallet, force=force)
+
+raise Exception("heyheyhey")

```

I would expect we don't load the labels plugin due to the error, but we do:
```
>>> plugins.get_plugin("labels")
<electrum.plugins.labels.qt.Plugin object at 0x7801df30fb50>
```

Log:
```
$ ./run_electrum -v --testnet -o
  0.75 | I | simple_config.SimpleConfig | electrum directory /home/user/.electrum/testnet
  0.75 | E | p/plugin.Plugins | cannot initialize plugin labels: Error pre-loading electrum.plugins.labels: Exception('heyheyhey')
Traceback (most recent call last):
  File "/home/user/wspace/electrum/electrum/plugin.py", line 148, in exec_module_from_spec
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/user/wspace/electrum/electrum/plugins/labels/__init__.py", line 25, in <module>
    raise Exception("heyheyhey")
Exception: heyheyhey

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/wspace/electrum/electrum/plugin.py", line 167, in load_plugins
    self.maybe_load_plugin_init_method(name)
  File "/home/user/wspace/electrum/electrum/plugin.py", line 293, in maybe_load_plugin_init_method
    module = self.exec_module_from_spec(init_spec, base_name)
  File "/home/user/wspace/electrum/electrum/plugin.py", line 150, in exec_module_from_spec
    raise Exception(f"Error pre-loading {path}: {repr(e)}") from e
Exception: Error pre-loading electrum.plugins.labels: Exception('heyheyhey')
  0.75 | D | util.profiler | Plugins.__init__ 0.0030 sec
  0.84 | I | simple_config.SimpleConfig | electrum directory /home/user/.electrum/testnet
  0.89 | I | __main__ | get_default_language: detected default as lang='en_UK'
  0.89 | I | i18n | setting language to 'en_UK'
  0.89 | I | logging | Electrum version: 4.5.8 - https://electrum.org - https://github.com/spesmilo/electrum
  0.89 | I | logging | Python version: 3.10.12 (main, Feb  4 2025, 14:57:36) [GCC 11.4.0]. On platform: Linux-6.8.0-52-generic-x86_64-with-glibc2.35
  0.89 | I | logging | Logging to file: /home/user/.electrum/testnet/logs/electrum_log_20250319T161247Z_6605.log
  0.89 | I | logging | Log filters: verbosity '*', verbosity_shortcuts ''
  0.89 | I | exchange_rate.FxThread | using exchange CoinGecko
  0.90 | D | util.profiler | Daemon.__init__ 0.0047 sec
  0.90 | I | daemon.Daemon | starting taskgroup.
  0.90 | I | daemon.CommandsServer | now running and listening. socktype=unix, addr=/home/user/.electrum/testnet/daemon_rpc_socket
  0.90 | I | p/plugin.Plugins | registering hardware bitbox02: ['hardware', 'bitbox02', 'BitBox02']
  0.90 | I | p/plugin.Plugins | registering hardware coldcard: ['hardware', 'coldcard', 'Coldcard Wallet']
  0.90 | I | p/plugin.Plugins | registering hardware digitalbitbox: ['hardware', 'digitalbitbox', 'Digital Bitbox wallet']
  0.90 | I | p/plugin.Plugins | could not find manifest.json of plugin hw_wallet, skipping...
  0.90 | I | p/plugin.Plugins | registering hardware jade: ['hardware', 'jade', 'Jade wallet']
  0.90 | I | p/plugin.Plugins | registering hardware keepkey: ['hardware', 'keepkey', 'KeepKey wallet']
  0.90 | I | p/plugin.Plugins | registering hardware ledger: ['hardware', 'ledger', 'Ledger wallet']
  0.90 | I | p/plugin.Plugins | registering hardware safe_t: ['hardware', 'safe_t', 'Safe-T mini wallet']
  0.90 | I | p/plugin.Plugins | registering hardware trezor: ['hardware', 'trezor', 'Trezor wallet']
  0.90 | I | p/plugin.Plugins | registering wallet type ('2fa', 'trustedcoin')
  1.01 | I | p/plugin.Plugins | loaded plugin 'labels'. (from thread: 'GUI')
  1.01 | D | util.profiler | Plugins.__init__ 0.1183 sec
```
2025-03-19 16:27:23 +00:00
ThomasV
0266832650 bump min version of electrum_aionostr and its dependencies 2025-03-19 16:21:09 +01:00
ThomasV
1e4728bdf1 Merge pull request #9560 from f321x/nostr_proxy
Pass proxy settings to aionostr manager for submarine swaps
2025-03-19 14:26:27 +01:00
ThomasV
e67cb560f6 Commands: add option documentation in docstring.
This allows plugins to document the commands they add.

The docstring is parsed as a regular expression:

    arg:<type>:<name>:<description>\n

Types are defined in commands.arg_types.

Note that this commit removes support for single letter
shortcuts in command options.

If a command is not properly documented, a warning is issued
with print(), because no logger is available at this point.
2025-03-19 13:03:38 +01:00
ThomasV
92b03d827c cmdline: suppress the display of global options when displaying the help of a command 2025-03-19 12:17:18 +01:00
ThomasV
d8964a00e7 config vars for plugins 2025-03-19 11:59:05 +01:00