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

View file

@ -167,7 +167,7 @@ class Resolver:
if not raw:
claim_value = claim_result['value']
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
except DecodeError:
pass
@ -427,7 +427,8 @@ def _decode_claim_result(claim):
claim['error'] = "Failed to parse: missing value." + backend_message
return claim
try:
claim['value'] = Claim.from_bytes(claim['value'])
if not isinstance(claim['value'], Claim):
claim['value'] = Claim.from_bytes(claim['value'])
claim['hex'] = hexlify(claim['value'].to_bytes())
except DecodeError:
claim['hex'] = claim['value']

View file

@ -122,6 +122,7 @@ class Output(BaseOutput):
]))
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.script.generate()
def generate_channel_private_key(self):
private_key = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1, hashfunc=hashlib.sha256)