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


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.

  • 2
    Hmm, nothing like using the wiki entry I wrote against me ;) (the first one). And the base 58 is not much of a problem, already programmed that awhile ago.
    – ThePiachu
    Dec 16 '11 at 7:28
  • Has the Script been changed since the Genesis Block? I am having some problems figuring out how to process this scriptPubKey from that block: 4104678AFDB0FE5548271967F1A67130B7105CD6A828E03909A67962E0EA1F61DEB649F6BC3F4CEF38C4F35504E51EC112DE5C384DF7BA0B8D578A4C702B6BF11D5FAC
    – ThePiachu
    Dec 17 '11 at 1:37
  • This transaction uses the en.bitcoin.it/wiki/… type. In it you have the public key itself before any hashing (step #1). The public key in the genesis block is 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f, I'm not sure where you got this value from. Dec 17 '11 at 16:37
  • It's the same public key, but with opcodes added on both sides - push 0x41 bytes on the left and checksig on the right. So it is a raw scriptpubkey dump from en.bitcoin.it/wiki/Genesis_block
    – ThePiachu
    Dec 17 '11 at 22:49

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.