# How do other nodes know my balance with LN?

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?

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.

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.

• 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? Sep 1, 2017 at 3:43
• 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. Sep 1, 2017 at 3:53
• 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. Sep 1, 2017 at 4:40
• 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. Sep 1, 2017 at 5:11
• 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. Sep 1, 2017 at 6:21