<p>Payment channels are a way to prevent double spending in such cases. As per the <a href="https://en.bitcoin.it/wiki/Payment_channels" rel="nofollow noreferrer">Wiki</a></p>

<blockquote>
  <p>A Micropayment Channel or Payment Channel is class of techniques designed to allow users to make multiple Bitcoin transactions without commiting all of the transactions to the Bitcoin block chain.[1] In a typical payment channel, only two transactions are added to the block chain but an unlimited or nearly unlimted number of payments can be made between the participants. </p>
</blockquote>

<p>A possible way for implementing vending machines would involve creating payment channels beforehand with the vending machine company. </p>

<p>Infact, for the vending machine case, an unidirectional channel would suffice. Refer to <a href="https://en.bitcoin.it/wiki/Payment_channels" rel="nofollow noreferrer">Wiki</a> for details. Bi-directional payment channels using hashlocks are the key to Lightning network which is used to facilitate off-chain transactions at real-time.</p>

CC BY-SA 3.0
2017-05-08T05:43:50.570Z
This is my first stackoverflow answer, please point if I anything needs more elaboration/or is not correct
sanket1729
CC BY-SA 3.0
2017-05-08T05:41:59.130Z
2017-05-08T05:41:59.130Z
sanket1729
<blockquote>
  <p>If a transaction takes anywhere from around 10 minutes to hours to get written to a block and put on the chain</p>
</blockquote>

<p>Just to have that said: if a proper fee is set, it can be ensured that the transaction will get confirmed within the next block.</p>

<p><em>Back to the question merit:</em> Performing a double-spending attack is <strong>very</strong> costly after the transaction has been propagated through the network. There is some risk, but there is some also when accepting cash or credit cards and the vending machines can be often enough fooled with tokens resembling the weight and size of a real coin. There are places, both online and physical that accept small unconfirmed transaction if they are valid, have a proper fee and are already propagated.</p>

<p>Additionaly, there are services such as Coinbase, that additionaly verify transactions between their users. If the transaction occurs between Coinbase accounts, it can be even more sure to appear in the blockchain, even if it isn't yet confirmed.</p>

CC BY-SA 3.0
2017-08-06T08:40:50.663Z
2017-08-06T08:40:50.663Z
Hubert Jasieniecki
<p>If a transaction takes anywhere from around 10 minutes to hours to get written to a block and put on the chain, how is it possible to have things like bitcoin vending machines? In those cases, the transaction would have to be near instantaneous to make it practical.</p>

CC BY-SA 3.0
2017-05-08T16:25:56.003Z
A vending machine doesn't have to worry about an attack that costs $50 to pull off.
David Schwartz
CC BY-SA 3.0
2017-05-09T16:11:35.123Z
@DavidSchwartz, can you explain that attack in more detail, or point me to some references?
sager89
CC BY-SA 3.0
2017-05-09T16:18:47.757Z
Check [here](https://en.bitcoin.it/wiki/Double-spending#Finney_attack) or punch "Finney attack" into your favorite search engine.
David Schwartz
<transactions><unconfirmed-transactions>
Bitcoin Transaction Speed
sager89
# Bitcoin Transaction Speed

(Asked by: username_0 on 2017-05-07)

If a transaction takes anywhere from around 10 minutes to hours to get written to a block and put on the chain, how is it possible to have things like bitcoin vending machines? In those cases, the transaction would have to be near instantaneous to make it practical.

**Tags:** transactions, unconfirmed-transactions

> **Comments:**
> **username_1**: A vending machine doesn't have to worry about an attack that costs $50 to pull off.  
> **username_0**: @username_1, can you explain that attack in more detail, or point me to some references?  
> **username_1**: Check [here](https://en.bitcoin.it/wiki/Double-spending#Finney_attack) or punch "Finney attack" into your favorite search engine.  

---

## 2 answers

### Answer by username_2 on 2017-05-08. Score: 1

Payment channels are a way to prevent double spending in such cases. As per the [Wiki](https://en.bitcoin.it/wiki/Payment_channels)

> A Micropayment Channel or Payment Channel is class of techniques designed to allow users to make multiple Bitcoin transactions without commiting all of the transactions to the Bitcoin block chain.[1] In a typical payment channel, only two transactions are added to the block chain but an unlimited or nearly unlimted number of payments can be made between the participants.

A possible way for implementing vending machines would involve creating payment channels beforehand with the vending machine company.

Infact, for the vending machine case, an unidirectional channel would suffice. Refer to [Wiki](https://en.bitcoin.it/wiki/Payment_channels) for details. Bi-directional payment channels using hashlocks are the key to Lightning network which is used to facilitate off-chain transactions at real-time.

> **Comments:**
> **username_2**: This is my first stackoverflow answer, please point if I anything needs more elaboration/or is not correct  

---

### Answer by username_3 on 2017-08-06. Score: 0

> If a transaction takes anywhere from around 10 minutes to hours to get written to a block and put on the chain

Just to have that said: if a proper fee is set, it can be ensured that the transaction will get confirmed within the next block.

*Back to the question merit:* Performing a double-spending attack is **very** costly after the transaction has been propagated through the network. There is some risk, but there is some also when accepting cash or credit cards and the vending machines can be often enough fooled with tokens resembling the weight and size of a real coin. There are places, both online and physical that accept small unconfirmed transaction if they are valid, have a proper fee and are already propagated.

Additionaly, there are services such as Coinbase, that additionaly verify transactions between their users. If the transaction occurs between Coinbase accounts, it can be even more sure to appear in the blockchain, even if it isn't yet confirmed.


---

