lnworker: fix some type hints re hold_invoices
This commit is contained in:
@@ -11,7 +11,7 @@ import operator
|
||||
import enum
|
||||
from enum import IntEnum, Enum
|
||||
from typing import (Optional, Sequence, Tuple, List, Set, Dict, TYPE_CHECKING,
|
||||
NamedTuple, Union, Mapping, Any, Iterable, AsyncGenerator, DefaultDict, Callable)
|
||||
NamedTuple, Union, Mapping, Any, Iterable, AsyncGenerator, DefaultDict, Callable, Awaitable)
|
||||
import threading
|
||||
import socket
|
||||
import aiohttp
|
||||
@@ -842,8 +842,8 @@ class LNWallet(LNWorker):
|
||||
self.final_onion_forwarding_failures = {} # todo: should be persisted
|
||||
# map forwarded htlcs (fw_info=(scid_hex, htlc_id)) to originating peer pubkeys
|
||||
self.downstream_htlc_to_upstream_peer_map = {} # type: Dict[Tuple[str, int], bytes]
|
||||
# payment_hash -> callback, timeout:
|
||||
self.hold_invoice_callbacks = {} # type: Dict[bytes, Tuple[Callable[[bytes], None], int]]
|
||||
# payment_hash -> callback:
|
||||
self.hold_invoice_callbacks = {} # type: Dict[bytes, Callable[[bytes], Awaitable[None]]]
|
||||
self.payment_bundles = [] # lists of hashes. todo:persist
|
||||
self.swap_manager = SwapManager(wallet=self.wallet, lnworker=self)
|
||||
|
||||
@@ -2070,7 +2070,7 @@ class LNWallet(LNWorker):
|
||||
info = PaymentInfo(payment_hash, lightning_amount_sat * 1000, RECEIVED, PR_UNPAID)
|
||||
self.save_payment_info(info, write_to_disk=False)
|
||||
|
||||
def register_callback_for_hold_invoice(self, payment_hash: bytes, cb: Callable[[bytes], None]):
|
||||
def register_callback_for_hold_invoice(self, payment_hash: bytes, cb: Callable[[bytes], Awaitable[None]]):
|
||||
self.hold_invoice_callbacks[payment_hash] = cb
|
||||
|
||||
def save_payment_info(self, info: PaymentInfo, *, write_to_disk: bool = True) -> None:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import asyncio
|
||||
from collections import defaultdict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from aiohttp import web
|
||||
|
||||
@@ -9,6 +10,11 @@ from electrum.logging import Logger
|
||||
from electrum.util import EventListener
|
||||
from electrum.lnaddr import lndecode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from electrum.simple_config import SimpleConfig
|
||||
from electrum.wallet import Abstract_Wallet
|
||||
|
||||
|
||||
class SwapServer(Logger, EventListener):
|
||||
"""
|
||||
public API:
|
||||
@@ -18,7 +24,7 @@ class SwapServer(Logger, EventListener):
|
||||
|
||||
WWW_DIR = os.path.join(os.path.dirname(__file__), 'www')
|
||||
|
||||
def __init__(self, config, wallet):
|
||||
def __init__(self, config: 'SimpleConfig', wallet: 'Abstract_Wallet'):
|
||||
Logger.__init__(self)
|
||||
self.config = config
|
||||
self.wallet = wallet
|
||||
|
||||
@@ -361,7 +361,7 @@ class SwapManager(Logger):
|
||||
callback = lambda: self._claim_swap(swap)
|
||||
self.lnwatcher.add_callback(swap.lockup_address, callback)
|
||||
|
||||
async def hold_invoice_callback(self, payment_hash):
|
||||
async def hold_invoice_callback(self, payment_hash: bytes) -> None:
|
||||
# note: this assumes the keystore is not encrypted
|
||||
key = payment_hash.hex()
|
||||
if key in self.swaps:
|
||||
|
||||
Reference in New Issue
Block a user