1
0
Commit Graph

16647 Commits

Author SHA1 Message Date
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
ThomasV
5f3a1f0b71 do not spam log with fee_histogram 2023-08-14 09:58:17 +02:00
ThomasV
0083560ee6 swapserver: throttle payments, handle exceptions in pay_pending_invoices 2023-08-14 09:53:04 +02:00
SomberNight
13864f7abe lnworker: clear paysessions dict 2023-08-11 22:01:22 +00:00
SomberNight
98bda60c01 lnworker: move sent_buckets into PaySession 2023-08-11 22:01:19 +00:00
SomberNight
00e88c4e50 lnworker: introduce PaySession cls, refactor pay_to_node 2023-08-11 22:01:16 +00:00
SomberNight
98bea49a3c lnworker.pay_to_node: make trampoline fee_level and failed_routes local
multiple instances of pay_to_node might run concurrently, esp for trampoline forwarding
2023-08-11 22:01:11 +00:00
SomberNight
35c9ac8f31 lnworker: MPP send: more aggressively split large htlcs
related: https://github.com/spesmilo/electrum/issues/7987#issuecomment-1670002482
2023-08-11 22:01:08 +00:00
SomberNight
8f768d1da5 lnworker.pay_to_node: log num htlcs in-flight 2023-08-11 22:01:05 +00:00
ThomasV
9f5f802cd1 config: save ports instead of net addresses (follow-up 012ce1c1bb) 2023-08-11 08:12:54 +02:00
SomberNight
2557474449 (trivial) fix typo in requirements-hw.txt
follow-up 9ea5193329
2023-08-10 18:06:59 +00:00
SomberNight
cc030c60e9 lnutil: make LnFeatures.supports() faster
LnFeatures.supports() is became part of the hot path of
LNPathFinder.find_path_for_payment()
in 6b43eac6fd,
which made find_path_for_payment considerably slower than before.
It used to take around 0.8 sec originally, then after linked commit went to ~9 sec,
and now this takes it down to ~1.1 sec (on my laptop).
2023-08-10 18:05:02 +00:00
ThomasV
f85354903d swapserver: try many times, to increase trampoline fee 2023-08-10 19:55:10 +02:00
SomberNight
9ea5193329 requirements-hw: pin ledger-bitcoin to "<0.2.2"
ledger-bitcoin==0.2.2 added new deps we don't want to bundle. otherwise it should be ok to use.
see https://github.com/LedgerHQ/app-bitcoin-new/issues/192
2023-08-10 15:40:46 +00:00
ThomasV
012ce1c1bb Remove SSL options from config.
This is out of scope for Electrum; HTTP services that require SSL
should be exposed to the world through a reverse proxy.
2023-08-10 17:24:29 +02:00
SomberNight
5a3abdde85 qml: don't apply ElListView deadzones on Linux desktop
otherwise I can't click on list items if the window is moved too far to the right :O

follow-up 583afefe33

Note: on modern Android, apps don't always run full-screen.
      You can pop them out into small windows and move them.
      Haven't tested how the deadzones work then though.
