1
0
Commit Graph

18542 Commits

Author SHA1 Message Date
SomberNight
d0be5fcfc8 lnchannel: persist error sent by remote peer into db
If a force-close happens due to e.g. a feerate disagreement or an invalid signature, etc,
and the remote peer sends us an error, it can be useful if users can provide us with this error.
If the user does not have logging enabled when the error is sent, without this persistence it will likely get lost.
2025-05-18 16:54:56 +00:00
ThomasV
d435d65bf5 Merge pull request #9838 from spesmilo/cli_get_preimage
CLI: add preimage to invoices
2025-05-18 15:37:44 +02:00
ThomasV
a66439eea5 CLI: add preimage to get_invoice
This should make regtest extract_preimage more reliable
2025-05-18 15:25:06 +02:00
ThomasV
a213dfca85 Qt: move nostr_relays to network dialog 2025-05-18 13:42:25 +02:00
ThomasV
79941529d2 simplify plugin logic: remove install/uninstall buttons
external plugins are enabled iff authorized
2025-05-18 12:24:38 +02:00
ThomasV
0a69a3d658 Merge pull request #9765 from f321x/plugin_pubk_user_prompt
plugins: add functionality to allow setting plugin pubkey from gui
2025-05-18 12:08:12 +02:00
SomberNight
1c41bd23b7 network: broadcast_transaction: log full raw tx on errors 2025-05-16 15:49:54 +00:00
SomberNight
68ac2d8079 network: sanitize_tx_broadcast_response: add new error messages 2025-05-16 15:48:12 +00:00
ThomasV
367dde4c9b Merge pull request #9835 from accumulator/qml_psbt_nostr_toggle
qml: add psbt_nostr enable/disable option in Preferences
2025-05-16 14:48:36 +02:00
Sander van Grieken
9a2a65c20f qml: add psbt_nostr enable/disable option in Preferences 2025-05-16 14:00:23 +02:00
ThomasV
f147058664 Merge pull request #9834 from f321x/fix_terms_wizard_windows
fix: make ToU scrollbar detection more reliable
2025-05-16 13:32:01 +02:00
ThomasV
b8c6200434 Merge pull request #9800 from accumulator/psbt_nostr_qml_choices
Psbt nostr qml choices
2025-05-16 13:30:58 +02:00
f321x
12ff5b2728 fix: make ToU scrollbar detection more reliable
adds some delay before detecting the scrollbar in the terms of use
dialog. This prevents it from falsely detecting a scrollbar and
disabling the "I Agree" button even if there is no scrollbar. I noticed this
issue on windows, the order in which the window is created seems to be
slightliy different from linux/wayland there.
2025-05-16 13:13:00 +02:00
ThomasV
9f9919e351 available_to_spend: check too_many_htlcs
partial fix for #8857
(this should at least fix the trampoline case)
2025-05-16 12:34:27 +02:00
ThomasV
128eb9cc8b available_to_spend: remove unused 'strict' parameter 2025-05-16 12:29:49 +02:00
ThomasV
fed526bbdf lnchannel: create helper functions too_many_htlcs and remaining_max_inflight 2025-05-16 12:29:00 +02:00
Sander van Grieken
c3f0993e53 test_lnchannel: add single_payment testcase for TestAvailableToSpend 2025-05-16 12:29:00 +02:00
Sander van Grieken
7f621d29b5 lnchannel: available_to_spend constrain max amount to channel max_htlc_value_in_flight_msat 2025-05-16 12:28:11 +02:00
ThomasV
25c53ec3a5 Merge pull request #9792 from accumulator/qml_issue_noamt_lninvoice_sticky_override_amt
qml: fix storing override amount too soon, while user is allowed to set a new override amount which was silently ignored.
2025-05-16 11:19:53 +02:00
Sander van Grieken
77407fa206 qml: offer same choices as desktop; Open, Discard, Save to wallet 2025-05-16 10:41:41 +02:00
accumulator
8368469e2c Merge pull request #9832 from accumulator/fix_9829
qml: handle callbacks via ui thread.
2025-05-16 10:23:03 +02:00
Sander van Grieken
c89398cd5b qml: handle callbacks via ui thread. 2025-05-16 09:49:41 +02:00
SomberNight
6320597f2c regtests: rm sleep from "swapserver_forceclose" test
less reliance on timing
(OTOH it hardcodes the output index of the commitment tx... meh)
2025-05-15 19:50:16 +00:00
SomberNight
f3551f3c25 commands: add cmd wait_for_sync 2025-05-15 19:42:34 +00:00
SomberNight
586cf33c05 lnchannel: rm sweep_info cache
- was added when functions in lnsweep returned already signed tx, and signing is expensive
- get_ctx_sweep_info does not presign anymore
- cache invalidation is difficult here
  - e.g. not only on new blocks, but we should e.g. also invalidate the cache when learning new preimages
