Take the 2-minute tour ×
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It's 100% free, no registration required.

I'm trying to setup a way of accepting Bitcoin payments in real life situations, where waiting for confirmations is typically not an option. I understand this is never 100% risk free (especially with crap like bitundo.com around), I just want to minimize the risk.

I've got a Bitcoin Core wallet with a bunch of unused addresses. I show the customer an address, he sends the money, and now I can do a few things: (all automated, i.e. through some kind of application or script)

  1. Check if the (unconfirmed) transaction appears on my own node / in my wallet
  2. Check if the (unconfirmed) transaction appears on sites using online APIs like blockr.io and blockchain.info
  3. Check if I don't see a similar transaction (from the same input address, but to another output address, i.e. a double spend attempt) on either my node or API sites.

If 1 or 2 are OK and 3 doesn't occur for e.g. five to ten seconds, how (un)certain is the transaction at this point?

I noticed that payment providers like bitpay and coinbase can sort of accept payments immediately, how do they tell legit transactions from double spend attempts?

share|improve this question
1  
+1 For bitundo. –  Maciej Mączko Apr 27 at 18:43
2  
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 Knaperek Apr 27 at 22:24
    
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 Apr 29 at 2:18
3  
@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 May 2 at 6:19
    
Good 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 May 3 at 21:13

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer
    
Thanks for the detailed answer. Are miners typically not normal nodes in the sense that they don't relay or propagate transactions to the rest of the network? I mean if I would deliberately send a 'secret' tx to a miner's node (hoping to get that included in the blockchain), wouldn't it get relayed to other nodes as well, thus allowing its presence to be detected on the network? –  RocketNuts Apr 27 at 16:15
    
That's an important distinction to make, and it's subtle. Yes, miners are typically running "normal" nodes, but remember that miners only typically do things to help the network because it furthers their own self-interest. If you have an arrangement with miners to pay them some cut of your double-spend gains, then it's to their advantage to keep your transactions secret until they hit the blockchain. They control the software that they're running, and it's open-source. Heck, miners already run modified node software. Eligius implements CPFP, which isn't in standard node software. –  Joe Amenta Apr 27 at 16:35
    
Would it be feasible to connect to such mining pools (or all major mining pools for that matter), just to see what transactions are supposed to be included? –  RocketNuts Apr 27 at 18:47
1  
@JoeAmenta, But delegating the task to a 3rd party is simply pushing the problem around the table. The question is still valid: How does the 3rd party minimize risk when he accepts zero confirmation payments? –  Pacerier May 23 at 16:30
1  
It's important to note that Coinbase only gives you double-spend protection if you're using their paid "instant-exchange" service which immediately cashes out payments for fiat. If you're keeping the bitcoin in your Coinbase wallet, no such guarantee is provided. (Their documentation is not entirely clear on this, but I just got this clarification from a Coinbase support rep.) –  Chris Martin Oct 8 at 0:25

First of all and most important: do only business with people you trust. That does not mean that you have to have known them for a long period of time, but only that the person that is doing business with you is more likely to optimize his profit if he does not scam you.

I'm not sure about the odds of successfully launching a double spend attack after a x seconds wait, but what you can do is write some software that connects to some of the major mining pools and waits if your transaction (or a malicious double spend attempt transaction) shows up. It would be great if mining pools had a web API for checking which transactions are likely to get included in their next block, but unfortunately they don't. That means that you would have to program such application yourself (I do not know of any existing libraries with this functionality, but enlighten me if they exist).

Finally, you could always work with green addresses. If your partner agrees in trusting some third party, transactions can be cleared instantaneous.

share|improve this answer
1  
Good suggestion about connecting to mining pools. Only doing business with people I trust, or green addresses, are not an option, I'm afraid. It's supposed to accept payment from random customers (i.e. complete strangers). –  RocketNuts Apr 27 at 15:26
    
Then there is no solution, except to connect to many nodes as possible, and especially to mining pools. Just connect as a dummy node and fetch the block they are working on. AFAIS there is no way the pool can cheat on you, if it is decentralized and open, like P2Pool. –  Jori Apr 28 at 11:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.