Browse Source

Remove imports from future and past

master
roshii 2 years ago
parent
commit
4e5d894007
  1. 9
      jmclient/test/test_taker.py
  2. 3
      scripts/add-utxo.py
  3. 3
      scripts/joinmarket-qt.py
  4. 19
      scripts/obwatch/ob-watcher.py
  5. 5
      scripts/yg-privacyenhanced.py
  6. 1
      setupall.py

9
jmclient/test/test_taker.py

@ -1,4 +1,3 @@
from future.utils import iteritems
from commontest import DummyBlockchainInterface from commontest import DummyBlockchainInterface
import jmbitcoin as bitcoin import jmbitcoin as bitcoin
import binascii import binascii
@ -135,7 +134,7 @@ class DummyWallet(LegacyWallet):
""" """
for p in privs: for p in privs:
addrs[p] = BTC_P2PKH.privkey_to_address(p) addrs[p] = BTC_P2PKH.privkey_to_address(p)
for p, a in iteritems(addrs): for p, a in addrs.items():
if a == addr: if a == addr:
return p return p
raise ValueError("No such keypair") raise ValueError("No such keypair")
@ -437,7 +436,7 @@ def test_taker_init(setup_taker, schedule, highfee, toomuchcoins, minmakers,
return clean_up() return clean_up()
if schedule[0][1] == 199599800: if schedule[0][1] == 199599800:
#need to force negative fees to make this feasible #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' v['cjfee'] = '-0.002'
# change_amount = (total_input - self.cjamount - # change_amount = (total_input - self.cjamount -
# self.orderbook[nick]['txfee'] + real_cjfee) # 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; #TODO note this test is not adequate, because the code is not;
#the code does not *DO* anything if a condition is unexpected. #the code does not *DO* anything if a condition is unexpected.
taker.input_utxos = copy.deepcopy(t_utxos_by_mixdepth)[0] 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"]) v["value"] = int(0.999805228 * v["value"])
res = taker.receive_utxos(maker_response) res = taker.receive_utxos(maker_response)
assert res[0] assert res[0]
@ -464,7 +463,7 @@ def test_taker_init(setup_taker, schedule, highfee, toomuchcoins, minmakers,
if schedule[0][3] == "mteaYsGsLCL9a4cftZFTpGEWXNwZyDt5KS": if schedule[0][3] == "mteaYsGsLCL9a4cftZFTpGEWXNwZyDt5KS":
# as above, but small -ve change instead of +ve. # as above, but small -ve change instead of +ve.
taker.input_utxos = copy.deepcopy(t_utxos_by_mixdepth)[0] 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"]) v["value"] = int(0.999805028 * v["value"])
res = taker.receive_utxos(maker_response) res = taker.receive_utxos(maker_response)
assert res[0] assert res[0]

3
scripts/add-utxo.py

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from future.utils import iteritems
"""A very simple command line tool to import utxos to be used """A very simple command line tool to import utxos to be used
as commitments into joinmarket's commitments.json file, allowing as commitments into joinmarket's commitments.json file, allowing
users to retry transactions more often without getting banned by users to retry transactions more often without getting banned by
@ -207,7 +206,7 @@ def main():
except: except:
jmprint("Failed to read json from " + options.in_json, "error") jmprint("Failed to read json from " + options.in_json, "error")
sys.exit(EXIT_FAILURE) 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"]]), utxobin, priv = get_utxo_info(",".join([u, pva["privkey"]]),
utxo_binary=True) utxo_binary=True)
if not utxobin: if not utxobin:

3
scripts/joinmarket-qt.py

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from future.utils import iteritems
from typing import Optional from typing import Optional
''' '''
@ -993,7 +992,7 @@ class SpendTab(QWidget):
mbinfo.append(" ") mbinfo.append(" ")
mbinfo.append("Counterparties chosen:") mbinfo.append("Counterparties chosen:")
mbinfo.append('Name, Order id, Coinjoin fee (sat.)') 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']: if o['ordertype'] in ['sw0reloffer', 'swreloffer', 'reloffer']:
display_fee = int(self.taker.cjamount * display_fee = int(self.taker.cjamount *
float(o['cjfee'])) - int(o['txfee']) float(o['cjfee'])) - int(o['txfee'])

19
scripts/obwatch/ob-watcher.py

@ -1,6 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from future.utils import iteritems
from past.builtins import cmp
from functools import cmp_to_key from functools import cmp_to_key
import http.server import http.server
@ -12,7 +10,7 @@ import time
import hashlib import hashlib
import os import os
import sys import sys
from future.moves.urllib.parse import parse_qs from urllib.parse import parse_qs
from decimal import Decimal from decimal import Decimal
from optparse import OptionParser from optparse import OptionParser
from twisted.internet import reactor from twisted.internet import reactor
@ -549,12 +547,19 @@ class OrderbookPageRequestHeader(http.server.SimpleHTTPRequestHandler):
('maxsize', satoshi_to_unit), ('maxsize', satoshi_to_unit),
('bondvalue', do_nothing)) ('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): def orderby_cmp(x, y):
if x['ordertype'] == y['ordertype']: if x['ordertype'] == y['ordertype']:
return cmp(Decimal(x['cjfee']), Decimal(y['cjfee'])) return _cmp(Decimal(x['cjfee']), Decimal(y['cjfee']))
return cmp(offername_list.index(x['ordertype']), return _cmp(offername_list.index(x['ordertype']),
offername_list.index(y['ordertype'])) offername_list.index(y['ordertype']))
for o in sorted(rows, key=cmp_to_key(orderby_cmp)): for o in sorted(rows, key=cmp_to_key(orderby_cmp)):
@ -665,7 +670,7 @@ class OrderbookPageRequestHeader(http.server.SimpleHTTPRequestHandler):
replacements = {} replacements = {}
orderbook_fmt = json.dumps(self.create_orderbook_obj()) orderbook_fmt = json.dumps(self.create_orderbook_obj())
orderbook_page = orderbook_fmt orderbook_page = orderbook_fmt
for key, rep in iteritems(replacements): for key, rep in replacements.items():
orderbook_page = orderbook_page.replace(key, rep) orderbook_page = orderbook_page.replace(key, rep)
self.send_response(200) self.send_response(200)
if self.path.endswith('.json'): if self.path.endswith('.json'):

5
scripts/yg-privacyenhanced.py

@ -1,6 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from future.utils import iteritems
import random import random
import sys import sys
@ -54,8 +52,7 @@ class YieldGeneratorPrivacyEnhanced(YieldGeneratorBasic):
f = self.cjfee_r f = self.cjfee_r
elif self.ordertype in ['swabsoffer', 'sw0absoffer']: elif self.ordertype in ['swabsoffer', 'sw0absoffer']:
f = str(self.txfee_contribution + self.cjfee_a) f = str(self.txfee_contribution + self.cjfee_a)
mix_balance = dict([(m, b) for m, b in iteritems(mix_balance) mix_balance = dict([(m, b) for m, b in mix_balance.items() if b > self.minsize])
if b > self.minsize])
if len(mix_balance) == 0: if len(mix_balance) == 0:
jlog.error('You do not have the minimum required amount of coins' jlog.error('You do not have the minimum required amount of coins'
' to be a maker: ' + str(self.minsize) + \ ' to be a maker: ' + str(self.minsize) + \

1
setupall.py

@ -1,5 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python
from __future__ import print_function
import sys, os, subprocess import sys, os, subprocess
"""A script to install in one of 3 modes: """A script to install in one of 3 modes:

Loading…
Cancel
Save