Bitcoin Forum
June 07, 2024, 05:19:10 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How are unconfirmed transactions relayed?  (Read 1007 times)
Jaxkr (OP)
Sr. Member
****
Offline Offline

Activity: 420
Merit: 250


View Profile
May 06, 2013, 09:55:36 PM
 #1

Hi everyone.
I'm currently curious as to how new transactions are relayed to the clients and miners.
Without confirmations, they aren't in the blockchain. How do the miners and clients know they happened?

How is the data transmitted in a decentralized way? Please be as technical as possible. Smiley
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
May 06, 2013, 10:02:31 PM
 #2

Your node (node here refers to full node i.e. running bitcoin-qt client or bitcoind) has connections with multiple clients.  When your node learns of a new tx (including one you create) it relays it to all the peers it is connected to.  Those peers verify the tx and relay it to all peers they know, who do the same.

All nodes all new unconfirmed tx to the memory pool which is just a list of tx the node "knows about".  Miners (in case of pool mining it is the pool actually doing the mining) use their copy of the memory pool to decide which tx to include in the next block they are working on.

When a miner broadcasts a block the same process happens at the block level.  The node relays the block to all its peers who verify the block and relays it on.

When your node confirms that a new block extends the longest chain it removes all the tx from the memory pool (as they are now unconfirmed).  If a new block orphans an existing block your node will add back any tx from the orphaned block to the memory pool and then remove any tx from the memory pool in the new block.

TL/DR: all nodes maintain a list of unconfirmed tx and relay them to another nodes.
Node learns of a new tx - add to memory pool
Node learns of a new block on longest chain - remove tx in block from memory pool
Node leans an existing block on the longest chain has been orphaned - add orphaned block's tx back to memory pool
Sukrim
Legendary
*
Offline Offline

Activity: 2618
Merit: 1006


View Profile
May 06, 2013, 11:00:26 PM
 #3

As far as I get it, your client will also actually take a look at the transactions, to make sure it doesn't spread fake/bogus/spamming/double-spending transactions - it will on one hand check if the script(s) of the transaction adheres to certain standards, that are deemed "safe". Also it will not allow the spreading of transactions that spend inputs that are already spent in another transaction in the memory pool.

The recent inclusion of transactions that have less than 5430 Satoshis as output in the "is not standard" category (which is blocked by default on clients to limit the capabilities of the transaction scripting language to a safe set of instructions) caused some uproar yesterday, as the option is now configurable, but not set by default at the previous implicit level of 1 Satoshi.

https://www.coinlend.org <-- automated lending at various exchanges.
https://www.bitfinex.com <-- Trade BTC for other currencies and vice versa.
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1025



View Profile
May 07, 2013, 02:34:15 AM
 #4

How is the data transmitted in a decentralized way? Please be as technical as possible. Smiley

Did you check this page yet?

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
Jaxkr (OP)
Sr. Member
****
Offline Offline

Activity: 420
Merit: 250


View Profile
May 07, 2013, 02:51:19 AM
 #5

Your node (node here refers to full node i.e. running bitcoin-qt client or bitcoind) has connections with multiple clients.  When your node learns of a new tx (including one you create) it relays it to all the peers it is connected to.  Those peers verify the tx and relay it to all peers they know, who do the same.

All nodes all new unconfirmed tx to the memory pool which is just a list of tx the node "knows about".  Miners (in case of pool mining it is the pool actually doing the mining) use their copy of the memory pool to decide which tx to include in the next block they are working on.

When a miner broadcasts a block the same process happens at the block level.  The node relays the block to all its peers who verify the block and relays it on.

When your node confirms that a new block extends the longest chain it removes all the tx from the memory pool (as they are now unconfirmed).  If a new block orphans an existing block your node will add back any tx from the orphaned block to the memory pool and then remove any tx from the memory pool in the new block.

TL/DR: all nodes maintain a list of unconfirmed tx and relay them to another nodes.
Node learns of a new tx - add to memory pool
Node learns of a new block on longest chain - remove tx in block from memory pool
Node leans an existing block on the longest chain has been orphaned - add orphaned block's tx back to memory pool

Thank you very much!
I've tried googling "bitcoin network protocol", and read the wiki. I still have one more question.
How do nodes learn about other nodes? Is it via trackers, similar to BitTorrent? However, trackers would require some form of centralization. I'm curious about this.
Jaxkr (OP)
Sr. Member
****
Offline Offline

Activity: 420
Merit: 250


View Profile
May 07, 2013, 02:51:50 AM
 #6

How is the data transmitted in a decentralized way? Please be as technical as possible. Smiley

Did you check this page yet?
Just read. Thanks for the link.
mc_lovin
Legendary
*
Offline Offline

