0

consider an offline transaction that has not been posted yet, created through a method such as here:

http://brainwallet.org/#tx

a) how could I calculate the transaction ID from the raw transaction? b) how could I calculate the transaction ID from the JSON transaction?

1

Both the reference client (Bitcoin-QT) and a service like http://brainwallet.org/ show the transaction ID after signing but before the transaction is broadcast.

Take for example, this valid binary transaction:

01000000017a06ea98cd40ba2e3288262b28638cec5337c1456aaf5eedc8e9e5a20f062bdf000000008b48304502200addea57dd4c2871357165ed6d2bc94b117e322918073ac4c66d535637e74600022100dfaa0dce9e2e61aa2867c87fadca4e0fa3c70e9852a4689b3ef24b3f94809b4a014104e0ba531dc5d2ad13e2178196ade1a23989088cfbeddc7886528412087f4bff2ebc19ce739f25a63056b6026a269987fcf5383131440501b583bab70a7254b09effffffff01b02e052a010000001976a9142dbde30815faee5bf221d6688ebad7e12f7b2b1a88ac00000000

In JSON it decodes to:

{
    "txid" : "46b690f548f6eb70dca7fb2020ff4be369c42f3ea2375fd3f6b34890b640f8e9",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        { [... snipped ...]}
        }
    ]
}

With the transaction ID in the first key. If you were doing the signing yoruself, the TXID is literally a double SHA256 hash of the raw transaction. There's some more information about raw transactions on the wiki.

1

The answer is right, but you always have to think about Transaction Malleability, so that your transaction's ID could easily change during mining process when it will be in the network. So that, you can't trust offline calculated transaction ID, and have to wait until your transction will be confirmed by the network to depend something on its ID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.