Commit Graph

8911 Commits

Author SHA1 Message Date
f321x
c816987164 android: qr scanner: add emoji to clipboard string
The string is not translated and might not be accessible for non-english
speakers, even though its relatively self-explanatory i think adding
this emoji makes it more accessible.
2025-10-28 14:32:04 +01:00
SomberNight
6423323037 interface: PaddedRSTransport: keep in sync with e-x: flush on close
ref f62f986b33

note: ReplyAndDisconnect is specific to electrumx, however I think the name is descriptive enough to keep it here.
2025-10-27 18:09:33 +00:00
ghost43
356f50beae Merge pull request #10280 from f321x/fix_network_tab_selection
qt: fix ServerWidget (Network Tab)
2025-10-27 17:58:33 +00:00
f321x
f2aa4404ad qt: fix ServerWidget
The ServerWidget was not working properly, when switching from "Manual
Mode" to "Auto Connect" the change wouldn't get saved as it depended on
having a correct server string entered (which isn't neccessary for Auto
Connect).
Also makes the widget behave more sane by cleaning the server input if
Auto Connect is enabled and switching to Manual Mode if the user
manually selects a server.

Update the ServerWidget every time it is shown (on initialization and
also when the user opens it again or switches between network dialog
tabs).
This will clean it up if the user has entered some invalid server and
closes it, otherwise this server would stay in the input field until the
application is restarted.

The list of servers in the ServerWidget allows the user to right click
and 'Use as server' on the servers in the list, however internally it
was handled differently than what the user would expect when clicking on
'Use as server'. E.g. if the user selects a server in autoconnect mode
it would still stay in autoconnect mode so the server could switch again
to another server any time? Now it will also change the mode to manual
(or stay in single server mode if that was selected before), making it
clear that this server will stay selected.

If the user clicks on "Follow this branch" the connect mode will get changed to
autoconnect as internally we connect to a random interface on this
branch.
2025-10-27 18:46:36 +01:00
f321x
679b7fe122 interface: add warmup budget to PaddedRSTransport
Adds a 1024 (unpadded) byte budget to the PaddedRSTransport below which
messages are instantly flushed down the socket before the transport will
beginn waiting for the buffer to reach MIN_PACKET_SIZE (1024).
This allows to get the first couple of messages sent quickly when
starting the wallet to improve UX.
2025-10-27 18:31:37 +01:00
f321x
ff2bbf159e interface: check genesis hash on connection
Prevents the client from accidentally connecting to a server on a
different network.
I noticed its possible to connect to mainnet servers on a signet
instance causing the recent peers to get populated with mainnet peers
rendering the wallet instance barely usable. Doing this check should
prevent this and similar issues.
2025-10-27 16:57:28 +01:00
dulanting
08fd2de003 chore: fix comment for electrum/gui/qt/main_window.py
Signed-off-by: dulanting <dulanting@outlook.jp>
2025-10-13 16:26:50 +08:00
ghost43
611f9b4485 Merge pull request #10264 from SomberNight/202510_tx_cleanup
transaction: (trivial) add some missing type hints, minimal clean-up
2025-10-09 15:34:58 +00:00
ghost43
89734b3bd4 Merge pull request #10242 from f321x/return_preimage_cli
cli: add command to export preimage, return preimage from check_hold_invoice
2025-10-09 15:31:04 +00:00
SomberNight
6e45d6e690 lnworker: (trivial) add a few missing type-hints 2025-10-09 15:06:23 +00:00
SomberNight
3379e46249 follow-up prev: add type-hints, etc 2025-10-09 14:57:41 +00:00
SomberNight
f1ad5bc23d transaction: (move-only) move some methods from Tx to PartialTx cls
these were already assuming `isinstance(self, PartialTransaction)`
2025-10-09 14:46:42 +00:00
SomberNight
f832c33d76 qt: main_window.confirm_tx_dialog: rm dead code 2025-10-09 14:36:15 +00:00
SomberNight
58676219f4 wallet: (trivial) mark calc_unused_change_addresses as private 2025-10-07 17:45:38 +00:00
ThomasV
f4e7ffd5f3 lnworker: set OPTION_ONION_MESSAGE_OPT feature if we are forwarding. 2025-10-07 11:19:37 +02:00
SomberNight
af6715040c lnurlw: follow-up: adapt to recent lnworker.get_bolt11_invoice refactor 2025-10-03 02:12:04 +00:00
SomberNight
ef8d53c46a lnurlw: follow-up: fix android edge-to-edge layout padding
as per https://github.com/spesmilo/electrum/pull/9993#issuecomment-3228252596
2025-10-03 02:11:43 +00:00
SomberNight
7d0ac64d06 Merge remote-tracking branch 'spesmilo/pr/9993': lnurl-withdraw
ref https://github.com/spesmilo/electrum/pull/9993
2025-10-02 23:34:40 +00:00
f321x
b57f867c2f cli: add command to export preimage
..also export preimage in check_hold_invoice return value if available.

