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?
1 Answer
- 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 agetdata
frame back - Client receives a
getdata
frame for the transaction it just created, so it sends atx
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 thetx
, sendsinv
, and repeat that until the entire network has the transaction.
References :
-
Correct me if I'm wrong, but doesn't bitcoin only send the transaction to one peer if it originated the transaction? Apr 16, 2013 at 21:01
-
1@NickODell Perhaps, but that's implementation related, and not a network rule. Apr 16, 2013 at 21:02
-
Thank you Tom, very clear explanation. However, I still have a question. Based on Satoshi paper 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?– anapasoApr 16, 2013 at 21:27
-
(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. Apr 16, 2013 at 22:15 -
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?– ulkasApr 17, 2013 at 7:11