Bitcoin Forum

Other => Beginners & Help => Topic started by: AlphaGammaDelta on July 30, 2015, 02:52:27 PM



Title: Double spending within ten minutes
Post by: AlphaGammaDelta on July 30, 2015, 02:52:27 PM
This must have been asked before but I can't find an answer.

SCENARIO:  It takes ten minutes to add a new block of data to the blockchain.  Larry has one bitcoin.  He goes to the mall and within one ten minute period between blocks:

1) Larry spends most of his bitcoin at a computer store.
2) Larry runs next door to a jewelry store, where he again spends most of his bitcoin.

Obviously this can't happen.  What is the mechanism that prevents double spending within the ten minutes between blocks?

Thanks.


Title: Re: Double spending within ten minutes
Post by: notlist3d on July 30, 2015, 03:43:16 PM
This must have been asked before but I can't find an answer.

SCENARIO:  It takes ten minutes to add a new block of data to the blockchain.  Larry has one bitcoin.  He goes to the mall and within one ten minute period between blocks:

1) Larry spends most of his bitcoin at a computer store.
2) Larry runs next door to a jewelry store, where he again spends most of his bitcoin.

Obviously this can't happen.  What is the mechanism that prevents double spending within the ten minutes between blocks?

Thanks.

Conformations are there to prevent this.  That is why you wait to see conformations before sending items/codes/etc. 

Like Bitmain I think 3 conformations they wait on before it shows paid in their payment if I'm not mistaken.

Are you really a AlphaGammaDelta? I had to look it up was one i was unfamiliar with :)


Title: Re: Double spending within ten minutes
Post by: guytp on July 30, 2015, 03:43:25 PM
You don't spend a balance in the blockchain, instead you spend a previous input.

For example - let's say you received 1 BTC from someone and another 1 BTC from someone else.  This gives you 2 BTC.

If you want to send 1.5 BTC you end up "claiming" both 1 BTC inputs that you were given, sending 1.5 BTC to your recipient (in this case a store) and the remainder back to yourself.

The transaction get's a unique ID which is basically made up from the exact details of the input and how much you are paying to whom.

In your example you would generate two different transactions.  Since both are claiming the same inputs you would get Shop A submitting a transaction then Shop B submitting a transaction both stating these inputs are being used.  These would propogate around the network - including to miners.

When a miner discovers a block they will pick up transactions.  If the miner has only seen one of your transactions then it will include that one (which may be for Shop A or Shop B depending on the network).  If it has seen both I believe it will only accept the first one it sees.

Once that miner has accepted and "published" your transaction it gets "confirmed" to the network.  At this point you would see the transaction the miner accepted as "1 confirmation" and the other as "unconfirmed".

If at the same time two different miners both discovered a block and they both published different transactions you'd temporarily see an orphaned chain.  It's then a race as to which one gets most people to see it.  Once 51% of the network have seen one of the two confirmed transactions first - that becomes the "official" transaction and the other one is "orphaned" meaning the money cannot be spent.

In your example one of the two shop keepers would receive the BTC and the other wouldn't.

For bitcoin transactions it is down to the vendor to decide how many confirmations they require before releasing goods.  As the number of confirmations goes up the change of a reversal becomes expoentially more difficult.  Forks very rarely occur for more than a couple of blocks so 5 is generally a good example that you've got the money.  If you're selling a £1mn painting you'll probably want to wait 30-or-so blocks.

If one of your shops below is selling an expensive item it would be fair for them to say "come back in 30 minutes to pick it up".  If they're both seeling you £10 of goods then one of them has made a loss through fraud.  This is no different than a shop doing "offline auths" on low value credit cards to speed up transaction times (i.e. they don't contact bank, hope it will be OK and take the risk themselves to serve people faster like if paying by card at McDonalds).

So the situation you describe can happen but only one person gets paid eventually.

Other coins implement systems for "0 confirmations" - or are starting to.  These still don't give you 100% confidence but will certainly approach having a few blocks confirmed in a current system as it adds an additional layer on top of the above.