I intentionally did not return the preimage in the returned dict of
wallet.export_requests as this seems risky to do considering some users
of the cli might forward the response to a payer and the payserver
exposes it too.

Closes https://github.com/spesmilo/electrum/issues/10176
2025-09-30 10:37:20 +02:00
f321x
286fc4b86e lnworker: enforce creation of PaymentInfo for b11
Enforce that the information used to create a bolt11 invoice using
`get_bolt11_invoice()` is similar to the related instance of PaymentInfo
by requiring a PaymentInfo as argument for `get_bolt11_invoice()`.
This way the invoice cannot differ from the created PaymentInfo.
This allows to use the information in PaymentInfo for validation of
incoming htlcs more reliably.

To cover all required information for the creation of a b11 invoice the
PaymentInfo class has to be extended with a expiry and
min_final_cltv_expiry. This requires a db upgrade.
2025-09-30 09:54:35 +02:00
f321x
d62b627a0b lnpeer: move htlc forwarding funcs to lnworker
forwarding happens independent of the peer that received the htlc to
forward and fits better in lnworker.
2025-09-30 09:54:24 +02:00
SomberNight
3d27992fb7 lnonion: (trivial) make OnionPacket.__init__ kw-only 2025-09-29 17:13:27 +00:00
f321x
32aa6ab20c lnutil: rename RecvMPPResolution.ACCEPTED
Renames RecvMPPResolution.ACCEPTED to .COMPLETE as .ACCEPTED is somewhat
misleading. Accepted could imply that the preimage for this set has been
revealed or that the set has been settled, however it only means that we
have received the full set (it is complete), but the set still can be
failed (e.g. through cltv timeout) and has not been claimed yet.
2025-09-29 16:11:26 +00:00
f321x
6a4ad9e67c lnonion: check onion version in process_onion_packet
Adds checks for the onion version in process_onion_packet and fails it
back with the correct error instead of raising in the OnionPacket
constructor.
2025-09-29 16:11:23 +00:00
f321x
7d0a69a9ce lnpeer: only spawn htlc_switch for peers with LNWallet
stop spawning htlc_switch for LNGossip peers, they don't handle any
htlcs
2025-09-29 16:11:20 +00:00
f321x
fcc3796079 lnworker: move RecvMPPResolution and status to lnutil
it is required both in lnpeer and lnworker, moving it to lnutil seems to
make more sense.

# Conflicts:
#	electrum/lnworker.py
2025-09-29 16:11:17 +00:00
f321x
9db975f9d7 lightning: remove legacy payment secret derivation
This seems old and not very useful anymore.
2025-09-29 16:11:13 +00:00
f321x
0ae60d8b45 lnonion: make comparisons more constant time
makes hmac comparisons and onion error decoding more constant time
according to bolt 4. However things might still not be perfectly
constant time, however this seems out of scope for timing over network.
2025-09-29 16:11:10 +00:00
f321x
e6ea6dbf0a lnutil: make UpdateAddHtlc dataclass
it is straightforward to move UpdateAddHtlc away from attr
to a dataclass without requiring any db update.
2025-09-29 16:11:07 +00:00
f321x
4c0155c072 lnworker: make PaymentInfo dataclass
Move PaymentInfo from NamedTuple to dataclass to allow for easier
handling e.g. using dataclasses.astuple etc.
2025-09-29 16:11:03 +00:00
f321x
acd52da764 lnpeer: cleanup imports 2025-09-29 16:10:59 +00:00
SomberNight
5d1df96020 tests: clear util.callback_mgr between test cases
util.callback_mgr.callbacks was not getting properly cleared between tests.
Every time an Abstract_Wallet or an LNWorker (or many other subclasses of EventListener) is instantiated,
self.register_callbacks() is called in __init__, which puts callbacks into util.callback_mgr.callbacks.
These are only cleaned up if we explicitly call Abstract_Wallet.stop() or LNWorker.stop() later, which we usually do not do in the tests.

