Skip to content

Conversation

@cdecker
Copy link
Member

@cdecker cdecker commented Feb 18, 2025

libwally did not support signing taproot outputs until
recently. This means that on elements-based networks we would
default to the legacy non-taproot channels.

Since libwally recently gained support for signing taproot outputs
we can remove support for legacy channels altogether now. This is also
a requirement to work with the VLS signer, which no longer supports
legacy channels either.

Depends-On: #8098 #8158

@cdecker cdecker force-pushed the 202448-elements-anchors branch 2 times, most recently from d26af91 to eb9a691 Compare March 20, 2025 13:06
@cdecker
Copy link
Member Author

cdecker commented Mar 26, 2025

Following the upgrade of libwally we now have the vast majority of tests passing, with the exception of a few. There is even a crash, in which the hsmd is refusing to sign an htlc_tx_mingle transaction, potentially due to one of the inputs spent being a taproot output.

My current status is the following:

  • I'm testing test_htlc_in_timeout, which exercises the crash
  • Building and testing is done via TEST_NETWORK=liquid-regtest poetry run ./configure && poetry run make && poetry run pytest tests -sk test_htlc_in_timeout.
  • Attaching gdb to the lightning-2 hsmd:
 gdb -ex "attach $(pstree -p $(pgrep -f lightning-2) | grep lightning_hsmd | grep -oE '[0-9]+')"
  • Then breaking at the message in question b handle_sign_htlc_tx_mingle

I found the following so far:

  • The call to wally_psbt_sign here fails for input 1, which matches utxo[0] that is passed along. close_info on the utxo is NULL, which isn't surprising as it is not a close.
  • The output being spent is a taproot output, so either we're spending via keypath, or we're missing some information hidden in the taptree.
  • The entire calltree ends in wally_psbt_get_input_signature_hash on this input 1
  • The last message lightningd emits is: We want to bump HTLC fee more, but ran out of funds!

Backtrace:

#0  wally_psbt_get_input_signature_hash (psbt=0x561dba6b9308, index=1, tx=0x561dba6b6608,
    script=0x561dba6bba58 "Q \336y\227%\037Uf\375\060\247\321\354\270Q\205UKQd\303b\037|>\r\332\034\351\233zY`\033\314!\273t²1K\002\020=\227\243\061", script_len=34, flags=0, bytes_out=0x7ffd1879f440 "_\365y\030\375\177", len=32)
    at ../../../libwally-core/src/psbt.c:4582
#1  0x0000561dae3f06e6 in wally_psbt_sign_bip32 (psbt=0x561dba6b9308, hdkey=0x7ffd1879f4e0, flags=20) at ../../../libwally-core/src/psbt.c:4775
#2  0x0000561dae3f07ef in wally_psbt_sign (psbt=0x561dba6b9308, priv_key=0x7ffd1879f630 "r\203/\006\237\331n\330\337o\246\236'mc\315\025\210", priv_key_len=32, flags=4) at ../../../libwally-core/src/psbt.c:4801
#3  0x0000561dae3ac894 in sign_our_inputs (utxos=0x561dba6be448, psbt=0x561dba6b9308) at hsmd/libhsmd.c:593
#4  0x0000561dae3abefe in handle_sign_htlc_tx_mingle (c=c@entry=0x561dba6b54d8, msg_in=msg_in@entry=0x561dba6bc358 "") at hsmd/libhsmd.c:1757
#5  0x0000561dae3a90fa in hsmd_handle_client_message (ctx=<optimized out>, client=0x561dba6b54d8, msg=0x561dba6bc358 "") at hsmd/libhsmd.c:2223
#6  0x0000561dae39e2da in handle_client (conn=0x561dba6b4e28, c=0x561dba6b4ba8) at hsmd/hsmd.c:719
#7  0x0000561dae480fbd in next_plan (conn=0x561dba6b4e28, plan=0x561dba6b4e48) at ccan/ccan/io/io.c:60
#8  do_plan (conn=conn@entry=0x561dba6b4e28, plan=plan@entry=0x561dba6b4e48, idle_on_epipe=false) at ccan/ccan/io/io.c:422
#9  0x0000561dae480ebd in io_ready (conn=conn@entry=0x561dba6b4e28, pollflags=1) at ccan/ccan/io/io.c:439
#10 0x0000561dae482742 in io_loop (timers=timers@entry=0x0, expired=expired@entry=0x0) at ccan/ccan/io/poll.c:455
#11 0x0000561dae39dfe3 in main (argc=3, argv=0x7ffd1879f988) at hsmd/hsmd.c:801

@cdecker cdecker force-pushed the 202448-elements-anchors branch 2 times, most recently from 5ba3c38 to 1557918 Compare May 6, 2025 07:50
cdecker added 5 commits July 3, 2025 14:40
Changelog-Changed: liquid: Added support for anchor outputs for liquid channels
The fee output is mandatory in `elements`-based chains, for the
homomorphic amount commitment to work out. These transactions were
missing that output.
Needed for zero-fee anchor outputs
@cdecker cdecker force-pushed the 202448-elements-anchors branch from 4085771 to bd5ae34 Compare July 3, 2025 13:13
@cdecker
Copy link
Member Author

cdecker commented Jul 3, 2025

Ok, pushing the latest version, so we can collaborate on this a bit.

Currently the following failures are still to address:

  • Potential failure to recognize owned funds: lightning_hsmd: Received wally_err attempting to sign input 1 with key 02ca4a6b6013115cdb3c3a59a6472399eb7dbc62210bd4fba4ee72c6fa6105fbd4

@cdecker
Copy link
Member Author

cdecker commented Jul 3, 2025

Just had another run of the tests:

= 13 failed, 655 passed, 181 skipped, 1 xfailed, 8 warnings, 5 errors in 3594.79s (0:59:54) =

With failures on:

FAILED tests/test_closing.py::test_onchain_different_fees - ValueError: Timeo...
FAILED tests/test_closing.py::test_close_weight_estimate - assert 877 == 701
FAILED tests/test_connection.py::test_update_fee_reconnect - ValueError: Time...
FAILED tests/test_closing.py::test_closing_simple - AssertionError: assert ['...
FAILED tests/test_closing.py::test_onchain_multihtlc_their_unilateral - Conne...
FAILED tests/test_closing.py::test_onchain_multihtlc_our_unilateral - Connect...
FAILED tests/test_closing.py::test_close_feerate_range - TimeoutError: Unable...
FAILED tests/test_misc.py::test_htlc_in_timeout - TimeoutError: Unable to fin...
FAILED tests/test_reckless.py::test_local_dir_install - assert 1 == 0
FAILED tests/test_reckless.py::test_disable_enable - assert 1 == 0
FAILED tests/test_reckless.py::test_tag_install - assert 1 == 0
FAILED tests/test_reckless.py::test_install - assert 1 == 0
FAILED tests/test_xpay.py::test_fail_after_success[True] - TimeoutError: Unab...
ERROR tests/test_cln_rs.py
ERROR tests/test_closing.py::test_onchain_multihtlc_their_unilateral - ValueE...
ERROR tests/test_closing.py::test_onchain_multihtlc_our_unilateral - ValueErr...
ERROR tests/test_misc.py::test_htlc_in_timeout - ValueError: 
ERROR tests/test_xpay.py::test_fail_after_success[True] - ValueError: 

Plus of course the couple of tests, I disabled in 931a079 for expediency.

@rustyrussell rustyrussell modified the milestones: v25.09, v25.12 Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants