-
Notifications
You must be signed in to change notification settings - Fork 906
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
hsmd crash when signing psbt #5499
Comments
We call `tal_wally_start` and then `tal_wally_start` again in `type_to_string` for psbt. end the last tal before calling type to string. Fixes: ElementsProject#5499 Reported-By: @fiatjaf lightning_hsmd: FATAL SIGNAL 6 (version v0.11.0.1-231-gddf8fbd-modded) 0x5574ca0d87ef send_backtrace common/daemon.c:33 0x5574ca0d8877 crashdump common/daemon.c:46 0x7f76ef63e8df ??? ???:0 0x7f76ef68e36c ??? ???:0 0x7f76ef63e837 ??? ???:0 0x7f76ef628534 ??? ???:0 0x5574ca0df55e tal_wally_start common/utils.c:27 0x5574ca0e4024 psbt_to_b64 bitcoin/psbt.c:687 0x5574ca0e4093 fmt_wally_psbt_ bitcoin/psbt.c:694 0x5574ca0df4b9 type_to_string_ common/type_to_string.c:32 0x5574ca0d5139 sign_our_inputs hsmd/libhsmd.c:486 0x5574ca0d5206 handle_sign_withdrawal_tx hsmd/libhsmd.c:1029 0x5574ca0d63c4 hsmd_handle_client_message hsmd/libhsmd.c:1575 0x5574ca0ce763 handle_client hsmd/hsmd.c:671 0x5574ca100032 next_plan ccan/ccan/io/io.c:59 0x5574ca1004b9 do_plan ccan/ccan/io/io.c:407 0x5574ca100552 io_ready ccan/ccan/io/io.c:417 0x5574ca101daf io_loop ccan/ccan/io/poll.c:453 0x5574ca0ceb7b main hsmd/hsmd.c:739 0x7f76ef62928f ??? ???:0 0x7f76ef629349 ??? ???:0 0x5574ca0cda04 ??? ../sysdeps/x86_64/start.S:115
Let's not crash if our PSBT is borked (no outputs). If you attempt to sign a PSBT that's invalid, we'll crash. Fixes: ElementsProject#5499
Partial fix: #5506 |
After applying the fix above, using the following psbt:
(This time the first input is not finalized, although it has the signature already.) I get:
|
Now this one has the first input finalized:
And the crash is the same? I don't know:
|
How to reproduce:
|
The crash is the same b/c we react the same way to a PSBT that's in some slightly "incorrect" state (call fatal).
Trying to sign this fails because it's missing the utxo information for the second input that you're asking CLN to sign for, there's no Ultimately, all these are the same underlying issue: the PSBT you're asking to sign is in a state that libwally doesn't like. (and we call On our end, the correct thing to do would be to return a nice error telling you what the problem with your PSBT is, not crashing. This doesn't really solve your problem tho (wanting to get a signed PSBT). What you really want is the bitcoind equivalent of
|
We call `tal_wally_start` and then `tal_wally_start` again in `type_to_string` for psbt. end the last tal before calling type to string. Fixes: ElementsProject#5499 Reported-By: @fiatjaf lightning_hsmd: FATAL SIGNAL 6 (version v0.11.0.1-231-gddf8fbd-modded) 0x5574ca0d87ef send_backtrace common/daemon.c:33 0x5574ca0d8877 crashdump common/daemon.c:46 0x7f76ef63e8df ??? ???:0 0x7f76ef68e36c ??? ???:0 0x7f76ef63e837 ??? ???:0 0x7f76ef628534 ??? ???:0 0x5574ca0df55e tal_wally_start common/utils.c:27 0x5574ca0e4024 psbt_to_b64 bitcoin/psbt.c:687 0x5574ca0e4093 fmt_wally_psbt_ bitcoin/psbt.c:694 0x5574ca0df4b9 type_to_string_ common/type_to_string.c:32 0x5574ca0d5139 sign_our_inputs hsmd/libhsmd.c:486 0x5574ca0d5206 handle_sign_withdrawal_tx hsmd/libhsmd.c:1029 0x5574ca0d63c4 hsmd_handle_client_message hsmd/libhsmd.c:1575 0x5574ca0ce763 handle_client hsmd/hsmd.c:671 0x5574ca100032 next_plan ccan/ccan/io/io.c:59 0x5574ca1004b9 do_plan ccan/ccan/io/io.c:407 0x5574ca100552 io_ready ccan/ccan/io/io.c:417 0x5574ca101daf io_loop ccan/ccan/io/poll.c:453 0x5574ca0ceb7b main hsmd/hsmd.c:739 0x7f76ef62928f ??? ???:0 0x7f76ef629349 ??? ???:0 0x5574ca0cda04 ??? ../sysdeps/x86_64/start.S:115
If you build a PSBT externally from CLN and attempt to sign for the output, we would crash. Now we don't crash. Changelog-Changed: JSON-RPC: `signpsbt` will now add redeemscript + witness-utxo to the PSBT for an input that we can sign for, before signing it. Fixes ElementsProject#5499 ?
Ok, since the proposed fix for this is pretty not fun (needing bitcoin-cli? having to call #5506 has been updated to do this now, can you check that it works with the plugin you're building? Note that it'll still crash if you attempt to sign a PSBT that it doesn't like for any other reason. |
Yes, it worked now! Thank you, that improves my life a lot, although if only I knew more about psbts none of these problems would have happened because I would have known I had to provide the utxo. |
If you build a PSBT externally from CLN and attempt to sign for the output, we would crash. Now we don't crash. Changelog-Changed: JSON-RPC: `signpsbt` will now add redeemscript + witness-utxo to the PSBT for an input that we can sign for, before signing it. Fixes #5499 ?
We call `tal_wally_start` and then `tal_wally_start` again in `type_to_string` for psbt. end the last tal before calling type to string. Fixes: ElementsProject#5499 Reported-By: @fiatjaf lightning_hsmd: FATAL SIGNAL 6 (version v0.11.0.1-231-gddf8fbd-modded) 0x5574ca0d87ef send_backtrace common/daemon.c:33 0x5574ca0d8877 crashdump common/daemon.c:46 0x7f76ef63e8df ??? ???:0 0x7f76ef68e36c ??? ???:0 0x7f76ef63e837 ??? ???:0 0x7f76ef628534 ??? ???:0 0x5574ca0df55e tal_wally_start common/utils.c:27 0x5574ca0e4024 psbt_to_b64 bitcoin/psbt.c:687 0x5574ca0e4093 fmt_wally_psbt_ bitcoin/psbt.c:694 0x5574ca0df4b9 type_to_string_ common/type_to_string.c:32 0x5574ca0d5139 sign_our_inputs hsmd/libhsmd.c:486 0x5574ca0d5206 handle_sign_withdrawal_tx hsmd/libhsmd.c:1029 0x5574ca0d63c4 hsmd_handle_client_message hsmd/libhsmd.c:1575 0x5574ca0ce763 handle_client hsmd/hsmd.c:671 0x5574ca100032 next_plan ccan/ccan/io/io.c:59 0x5574ca1004b9 do_plan ccan/ccan/io/io.c:407 0x5574ca100552 io_ready ccan/ccan/io/io.c:417 0x5574ca101daf io_loop ccan/ccan/io/poll.c:453 0x5574ca0ceb7b main hsmd/hsmd.c:739 0x7f76ef62928f ??? ???:0 0x7f76ef629349 ??? ???:0 0x5574ca0cda04 ??? ../sysdeps/x86_64/start.S:115
We call `tal_wally_start` and then `tal_wally_start` again in `type_to_string` for psbt. end the last tal before calling type to string. Fixes: ElementsProject#5499 Reported-By: @fiatjaf lightning_hsmd: FATAL SIGNAL 6 (version v0.11.0.1-231-gddf8fbd-modded) 0x5574ca0d87ef send_backtrace common/daemon.c:33 0x5574ca0d8877 crashdump common/daemon.c:46 0x7f76ef63e8df ??? ???:0 0x7f76ef68e36c ??? ???:0 0x7f76ef63e837 ??? ???:0 0x7f76ef628534 ??? ???:0 0x5574ca0df55e tal_wally_start common/utils.c:27 0x5574ca0e4024 psbt_to_b64 bitcoin/psbt.c:687 0x5574ca0e4093 fmt_wally_psbt_ bitcoin/psbt.c:694 0x5574ca0df4b9 type_to_string_ common/type_to_string.c:32 0x5574ca0d5139 sign_our_inputs hsmd/libhsmd.c:486 0x5574ca0d5206 handle_sign_withdrawal_tx hsmd/libhsmd.c:1029 0x5574ca0d63c4 hsmd_handle_client_message hsmd/libhsmd.c:1575 0x5574ca0ce763 handle_client hsmd/hsmd.c:671 0x5574ca100032 next_plan ccan/ccan/io/io.c:59 0x5574ca1004b9 do_plan ccan/ccan/io/io.c:407 0x5574ca100552 io_ready ccan/ccan/io/io.c:417 0x5574ca101daf io_loop ccan/ccan/io/poll.c:453 0x5574ca0ceb7b main hsmd/hsmd.c:739 0x7f76ef62928f ??? ???:0 0x7f76ef629349 ??? ???:0 0x5574ca0cda04 ??? ../sysdeps/x86_64/start.S:115
We call `tal_wally_start` and then `tal_wally_start` again in `type_to_string` for psbt. end the last tal before calling type to string. Fixes: ElementsProject#5499 Reported-By: @fiatjaf lightning_hsmd: FATAL SIGNAL 6 (version v0.11.0.1-231-gddf8fbd-modded) 0x5574ca0d87ef send_backtrace common/daemon.c:33 0x5574ca0d8877 crashdump common/daemon.c:46 0x7f76ef63e8df ??? ???:0 0x7f76ef68e36c ??? ???:0 0x7f76ef63e837 ??? ???:0 0x7f76ef628534 ??? ???:0 0x5574ca0df55e tal_wally_start common/utils.c:27 0x5574ca0e4024 psbt_to_b64 bitcoin/psbt.c:687 0x5574ca0e4093 fmt_wally_psbt_ bitcoin/psbt.c:694 0x5574ca0df4b9 type_to_string_ common/type_to_string.c:32 0x5574ca0d5139 sign_our_inputs hsmd/libhsmd.c:486 0x5574ca0d5206 handle_sign_withdrawal_tx hsmd/libhsmd.c:1029 0x5574ca0d63c4 hsmd_handle_client_message hsmd/libhsmd.c:1575 0x5574ca0ce763 handle_client hsmd/hsmd.c:671 0x5574ca100032 next_plan ccan/ccan/io/io.c:59 0x5574ca1004b9 do_plan ccan/ccan/io/io.c:407 0x5574ca100552 io_ready ccan/ccan/io/io.c:417 0x5574ca101daf io_loop ccan/ccan/io/poll.c:453 0x5574ca0ceb7b main hsmd/hsmd.c:739 0x7f76ef62928f ??? ???:0 0x7f76ef629349 ??? ???:0 0x5574ca0cda04 ??? ../sysdeps/x86_64/start.S:115
We call `tal_wally_start` and then `tal_wally_start` again in `type_to_string` for psbt. end the last tal before calling type to string. Fixes: ElementsProject#5499 Reported-By: @fiatjaf lightning_hsmd: FATAL SIGNAL 6 (version v0.11.0.1-231-gddf8fbd-modded) 0x5574ca0d87ef send_backtrace common/daemon.c:33 0x5574ca0d8877 crashdump common/daemon.c:46 0x7f76ef63e8df ??? ???:0 0x7f76ef68e36c ??? ???:0 0x7f76ef63e837 ??? ???:0 0x7f76ef628534 ??? ???:0 0x5574ca0df55e tal_wally_start common/utils.c:27 0x5574ca0e4024 psbt_to_b64 bitcoin/psbt.c:687 0x5574ca0e4093 fmt_wally_psbt_ bitcoin/psbt.c:694 0x5574ca0df4b9 type_to_string_ common/type_to_string.c:32 0x5574ca0d5139 sign_our_inputs hsmd/libhsmd.c:486 0x5574ca0d5206 handle_sign_withdrawal_tx hsmd/libhsmd.c:1029 0x5574ca0d63c4 hsmd_handle_client_message hsmd/libhsmd.c:1575 0x5574ca0ce763 handle_client hsmd/hsmd.c:671 0x5574ca100032 next_plan ccan/ccan/io/io.c:59 0x5574ca1004b9 do_plan ccan/ccan/io/io.c:407 0x5574ca100552 io_ready ccan/ccan/io/io.c:417 0x5574ca101daf io_loop ccan/ccan/io/poll.c:453 0x5574ca0ceb7b main hsmd/hsmd.c:739 0x7f76ef62928f ??? ???:0 0x7f76ef629349 ??? ???:0 0x5574ca0cda04 ??? ../sysdeps/x86_64/start.S:115
If you build a PSBT externally from CLN and attempt to sign for the output, we would crash. Now we don't crash. Changelog-Changed: JSON-RPC: `signpsbt` will now add redeemscript + witness-utxo to the PSBT for an input that we can sign for, before signing it. Fixes ElementsProject#5499 ?
We call `tal_wally_start` and then `tal_wally_start` again in `type_to_string` for psbt. end the last tal before calling type to string. Fixes: ElementsProject#5499 Reported-By: @fiatjaf lightning_hsmd: FATAL SIGNAL 6 (version v0.11.0.1-231-gddf8fbd-modded) 0x5574ca0d87ef send_backtrace common/daemon.c:33 0x5574ca0d8877 crashdump common/daemon.c:46 0x7f76ef63e8df ??? ???:0 0x7f76ef68e36c ??? ???:0 0x7f76ef63e837 ??? ???:0 0x7f76ef628534 ??? ???:0 0x5574ca0df55e tal_wally_start common/utils.c:27 0x5574ca0e4024 psbt_to_b64 bitcoin/psbt.c:687 0x5574ca0e4093 fmt_wally_psbt_ bitcoin/psbt.c:694 0x5574ca0df4b9 type_to_string_ common/type_to_string.c:32 0x5574ca0d5139 sign_our_inputs hsmd/libhsmd.c:486 0x5574ca0d5206 handle_sign_withdrawal_tx hsmd/libhsmd.c:1029 0x5574ca0d63c4 hsmd_handle_client_message hsmd/libhsmd.c:1575 0x5574ca0ce763 handle_client hsmd/hsmd.c:671 0x5574ca100032 next_plan ccan/ccan/io/io.c:59 0x5574ca1004b9 do_plan ccan/ccan/io/io.c:407 0x5574ca100552 io_ready ccan/ccan/io/io.c:417 0x5574ca101daf io_loop ccan/ccan/io/poll.c:453 0x5574ca0ceb7b main hsmd/hsmd.c:739 0x7f76ef62928f ??? ???:0 0x7f76ef629349 ??? ???:0 0x5574ca0cda04 ??? ../sysdeps/x86_64/start.S:115
If you build a PSBT externally from CLN and attempt to sign for the output, we would crash. Now we don't crash. Changelog-Changed: JSON-RPC: `signpsbt` will now add redeemscript + witness-utxo to the PSBT for an input that we can sign for, before signing it. Fixes ElementsProject#5499 ?
Issue and Steps to Reproduce
lightningd
crashes withWhat I did was:
lightningd
according tolistfunds
):cHNidP8BAHsCAAAAAg58E5nVxhCzXVWa/G6NiJFef004SM+xoEsxSLhwSzOtAAAAAAABAAAA1zPMkjE1xjLC1PIL4tqr6Es1Tvf/57OEhrUtKjqND+QAA AAAAAAAAAB4gIAAAAAAAAWABSB/6fHdOptg0U8kKiAAgDjBTEmawAAAAAAAAAA
reserveinputs
with the psbtsignpsbt
with the psbtThe text was updated successfully, but these errors were encountered: