Skip to content

Commit

Permalink
Refactor: alphabetical order of imports and abc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kristapsk committed Jun 6, 2023
1 parent b184527 commit 2cc7f21
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
32 changes: 15 additions & 17 deletions jmclient/jmclient/blockchaininterface.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@

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
INF_HEIGHT = 10**8

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
Expand All @@ -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."""
Expand Down
6 changes: 6 additions & 0 deletions jmclient/test/commontest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2cc7f21

Please sign in to comment.