1
0
Commit Graph

19480 Commits

Author SHA1 Message Date
Sander van Grieken
fb58d210e5 onion_message: fix forwarding, blinding was renamed path_key
followup 130af59760
2025-12-05 17:51:19 +01:00
ghost43
f3dccc8e4b Merge pull request #10347 from accumulator/gossip_cln_feature_workaround
electrum refuses to exchange gossip with CLN nodes, due to missing feature OPTION_CHANNEL_TYPE_OPT
2025-12-05 15:18:55 +00:00
Sander van Grieken
3e4f80aa06 electrum refuses to exchange gossip with CLN nodes, due to missing feature OPTION_CHANNEL_TYPE_OPT.
moving OPTIONAL_CHANNEL_TYPE_OPT to BASE_FEATURES
2025-12-05 15:51:16 +01:00
ThomasV
55cc27d27e Test JIT channels: check that lnpay success is true.
This test fails since 0f314d1dd9
2025-12-05 12:05:37 +01:00
ThomasV
cd1d384db5 lnwatcher: remove address callback if keep_watching is False
(follow-up 9b72dc297b)
2025-12-05 11:53:24 +01:00
ThomasV
40729aa0e5 test accounting_addresses: stop alice before requesting, because we need a new session.
(follow-up 9b72dc297b)
2025-12-05 11:31:27 +01:00
SomberNight
ef0e4e02b7 txbatcher: add TODOs re nLocktime block-height vs timestamp confusion
seems harmless atm but some rethinking is needed and checks should be added
2025-12-04 15:32:46 +00:00
ghost43
1eb69c90dd Merge pull request #10341 from SomberNight/202512_nwc_dontmutateevent
plugins: nwc: don't mutate aionostr Event
2025-12-04 15:24:40 +00:00
ThomasV
9b72dc297b lnwatcher: remove rearly return that breaks accounting_addresses
This reverts 6ffaa55.
Also, in regtests, add a check that fails if accounting_addresses are broken.
2025-12-04 10:26:01 +01:00
SomberNight
75ac8bcee1 plugins: nwc: don't mutate aionostr Event
I want to change the Event class to be immutable.
2025-12-04 00:47:32 +00:00
ThomasV
32c677bed0 Qt wizard: bugfix: standardize_path in WCWalletName
without this, any wallet that is not in the config
wallet_path cannot be open.
2025-12-03 11:45:51 +01:00
ThomasV
cb7e550abb follow-up prev commit 2025-12-02 10:38:10 +01:00
SomberNight
14fd85f935 json_db: fix StoredDict.__delitem__() to work similarly to .pop()
follow-up https://github.com/spesmilo/electrum/pull/10233 ("jsondb pointers")
2025-12-01 19:42:47 +00:00
SomberNight
afc87fea9a tests: json_db: add more asserts for clarity 2025-12-01 19:33:14 +00:00
SomberNight
1119cb9a75 json_db: add some type hints and asserts
- fix some incorrect type hints
- add many new type hints
- add asserts re types

