1
0
Commit Graph

18299 Commits

Author SHA1 Message Date
SomberNight
70d1e1170e asyncio: clarify strong refs for run_coroutine_threadsafe
We added some code in 0b3a283586
to explicitly hold strong refs for all tasks/futures. At the time I was uncertain if that also solves
GC issues with asyncio.run_coroutine_threadsafe.
ref https://github.com/spesmilo/electrum/pull/9608#issuecomment-2703681663

Looks like it does. run_coroutine_threadsafe *is* going through the custom task factory.
See the unit test.
The somewhat confusing thing is that we need a few event loop iterations for the task factory to run,
due to how run_coroutine_threadsafe is implemented. And also, the task that we will hold as strong ref
in the global set is not the concurrent.futures.Future that run_coroutine_threadsafe returns.

So this commit simply "fixes" the unit test so that it showcases this, and removes related, older, plumbing
from util.py that we now know is no longer needed because of this.
2025-04-08 18:54:58 +00:00
ghost43
aef2a7a8a9 Merge pull request #9705 from accumulator/qml_freeze_reused_address_utxos
qml: add config option WALLET_FREEZE_REUSED_ADDRESS_UTXOS
2025-04-08 14:07:57 +00:00
Sander van Grieken
6e8f97d36a qml: add config option WALLET_FREEZE_REUSED_ADDRESS_UTXOS 2025-04-07 19:48:20 +02:00
SomberNight
cca29eff72 contrib/push_locale: minor clean-up 2025-04-07 17:17:39 +00:00
SomberNight
ef452b1f49 contrib/push_locale: update qt5->qt6 2025-04-07 17:16:02 +00:00
ghost43
5dad7c55fd Merge pull request #9704 from f321x/future_tx_fee
tx / gui: Disable output value rounding for 0 fee tx and don't show relay fee warning in gui
2025-04-07 15:40:11 +00:00
f321x
42bd334f5b add coinchooser test with zero fee estimation 2025-04-07 17:14:25 +02:00
ghost43
d86276042a Merge pull request #9706 from accumulator/lnworker_channelopen_min_amount
lnworker: use MIN_FUNDING_SAT as lower bound for channel open
2025-04-07 14:42:14 +00:00
ThomasV
ddf836935e Merge pull request #9709 from f321x/fix_fee_slider_qml_channel_open
qml: pass updated fee policy to make_tx function when opening channel
2025-04-07 15:05:53 +02:00
f321x
23c0887a5c qml: pass updated fee policy to make_tx function when opening channel 2025-04-07 14:08:15 +02:00
Sander van Grieken
f751a77a65 lnworker: use MIN_FUNDING_SAT as lower bound for channel open 2025-04-07 13:09:09 +02:00
accumulator
746c13b32d Merge pull request #9674 from accumulator/qml_lightning_invoice_insufficient_balance
qml: show insufficient balance text for lightning invoice without fal…
2025-04-07 12:09:17 +02:00
accumulator
dc3c7956c0 Merge pull request #9703 from f321x/open_channel_dialog_fix
qml: call QEChannelOpener.validate() on updateMaxAmount
2025-04-07 11:58:13 +02:00
f321x
8d84008f5b disable output value rounding for 0 fee tx and remove relay fee warning from gui 2025-04-07 11:52:43 +02:00
f321x
8b7e967555 call QEChannelOpener.validate() on updateMaxAmount 2025-04-07 10:16:48 +02:00
Sander van Grieken
71801de7ea qml: show insufficient balance text for lightning invoice without fallback and insufficient ln send capacity 2025-04-07 10:02:25 +02:00
ThomasV
282c4561ff swapsserver fix for legacy clients. (follow-up 6e92a00) 2025-04-05 18:17:06 +02:00
accumulator
bc4fcd8b83 Merge pull request #9682 from accumulator/android_permissions_support
Android >=13 permissions support
2025-04-05 11:47:27 +02:00
SomberNight
f429af7d01 lnutil: cache validate_features() results
channel_db.load_data() is slow, slowing down startup time (when trampoline is disabled).
util.list_enabled_bits() is one of the main contributors to the slowness, called by validate_features().

One could argue that we could even simply *not* call validate_features for gossip messages as part of load_data,
as they have already been validated before storing them in the db. However re-validating them there is a good
clean-up/sanity check IMO. Note that what is considered "valid" can change over time, so just because validate_features
passed when we originally received and stored a gossip message, it might no longer be valid a year later if the bolts change.

This caching decreases the time needed for load_data on two different machines / gossip dbs as below:
47 sec -> 10 sec
18 sec -> 6 sec

If instead of caching, I just rm the validate_features() calls, the benchmarks are almost identical, within noise.
That is, the cache looks really effective.
(the rest of the slowness is mostly due to lnmsg.decode_msg)

```
>>> lnutil.validate_features.cache_info()
CacheInfo(hits=172674, misses=287, maxsize=1000, currsize=277)
```

