Recently, I wrote a c++ code to extract some information from some messages in BITCOIN protocol. for example, I extracted bitcoin value and output address corresponded to it from tx messages of this protocol.

Extraction algorithm for output addresses is based on type of scripts such as P2PK, P2PKH, P2SH, P2WPKH and etc. but it is not clear how to extract input addresses.

can anyone explain what is the extraction method for input addresses in tx messages?

  • Inputs don't have addresses. Outputs do. Inputs spend previous outputs. You'll need to find the output being spent to figure out the address (which is not explicit in the protocol), but generally this is not interesting information for anything but debug purposes. Jun 15 '19 at 6:07
  • @PieterWuille You mean that every address which is shown in bitcoin explorers are previous outputs? I know that UTXO's are same previous outputs, but what about other transactions?
    – Saeed
    Jun 15 '19 at 6:50
  • Yes, that's exactly what UTXO means: unspent transaction output. An input simply spends a UTXO and gets to create new ones with the redeemed value. Bitcoin transaction inputs do not contains addresses or amounts; simply the identifier of a UTXO being spent, and the signature data necessary to authorize the spend. Jun 15 '19 at 6:52
  • @PieterWuille So how I can access the transactions which their output addresses spent as input address for current transaction?
    – Saeed
    Jun 15 '19 at 7:33
  • 2
    As a personal comment judging by the questions you're asking: trying to learn Bitcoin by trying to decipher pcap dumps is not going to teach you much. The Bitcoin protocol is designed for interaction between Bitcoin nodes, which maintain state, and interact in various ways. Looking at the operation of those nodes directly will explain a lot more than trying to infer it from the trail of TCP messages you can observe. Jun 15 '19 at 8:06

Your Answer

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

Browse other questions tagged or ask your own question.