2023-08-10 15:22:36 +00:00
ThomasV
dfa0dd47b7 swapserver: remove config option LIGHTNING_SWAP_HTLC_FIRST; read it from get_pairs instead. 2023-08-10 17:06:31 +02:00
SomberNight
d663d92424 qml: handle importChannelBackupFailed in WalletMainView
error was not being shown when scanning/pasting channel backup from Send screen
2023-08-10 14:46:00 +00:00
SomberNight
a187210f90 labels plugin: don't log received data
this log line is 120 KB for one of my wallets (not even cherry-picking a large one)
2023-08-10 14:31:15 +00:00
SomberNight
8931420938 interface: log: silence some tracebacks
```
191.73 | D | i/interface.[btc.electroncash.dk:60002] | (disconnect) trace for RPCError(-32603, 'internal error: bitcoind request timed out')
Traceback (most recent call last):
  File "...\electrum\electrum\interface.py", line 514, in wrapper_func
    return await func(self, *args, **kwargs)
  File "...\electrum\electrum\interface.py", line 537, in run
    await self.open_session(ssl_context)
  File "...\electrum\electrum\interface.py", line 687, in open_session
    async with self.taskgroup as group:
  File "...\aiorpcX\aiorpcx\curio.py", line 304, in __aexit__
    await self.join()
  File "...\electrum\electrum\util.py", line 1309, in join
    task.result()
  File "...\electrum\electrum\interface.py", line 724, in request_fee_estimates
    async with OldTaskGroup() as group:
  File "...\aiorpcX\aiorpcx\curio.py", line 304, in __aexit__
    await self.join()
  File "...\electrum\electrum\util.py", line 1309, in join
    task.result()
  File "...\electrum\electrum\interface.py", line 1128, in get_estimatefee
    res = await self.session.send_request('blockchain.estimatefee', [num_blocks])
  File "...\electrum\electrum\interface.py", line 169, in send_request
    response = await util.wait_for2(
  File "...\electrum\electrum\util.py", line 1383, in wait_for2
    return await asyncio.ensure_future(fut, loop=get_running_loop())
  File "...\aiorpcX\aiorpcx\session.py", line 540, in send_request
    return await self._send_concurrent(message, future, 1)
  File "...\aiorpcX\aiorpcx\session.py", line 512, in _send_concurrent
    return await future
aiorpcx.jsonrpc.RPCError: (-32603, 'internal error: bitcoind request timed out')
```

```
 93.60 | E | asyncio | Task exception was never retrieved
future: <Task finished name='Task-7385' coro=<Interface.get_estimatefee() done, defined at ...\electrum\electrum\interface.py:1123> exception=RPCError(-32603, 'internal error: bitcoind request timed out')>
Traceback (most recent call last):
  File "...\electrum\electrum\interface.py", line 1132, in get_estimatefee
    res = await self.session.send_request('blockchain.estimatefee', [num_blocks])
  File "...\electrum\electrum\interface.py", line 169, in send_request
    response = await util.wait_for2(
  File "...\electrum\electrum\util.py", line 1383, in wait_for2
    return await asyncio.ensure_future(fut, loop=get_running_loop())
  File "...\aiorpcX\aiorpcx\session.py", line 540, in send_request
    return await self._send_concurrent(message, future, 1)
  File "...\aiorpcX\aiorpcx\session.py", line 512, in _send_concurrent
    return await future
aiorpcx.jsonrpc.RPCError: (-32603, 'internal error: bitcoind request timed out')
```
2023-08-10 14:22:43 +00:00
ThomasV
e0c1fbfe77 normal swaps: use different callbacks for server and client
- client creates tx immediately
- server defers tx creation, and does not use encrypted storage
2023-08-10 15:19:52 +02:00
ThomasV
88883d762c swapserver: remove /api from url 2023-08-10 10:29:32 +02:00
ThomasV
fd10ae3a3b New flow for submarine swaps:
- client requests payment_hash from the server
 - client sends an invoice with that hash
 - client waits to receive HTLCs, then broadcasts funding tx

