1
0

lnworker: add/fix some type hints, add some comments

follow-up recent refactor
This commit is contained in:
SomberNight
2023-11-20 11:34:56 +00:00
parent 1cc92d4890
commit 4cdd199f5b
3 changed files with 44 additions and 29 deletions

View File

@@ -66,13 +66,15 @@ hex_to_bytes = lambda v: v if isinstance(v, bytes) else bytes.fromhex(v) if v is
json_to_keypair = lambda v: v if isinstance(v, OnlyPubkeyKeypair) else Keypair(**v) if len(v)==2 else OnlyPubkeyKeypair(**v)
def serialize_htlc_key(scid:bytes, htlc_id: int):
def serialize_htlc_key(scid: bytes, htlc_id: int) -> str:
return scid.hex() + ':%d'%htlc_id
def deserialize_htlc_key(htlc_key:str):
def deserialize_htlc_key(htlc_key: str) -> Tuple[bytes, int]:
scid, htlc_id = htlc_key.split(':')
return bytes.fromhex(scid), int(htlc_id)
@attr.s
class OnlyPubkeyKeypair(StoredObject):
pubkey = attr.ib(type=bytes, converter=hex_to_bytes)