Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Frodek on January 29, 2019, 10:03:26 AM



Title: Output witness scripthash but input keyhash?
Post by: Frodek on January 29, 2019, 10:03:26 AM
Is
https://www.blockchain.com/btc/tx/49de9ea077feee38d4952023fbe9cbdbb9020675667c9637ea0f1a456cc40030 (https://www.blockchain.com/btc/tx/49de9ea077feee38d4952023fbe9cbdbb9020675667c9637ea0f1a456cc40030)

https://blockchair.com/bitcoin/transaction/49de9ea077feee38d4952023fbe9cbdbb9020675667c9637ea0f1a456cc40030 (https://blockchair.com/bitcoin/transaction/49de9ea077feee38d4952023fbe9cbdbb9020675667c9637ea0f1a456cc40030)

blockchair.com say that is witness_v0_keyhash. and witnessStack has height only two :

http://chainquery.com/bitcoin-api/getrawtransaction/49de9ea077feee38d4952023fbe9cbdbb9020675667c9637ea0f1a456cc40030/1 (http://chainquery.com/bitcoin-api/getrawtransaction/49de9ea077feee38d4952023fbe9cbdbb9020675667c9637ea0f1a456cc40030/1)

"txinwitness": [                  "30450221009c081fce7e263de3c8a0b0b12b18b6338cb2db4fc2f37ce3d22ec4ad618d611002205 21e0fbabb810593ef6878169e0d1020e69b167b9bbf54915b44e92c5b55ab7301",
                    "210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ac"
                ],

But previous was scripthash and address is long (62, not 42) like scripthash
bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3   


Title: Re: Output witness scripthash but input keyhash?
Post by: Coding Enthusiast on January 29, 2019, 02:15:34 PM
Previous outputs which this transaction is spending weren't "scripthash", they were Pay To Witness Pubkey Hash[1]. That is why the signature (or more precisely the scriptsig) is "transferred" elsewhere in a field called "witness" instead of it being in its usual place after the outpoint.

[1] https://bitcoin.stackexchange.com/questions/64733/what-is-p2pk-p2pkh-p2sh-p2wpkh-eli5

"txinwitness": [                  "30450221009c081fce7e263de3c8a0b0b12b18b6338cb2db4fc2f37ce3d22ec4ad618d611002205 21e0fbabb810593ef6878169e0d1020e69b167b9bbf54915b44e92c5b55ab7301",
                    "210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ac"
                ],

This is your scriptsig.
30 <-Sequence tag of DER
45 <-DER length
02 <-Int tag of DER
21 <-DER Length
009c081fce7e263de3c8a0b0b12b18b6338cb2db4fc2f37ce3d22ec4ad618d6110 <-x coordinate of R
02 <-Int tag of DER
20 <-DER Length
521e0fbabb810593ef6878169e0d1020e69b167b9bbf54915b44e92c5b55ab73 <-s
01 <-SigHashType
21 <-OP_PushData
0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ac <-compressed public key

(there are some CompactInt sizes among these numbers that the JSON serialization has omitted though)