From f56e1cafac6e652550e7df0dbb23026b68eb1ccc Mon Sep 17 00:00:00 2001 From: f321x Date: Tue, 3 Feb 2026 12:26:04 +0100 Subject: [PATCH] lnworker: stop setting static jit alias for jit channel ...so we can have multiple just in time channels with the same lsp. We already save a remote scid alias in `on_channel_ready` which we already have received after the new zeroconf channel is in open state. So setting the alias to the static node id hash is counterproductive because it doesn't allow to differentiate between channels. Also extends the regtest (`just_in_time`) to do a second channel opening, to cover this scenario. This doesn't add much runtime to the test, so the cost seems reasonable. --- electrum/lnworker.py | 3 +-- tests/regtest/regtest.sh | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 8e39e7889..5bc933a4b 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -1511,8 +1511,7 @@ class LNWallet(Logger): while not next_chan.is_open(): await asyncio.sleep(1) await util.wait_for2(wait_for_channel(), LN_P2P_NETWORK_TIMEOUT) - next_chan.save_remote_scid_alias(self._scid_alias_of_node(next_peer.pubkey)) - self.logger.info(f'JIT channel is open') + self.logger.info(f'JIT channel is open (will forward htlc and await preimage now)') next_amount_msat_htlc -= channel_opening_fee # fixme: some checks are missing htlc = next_peer.send_htlc( diff --git a/tests/regtest/regtest.sh b/tests/regtest/regtest.sh index e51af808c..f9f19751c 100755 --- a/tests/regtest/regtest.sh +++ b/tests/regtest/regtest.sh @@ -779,10 +779,24 @@ if [[ $1 == "just_in_time" ]]; then echo "carol pays alice" # note: set amount to 0.001 to test failure: 'payment too low' invoice=$($alice add_request 0.01 --lightning --memo "invoice" | jq -r ".lightning_invoice") - success=$($carol lnpay $invoice| jq '.success') - if [[ $success != "true" ]]; then - echo "JIT payment failed" - exit 1 + success=$($carol lnpay $invoice | jq -r ".success") + if [[ "$success" != "true" ]]; then + echo "jit payment failed" + exit 1 + fi + # try again, multiple jit openings should work without issues + new_blocks 3 + echo "carol pays alice again" + invoice=$($alice add_request 0.04 --lightning --memo "invoice2" | jq -r ".lightning_invoice") + success=$($carol lnpay $invoice | jq -r ".success") + if [[ "$success" != "true" ]]; then + echo "jit payment failed" + exit 1 + fi + alice_chan_count=$($alice list_channels | jq '. | length') + if [[ "$alice_chan_count" != "2" ]]; then + echo "alice should have two jit channels" + exit 1 fi fi