mirror of
https://github.com/JoinMarket-Org/joinmarket-clientserver.git
synced 2026-08-13 12:33:40 +02:00
fix int assertions
This commit is contained in:
parent
c032e46273
commit
59a998fda0
5 changed files with 18 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue