diff --git a/jmclient/test/test_taker.py b/jmclient/test/test_taker.py index c475dc8..8d20a43 100644 --- a/jmclient/test/test_taker.py +++ b/jmclient/test/test_taker.py @@ -1,4 +1,3 @@ -from future.utils import iteritems from commontest import DummyBlockchainInterface import jmbitcoin as bitcoin import binascii @@ -135,7 +134,7 @@ class DummyWallet(LegacyWallet): """ for p in privs: addrs[p] = BTC_P2PKH.privkey_to_address(p) - for p, a in iteritems(addrs): + for p, a in addrs.items(): if a == addr: return p raise ValueError("No such keypair") @@ -437,7 +436,7 @@ def test_taker_init(setup_taker, schedule, highfee, toomuchcoins, minmakers, return clean_up() if schedule[0][1] == 199599800: #need to force negative fees to make this feasible - for k, v in iteritems(taker.orderbook): + for k, v in taker.orderbook.items(): v['cjfee'] = '-0.002' # change_amount = (total_input - self.cjamount - # self.orderbook[nick]['txfee'] + real_cjfee) @@ -456,7 +455,7 @@ def test_taker_init(setup_taker, schedule, highfee, toomuchcoins, minmakers, #TODO note this test is not adequate, because the code is not; #the code does not *DO* anything if a condition is unexpected. taker.input_utxos = copy.deepcopy(t_utxos_by_mixdepth)[0] - for k,v in iteritems(taker.input_utxos): + for k,v in taker.input_utxos.items(): v["value"] = int(0.999805228 * v["value"]) res = taker.receive_utxos(maker_response) assert res[0] @@ -464,7 +463,7 @@ def test_taker_init(setup_taker, schedule, highfee, toomuchcoins, minmakers, if schedule[0][3] == "mteaYsGsLCL9a4cftZFTpGEWXNwZyDt5KS": # as above, but small -ve change instead of +ve. taker.input_utxos = copy.deepcopy(t_utxos_by_mixdepth)[0] - for k,v in iteritems(taker.input_utxos): + for k,v in taker.input_utxos.items(): v["value"] = int(0.999805028 * v["value"]) res = taker.receive_utxos(maker_response) assert res[0] diff --git a/scripts/add-utxo.py b/scripts/add-utxo.py index 3675cb9..2c595e3 100755 --- a/scripts/add-utxo.py +++ b/scripts/add-utxo.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -from future.utils import iteritems """A very simple command line tool to import utxos to be used as commitments into joinmarket's commitments.json file, allowing users to retry transactions more often without getting banned by @@ -207,7 +206,7 @@ def main(): except: jmprint("Failed to read json from " + options.in_json, "error") sys.exit(EXIT_FAILURE) - for u, pva in iteritems(utxo_json): + for u, pva in utxo_json.items(): utxobin, priv = get_utxo_info(",".join([u, pva["privkey"]]), utxo_binary=True) if not utxobin: diff --git a/scripts/joinmarket-qt.py b/scripts/joinmarket-qt.py index f9151b7..3b3cefb 100755 --- a/scripts/joinmarket-qt.py +++ b/scripts/joinmarket-qt.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -from future.utils import iteritems from typing import Optional ''' @@ -993,7 +992,7 @@ class SpendTab(QWidget): mbinfo.append(" ") mbinfo.append("Counterparties chosen:") mbinfo.append('Name, Order id, Coinjoin fee (sat.)') - for k, o in iteritems(offers): + for k, o in offers.items(): if o['ordertype'] in ['sw0reloffer', 'swreloffer', 'reloffer']: display_fee = int(self.taker.cjamount * float(o['cjfee'])) - int(o['txfee']) diff --git a/scripts/obwatch/ob-watcher.py b/scripts/obwatch/ob-watcher.py index 2321ecf..72a4673 100755 --- a/scripts/obwatch/ob-watcher.py +++ b/scripts/obwatch/ob-watcher.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -from future.utils import iteritems -from past.builtins import cmp from functools import cmp_to_key import http.server @@ -12,7 +10,7 @@ import time import hashlib import os import sys -from future.moves.urllib.parse import parse_qs +from urllib.parse import parse_qs from decimal import Decimal from optparse import OptionParser from twisted.internet import reactor @@ -549,12 +547,19 @@ class OrderbookPageRequestHeader(http.server.SimpleHTTPRequestHandler): ('maxsize', satoshi_to_unit), ('bondvalue', do_nothing)) - # somewhat complex sorting to sort by cjfee but with swabsoffers on top + def _cmp(x, y): + if x < y: + return -1 + elif x > y: + return 1 + else: + return 0 + # somewhat complex sorting to sort by cjfee but with swabsoffers on top def orderby_cmp(x, y): if x['ordertype'] == y['ordertype']: - return cmp(Decimal(x['cjfee']), Decimal(y['cjfee'])) - return cmp(offername_list.index(x['ordertype']), + return _cmp(Decimal(x['cjfee']), Decimal(y['cjfee'])) + return _cmp(offername_list.index(x['ordertype']), offername_list.index(y['ordertype'])) for o in sorted(rows, key=cmp_to_key(orderby_cmp)): @@ -665,7 +670,7 @@ class OrderbookPageRequestHeader(http.server.SimpleHTTPRequestHandler): replacements = {} orderbook_fmt = json.dumps(self.create_orderbook_obj()) orderbook_page = orderbook_fmt - for key, rep in iteritems(replacements): + for key, rep in replacements.items(): orderbook_page = orderbook_page.replace(key, rep) self.send_response(200) if self.path.endswith('.json'): diff --git a/scripts/yg-privacyenhanced.py b/scripts/yg-privacyenhanced.py index d87bf55..4c4e840 100755 --- a/scripts/yg-privacyenhanced.py +++ b/scripts/yg-privacyenhanced.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -from future.utils import iteritems - import random import sys @@ -54,8 +52,7 @@ class YieldGeneratorPrivacyEnhanced(YieldGeneratorBasic): f = self.cjfee_r elif self.ordertype in ['swabsoffer', 'sw0absoffer']: f = str(self.txfee_contribution + self.cjfee_a) - mix_balance = dict([(m, b) for m, b in iteritems(mix_balance) - if b > self.minsize]) + mix_balance = dict([(m, b) for m, b in mix_balance.items() if b > self.minsize]) if len(mix_balance) == 0: jlog.error('You do not have the minimum required amount of coins' ' to be a maker: ' + str(self.minsize) + \ diff --git a/setupall.py b/setupall.py index c4db920..5808498 100644 --- a/setupall.py +++ b/setupall.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function import sys, os, subprocess """A script to install in one of 3 modes: