Advertisement
Guest User

Breakdown of Bitcoin transaction

a guest
Nov 27th, 2014
975
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.16 KB | None | 0 0
  1. https://blockchain.info/tx/60b20eca2285b7ed8b64a1f98277c16fcc205b9e21413d6a72545880d2a3f341?show_adv=true
  2.  
  3. or to view hex:
  4.  
  5. https://blockchain.info/tx/60b20eca2285b7ed8b64a1f98277c16fcc205b9e21413d6a72545880d2a3f341?format=hex
  6.  
  7. Full original broadcast tx:
  8.  
  9. 010000000217cbf067a9ad71b2f69ea66a1c94d04cee26f856b5b4bdccaeccb59761419668010000008a4730440220735364aea32db724e7f0179f48e4ad5a63a3b04f733e82ca5215097a91aa7123022015846041c9564ff96fb269cb5e9b2f24dac003299e5d16d34fb9c699d55825c7014104617f9e26b7f6f776e30cb4aa24ebef9e183caf6da25684862a32446589be20a53c2b37a7283430033bdfd2f31a96edaea88bf9ebf07498476cb34d16b47887edffffffff877a5dd62eab9f1fd28739a9ae7c68fcb0f075b2c2ede13cb3acff15d362e271010000008c493046022100d0af9e17b678ad7823ad331a04d5b50f2dc173715949718ef974314f9ddbf0fa02210098de23b9c6daad57e7c8a8748718c56ec8d20cd2686aa652c4fb85091a39c690014104617f9e26b7f6f776e30cb4aa24ebef9e183caf6da25684862a32446589be20a53c2b37a7283430033bdfd2f31a96edaea88bf9ebf07498476cb34d16b47887edffffffff01709cc901000000001976a914ea0fcd06c9c62e590a8975627d0165b514568a5a88ac00000000
  10.  
  11. Tx ID: 60b20eca2285b7ed8b64a1f98277c16fcc205b9e21413d6a72545880d2a3f341
  12. Tx ID created by byte_reverse(double_sha256(fullsignedtx))
  13.  
  14.  
  15. Breakdown of tx:
  16.  
  17. 01000000 - byte_reverse(Version: 1, in hex, 4 bytes long)
  18. 02 - Total number of inputs (starts at 1, not 0, so for this tx there are 2 total inputs not three)
  19. 17cbf067a9ad71b2f69ea66a1c94d04cee26f856b5b4bdccaeccb59761419668 - byte_reverse(input_txid)
  20. 01000000 - byte_reverse of vout num for prev_tx (starting at 0, so this is the second output from that tx)
  21. 8a - total byte length (in hex, 0x8a = 138) of following signature + pubkey, (plus prefix bytes to indicate length)
  22. 47 - total byte length (0x47 = 71) of following signature
  23. 30 - DER encoded signature
  24. 44 - total byte length of following signature info
  25. 02 - first value is an integer, represented in hex (DER format calls that 0x02 apparently)
  26. 20 - byte length of first value (0x20 = 32 in decimal)
  27. 735364aea32db724e7f0179f48e4ad5a63a3b04f733e82ca5215097a91aa7123 - r value (pub X coord of random nonce)
  28. 02 - next number is also an int
  29. 20 - next data is 32 bytes long
  30. 15846041c9564ff96fb269cb5e9b2f24dac003299e5d16d34fb9c699d55825c7 - s value (signature for nonce,data,privkey tuple)
  31. 01 - bitcoin signature type SIGHASH_ALL
  32. (tells miners how to verify signature. some sig types sign only certain inputs or outputs, like in coinjoin tx's. the standard SIGHASH_ALL signs your input and all outputs so no modifications can be made)
  33. 41 - byte length of following public key (0x41=65)
  34. 04617f9e26b7f6f776e30cb4aa24ebef9e183caf6da25684862a32446589be20a53c2b37a7283430033bdfd2f31a96edaea88bf9ebf07498476cb34d16b47887ed - pubkey which is the key for the input address and which corresponds to the privkey used to make sig
  35. ffffffff - sequence number, assigned just now in this tx, to this last input, for use with nlocktime in this tx
  36. 877a5dd62eab9f1fd28739a9ae7c68fcb0f075b2c2ede13cb3acff15d362e271 - second input byte_reverse(tx_id)
  37. 01000000 - second input byte_reversed vout number. (again, starting at 0, so this is the second output)
  38. 8c - length of full signature and pubkey
  39. 49 - length of following signature info
  40. 30 - DER encoded signature
  41. 46 - length of following signature info
  42. 02 - first number is der int
  43. 21 - length of first number data plus 00 prefix
  44. 00 - DER prefixes integer with 00 if integer begins with 0x80 or higher.
  45. d0af9e17b678ad7823ad331a04d5b50f2dc173715949718ef974314f9ddbf0fa - r value
  46. 02 - next number is int
  47. 21 - length of next number and 00 prefix
  48. 00 - prefix, since next number starts at 0x80 or higher
  49. 98de23b9c6daad57e7c8a8748718c56ec8d20cd2686aa652c4fb85091a39c690 - s value
  50. 01 - SIGHASH_ALL
  51. 41 - length of following pubkey
  52. 04617f9e26b7f6f776e30cb4aa24ebef9e183caf6da25684862a32446589be20a53c2b37a7283430033bdfd2f31a96edaea88bf9ebf07498476cb34d16b47887ed - pubkey for prevtx vout, which should be the same one used for the signature
  53. ffffffff - sequence number assigned to input
  54. 01 - total number of outputs, in hex, starting at 1 not 0.
  55. 709cc90100000000 - byte_reverse of (number of satoshis in output represented in hex), zfilled to 8 bytes long
  56. 19 - number of bytes for output script
  57. 76 - OP_DUP, duplicated previous stack data (which will be the hash160 when this script is used to spend the money)
  58. a9 - OP_HASH160, the ripemd160(sha250(pubkey)) for the output key
  59. 14 - length of the hash160 data
  60. ea0fcd06c9c62e590a8975627d0165b514568a5a - hash160 of address's public key
  61. 88 - OP_EQUALVERIFY, does OP_EQUAL which puts TRUE on the stack if sig is valid
  62. then does OP_VERIFY which stops the transaciton and marks it invalid if the top stack item is not TRUE
  63. ac - OP_CHECKSIG, makes sure the data that has a valid sig is actually this tx's data.
  64. 00000000 - nlocktime
  65.  
  66.  
  67. When signing, you replace the signature with your own input scriptpubkey, remove the sighash type byte, replace other inputs with 00, and then add the hash type (8 bytes, byte_reversed) to the end.
  68.  
  69. So the first signature in this tx signed the double_sha256 of the following:
  70.  
  71. 010000000217cbf067a9ad71b2f69ea66a1c94d04cee26f856b5b4bdccaeccb59761419668010000001976a9140a2217742759c9951371083564d94b8b0317528488acffffffff877a5dd62eab9f1fd28739a9ae7c68fcb0f075b2c2ede13cb3acff15d362e2710100000000ffffffff01709cc901000000001976a914ea0fcd06c9c62e590a8975627d0165b514568a5a88ac0000000001000000
  72.  
  73. And the second input signed the double_sha256 of the following:
  74.  
  75. 010000000217cbf067a9ad71b2f69ea66a1c94d04cee26f856b5b4bdccaeccb597614196680100000000ffffffff877a5dd62eab9f1fd28739a9ae7c68fcb0f075b2c2ede13cb3acff15d362e271010000001976a9140a2217742759c9951371083564d94b8b0317528488acffffffff01709cc901000000001976a914ea0fcd06c9c62e590a8975627d0165b514568a5a88ac0000000001000000
  76.  
  77. The unsigned tx, which bitcoind spits out with createrawtransaction, sets both inputs to 00 and does not have a sighash identifier:
  78.  
  79. 010000000217cbf067a9ad71b2f69ea66a1c94d04cee26f856b5b4bdccaeccb597614196680100000000ffffffff877a5dd62eab9f1fd28739a9ae7c68fcb0f075b2c2ede13cb3acff15d362e2710100000000ffffffff01709cc901000000001976a914ea0fcd06c9c62e590a8975627d0165b514568a5a88ac00000000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement