1
0
Commit Graph

16708 Commits

Author SHA1 Message Date
SomberNight
5e8b14f742 logging: add config var "LOGS_NUM_FILES_KEEP" instead of hardcoded 10 2023-09-06 16:55:04 +00:00
SomberNight
43615487de follow-up prev 2023-09-06 16:24:11 +00:00
SomberNight
19718001e4 (trivial) CI: rename tasks 2023-09-06 16:21:18 +00:00
SomberNight
976f06f3c6 follow-up kivy removal: rm kivy/theming submodule
Looks like this was not fully removed.

$ git rm --force electrum/gui/kivy/theming/atlas

follow-up b45c84f24f
see https://github.com/spesmilo/electrum/pull/8591
2023-09-06 16:11:04 +00:00
SomberNight
c3562c00e6 tests: fix warnings in test_network.py
```
electrum/tests/test_network.py::TestNetwork::test_can_connect_during_backward
electrum/tests/test_network.py::TestNetwork::test_chain_false_during_binary
electrum/tests/test_network.py::TestNetwork::test_fork_conflict
electrum/tests/test_network.py::TestNetwork::test_fork_noconflict
  /tmp/cirrus-ci-build/electrum/interface.py:410: RuntimeWarning: coroutine 'Interface.run' was never awaited
    task = await self.network.taskgroup.spawn(self.run())
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
```

