btcsuite / btcd

An alternative full node bitcoin implementation written in Go (golang)
https://github.com/btcsuite/btcd/blob/master/README.md
ISC License
6.1k stars 2.31k forks source link

docs: add documentation for signing/creating PSBT packets #1988

Open ripoff2 opened 1 year ago

ripoff2 commented 1 year ago

Hi, thank you for your work. Due to the lack of examples, I have a question, how can I add FinalScriptWitness to PSBT? The thing is, I have two base64 encoded PSBT: signed and unsinged. The only difference in them is that the one signed by the wallet (manually) has a FinalScriptWitness parameter. However, I have not been able to reproduce it. It is also worth noting that the signature was made with a Taproot address.

guggero commented 1 year ago

Per definition, the "unsigned TX" within the PSBT will never contain a scriptSig or a witness. So if you sign a PSBT, instead of putting the witness stack into the "witness" field of the TX input, you add it to the FinalScriptWitness field of the PSBT input.

There are examples in the lnd code base. See SignPsbt and its integration tests.

ripoff2 commented 1 year ago

@guggero thanks a lot!

guggero commented 1 year ago

You're welcome. Did that help you answer your question and we can close the issue? Or do you see this as a feature request issue to add more documentation to the PSBT package?

ripoff2 commented 1 year ago

@guggero sry I forgot to make a reply. I've solve my issue, ty for providing info about lnd codebase - rly helpful!