Title: finding TxHash to verify a Tx Post by: redPanda on May 08, 2015, 04:04:36 PM In order to verify a transaction, I want to make sure that I have the correct value
for the double hash of the TxCopy (the transaction hash used to sign and verify a transaction). I used http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html for the final transaction and https://en.bitcoin.it/w/images/en/7/70/Bitcoin_OpCheckSig_InDetail.png" to find TxCopy from finalTx. from finalTx: There is just 1 input: prevOutputHashReverse = 484d40d45b9ea0d652fca8258ab7caa42541eb52975857f96fb50cd732c8b481 prevOutputHash = 81b4c832d70cb56ff957589752eb4125a4cab78a25a8fc52d6a09e5bd4404d48 prevOutputIndex = 00000000 from prevOutputHash and prevOutputIndex, I can get the prevOutput: prevOutput = 728b0100000000001976a914df3bd30160e6c6145baaf2c88a8844c13a00d1d588ac from prevOutput, I get prevOutputScriptPubKey = 76a914df3bd30160e6c6145baaf2c88a8844c13a00d1d588ac now I can construct the txCopy this only differences with finalTx are steps e, f and k NOTE: in https://en.bitcoin.it/w/images/en/7/70/Bitcoin_OpCheckSig_InDetail.png step 2, there is an instruction: "if no OP_CS, simply copy PKScript" (=prevOutputScriptPubKey) I don't know what to do with those OP_CODE_SEPARATOR ! Should I copy PKScript or not? What SCRIPT_PART4 should be? If I copy PKScript, does it mean SCRIPT_PART4 = PKScript? If yes: step e below becomes 32 and step f becomes (PKScript | PKScript) = 76a914df3bd30160e6c6145baaf2c88a8844c13a00d1d588ac76a914df3bd30160e6c6145baaf2c 88a8844c13a00d1d588ac with SCRIPT_PART4 empty: a) version = 01000000 b) input count = 01 c) prevOutputHashReverse = 484d40d45b9ea0d652fca8258ab7caa42541eb52975857f96fb50cd732c8b481 d) preOutputIndex = 00000000 e) prevOutputScriptPubKeyLength = 19 f) prevOutputScriptPubKey = 76a914df3bd30160e6c6145baaf2c88a8844c13a00d1d588ac g) sequence = ffffffff h) outputCount = 01 i) output00 = 62640100000000001976a914c8e90996c7c6080ee06284600c684ed904d14c5c88ac j) lockTime = 00000000 k) hashTypeCode = 01000000 (little-endian) txCopy = 0100000001484d40d45b9ea0d652fca8258ab7caa42541eb52975857f96fb50cd732c8b48100000 0001976a914df3bd30160e6c6145baaf2c88a8844c13a00d1d588ac ffffffff0162640100000000001976a914c8e90996c7c6080ee06284600c684ed904d14c5c88ac0 000000001000000 SHA256(SHA256(txCopy)) = 5FDA68729A6312E17E641E9A49FAC2A4A6A680126610AF573CAAB270D232F850 Can somebody tells me if it's the correct value ? if SCRIPT_PART4 = PKScript: SHA256(SHA256(txCopy)) = 488A0FCF5FCBF4119E9595F029060D31CE97DC0A9C5594B9A3D7E914B5B268BE Title: Re: finding TxHash to verify a Tx Post by: fbueller on May 08, 2015, 09:00:33 PM OP_CODESEPARATOR isn't something you will encounter a lot of.
Normally you can just copy the txOut's script directly (SCRIPT_PART4) when making txCopy (when you drop the scriptPubKey into the scriptSig of the input), but if OP_CODSEPARATOR is used, you only copy the script following it. |