3
I would like to count script step by step, but I have problem with it.
For example, I have such transaction:
{
"locktime": 0,
"txid": "c0fdb774710943d8dbb5f823c00394452fb1a1d63a3a7a9fb8de41299b37f090",
"version": 1,
"vin": [
{
"scriptSig": {
"asm": "3045022074f35af390c41ef1f5395d11f6041cf55a6d7dab0acdac8ee746c1f2de7a43b3022100b3dc3d916b557d378268a856b8f9a98b9afaf45442f5c9d726fce343de835a5801 02c34538fc933799d972f55752d318c0328ca2bacccd5c7482119ea9da2df70a2f",
"hex": "483045022074f35af390c41ef1f5395d11f6041cf55a6d7dab0acdac8ee746c1f2de7a43b3022100b3dc3d916b557d378268a856b8f9a98b9afaf45442f5c9d726fce343de835a58012102c34538fc933799d972f55752d318c0328ca2bacccd5c7482119ea9da2df70a2f"
},
"sequence": 4294967295,
"txid": "e1142c945b73826b552407916c13402fb873fb1d3f7c16fa561367aaddd076a7",
"vout": 0
}
],
"vout": [
{
"n": 0,
"scriptPubKey": {
"addresses": [
"1PQnDVEi2u4e8rFmE3d9J51eQz8cQXpybC"
],
"asm": "OP_DUP OP_HASH160 f5d214041d44860c8c08202a9e4263fc47a2fe88 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a9145e4ff47ceb3a51cdf7ddd80afc4acc5a692dac2d88ac",
"reqSigs": 1,
"type": "pubkeyhash"
},
"value": 0.58407
}
]
}
First of all I put on the stack
3045022074f35af390c41ef1f5395d11f6041cf55a6d7dab0acdac8ee746c1f2de7a43b3022100b3dc3d916b557d378268a856b8f9a98b9afaf45442f5c9d726fce343de835a5801
and
02c34538fc933799d972f55752d318c0328ca2bacccd5c7482119ea9da2df70a2f
and I start execute script, so
after OP_DUP the stack looks like:
3045022074f35af390c41ef1f5395d11f6041cf55a6d7dab0acdac8ee746c1f2de7a43b3022100b3dc3d916b557d378268a856b8f9a98b9afaf45442f5c9d726fce343de835a5801 02c34538fc933799d972f55752d318c0328ca2bacccd5c7482119ea9da2df70a2f 02c34538fc933799d972f55752d318c0328ca2bacccd5c7482119ea9da2df70a2fto execute OP_HASH160, I get the first element on the top of stack, change hex to bytes, count Hash160 using formula: Hash160(x) = RIPEMD160(SHA256(x)) and put new value on stack. In Javascript it looks like
CryptoJS.RIPEMD160(hexToBytes(CryptoJS.SHA256(hexToBytes("02c34538fc933799d972f55752d318c0328ca2bacccd5c7482119ea9da2df70a2f")).toString())).toString()
and it returns value "38ef3b4b7f01ea41e2013d4b77f63c998967efc9", so the new value of stack is:
3045022074f35af390c41ef1f5395d11f6041cf55a6d7dab0acdac8ee746c1f2de7a43b3022100b3dc3d916b557d378268a856b8f9a98b9afaf45442f5c9d726fce343de835a5801
02c34538fc933799d972f55752d318c0328ca2bacccd5c7482119ea9da2df70a2f
38ef3b4b7f01ea41e2013d4b77f63c998967efc9
the next step of counting script is putting f5d214041d44860c8c08202a9e4263fc47a2fe88 on the stack
3045022074f35af390c41ef1f5395d11f6041cf55a6d7dab0acdac8ee746c1f2de7a43b3022100b3dc3d916b557d378268a856b8f9a98b9afaf45442f5c9d726fce343de835a5801 02c34538fc933799d972f55752d318c0328ca2bacccd5c7482119ea9da2df70a2f 38ef3b4b7f01ea41e2013d4b77f63c998967efc9 f5d214041d44860c8c08202a9e4263fc47a2fe88
And now, I should check if 38ef3b4b7f01ea41e2013d4b77f63c998967efc9 is equal f5d214041d44860c8c08202a9e4263fc47a2fe88 and I get of course false.
What am I doing wrong? I got the same problem with all transactions, which I checked, so probably I don't understand how scripts work or how OP_HASH160 is counted.
@me.ex Nice to hear that i could help you, maybe you can mark the answer as correct;) – Dennis Kriechel – 2014-06-16T18:22:00.010