1

If I'm right, segwit TxIDs are composed of the SHA^2(256) hash of the non-segwit data of a transaction. But, how does another node use the TxID to obtain information about the transaction such as the address information.

Am I right in saying that the node with the TxID will send it to a full-node which matches the desired TxID with the TxIDs that it stores with the relevant information which is then sent back to the node? If so, does that mean full nodes store the TxID and the transaction information?

1 Answer 1

4

Yes, all txids are calculated only from non-witness data. While many nodes have a complete copy of the blockchain (which does contain all transactions), most nodes do not have a full transaction index. It is generally not possible to request a transaction per its txid via the P2P protocol.

enter image description here
via https://developer.bitcoin.org/reference/p2p_networking.html

Nodes will advertise new transactions to their peers once per inv (inventory) messages. Only the notified peers can then request announced transactions per getdata messages, which prompts tx message responses. Nodes will not serve getdata requests unless they recently announced the transaction to the requesting peer for privacy reasons.

In absence of a prior announcement, a node can only learn about a transaction from a peer by requesting the block it was included in.

You can read more about the P2P messages for example here: https://developer.bitcoin.org/reference/p2p_networking.html

4
  • Maybe a clarification: there is no generic way in the P2P protocol to request a transaction by its txid. The getdata/tx approach only works for recently announced transactions. Beyond that, the only way of getting transactions is by fetching the blocks they are in. May 14 at 14:23
  • I revised my answer to clarify that confirmed transactions cannot be requested outside of the context of the block they're in.
    – Murch
    May 14 at 14:33
  • 2
    That's not exactly right. The criterion for being able to fetch a transaction is solely "has it been announced recently". If that's the case, it can be requested (even if it has since confirmed). If that's not the case, it's not guaranteed to be requestable (even if it is still unconfirmed); e.g. if a transaction was relayed by node X before you connected to X, you generally can't getdata it (for privacy reasons). May 14 at 15:42
  • 1
    Thanks for the correction, I hope I got it right now.
    – Murch
    May 14 at 18:32

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.