closes https://github.com/spesmilo/electrum/pull/7817
2023-09-06 15:53:40 +00:00
SomberNight
dd3966070d tests: rm some redundant "electrum_path" temp dirs 2023-09-06 14:12:30 +00:00
SomberNight
4f90632b1d tests: fix warnings in test_storage_upgrade.py
Manage global event loop so that it is accessible to threads
other than the asyncio thread. In particular, the Plugins
thread needs to reference it in its on_stop().
2023-09-06 14:12:26 +00:00
SomberNight
2529323ba3 (trivial) lnworker: fix type hint 2023-09-06 14:11:41 +00:00
SomberNight
1dd4acce9c Merge branch '202308_rm_kivy'
(PR https://github.com/spesmilo/electrum/pull/8591)
2023-09-06 13:35:57 +00:00
ThomasV
af27d5b95e Payment bundles: use lists of payment keys.
That way we don't need to special case trampoline outer onions
2023-09-06 10:44:55 +02:00
ThomasV
04c2129685 follow-up prev commit; do not return tw-info if forwarding is disabled 2023-09-06 10:35:31 +02:00
ThomasV
0e43ef2792 lnpeer: return fw_info for all parts of a MPP in a trampoline onion
Due to an indendation error, fw_info was returned only for one
HTLC of the MPP. Thus, maybe_fulfill_htlc was called again with
the remaining HTLCs, which could possibly be failed due to MPP
timeout, resulting in fund loss for the forwarder.
2023-09-06 09:51:07 +02:00
SomberNight
f28a2824d5 qt: do not show UntrustedServerReturnedError when sweeping
We should not show the untrusted text in the GUI...
With this change, we still log the text, but otherwise it should avoid
unintentionally showing it anywhere, as the original exception is
masked away.

related: https://github.com/spesmilo/electrum/issues/8599#issuecomment-1706775508

Example traceback (and the exc is then shown in main_window.on_error):
```
 10.77 | D | n/network | got error from server for Network.listunspent_for_scripthash: <UntrustedServerReturnedError [DO NOT TRUST THIS MESSAGE] original_exception: "RPCError(0, 'heyheyhey')">
 10.78 | E | gui.qt.main_window.[test_segwit_2] | on_error
Traceback (most recent call last):
  File "...\electrum\electrum\network.py", line 898, in wrapper
    return await func(self, *args, **kwargs)
  File "...\electrum\electrum\network.py", line 1149, in listunspent_for_scripthash
    return await self.interface.listunspent_for_scripthash(sh)
  File "...\electrum\electrum\interface.py", line 1027, in listunspent_for_scripthash
    raise aiorpcx.jsonrpc.RPCError(0, "heyheyhey")
aiorpcx.jsonrpc.RPCError: (0, 'heyheyhey')

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

Traceback (most recent call last):
  File "...\electrum\electrum\gui\qt\util.py", line 925, in run
    result = task.task()
  File "...\electrum\electrum\gui\qt\main_window.py", line 2505, in <lambda>
    task = lambda: self.network.run_from_another_thread(
  File "...\electrum\electrum\network.py", line 383, in run_from_another_thread
    return fut.result(timeout)
  File "...\Python310\lib\concurrent\futures\_base.py", line 458, in result
    return self.__get_result()
  File "...\Python310\lib\concurrent\futures\_base.py", line 403, in __get_result
    raise self._exception
  File "...\electrum\electrum\wallet.py", line 151, in sweep_preparations
    async with OldTaskGroup() as group:
  File "...\aiorpcX\aiorpcx\curio.py", line 304, in __aexit__
    await self.join()
  File "...\electrum\electrum\util.py", line 1316, in join
    task.result()
  File "...\electrum\electrum\wallet.py", line 142, in find_utxos_for_privkey
    await _append_utxos_to_inputs(
  File "...\electrum\electrum\wallet.py", line 129, in _append_utxos_to_inputs
    u = await network.listunspent_for_scripthash(scripthash)
  File "...\electrum\electrum\network.py", line 872, in make_reliable_wrapper
    async with OldTaskGroup(wait=any) as group:
  File "...\aiorpcX\aiorpcx\curio.py", line 304, in __aexit__
    await self.join()
  File "...\electrum\electrum\util.py", line 1327, in join
    self.completed.result()
  File "...\electrum\electrum\network.py", line 903, in wrapper
    raise wrapped_exc from e
electrum.network.UntrustedServerReturnedError: The server returned an error.
```
2023-09-05 15:47:33 +00:00
sorenstoutner
ddad5f1320 Fix Revealer Qt layout (#8587)
* Fix Revealer Qt layout

* Add license information
2023-09-05 12:32:38 +00:00
Sander van Grieken
307cf25fd4 register distinction between address and script for SPK type payment identifiers and allow zero amount for
script destinations.

This is mainly to support OP_RETURN outputs, which typically have a zero amount output value,
but as we don't special case OP_RETURN, this is currently done for all non-address scripts

Also, it's probably good to add a warning popup for OP_RETURN outputs with a non-zero output value, but this
would also need special casing for OP_RETURN.

Saving of script output payment identifiers is disabled for now, as reading the script from the stored invoice
back into human-readable form is currently not implemented, and currently only lightning invoices or address output
is supported.
2023-09-04 20:00:40 +02:00
Sander van Grieken
0d96bc1dbd qt/send_tab: fix regressions paymentidentifier
Fix '!' amount expand while PaymentIdentifier not set due to editor pushback timer.
Fix '!' amount expand for BIP21 without a specified payment amount.
2023-09-04 15:55:23 +02:00
Sander van Grieken
a52c715304 qml: show experimental warning before opening first lightning channel. closes #8564 2023-09-04 15:02:40 +02:00
Sander van Grieken
a740a20fc2 qml: pass the invoice/invoiceparser to payOnchain 2023-09-01 15:44:24 +02:00
Sander van Grieken
c348d4d7ce follow-up 0a804607a4, don't ask confirmation for regular onchain invoices 2023-09-01 15:08:01 +02:00
Sander van Grieken
0a804607a4 qml: properly suggest paying bolt11 invoice onchain if insufficient LN balance.
Also, if fallback address is present, don't warn on bolt11 and no ln channels.
2023-09-01 15:03:44 +02:00
ThomasV
a5da379d13 swap dialog: show on_result popup for both directions 2023-09-01 08:47:55 +02:00
ThomasV
b5654b640a Merge pull request #8590 from SomberNight/202308_debug_threading_issues
add stacktracer.py: helper util to debug threading issues
2023-08-31 14:46:08 +02:00
ThomasV
e80310eb32 lnpeer: trampoline forwarding failures may be indexed by outer or inner onion payment secret 2023-08-31 05:55:28 +02:00
SomberNight
00ae370a45 tests: split out wallets from test_storage_upgrade.py
so that Thomas' emacs does not crash when editing the file :D
2023-08-30 18:40:41 +00:00
SomberNight
59a6690986 stacktracer.py: small fixes and clean-up 2023-08-30 16:57:37 +00:00
SomberNight
b45c84f24f remove the kivy gui
We now use the qml gui on Android, and haven't been maintaining
the kivy GUI for a while.
2023-08-30 16:47:37 +00:00
ghost43
e8c0767ca7 Merge pull request #8584 from SomberNight/202308_fix8582
invoices: also run amount-validator on setter
2023-08-30 16:27:00 +00:00
SomberNight
b284b88746 add stacktracer.py: helper util to debug threading issues
taken from https://code.activestate.com/recipes/577334-how-to-debug-deadlocked-multi-threaded-programs/
2023-08-30 16:03:00 +00:00
SomberNight
c3f16615ca android build: exclude kivy classes from qml apk
taken from https://github.com/spesmilo/electrum/pull/8545
22bfd4eca6

note: com.android.support is used in our p4a fork's PythonActivity.java
(com.android.support was previously pulled in by me.dm7.barcodescanner)
052b9f7945/pythonforandroid/bootstraps/qt5/build/src/main/java/org/kivy/android/PythonActivity.java (L43)
2023-08-30 14:10:56 +00:00
SomberNight
111a753dc2 ci: don't run unit tests on pypy
We never really supported pypy - the CI was running the tests there
just to see compatibility.
A few of the unit tests consistently hang, resulting in the whole
test runner timing out and wasting compute resources. Someone could
debug the hangs and try to fix them, but I don't have the time.
2023-08-30 12:46:12 +00:00
SomberNight
6557a21c45 channel_db: don't wait for load_data to finish if stopping
ChannelDB.load_data() takes ~15 seconds. Previously if the user tried
to close the program while load_data is running, we would block until
load_data() finished. (e.g. consider starting and immediately stopping
Electrum)
Now instead we can abort load_data early.
2023-08-30 11:49:42 +00:00
ThomasV
78f0f788d6 submarine swaps: use a short expiry with hold invoices, and display result to the user 2023-08-30 11:07:16 +02:00
ThomasV
4d0ec8d177 lnworker: choose IP address with recent timestamp (Rogach) 2023-08-30 09:32:34 +02:00
ThomasV
f5ab4b0f18 swapserver: sanity check amount in new flow 2023-08-27 20:56:49 +02:00
ThomasV
e06df2cb69 swapserver: reduce refund delay to 70 blocks
if a refund occurs, it needs to be done before the cltv expiration
of the htlc, or the channel might be force closed.
2023-08-27 14:06:56 +02:00
ThomasV
5e09a416a7 address_synchronizer: save stored_height on each block 2023-08-27 11:57:50 +02:00
ThomasV
40c08d350f trampoline: fix two bugs preventing legacy payments to
Electrum clients that have non-trampoline channels.

 - if an invoice supports trampoline, but provides only
non-trampoline nodes in its routing hints, we must use
a legacy trampoline payment

 - when we create a trampoline onion for a legacy payment,
the invoice_features field is a u64, so we need to remove
high feature bits.
2023-08-27 11:48:29 +02:00
ThomasV
b2053c68f1 make use_to_trampolines a user visible option, disable it by default 2023-08-27 11:43:17 +02:00
ThomasV
a300b8968a swapserver: do not expose the swapserver plugin in qt 2023-08-27 11:10:09 +02:00
ThomasV
341227c3cd qt: show routing hints in ln invoice window 2023-08-27 11:08:54 +02:00
SomberNight
b8d410849c fix revealer plugin for python 3.10+
fixes https://github.com/spesmilo/electrum/issues/7719
2023-08-25 23:35:07 +00:00
SomberNight
6a9e532ff1 Plugins: make Plugins.stop() faster
Plugins.stop() is now part of the normal shutdown flow (since 90f39bce88),
so this shaves up to 100 ms off that (avg: 50 ms).
It is also waited on in around ~60 unit tests: this saves 3 sec.
2023-08-24 18:27:34 +00:00
SomberNight
392f6d8e30 fix tests: another follow-up to daemon managing Plugins object
In python 3.8 and 3.9, asyncio.Event/Lock/etc cannot be created before the
event loop itself is created. Hence, to have Plugins.__init__ create an
Event, we need to postpone creating Plugins() from setUpClass to setUp.

follow-up 90f39bce88
2023-08-24 18:21:23 +00:00
SomberNight
1dfc1d567b follow-up prev 2023-08-24 17:30:06 +00:00
SomberNight
90f39bce88 run_electrum: have daemon manage Plugins object, and call Plugins.stop
Plugins.stop was never called, so the Plugins thread only stopped
because of the is_running() check in run(), which triggers too late:
the Plugins thread was stopping after the main thread stopped.

E.g. playing around in the qt wizard with wallet creation for a Trezor,
and closing the wizard (only window):
``` 24.85 | E | p/plugin.Plugins |
Traceback (most recent call last):
  File "/home/user/wspace/electrum/electrum/util.py", line 386, in run_jobs
    job.run()
  File "/home/user/wspace/electrum/electrum/plugin.py", line 430, in run
    client.timeout(cutoff)
  File "/home/user/wspace/electrum/electrum/plugin.py", line 363, in wrapper
    return run_in_hwd_thread(partial(func, *args, **kwargs))
  File "/home/user/wspace/electrum/electrum/plugin.py", line 355, in run_in_hwd_thread
    fut = _hwd_comms_executor.submit(func)
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 167, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
```
2023-08-24 17:15:14 +00:00
ThomasV
c12d9b14da qt console: add 'channels' shortcut 2023-08-24 12:09:59 +02:00
SomberNight
ffa3acc013 invoices: don't modify .amount_msat directly 2023-08-22 18:12:15 +00:00
SomberNight
4e6e6f76ca invoices: also run amount-validator on setter
- @amount_msat.validator prevents the creation of invoices with e.g. too large amounts
- however the qml gui is mutating invoices by directly setting the `amount_msat` field,
  and it looks like attrs validators only run during init.
  We can use `on_setattr` (introduced in attrs==20.1.0).
- a wallet db upgrade is added to rm existing insane invoices
- btw the qml gui was already doing its own input validation on the textedit
  (see qeconfig.btcAmountRegex). however that only limits the input to not have more
  chars than what is needed to represent 21M BTC (e.g. you can still enter 99M BTC,
  which the invoice logic does not tolerate later on - but is normally caught).

fixes https://github.com/spesmilo/electrum/issues/8582
2023-08-22 18:10:21 +00:00
SomberNight
7245762922 qt: fix lnurl-pay
regression from https://github.com/spesmilo/electrum/pull/8462
2023-08-22 17:00:17 +00:00
SomberNight
7482e275b9 follow-up storage/db changes
follow-up b96cc82333
2023-08-22 14:50:30 +00:00