This means that we now use same script for normal and reverse swaps.
The new flow is enabled by setting option LIGHTNING_SWAP_HTLC_FIRST
in the client. The old protocol is still supported server-side.
2023-08-10 09:04:30 +02:00
ThomasV
11af4e47a8 follow-up ff547e3dcf 2023-08-10 09:02:42 +02:00
ThomasV
ff547e3dcf swapserver: use a single config variable for swapserver_url; testnet and regtest have their own config files 2023-08-10 08:11:37 +02:00
SomberNight
c5493a354d qt PayToEdit: always add context menu items
fixes regression from https://github.com/spesmilo/electrum/pull/8462
2023-08-09 16:00:09 +00:00
SomberNight
2f2be1a606 lnpeer: follow-up OPTION_SUPPORT_LARGE_CHANNEL
follow-up 40f2087ac3
2023-08-09 15:40:42 +00:00
SomberNight
44ef5a35b7 CLI: fix regression re handling "unknown command", re locale
if qt is not installed, e.g. on a server, was getting:
```
$ ./run_electrum sadasdasddsa
Traceback (most recent call last):
  File "/home/user/wspace/electrum/./run_electrum", line 532, in <module>
    main()
  File "/home/user/wspace/electrum/./run_electrum", line 383, in main
    lang = get_default_language(gui_name=gui_name)
  File "/home/user/wspace/electrum/electrum/gui/default_lang.py", line 23, in get_default_language
    from PyQt5.QtCore import QLocale
ModuleNotFoundError: No module named 'PyQt5.QtCore'
```
2023-08-09 14:52:40 +00:00
SomberNight
e38605c10a CLI: fix regression re handling "unknown command", re payment_identifiers
```
$ ./run_electrum sadasdasddsa
Traceback (most recent call last):
  File "/home/user/wspace/electrum/./run_electrum", line 532, in <module>
    main()
  File "/home/user/wspace/electrum/./run_electrum", line 398, in main
    if uri and not PaymentIdentifier(None, uri).is_valid():
  File "/home/user/wspace/electrum/electrum/payment_identifier.py", line 136, in __init__
    self.parse(text)
  File "/home/user/wspace/electrum/electrum/payment_identifier.py", line 265, in parse
    elif contact := self.contacts.by_name(text):
AttributeError: 'NoneType' object has no attribute 'by_name'
```
2023-08-09 14:52:37 +00:00
ThomasV
40f2087ac3 Add option for support_large_channels.
max_funding_sats is a config variable and defaults to the old value.
2023-08-09 16:36:12 +02:00
ThomasV
1ce50b9dee submarine swaps: register callbacks on startup 2023-08-09 14:15:49 +02:00
ThomasV
bf86cd6761 lnpeer and lnworker cleanup:
- rename trampoline_forwardings -> final_onion_forwardings,
   because this dict is used for both trampoline and hold invoices
 - remove timeout from hold_invoice_callbacks (redundant with invoice)
 - add test_failure boolean parameter to TestPeer._test_simple_payment,
   in order to test correct propagation of OnionRoutingFailures.
 - maybe_fulfill_htlc: raise an OnionRoutingFailure if we do not have
   the preimage for a payment that does not have a hold invoice callback.
   Without this, the above unit tests stall when we use test_failure=True
2023-08-09 13:23:26 +02:00
SomberNight
47a591b87f lnworker.pay_invoice: log more
related https://github.com/spesmilo/electrum/issues/7987#issuecomment-1670002482
2023-08-08 17:13:10 +00:00
SomberNight
afac158c80 lnworker: clean-up sent_htlcs_q and sent_htlcs_info
- introduce SentHtlcInfo named tuple
  - some previously unnamed tuples are now much shorter:
    create_routes_for_payment no longer returns an 8-tuple!
- sent_htlcs_q (renamed from sent_htlcs), is now keyed on payment_hash+payment_secret
  (needed for proper trampoline forwarding)
2023-08-08 16:37:50 +00:00
SomberNight
44bdd20ccc lnworker: add RecvMPPResolution with "FAILED" state
- add RecvMPPResolution enum for possible states of a pending incoming MPP,
  and use it in check_mpp_status
  - new state: "FAILED", to allow nicely failing back the whole MPP set
- key more things with payment_hash+payment_secret, for consistency
  (just payment_hash is insufficient for trampoline forwarding)
2023-08-08 16:37:46 +00:00
SomberNight
c527ef8967 lnpeer: refuse to forward htlcs that correspond to payreq we created 2023-08-07 18:57:04 +00:00
ThomasV
cb907c90f9 submarine swaps: set prepay_hash for normal swaps.
This fixes the group_id of fee prepayment transactions for the server
2023-08-06 11:37:31 +02:00
SomberNight
8dd5865469 rm unused import
follow-up d51f00e2a3
2023-08-04 18:21:50 +00:00
SomberNight
5a4b98a066 CI: don't run unit tests on "python:rc", looks like it's unmaintained
The "python:rc" tag on dockerhub has not been updated for 2+ years
and is still at 3.10.0rc2. Even 3.11 has been released for many months now.
see https://hub.docker.com/_/python/tags
2023-08-04 18:18:24 +00:00
SomberNight
d51f00e2a3 asyncio.wait_for() is too buggy. use util.wait_for2() instead
wasted some time because asyncio.wait_for() was suppressing cancellations. [0][1][2]
deja vu... [3]

