From
http://www.cryptocoinsnews.com/news/the-mathematically-secure-way-to-accept-zero-confirmation-transactions/2014/02/13, here is what services like MyCelium and BitPay may be doing:
More specifically, with every additional second a larger percentage of active Bitcoin nodes will have heard the original transaction and everyone viewing the blockchain can be increasingly certain that the transaction will be mined in the next block and receive one confirmation, then two, and so on and so forth.
What this means is that any Bitcoin transaction can be accepted with zero confirmations with a mathematically derived confidence level some refer to as “Transaction Confidence.” This transaction confidence measure assures us that even if a double spend were attempted the original and correct transaction is already too heavily propagated to be overtaken.
But as you aptly noted, there is no 100% risk-free way of being able to do this if you don't trust the sender. That's why the blockchain exists in the first place.
One risk of relying on "transaction confidence" is that there's nothing in the network that prevents someone from submitting a double-spend transaction directly to the miners, without broadcasting it to the network as a whole, under the agreement that any blocks that those miners find should pick their secret one instead of the one they broadcast to the network. This is a risk no matter how much of the network sees the public transaction, which is one of the reasons why you can't have 100% confidence in a transaction that has never made it into a block.
In particular, if you accept a 0-confirmation transaction that spends inputs from other 0-confirmation transactions, the risk is much greater, because either the transaction directly to you or any of its 0-confirmation inputs could be double-spent, to your detriment.
Frankly, even 1-confirmation transactions aren't risk-free. Even under normal circumstances, blocks get orphaned, which could create a window for double-spending, because the winning branch may not resolve the transactions the way that the losing branch did.
If you're serious about trying to minimize the risks of accepting BTC in "real-life" (a.k.a., brick-and-mortar) situations where speed is important, I can't think of a better idea than going with a service like Coinbase (no affiliation). Those services operate on a scale where they can afford to eat losses from double-spends, which should be rare, so that you don't have to worry about it. Currently, they have an economic incentive to increase adoption of the currency by being very attractive to merchants who choose to do so.
For selling a cup of coffee, a soda or sandwiches - I believe other coins (as Ripple, 42coin or even Dogecoin) would be more appropriate for this: I can very well see people waiting for up to 2 minutes, but no more, at which point your risk is enormously reduced. – Joe Pineda – 2014-04-29T02:18:35.437
3
I'm currently trying to solve the same problem with connecting to as many nodes as possible in order to detect a possible double spend in a few seconds. Just to correct your assumption a bit: 3.) a transaction coming from the same input address to a different output address does not necessarily mean double spend if it spends different TXOUTs. Therefore you should only look for transactions spending the same TXOUT, but sending it to a different address.
– Jozef – 2014-04-27T22:24:24.3703@JoePineda Let's just picture that in detail for a moment: You are at your favorite coffee shop, in line to get a cup of coffee and donuts (or similar). Behind you there are five more people waiting. Everyone just wants to grab something and rush on to work. 10 minutes certainly are a no-go, but even two minutes standing there watching half a dozen people grab their stuff and go on with their morning are unacceptable. – Murch – 2014-05-02T06:19:14.250
1Good point! I myself am willing to wait up to about 2 minutes at the counter - once I'm in front of the clerk, that is. But am not willing to spend more than 3 minutes altogether, summing those in line plus at the clerk, and I guess most people wouldn't either :( – Joe Pineda – 2014-05-03T21:13:02.557
@JoePineda, 10 seconds is the threshold of tolerance. Don't forget that it's not just 10 secs/customer but an extra 10 secs/customer, in addition to the 20 seconds we already have to wait while the cashier scans the item. – Pacerier – 2014-05-23T16:26:21.193
@RocketNuts, What's wrong with BitUndo? – Pacerier – 2014-05-24T08:05:53.787
@Pacerier it includes in the block a transaction with higher fee, not the first one. That makes them a good processor for double spends. – jangorecki – 2015-08-29T10:35:06.230