make our channels private, and put routing hints in invoices we create
This commit is contained in:
@@ -45,6 +45,9 @@ from .lnutil import LN_GLOBAL_FEATURE_BITS, LNPeerAddr
|
||||
class UnknownEvenFeatureBits(Exception): pass
|
||||
|
||||
|
||||
class NotFoundChanAnnouncementForUpdate(Exception): pass
|
||||
|
||||
|
||||
class ChannelInfo(PrintError):
|
||||
|
||||
def __init__(self, channel_announcement_payload):
|
||||
@@ -126,7 +129,7 @@ class ChannelInfo(PrintError):
|
||||
else:
|
||||
self.policy_node2 = new_policy
|
||||
|
||||
def get_policy_for_node(self, node_id):
|
||||
def get_policy_for_node(self, node_id: bytes) -> 'ChannelInfoDirectedPolicy':
|
||||
if node_id == self.node_id_1:
|
||||
return self.policy_node1
|
||||
elif node_id == self.node_id_2:
|
||||
@@ -271,7 +274,7 @@ class ChannelDB(JsonDB):
|
||||
JsonDB.__init__(self, path)
|
||||
|
||||
self.lock = threading.RLock()
|
||||
self._id_to_channel_info = {}
|
||||
self._id_to_channel_info = {} # type: Dict[bytes, ChannelInfo]
|
||||
self._channels_for_node = defaultdict(set) # node -> set(short_channel_id)
|
||||
self.nodes = {} # node_id -> NodeInfo
|
||||
self._recent_peers = []
|
||||
@@ -340,7 +343,7 @@ class ChannelDB(JsonDB):
|
||||
# number of channels
|
||||
return len(self._id_to_channel_info)
|
||||
|
||||
def get_channel_info(self, channel_id) -> Optional[ChannelInfo]:
|
||||
def get_channel_info(self, channel_id: bytes) -> Optional[ChannelInfo]:
|
||||
return self._id_to_channel_info.get(channel_id, None)
|
||||
|
||||
def get_channels_for_node(self, node_id):
|
||||
@@ -401,7 +404,7 @@ class ChannelDB(JsonDB):
|
||||
channel_info = self._id_to_channel_info.get(short_channel_id, None)
|
||||
if channel_info is None:
|
||||
self.print_error("could not find", short_channel_id)
|
||||
return
|
||||
raise NotFoundChanAnnouncementForUpdate()
|
||||
channel_info.on_channel_update(msg_payload, trusted=trusted)
|
||||
|
||||
def on_node_announcement(self, msg_payload):
|
||||
|
||||
Reference in New Issue
Block a user