Activity: 1190
Merit: 1000


www.bitcointrading.com


View Profile WWW
May 07, 2013, 04:06:42 AM
 #7

Your node (node here refers to full node i.e. running bitcoin-qt client or bitcoind) has connections with multiple clients.  When your node learns of a new tx (including one you create) it relays it to all the peers it is connected to.  Those peers verify the tx and relay it to all peers they know, who do the same.

All nodes all new unconfirmed tx to the memory pool which is just a list of tx the node "knows about".  Miners (in case of pool mining it is the pool actually doing the mining) use their copy of the memory pool to decide which tx to include in the next block they are working on.

When a miner broadcasts a block the same process happens at the block level.  The node relays the block to all its peers who verify the block and relays it on.

When your node confirms that a new block extends the longest chain it removes all the tx from the memory pool (as they are now unconfirmed).  If a new block orphans an existing block your node will add back any tx from the orphaned block to the memory pool and then remove any tx from the memory pool in the new block.

TL/DR: all nodes maintain a list of unconfirmed tx and relay them to another nodes.
Node learns of a new tx - add to memory pool
Node learns of a new block on longest chain - remove tx in block from memory pool
Node leans an existing block on the longest chain has been orphaned - add orphaned block's tx back to memory pool

If it's adding unconfirmed tx's to the memory pool, couldn't a person attack via this way?  Everyone adds all the BS spam tx's and it overloads?
oakpacific
Hero Member
*****
Offline Offline

Activity: 784
Merit: 1000


View Profile
May 07, 2013, 06:06:20 AM
 #8

A bit off-topic, sorry OP. But I always wonder why can't merchants just reject/put on hold transactions from addresses with still unconfirmed transactions to prevent race-attacks? Should be a fair request with a deterministic wallet as it's recommended to use every address only once.

https://tlsnotary.org/ Fraud proofing decentralized fiat-Bitcoin trading.
Sukrim
Legendary
*
Offline Offline

Activity: 2618
Merit: 1006


View Profile
May 07, 2013, 07:00:30 AM
 #9

If it's adding unconfirmed tx's to the memory pool, couldn't a person attack via this way?  Everyone adds all the BS spam tx's and it overloads?

As I already wrote above, there are no "BS spam tx" - they either really do cost real coin or are not relayed if your client deems them to be "BS". If a client sends you a lot of these (to DoS you maybe), your client will simply cut the connection to that one and move on with it's life.

https://www.coinlend.org <-- automated lending at various exchanges.
https://www.bitfinex.com <-- Trade BTC for other currencies and vice versa.
niko
Hero Member
*****
Offline Offline

Activity: 756
Merit: 501


There is more to Bitcoin than bitcoins.


View Profile
May 07, 2013, 07:36:25 AM
 #10

Right here: https://en.bitcoin.it/wiki/Network

They're there, in their room.
Your mining rig is on fire, yet you're very calm.
Jaxkr (OP)
Sr. Member
****
Offline Offline

Activity: 420
Merit: 250


View Profile
May 08, 2013, 12:38:35 AM
 #11

If it's adding unconfirmed tx's to the memory pool, couldn't a person attack via this way?  Everyone adds all the BS spam tx's and it overloads?

As I already wrote above, there are no "BS spam tx" - they either really do cost real coin or are not relayed if your client deems them to be "BS". If a client sends you a lot of these (to DoS you maybe), your client will simply cut the connection to that one and move on with it's life.
And transactions fees serve as DoS protection!
Sukrim
Legendary
*
Offline Offline

Activity: 2618
Merit: 1006


View Profile
May 08, 2013, 01:07:36 AM
 #12

How do you come to this conclusion?

https://www.coinlend.org <-- automated lending at various exchanges.
https://www.bitfinex.com <-- Trade BTC for other currencies and vice versa.
Jaxkr (OP)
Sr. Member
****
Offline Offline

Activity: 420
Merit: 250


View Profile
May 08, 2013, 01:30:32 AM
 #13

How do you come to this conclusion?
It costs spammers much more to get junk transactions verified.
However, fees don't protect relays. Hopefully, the new minimum transaction amount will in the future.
Sukrim
Legendary
*
Offline Offline

Activity: 2618
Merit: 1006


View Profile
May 08, 2013, 01:42:22 AM
 #14

Relays don't need that much protection, the new default setting is not a hard standard (and there is actually an incentive to set this to 21 million for anyone who doesn't mine...) and in my opinion I'd rather have a measurement/setting based on transaction size and UTXO set impact than transacted amount...

https://www.coinlend.org <-- automated lending at various exchanges.
https://www.bitfinex.com <-- Trade BTC for other currencies and vice versa.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!