no functional changes intended
2025-12-01 19:29:51 +00:00
SomberNight
828fc569c9 commands: version_info: include openssl version 2025-11-30 06:03:08 +00:00
ghost43
d17bb016ef Merge pull request #10330 from SomberNight/202511_lnsweep_refactor_preimage
lnsweep: factor out "maybe_reveal_preimage_for_htlc"
2025-11-28 16:57:05 +00:00
SomberNight
ef8fd03e8f lnsweep: factor out "maybe_reveal_preimage_for_htlc"
no functional changes
2025-11-28 15:55:35 +00:00
ghost43
125b7ee0d7 Merge pull request #10319 from f321x/fix_lightning_num_sats_can_send
lnworker: use config lightning fee for estimate
2025-11-28 15:35:05 +00:00
f321x
c575abc8e2 qt: update tabs on exit of SettingsDialog
Update the tabs after the SettingsDialog gets closed, some values might
have to be updated according to the new configuration.
2025-11-28 16:25:39 +01:00
f321x
af4dc24d87 lnworker: use config lightning fee for estimate
I was unable to do a "Max" amount submarine swap because the
`fee_estimate` method used by `LNWallet.num_sats_can_send()` uses a
hardcoded `fee_proportional_millionths` to estimate the fee for the
lightning payment.
When the actual fee determined later is higher
than the estimated fee the payment fails as the channel is unable to add
the htlc sum including the real fees as the amount exceeds the balance of
the channel.
Using the fees the maximum fees user has configured and estimate the
potential fee as inverse of PaymentFeeBudget is more
reliable/conservative as we definitely aren't going to pay more fees
than this amount.
2025-11-28 16:25:34 +01:00
ThomasV
bcbc1b4e6e Merge pull request #10328 from f321x/improve_lnfee_slider
qt: SettingsDialog: update ln fee config on slider moved
2025-11-28 14:06:13 +01:00
ThomasV
128026a442 SwapProvidersButton class
factorize code that is used in both SwapDialog and Submarine payments
2025-11-28 13:31:14 +01:00
ThomasV
8bec3eafd2 swaps dialog: in callbacks, update either send or receive field, depending on which one follows
before this, the content of the non-following field could be modified by callbacks
2025-11-28 10:49:23 +01:00
f321x
088f273d9b qt: SettingsDialog: update ln fee config on slider moved
When moving the lightning fee slider in the SettingsDialog by clicking
on the range instead of pulling the slider the new fee value wouldn't
get stored in the config as the sliderRelased signal is only emitted
when the slider is pulled.
This change updates it on valueChanged.
2025-11-28 09:55:32 +01:00
ghost43
3f45c41981 Merge pull request #10230 from f321x/refactor_htlc_handling
lightning: refactor htlc switch
2025-11-27 17:26:53 +00:00
ghost43
09af77872f Merge pull request #10327 from f321x/followup_10303
swaps: followup 10303
2025-11-27 17:25:22 +00:00
f321x
59586d6f94 tests: lnpeer: add test_payment_with_malformed_onion
Adds a simple forwarding test where the receiver fails a malformed onion with
`update_fail_malformed_htlc`.
2025-11-27 17:58:51 +01:00
f321x
16ed7e666c lnpeer: use INVALID_ONION_VERSION for unparsable onions
Use the `OnionFailureCode.INVALID_ONION_VERSION` (BADONION | PERM | 4)
code when sending back `update_fail_malformed_htlc` as just sending a plain
`BADONION` is not explicitly mentioned as correct in the spec.
2025-11-27 17:58:49 +01:00
f321x
1fd5458b0e tests: lnpeer: test_dont_expire_htlcs
Adds unittest to test the dont_expire_htlcs logic
2025-11-27 17:58:47 +01:00
f321x
4f2e1b65f0 tests: test_lnpeer: add test_dont_settle_htlcs
Adds test for the dont_settle_htlcs functionality of lnworker used by
Just-In-Time channels.
2025-11-27 17:58:46 +01:00
f321x
abc469c846 lnworker: split dont_settle_htlcs
Splits `LNWallet.dont_settle_htlcs` into `LNWallet.dont_settle_htlcs`
and `LNWallet.dont_expire_htlcs`.

Registering a payment hash in dont_settle_htlcs will prevent it from
getting fulfilled if we have the preimage stored. The preimage will not
be released before the the payment hash gets removed from
dont_settle_htlcs. Htlcs can still get expired as usual or failed if no
preimage is known.
This is only used by Just-in-time channel openings.

Registering a payment hash in dont_expire_htlcs allows to overwrite the
minimum final cltv delta value after which htlcs would usually get
expired. This allows to delay expiry of htlcs or, if the value in the
dont_settle_htlcs dict is None, completely prevent expiry and let the
htlc get expired onchain.

Splitting this up in two different dicts makes it more explicit and
easier to reason about what they are actually doing.

 Please enter the commit message for your changes. Lines starting
2025-11-27 17:58:44 +01:00
f321x
b1e58450bd tests: test_lnpeer: add test_payment_bundle_with_hold_invoice
Adds test_payment_bundle_with_hold_invoice to simulate the use of a
payment bundle in which one invoice of the bundle needs to trigger a hold invoice
callback (similar to submarine swaps).
Also modifies the test helper _test_simple_payment() to compare the
results of all payment attempts instead of just returning after the
first (of multiple) payments raises its result causing the test to miss
if all payments were successful or not.
2025-11-27 17:58:43 +01:00
f321x
95729a08ef lnpeer: report htlc_switch exceptions to crash reporter
It seems useful to report exceptions happening in the htlc_switch to the
crash reporter as it shouldn't raise exceptions in theory and this could
help catch subtle bugs.
2025-11-27 17:58:41 +01:00
f321x
042557da9b tests: test_lnpeer: test_htlc_switch_iteration_benchmark
Benchmark how long a call to _run_htlc_switch_iteration takes with 10
trampoline mpp sets of 1 htlc each.
2025-11-27 17:58:40 +01:00
f321x
f56b13b610 tests: test_lnpeer: test_hold_invoice_set_doesnt_get_exp
Add test `test_hold_invoice_set_doesnt_get_expired` to test_lnpeer to
ensure a mpp set on which a hold invoice callback doesn't get expired
automatically if the cltv_abs falls below MIN_FINAL_CLTV_DELTA_ACCEPTED
as these sets should only get failed if the htlcs are safe to fail by
the target of the hold invoice callback (e.g. swap got refunded
successfully).
2025-11-27 17:58:38 +01:00
f321x
bb828097b3 tests: test_lnpeer: test compare trampoline onions
Adds test_forwarder_fails_for_inconsistent_trampoline_onions
which checks that a forwarder compares the trampoline onions of a mpp
set and fails the set if the onions are not similar.
In the test alice sends a mpp through bob with 2 htlcs, in one
trampoline onion amt_to_forward is off by 1 msat so bob fails the htlc
set instead of initiating the trampoline forwarding.
2025-11-27 17:58:34 +01:00
f321x
447d91d7b6 tests: lnpeer: test_trampoline_mpp_consolidation_forwarding_amount
Add sanity check that bob is not forwarding more sats to carol if than
he receives from alice. (he only forwards once and doesn't try to
forward multiple times).
This should get caught by asserts in lnworker/lnpeer, nevertheless it
seems to make sense to just add this test to prevent regressions of this
kind.
2025-11-27 17:57:26 +01:00
f321x
f35b353841 tests: lnpeer: test_mpp_cleanup_after_expiry
1. Alice sends two HTLCs to Bob, not reaching total_msat,
   and eventually they MPP_TIMEOUT