Looks like this is finally getting fixed in cpython 3.12 [4]
So far away...
In attempt to avoid encountering this again, let's try using
asyncio.timeout in 3.11, which is how upstream reimplemented wait_for in 3.12 [4], and
aiorpcx.timeout_after in 3.8-3.10.

[0] https://github.com/python/cpython/issues/86296
[1] https://bugs.python.org/issue42130
[2] https://bugs.python.org/issue45098
[3] https://github.com/kyuupichan/aiorpcX/issues/44
[4] https://github.com/python/cpython/pull/98518
2023-08-04 18:18:21 +00:00
SomberNight
20f4d44f09 cli: "daemon -d": init rpc credentials before os.fork()
follow-up 8b195ee77a
2023-08-03 22:42:08 +00:00
SomberNight
69336befee follow-up ImportedChannelBackup changes: fix opening wallet w/ old cbs
follow-up https://github.com/spesmilo/electrum/pull/8536

```
  1.52 | E | gui.qt.ElectrumGui |
Traceback (most recent call last):
  File "/home/user/wspace/electrum/electrum/gui/qt/__init__.py", line 342, in start_new_window
    wallet = self.daemon.load_wallet(path, None)
  File "/home/user/wspace/electrum/electrum/daemon.py", line 469, in func_wrapper
    return func(self, *args, **kwargs)
  File "/home/user/wspace/electrum/electrum/daemon.py", line 479, in load_wallet
    wallet = self._load_wallet(path, password, manual_upgrades=manual_upgrades, config=self.config)
  File "/home/user/wspace/electrum/electrum/util.py", line 466, in do_profile
    o = func(*args, **kw_args)
  File "/home/user/wspace/electrum/electrum/daemon.py", line 504, in _load_wallet
    db = WalletDB(storage.read(), manual_upgrades=manual_upgrades)
  File "/home/user/wspace/electrum/electrum/wallet_db.py", line 117, in __init__
    self._after_upgrade_tasks()
  File "/home/user/wspace/electrum/electrum/wallet_db.py", line 247, in _after_upgrade_tasks
    self._load_transactions()
  File "/home/user/wspace/electrum/electrum/util.py", line 466, in do_profile
    o = func(*args, **kw_args)
  File "/home/user/wspace/electrum/electrum/wallet_db.py", line 1536, in _load_transactions
    self.data = StoredDict(self.data, self, [])
  File "/home/user/wspace/electrum/electrum/json_db.py", line 117, in __init__
    self.__setitem__(k, v)
  File "/home/user/wspace/electrum/electrum/json_db.py", line 49, in wrapper
    return func(self, *args, **kwargs)
  File "/home/user/wspace/electrum/electrum/json_db.py", line 135, in __setitem__
    v = self.db._convert_dict(self.path, key, v)
  File "/home/user/wspace/electrum/electrum/json_db.py", line 247, in _convert_dict
    v = dict((k, constructor(**x)) for k, x in v.items())
  File "/home/user/wspace/electrum/electrum/json_db.py", line 247, in <genexpr>
    v = dict((k, constructor(**x)) for k, x in v.items())
TypeError: ImportedChannelBackupStorage.__init__() missing 1 required positional argument: 'local_payment_pubkey'
```
2023-08-03 17:21:11 +00:00
SomberNight
a674f63ce3 qt channels list: add TODO
(noticed on regtest)
2023-08-03 17:21:08 +00:00
SomberNight
8b195ee77a cli: "./run_electrum daemon -d" to block until daemon becomes ready
Without this,
`$ python3 -m unittest electrum.tests.regtest.TestUnixSockets.test_unixsockets`
was failing on my machine but succeeding on CI, due to timing differences.
2023-08-03 17:21:05 +00:00
SomberNight
58a9904a34 daemon: rm "daemon_jobs". maybe makes _run API less error-prone
(follow-up prev)
2023-08-03 17:21:01 +00:00
SomberNight
e94d45edd8 swapserver: small clean-up 2023-08-03 17:20:58 +00:00
Sander van Grieken
c068b80d78 qml: fix issues with 2fa, simplify terms and conditions retrieval code 2023-08-03 17:17:06 +02:00