I have a question for ChatGPT:
I made an unsigned PSBT file (P2WPKH) using a watch wallet. Then, I signed that file offline and brought it back into my watch wallet. After that, I was able to broadcast the transaction, and it got added to the blockchain. But when I checked the signed PSBT file, I only see "final_scriptwitness" as an extra value, and there’s no clear signature. Why is that?
Is ChatGPT's response accurate? (Inquiry about P2WPKH)
6 replies 246 views
gr3g.0rbitHero Member
Posts: 1025 · Reputation: 2646
#2Oct 14, 2022, 10:57 PM
That is actually good and direct answer. (probably because "PSBT" is relatively new)
The key concepts can be nitpicked or expanded here and there but the general explanation is on point.
For actual example, here's the mentioned part of a testnet4 transaction's decoded PSBT:
(transaction: 3a59bb3faabe232f62d8a67d60b5930e876ac26186565e7099c0b65b9bcff66a)
Input part of "getrawtransaction 3a59bb3faabe232f62d8a67d60b5930e876ac26186565e7099c0b65b9bcff66a 1" result:
(as you can see, there's no scrptSig, the above is under "txinwitness")
Thank you for your assessment. Is it possible to decode txinwitness even further? So the first value:
gr3g.0rbitHero Member
Posts: 1025 · Reputation: 2646
#4Oct 16, 2022, 04:13 PM
If you mean a command to decode it, AFAIK there's none but that's the signature followed by the sighash flag "0x01" so it's basically the actual data that it represents.
The DER-encoded signature:
And the SigHash type:
The signature can be further sorted-out to get the R and S values, refer to BIP66: (https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki#der-encoding-reference)
Many thanks for the reference. I am trying to understand this as a whole and also came across this page:
https://learnmeabitcoin.com/technical/script/p2wpkh/
I hope the explanations there are correct.
I think my difficulties in understanding are due to the fact that I have not yet understood the classic P2PKH procedure in detail. So I still need to study it myself.
One question that is bothering me: What exactly is signed with the P2WPKH procedure? I sign on my offline wallet with the private key material. But what is the input for a signature?
Or to put it another way: How does the Core Client check the correctness of the signature? To which data does the core client (or another Bitcoin programme) apply the coresponding pubkey?
gr3g.0rbitHero Member
Posts: 1025 · Reputation: 2646
#6Oct 19, 2022, 10:58 PM
That website is legit, it's maintained by a former Bitcoin developer.
As for the signed data, it's the "message hash" (aka Z-value) which is the hash of the unsigned transaction with stripped parts depending on the "sighash type".
On that website, the whole process from unsigned raw transaction to signed raw transaction is explained here:
https://learnmeabitcoin.com/technical/keys/signature/#legacy-algorithm (example is for the commonly used "sighash_all")
Sighash type is explained just below that page.
I don't have a sendable Merrit at the moment, but thank you very much.
Related topics
- Curious about recovering BTC from 2010/2011 7
- What Should I Know About Multisig Wallets? 13
- bitcoin-qt sync issues and slow speeds 6
- Recovering a Bitcoin wallet and address 8
- Creating a list of non-zero wallets and their balances using Python 4
- CipherSeed: A Comprehensive Guide to Super-Secure Crypto Wallet Backups 5