2025-05-15 19:41:44 +00:00
SomberNight
b1f0c6e353 synchronizer: get_transaction should discard tx_height as it can change
tx_height comes from the `get_history` RPC, we then call the `get_transaction` RPC.
By the time the `get_transaction` RPC returns, we might have received another
scripthash status update, called `get_history` again, and updated height for the txid.
Synchronizer._get_transaction() should not call adb.receive_tx_callback() with
the old tx_height (but it was doing exactly that).

Patch to trigger, e.g. regtest failures:
(e.g. for tests.regtest.TestLightningAB.test_extract_preimage)
```
diff --git a/electrum/interface.py b/electrum/interface.py
index 8649652b9c..fce7a1c6de 100644
--- a/electrum/interface.py
+++ b/electrum/interface.py
@@ -991,6 +991,7 @@ class Interface(Logger):
         return res

     async def get_transaction(self, tx_hash: str, *, timeout=None) -> str:
+        await asyncio.sleep(3)
         if not is_hash256_str(tx_hash):
             raise Exception(f"{repr(tx_hash)} is not a txid")
         raw = await self.session.send_request('blockchain.transaction.get', [tx_hash], timeout=timeout)

```
2025-05-15 19:35:15 +00:00
SomberNight
61283fe18b adb: (trivial) receive_tx_callback: make tx_height param kw-only 2025-05-15 19:09:37 +00:00
ThomasV
626264d24f Merge pull request #9784 from f321x/allow_lnaddress_contacts
qt: allow lightning addresses in contacts
2025-05-15 19:09:48 +02:00
f321x
b6e1e527c2 contacts: support lightning addressses as contact address
lightning addresses are useful and widely adopted, so it should be
possible to save them as payment identifier for a contact.
2025-05-15 17:55:23 +02:00
ThomasV
6500788328 Merge pull request #9710 from f321x/dont_delete_config_on_syntax_error
config: Raise instead of overwriting the config file on syntax error
2025-05-15 17:24:35 +02:00
f321x
8870838834 raise instead of overwriting the config file on syntax error 2025-05-15 17:21:16 +02:00
ghost43
79a54c1578 Merge pull request #9826 from f321x/fix_fee_disagreement_ln
fix: reduce update_fee target for anchor channels
2025-05-15 13:30:11 +00:00
ThomasV
93e7de20e9 Merge pull request #9753 from f321x/debug_ln_payment_failure
ln: don't exclude single part configs for too small payments
2025-05-15 13:25:00 +02:00
f321x
e8171ca7c6 suggest_splits: don't exclude single part configs for too small multi
part configs

I noticed certain ln payments become very unreliable. These payments are ~21k sat, from gossip to gossip sender, with direct, unannounced channel.

Due to the recent fix https://github.com/spesmilo/electrum/pull/9723 `LNPathFinder.get_shortest_path_hops()` will not use channels for the last hop of a route anymore that aren't also passed to it in `my_sending_channels`:

```python
if edge_startnode == nodeA and my_sending_channels:  # payment outgoing, on our channel
    if edge_channel_id not in my_sending_channels:
        continue
```

Conceptually this makes sense as we only want to send through `my_sending_channels`, however if the only channel between us and the receiver is a direct channel that we got from the r_tag and it's not passed in `my_sending_channel` it's not able to construct a route now.

Previously this type of payment worked as `get_shortest_path_hops()` knew of the direct channel between us and `nodeB` from the invoices r_tag and then just used this channel as the route, even though it was (often) not contained in `my_sending_channels`.

`my_sending_channels`, passed in `LNWallet.create_routes_for_payment()` is either a single channel or all our channels, depending on `is_multichan_mpp`:

```python
for sc in split_configurations:
	  is_multichan_mpp = len(sc.config.items()) > 1
```

This causes the unreliable, random behavior as `LNWallet.suggest_splits()` is supposed to `exclude_single_part_payments` if the amount is > `MPP_SPLIT_PART_MINAMT_SAT` (5000 sat).
As `mpp_split.py suggest_splits()` is selecting channels randomly, and then removes single part configs, it sometimes doesn't return a single configuration, as it removes single part splits, and also removes multi part splits if a part is below 10 000 sat:

```python
if target_parts > 1 and config.is_any_amount_smaller_than_min_part_size():
    continue
```

This will result in a fallback to allow single part payments:

```python
split_configurations = get_splits()
if not split_configurations and exclude_single_part_payments:
    exclude_single_part_payments = False
    split_configurations = get_splits()
```

Then the payment works as all our channels are passed as `my_sending_channels` to  `LNWallet.create_routes_for_payment()`.

