diff --git a/jmclient/jmclient/blockchaininterface.py b/jmclient/jmclient/blockchaininterface.py index a4ef3421d..7e8f8f8da 100644 --- a/jmclient/jmclient/blockchaininterface.py +++ b/jmclient/jmclient/blockchaininterface.py @@ -1,19 +1,18 @@ - -import abc import ast +import binascii import random import sys import time -from typing import Optional, Tuple +from abc import ABC, abstractmethod from decimal import Decimal -import binascii +from typing import Optional, Tuple from twisted.internet import reactor, task -from jmbase import bintohex, hextobin, stop_reactor -import jmbitcoin as btc -from jmclient.jsonrpc import JsonRpcConnectionError, JsonRpcError -from jmclient.configure import jm_single +import jmbitcoin as btc +from jmbase import bintohex, hextobin, stop_reactor from jmbase.support import get_log, jmprint, EXIT_FAILURE +from jmclient.configure import jm_single +from jmclient.jsonrpc import JsonRpcConnectionError, JsonRpcError # an inaccessible blockheight; consider rewriting in 1900 years @@ -21,25 +20,24 @@ log = get_log() -class BlockchainInterface(object): - __metaclass__ = abc.ABCMeta +class BlockchainInterface(ABC): def __init__(self): pass - @abc.abstractmethod + @abstractmethod def is_address_imported(self, addr): """checks that address is already imported""" - @abc.abstractmethod - def is_address_labeled(self, utxo, walletname): + @abstractmethod + def is_address_labeled(self, utxo: dict, walletname: str) -> bool: """checks that UTXO belongs to the JM wallet""" - @abc.abstractmethod + @abstractmethod def pushtx(self, txhex): """pushes tx to the network, returns False if failed""" - @abc.abstractmethod + @abstractmethod def query_utxo_set(self, txouts, includeconfs=False): """ takes a utxo or a list of utxos @@ -49,14 +47,14 @@ def query_utxo_set(self, txouts, includeconfs=False): """ # address and output script contain the same information btw - @abc.abstractmethod + @abstractmethod def estimate_fee_per_kb(self, N): '''Use the blockchain interface to get an estimate of the transaction fee per kb required for inclusion in the next N blocks. ''' - @abc.abstractmethod + @abstractmethod def get_wallet_rescan_status(self) -> Tuple[bool, Optional[Decimal]]: """Returns pair of True/False is wallet currently rescanning and Optional[Decimal] with current rescan progress status.""" diff --git a/jmclient/test/commontest.py b/jmclient/test/commontest.py index 7bdab6f7b..bba00ec5d 100644 --- a/jmclient/test/commontest.py +++ b/jmclient/test/commontest.py @@ -4,6 +4,7 @@ import os import random from decimal import Decimal +from typing import Optional, Tuple from jmbase import (get_log, hextobin, bintohex, dictchanger) @@ -50,6 +51,11 @@ def import_addresses(self, addr_list, wallet_name, restart_cb=None): pass def is_address_imported(self, addr): pass + def is_address_labeled(self, utxo: dict, walletname: str) -> bool: + pass + def get_wallet_rescan_status(self) -> Tuple[bool, Optional[Decimal]]: + pass + def get_current_block_height(self): return 10**6