electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 43eb33327ef066a6a1ee7b79ae4ccca6b285ba5d
parent 50cc603d914710c3008dc37305ed05fc68777927
Author: SomberNight <somber.night@protonmail.com>
Date:   Thu, 17 May 2018 15:52:02 +0200

PathFinder: change path element semantics from "from node, take edge" to "to get to node, use edge"

Diffstat:
Mlib/lnbase.py | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/lnbase.py b/lib/lnbase.py @@ -18,7 +18,7 @@ import time import binascii import hashlib import hmac -from typing import Sequence, Union +from typing import Sequence, Union, Tuple import cryptography.hazmat.primitives.ciphers.aead as AEAD from cryptography.hazmat.primitives.ciphers import Cipher, algorithms from cryptography.hazmat.backends import default_backend @@ -1480,11 +1480,12 @@ class LNPathFinder(PrintError): @profiler def find_path_for_payment(self, from_node_id: bytes, to_node_id: bytes, - amount_msat: int=None) -> Sequence[bytes, bytes]: + amount_msat: int=None) -> Sequence[Tuple[bytes, bytes]]: """Return a path between from_node_id and to_node_id. Returns a list of (node_id, short_channel_id) representing a path. - To get from node ret[n][0] to ret[n+1][0], use channel ret[n][1] + To get from node ret[n][0] to ret[n+1][0], use channel ret[n+1][1]; + i.e. an element reads as, "to get to node_id, travel through short_channel_id" """ # TODO find multiple paths?? @@ -1519,10 +1520,11 @@ class LNPathFinder(PrintError): # backtrack from end to start cur_node = to_node_id - path = [(cur_node, None)] + path = [] while cur_node != from_node_id: - cur_node, edge_taken = prev_node[cur_node] + prev_node_id, edge_taken = prev_node[cur_node] path += [(cur_node, edge_taken)] + cur_node = prev_node_id path.reverse() return path