However sometimes this fallback doesn't happen, because a few mpp configurations found in the first iteration of `suggest_splits` have been kept, e.g. [10500, 10500], but at the same time most others have been removed as they crossed the limit, e.g. [11001, 9999], (which happens sometimes with payments ~20k sat), this makes `suggest_splits` return very few usable channels/configurations (sometimes just one or two, even with way more available channels).
This makes payments in this range unreliable as we do not retry to generate new split configurations if the following path finding fails with `NoPathFound()`, and there is no single part configuration that allows the path finding to access all channels. Also this does not only affect direct channel payments, but all gossip payments in this amount range.

There seem to be multiple ways to fix this, i think one simple approach is to just disable `exclude_single_part_payments` if the splitting loop already begins to sort out configs on the second iteration (the first split), as this indicates that the amount may be too small to split within the given limits, and prevents the issue of having only few valid splits returned and not going into the fallback. However this also results in increased usage of single part payments.
2025-05-15 10:26:33 +02:00
ThomasV
33ea89c94b Merge pull request #9793 from accumulator/psbt_nostr_send_description
PSBT nostr, send invoice/tx description along with PSBT
2025-05-15 09:44:55 +02:00
ThomasV
926e20be9c Merge pull request #9825 from accumulator/qt_no_request_details_when_multiple_selected
qt: don't show request details when multiple requests are selected in…
2025-05-15 09:32:43 +02:00
f321x
61874e9fe7 fix: reduce update_fee target for anchor channels
the update_fee logic for lightning channels was not adapted to anchor
channels causing us to send update_fee with a eta target of 2 blocks.
This causes force closes when there are mempool spikes as the fees we
try to update to are a lot higher than e.g. eclair uses. Eclair will
force close if our fee is 10x > than their fee.
2025-05-14 18:01:44 +02:00
SomberNight
6c11c75d58 follow-up prev 2025-05-14 13:29:30 +00:00
SomberNight
44f3444795 lnworker: make "preimages" dict private
I want to hook into lnworker.save_preimage (not done yet).
Other modules should not put preimages into the dict directly.
2025-05-14 13:23:02 +00:00
Sander van Grieken
4c88836389 qt: don't show request details when multiple requests are selected in request_list 2025-05-14 14:45:14 +02:00
ThomasV
37352ea5a9 Merge pull request #9823 from f321x/psbt_nostr_verify_authors
fix: verify author pubkey of psbt nostr events
2025-05-14 13:12:25 +02:00
Sander van Grieken
a9213c4d66 psbt_nostr: send label along with PSBT 2025-05-14 12:49:33 +02:00
Sander van Grieken
6566f2f0a4 qt: pass Invoice object to transaction dialog when appropriate.
This is purely informational and optional, with the main immediate use to provide the
invoice description/message/label to the transaction dialog, so it can be stored
when saving the tx in history, or passed along with PSBTs sent to cosigners.

Before, the tx description was not saved in history when an invoice was not saved before
signing and saving the tx for sending later.
2025-05-14 12:49:33 +02:00
Sander van Grieken
f535817006 psbt_nostr: qml: don't let iterator overwrite param 2025-05-14 12:48:47 +02:00
f321x
759022d3ff fix: verify author pubkey of psbt nostr events
Checks if the pubkey of the author sending the psbt cosigning
request is in our list of cosigner pubkeys to prevent accepting
"fake" requests from other pubkeys.
2025-05-14 11:28:11 +02:00
Sander van Grieken
a45ca41268 qml: fix storing override amount too soon, while user is allowed to set a new override amount which was silently ignored.
lightning: implicit save of lightning invoice with override amount deferred until actual payment is accepted.
on-chain: for now, invoice is implicitly saved when override amount is passed to ConfirmTxDialog. (this is sooner
than current desktop client, which saves - and only saves - when Pay is clicked from ConfirmTxDialog)
2025-05-14 10:57:57 +02:00
SomberNight
1b031d432e qt tx dialog: allow clicking into the future. wheeee
- "outpoints" for inputs were already clickable to open the funding tx
- now "outpoints" for outputs are also clickable to open the spending tx
2025-05-13 18:30:20 +00:00
accumulator
2947de23da Merge pull request #9820 from f321x/qml_terms_of_use
qml: add terms of use to setup wizard
2025-05-13 15:54:34 +02:00
f321x
adaafeaae1 disable proxy checkbox in ProxyConfig by default
disable the checkbox by default, so that if a user selects Enable Proxy
in the advanced network settings, and then just clicks next with the proxy
checkbox set, doesn't end up with a invalid proxy configuration which
doesn't connect to the server and has to be fixed manually.
2025-05-13 14:28:22 +02:00
f321x
38f51a3b13 qml: add terms of use to setup wizard 2025-05-13 14:28:13 +02:00