1
0

encapsulate get_routing_info in lnaddr

This commit is contained in:
ThomasV
2021-02-07 12:21:00 +01:00
parent 0c93394513
commit 4febbcdc2d
2 changed files with 12 additions and 8 deletions

View File

@@ -8,6 +8,7 @@ from binascii import hexlify
from decimal import Decimal
from typing import Optional
import random
import bitstring
from .bitcoin import hash160_to_b58_address, b58_address_to_hash160
@@ -282,6 +283,16 @@ class LnAddr(object):
return None
return self.amount * COIN
def get_routing_info(self, tag):
# note: tag will be 't' for trampoline
r_tags = list(filter(lambda x: x[0] == tag, self.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)
return r_tags
def get_amount_msat(self) -> Optional[int]:
if self.amount is None:
return None