diff --git a/contrib/pyln-proto/pyln/proto/__init__.py b/contrib/pyln-proto/pyln/proto/__init__.py index a90ac9940..ce4d2abea 100644 --- a/contrib/pyln-proto/pyln/proto/__init__.py +++ b/contrib/pyln-proto/pyln/proto/__init__.py @@ -1,4 +1,5 @@ from .bech32 import bech32_decode +from .primitives import ShortChannelId, PublicKey from .invoice import Invoice from .onion import OnionPayload, TlvPayload, LegacyOnionPayload from .wire import LightningConnection, LightningServerSocket @@ -13,4 +14,6 @@ __all__ = [ "LegacyOnionPayload", "TlvPayload", "bech32_decode", + "ShortChannelId", + "PublicKey", ] diff --git a/contrib/pyln-proto/pyln/proto/primitives.py b/contrib/pyln-proto/pyln/proto/primitives.py index 418f52212..151424b86 100644 --- a/contrib/pyln-proto/pyln/proto/primitives.py +++ b/contrib/pyln-proto/pyln/proto/primitives.py @@ -85,6 +85,9 @@ class ShortChannelId(object): and self.outnum == other.outnum ) + def __hash__(self): + return self.to_int().__hash__() + class Secret(object): def __init__(self, data: bytes) -> None: @@ -147,6 +150,15 @@ class PublicKey(object): self.serializeCompressed().hex() ) + def __eq__(self, other: object) -> bool: + if not isinstance(other, PublicKey): + return False + + return self.key == other.key + + def __hash__(self): + return self.to_bytes().__hash__() + def Keypair(object): def __init__(self, priv, pub):