-----

We could alternatively directly cache util.list_enabled_bits (instead of validate_features).
That would be a bit slower and might end up using a lot more memory in some cases I think, but maybe conceptually would be cleaner.
Also note that if validate_features() raises an exception, that is not cached.
2025-04-04 18:24:50 +00:00
SomberNight
b13de0afb5 lnpeer: request_gossip: change log line format
before/after:
`requesting channel graph since Fri Apr  4 17:19:05 2025`
`requesting channel graph since 2025-04-04T17:20:04`
2025-04-04 17:23:26 +00:00
ThomasV
dee76b2137 Merge pull request #9660 from f321x/swap_announce_liquidity
swaps: Announce available liquidity instead of static maximum value
2025-04-04 18:04:34 +02:00
f321x
6e8bdb346a move onchain balance calculation to wallet.py 2025-04-04 15:08:51 +02:00
f321x
17a9a91e1f announce actual available liquidity as swap provider 2025-04-04 15:06:50 +02:00
ThomasV
1405f02c0a Merge pull request #9696 from f321x/fix_node_ann_exception
lightning: fix exception if LIGHTNING_LISTEN is not set on public node
2025-04-04 14:22:58 +02:00
f321x
db55e37277 fix exception if LIGHTNING_LISTEN is not set on public node 2025-04-04 12:20:48 +02:00
ThomasV
181c132fee Merge pull request #9666 from accumulator/qml_close_invoicedialog_after_onchain_broadcast_success
qml: auto close invoicedialog after successful onchain tx broadcast
2025-04-03 17:18:31 +02:00
Sander van Grieken
f76218ea83 qml: introduce InfoBanner allowing a clickable sticky message to stay below header and
implement ln utxo reserve check with warning. Clicking shows a suggestion to swap.
2025-04-03 14:39:05 +02:00
Sander van Grieken
3fd64b60ab qml: show warning in ConfirmTxDialog if max amount cannot be fully sent due to channel reserve requirements. 2025-04-03 14:39:05 +02:00
ThomasV
001a1152fd add unit tests for ln_utxo_reserve 2025-04-03 14:39:05 +02:00
ThomasV
32807462b0 qt: add warning about low utxo reserve 2025-04-03 14:39:05 +02:00
ThomasV
b339b1e7e3 ln_utxo_reserve
When we send max, decrease sent amount in order to keep some
reserve utxo, in order to be able to sweep lightning channels.
2025-04-03 14:39:05 +02:00
ThomasV
307f5d301e Merge pull request #9693 from f321x/psbt_nostr_ephemeral_event
psbt plugin: add expiration tag to psbt nostr event and use ssl context
2025-04-03 14:28:22 +02:00
f321x
b8d10df2dc add expiration tag to psbt nostr event and pass ssl context to relay manager 2025-04-03 13:56:29 +02:00
ThomasV
cb75f21f3b Merge pull request #9640 from f321x/swap_dm_relays
swaps: Update submarine swap nostr relays dynamically and remove redundant query
2025-04-03 13:34:54 +02:00
Sander van Grieken
1ac885ea40 qml: add android permission methods in AppController 2025-04-03 12:37:17 +02:00
SomberNight
5c233ac325 ci: enable more flake8 stuff
```
$ export ELECTRUM_LINTERS=E9,E101,E129,E273,E274,E703,E71,E722,F5,F6,F7,F8,W191,W29,B
$ export ELECTRUM_LINTERS_IGNORE=B007,B009,B010,B019,B036,F541,F841
$ flake8 . --count --select="$ELECTRUM_LINTERS" --ignore="$ELECTRUM_LINTERS_IGNORE" --show-source --statistics --exclude "*_pb2.py,electrum/_vendor/"
./electrum/commands.py:98:1: F811 redefinition of unused 'format_satoshis' from line 48
def format_satoshis(x):
^
./electrum/commands.py:437:9: F811 redefinition of unused 'Mnemonic' from line 62
        from .mnemonic import Mnemonic
        ^
./electrum/gui/qt/wizard/wallet.py:37:5: F811 redefinition of unused 'Daemon' from line 14
    from electrum.daemon import Daemon
    ^
./electrum/lntransport.py:14:1: F811 redefinition of unused 'Optional' from line 12
from typing import NamedTuple, List, Tuple, Mapping, Optional, TYPE_CHECKING, Union, Dict, Set, Sequence
^
./electrum/lntransport.py:14:1: F811 redefinition of unused 'TYPE_CHECKING' from line 12
from typing import NamedTuple, List, Tuple, Mapping, Optional, TYPE_CHECKING, Union, Dict, Set, Sequence
^
./electrum/plugin.py:966:13: F811 redefinition of unused 'hid' from line 593
            import hid
            ^
./electrum/plugin.py:1040:13: F811 redefinition of unused 'hid' from line 593
            import hid
            ^
./electrum/util.py:44:1: F811 redefinition of unused 'json' from line 26
import json
^
./electrum/util.py:46:1: F811 redefinition of unused 'NamedTuple' from line 29
from typing import NamedTuple, Optional
^
./electrum/util.py:46:1: F811 redefinition of unused 'Optional' from line 29
from typing import NamedTuple, Optional
^
./electrum/util.py:1456:56: F811 redefinition of unused 'traceback' from line 34
        async def __aexit__(self, exc_type, exc_value, traceback):
                                                       ^
./electrum/wallet_db.py:536:9: F811 redefinition of unused 'LOCAL' from line 46
        LOCAL = 1
        ^
./electrum/wallet_db.py:537:9: F811 redefinition of unused 'REMOTE' from line 46
        REMOTE = -1
        ^
./tests/test_bitcoin.py:28:1: F811 redefinition of unused 'bitcoin' from line 9
from electrum import crypto, constants, bitcoin
^
./tests/test_txbatcher.py:11:1: F811 redefinition of unused 'Transaction' from line 7
from electrum.transaction import Transaction, PartialTxInput, PartialTxOutput, TxOutpoint
^
./tests/test_wallet_vertical.py:20:1: F811 redefinition of unused 'Transaction' from line 10
from electrum.transaction import Transaction, PartialTxOutput, tx_from_any, Sighash
^
16    F811 redefinition of unused 'format_satoshis' from line 48
16

```
2025-04-02 16:21:59 +00:00
SomberNight
55281295b7 ci: bump flake8 to new version
```
./electrum/commands.py:144:9: F824 `global known_commands` is unused: name is never assigned in scope
        global known_commands
        ^
./electrum/commands.py:1916:9: F824 `global known_commands` is unused: name is never assigned in scope
        global known_commands
        ^
./electrum/gui/qt/main_window.py:2405:13: F824 `nonlocal done` is unused: name is never assigned in scope
            nonlocal done
            ^
./electrum/i18n.py:52:5: F824 `global language` is unused: name is never assigned in scope
    global language
    ^
./electrum/plugin.py:189:9: F824 `global _root_permission_cache` is unused: name is never assigned in scope
        global _root_permission_cache
        ^
5     F824 `global known_commands` is unused: name is never assigned in scope
5

```
2025-04-02 14:56:53 +00:00
ThomasV
651e081b2f Merge pull request #9671 from accumulator/fix_lightning_can_receive_offline_peer
lnworker: take peer_state into account in get_channels_for_receiving
2025-04-02 14:33:45 +02:00
ghost43
bbea6223f1 Merge pull request #9692 from f321x/fix_channel_freezing
lightning: don't use frozen channels from route hint
2025-04-02 12:28:15 +00:00
f321x
964ffbd2c4 don't use route hint channels if they are frozen 2025-04-02 13:48:46 +02:00
Sander van Grieken
08e2970889 lnworker: add parameter include_disconnected for get_channels_for_receiving(),
allowing less strict filtering when building route hints (i.e. likely usable soon-ish)
2025-04-02 11:35:47 +02:00
ThomasV
ff3e70d743 psbt_nostr: fix for watch-only wallets 2025-04-02 11:31:08 +02:00
ghost43
edbb1f2a58 Merge pull request #9664 from SomberNight/202503_bump_freeze_packages
build: partial rerun freeze_packages
2025-04-01 17:01:02 +00:00
SomberNight
b70da1d3b9 build: set YARL_NO_EXTENSIONS for all builds
due to cython version mismatch -- easier to just disable the compilation for now
2025-04-01 16:59:26 +00:00
SomberNight
269a240fb9 build: partial rerun freeze_packages
update electrum-aionostr, aiorpcx, and aiohttp (and friends)
2025-04-01 16:59:22 +00:00
SomberNight
5f551183ae tests/test_txbatcher.py: fix race in network.next_tx()
With `txbatcher.SLEEP_INTERVAL = 0.01`, on my laptop, the batcher called try_broadcasting() even before next_tx() effectively awaited _tx_event.
This resulted in the test failing due to timeout.

Basically, if the txbatcher.SLEEP_INTERVAL was too low, the 2-4 event loop iterations needed to await _tx_event.wait() took too long.
(note that the exact number of event loop iterations needed depends on the python version and the OS)
2025-04-01 15:54:05 +00:00
SomberNight
2807be08c8 tests/test_txbatcher.py: de-duplicate "create wallet" logic 2025-04-01 15:00:23 +00:00
ghost43
664c4b25d1 Merge pull request #9689 from f321x/ln_disable_fallback_fee
lightning: don't use fallback feerates for lightning fee estimation
2025-04-01 12:20:32 +00:00
f321x
0b19b660c5 don't use fallback feerates in lightning by default 2025-04-01 14:12:02 +02:00
Sander van Grieken
4a072a45b1 android: add POST_NOTIFICATIONS permission 2025-03-28 15:53:13 +01:00