Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: japerry on July 01, 2016, 12:58:35 PM



Title: Timeout on un-confirmed transactions?
Post by: japerry on July 01, 2016, 12:58:35 PM
As I understand it, if a transaction sits on the blockchain for long enough without confirmations it will time out and be returned to the sending address? Am I correct in this assumption? If so, what is the length of time a transaction needs to sit without confirmations before it is returned to the sender?



Title: Re: Timeout on un-confirmed transactions?
Post by: DannyHamilton on July 01, 2016, 01:18:14 PM
As I understand it, if a transaction sits on the blockchain for long enough without confirmations it will time out and be returned to the sending address?

Someone has either given you incorrect information, or you have mis-understood something you've been told.

Am I correct in this assumption?

No.

If so, what is the length of time a transaction needs to sit without confirmations before it is returned to the sender?

Once a transaction is on the blockchain, it is confirmed.  That is the definition of "confirmed" in the bitcoin system.  So a transaction cannot "sit on the blockchain" unless it is already confirmed.

You can broadcast your transaction to the peer nodes that you are connected to, and they can relay that transaction to the peer nodes that they are connected to, and so on until pretty much all nodes on the network have heard about your transaction.  The nodes will store your transaction in their memory pool in case any peer requests it. It won't be "on the blockchain" yet, but some websites might show you the transaction if they have heard about it from any of the nodes they are connected to.

Miners (and mining pools) will have heard about the transaction from their connected peers and they can choose to include the transaction in the block that they are working on if they want to. If a miner chooses to include your transaction in their block and they successfully solve the block before any other miners (or pools) solve a block at the same block-height, THEN your transaction is added to the blockchain. The miner broadcasts his block to all his connected peers, and it is relayed throughout the network until nearly everyone has the block with your transaction in their blockchain. When any node sees this new block with your transaction on their blockchain, that node then considers your transaction to be "confirmed".

If none of the miners (or pools) choose to include your transaction in any of their blocks, then it won't get confirmed.  Eventually, the nodes on the network will drop your transaction out of their memory pool to make room for newer transactions. There is no specific amount of time that a node is required to remember your transaction.  Some might drop it within a few hours, others might wait a day, some nodes might remember your transaction for a week.  If someone wants to remember the transaction forever, they are welcome to try to do so.

Once your transaction has been transmitted, it is view-able by anyone on the network.  That means that anyone can save a copy of it and re-transmit it later if they want.  So if the recipient of your transaction (or anyone else) wants to, they can re-braodcast the transaction every day or so to remind the network and refresh the transaction in the memory of all the nodes.

How often YOU re-braodcast the transaction depends on what wallet you are using.  Some wallets (such as Bitcoin Core) will remember all the transactions that they have created, and will re-braodcast the transactions forever trying to remind the network about them so that they eventually get confirmed.  Other wallets (such as blockchain.info) will drop the transaction from their storage after a few days if it hasn't confirmed yet, because they wallet creator assumes that the transaction will never confirm and that most peers have forgotten about it.

Transactions are never "returned to the sender".  They are simply forgotten.  If enough of the network has forgotten about your transaction, and your wallet also forgets that you ever sent the transaction, then the wallet will see the bitcoins associated with that transaction as never having been spent and will allow you to create a new transaction that uses those same bitcoins.

If you create a new transaction with the same bitcoins, and if the new transaction gets confirmed, then the old unconfirmed transaction will become invalid (since it tries to spend bitcoins that you don't have anymore).  All nodes will then drop the invalid old transaction from their memory and will refuse to accept it from anyone that tries to broadcast it.


Title: Re: Timeout on un-confirmed transactions?
Post by: japerry on July 01, 2016, 01:23:24 PM
Wow!! That's a fantastic explanation!! Thank you! You have increased my understanding of how the process works a thousand-fold!! My hat is off to you sir!







Title: Re: Timeout on un-confirmed transactions?
Post by: yakuza699 on July 05, 2016, 10:30:23 PM
There is no specific amount of time that a node is required to remember your transaction.  Some might drop it within a few hours, others might wait a day, some nodes might remember your transaction for a week.
Actually in Bitcoin core 0.12 the "-mempoolexpiry" parameter was introduced which is set to 72 hours by default. So majority of 0.12 users will drop the transaction after 72 hours. Though anyone can re-broadcast the transaction so I can't see the use of this parameter.


Title: Re: Timeout on un-confirmed transactions?
Post by: DannyHamilton on July 05, 2016, 11:09:38 PM
Actually in Bitcoin core 0.12 the "-mempoolexpiry" parameter was introduced which is set to 72 hours by default. So majority of 0.12 users will drop the transaction after 72 hours.

True.  Most won't bother to change the default value, so if they happen to be running Core version 0.12.x then they will drop it after 72 hours.  however, there are a lot of people out there running things other than Core 0.12.x and there may be people that choose to change their default value.  As I said:  "There is no specific amount of time that a node is required to remember your transaction".  Nothing in the protocol stops someone from dropping your transaction after 1 hour, or stops them from keeping it forever.  And as you pointed out:

Anyone can re-broadcast the transaction so I can't see the use of this parameter.

I suppose the parameter is just to get a significant percentage of the nodes on the network to all drop the transaction after a few days in those situations where it isn't re-broadcast.