1
0
Commit Graph

16693 Commits

Author SHA1 Message Date
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
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
SomberNight
e23c6c7050 release notes: add pre-notification of security fixes for 4.4.6 2023-08-22 11:11:53 +00:00
ThomasV
fc183e5143 Fix regtests (follow-up 0ebb6469ff)
Note: We should probably require the password in load_wallet,
and store it in memory as long as the wallet is loaded. In that
case, commands that currently require a password would no longer
require it if the wallet is loaded.
2023-08-18 08:52:02 +02:00
ThomasV
b96cc82333 Make storage a field of db
This comes from the jsonpatch_new branch.
I rather have in master now, because it touches a lot of filese.
2023-08-18 08:08:31 +02:00
ThomasV
0ebb6469ff CLI: make sure we do not load WalletDB while another process is accessing it
- do not load WalletDB in order to check keystore password
- do not allow --offline commands while a daemon is running
2023-08-18 08:05:54 +02:00
SomberNight
a3997f8b58 lnworker: don't create invoice with dupl t-hints, & filter when sending
- when creating an invoice, if we had multiple chans with the same trampoline,
  were putting duplicate t-hints into the invoice
- when paying an invoice that had duplicate t-hints, we would sometimes
  construct invalid paths (SRC>T1->T1->DST)
2023-08-17 20:04:02 +00:00
SomberNight
d684cf2dc3 update release notes for version 4.4.6 2023-08-17 16:32:16 +00:00
SomberNight
2e4fbd9275 update block header checkpoints 2023-08-17 15:45:43 +00:00
SomberNight
cee22abcb5 wallet_db: upgrade to version 53, for imported chan backups
follow-up https://github.com/spesmilo/electrum/pull/8536

This replaces 69336befee, which was insufficient.
#8536 added a new field into the struct, which older versions do not ignore but raise:
opening a wallet file with new code updated the struct to include it,
after which old code could no longer open the wallet file.
i.e. #8536 was an invisible wallet upgrade, breaking compat.
This commit simply formalises the wallet upgrade: old code will now show
an understandable error when trying to open new files.
2023-08-17 14:08:27 +00:00
SomberNight
635880b3cb qt gui: input_qr_from_screenshot: better msg if screenshot is black
The input_qr_from_screenshot functionality is broken on some Linux machines:
on some machines, `screen.grabWindow(0)` returns an all-black image.

In such cases, instead of telling the user "No QR code was found on the screen",
we will tell them "Failed to take screenshot".

To test:
`QApplication.instance().primaryScreen().grabWindow(0).save("/home/user/wspace/tmp/pic2.png", "png")`

Tested on:
- machine 1:
    - ubuntu 22.04, gnome, wayland
    - pyqt.version: 5.15.9
    - qt.version: 5.15.2
    => gets all-black image for screenshot
- machine 2:
    - manjaro, kde, x11
    - pyqt.version: 5.15.9
    - qt.version: 5.15.8
    => screenshot works

I guess it might be due to x11 vs wayland.
2023-08-16 17:38:42 +00:00
SomberNight
2c2e3f8ca4 util.randrange: expand docstring 2023-08-16 16:32:42 +00:00
SomberNight
5e1e7dd9b3 util.CallbackManager: make sure exceptions in cbs are logged
this resolves the existing FIXME
2023-08-16 16:27:17 +00:00
SomberNight
7012d998f1 json_db: add back profiler to _write
follow-up 411098f293
2023-08-15 17:04:49 +00:00
SomberNight
98ccad68c1 channel_db: add TTLs to channel_updates_for_private_channels
eclair sends CHANNEL_DISABLED if its peer is offline. E.g. we might be
trying to pay a mobile phone with the app closed. In that case we
should not cache the CHANNEL_DISABLED for too long.
2023-08-15 16:34:51 +00:00
SomberNight
1dd0608718 lnrouter: rework blacklist a bit
separate from LiquidityHintMgr
2023-08-15 16:34:48 +00:00
ThomasV
68be768818 swapserver: use taskgroup (follow-up 0083560ee6) 2023-08-15 09:15:57 +02:00