2. Bob fails both HTLCs
3. Alice then retries and sends HTLCs again to Bob, for the same RHASH,
   this time reaching total_msat, and the payment succeeds

Test that the sets are properly cleaned up after MPP_TIMEOUT
and the sender gets a second chance to pay the same invoice.
2025-11-27 17:57:25 +01:00
f321x
a91f7c519f tests: lnpeer: test_dont_settle_partial_mpp_trigger_with_invalid_cltv_htlc
Adds unittest to verify that lnpeer doesn't settle any htlcs of
incomplete mpp.
2025-11-27 17:57:23 +01:00
f321x
a7de8de5a2 tests: lnpeer: test_reject_multiple_payments_of_same_invoice
Test that lnpeer rejects incoming htlcs for payments that have already
been paid so invoices cannot be paid twice.
2025-11-27 17:57:21 +01:00
f321x
7840df2e0d tests: lnpeer: test_reject_payment_for_expired_invoice
Test that lnpeer is rejecting incoming htlcs for invoices that are
already expired.
2025-11-27 17:57:19 +01:00
f321x
da5f59903d tests: lnpeer: test_reject_invalid_min_final_cltv_delta
Add `test_reject_invalid_min_final_cltv_delta` which is supposed to test
that the peer rejects incoming htlcs with final cltv delta differing
from what has been requested in the lightning invoice.
2025-11-27 17:57:18 +01:00
f321x
0f314d1dd9 lnpeer/lnworker: refactor htlc_switch
refactor `htlc_switch` to new architecture to make it more robust
against partial settlement of htlc sets and increase maintainability.
Htlcs are now processed in two steps, first the htlcs are collected into
sets from the channels, and potentially failed on their own already.
Then a second loop iterates over the htlc sets and finalizes only on
whole sets.

# Conflicts:
#	electrum/lnpeer.py
2025-11-27 17:57:14 +01:00
f321x
3d0ba33652 swaps: followup 10303
small followup replacing tx height integers with const variables and
considering claim tx broadcast too if there is an unconfirmed parent
(height -1).
2025-11-27 17:44:49 +01:00
f321x
41d391a617 Fix: For inner trampoline onions amt_to_forward can be larger than the htlc amount
Add unittest to TestPeerForwarding which sends a multi trampoline
payment.

Wait another htlc_switch iteration in tests because trampolines might have different delays
2025-11-27 17:44:31 +01:00
SomberNight
bc2bd48516 qml: (trivial) QEConfig.formatMilliSats: conv unused fallback to assert 2025-11-27 16:14:52 +00:00
ghost43
8358a17ebb Merge pull request #10325 from f321x/debug_not_enough_balance
lightning: fix race when doing concurrent payments
2025-11-27 16:06:52 +00:00
ghost43
2c46cf0ebd Merge pull request #10321 from accumulator/qml_msat_precision
qml millisat precision fix
2025-11-27 15:46:34 +00:00
f321x
196cc33c1c ln: fix race when doing concurrent ln payments
There is a race when initiating multiple lightning payments concurrently
(e.g. when doing a reverse swap with prepayment + swap payment).
suggest_splits might overallocate
split amounts for a channel as the splitting of both invoice amounts runs
concurrently and before acutal htlcs that reduce the channels balance
have been added to the channel yet. This results in a "not
enough balance" PaymentFailure once we try to send the htlcs and the
other payment attempt already reduced the available balance of the
channel.

This fix takes a lock from splitting the amount until the htlcs are
put on the channel, so suggest_splits always acts on the correct channel
balance.
2025-11-27 16:43:40 +01:00