Title: Re: Double spending within ten minutes
Post by: achow101 on July 30, 2015, 03:43:33 PM
Nodes will only accept and relay the first transaction that it sees that spends those inputs. Larry would need to spend the same inputs twice. Most nodes that see the first transaction will reject the second one since it spends the same inputs twice. It is part of the relaying rules. Miners also follow these rules. When they see a double spend, they go with the version that came first. Due to the network speed, Larry would not be able to do the common Race Attack. That would require him to be at both stores at once and send both transactions at the same time. Due to the network propagation, the first transaction sent will reach most of the network before Larry can even leave the first store.

Also, most businesses and business deals should only go through after a few confirmations. This ensures that the transaction cannot be double spent. The computer store would be very idiotic to let unconfirmed transactions to happen.


Title: Re: Double spending within ten minutes
Post by: ranochigo on August 01, 2015, 03:41:22 PM
Nodes will only accept and relay the first transaction that it sees that spends those inputs. Larry would need to spend the same inputs twice. Most nodes that see the first transaction will reject the second one since it spends the same inputs twice. It is part of the relaying rules. Miners also follow these rules. When they see a double spend, they go with the version that came first. Due to the network speed, Larry would not be able to do the common Race Attack. That would require him to be at both stores at once and send both transactions at the same time. Due to the network propagation, the first transaction sent will reach most of the network before Larry can even leave the first store.

Also, most businesses and business deals should only go through after a few confirmations. This ensures that the transaction cannot be double spent. The computer store would be very idiotic to let unconfirmed transactions to happen.
The rules are for reference implementation. People can modify it themselves, whether to relay double spend transactions or not. Do note that a miner can accept the replacement transaction if they want to, the entire network would then accept that transaction.But it is not possible for two transactions spending the same output to get confirmations as majority of the network would reject that.
Zero confirmations are not always safe. (https://www.mail-archive.com/bitcoin-dev@lists.linuxfoundation.org/msg00500.html)

IMO, it is okay to allow small transactions to go through if you connect to peers at different geographical locations, make sure big pools are accepting the transaction, inputs are already confirmed and a good fee per kilobyte has been used.


Title: Re: Double spending within ten minutes
Post by: BestBitcoinOdds on August 01, 2015, 04:33:23 PM
This must have been asked before but I can't find an answer.

SCENARIO:  It takes ten minutes to add a new block of data to the blockchain.  Larry has one bitcoin.  He goes to the mall and within one ten minute period between blocks:

1) Larry spends most of his bitcoin at a computer store.
2) Larry runs next door to a jewelry store, where he again spends most of his bitcoin.

Obviously this can't happen.  What is the mechanism that prevents double spending within the ten minutes between blocks?

Thanks.

Yes, confirmations are needed.   It is not advisable to sell product for bitcoin without waiting for confirmations.    This is why I reall think we need to change the standard block time to reduce variances.


Title: Re: Double spending within ten minutes
Post by: ranochigo on August 01, 2015, 04:44:28 PM
This must have been asked before but I can't find an answer.

SCENARIO:  It takes ten minutes to add a new block of data to the blockchain.  Larry has one bitcoin.  He goes to the mall and within one ten minute period between blocks:

1) Larry spends most of his bitcoin at a computer store.
2) Larry runs next door to a jewelry store, where he again spends most of his bitcoin.

Obviously this can't happen.  What is the mechanism that prevents double spending within the ten minutes between blocks?

Thanks.

Yes, confirmations are needed.   It is not advisable to sell product for bitcoin without waiting for confirmations.    This is why I reall think we need to change the standard block time to reduce variances.
Confirmations should be needed for amounts more than $100. Changing block times aren't easy and it would reduce the security of the network, increasing orphan blocks. A 5 minutes block would need 2 blocks to provide the same level of consensus as 10 minute blocks and it would require a hard fork to reduce block time. Varience can't be eliminated. Even with shorter block time, blocks can still reach 30 minutes per.


