<p>The two channel owners have cooperatively locked up a sum of Bitcoin in a 2-of-2 multisig address.</p>

<p>The only thing that they can do, is to renegotiate how much each of their balance shares is. This is what happens when they send funds in Lightning: the sender offers to increase the balance share of the recipient and at the cost of reducing their own.</p>

<p>Likewise, when you attempt a multi-hop payment, you offer a conditional smart contract to your channel partner. Your channel partner gets to increase their channel balance share at your cost, when they prove to you that they have forwarded the sent sum to the recipient.</p>

<p>Since the sum of the two balance shares can never exceed the channel capacity, nobody can ever send more money than their balance share: Their channel partner would simply deny the payment attempt.</p>

CC BY-SA 3.0
2018-04-12T20:37:01.100Z
2018-04-12T20:37:01.100Z
Murch
<p>When A and B have a channel with each other, those funds are locked up in that channel. They are locked up because an on-chain transaction has occurred which pays the funds for that channel to a 2-of-2 multisig output that requires A and B to both sign in order for the funds to leave the channel.</p>

CC BY-SA 3.0
2017-09-01T03:43:52.190Z
In my example, A, B and C each have a channel open with D. Won't it be possible for D to pay the set-up cost for those channels?
Todd Freed
CC BY-SA 3.0
2017-09-01T03:53:44.660Z
Yes, so? A can't double spend his coins because they are still locked in a channel. The only way he could pay C 6 Bitcoin after paying B 6 Bitcoin is if he has 6 or more Bitcoin remaining on his side of his channel with D, or has some other payment channel with someone else where he has 6 or more Bitcoin and can route a payment to C.
Ava Chow
CC BY-SA 3.0
2017-09-01T04:40:37.093Z
But how does anyone know A's coins are locked in the channel, if D paid the funding transaction for the channel? On-chain, A hasn't spent anything. A has a channel open, sure, but that's all anyone outside the channel knows about it.
Todd Freed
CC BY-SA 3.0
2017-09-01T05:11:36.193Z
If A wanted to pay someone and route that payment through D, then D would know about that. If he wanted to "double spend" that payment, D would also know and prevent that from happening. There are only two parties in a payment channel, A and D. The only place money can go to in that channel is either to A or to D, and both will know their respective balances within the channel.
Ava Chow
CC BY-SA 3.0
2017-09-01T06:12:37.603Z
A opens a payment channel and spends all their coins. A opens a second, unrelated payment channel and spends all their coins a second time. What prevents this?
Todd Freed
CC BY-SA 3.0
2017-09-01T06:21:19.413Z
The funds in A's first payment channel are locked in that channel by an on chain transaction. He cannot fund a second payment channel with the same funds because it requires an on chain transaction. The funds cannot leave that channel for something else without another on chain transaction. The same applies if someone else funded the channel: those funds are locked in the channel until it is closed.
Ava Chow
CC BY-SA 3.0
2017-09-01T06:44:58.490Z
Alright. I think I get it. So the most I can ever send over a channel is the amount I contributed to the funding transaction for the channel.
Todd Freed
CC BY-SA 3.0
2017-09-02T17:54:34.027Z
Not really. A could receive money from B in the channel and then send it back to B. He would still be sending money over the channel but did not contribute that amount in the funding. By the closing of the channel the maximum net amount that A and B could have sent over the channel is limited by how much each put into the channel.
Ava Chow
CC BY-SA 3.0
2017-09-01T03:31:51.247Z
2017-09-01T03:31:51.247Z
Ava Chow
<p>Consider the following 3 nodes, A, B and C.</p>

<p>At time t=0, A has 10 bitcoins. A sends 6 bitcoins to B. Then, A attempts to send 6 bitcoins to C.</p>

<p>With on-chain transactions, the second transaction is prevented, because everyone knows A's balance at all times.</p>

<p>How is the second transaction prevented if the first transaction is made on the lightning network?</p>

