Skip to content

lq: Add taproot channel support for elements #8097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

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 from eb9a691 to 5ba3c38 Compare May 5, 2025 17:15
cdecker added 4 commits May 6, 2025 09:49
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.
@cdecker cdecker force-pushed the 202448-elements-anchors branch from 5ba3c38 to 1557918 Compare May 6, 2025 07:50
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.

1 participant