to explain LN channels(hop)..
firstly ill display this image and then explain it
first some people think anyone can set up a channel with a click and remain permissionless(#1).. wrong!
you have to set it up WITH ANOTHER PARTY (#2) !! permissioned as you need their signature to sign off on payments !!
next you cant just instantly pay anyone. for instance A cant just pay E,
you need to have to find a route to the intended 'anyone' by finding a path of channels that can link you to the intended party.
this involves some parties having more than one channel open (#3) as you can see B has 2, C has 2, D has 2..
next is the funding..
A doesnt just fund E.. A has to pass funds to B(plus a fee) in the A_B channel... B then needs to use a separate channel B_C with separate funding to fund C, and so on. (#4)
this means with a cap per channel of lets say 0.1btc
B needs to deposit 0.1 into 2 channels
C needs to deposit 0.1 into 2 channels and so on
now, with many channels available and channels having funds, this then allows a path (route)(#5) to be established from A to E
now lets say A wants to pay E
we will start with the blank slate(#6)
imagine A wants to pay E 0.01btc... and each 'hop' cost 0.001 fee to thank each person of the route for participating.
(dont knit pick the fee or take it literally. i chose 0.001 randomly for demo purposes only, i simply couldnt be arsed to do lengthy decimals to show a very small fee)as you can see in(#7) A has worked out it would cost him 0.003 in fee's to get to E and so A passed 0.013 to B
B in A_B is where B's 0.001 fee remains.
in (#8) B using the separate stash knows its going to cost him 0.002 in fee's to get to E and so B passed 0.012 to C
C in B_C is where C's 0.001 fee remains.
in (#9) C using the separate stash knows its going to cost him 0.001 in fee's to get to E and so C passed 0.011 to D
D in B_C is where C's 0.001 fee remains.
in (#10) D using the separate stash passes 0.011 to E
D in D_D is where D's 0.001 fee remains.
which when if they all closed channels and totalled up their holdings
(#11) A=0.087 B=0.101 C=0.101 D=0.101 E=0.110
which means the guys in the middle are 0.001(fee) in profit from acting as routes(hops) and E has the 0.01 which indirectly came from A
because A is down by 0.01... (and down by 0.003 for the fee's)
all that the mainnet chain see's to set up the channels is the 8 transactions (into a channel) to set up the 4 channels (2 tx per channel)
as shown by the arrows in (#5)
A(0.1)->A_B B(0.1)->A_B B(0.1)->B_C C(0.1)->B_C
C(0.1)->C_D D(0.1)->C_D D(0.1)->D_E E(0.1)->D_E
and 4 final transactions when closing the channels
A_B(0.2)->A(0.087)B(0.103) B_C(0.2)->B(0.088)C(0.102)
C_D(0.2)->C(0.089)B(0.101) D_E(0.2)->B(0.09)C(0.110)
which when if they all closed channels and totalled up their holdings
(#11) A=0.087 B=0.101 C=0.101 D=0.101 E=0.110
which means the guys in the middle are 0.001(fee) in profit from acting as routes(hops) and E has the 0.01 which indirectly came from A
because A is down by 0.01... (and down by 0.003 for the fee's)
the steps #7 to #10 are funds moved all off chain.. never seen by the mainnet chain
and funds can move back and forth as many times as possible off chain as long as:
the channels have enough funds to work as a route for the particular payment
and
there are enough channels to link/create a route