lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.56k stars 2.06k forks source link

invoices lacking routing hints, made from zero_conf channels, yield "NO_ROUTE" on payment attempts in first few minutes of the channel's life #8830

Closed MegalithicBTC closed 4 weeks ago

MegalithicBTC commented 4 weeks ago

I'm running 0.18-beta.

I have a node setup to receive 0-conf payments on MutinyNet, using bos --node=mutinynet inbound-channel-rules --trust-funding-from [sending channel public key.]

This is working well, But I am finding this consistent behavior: An invoice generated on the receiving node with the command lncli addinvoice can't be paid within roughly the first 3 (three) minutes following the opening of the channel.

Attempts to pay to the receiving node from any other node yield "NO_ROUTE"

I am however finding that invoices generated with the --private flag CAN be paid immediately.

So I am guessing what is going on is that information about the channel has simply not yet propagated to the network during this time, and 0-conf channels simply are not useable in the first few minutes unless an invoice provides route hints?

I am unclear whether this would be considered a bug in LND, or rather, this is just a feature of the network -- if you want to reach a very new channel, do you need to provide route hints in the invoice? --In the case of 0-conf, we are talking about a channel that potentially opened, without any confirmations, in the last 20 seconds....

Here is the timeline.. immediately after the channel opens, I see this in listchannels

"zero_conf": true, "zero_conf_confirmed_scid": "0"

... and then about 2 minutes later it goes to...

"zero_conf": true, "zero_conf_confirmed_scid": "931832806179471360"

During this time, invoices created without the --private flag can NOT be paid -- i.e., route hints seem to be required.

.... and then about 30 to 60 seconds after the zero_conf_confirmed_scid populates, invoices without route hints CAN be paid.

Again, I don't know enough to say if this is a bug with LND or just a general feature of the network.

Thanks

saubyk commented 4 weeks ago

Hi @MegalithicBTC, what you're observing is not a bug but expected behavior.

Zero conf channel is active for payments only between the peer nodes, as long as the channel opening transaction is not confirmed. The zero conf channel is not gossiped i.e. other nodes don't know about it, until the transaction is confirmed. Since the channel is not gossiped, if you want a 3rd node to pay, you'll have to provide the hop hint.

Once the transaction is confirmed, you see the value of zero_conf_confirmed_scid populated. After this, the channel is gossiped on the graph and other nodes learn about this channel. Then any node should be able to pay using this channel.

Hope this helps. Closing this issue now. Thanks.

MegalithicBTC commented 4 weeks ago

@saubyk thanks for the clear explanation. You wrote

Once the transaction is confirmed, you see the value of zero_conf_confirmed_scid populated

So my question is, is it possible for my node, and my peer's node, to influence at what point the network thinks that the transaction is confirmed?

We've set protocol.zero-conf=true .. but if we also set, for example bitcoin.defaultchanconfs=1 ... (and maybe our peer set the same value in their configuration?) .... then would that "convince" the network that the channel could be gossiped after just one confirmation, instead of the default 3 to 6?

So put another way -- for the best results with zero-conf channels, to increase the usability of the channel for features like keysend immediately, should we be setting any values in the lnd.conf in addition to protocol.zero-conf=true and protocol.option-scid-alias=true ?

Our specific goal is to get Keysends (which don't allow routing hints) working, as soon as possible.

thanks

saubyk commented 4 weeks ago

Regardless of the value that can be set for bitcoin.defaultchanconfs, there is no config option to control when the channel will be gossiped.

bitcoin.defaultchanconfs can determine how soon the channel can be active after confirmation, as in ready to transact, but the gossip propagation of channel is determined by the protocol specification, which a user cannot influence.

Basically, the protocol dictates that it's unsafe to let the network know about your channel, until a certain minimum block height of transaction confirmation is reached.

MegalithicBTC commented 4 weeks ago

Great, thanks for the explanation. For future searchers who find this discussion, I am linking here the relevant requirements in BOLT7: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#requirements

A node:

  • if the open_channel message has the announce_channel bit set AND a shutdown message has not been sent:
    • MUST send the announcement_signatures message.
      • MUST NOT send announcement_signatures messages until channel_ready has been sent and received AND the funding transaction has at least six confirmations.