diff --git a/jmbase/setup.py b/jmbase/setup.py index e4e86ca91..d550d2d1a 100644 --- a/jmbase/setup.py +++ b/jmbase/setup.py @@ -9,7 +9,7 @@ author_email='', license='GPL', packages=['jmbase'], - install_requires=['future', 'twisted==19.7.0', 'service-identity', + install_requires=['twisted==19.7.0', 'service-identity', 'chromalog==1.0.5'], python_requires='>=3.3', zip_safe=False) diff --git a/jmbitcoin/jmbitcoin/secp256k1_ecies.py b/jmbitcoin/jmbitcoin/secp256k1_ecies.py index 9d928baa7..8e821088b 100644 --- a/jmbitcoin/jmbitcoin/secp256k1_ecies.py +++ b/jmbitcoin/jmbitcoin/secp256k1_ecies.py @@ -1,8 +1,5 @@ #!/usr/bin/python -from __future__ import (absolute_import, division, - print_function, unicode_literals) -from builtins import * # noqa: F401 -from future.utils import native + import coincurve as secp256k1 import base64 import hmac @@ -19,7 +16,7 @@ class ECIESDecryptionError(Exception): # AES primitives. See BIP-SNICKER for specification. def aes_encrypt(key, data, iv): encrypter = pyaes.Encrypter( - pyaes.AESModeOfOperationCBC(key, iv=native(iv))) + pyaes.AESModeOfOperationCBC(key, iv=iv)) enc_data = encrypter.feed(data) enc_data += encrypter.feed() @@ -27,7 +24,7 @@ def aes_encrypt(key, data, iv): def aes_decrypt(key, data, iv): decrypter = pyaes.Decrypter( - pyaes.AESModeOfOperationCBC(key, iv=native(iv))) + pyaes.AESModeOfOperationCBC(key, iv=iv)) try: dec_data = decrypter.feed(data) dec_data += decrypter.feed() diff --git a/jmbitcoin/jmbitcoin/secp256k1_main.py b/jmbitcoin/jmbitcoin/secp256k1_main.py index 197809fe6..44fdd3960 100644 --- a/jmbitcoin/jmbitcoin/secp256k1_main.py +++ b/jmbitcoin/jmbitcoin/secp256k1_main.py @@ -1,5 +1,4 @@ #!/usr/bin/python -from future.utils import native_bytes, bytes_to_native_str import binascii import hashlib import sys @@ -60,7 +59,7 @@ def privkey_to_pubkey(priv): and return compressed/uncompressed public key as appropriate.''' compressed, priv = read_privkey(priv) #secp256k1 checks for validity of key value. - newpriv = secp256k1.PrivateKey(secret=native_bytes(priv)) + newpriv = secp256k1.PrivateKey(secret=priv) return newpriv.public_key.format(compressed) # b58check wrapper functions around bitcointx.base58 functions: @@ -137,7 +136,7 @@ def multiply(s, pub, return_serialized=True): ''' newpub = secp256k1.PublicKey(pub) #see note to "tweak_mul" function in podle.py - res = newpub.multiply(native_bytes(s)) + res = newpub.multiply(s) if not return_serialized: return res return res.format() diff --git a/jmbitcoin/jmbitcoin/snicker.py b/jmbitcoin/jmbitcoin/snicker.py index 5c6be9493..76114795e 100644 --- a/jmbitcoin/jmbitcoin/snicker.py +++ b/jmbitcoin/jmbitcoin/snicker.py @@ -1,7 +1,3 @@ -from __future__ import (absolute_import, division, - print_function, unicode_literals) -from builtins import * # noqa: F401 - # Implementation of proposal as per # https://gist.github.com/AdamISZ/2c13fb5819bd469ca318156e2cf25d79 # (BIP SNICKER) diff --git a/jmbitcoin/setup.py b/jmbitcoin/setup.py index b576855ee..ef4b61de7 100644 --- a/jmbitcoin/setup.py +++ b/jmbitcoin/setup.py @@ -9,6 +9,5 @@ author_email='', license='GPL', packages=['jmbitcoin'], - install_requires=['future', 'coincurve', 'urldecode', - 'python-bitcointx>=1.0.5', 'pyaes'], + install_requires=['coincurve', 'python-bitcointx>=1.0.5', 'pyaes', 'urldecode'], zip_safe=False) diff --git a/jmbitcoin/test/test_ecdh.py b/jmbitcoin/test/test_ecdh.py index c417c462b..5988385b1 100644 --- a/jmbitcoin/test/test_ecdh.py +++ b/jmbitcoin/test/test_ecdh.py @@ -1,7 +1,4 @@ #! /usr/bin/env python -from __future__ import (absolute_import, division, - print_function, unicode_literals) -from builtins import * # noqa: F401 '''Tests coincurve binding to libsecp256k1 ecdh module code''' import hashlib diff --git a/jmbitcoin/test/test_ecies.py b/jmbitcoin/test/test_ecies.py index 4a529c5c3..a34e58371 100644 --- a/jmbitcoin/test/test_ecies.py +++ b/jmbitcoin/test/test_ecies.py @@ -1,7 +1,4 @@ #! /usr/bin/env python -from __future__ import (absolute_import, division, - print_function, unicode_literals) -from builtins import * # noqa: F401 '''Tests ECIES implementation as defined in BIP-SNICKER (and will be updated if that is).''' diff --git a/jmclient/jmclient/client_protocol.py b/jmclient/jmclient/client_protocol.py index 9711d9b0d..8a2a70f0b 100644 --- a/jmclient/jmclient/client_protocol.py +++ b/jmclient/jmclient/client_protocol.py @@ -1,5 +1,4 @@ #! /usr/bin/env python -from future.utils import iteritems from twisted.internet import protocol, reactor, task from twisted.internet.error import (ConnectionLost, ConnectionAborted, ConnectionClosed, ConnectionDone) @@ -303,7 +302,7 @@ def on_JM_TX_RECEIVED(self, nick, txhex, offer): return {"accepted": True} def tx_match(self, txd): - for k,v in iteritems(self.finalized_offers): + for k,v in items(self.finalized_offers): # Tx considered defined by its output set if v["txd"].vout == txd.vout: offerinfo = v diff --git a/jmclient/jmclient/electruminterface.py b/jmclient/jmclient/electruminterface.py index 6327a9884..773d83042 100644 --- a/jmclient/jmclient/electruminterface.py +++ b/jmclient/jmclient/electruminterface.py @@ -1,4 +1,3 @@ -from future.utils import iteritems import jmbitcoin as btc import json import queue as Queue @@ -332,7 +331,7 @@ def sync_unspent(self, wallet): for m in range(wallet.max_mixdepth): for fc in [0, 1]: branch_list = [] - for k, v in iteritems(self.temp_addr_history[m][fc]): + for k, v in self.temp_addr_history[m][fc].items(): if k == "finished": continue if v["used"]: diff --git a/jmclient/jmclient/maker.py b/jmclient/jmclient/maker.py index 8ae48342c..ef7d3ca09 100644 --- a/jmclient/jmclient/maker.py +++ b/jmclient/jmclient/maker.py @@ -1,5 +1,4 @@ #! /usr/bin/env python -from future.utils import iteritems import base64 import pprint import random @@ -470,7 +469,7 @@ def on_tx_received(self, nick, txser): [x[1] for x in utxo.values()]) total_sender_input = 0 - for i, u in iteritems(utxo): + for i, u in utxo.items(): if utxo_data[i] is None: return (False, "Proposed transaction contains invalid utxos") total_sender_input += utxo_data[i]["value"] @@ -505,7 +504,7 @@ def on_tx_received(self, nick, txser): # Manual verification of the transaction signatures. # TODO handle native segwit properly - for i, u in iteritems(utxo): + for i, u in utxo.items(): if not btc.verify_tx_input(tx, i, tx.vin[i].scriptSig, btc.CScript(utxo_data[i]["script"]), diff --git a/jmclient/jmclient/snicker_receiver.py b/jmclient/jmclient/snicker_receiver.py index 8d9106708..c297dc4e0 100644 --- a/jmclient/jmclient/snicker_receiver.py +++ b/jmclient/jmclient/snicker_receiver.py @@ -1,7 +1,4 @@ #! /usr/bin/env python -from __future__ import (absolute_import, division, - print_function, unicode_literals) -from builtins import * # noqa: F401 import sys import binascii diff --git a/jmclient/jmclient/storage.py b/jmclient/jmclient/storage.py index 34d969d97..1989979e0 100644 --- a/jmclient/jmclient/storage.py +++ b/jmclient/jmclient/storage.py @@ -1,5 +1,3 @@ -from future.utils import native - import os import shutil import atexit @@ -253,7 +251,7 @@ def _decrypt_file(self, password, data): def _encrypt(self, data, iv): encrypter = pyaes.Encrypter( - pyaes.AESModeOfOperationCBC(self._hash.hash, iv=native(iv))) + pyaes.AESModeOfOperationCBC(self._hash.hash, iv=iv)) enc_data = encrypter.feed(self.MAGIC_DETECT_ENC + data) enc_data += encrypter.feed() @@ -261,7 +259,7 @@ def _encrypt(self, data, iv): def _decrypt(self, data, iv): decrypter = pyaes.Decrypter( - pyaes.AESModeOfOperationCBC(self._hash.hash, iv=native(iv))) + pyaes.AESModeOfOperationCBC(self._hash.hash, iv=iv)) try: dec_data = decrypter.feed(data) dec_data += decrypter.feed() diff --git a/jmclient/jmclient/taker.py b/jmclient/jmclient/taker.py index 9ee185ac4..436ded7eb 100644 --- a/jmclient/jmclient/taker.py +++ b/jmclient/jmclient/taker.py @@ -1,5 +1,4 @@ #! /usr/bin/env python -from future.utils import iteritems import base64 import pprint @@ -354,7 +353,7 @@ def receive_utxos(self, ioauth_data): rejected_counterparties = [] #Need to authorize against the btc pubkey first. - for nick, nickdata in iteritems(ioauth_data): + for nick, nickdata in ioauth_data.items(): utxo_list, auth_pub, cj_addr, change_addr, btc_sig, maker_pk = nickdata if not self.auth_counterparty(btc_sig, auth_pub, maker_pk): jlog.debug( @@ -374,7 +373,7 @@ def receive_utxos(self, ioauth_data): self.maker_utxo_data = {} - for nick, nickdata in iteritems(ioauth_data): + for nick, nickdata in ioauth_data.items(): utxo_list, auth_pub, cj_addr, change_addr, _, _ = nickdata utxo_data = jm_single().bc_interface.query_utxo_set(utxo_list) self.utxos[nick] = utxo_list @@ -452,8 +451,7 @@ def receive_utxos(self, ioauth_data): #used to track return of signatures for phase 2 self.nonrespondants = list(self.maker_utxo_data.keys()) - my_total_in = sum([va['value'] for u, va in iteritems(self.input_utxos) - ]) + my_total_in = sum([va['value'] for u, va in self.input_utxos.items()]) if self.my_change_addr: #Estimate fee per choice of next/3/6 blocks targetting. estimated_fee = estimate_tx_fee( @@ -559,7 +557,7 @@ def on_sig(self, nick, sigb64): utxo_data = jm_single().bc_interface.query_utxo_set([x[ 1] for x in utxo.values()]) # insert signatures - for i, u in iteritems(utxo): + for i, u in utxo.items(): if utxo_data[i] is None: continue # Check if the sender included the scriptCode in the sig message; @@ -698,7 +696,7 @@ def priv_utxo_pairs_from_utxos(utxos, age, amt): new_utxos, too_old, too_small = filter_by_coin_age_amt(list(utxos.keys()), age, amt) new_utxos_dict = {k: v for k, v in utxos.items() if k in new_utxos} - for k, v in iteritems(new_utxos_dict): + for k, v in new_utxos_dict.items(): addr = self.wallet_service.script_to_addr(v["script"]) priv = self.wallet_service.get_key_from_addr(addr) if priv: #can be null from create-unsigned @@ -985,7 +983,7 @@ def receive_utxos(self, ioauth_data): # use output destination self.my_cj_addr and use amount self.amount self.outputs.append({'address': self.my_cj_addr, 'value': self.cjamount}) - my_total_in = sum([va['value'] for u, va in iteritems(self.input_utxos)]) + my_total_in = sum([va['value'] for u, va in self.input_utxos.items()]) # estimate the fee for the version of the transaction which is # not coinjoined: est_fee = estimate_tx_fee(len(self.input_utxos), 2, @@ -1137,7 +1135,7 @@ def on_tx_received(self, nick, txser): # Next we'll verify each of the counterparty's inputs, # while at the same time gathering the total they spent. total_receiver_input = 0 - for i, u in iteritems(retrieve_utxos): + for i, u in retrieve_utxos.items(): if utxo_data[i] is None: return (False, "Proposed transaction contains invalid utxos") total_receiver_input += utxo_data[i]["value"] diff --git a/jmclient/jmclient/taker_utils.py b/jmclient/jmclient/taker_utils.py index 6f5c72798..37afaf28e 100644 --- a/jmclient/jmclient/taker_utils.py +++ b/jmclient/jmclient/taker_utils.py @@ -1,4 +1,3 @@ -from future.utils import iteritems import logging import pprint import os @@ -81,8 +80,7 @@ def direct_send(wallet_service, amount, mixdepth, destination, answeryes=False, log.error( "There are no available utxos in mixdepth: " + str(mixdepth) + ", quitting.") return - - total_inputs_val = sum([va['value'] for u, va in iteritems(utxos)]) + total_inputs_val = sum([va['value'] for u, va in utxos.items()]) if is_burn_destination(destination): if len(utxos) > 1: @@ -116,7 +114,7 @@ def direct_send(wallet_service, amount, mixdepth, destination, answeryes=False, fee_est = estimate_tx_fee(len(utxos), 2, txtype=txtype) else: fee_est = initial_fee_est - total_inputs_val = sum([va['value'] for u, va in iteritems(utxos)]) + total_inputs_val = sum([va['value'] for u, va in utxos.items()]) changeval = total_inputs_val - fee_est - amount outs = [{"value": amount, "address": destination}] change_addr = wallet_service.get_internal_addr(mixdepth) diff --git a/jmclient/jmclient/wallet_utils.py b/jmclient/jmclient/wallet_utils.py index 2681f8948..7eb58280c 100644 --- a/jmclient/jmclient/wallet_utils.py +++ b/jmclient/jmclient/wallet_utils.py @@ -1,4 +1,3 @@ -from future.utils import iteritems import json import os import sys @@ -382,7 +381,7 @@ def wallet_showutxos(wallet, showprivkey): unsp[us]['privkey'] = wallet.get_wif_path(av['path']) used_commitments, external_commitments = podle.get_podle_commitments() - for u, ec in iteritems(external_commitments): + for u, ec in external_commitments.items(): success, us = utxo_to_utxostr(u) assert success tries = podle.get_podle_tries(utxo=u, max_tries=max_tries, @@ -403,7 +402,7 @@ def wallet_display(wallet_service, showprivkey, displayall=False, def get_addr_status(addr_path, utxos, is_new, is_internal): addr_balance = 0 status = [] - for utxo, utxodata in iteritems(utxos): + for utxo, utxodata in utxos.items(): if addr_path != utxodata['path']: continue addr_balance += utxodata['value'] @@ -864,7 +863,7 @@ def print_row(index, time, tx_type, amount, delta, balance, cj_n, amount = cj_amount delta_balance = out_value - our_input_value mixdepth_src = wallet.get_script_mixdepth(list(our_input_scripts)[0]) - cj_script = list(set([a for a, v in iteritems(output_script_values) + cj_script = list(set([a for a, v in output_script_values.items() if v == cj_amount]).intersection(our_output_scripts))[0] mixdepth_dst = wallet.get_script_mixdepth(cj_script) else: diff --git a/jmclient/jmclient/yieldgenerator.py b/jmclient/jmclient/yieldgenerator.py index f89af3604..b0a329939 100644 --- a/jmclient/jmclient/yieldgenerator.py +++ b/jmclient/jmclient/yieldgenerator.py @@ -1,5 +1,4 @@ #! /usr/bin/env python -from future.utils import iteritems import datetime import os @@ -78,7 +77,7 @@ def __init__(self, wallet_service, offerconfig): def create_my_orders(self): mix_balance = self.get_available_mixdepths() - if len([b for m, b in iteritems(mix_balance) if b > 0]) == 0: + if len([b for m, b in mix_balance.items() if b > 0]) == 0: jlog.error('do not have any coins left') return [] @@ -115,7 +114,7 @@ def oid_to_order(self, offer, amount): mix_balance = self.get_available_mixdepths() filtered_mix_balance = {m: b - for m, b in iteritems(mix_balance) + for m, b in mix_balance.items() if b >= total_amount} if not filtered_mix_balance: return None, None, None @@ -177,7 +176,7 @@ def select_input_mixdepth(self, available, offer, amount): inputs. available is a mixdepth/balance dict of all the mixdepths that can be chosen from, i.e. have enough balance. If there is no suitable input, the function can return None to abort the order.""" - available = sorted(iteritems(available), key=lambda entry: entry[0]) + available = sorted(available.items(), key=lambda entry: entry[0]) return available[0][0] def select_output_address(self, input_mixdepth, offer, amount): diff --git a/jmclient/setup.py b/jmclient/setup.py index dbd5187ee..cf18836de 100644 --- a/jmclient/setup.py +++ b/jmclient/setup.py @@ -9,7 +9,7 @@ author_email='', license='GPL', packages=['jmclient'], - install_requires=['future', 'configparser;python_version<"3.2"', + install_requires=['configparser;python_version<"3.2"', 'joinmarketbase==0.6.2', 'mnemonic', 'argon2_cffi', 'bencoder.pyx>=2.0.0', 'pyaes'], python_requires='>=3.3', diff --git a/jmclient/test/test_snicker.py b/jmclient/test/test_snicker.py index 8417a78b7..41f620734 100644 --- a/jmclient/test/test_snicker.py +++ b/jmclient/test/test_snicker.py @@ -1,9 +1,6 @@ #! /usr/bin/env python -from __future__ import (absolute_import, division, - print_function, unicode_literals) -from builtins import * # noqa: F401 -'''Test of unusual transaction types creation and push to -network to check validity.''' +'''Test of SNICKER functionality using Joinmarket + wallets as defined in jmclient.wallet.''' import binascii from commontest import make_wallets, dummy_accept_callback, dummy_info_callback diff --git a/jmdaemon/jmdaemon/daemon_protocol.py b/jmdaemon/jmdaemon/daemon_protocol.py index 920e5e004..f6e754432 100644 --- a/jmdaemon/jmdaemon/daemon_protocol.py +++ b/jmdaemon/jmdaemon/daemon_protocol.py @@ -1,5 +1,4 @@ #! /usr/bin/env python -from future.utils import iteritems from .message_channel import MessageChannelCollection from .orderbookwatch import OrderbookWatch @@ -239,7 +238,7 @@ def on_JM_FILL(self, amount, commitment, revelation, filled_offers): #Reset utxo data to null for this new transaction self.ioauth_data = {} self.active_orders = json.loads(filled_offers) - for nick, offer_dict in iteritems(self.active_orders): + for nick, offer_dict in self.active_orders.items(): offer_fill_msg = " ".join([str(offer_dict["oid"]), str(amount), self.kp.hex_pk().decode('ascii'), str(commitment)]) self.mcc.prepare_privmsg(nick, "fill", offer_fill_msg) diff --git a/jmdaemon/jmdaemon/irc.py b/jmdaemon/jmdaemon/irc.py index 9e75037ce..c91fb83a3 100644 --- a/jmdaemon/jmdaemon/irc.py +++ b/jmdaemon/jmdaemon/irc.py @@ -17,7 +17,6 @@ def wlog(*x): """Simplifier to add lists to the debug log """ def conv(s): - # note: this only works because of the future package if isinstance(s, str): return s elif isinstance(s, bytes): diff --git a/jmdaemon/jmdaemon/message_channel.py b/jmdaemon/jmdaemon/message_channel.py index 70cd1e639..a5cbe6cfa 100644 --- a/jmdaemon/jmdaemon/message_channel.py +++ b/jmdaemon/jmdaemon/message_channel.py @@ -1,5 +1,4 @@ #! /usr/bin/env python -from future.utils import iteritems import abc import base64 import binascii @@ -334,7 +333,7 @@ def fill_orders(self, nick_order_dict, cj_amount, taker_pubkey, commitment): """ for mc in self.available_channels(): filtered_nick_order_dict = {k: v - for k, v in iteritems(nick_order_dict) + for k, v in nick_order_dict.items() if mc == self.active_channels[k]} mc.fill_orders(filtered_nick_order_dict, cj_amount, taker_pubkey, commitment) @@ -370,7 +369,7 @@ def send_tx(self, nick_list, txhex): tx_nick_sets[self.active_channels[nick]] = [nick] else: tx_nick_sets[self.active_channels[nick]].append(nick) - for mc, nl in iteritems(tx_nick_sets): + for mc, nl in tx_nick_sets.items(): self.prepare_send_tx(mc, nl, txhex) def prepare_send_tx(self, mc, nick_list, txhex): @@ -824,7 +823,7 @@ def request_orderbook(self): # Taker callbacks def fill_orders(self, nick_order_dict, cj_amount, taker_pubkey, commitment): - for c, order in iteritems(nick_order_dict): + for c, order in nick_order_dict.items(): msg = str(order['oid']) + ' ' + str(cj_amount) + ' ' + taker_pubkey msg += ' ' + commitment self.privmsg(c, 'fill', msg) diff --git a/jmdaemon/setup.py b/jmdaemon/setup.py index 3ddeac609..4a2fe3413 100644 --- a/jmdaemon/setup.py +++ b/jmdaemon/setup.py @@ -9,6 +9,6 @@ author_email='', license='GPL', packages=['jmdaemon'], - install_requires=['future', 'txtorcon', 'pyopenssl', 'libnacl', 'joinmarketbase==0.6.2'], + install_requires=['txtorcon', 'pyopenssl', 'libnacl', 'joinmarketbase==0.6.2'], python_requires='>=3.3', zip_safe=False) diff --git a/jmdaemon/test/test_daemon_protocol.py b/jmdaemon/test/test_daemon_protocol.py index 321d548fd..cf82107c3 100644 --- a/jmdaemon/test/test_daemon_protocol.py +++ b/jmdaemon/test/test_daemon_protocol.py @@ -1,5 +1,4 @@ #! /usr/bin/env python -from future.utils import iteritems '''test daemon-protocol interfacae.''' from jmdaemon import MessageChannelCollection @@ -254,7 +253,7 @@ def on_JM_FILL(self, amount, commitment, revelation, filled_offers): "!push abcd abc def", "3", "4", str(list(tmpfo.keys())[0]), 6, 7, self.mcc.mchannels[0].hostid) #send "valid" onpubkey, onioauth messages - for k, v in iteritems(tmpfo): + for k, v in tmpfo.items(): reactor.callLater(1, self.on_pubkey, k, dummypub) reactor.callLater(2, self.on_ioauth, k, ['a', 'b'], "auth_pub", "cj_addr", "change_addr", "btc_sig")