1
0
Commit Graph

18229 Commits

Author SHA1 Message Date
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
ThomasV
647ae49451 Merge pull request #9651 from f321x/plugin_manifest_json
Use manifest.json instead of loading init file for plugin registration
2025-03-19 10:52:02 +01:00
f321x
a9f8048251 use manifest.json instead of loading init file for plugin registration 2025-03-19 10:38:20 +01:00
ThomasV
cbef1bc4b0 Merge pull request #9652 from SomberNight/202503_rm_ledger_hw1
plugins: ledger: rm support for hw.1
2025-03-19 08:04:16 +01:00
SomberNight
536fce3f94 cli: don't add wallet to running online GUI, if called with -o 2025-03-18 19:33:24 +00:00
SomberNight
d36e877eb8 lnworker: comment re hist: if paying MPP, amt and fee might be shifted
a bit confusing behaviour
2025-03-18 19:25:18 +00:00
ThomasV
26910ef81d Merge pull request #9620 from accumulator/lightning_pass_invoice_not_bolt11
refactor lnworker.pay_invoice to accept Invoice object instead of bolt11 string
2025-03-18 20:09:01 +01:00
SomberNight
4c970fd8fa plugins: ledger: better error msg for hw.1 2025-03-18 17:26:12 +00:00
SomberNight
154adf0081 plugins: ledger: rm support for hw.1
This removes support for Ledger HW.1 and "Nano" (non-S) devices.
These were manufactured/sold around 2015-2016, and are long unsupported by the upstream vendor.

We previously added a deprecation warning to the GUI [0] released in 4.3.3 (2023-01-02), to warn owners of these devices.
This PR now fully removes support.

As a consequence, the unmaintained btchip-python dependency can now be removed, which solves [1].

[0]: 9b82eb6d06
[1]: https://github.com/spesmilo/electrum/issues/9370#issuecomment-2593675364
2025-03-18 16:18:49 +00:00
SomberNight
7737dbf795 plugins: ledger: fix Ledger_Client_Legacy.sign_transaction
regression from 2f1095510c
2025-03-18 15:34:17 +00:00
ThomasV
38f9cac48c Merge pull request #9649 from f321x/move_commands_to_init
Move plugin commands to init file of plugin
2025-03-18 11:14:30 +01:00
f321x
e74029c880 move plugin commands to init file of plugin 2025-03-18 09:37:07 +01:00
ghost43
75cef43f9c Merge pull request #9650 from SomberNight/202503_keepkey
plugins: keepkey: vendor our fork of keepkeylib (as git submodule)
2025-03-17 18:27:42 +00:00
SomberNight
822ab5d73c requirements: follow-up prev: rm protobuf upper bound
now that the keepkey pb2's are regenerated using the "new" format,
we don't need an old python3-protobuf to parse them

ref https://github.com/spesmilo/electrum/issues/7922
2025-03-17 17:53:51 +00:00
SomberNight
c8143957a6 plugins: keepkey: rm dependence on external keepkeylib
we will instead bundle our own fork, as a git submodule,
https://github.com/spesmilo/electrum-keepkeylib

related https://github.com/spesmilo/electrum/issues/7922
and https://github.com/keepkey/python-keepkey/issues/146
(i.e. upstream keepkeylib is unmaintained)
2025-03-17 17:53:48 +00:00
SomberNight
457979ce63 plugin.py: fix plugin.read_file
follow-up 246f03fe20
2025-03-17 17:52:31 +00:00
ThomasV
e7907d31cc Merge pull request #9646 from f321x/plugins_import_dir_and_zip
Allow all plugins to be either zip or directory based
2025-03-17 16:41:37 +01:00
f321x
246f03fe20 allow all plugins to be either zip or directory based 2025-03-17 16:27:33 +01:00
ThomasV
bea4c617f6 Merge pull request #9645 from oren-z0/fix-base-tx-type
fix base_tx type
2025-03-17 14:04:44 +01:00
Oren
e658d9118a fix base_tx type
base_tx in make_unsigned_transaction
is expected to be of type
Optional[Transaction], not boolean.
2025-03-17 14:54:48 +02:00
ThomasV
3463e68306 add accounting addresses 2025-03-17 10:47:19 +01:00
ThomasV
2133427f53 fix issue #9543 2025-03-17 10:46:00 +01:00
ThomasV
58be5a3ad5 Allow wallets to use non-deterministic lightning,
if they use a software keystore.

This excludes hardware wallets and watching-only wallet.
Also, this forbids creation of new channels in those wallets,
in case lightning was previously enabled.

Fixes #9440
2025-03-17 09:51:52 +01:00
ThomasV
f8714dd57a fix #9635 2025-03-16 17:01:07 +01:00
ThomasV
9d1ffe0c37 support for arguments to plugin commands:
- add a simple parser that only figures out where the config is,
   and does not complain if args are unknown
2025-03-16 15:01:22 +01:00
ThomasV
d2fa404e06 plugin commands: load the plugin in func_wrapper 2025-03-16 12:26:31 +01:00
ThomasV
51890fd0b5 Merge pull request #9629 from f321x/plugin-commands
Allow plugins to register CLI commands
2025-03-16 12:09:09 +01:00
ThomasV
a474b8674d plugin commands:
- make plugin commands start with plugin name + underscore
 - plugin_name must be passed to the plugin_command decorator
 - fixes:
    - remove plugin_commands (unneeded)
    - func_wrapper must await func()
    - setattr(Commands, name, func_wrapper)
 - add push/pull commands to labels plugin
2025-03-16 11:53:34 +01:00
ThomasV
cb39737a39 Plugins call with cmd_only:
- pass temporary config to Plugins
 - load only enabled plugins
 - parse the command line again after plugins are loaded
2025-03-15 13:31:00 +01:00
ThomasV
4f79e516e4 run_electrum: add parse_command_line method 2025-03-15 13:22:28 +01:00
f321x
ae64583ebc add handling of plugin commands 2025-03-15 13:22:28 +01:00
ThomasV
61c5df8407 Merge pull request #9638 from f321x/140325-force-close-exception
Fix anchor output sweeping bug creating invalid sweeping tx
2025-03-14 19:39:32 +01:00
ThomasV
81d4e90f66 Merge branch 'master' into 140325-force-close-exception 2025-03-14 19:38:13 +01:00