As a result, when running multiple unit tests in a row, lots of objects created in a given testcase are never GC-ed and leak into subsequent tests. This is not only a memory leak, but wastes compute too: when events are triggered and cbs get called, these old objects also have their cbs called.

After running all (~1061) unit tests, I observe util.callback_mgr.callbacks had 30 events with a total of 3156 callbacks stored.

On my laptop, running all unit tests previously took ~115 sec, and now it takes ~73 sec.
2025-09-26 15:53:41 +00:00
ghost43
de7612b3b1 Merge pull request #10216 from SomberNight/202509_adb_spv
adb: change API of util.TxMinedInfo: height() is now always SPV-ed
2025-09-24 13:50:14 +00:00
SomberNight
a4293c483e transaction: SPV-verify TxInput.block_height and .spent_height 2025-09-24 13:46:35 +00:00
SomberNight
b944371ffd adb: change API of util.TxMinedInfo: height() is now always SPV-ed 2025-09-24 13:46:24 +00:00
SomberNight
6a9c94ff0b wallet: anchor reserve: handle wallet.use_change being off
fixes https://github.com/spesmilo/electrum/issues/10231
2025-09-24 13:38:08 +00:00
Sander van Grieken
0fcd8f76fc qml: small gridlayout fix in BalanceDetails 2025-09-19 15:36:07 +02:00
ThomasV
5c2c9ac941 network.py: do not require MyEncoder for serializing recent servers
This class is overkill. I am trying to restrict its usage to wallet_db
2025-09-18 12:04:17 +02:00
ThomasV
ff593ea118 Merge pull request #10226 from f321x/fix_8100
wallet: fix AttributeError when getting help text
2025-09-16 12:06:06 +02:00
f321x
b6a4ebecda wallet: fix AttributeError when getting help text
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'
```
2025-09-16 09:38:01 +02:00
ThomasV
12a8cdc842 Merge pull request #10223 from PeytonAllworth/refactor/fstring-upstream
refactor(paymentrequest): use f-string in error message
2025-09-14 11:28:51 +02:00
copronista
6be8e3ec88 Update plugin.py
https://github.com/spesmilo/electrum/issues/10220
2025-09-13 23:12:44 -04:00
Peyton Allworth
67f09bf528 refactor(paymentrequest): use f-string in error message 2025-09-12 22:49:02 -07:00
SomberNight
e10cf30627 crash_reporter: flag reports where console was used in app_version
so we don't waste time on weird reports where the user modified
internals at runtime

ref
https://github.com/spesmilo/electrum/issues/10217
https://github.com/spesmilo/electrum/issues/10218
2025-09-11 17:01:52 +00:00
SomberNight
47f1a2d7a2 wallet.get_full_history: rm "include_fiat" arg, infer it from fx
ref https://github.com/spesmilo/electrum/pull/10209#discussion_r2334228490
2025-09-09 17:24:59 +00:00
ghost43
df45233c2f Merge pull request #10209 from f321x/fix_fiat_history_export
qt: add missing fiat values in csv/json history export
2025-09-09 16:56:21 +00:00
ghost43
b4a6de46f4 Merge pull request #10188 from f321x/capacity_warning_zero_amount
qt: receive dialog: also propose swaps for 0 amount invoices
2025-09-09 16:16:23 +00:00
ghost43
4389618f72 Merge pull request #10212 from SomberNight/202509_tests_for_old_hex_seed
tests: restore from old "hex" seed
2025-09-09 15:42:05 +00:00
ghost43
874d89b259 Merge pull request #10211 from f321x/swap_cleanup_check
swaps: only set swap redeemed if preimage is available
2025-09-09 15:40:29 +00:00
ThomasV
61aeffd26f qt: add_to_coincontrol: assert that coins are in self._utxo_dict 2025-09-09 15:55:54 +02:00