When a transaction is broadcast to the network, what is actually being sent?

9

2

When a transaction is broadcasted to the network, what is being sent? Is it a hash? if yes, is it going to be the hash of: previous transaction + public key of the receiver?

anapaso

Posted 2013-04-16T20:54:28.970

Reputation: 703

Answers

10

  • Client creates a new transaction, adds it to its memory pool
  • Client broadcasts an inv frame, which indicates that it has something in its memory pool, by giving the hash of the transaction to one or more connected peers
  • Peer receives inv frame, checks its own memory pool, it's not in there, so it sends a getdata frame back
  • Client receives a getdata frame for the transaction it just created, so it sends a tx with the entire transaction
  • Peer receives the tx, hashes it and puts it in the memory pool
  • Peer now has something new in the memory pool, and broadcasts an inv to all connected peers
  • Client gets an inv frame, notices that it's already in the memory pool, and ignores it
  • Another client gets the inv frame as well, getdata's it, stores the tx, sends inv, and repeat that until the entire network has the transaction.

References :

Tom van der Woerdt

Posted 2013-04-16T20:54:28.970

Reputation: 2 397

Correct me if I'm wrong, but doesn't bitcoin only send the transaction to one peer if it originated the transaction?Nick ODell 2013-04-16T21:01:36.660

1@NickODell Perhaps, but that's implementation related, and not a network rule.Tom van der Woerdt 2013-04-16T21:02:29.510

Thank you Tom, very clear explanation. However, I still have a question. Based on Satoshi paper http://bitcoin.org/bitcoin.pdf, the hash consists of the public key of the receiver too. I suppose that the public key is added in order to have different hashes?

anapaso 2013-04-16T21:27:33.650

(Disclaimer: I've never read the paper, I've only built a client.) The hash of a transaction is simply the entire transaction (tx) hashed (unlike blocks, which only have their headers hashed). This includes all the inputs and outputs.Tom van der Woerdt 2013-04-16T22:15:44.583

how fast or how long does it take to broadcast the information to all peers? i mean when i'm mining, and somebody has already found a new block, how long would it take till i receive the information and start mining again on new block?ulkas 2013-04-17T07:11:55.813

Reaching all peers can take a long time (maybe even up to an hour), as there are always a few edges on the network where it takes a lot longer. However, for most nodes it's a matter of seconds to maybe two minutes.Tom van der Woerdt 2013-04-17T09:04:52.033