diff --git a/electrum/lnonion.py b/electrum/lnonion.py index 07385151a543..f3db1c1aa9f1 100644 --- a/electrum/lnonion.py +++ b/electrum/lnonion.py @@ -175,7 +175,7 @@ def get_shared_secrets_along_route(payment_path_pubkeys: Sequence[bytes], def get_shared_secrets_along_route2(payment_path_pubkeys_plus: Sequence[Union[bytes, Tuple[bytes, bytes]]], - session_key: bytes) -> tuple[Sequence[bytes], Sequence[bytes]]: + session_key: bytes) -> Tuple[Sequence[bytes], Sequence[bytes]]: num_hops = len(payment_path_pubkeys_plus) hop_shared_secrets = num_hops * [b''] hop_blinded_node_ids = num_hops * [b''] @@ -251,7 +251,7 @@ def new_onion_packet( def new_onion_packet2( - payment_path_pubkeys: Sequence[Union[bytes, tuple]], + payment_path_pubkeys: Sequence[Union[bytes, Tuple[bytes, bytes]]], session_key: bytes, hops_data: Sequence[OnionHopsDataSingle], *, @@ -374,7 +374,7 @@ def process_onion_packet( onion_packet: OnionPacket, our_onion_private_key: bytes, *, - associated_data: bytes = bytes(), + associated_data: bytes = b'', is_trampoline=False, tlv_stream_name='payload') -> ProcessedOnionPacket: if not ecc.ECPubkey.is_pubkey_bytes(onion_packet.public_key): diff --git a/electrum/onion_message.py b/electrum/onion_message.py index 5982d094f892..68894a714439 100644 --- a/electrum/onion_message.py +++ b/electrum/onion_message.py @@ -37,6 +37,7 @@ if TYPE_CHECKING: from electrum.lnworker import LNWallet + from electrum.network import Network logger = get_logger(__name__) diff --git a/tests/test_bolt12.py b/tests/test_bolt12.py index 7af2e66d6736..8b6e75fc5729 100644 --- a/tests/test_bolt12.py +++ b/tests/test_bolt12.py @@ -272,8 +272,15 @@ def test_serde_complex_fields(self): ]} } - with self.assertRaises(Exception): + # assertRaises on generic Exception used in lnmsg encode/write_tlv_stream makes flake8 complain + # so work around this for now (TODO: refactor lnmsg generic exceptions) + #with self.assertRaises(Exception): + try: invreq_pl_tlv = encode_invoice_request(invreq, payer_key=payer_key) + except Exception as e: + pass + else: + raise Exception('Exception expected') # test complex field count matches parameters invreq = {