From aecc7c664389058072df7875254b9baa1b4a5967 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Sun, 15 Jul 2018 15:23:31 -0400 Subject: [PATCH] resolve works in py3!!!!!11111oneoneone --- lbrynet/wallet/claim_proofs.py | 6 +++--- lbrynet/wallet/resolve.py | 8 ++++---- tests/integration/wallet/test_transactions.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lbrynet/wallet/claim_proofs.py b/lbrynet/wallet/claim_proofs.py index d950b5abe..80c9e218c 100644 --- a/lbrynet/wallet/claim_proofs.py +++ b/lbrynet/wallet/claim_proofs.py @@ -17,7 +17,7 @@ def height_to_vch(n): # need to reset each value mod 256 because for values like 67784 # 67784 >> 8 = 264, which is obviously larger then the maximum # value input into chr() - return ''.join([chr(x % 256) for x in r]) + return b''.join([six.int2byte(x % 256) for x in r]) def get_hash_for_outpoint(txhash, nOut, nHeightOfLastTakeover): @@ -31,7 +31,7 @@ def get_hash_for_outpoint(txhash, nOut, nHeightOfLastTakeover): # noinspection PyPep8 def verify_proof(proof, rootHash, name): previous_computed_hash = None - reverse_computed_name = b'' + reverse_computed_name = '' verified_value = False for i, node in enumerate(proof['nodes'][::-1]): found_child_in_chain = False @@ -55,7 +55,7 @@ def verify_proof(proof, rootHash, name): if found_child_in_chain is True: raise InvalidProofError("already found the next child in the chain") found_child_in_chain = True - reverse_computed_name += six.int2byte(child['character']) + reverse_computed_name += chr(child['character']) to_hash += previous_computed_hash if not found_child_in_chain: diff --git a/lbrynet/wallet/resolve.py b/lbrynet/wallet/resolve.py index cf31a2343..b3c5e14b5 100644 --- a/lbrynet/wallet/resolve.py +++ b/lbrynet/wallet/resolve.py @@ -1,7 +1,7 @@ import logging from ecdsa import BadSignatureError -from binascii import unhexlify +from binascii import unhexlify, hexlify from twisted.internet import defer @@ -287,7 +287,7 @@ class Resolver(object): def format_amount_value(obj): COIN = 100000000 if isinstance(obj, dict): - for k, v in obj.iteritems(): + for k, v in obj.items(): if k == 'amount' or k == 'effective_amount': if not isinstance(obj[k], float): obj[k] = float(obj[k]) / float(COIN) @@ -324,7 +324,7 @@ def _verify_proof(name, claim_trie_root, result, height, depth, transaction_clas claim_sequence, claim_address, supports): r = { 'name': name, - 'value': value.encode('hex'), + 'value': hexlify(value), 'claim_id': claim_id, 'txid': txid, 'nout': n, @@ -353,7 +353,7 @@ def _verify_proof(name, claim_trie_root, result, height, depth, transaction_clas claim_id = result['claim_id'] claim_sequence = result['claim_sequence'] claim_script = claim_output.script - decoded_name, decoded_value = claim_script.values['claim_name'], claim_script.values['claim'] + decoded_name, decoded_value = claim_script.values['claim_name'].decode(), claim_script.values['claim'] if decoded_name == name: return _build_response(name, decoded_value, claim_id, tx.id, nOut, claim_output.amount, diff --git a/tests/integration/wallet/test_transactions.py b/tests/integration/wallet/test_transactions.py index b2e2afe23..cfa3993b8 100644 --- a/tests/integration/wallet/test_transactions.py +++ b/tests/integration/wallet/test_transactions.py @@ -78,7 +78,7 @@ class BasicTransactionTest(IntegrationTestCase): self.assertEqual(round(await d2f(self.account.get_balance(0))/COIN, 1), 8.0) self.assertEqual(round(await d2f(self.account.get_balance(0, True))/COIN, 1), 10.0) - response = await d2f(self.ledger.resolve(0, 5, 'lbry://@bar/foo')) + response = await d2f(self.ledger.resolve(0, 10, 'lbry://@bar/foo')) self.assertIn('lbry://@bar/foo', response) abandon_tx = await d2f(Transaction.abandon(claim_tx.outputs[0], [self.account], self.account))