lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.65k stars 2.07k forks source link

SignPsbt fails to add partial signature when P2TR output is being spent in a funded PSBT #6579

Closed alexbosworth closed 2 years ago

alexbosworth commented 2 years ago

Background

Given a funded PSBT using FundPsbt, the resulting funded PSBT should be able to be signed with SignPsbt but there is no signature being added in the result of SignPsbt when an input is a P2TR input like there is when an input is a P2WPKH.

Your environment

Steps to reproduce

Also do the same thing, but where the input is a P2WPKH

Expected behavior

Both the P2TR signing and the P2WPKH signing should result in a partially signed PSBT

Actual behavior

For the P2TR funded PSBT the output of SignPsbt will be equal to the output of FundPbst, meaning it is not partially signed

For the P2WPKH funded PSBT it will include a partial signature as expected

Roasbeef commented 2 years ago

I think I spotted the issue, when we sign we skip if the bip32 derivation info isn't present: https://github.com/lightningnetwork/lnd/blob/master/lnwallet/btcwallet/psbt.go#L132-L136

However, when we fund w/ a P2TR input, we only place the new taproot specific info: https://github.com/btcsuite/btcwallet/blob/af5562928b707e0b56c1e44052ece3205bb66552/wallet/psbt.go#L273-L288

The itests we have also always put both and old and new information: https://github.com/lightningnetwork/lnd/blob/7106ea59db9ade78d65bb46605f94637900c0e3f/lntest/itest/lnd_psbt_test.go#L769-L776

Roasbeef commented 2 years ago

If this is correct, then we need to fix this on the btcwallet side, then update the lnd dep.