Can someone post an explanation of how to find the source and destination addresses of a transaction from the input/output portions of a block?

  • From input script? you mean just like that: ScriptSig: PUSHDATA(72)[3045022100f4427952c78e1dc5108bc57a101a53f766706ee08fa99c24ec17f05d06e66ffb02201e826952e13a3042b6599bcfc921ad14504e08cf05f19f82eb8d1111e56ee1a701] PUSHDATA(33)[0236371dd8c40e66849d7fda6f78645ca0222798de7d1f3df8d1af78eb114d719b]
    – Adam
    Jan 6 '18 at 22:07
  • hmm, Bitcoin? Altcoin? from input/output portion of a block? In Bitcoin a block contains transactions, and these transactions move coins from one address to another. Besides bitcoin.org and of course Andreas book "Mastering Bitcoin", this here is maybe the shortest way: righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html? Otherwise you may need to rephrase your question, so we can find the right answer / approach... Jan 6 '18 at 22:53
  • @pebwindkraft Thanks for the response! I guess I'm trying to figure out where the source and destination addresses are stored in a transaction? Does that make sense?
    – mdornfe1
    Jan 6 '18 at 22:54

in general: I have added a sample tx, which explains the details:

TX_IN COUNT [var_int]: hex=02, decimal=2
  TX_IN[0] OutPoint hash (char[32])

--> this is the previous tx, which contains funds to move

  TX_IN[0] OutPoint index (uint32_t)
  hex=01000000, reversed=00000001, decimal=1
  TX_IN[0] Script Length (var_int)
  hex=6A, decimal=106
  TX_IN[0] Script Sig (uchar[])

--> this script has the signature, and the following public key (starting with 02B12126...) - this is where the funds were signed with, and would be the source address (you would need to convert the pub key first to the bitcoin address - see references in my comments)

  TX_IN[0] Sequence (uint32_t)

--> and here follows a second input, from which this transaction moves funds... same rules as before.

  TX_IN[1] OutPoint hash (char[32])
  TX_IN[1] OutPoint index (uint32_t)
  hex=00000000, reversed=00000000, decimal=0
  TX_IN[1] Script Length (var_int)
  hex=6B, decimal=107
  TX_IN[1] Script Sig (uchar[])
  TX_IN[1] Sequence (uint32_t)

and here follow the outputs...

TX_OUT COUNT, hex=02, decimal=2
  TX_OUT[0] Value (uint64_t)
  hex=9025730000000000, reversed_hex=0000000000732590, dec=7546256, bitcoin=0.07546256
  TX_OUT[0] PK_Script Length (var_int)
  hex=19, dec=25
  TX_OUT[0] pk_script (uchar[])

--> this pk_script defines the conditions, under which the funds can be spend. It is encoded in bitcoin's script language, and would finally translate to an address: 1Q2tmgphDqFJxhFFYNrjBr5o8XKSSDKtXv

  TX_OUT[1] Value (uint64_t)
  hex=9838110000000000, reversed_hex=0000000000113898, dec=1128600, bitcoin=0.01128600
  TX_OUT[1] PK_Script Length (var_int)
  hex=19, dec=25
  TX_OUT[1] pk_script (uchar[])

and this is a second script (usually a return address), which translates here to: 1AkUKA3NNQt4gs3GGexhacnkSMcmYHsN3S


Hope this helps, as mentioned before, Ken Shirrifs link is probably best to quickly follow.

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.