<p>If we assume that A, B and C are all connected to the same LN hub, called D - and the payments all route through D - then I can see how the double-spend is prevented.</p>

<p>But what if there is no path through LN connecting B and C? Or, there is a path, but A chooses a different route for its second payment compared to the first payment?</p>

<p>Finally, what if the first payment is made via LN, but the second payment is on-chain?</p>

<lightning-network>
How do other nodes know my balance with LN?
Todd Freed
# How do other nodes know my balance with LN?

(Asked by: username_0 on 2017-09-01)

Consider the following 3 nodes, A, B and C.

At time t=0, A has 10 bitcoins. A sends 6 bitcoins to B. Then, A attempts to send 6 bitcoins to C.

With on-chain transactions, the second transaction is prevented, because everyone knows A's balance at all times.

How is the second transaction prevented if the first transaction is made on the lightning network?

If we assume that A, B and C are all connected to the same LN hub, called D - and the payments all route through D - then I can see how the double-spend is prevented.

But what if there is no path through LN connecting B and C? Or, there is a path, but A chooses a different route for its second payment compared to the first payment?

Finally, what if the first payment is made via LN, but the second payment is on-chain?

**Tags:** lightning-network


---

## 2 answers

### Answer by username_1 on 2018-04-12. Score: 1

The two channel owners have cooperatively locked up a sum of Bitcoin in a 2-of-2 multisig address.

The only thing that they can do, is to renegotiate how much each of their balance shares is. This is what happens when they send funds in Lightning: the sender offers to increase the balance share of the recipient and at the cost of reducing their own.

Likewise, when you attempt a multi-hop payment, you offer a conditional smart contract to your channel partner. Your channel partner gets to increase their channel balance share at your cost, when they prove to you that they have forwarded the sent sum to the recipient.

Since the sum of the two balance shares can never exceed the channel capacity, nobody can ever send more money than their balance share: Their channel partner would simply deny the payment attempt.


---

### Answer by username_2 on 2017-09-01. Score: 0

When A and B have a channel with each other, those funds are locked up in that channel. They are locked up because an on-chain transaction has occurred which pays the funds for that channel to a 2-of-2 multisig output that requires A and B to both sign in order for the funds to leave the channel.

> **Comments:**
> **username_0**: In my example, A, B and C each have a channel open with D. Won't it be possible for D to pay the set-up cost for those channels?  
> **username_2**: Yes, so? A can't double spend his coins because they are still locked in a channel. The only way he could pay C 6 Bitcoin after paying B 6 Bitcoin is if he has 6 or more Bitcoin remaining on his side of his channel with D, or has some other payment channel with someone else where he has 6 or more Bitcoin and can route a payment to C.  
> **username_0**: But how does anyone know A's coins are locked in the channel, if D paid the funding transaction for the channel? On-chain, A hasn't spent anything. A has a channel open, sure, but that's all anyone outside the channel knows about it.  
> **username_2**: If A wanted to pay someone and route that payment through D, then D would know about that. If he wanted to "double spend" that payment, D would also know and prevent that from happening. There are only two parties in a payment channel, A and D. The only place money can go to in that channel is either to A or to D, and both will know their respective balances within the channel.  
> **username_0**: A opens a payment channel and spends all their coins. A opens a second, unrelated payment channel and spends all their coins a second time. What prevents this?  
> **username_2**: The funds in A's first payment channel are locked in that channel by an on chain transaction. He cannot fund a second payment channel with the same funds because it requires an on chain transaction. The funds cannot leave that channel for something else without another on chain transaction. The same applies if someone else funded the channel: those funds are locked in the channel until it is closed.  
> **username_0**: Alright. I think I get it. So the most I can ever send over a channel is the amount I contributed to the funding transaction for the channel.  
> **username_2**: Not really. A could receive money from B in the channel and then send it back to B. He would still be sending money over the channel but did not contribute that amount in the funding. By the closing of the channel the maximum net amount that A and B could have sent over the channel is limited by how much each put into the channel.  

---

