How is the previous transaction hash calculated?

4

1

Can anyone provide a clear example on how to calculate a previous transaction hash?

Say I want to create a new transaction, I get that the hash is calculated by doubling sha256 a message m, but I'm having a hard time understanding the structure of m.

Mohamed Amine

Posted 2014-07-31T10:35:32.733

Reputation: 41

Answers

2

You do not need to calculate previous transaction hash, because it is already known. To spend the previous output you just have to know

  • tx hash
  • output index in this tx
  • output value
  • output script

plus you should choose

  • fee
  • new address

then create some byte data and sign it with appropriate private key

Good manual you can find here: How to redeem a basic Tx?

amaclin

Posted 2014-07-31T10:35:32.733

Reputation: 5 763

0

You hash the header. Format is here: https://en.bitcoin.it/wiki/Block_hashing_algorithm The body contains the transactions. Here's the Bitcoin transaction format: https://en.bitcoin.it/wiki/Transactions

juhraffe

Posted 2014-07-31T10:35:32.733

Reputation: 146