From a06b49ae40a430c8b197c382c2dc5df6be2e8e3d Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 8 Oct 2018 21:14:56 +0200 Subject: [PATCH] when paying and there are multiple 'r' hints, use one at random --- electrum/lnworker.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index fdca280cb..0e45cf8e6 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -259,9 +259,14 @@ class LNWorker(PrintError): invoice_pubkey = decoded_invoice.pubkey.serialize() # use 'r' field from invoice route = None # type: List[RouteEdge] - for tag_type, data in decoded_invoice.tags: - if tag_type != 'r': continue - private_route = data + # only want 'r' tags + r_tags = list(filter(lambda x: x[0] == 'r', decoded_invoice.tags)) + # strip the tag type, it's implicitly 'r' now + r_tags = list(map(lambda x: x[1], r_tags)) + # if there are multiple hints, we will use the first one that works, + # from a random permutation + random.shuffle(r_tags) + for private_route in r_tags: if len(private_route) == 0: continue border_node_pubkey = private_route[0][0] path = self.network.path_finder.find_path_for_payment(self.node_keypair.pubkey, border_node_pubkey, amount_msat)