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