lightninglabs / lightning-dev-site

Lightning Network Daemon Developer Site
25 stars 40 forks source link

Stage 1 - Multi-hop payments #14

Closed magomimmo closed 6 years ago

magomimmo commented 6 years ago

After having opened the channel between Charlie and Bob, mined the funding tx (I generated 3 block instead of just 1), created the invoice as Charlie, when I try to send the payment from Alice to Charlie I get the following error:

{
    "payment_error": "unable to find a path to destination",
    "payment_preimage": "",
    "payment_route": null
}

If I send a payment from Bob to Charlie, by having an open payment channel between them, the send payment works as expected.

magomimmo commented 6 years ago

I retried the multi-hop payment from scratch and it's still unable to find a path between Alice and Charlie via Bob. My considerations are the following: In Stage 1 Bob is the only peer without any fund. Could he partecipate in a multi-hop payment without having any fund. Moreover, when Charlie open the channel with Bob, he asked to Bob a commitment of 200.000 satoshi, but he has no funds. How could it partecipate in the multi-hop payment?

Roasbeef commented 6 years ago

At the point where you attempted the multi-hop payment, if you do lncli describegraph, do you see 3 channel advertised? Due to a recent change, the channels are only fully advertised after 6 blocks.

magomimmo commented 6 years ago

Yep. I discovered it this late afternoon by looking at the logs....But there is still something that IMHO is wrong. Bob has no funds in your scenario and the funding tx by Charlie ask for some fund from him.

magomimmo commented 6 years ago

Hi @Roasbeef with 6 confirmations ii works, but I changed the values for the --push_amt to Alice, in such a way that Bob, the hop between Charlie and Alice, has enough funds in his channel with Alice. I'll try to redo this use case with the same values of the tutorial to see if I'm wrong. In such a case I'll close the issue. Thanks for your time.

magomimmo commented 6 years ago

Hi @Roasbeef I confirm that if Bob does not have enough funds in his channel, he can't participate as an hop in the route between Charlie and Alice and this behavior seems to be correct to me. So, this mean that the tutorial has to be updated with correct funds for Bob.

ndeet commented 6 years ago

@magomimmo @Roasbeef I tested everything from scratch. The tutorial works as long as we generate 6 blocks after opening the channels. @magomimmo In my test it does not matter that Bob has no funds initially. I also thought after reading the docs that always both entities need to add funds to the funding tx. But it seems that it is also possible if only one entity adds funds. In the tutorial this is done by Alice and Charlie (Bob never adds any funds to the funding_tx, it seems).

I saw PR https://github.com/lightninglabs/lightning-dev-site/pull/16 is related to this issue but they are not referenced. What I do now. @magomimmo Can you update your PR and only change the block generation to 6

btcctl --simnet --rpcuser=kek --rpcpass=kek generate 6

The other changes, especially for the amounts are not needed imo.

magomimmo commented 6 years ago

@ndeet I'm pretty new to LN, so, I can be deadly wrong.

The following are the original values of the tutorial:

Then

In my understanding this is only possible if Bob participates in a channel where his current balance is more than 200K, but in scenario of the tutorial he only has 10K in the channel with Alice. Unless LN requires that the limit amount for Bob to participate to a new opened channel is the sum of the capacity of all the channels he participates in.

The other this that's is still obscure to me is Who pays for the funding and the closing txs?

magomimmo commented 6 years ago

@ndeet I tested everything from scratch too and you're right even on the fact that Bob does not need to have enough funds on-chain to participate in an off-chain payment channel requiring him funds he does not own neither on_chain and neither off_chain. This is very very weird. I try the following: alice close the channel with bob and charlie close the channel with bob. At the end Bob has 210001K on chain, even if he only received a payment of 10k from Alice. there is something that I do not understand.....

ndeet commented 6 years ago

@magomimmo Interesting, I think I know what is confusing you:

Note that this time, we supplied the --push_amt argument, which specifies the amount of money we want to other party to have at the first channel state. It could be interpreted like you said. But I understand it this way: --push_amt is an initial amount which gets pushed to the other channel entity.

The lncli command help shows this:

--push_amt value the number of satoshis to push to the remote side as part of the initial commitment state (default: 0)

So this could be the reason why after closing the channel bob got this 200000 into his wallet. Maybe @Roasbeef can clarify the use case for this option.

@Roasbeef, can you also give some hints why not both entities are required to make a deposit on opening channels. Bob in our case has no penalty if he acts malicious?

magomimmo commented 6 years ago

@ndeet I dont' know what to say. I'll test what happen when the channel between Charlie and Bob is closed by Bob instead of being closed by Charlie and let you know.

Tested: when Bob close the channel initiated by Charlie with a push amount for him, he gets all of it as well. Weird. The only limitation I see on the push amount value is that it has to be less than the local amount.

BOLT 2 Specification says:

funding_satoshis is the amount the sender is putting into the channel. push_msat is an amount of initial funds that the sender is unconditionally giving to the receiver

The sender is the funder of the channel and the receiver is the fundee. In my understanding at the moment in the specification there is no an open_channel message able to required that both parties participate with their funds for establishing the payment channel. To me it seems that a very useful scenario.is missing.

magomimmo commented 6 years ago

@ndeet @Roasbeef I wrote a major review of the Stage 1 Tutorial thta override the current Stage 1 PR. Could please take a look at it before I push the PR. Here il the link: https://github.com/magomimmo/lightning-dev-site/blob/major-stage-1-review/tutorial/01-lncli.md

Thanks so much to be patient

ndeet commented 6 years ago

Hi @magomimmo thank you, you really did a lot of rewrite and additional information. As the changes are huge and I have some comments about inconsistencies / improvements I would prefer the following.

This way we can have a working tutorial again without much review needed. And on the other hand your improvements can be checked and discussed in a separate issue + PR.

Currently with the changes sitting only in your branch I can't do inline comments (which is possible when there is a PR). I can see the diff here but can't comment: https://github.com/lightninglabs/lightning-dev-site/compare/master...magomimmo:major-stage-1-review

e.g. minor typo like this

btcct.conf is located under ~/.btcctl directory on POSIX OSes and under ~/Library/Application Support/Btcctl directory on MacOS.

--> btcct.conf should be btcctl.conf

And some other things like what the miner is all about etc should be discussed in a separate issue + PR where we can discuss directly on the code.

magomimmo commented 6 years ago

Hi @ndeet I agree. Regarding your comment and fix, just fork my fork. When we're happy with the result we'll submit a separate issue + PR as you said.

Thanks so much for your time and suggestions....

MaxFangX commented 6 years ago

Looks like this is resolved. Thanks for the contributions!