diff --git a/jmclient/jmclient/taker_utils.py b/jmclient/jmclient/taker_utils.py index ea03973..c522b87 100644 --- a/jmclient/jmclient/taker_utils.py +++ b/jmclient/jmclient/taker_utils.py @@ -39,7 +39,7 @@ def direct_send(wallet, amount, mixdepth, destaddr, answeryes=False, """ #Sanity checks assert validate_address(destaddr)[0] - assert isinstance(mixdepth, int) + assert isinstance(mixdepth, numbers.Integral) assert mixdepth >= 0 assert isinstance(amount, numbers.Integral) assert amount >=0 diff --git a/jmclient/jmclient/wallet.py b/jmclient/jmclient/wallet.py index d0330da..c00e1cc 100644 --- a/jmclient/jmclient/wallet.py +++ b/jmclient/jmclient/wallet.py @@ -12,6 +12,7 @@ from mnemonic import Mnemonic from hashlib import sha256 from itertools import chain from decimal import Decimal +from numbers import Integral from .configure import jm_single @@ -489,9 +490,9 @@ class BaseWallet(object): def add_utxo(self, txid, index, script, value): assert isinstance(txid, bytes) - assert isinstance(index, int) + assert isinstance(index, Integral) assert isinstance(script, bytes) - assert isinstance(value, int) + assert isinstance(value, Integral) if script not in self._script_map: raise WalletError("Tried to add UTXO for unknown key to wallet.") @@ -1136,7 +1137,7 @@ class BIP32Wallet(BaseWallet): def get_path(self, mixdepth=None, internal=None, index=None): if mixdepth is not None: - assert isinstance(mixdepth, int) + assert isinstance(mixdepth, Integral) if not 0 <= mixdepth <= self.max_mixdepth: raise WalletError("Mixdepth outside of wallet's range.") @@ -1146,7 +1147,7 @@ class BIP32Wallet(BaseWallet): int_type = self._get_internal_type(internal) if index is not None: - assert isinstance(index, int) + assert isinstance(index, Integral) if internal is None: raise Exception("internal must be set if index is set") assert index <= self._index_cache[mixdepth][int_type] @@ -1164,7 +1165,7 @@ class BIP32Wallet(BaseWallet): @classmethod def _harden_path_level(cls, lvl): - assert isinstance(lvl, int) + assert isinstance(lvl, Integral) if not 0 <= lvl < cls.BIP32_MAX_PATH_LEVEL: raise WalletError("Unable to derive hardened path level from {}." "".format(lvl)) @@ -1172,7 +1173,7 @@ class BIP32Wallet(BaseWallet): @classmethod def _path_level_to_repr(cls, lvl): - assert isinstance(lvl, int) + assert isinstance(lvl, Integral) if not 0 <= lvl < cls.BIP32_MAX_PATH_LEVEL * 2: raise WalletError("Invalid path level {}.".format(lvl)) if lvl < cls.BIP32_MAX_PATH_LEVEL: diff --git a/jmclient/jmclient/wallet_utils.py b/jmclient/jmclient/wallet_utils.py index 68ae484..fba6e40 100644 --- a/jmclient/jmclient/wallet_utils.py +++ b/jmclient/jmclient/wallet_utils.py @@ -6,6 +6,7 @@ import sqlite3 import binascii from datetime import datetime from optparse import OptionParser +from numbers import Integral from jmclient import (get_network, WALLET_IMPLEMENTATIONS, Storage, podle, jm_single, BitcoinCoreInterface, JsonRpcError, sync_wallet, WalletError, VolatileStorage, StoragePasswordError, @@ -167,7 +168,7 @@ class WalletViewEntry(WalletViewBase): self.account = account assert forchange in [0, 1, -1] self.forchange =forchange - assert isinstance(aindex, int) + assert isinstance(aindex, Integral) assert aindex >= 0 self.aindex = aindex self.address = addr diff --git a/jmdaemon/jmdaemon/daemon_protocol.py b/jmdaemon/jmdaemon/daemon_protocol.py index 1997d93..fc91d79 100644 --- a/jmdaemon/jmdaemon/daemon_protocol.py +++ b/jmdaemon/jmdaemon/daemon_protocol.py @@ -23,6 +23,7 @@ import threading import os import copy from functools import wraps +from numbers import Integral """Joinmarket application protocol control flow. For documentation on protocol (formats, message sequence) see @@ -228,9 +229,10 @@ class JMDaemonServerProtocol(amp.AMP, OrderbookWatch): @JMFill.responder def on_JM_FILL(self, amount, commitment, revelation, filled_offers): """Takes the necessary data from the Taker and initiates the Stage 1 - interaction with the Makers. - """ - if not (self.jm_state == 1 and isinstance(amount, int) and amount >=0): + interaction with the Makers. + """ + if not (self.jm_state == 1 and isinstance(amount, Integral) + and amount >= 0): return {'accepted': False} self.cjamount = amount self.commitment = commitment diff --git a/jmdaemon/jmdaemon/orderbookwatch.py b/jmdaemon/jmdaemon/orderbookwatch.py index fae9380..3e48e55 100644 --- a/jmdaemon/jmdaemon/orderbookwatch.py +++ b/jmdaemon/jmdaemon/orderbookwatch.py @@ -10,6 +10,7 @@ import time import threading import json from decimal import InvalidOperation, Decimal +from numbers import Integral from jmdaemon.protocol import JM_VERSION from jmbase.support import get_log, joinmarket_alert, DUST_THRESHOLD @@ -95,7 +96,8 @@ class OrderbookWatch(object): "from {}").format log.debug(fmt(minsize, maxsize, counterparty)) return - if ordertype in ['swabsoffer', 'absoffer'] and not isinstance(cjfee, int): + if ordertype in ['swabsoffer', 'absoffer']\ + and not isinstance(cjfee, Integral): try: cjfee = int(cjfee) except ValueError: