resolve works in py3!!!!!11111oneoneone
This commit is contained in:
parent
c5c1b62939
commit
aecc7c6643
3 changed files with 8 additions and 8 deletions
|
@ -17,7 +17,7 @@ def height_to_vch(n):
|
||||||
# need to reset each value mod 256 because for values like 67784
|
# need to reset each value mod 256 because for values like 67784
|
||||||
# 67784 >> 8 = 264, which is obviously larger then the maximum
|
# 67784 >> 8 = 264, which is obviously larger then the maximum
|
||||||
# value input into chr()
|
# 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):
|
def get_hash_for_outpoint(txhash, nOut, nHeightOfLastTakeover):
|
||||||
|
@ -31,7 +31,7 @@ def get_hash_for_outpoint(txhash, nOut, nHeightOfLastTakeover):
|
||||||
# noinspection PyPep8
|
# noinspection PyPep8
|
||||||
def verify_proof(proof, rootHash, name):
|
def verify_proof(proof, rootHash, name):
|
||||||
previous_computed_hash = None
|
previous_computed_hash = None
|
||||||
reverse_computed_name = b''
|
reverse_computed_name = ''
|
||||||
verified_value = False
|
verified_value = False
|
||||||
for i, node in enumerate(proof['nodes'][::-1]):
|
for i, node in enumerate(proof['nodes'][::-1]):
|
||||||
found_child_in_chain = False
|
found_child_in_chain = False
|
||||||
|
@ -55,7 +55,7 @@ def verify_proof(proof, rootHash, name):
|
||||||
if found_child_in_chain is True:
|
if found_child_in_chain is True:
|
||||||
raise InvalidProofError("already found the next child in the chain")
|
raise InvalidProofError("already found the next child in the chain")
|
||||||
found_child_in_chain = True
|
found_child_in_chain = True
|
||||||
reverse_computed_name += six.int2byte(child['character'])
|
reverse_computed_name += chr(child['character'])
|
||||||
to_hash += previous_computed_hash
|
to_hash += previous_computed_hash
|
||||||
|
|
||||||
if not found_child_in_chain:
|
if not found_child_in_chain:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from ecdsa import BadSignatureError
|
from ecdsa import BadSignatureError
|
||||||
from binascii import unhexlify
|
from binascii import unhexlify, hexlify
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ class Resolver(object):
|
||||||
def format_amount_value(obj):
|
def format_amount_value(obj):
|
||||||
COIN = 100000000
|
COIN = 100000000
|
||||||
if isinstance(obj, dict):
|
if isinstance(obj, dict):
|
||||||
for k, v in obj.iteritems():
|
for k, v in obj.items():
|
||||||
if k == 'amount' or k == 'effective_amount':
|
if k == 'amount' or k == 'effective_amount':
|
||||||
if not isinstance(obj[k], float):
|
if not isinstance(obj[k], float):
|
||||||
obj[k] = float(obj[k]) / float(COIN)
|
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):
|
claim_sequence, claim_address, supports):
|
||||||
r = {
|
r = {
|
||||||
'name': name,
|
'name': name,
|
||||||
'value': value.encode('hex'),
|
'value': hexlify(value),
|
||||||
'claim_id': claim_id,
|
'claim_id': claim_id,
|
||||||
'txid': txid,
|
'txid': txid,
|
||||||
'nout': n,
|
'nout': n,
|
||||||
|
@ -353,7 +353,7 @@ def _verify_proof(name, claim_trie_root, result, height, depth, transaction_clas
|
||||||
claim_id = result['claim_id']
|
claim_id = result['claim_id']
|
||||||
claim_sequence = result['claim_sequence']
|
claim_sequence = result['claim_sequence']
|
||||||
claim_script = claim_output.script
|
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:
|
if decoded_name == name:
|
||||||
return _build_response(name, decoded_value, claim_id,
|
return _build_response(name, decoded_value, claim_id,
|
||||||
tx.id, nOut, claim_output.amount,
|
tx.id, nOut, claim_output.amount,
|
||||||
|
|
|
@ -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))/COIN, 1), 8.0)
|
||||||
self.assertEqual(round(await d2f(self.account.get_balance(0, True))/COIN, 1), 10.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)
|
self.assertIn('lbry://@bar/foo', response)
|
||||||
|
|
||||||
abandon_tx = await d2f(Transaction.abandon(claim_tx.outputs[0], [self.account], self.account))
|
abandon_tx = await d2f(Transaction.abandon(claim_tx.outputs[0], [self.account], self.account))
|
||||||
|
|
Loading…
Reference in a new issue