Title: Re: Double spending within ten minutes
Post by: Foxpup on August 02, 2015, 07:28:54 AM
Unconfirmed transactions are relayed to everyone on the network. That's how miners get them in the first place. The jewellery store will normally see his original transaction within seconds, and will reject Larry's double spend unless he runs very fast. Bonus points for wiring the point-of-sale terminal to trigger the silent alarm and lock the doors when a double-spend attempt is detected.

While there is always a risk of double-spends against unconfirmed transactions, the chance of success is so low, and the risk of being caught is so high, that in practice it should not be a problem.


Title: Re: Double spending within ten minutes
Post by: ajareselde on August 02, 2015, 09:32:54 AM
This must have been asked before but I can't find an answer.

SCENARIO:  It takes ten minutes to add a new block of data to the blockchain.  Larry has one bitcoin.  He goes to the mall and within one ten minute period between blocks:

1) Larry spends most of his bitcoin at a computer store.
2) Larry runs next door to a jewelry store, where he again spends most of his bitcoin.

Obviously this can't happen.  What is the mechanism that prevents double spending within the ten minutes between blocks?

Thanks.

Yes, confirmations are needed.   It is not advisable to sell product for bitcoin without waiting for confirmations.    This is why I reall think we need to change the standard block time to reduce variances.
Confirmations should be needed for amounts more than $100. Changing block times aren't easy and it would reduce the security of the network, increasing orphan blocks. A 5 minutes block would need 2 blocks to provide the same level of consensus as 10 minute blocks and it would require a hard fork to reduce block time. Varience can't be eliminated. Even with shorter block time, blocks can still reach 30 minutes per.

Regardless of block time, unconfirmed transactions could be lasting way more than 10 minutes op is talking about, since block time varies, and also in
cases like the blockchain spam attack (some call it "testing"). But in any way, confirmations should be the only reason to take the transaction seriously.

cheers


Title: Re: Double spending within ten minutes
Post by: Snorek on August 02, 2015, 12:02:03 PM
Double spending is not problem of the ordinary bitcoin users. It is rather like bitcoin companies are penalized for double spending.
And it is totally possible for bitcoin network to process confirmatin much faster. however, it is not feasible for bitcoin's code to be adjusted to make confirmations quicker.


Title: Re: Double spending within ten minutes
Post by: ranochigo on August 02, 2015, 02:28:21 PM
This must have been asked before but I can't find an answer.

SCENARIO:  It takes ten minutes to add a new block of data to the blockchain.  Larry has one bitcoin.  He goes to the mall and within one ten minute period between blocks:

1) Larry spends most of his bitcoin at a computer store.
2) Larry runs next door to a jewelry store, where he again spends most of his bitcoin.

Obviously this can't happen.  What is the mechanism that prevents double spending within the ten minutes between blocks?

Thanks.

Yes, confirmations are needed.   It is not advisable to sell product for bitcoin without waiting for confirmations.    This is why I reall think we need to change the standard block time to reduce variances.
Confirmations should be needed for amounts more than $100. Changing block times aren't easy and it would reduce the security of the network, increasing orphan blocks. A 5 minutes block would need 2 blocks to provide the same level of consensus as 10 minute blocks and it would require a hard fork to reduce block time. Varience can't be eliminated. Even with shorter block time, blocks can still reach 30 minutes per.

Regardless of block time, unconfirmed transactions could be lasting way more than 10 minutes op is talking about, since block time varies, and also in
cases like the blockchain spam attack (some call it "testing"). But in any way, confirmations should be the only reason to take the transaction seriously.

cheers
In the future, blockchain spamming costs would be much more expensive than now due to the increased block size. More transactions are able to be confirmed. The spam just shows that a simple 0.0001BTC fee can easily get your transaction confirmed within several blocks. Confirmations aren't that necessary for brick and mortar stores. After all, the risk of accepting a counterfeit note and getting charged back is much higher compared to accepting a transaction after it has fulfilled serveral requirements set by the owner.