1

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?

3
  • 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
1

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

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

--> 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[])
  4730440220128487F04A591C43D7A6556FFF9158999B46D6119C1A4D4CF1F5D0AC1DD57A94022061556761E9E1B1E656C0A70AA7B3E83454CD61662DF61EBDC31E43196B5E0C10012102B12126A716CE7BBB84703BCFBF0AFA80283C75A7304A48CD311A5027EFD906C2 

--> 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)
  FFFFFFFF

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

 TX_IN[1]
  TX_IN[1] OutPoint hash (char[32])
  A75B4B6369ABC4A5F0A95FF714460BFA33802A2C422FD06D7B28771570C4520E
  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[])
  483045022100A428348FF55B2B59BC55DDACB1A00F4ECDABE282707BA5185D39FE9CDF05D7F0022074232DAE76965B6311CEA2D9E5708A0F137F4EA2B0E36D0818450C67C9BA259D0121025F95E8A33556E9D7311FA748E9434B333A4ECFB590C773480A196DEAB0DEDEE1 
  TX_IN[1] Sequence (uint32_t)
  FFFFFFFF

and here follow the outputs...

TX_OUT COUNT, hex=02, decimal=2
 TX_OUT[0]
  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[])
  76A914FCA68658B537382E27A85522D292E1AD9543FE0488AC

--> 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]
  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[])
  76A9146AF1D17462C6146A8A61217E8648903ACD3335F188AC

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

 LOCK_TIME
00000000

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.