Commit Graph

903 Commits

Author SHA1 Message Date
ThomasV
a0636e8f33 lnworker: fix timestamp in get_lightning_history 2025-06-06 08:46:21 +02:00
ThomasV
94517fbc0e lnworker: minor fix, follow-up fc4f995668 2025-06-03 10:26:25 +02:00
ThomasV
fc4f995668 lnworker: fix invoice status in htlc_failed from previous session
(status was remaining inflight)
2025-06-02 16:14:34 +02:00
ThomasV
ae7a1073cf Merge pull request #9685 from f321x/hold_invoice_cli
cli: add hold invoice cli functionality
2025-06-01 12:03:46 +02:00
ThomasV
853b793bef rm verbosity_shortcuts option (unused, redundant) 2025-05-29 16:20:41 +02:00
Sander van Grieken
84322500ef lnworker: imports, formatting, whitespace 2025-05-23 14:00:57 +02:00
f321x
539b83c2e4 followup #9845, fix broken mpp consolidation test
fixes broken test_trampoline_mpp_consolidation caused to fail by
https://github.com/spesmilo/electrum/pull/9845 by allowing single
channel splits for trampoline payments if TEST_FORCE_MPP is Trues
as the test relies on mpp through a single channel (it tests mpp and
there is only a single channel on the graph).
2025-05-20 18:34:46 +02:00
ThomasV
d1917b2951 Merge pull request #9837 from spesmilo/htlc_slots_left
pass number of htlc_slots_left to suggest_splits
2025-05-20 12:55:45 +02:00
ThomasV
4a17d5a316 pass number of htlc_slots_left to suggest_splits 2025-05-17 15:50:03 +02:00
f321x
f7ad95f42d make lightning dns seed fetching async 2025-05-16 17:10:10 +02:00
ThomasV
128eb9cc8b available_to_spend: remove unused 'strict' parameter 2025-05-16 12:29:49 +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
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
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
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
f321x
41b8b16a7c add hold invoice cli functionality 2025-05-09 18:48:05 +02:00
ThomasV
5be646dfd2 call lnwatcher callbacks in asyncio thread
This partially reverts fbebe7de1a
lnwatcher.trigger_callbacks is called manually in commands.py
2025-05-06 12:37:00 +02:00
f321x
396800be61 fix: exception in suggest_swap_to_send due to missing method
can_pay_onchain has been removed in commit 840243e but
suggest_swap_to_send was still calling it causing an exception.
2025-05-05 12:41:41 +02:00
f321x
e72de47ef0 Remove LIGHTNING_LEGACY_ADD_TRAMPOLINE config option to prevent too large onion payload
The option to add a 2nd trampoline hop to legacy trampoline payments requires too much space in the trampoline onion.
Because the trampoline onion has only limited space of 400b and the payload with 2nd t hop and no r_tags already requires 392b it is essentially unusable for payments that require routing hints to be included in the onion
(because the receiver has no direct channel to the 2nd trampoline node)
as there is no space left to include them (1r_tag == ~52b).
2025-04-14 09:35:41 +02:00
ThomasV
875cb24665 Merge pull request #9707 from f321x/fix_receive_unknown_htlc_failed
lightning: trigger payment_failed only once in LNWallet.htlc_failed().
2025-04-11 12:39:25 +02:00
f321x
253ab6849a implement NIP47 plugin 2025-04-10 10:22:29 +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
f321x
cb4837f1b3 trigger payment_failed only once on htlc timeout tx failing 2025-04-07 13:00:29 +02:00
f321x
6e8bdb346a move onchain balance calculation to wallet.py 2025-04-04 15:08:51 +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
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
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
f321x
0b19b660c5 don't use fallback feerates in lightning by default 2025-04-01 14:12:02 +02:00
ThomasV
e9335f5cc7 fix typo 2025-03-20 10:54:29 +01:00
ThomasV
525e261520 lnworker: replace sometimes failing assert with print statement
this assert typically fails when a channel is force-closed and
the tx is unconfirmed
2025-03-20 10:09:04 +01:00
ThomasV
60338eba5d lnworker.handle_onchain_state early return if no network (follow-up fbebe7de1a) 2025-03-20 10:00:59 +01:00
SomberNight
d36e877eb8 lnworker: comment re hist: if paying MPP, amt and fee might be shifted
a bit confusing behaviour
2025-03-18 19:25:18 +00:00
ThomasV
26910ef81d Merge pull request #9620 from accumulator/lightning_pass_invoice_not_bolt11
refactor lnworker.pay_invoice to accept Invoice object instead of bolt11 string
2025-03-18 20:09:01 +01:00
ThomasV
8e6be0a36a Remove inheritance between LNWatcher and Watchtower
As LNWatcher is no longer async, there is not enough overlap
between these classes to deserve inheritance
2025-03-14 11:59:56 +01:00
ThomasV
fbebe7de1a Make lnwatcher not async
This fixes offline history not having the proper labels
2025-03-14 11:09:11 +01:00
f321x
af8d1fb401 handle jit invoices in qml
make min funding amount symbol, change Signal name, change Exception type

change minChannelFunding to QEAmount and make message text variable

qml: improve translatibility of strings

init minchannelfunding value in init method

rebase on master
2025-03-13 12:02:46 +01:00
ThomasV
798df671ea If we have proposed htlcs in a channel that was force-closed,
call lnworker.htlc_failed once the htlc_tx is deeply mined.

In the case of a forwarding, this will fail incoming htlcs.
(fixes #8547)
2025-03-12 20:11:11 +01:00
ThomasV
c42201ccac remove lnworker.enable_htlc_settle_onchain: not used
I think this has only been used for manual testing
2025-03-11 12:12:43 +01:00
Sander van Grieken
6fdb6c93f7 refactor lnworker.pay_invoice to accept Invoice object instead of bolt11 string
rename lnworker._check_invoice to lnworker._check_bolt11_invoice
2025-03-09 14:47:34 +01:00
ThomasV
8011ae00ab Merge pull request #9586 from f321x/jit-block-preimage
Add mechanism to block htlcs from settling back
2025-03-07 12:04:39 +01:00
f321x
109ad2b3da add mechanism to block htlcs from settling back 2025-03-07 12:03:59 +01:00
ThomasV
840243e029 separate fee policy from config
- Wallet.make_unsigned_transaction takes a FeePolicy parameter
 - fee sliders act on a FeePolicy instead of config
 - different fee policies may be used for different purposes
 - do not detect dust outputs in lnsweep, delegate that to lnwatcher
2025-03-05 10:29:26 +01:00
ThomasV
6234cbf97b Merge pull request #9603 from spesmilo/gossip_info
gossip: less log lines, use command line instead
2025-03-05 08:23:19 +01:00
ThomasV
1201b87ad7 Merge pull request #9587 from f321x/jit-invoice-creation
Disable mpp flags in invoice creation if jit channel is required and consider available liquidity
2025-03-04 16:07:54 +01:00
f321x
d62eb7ab13 disable mpp flags in invoice creation if jit channel is required, check against available liquidity if we need a jit channel 2025-03-04 15:24:03 +01:00
ThomasV
96d0dad41c gossip: less log lines, use command line instead 2025-03-04 14:33:54 +01:00
f321x
d348da811a introduce gossip query handling and forwarding 2025-03-04 13:10:37 +01:00