for victor

This commit is contained in:
Lex Berezhny 2019-03-20 17:31:00 -04:00
parent 2bea0f697a
commit e74998209d
3 changed files with 7 additions and 2 deletions

View file

@ -4,6 +4,7 @@ from binascii import hexlify
from datetime import datetime from datetime import datetime
from json import JSONEncoder from json import JSONEncoder
from ecdsa import BadSignatureError from ecdsa import BadSignatureError
from lbrynet.schema.claim import Claim
from lbrynet.wallet.ledger import MainNetLedger from lbrynet.wallet.ledger import MainNetLedger
from lbrynet.wallet.transaction import Transaction, Output from lbrynet.wallet.transaction import Transaction, Output
from lbrynet.wallet.dewies import dewies_to_lbc from lbrynet.wallet.dewies import dewies_to_lbc
@ -23,6 +24,8 @@ class JSONResponseEncoder(JSONEncoder):
return self.encode_transaction(obj) return self.encode_transaction(obj)
if isinstance(obj, Output): if isinstance(obj, Output):
return self.encode_output(obj) return self.encode_output(obj)
if isinstance(obj, Claim):
return obj.to_dict()
if isinstance(obj, datetime): if isinstance(obj, datetime):
return obj.strftime("%Y%m%dT%H:%M:%S") return obj.strftime("%Y%m%dT%H:%M:%S")
if isinstance(obj, Decimal): if isinstance(obj, Decimal):

View file

@ -167,7 +167,7 @@ class Resolver:
if not raw: if not raw:
claim_value = claim_result['value'] claim_value = claim_result['value']
try: try:
decoded = claim_result['value'] = Claim.from_bytes(claim_value) decoded = claim_result['value'] = Claim.from_bytes(unhexlify(claim_value))
claim_result['decoded_claim'] = True claim_result['decoded_claim'] = True
except DecodeError: except DecodeError:
pass pass
@ -427,6 +427,7 @@ def _decode_claim_result(claim):
claim['error'] = "Failed to parse: missing value." + backend_message claim['error'] = "Failed to parse: missing value." + backend_message
return claim return claim
try: try:
if not isinstance(claim['value'], Claim):
claim['value'] = Claim.from_bytes(claim['value']) claim['value'] = Claim.from_bytes(claim['value'])
claim['hex'] = hexlify(claim['value'].to_bytes()) claim['hex'] = hexlify(claim['value'].to_bytes())
except DecodeError: except DecodeError:

View file

@ -122,6 +122,7 @@ class Output(BaseOutput):
])) ]))
private_key = ecdsa.SigningKey.from_pem(channel.private_key, hashfunc=hashlib.sha256) private_key = ecdsa.SigningKey.from_pem(channel.private_key, hashfunc=hashlib.sha256)
self.claim.signature = private_key.sign_digest_deterministic(digest, hashfunc=hashlib.sha256) self.claim.signature = private_key.sign_digest_deterministic(digest, hashfunc=hashlib.sha256)
self.script.generate()
def generate_channel_private_key(self): def generate_channel_private_key(self):
private_key = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1, hashfunc=hashlib.sha256) private_key = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1, hashfunc=hashlib.sha256)