Bitcoin script example

Is there some good example on how to process a basic tx’s scriptsig and get the recipient’s address from the raw transaction?

Answer

In the output there is a field “scriptPubKey” that for a standard transaction looks like this:

OP_DUP OP_HASH160 62e907b15cbf27d5425399ebf6f0fb50ebb88f18 OP_EQUALVERIFY OP_CHECKSIG

The hex number is what you get the address from; this is the result of step #3 in https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses. To get the address continue the process in that example. (Though, arguably the hardest part is calculating Base58Check, for which an example is not given.)

Also relevant is https://en.bitcoin.it/wiki/Script#Standard_Transaction_to_Bitcoin_address.

Leave a Reply

Your email address will not be published. Required fields are marked *