Trampoline routing.
- trampoline is enabled by default in config, to prevent download of `gossip_db`.
(if disabled, `gossip_db` will be downloaded, regardless of the existence of channels)
- if trampoline is enabled:
- the wallet can only open channels with trampoline nodes
- already-existing channels with non-trampoline nodes are frozen for sending.
- there are two types of trampoline payments: legacy and end-to-end (e2e).
- we decide to perform legacy or e2e based on the invoice:
- we use trampoline_routing_opt in features to detect Eclair and Phoenix invoices
- we use trampoline_routing_hints to detect Electrum invoices
- when trying a legacy payment, we add a second trampoline to the path to preserve privacy.
(we fall back to a single trampoline if the payment fails for all trampolines)
- the trampoline list is hardcoded, it will remain so until `trampoline_routing_opt` feature flag is in INIT.
- there are currently only two nodes in the hardcoded list, it would be nice to have more.
- similar to Phoenix, we find the fee/cltv by trial-and-error.
- if there is a second trampoline in the path, we use the same fee for both.
- the final spec should add fee info in error messages, so we will be able to fine-tune fees
This commit is contained in:
@@ -359,22 +359,25 @@ class Network(Logger, NetworkRetryManager[ServerAddr]):
|
||||
def has_channel_db(self):
|
||||
return self.channel_db is not None
|
||||
|
||||
def init_channel_db(self):
|
||||
if self.channel_db is None:
|
||||
from . import lnrouter
|
||||
from . import channel_db
|
||||
def start_gossip(self):
|
||||
from . import lnrouter
|
||||
from . import channel_db
|
||||
from . import lnworker
|
||||
if not self.config.get('use_gossip'):
|
||||
return
|
||||
if self.lngossip is None:
|
||||
self.channel_db = channel_db.ChannelDB(self)
|
||||
self.path_finder = lnrouter.LNPathFinder(self.channel_db)
|
||||
self.channel_db.load_data()
|
||||
|
||||
def start_gossip(self):
|
||||
if self.lngossip is None:
|
||||
from . import lnworker
|
||||
self.lngossip = lnworker.LNGossip()
|
||||
self.lngossip.start_network(self)
|
||||
|
||||
def stop_gossip(self):
|
||||
self.lngossip.stop()
|
||||
if self.lngossip:
|
||||
self.lngossip.stop()
|
||||
self.lngossip = None
|
||||
self.channel_db.stop()
|
||||
self.channel_db = None
|
||||
|
||||
def run_from_another_thread(self, coro, *, timeout=None):
|
||||
assert self._loop_thread != threading.current_thread(), 'must not be called from network thread'
|
||||
|
||||
Reference in New Issue
Block a user