1
0

lnaddr: add get_features method

This commit is contained in:
SomberNight
2021-03-08 21:36:27 +01:00
parent 196b4c00a3
commit 4069b455d0
4 changed files with 17 additions and 9 deletions

View File

@@ -6,7 +6,7 @@ import time
from hashlib import sha256
from binascii import hexlify
from decimal import Decimal
from typing import Optional
from typing import Optional, TYPE_CHECKING
import random
import bitstring
@@ -17,6 +17,9 @@ from . import constants
from . import ecc
from .bitcoin import COIN
if TYPE_CHECKING:
from .lnutil import LnFeatures
# BOLT #11:
#
@@ -315,6 +318,10 @@ class LnAddr(object):
return None
return int(self.amount * COIN * 1000)
def get_features(self) -> 'LnFeatures':
from .lnutil import LnFeatures
return LnFeatures(self.get_tag('9') or 0)
def __str__(self):
return "LnAddr[{}, amount={}{} tags=[{}]]".format(
hexlify(self.pubkey.serialize()).decode('utf-8') if self.pubkey else None,