Fixes AttributeError when trying to get `num_sats_can_receive()` in
wallets without lnworker. Fixes https://github.com/spesmilo/electrum/issues/8100#issuecomment-3294556043.
```
Traceback (most recent call last):
File "/usr/lib/python3.13/site-packages/electrum/gui/qt/request_list.py", line 103, in selection_changed
self.receive_tab.update_current_request()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.13/site-packages/electrum/gui/qt/receive_tab.py", line 237, in update_current_request
help_texts = self.wallet.get_help_texts_for_receive_request(req)
File "/usr/lib/python3.13/site-packages/electrum/wallet.py", line 3446, in get_help_texts_for_receive_request
can_receive = self.lnworker.num_sats_can_receive()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'num_sats_can_receive'
```
For forward swaps this will ensure that the swap only gets set redeemed
and cleaned up after the preimage has been extracted, as it could happen
that `current_height - spent_height > REDEEM_AFTER_DOUBLE_SPENT_DELAY`
is true even if the preimage has not been extracted yet.
For reverse swaps this changes nothing as they always have the preimage.
Catch exceptions happening to callbacks to continue calling the
remaining callbacks. Otherwise if the first callback throws an exception
the remaining callbacks aren't going to be called.
I don't understand what the "coins not used" comment meant here.
It was added in the change away from the old config.WALLET_BATCH_RBF option
(ab14c3e138).
The `coins` param *is used* in wallet.get_candidates_for_batching.
Without setting that, the returned set of candidates was restricted to
only base txs that had a large enough change output to cover *all* the newly added outputs.
Instead, it is desirable to allow adding new inputs.
note that atm none of the plugin commands are explicitly marked with 'n' but all require it.
Also note that 'w' for plugin commands kind of implies 'n' anyway, as the 'load_wallet' hook relies on having a daemon.
```
$ ./run_electrum -o --testnet labels_pull
Password:
1.96 | E | __main__ | error running command (without daemon)
Traceback (most recent call last):
File "/home/user/wspace/electrum/./run_electrum", line 587, in handle_cmd
result = fut.result()
File "/usr/lib/python3.13/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.13/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/home/user/wspace/electrum/./run_electrum", line 267, in run_offline_command
result = await func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/wspace/electrum/electrum/commands.py", line 202, in func_wrapper
return await func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/wspace/electrum/electrum/commands.py", line 2214, in func_wrapper
kwargs['plugin'] = daemon._plugins.get_plugin(plugin_name)
^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute '_plugins'
```
Replace calls to deprecated asyncio.iscoroutinefunction with calls to
inspect.iscoroutinefunction to prevent the following deprecation
warnings from showing up if running with Python 3.14:
```
/home/user/code/electrum-fork/electrum/util.py:1225: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
assert asyncio.iscoroutinefunction(func), 'func needs to be a coroutine'
/home/user/code/electrum-fork/electrum/util.py:507: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
if asyncio.iscoroutinefunction(func):
/home/user/code/electrum-fork/electrum/util.py:1246: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
assert asyncio.iscoroutinefunction(func), 'func needs to be a coroutine'
/home/user/code/electrum-fork/electrum/lnpeer.py:272: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
assert asyncio.iscoroutinefunction(func), 'func needs to be a coroutine'
/home/user/code/electrum-fork/electrum/util.py:1225: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
assert asyncio.iscoroutinefunction(func), 'func needs to be a coroutine'
/home/user/code/electrum-fork/electrum/util.py:507: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
if asyncio.iscoroutinefunction(func):
```
When a SwapDialog gets initiated with a recv_amount_sat through the
receive tab the Max Button and edits are disabled and the user is forced
to do a swap with the preset amount. Maybe the user wants to do a larger
swap?
I think it makes sense to run the tests with both the "latest" dependencies,
and with the pinned dependencies that we package for releases.
Testing with latest can reveal changes/issues with new dep versions,
while testing with pinned is testing what users will actually run.
Previously we were only testing with "latest".
- it was originally added in https://github.com/spesmilo/electrum/pull/1334,
with the goal of simplifying running the tests on local dev machines.
However this usage is not documented anywhere, and AFAIK regular contributors
don't use it either.
- tox just adds another layer of abstraction that is not that useful IMO
- I want more control over which electrum-deps are installed, which tox is
(in this case) unhelpfully abstracting away
I think _wallet_key_from_path should not raise.
This is probably the sane way to deal with this.
Though all this is assuming that os.path.realpath can be treated as consistent/stateless.
closes https://github.com/spesmilo/electrum/issues/10182